开发者

Dense_Rank() alternative in sql server 2000?(Set based)

Actually, I have the task of finding the employees bas开发者_开发知识库ed on the salary rank.

So I used Dense_Rank() and got the answer.

Initially I was told to solve in SQL SERVER 2005.

Later on they changed the requirement and is saying that the query should run in SQL SERVER 2000 also.

I solved that using a while loop.

But they are saying that they will accept the solution using SET BASED approach.

How to do that?

Thanks in advance


Refer to this article, Ranking In SQL Server 2000

The author talks about how to implement Dense_Rank()


You may try something like this:

SELECT  * ,
    ( SELECT    COUNT(C1)
      FROM      T1 
      WHERE     P1.C1>= T.C
    ) AS Rnk
FROM    T
ORDER BY C DESC;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜