Home » SQL & PL/SQL » SQL & PL/SQL » Facing problem using rank function.........
Facing problem using rank function......... [message #274471] Tue, 16 October 2007 03:24 Go to next message
nawshot
Messages: 12
Registered: May 2007
Junior Member
Hi all,

i need to generate a report which has 3 columns,
the first column should display top 5 phone mdel based on the count of customers, second columns should display top 3 return reasons for each phone model.
for eg.

sno----Model------reason---------------count
1.-----Nokia---------------------------200
---------1----------keypad_fault---------70
---------2----------No display-----------40
---------3----------damaged--------------30
2.-----LG------------------------------160
---------1----------damaged--------------60
---------2----------keypad_falut---------40
---------3----------Can't Hear-----------30
3.-----Sony----------------------------130
---------1-----------No display----------40
---------2-----------Can;t hear----------20
---------3-----------damaged-------------10
.
..
...

I am able to get top 5 models but unable to rank i.e get top 3 reasons per model.

Please help me out.

thanks and regards,
naw.
Re: Facing problem using rank function......... [message #274474 is a reply to message #274471] Tue, 16 October 2007 03:28 Go to previous messageGo to next message
Michel Cadot
Messages: 64120
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Please read and follow OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format. Use the "Preview Message" button.
Please always post your Oracle version (4 decimals).

Post a test case: create table and insert statements.

Regards
Michel
Re: Facing problem using rank function......... [message #274493 is a reply to message #274474] Tue, 16 October 2007 04:18 Go to previous message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
Try using something like:
ROW_NUMBER() OVER (PARTITION BY model ORDER BY count DESC)
Previous Topic: Convert secons in hours more than 24
Next Topic: problem with my delete procedure
Goto Forum:
  


Current Time: Tue Dec 06 11:57:41 CST 2016

Total time taken to generate the page: 0.09120 seconds