繁体   English   中英

如何在SQL Teradata中转置表

[英]How transpose a table in SQL Teradata

我在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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM