공부
[SQL] count distinct with conditions
승가비
2020. 7. 24. 19:48
728x90
select
count(distinct tag) as tag_count,
count(distinct (case when entryId > 0 then tag end)) as positive_tag_count
from
your_table_name;
https://stackoverflow.com/questions/14048098/count-distinct-with-conditions
COUNT DISTINCT with CONDITIONS
I want to count the number of distinct items in a column subject to a certain condition, for example if the table is like this: tag | entryID ----+--------- foo | 0 foo | 0 bar | 3 If I want to c...
stackoverflow.com
728x90