-
SQL Help
I have a Table for example
Table X
person varchar2(10),month varchar2(2),count number
I want to select top 3 persons from the table for all the month.It should look like this
person month count
xxx jan 25
yyy jan 20
zzz jan 15
aaa feb 30
bbb feb 25
ccc feb 10
Pls. help me.
-
Try this:
SELECT PERSON, MONTH, COUNT
FROM ( SELECT
PERSON,
MONTH,
COUNT,
ROW_NUMBER() OVER (PARTITION BY MONTH ORDER BY COUNT DESC) RN
FROM TABLEA
)
WHERE RN <= 3
ORDER BY 2,1 ;
Tamil
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|