troubleshooting Question

help with union

Avatar of HLRosenberger
HLRosenbergerFlag for United States of America asked on
Microsoft SQL ServerSQL
10 Comments1 Solution374 ViewsLast Modified:
I have attached the result of a UNION.  Where there are duplicate categories, I do not want the NULL hour/date record.  When the NULL hour/date record is the only one for a category, then I want to keep it.

 When the How can I do this?  

here's the SQL

SELECT Category , annualhours AS Hours,  Date AS Date  

FROM training_details_report
where EmpUID = 2368 and annualhours > 0 and
(date BETWEEN '1/1/2011' AND '12/31/2011')

union

select Category, null as hours, null as date from BCS_Training_Categories
union.png
ASKER CERTIFIED SOLUTION
ralmada

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 10 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 10 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