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

Php operator `break` doesn't stop while -

ubuntu - Bash Script to Check That Files Are Being Created -

vim: Search & replace -