How to take a step without aggregation, is this possible?

I want to rearrange a table with rows and columns in the following order. Is this possible and how?

enter image description here

This is the result that I expect. How can i do this.

enter image description here

+4
source share
2 answers

If you have multiple values ​​for each row, then what would you expect without an aggregation function?

And if you have one value for each row, so no matter what amount to use, minimum, maximum or average aggregation. like this (in oracle):

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'))
+3
source
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

Edit: I wrote this without an editor and did not run SQL. Hope you have an idea.

+1
source

Source: https://habr.com/ru/post/1623857/