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

javascript - THREE.js reposition vertices for RingGeometry -

javascript - I need to update the text of a paragraph by inline edit -

assembly - What is the addressing mode for ld, add, and rjmp instructions? -