如何在SQL Teradata中转置表
我在Teradata中有一个表,带有以下查询:如何在SQL Teradata中转置表,sql,teradata,query-performance,Sql,Teradata,Query Performance,我在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 ti
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
使用时的用例
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
column3
在结果集中没有意义。是的,我将修改它。谢谢。您的Teradata版本是什么?Teradata 16支持column3
在结果集中没有意义。是的,我将对此进行修改。谢谢。您的Teradata版本是什么?Teradata 16支持