title: SQL error while getting data from table by 'type' column
body: <p>I want to group by date in single query but for different data. I have tried this so far :</p>
  <pre><code>$record_by_date = DB::select(&quot;SELECT SUM(amount) as 'amount', 
     cast(date as date) dateAdded  FROM expense_incomes WHERE (CASE WHEN 
     type='Expense' THEN 'Expense' WHEN type='Income' THEN 'Income' END AS Type) 
     GROUP BY cast(date as date)&quot;);
  </code></pre>
  <p>First is it correct way to do it? I am using CASE <br>
  Second, if it is correct way, I am getting error, how to solve this?
  <br></p>
  <blockquote>
  <p>SQLSTATE[42000]: Syntax error or access violation: 1064 You have an
  error in your  SQL syntax; check the manual that corresponds to your
  MariaDB server version for  the right syntax to use near 'AS <code>Type</code>)
  GROUP BY cast(date as date)' at line 1  (SQL: SELECT SUM(amount) as
  'amount', cast(date as date) dateAdded FROM  expense_incomes WHERE
  (CASE WHEN type='Expense' THEN 'Expense' WHEN type='Income'  THEN
  'Income' END AS <code>Type</code>) GROUP BY cast(date as date))</p>
  </blockquote>