sql - case statement in where clause for avoiding checking null evaluation -



sql - case statement in where clause for avoiding checking null evaluation -

i have query like

case when ( select sum(amount) table id in(10,100) , to_char(month,'yyyy-mm') = to_char(@date::date,'yyyy-mm') ) null ( select sum(amount) table id in(10,100) , to_char(month,'yyyy-mm') = to_char(@date::date- interval '1 month','yyyy-mm') ) else ( select sum(amount) table id in(10,100) , to_char(month,'yyyy-mm') = to_char(@date::date,'yyyy-mm') ) end

i need rewrite query can utilize case statement in clause in postgres

i think want smthing this, not clear.

coalesce(select sum(amount) table id in(10,100) , to_char(month,'yyyy-mm') = to_char(@date::date,'yyyy-mm') , select sum(amount) table id in(10,100) , to_char(month,'yyyy-mm') = to_char(@date::date- interval '1 month','yyyy-mm') )

sql postgresql

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -