2015-10-16 55 views
1

我有吐出來的是以下數據的查詢:如何在Oracle中轉發此數據?

ID  | RESPONSE_VALUE      | TITLE 
--------------------------------------------------------------------- 
1634303 | 6th Grade - Referring teacher's room | Academic_Area 
1634303 | doing stuff and thangs    | Help 
1634303 | Doe, Jane       | Name 
1634303 | Doe, John       | Name_of_Student 
1634303 | 1 Day        | Days 
1634303 | Tuesday        | Preferred_PAWs_Day 
1634303 | Online        | materials 

我想,所以它看起來像這樣樞這樣的數據:

ID | Academic_Area       | Help      | Name  | Name_of_Student | Days | Preferred_PAWs_Day | materials 
-------------------------------------------------------------------------------------------------------------------------------------------------------- 
1634303 | "6th Grade - Referring teacher's room" | "doing stuff and thangs" | "Doe, Jane" | "John, Doe" | "1 Day" | Tuesday   | "" 

由於這種數據並沒有真正有一個聚合函數是有道理的,我沒有看到一個很好的方法來調整數據。

回答

2

您可以使用listagg()max()(如果只涉及一個值)。

例如:

select id, 
     max(case when response_value = '6th Grade - Referring teacher''s room' 
       then title 
      end) as "6th Grade - Referring teacher's room", 
     . . . 
from t 
group by id;