I'm trying to do multiple counts on the same column with different where like clauses.
I have figured out the base Queries for each of my like clauses but I need to combine them to produce one result.
select system_user, COUNT(details) from asset_log where details like 'Viewed';
select system_user, COUNT(details) from asset_log where details like 'Viewed Web%';
select system_user, COUNT(details) from asset_log where details like 'ThumbView';
select system_user, COUNT(details) from asset_log where details like 'Exported%';
I'm sure its possible, I just dont know how to do it. Any help would be appreciated.
Thanks In Advance
Update:
this Ended up working for me
select distinct system_user,
SUM(CASE WHEN details ='viewed' then 1 Else 0 end) AS viewed_count,
SUM(CASE WHEN details Like 'Viewed Web%' then 1 Else 0 end) AS Web_count,
SUM(CASE WHEN details = 'ThumbView' then 1 Else 0 end) AS ThumbView_count,
SUM(CASE WHEN details Like 'Exported%' then 1 Else 0 end) AS Exported_count
from asset_log GROUP BY system_user;
Thanks!