Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在SQL Teradata中转置表_Sql_Teradata_Query Performance - Fatal编程技术网

如何在SQL 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

我在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
使用时的用例

   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支持