View Single Post

  #1 (permalink)  
Old 01-29-2007
laredotornado@zipmail.com
 
Posts: n/a
Default getting months from days

Hi,

I'm using MySQL 5.0. If I have a table, DAILY_SALES, with columns

DAY DATE,
SALES FLOAT UNSIGNED,
USER_ID INTEGER,
PRIMARY KEY (DAY)

How would I write a query that given a user id and date range, returns
monthly sales totals? So, if the date range were '2006-01-01' to
'2006-12-31', my query result set would have twelve rows of data (and
you can assume there is at least one sale per month).

Thanks for your help, - Dave

Reply With Quote