mysql - Following SQL query returns resultset for only available months, how to get all month if data is not present? -
following query gives result-set available months , how can months if data not present .
eg:- apr-2013 , may-2013 having value june-2013 no value how can june-2013 in result set total 0 .
select concat(substr(monthname(fileddate) , 1, 3) , "-", year(fileddate)) month, count(*) carstore store=20 , (soldstate = 2 or soldstate = 3) , cartype '%toyoto%' , fileddate between date('2013-04-07') , date('2014-04-30') group month order year(fileddate), month(fileddate) ; +----------+----------+ | month | count(*) | +----------+----------+ | apr-2013 | 2 | | may-2013 | 2 | | jul-2013 | 14 | | aug-2013 | 3 | | sep-2013 | 2 | | nov-2013 | 4 | | dec-2013 | 19 | | jan-2014 | 61 | | feb-2014 | 21 | | apr-2014 | 3 | +----------+----------+
Comments
Post a Comment