troubleshooting Question

Help with Stored Procedure Output

Avatar of mburk1968
mburk1968Flag for United States of America asked on
Microsoft SQL Server 2008
16 Comments1 Solution283 ViewsLast Modified:
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]
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 16 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 16 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros