my table design is

date     income  expenses  

2011-08-5   1000    500
2011-09-6   7000    400
2011-10-7   2000    300

I have daily expenses and Income in the above table.I need to retrieve monthly(sum of daily) income and expenses for particular year.
How should i write query for that .
Pls help me
Thanks in advance


This is quick and dirty since I don't know the real field names or table name but something like this should work:

left(`date`,7) as 'Year-Month',
sum(income) as Monthly_Income,
sum(expenses) as Monthly Expenses
group By 'Year-Month'

You should get a monthly total on each line.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.