Sunday, 8 July 2012

Group by month in SQLite


it is always good while you group by MONTH it should check YEAR also



select SUM(transaction) as Price, 
       DATE_FORMAT(transDate, "%m-%Y") as 'month-year' 
       from transaction group by DATE_FORMAT(transDate, "%m-%Y");
FOR SQLITE
select SUM(transaction) as Price, 
       strftime("%m-%Y", transDate) as 'month-year' 
       from transaction group by strftime("%m-%Y", transDate);
 
 
 
Price    month230        2
500        3
400        4
 

No comments:

Post a Comment