Skip to content

How to find ranking

Kanhialal kk

Asked Apr 10, 2012, 2:27 AM EDT2 answers
Share
LinkedInX
hi..
i have a database table just like below.
___________________________________
cliencode  InvoiceNo  datetime
1  1001  10/10/2011
1  1002   10/10/2011
1  1003   10/10/2011
2  1004   10/10/2011
2  1005   10/10/2011
2  1006   10/10/2011
3  1007   10/10/2011
1  1008   10/10/2011
1  1009   10/10/2011
2  1010   10/10/2011
___________________________________

now i want to find ranking of client code so how it is possible.
please help

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • Senthilkumar
    0
    Hi,

    There are two functions in RANK.
    RANK()
    DENSE_RANK()

    SELECT clientcode,InvoiceNo, ddatetime, RANK() OVER (ORDER BY cliencode DESC) AS RankByClientCode FROM table_name

    SELECT clientcode,InvoiceNo, ddatetime, DENSE_RANK() OVER (ORDER BY cliencode DESC) AS RankByClientCode FROM table_name
    0
  • 0
    thanks sir.. but when i running that query following error occurs..

    select CCode,InvoiceNo,RANK() OVER(order by ccode desc)as RankByCCode from InvoiceNo

    Server: Msg 195, Level 15, State 10, Line 1
    'RANK' is not a recognized function name.

    one thing i aware you that i am using sql server 2000... for database

    please your help is needed
    0