I have the following subquery. I am calculation the remaining balance of PTO to the end of the current month. My issue is that if a user has not yet submitted PTO for this year I receive a NULL value. I want to see the hours that are in the PTOBeginningBalances.
,( SELECT ( PB.BeginningBalance ) - COALESCE(SUM(PR.TotalHoursUsed), 0)
FROM PTORequest PR
LEFT OUTER JOIN PTOBeginningBalances PB ON PR.EmployeeUsername = PB.EmployeeUsername
WHERE PBAL.EmployeeUsername = PB.EmployeeUsername
--AND SUBSTRING(Status, 4, LEN(Status) - 3) = 'Approved'
AND ( YEAR(Year) = YEAR(GETDATE()) )
AND ( YEAR(StartDateAndTime) = YEAR(GETDATE())
OR YEAR(EndDateAndTime) = YEAR(GETDATE())
GROUP BY PB.BeginningBalance
) AS [Remaining Hours]