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

c - Compilation of a code: unkown type name string -

java - Bypassing "final local variable defined in an enclosing type" -

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