I'm relatively new to the construction of complex queries,
and I'm trying to figure one out that I'm sure is common;
I wasn't able to find anything especially helpful in the docs.

Suppose I have the canonical database of CDs, with one table,
which includes fields for title, cost, and date_purchased.
I'd like to get a result set that shows the number of CDs
purchased, and their sum cost, for each month. Thus, if I
bought some CDs that cost exactly $15.00 each month for the
last few months, I'll get something like

2001-12   2   30.00
2002-01   3   45.00
2002-02   2   30.00
2002-03   1   15.00

(The exact format isn't too important, I can figure that out
once I get the basic query down.)

What's the best way to construct this SQL query?

Thanks.

Jesse Sheidlower


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to