TS_CD30 테이블
CD_ITEM | NM_ITEM | CD_PITEM |
AA | 티셔츠 | * |
AA01 | 기본티셔츠 | AA |
AA02 | 후드티셔츠 | AA |
BB | 블라우스 | * |
BB01 | 롱블라우스 | BB |
WITH JUUUN(CD_ITEM,NM_ITEM,SEQ) AS
(
SELECT CD_ITEM, NM_ITEM, 1 AS SEQ
FROM TS_CD30
WHERE CD_PITEM = '*'
UNION ALL
SELECT J.CD_ITEM, J.NM_ITEM, (SEQ + 1)
FROM TS_CD30 AS J
INNER JOIN JUUUN AS C
ON C.CD_ITEM = J.CD_PITEM
)
SELECT * FROM JUUUN ORDER BY CD_ITEM
(
SELECT CD_ITEM, NM_ITEM, 1 AS SEQ
FROM TS_CD30
WHERE CD_PITEM = '*'
UNION ALL
SELECT J.CD_ITEM, J.NM_ITEM, (SEQ + 1)
FROM TS_CD30 AS J
INNER JOIN JUUUN AS C
ON C.CD_ITEM = J.CD_PITEM
)
SELECT * FROM JUUUN ORDER BY CD_ITEM
'Database > MS-SQL' 카테고리의 다른 글
원하는 길이만큼 앞에 0을 붙여주는 함수 (0) | 2012.04.24 |
---|---|
인덱스고찰 (인덱스,물리적조인) (0) | 2012.04.24 |
LinkedServer (링크드서버) Query (0) | 2012.04.24 |
대칭 암호화 구현 (0) | 2012.04.24 |
MS-SQL 2005에서의 암호화 지원 (0) | 2012.04.24 |
Posted by 김준홍 (http://www.Juuun.com)