Semprise
02-05-2008, 06:35 PM
Say I have a table T with column N
N
--
5
2
8
3
9
6
2
12
23
9
I want to get the top 5 highest unique numbers: that is 23, 12, 9, 8, 6.
SELECT UNIQUE N
FROM T
WHERE ROWNUM <=5
Will give me 23, 12, 9 ,8. It seems to count the 9 twice. Without UNIQUE:
SELECT N
FROM T
WHERE ROWNUM <=5
I get 23, 12, 9, 9 ,8
Anyone know what I do to get the 5 values I want? I am using oracle 8i.
N
--
5
2
8
3
9
6
2
12
23
9
I want to get the top 5 highest unique numbers: that is 23, 12, 9, 8, 6.
SELECT UNIQUE N
FROM T
WHERE ROWNUM <=5
Will give me 23, 12, 9 ,8. It seems to count the 9 twice. Without UNIQUE:
SELECT N
FROM T
WHERE ROWNUM <=5
I get 23, 12, 9, 9 ,8
Anyone know what I do to get the 5 values I want? I am using oracle 8i.