I'm not able to figure it out why below code is returning blank value instead of the minimum for "Min(Statestarttime)"I have some blank varchar fields in my table but SQL supposed to ignore that if it can't how can I do that? Please help.
SELECT Date, EmpID,
SUM(CASE WHEN State = 'active' THEN MinutesatState ELSE 0 END) AS active,
SUM(CASE WHEN State = 'idle' THEN MinutesatState ELSE 0 END) AS idle,
Min(Statestarttime) as Starttime,
MAX(StateEndtime) as endtime,
ROUND(SUM(CASE WHEN State = 'active' THEN MinutesatState ELSE 0 END)/60,2) AS activehr,
ROUND(SUM(CASE WHEN State = 'idle' THEN MinutesatState ELSE 0 END)/60,2) AS idlehr
FROM time WHERE EmpID=303867 GROUP BY Date ORDER BY `time`.`Date` DESC
Comments
Post a Comment