I couldn't apply this question as my database structure is different.
My appointment table has dates in yyyy-mm-dd format and status of appointments as pending, cancelled and completed. My query generates comma separated results for 12 months :
$pending = $con->query("SELECT GROUP_CONCAT(cnt) cnt
FROM (select count(*) cnt from appointment where strftime('%Y', date) = '2022' and status like '%PENDING%' GROUP BY strftime('%m', date)) q;")->fetchColumn();
There are no dates for some months, I want 0 in those result sets. All months except February and April have 1 appointment and I would like the result to be like 1,0,1,0,1,1,1,1,1,1,1,1.
I tried this but it didn't help :
$pending = $con->query("SELECT coalesce(GROUP_CONCAT(cnt),0) cnt
FROM (select count(*) cnt from appointment where strftime('%Y', date) = '2022' and status like '%PENDING%' GROUP BY strftime('%m', date)) q;")->fetchColumn();