I've got an SQL query that works great, unless there are 0 records found. Is there any way to make "ttlTotal" = 0? Currently it returns NULL when there are no records found.
SELECT
UserName,
SUM(ifNull(Day1Reg, 0) +
ifNull(Day2Reg, 0) +
ifNull(Day3Reg, 0) +
ifNull(Day4Reg, 0) +
ifNull(Day5Reg, 0) +
ifNull(Day6Reg, 0) +
ifNull(Day7Reg, 0) +
ifNull(Day1OT, 0) +
ifNull(Day2OT, 0) +
ifNull(Day3OT, 0) +
ifNull(Day4OT, 0) +
ifNull(Day5OT, 0) +
ifNull(Day6OT, 0) +
ifNull(Day7OT, 0)) as ttlTotal
FROM weeks
WHERE RecNum = 1
AND
(Day1Reg IS NOT NULL OR
Day1OT IS NOT NULL OR
Day2Reg IS NOT NULL OR
Day2OT IS NOT NULL OR
Day3Reg IS NOT NULL OR
Day3OT IS NOT NULL OR
Day4Reg IS NOT NULL OR
Day4OT IS NOT NULL OR
Day5Reg IS NOT NULL OR
Day5OT IS NOT NULL OR
Day6Reg IS NOT NULL OR
Day6OT IS NOT NULL OR
Day7Reg IS NOT NULL OR
Day7OT IS NOT NULL)
GROUP BY UserName
Aucun commentaire:
Enregistrer un commentaire