I have a table as
mysql> select * FROM testa;
+---------+-------+
| month_x | money |
+---------+-------+
| 11101 | 12345 |
| 11105 | 100 |
| 11105 | 100 |
| 11105 | 100 |
| 11105 | 100 |
| 11106 | 12345 |
+---------+-------+
6 rows in set (0.00 sec)
where last two digits in the month_x are months now i want my output as
Month TOTAL
01 12345
02 0
03 0
04 0
05 400
06 12345
07 0
08 0
09 0
10 0
11 0
12 0
IS possible using the If else or case.
For this you need to create a table first with months’ numeric value in it.
Then execute this query,
Result is,