test테이블에서 c컬럼이 2인 데이터만 추출하고 싶은데요..(c컬럼의 값이 가장 많은 것.)
도움 부탁드립니다.
by 강정식
[2008.03.21 00:00:00]
WITH tab AS ((SELECT CASE WHEN LEVEL BETWEEN 1 AND 20 THEN 1
WHEN LEVEL BETWEEN 21 AND 40 THEN 2
ELSE 3 END c
FROM dual
CONNECT BY LEVEL <= 100))
SELECT C
FROM (SELECT C,
CNT,
MAX(CNT) OVER(ORDER BY 1) MAX_CNT
FROM (SELECT C,
COUNT(*) OVER(PARTITION BY C) CNT
FROM TAB))
WHERE CNT = MAX_CNT
by finecomp
[2008.03.21 00:00:00]
이렇게도...;
SELECT SUBSTR(MAX(LPAD(cnt,10,'0')||c), 11)
FROM(
SELECT c, COUNT(*) as cnt
FROM t
GROUP BY c
)
댓글등록
SQL문을 포맷에 맞게(깔끔하게) 등록하려면 code() 버튼을 클릭하여 작성 하시면 됩니다.