Table structure:
CALLS:
ID
incoming_from
time_of_call
date_of_call
I'm using the query below. It gives me what I want except if there are no calls for January, it skips that month, which makes perfect sense logically except that I want it to indicate "0" for january.
I want to run a query that forces a result for January even if there are no records that meet that criteria.
Is there something like a PHP explode or something like that where you can force an answer for a month not there? I'd rather not build a table for all the months/years.
Any ideas? Your help is MUCH appreicated!
SELECT DATE_FORMAT(date_call, '%Y') as year_name,
DATE_FORMAT(date_call, '%M') as month_name, COUNT(CASE WHEN returned = 'Y' THEN call_id ELSE NULL END) AS 'returned'
FROM calls
GROUP BY month_name, year_name
Bookmarks