2021年3月25日星期四

SQL coalesce Null columns

select       id   , coalesce(iff(name = 'Alpha', price, null), null) alpha_price   ,null as beta_price   , coalesce(iff(name = 'beta', price, null), null) beta_price    from table1  

output :

id.     alpha_price     beta_price   123       29             NULL  123       NULL           40  

expected output :

id     alpha_price     beta_price   123       29             40  
https://stackoverflow.com/questions/66809992/sql-coalesce-null-columns March 26, 2021 at 09:52AM

没有评论:

发表评论