sql - How can I get that result from CASE statament in MySQL? -
select field_name, sum(case when field_name not null 1 else 0 end) count table_name group department result is: field_name count aaa 9 bbb 0 ccc 7
but how can rows have more 0 in second column.
select field_name, sum(case when field_name not null 1 else 0 end) count table_name group department having `count` > 0
having
clause executed after where
, group by
can address aggregating functions
Comments
Post a Comment