我在 Teradata 中有这个表,有这个查询:
select column1, column2,column3 from squema.table;
column1 column2 column3 count
ab1 ab2 tip1 123
ab1 ab2 tip2 23
ab1 ab2 tip3 5
我正在尝试转置,但我没有找到一个很好的样本来在 Teradata 中获取此表:
column1 column2 tip1 tip2 tip3
ab1 ab2 123 23 5
谢谢你的帮助。
用例当
select column1, column2,max(case when column3='tip1' then count end) as tip1
,
max(case when column3='tip1' then count end) as tip2,
max(case when column3='tip1' then count end) as tip3
from squema.table group by column1, column2
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句