mysql - Remove null values from SQL results -


the query below returns null rows in output. can avoid null rows if i've 2 separate queries. there better approach avoiding null rows?

select date_part('h',convert_timezone('utc+05:30',  value)) h  ,          count (case when cond1 1 else null end) "result1",        count (case when cond2 1 else null end) "result2" table_name conds group cols  expected output: h | result1 | result2  1 |   23    |   51 2 |   45    | 100  actual output: h | result1 | result2    |     0   |   0   |     0   |   0                             1 |   23    |   51 

if don't want query, try approach:

select date_part('h',convert_timezone('utc+05:30',  value)) h  ,   count (case when cond1 1 else null end) "result1", count (case when cond2 1 else null end) "result2" table_name conds group cols having date_part('h',convert_timezone('utc+05:30',  value)) not null 

in example, alternatively expand conditions include same test not null , forego using having clause.


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -