Here is the normal mysql query
SELECT SUM( Minutes ) as minsDecPrac, COUNT( DISTINCT (CAST(dtDateTime as DATE))) as playDecPrac FROM `tbl_atschool_timelog` WHERE `intuid` = 48876 AND `intGametypeId` = 2 AND `intGame` = 1
Here is the Output
minsDecPrac playDecPrac
17 1
Here is the query using CASE WHEN
SELECT SUM(CASE WHEN intGametypeId = 2 AND intGame =1 THEN Minutes ELSE 0 END) AS minsDecPrac COUNT(DISTINCT CASE WHEN intGametypeId = 2 AND intGame =1 THEN (CAST(dtDateTime as DATE)) ELSE 0 END) AS playDecPrac FROM `tbl_atschool_timelog` WHERE `intuid` = 48876
Here is the Output
minsDecPrac playDecPrac
17 2
The problem is that if i use CASE WHEN, the output of "playDecPrac"(dtDateTime ) is wrong. I don't know what i am wrong. Please help me if anybody knows