DB

ORDER BY 특정 값으로 정렬

인생아 2017. 4. 27. 15:00
반응형
WITH TAB AS (
                 SELECT '홍길동' AS COL1 FROM DUAL
UNION ALL SELECT '임꺽정' AS COL1 FROM DUAL
UNION ALL SELECT '허준' AS COL1 FROM DUAL
UNION ALL SELECT '고길동' AS COL1 FROM DUAL
) 



SELECT DECODE(COL1, '임꺽정', 1, '허준', 2, '고길동', 3, '홍길동', 4) AS ORDER_COL
	  ,COL1
  FROM TAB
 ORDER BY ORDER_COL
반응형