I have a select statement, sth like..
select col1, col2, col3 from tbl1 where (conditions)
If there is no row,
All I see is..
NULL,NULL,NULL
What I want to get is
0,0,0
I know there is sth like..
select when (condition) then RESULT else 0 end as 'Col1',..... from tbl1
But if i Do that, I have to check condition everyline..
Any better idea??
Try this:
Another approach, if you intend to get 1 row but didn’t get any, you can use the sum coalesce approach:
Another one, use WITH so you don’t have to re-evaluate rows when filtering don’t produce any results: