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

Hello,

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

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

You should get a monthly total on each line.

thanks rch1231

Be a part of the DaniWeb community

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