-2

これがデータのスクリーンショットです。

ここに画像の説明を入力

ここでは、2 つの異なる年 (2013 年と 2014 年など) に基づいて列 ( ) を月ごとに比較したいSal, TA, DAので、出力は次のようになります...

ここに画像の説明を入力

これについて私に質問してください

4

1 に答える 1

0

次のようなものを試してください

select EMP_ID, MONTH,
max( case when Year=2013 then Sal else null end) as Sal_2013, 
max( case when Year=2014 then Sal else null end) as Sal_2014, 
max( case when Year=2013 then TA else null end) as TA_2013, 
max( case when Year=2014 then TA else null end) as TA_2014, 
max( case when Year=2013 then DA else null end) as DA_2013, 
max( case when Year=2014 then DA else null end) as DA_2014
from  table1
group by EMP_ID, MONTH
于 2013-05-11T07:53:55.053 に答える