Posted in General

Difference between OVER(), RANK() and DENSE_RANK()

I came across this article at 4GuysFromRolla. They spoke about OVER, RANK, DENSE_RANK in SQL Server 2005. SQL brought in these functions (oh yeah oracle had it since i was wearing nappies). Though i used RANK’s in Oracle, i didn’t really understand the difference before.

  1. OVER – gives sequential numbers
  2. RANK – gives ranks to records, so more than a record may have same rank
  3. DENSE_RANK – same as ranks, but will continue the ranking number, but rank will skip ranks when more than a record gets same rank.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s