WITH schoolpoint AS
(
SELECT 100 점수, 80 평균, '2005' 년월 FROM dual
UNION ALL SELECT 200, 90, '2006' FROM dual
UNION ALL SELECT 300, 100, '2007' FROM dual
UNION ALL SELECT 200, 80, '2008' FROM dual
)
SELECT DECODE(lv,1,'점수',2,'평균') 구분
, MIN(DECODE(년월,'2005',v)) "2005"
, MIN(DECODE(년월,'2006',v)) "2006"
, MIN(DECODE(년월,'2007',v)) "2007"
, MIN(DECODE(년월,'2008',v)) "2008"
FROM
(
SELECT lv, 년월
, DECODE(lv,1,점수,2,평균) v
FROM schoolpoint
, (SELECT LEVEL lv FROM dual CONNECT BY LEVEL <= 2)
)
GROUP BY lv
;
댓글등록
SQL문을 포맷에 맞게(깔끔하게) 등록하려면 code() 버튼을 클릭하여 작성 하시면 됩니다.