Greg Chu Technical History
Monday, April 13, 2015
Add two counts in SQL
use COALESCE to default to zero:
SELECT COALESCE(MAR1.GENERATED,0)
SELECT SUM(s.TOTAL_DOCS) totalHours
FROM (
( SELECT count(*) as TOTAL_DOCS
FROM x WHERE ..
)
UNION ALL
(SELECT count(*) as TOTAL_DOCS FROM x
WHERE ...
)
) s
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment