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

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -