I am trying to find a total count of all the users who have viewed a particular object in my particular table. I have a query which, so far, breaks it apart by object...
select object, count(distinct user) 'c' from events e where (action = 'viewed') and object in ('car','truck') group by object, 'c'
The output looks like the following...
car 92
truck 20
What I would like is to simply output the number 112
. Any help would be great.
Put a sum()
around your current query
select sum(c)
from
(
select object, count(distinct user) 'c'
from events e
where (action = 'viewed') and object in ('car','truck')
group by object, 'c'
) tmp