我知道pivot只能用一个列来完成,但是想不出一个合适的方法来使用case语句来翻转表。values (11,223,43,12)我不确定如何在一条语句中做到这一点,或者通过给服务器增加额外的开销?,casewhen month=1 then apples else 0 end jan
,casewhen month=2 then apples else 0 e
如果表B的col2是' XYZ‘,那么我只需要该id包含XYZ的行。if 'XYZ' in (select b1.col2 from table b1 where b1.col1 = b.col1) then b.col2 = 'XYZ' end and casewhen (select count(b1.col) from table b1 where b1.col = b.col1 and b1.col = 'XYZ') >0 then b.col