how can i substitute a NULL value for a 0 in an SQL Query result

Posted by Name.IsNullOrEmpty on Stack Overflow See other posts from Stack Overflow or by Name.IsNullOrEmpty
Published on 2010-05-26T06:59:38Z Indexed on 2010/05/26 7:01 UTC
Read the original article Hit count: 202

Filed under:
|
SELECT  EmployeeMaster.EmpNo, Sum(LeaveApplications.LeaveDaysTaken) AS LeaveDays
    FROM  EmployeeMaster  FULL OUTER JOIN
    LeaveApplications ON EmployeeMaster.id = LeaveApplications.EmployeeRecordID INNER JOIN
    LeaveMaster ON EmployeeMaster.id = LeaveMaster.EmpRecordID
    GRoup BY EmployeeMaster.EmpNo
    order by LeaveDays Desc

with the above query, if an employee has no leave application record in table LeaveApplications, then their Sum(LeaveApplications.LeaveDaysTaken) AS LeaveDays column returns NULL. What i would like to do is place a value of 0 (Zero) instead of NULL. I want to do this because i have a calculated column in the same query whose formular depends on the LeaveDays returned and when LeaveDays is NULL, the formular some how fails. Is there away i can put 0 for NULL such that that i can get my desired result.

© Stack Overflow or respective owner

Related posts about sql-server-2005

Related posts about tsql