Subversion Repositories MemberDirect

[/] [parsestatements/] [examples.sql] - Rev 3

Compare with Previous | Blame | View Log

/* Here are some sample MySQL queries you can try once you've extracted
   all of the transactions into a MySQL table. */
 
/* Query to show total spending by 'item' (i.e. the payee) in descending order */
 
SELECT item,sum(amount) AS total FROM transactions WHERE amount < 0 AND item <> '' GROUP BY item ORDER BY total;
 
/* Query to show total spending by year. */
 
SELECT year(date),sum(amount) AS total FROM transactions WHERE amount < 0 AND item <> '' GROUP BY year(date);
 
/* Query to show total spending by year and month. */
 
SELECT date_format(date,"%Y-%m") AS yearmonth,sum(amount) AS total FROM transactions WHERE amount < 0 AND item <> '' GROUP BY yearmonth;
 
/* Query to show total spending for a single "item" (i.e. payee) by year and month. */
 
SELECT date_format(date,"%Y-%m") AS yearmonth,sum(amount) AS total FROM transactions WHERE amount < 0 AND item = 'CASA MIA' GROUP BY yearmonth

Compare with Previous | Blame | View Log