FIRST MAX
SELECT MAX(SALARY)
FROM SALARY_TABLE
;
SECOND MAX
SELECT MAX(SALARY)
FROM SALARY_TABLE
WHERE SALARY < (SELECT MAX(SALARY)
FROM SALARY_TABLE)
;
N'TH MAX WITHOUT DUPLICATES
SELECT SALARY
FROM SALARY_TABLE A
WHERE 1 = ( SELECT COUNT(*)
FROM SALARY_TABLE B
WHERE B.SALARY >= A.SALARY)
;
-- N'TH MAX WITH DUPLICATES
SELECT DISTINCT SALARY
FROM SALARY A
WHERE 1 = ( SELECT COUNT(DISTINCT B.SALARY)
FROM SALARY_TABLE B
WHERE B.SALARY >= A.SALARY)
Sunday, July 12, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment