infinitizon
MIS
Could someone help me with this query, it doesn't seem to be performing as expected.
It is supposed to check if the total number of seconds done on overtime by a staff (e.g staff_id='CST000012') for a particular month (e.g. DATEPART(MONTH,apply_date)=5) exists. That is, it is not null. If it is null put zero(0) else, put the number of seconds.
it keeps on giving me null if the staff_id does not exist instead of zero(0).
I'm using MSSQL Server 2008
Help.
Code:
SELECT (CASE SUM(DATEDIFF(SECOND,start_time,end_time))
WHEN NULL THEN 0 ELSE SUM(DATEDIFF(SECOND,start_time,end_time))
END)[totalMthSecs]
FROM OvertimeApplication
WHERE DATEPART(MONTH,apply_date)=5 AND staff_id='CST000012'
It is supposed to check if the total number of seconds done on overtime by a staff (e.g staff_id='CST000012') for a particular month (e.g. DATEPART(MONTH,apply_date)=5) exists. That is, it is not null. If it is null put zero(0) else, put the number of seconds.
it keeps on giving me null if the staff_id does not exist instead of zero(0).
I'm using MSSQL Server 2008
Help.