如何在没有聚合的情况下进行透视,这可能吗?

How to Pivot Without Aggregation, Is that possible?

我想按以下顺序重新排列 table 的行和列。这可能吗?如何实现?

这是我期待的结果。我该怎么做。

如果你的每一行都有多个值,那么你期望没有聚合函数会怎样?

如果每行只有一个值,那么无论使用 sum、min、max 还是 avg 聚合函数都没有关系。
像这样(在 Oracle 中):

select row_id, 'C1', 'C2', 'C3'
  from table 
pivot(max("value") for column_id in('C1', 'C2','C3'));

带有示例的可执行版本:

select row_id, 'C1', 'C2', 'C3'
  from (select 1 table_id, 'C1' Column_id, 1 Row_id, 20000 "value"          from dual        union all
    select 1 table_id, 'C2' Column_id, 1 Row_id, 30000 "value"          from dual        union all
    select 1 table_id, 'C3' Column_id, 1 Row_id, 25000 "value"          from dual        union all
    select 1 table_id, 'C1' Column_id, 2 Row_id, 80200 "value"          from dual        union all
    select 1 table_id, 'C2' Column_id, 2 Row_id, 50000 "value"          from dual        union all
    select 1 table_id, 'C3' Column_id, 2 Row_id, 95000 "value" from dual) 
pivot(max("value") for column_id in('C1', 'C2','C3'))
Select Row_ID,
     Min(Case DBColumnName When 'c1' Then Value End) c1,
     Min(Case DBColumnName When 'c2' Then Value End) c2,
     Min(Case DBColumnName When 'c3' Then Value End) c3
   From table
   Group By Row_ID

编辑:我在没有编辑的情况下写了这篇文章并且没有 运行 SQL。我希望,你明白了。