-----------------------
1정원 2정원 3정원
컴공과. 120. 120. 120
이 테이블을
컴공 1정원 120
컴공 2정원 120
컴공 3정원 120
이런식으로 쭉 나열되게 표시하려면 어째해야 될까요?
select문좀 가르쳐주세요 부탁드립니다. ㅠㅠ
Comment 5
-
나는짱이야
2016.01.07 20:26
-
아이워너야근
2016.01.07 20:29
예제좀 적어주세요 ㅠㅠ
-
Terry
2016.01.07 23:20
다른 이야기지만..닉네임이..왜 이리 슬프게 느껴지는지요 ㅠ_ㅠ;;;
-
Terry
2016.01.07 22:29
참고만 하세요..
덕분에 처음으로 Unpivot 써봤네요^^
감사해요~~
---쿼리시작---
with tblA(학과,[1정원],[2정원],[3정원]) As
(
Select '컴공과',120,120,120
)
Select 학과,정원,정원2
From tblA
Unpivot ( 정원2 For 정원 In ([1정원],[2정원],[3정원])) unpvt---쿼리끝---
-
건우아빠
2016.01.07 22:38
case 문
with tblA(학과,[1정원],[2정원],[3정원]) As
(
Select '컴공과',120,120,120
)
Select a.학과
, case b.no
when 1 then '1정원 '
when 2 then '2정원 '
when 3 then '3정원 '
end
, case b.no
when 1 then a.[1정원]
when 2 then a.[2정원]
when 3 then a.[3정원]
end
From tblA a , (select 1 no union select 2 no union select 3 no ) bunipivot 이 좀더 효율적일듯.....
case문 또는 피벗으로 하면 되지 않을까요?