i want create 2 queries table has fields name,surname , amount paid,the first query should select day,month , amount paid,the second query should select month,year in year , total amount paid in month,lets john paid on 2013-05-01, on 2013-05-03,while peter paid on 2013-04-08, want first query output
month , day amount 05-01 200 05-03 400 04-08 50
and second query should output:
month , year total 2013-05 600 2013-04 50
i know can use sum
aggregate function select total tricky part how select day , month in format above,
first query be
select date_format(date, "%m-%d") 'month , day',price amount `tablename`
and second query be
select date_format(date, "%y-%m") 'month , year' , sum(price) total `tablename` group year(date), month(date)
Comments
Post a Comment