Reputation: 11
Please help me figure this out...
I have a temporary table that has NULL values. I want to only extract one record, representing rows that have data. What I currently have in the table is
When I run the following statement,
SELECT * FROM #TempTable WHERE SICK IS NOT NULL AND VAC IS NOT NULL;
I want my results to be ResultsSample
Upvotes: 0
Views: 52
Reputation: 2021
You can use MAX function..for this.
SELECT ID, MAX(SICK) SICK , MAX(VAC) VAC
FROM #TempTable
GROUP BY ID
Upvotes: 0
Reputation: 1271171
Use aggregation:
select id, sum(sick) as sick, sum(vac) as vac
from #TempTable
group by id;
Upvotes: 1