MySQL Count with several criteria coloumn one table [on hold]
I have a data transaction table
Table Data (Month,Year,Type,Color)
+-------+------+-----------------------+---------------+
| Month | Year | type | Color |
+-------+------+-----------------------+---------------+
| 1 | 2013 | MATIC | BLACK |
| 1 | 2013 | MATIC | BLACK |
| 2 | 2013 | MATIC | BLACK |
| 2 | 2013 | MATIC | RED |
| 3 | 2013 | MATIC | WHITE |
| 3 | 2013 | MATIC | WHITE |
| 4 | 2013 | MATIC | WHITE |
| 4 | 2013 | MATIC | WHITE |
| 1 | 2013 | SPORT | RED |
| 1 | 2013 | SPORT | YELLOW |
| 2 | 2013 | SPORT | YELLOW |
| 2 | 2013 | SPORT | BLACK |
| 3 | 2013 | SPORT | BLACK |
+-------+------+-----------------------+---------------+
i want count number by type,color,year,month so the result like this
+-------+------+-----------------------+---------------+--------+
| Month | Year | type | Color | Number |
+-------+------+-----------------------+---------------+--------+
| 1 | 2013 | MATIC | BLACK | 2 |
| 2 | 2013 | MATIC | BLACK | 1 |
| 2 | 2013 | MATIC | RED | 1 |
| 3 | 2013 | MATIC | WHITE | 2 |
| 4 | 2013 | MATIC | WHITE | 2 |
| 1 | 2013 | SPORT | RED | 1 |
| 1 | 2013 | SPORT | YELLOW | 1 |
| 2 | 2013 | SPORT | YELLOW | 1 |
| 2 | 2013 | SPORT | BLACK | 1 |
| 3 | 2013 | SPORT | BLACK | 1 |
+-------+------+-----------------------+---------------+--------+
its group by month,year,type,color, What query to get the number ?
No comments:
Post a Comment