0

how to get zero value in group by ? I have a query like this

SELECT cb.pk_id
       , cb.name
       , date_format(sa.reg_date,'%M %Y') as bulan
       , COUNT(sa.qty) AS count 
FROM tbl_pic cb 
         LEFT JOIN tbl_asset sa ON cb.pk_id = sa.pic 
GROUP BY cb.pk_id
         , cb.name
         , cb.identity
         , year(reg_date)
         , month(reg_date)

with result like this

Image of actual result

i want to get zero value on non-existent month result like this

Image of Expected Result

is it possible ? Thank you

SOS
  • 6,330
  • 2
  • 10
  • 29
  • 2
    You need to include a _calendar_ table in your query, which is a table having all dates which you want to appear in the output. – Tim Biegeleisen Apr 19 '22 at 04:29

0 Answers0