I have INVOICE table here is the layout:

+-------------------------+---------------+------+-----+---------+----------
------+
| Field                   | Type          | Null | Key | Default | Extra
|
+-------------------------+---------------+------+-----+---------+----------
------+
| ID                      | int(11)       |      | PRI | NULL    |
auto_increment |
| CLIENT_NAME             | int(11)       | YES  |     | NULL    |
|
| STATE                   | varchar(255)  | YES  |     | NULL    |
|
| STATEMENT_DATE          | date          | YES  |     | NULL    |
|
| INVOICE_AMOUNT          | double(16,2)  | YES  |     | NULL    |
|
| LAST_MODIFIED_DATE      | timestamp(14) | YES  |     | NULL    |
|
| ACTIVE_FLAG             | tinyint(1)    | YES  |     | NULL    |
|
+-------------------------+---------------+------+-----+---------+----------
------+

I would like to produce a result set that would give me the following
report:
it would be a sum of the INVOICE_AMOUNT grouped by state(STATE) and
month(STATEMENT_DATE). 

+------------+---------+---------+---------+---------+
| MONTH      | STATE_1 | STATE_2 | STATE_3 | ...     |
+------------+---------+---------+---------+---------+
| JANUARY    |    1234 |   12345 |     124 |         |
| FEBRUARY   |    2536 |   65874 |     457 |         |
| MARCH      |    4578 |   87452 |     547 |         |
| ...        |         |         |         |         |
+------------+---------+---------+---------+---------+

Any idea, I tried a bunch of different syntax without any solutions.

Stephane
mysql, query

---------------------------------------------------------------------
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