Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ranking Records

Status
Not open for further replies.

d3c3as3d

MIS
Sep 3, 2001
2
AU
Would anyone tell me how you would
rank a records in (as/400) db2


product prct_count rank OR rank
aaa 99 1 4
bbb 50 2 2
eee 50 2 2
ccc 20 4 1


Thank in advance
 
select product, prct_count, rank() over(order by prct_count desc) as product_rank
from rank_test
order by product_rank

If you want to rank it in reverse order, then change the (order by prct_count desc) to (order by prct_count asc).

This should to the trick.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top