I tried the solution given in "mysql SELECT COUNT(*) … GROUP BY … not returning rows where the count is zero" but it didn't work for me.
Here is SQL ::
SELECT empid, SUM (total_records) total_records
FROM (SELECT ID,
(CASE WHEN ID LIKE '2%' THEN '2____'
WHEN ID LIKE '3%' THEN '3____'
WHEN ID LIKE '99%' THEN '99____'
END) empid,
total_records
FROM tr
where ( id like '2%' or id like '3%' or id like '99%'))
GROUP BY empid;
When the particular value in empid SUM is ZERO, that row isn't shown at the output. This shows we have no data (or sum) for that particular empid. But is it possible to have '0' for that particular value to be displayed in the result set ?