below is my data present in my database.
startingdate - varchar
tablename - couponentry
coupon price month startingdate
100 15 1-month 02-03-2015
101 15 1-month 04-03-2015
102 15 1-month 05-03-2015
103 15 1-month 07-04-2015
104 15 1-month 08-04-2015
105 15 1-month 15-05-2015
106 15 1-month 18-05-2015
107 15 2-month 02-02-2015
108 15 2-month 04-02-2015
109 15 2-month 05-02-2015
110 15 2-month 07-03-2015
111 15 2-month 08-03-2015
112 15 2-month 15-05-2015
113 15 2-month 18-05-2015
114 15 2-month 18-05-2015
I need count of total coupon based on 1-month,2-month and so on..and also need to display month wise seprate totalcount of coupon.
FOR EX - In above data - total 7 coupon created in 1-month. from this 3 coupon comes in march,2 in april and 2 in may month.... like wise...
expected output like below
month jan feb mar april may june ... totalcoupon totalprice
1-month 3 2 2 7 105
2-month 3 2 3 8 120
below is my query which i tried...
SELECT month,COUNT(CE.coupon) As Total,SUM(CE.Price) AS TotalPrice FROM coupon_entry CE LEFT JOIN subagentmaster SAM ON CE.subagentid = SAM.id LEFT JOIN tehsilmaster TM ON SAM.tehsil = TM.id LEFT JOIN city_master CM ON CE.city = CM.id WHERE CM.cityname = 'nagpur' GROUP BY CE.month
but this is getting below output
month totalcoupon totalprice
1-month 7 105
2-month 8 120