title: Group by a Substring mysql not working
body: <p>I want to use GROUP BY clause on a query in case IFF it's column TYPE contains [Sale], for that purpose I put the query below,</p>
  
  <pre><code>SELECT 
     PAYABLE_TYPE AS TYPE,
     CASE WHEN (SUBSTRING(PAYABLE_TYPE, 1,6) = '[Sale]') THEN PAYABLE_TYPE END AS T,
     PAYABLE_PARTICULAR AS PARTICULAR,
     DEBIT,
     CREDIT,
     PAYABLE_DATE AS DATE
  FROM PAYABLES
  WHERE PAYABLE_DATE &gt;= $P{DateStart} &amp;&amp; PAYABLE_DATE &lt;= $P{DateEnd}
  GROUP BY T
  </code></pre>
  
  <p>But it only returns me 2 lines at all, what I have is in the image below and the GREEN boxed line shows what I need to group. One more thing I need that grouped total to be sum up as well there. Thanks</p>
  
  <p><img src="https://i.stack.imgur.com/UnMOp.png" alt="enter image description here"></p>