Get DENSE RANK in a grouped data
Posted: Thu Mar 08, 2007 12:13 pm
I need to get the rank (basically dense rank) of the SALES_NUMBER based on the CAR_BRAND in a particular group based on STATE, CITY, ZIP
My source and target tables are oracle. can anybody point me in the right direction.
Source
--------
Output required
------------------
Appreciate your response
Thanks
Clara
My source and target tables are oracle. can anybody point me in the right direction.
Source
--------
Code: Select all
STATE CITY ZIP CAR_BRAND SALES_NUMBER
---------- ---------- ---------- ---------- ------------
CA SACRAMENTO 95834 NISSAN 500
NY NY 10038 LEXUS 100
NY NY 10038 BMW 200
NY NY 10038 VOLVO 250
PA MILLMONT 17845 BMW 50
PA MILLMONT 17845 VOLVO 50
PA MILLMONT 17845 HONDA 150
TX SAN MARCOS 78666 VOLVO 50
TX SAN MARCOS 78666 BMW 100
------------------
Code: Select all
STATE CITY ZIP CAR_BRAND SALES_NUMBER RANK
---------- ---------- ---------- ---------- ------------ ------
CA SACRAMENTO 95834 NISSAN 500 1
NY NY 10038 LEXUS 100 1
NY NY 10038 BMW 200 2
NY NY 10038 VOLVO 250 3
PA MILLMONT 17845 BMW 50 1
PA MILLMONT 17845 VOLVO 50 1
PA MILLMONT 17845 HONDA 150 2
TX SAN MARCOS 78666 VOLVO 50 1
TX SAN MARCOS 78666 BMW 100 2
Thanks
Clara