Use of RANK() and Partition by clause in SQL-Server 2005

Use of RANK() and Partition by clause in SQL-Server 2005
We will start by creating one table for demonstration and enter some records in it.
This blog is moved to “Extreme-Advice.com“, to read this post, kindly click here.
Advertisements

2 Responses to “Use of RANK() and Partition by clause in SQL-Server 2005”

  1. Ritesh Shah Says:

    I have been asked one question by Raju at my other blog, but answering the same here as that word press blog is dead now.https://riteshshah.wordpress.com/2009/03/03/use-of-rank-and-partition-by-clause-in-sql-server-2005/Here is the answer:create table #Temp( Name varchar(10), [Time] int, age int)GOinsert into #Tempselect 'Steve', 12, 33 UNION ALLselect 'Tim', 34 ,28 UNION ALLselect 'Mark', 22 ,37 UNION ALLselect 'Tom', 21 ,30 UNION ALLselect 'Cliff', 13, 33 UNION ALLselect 'Vini', 17, 28 UNION ALLselect 'Matt', 10 ,28 UNION ALLselect 'Ben', 9 ,29 UNION ALLselect 'Brandon', 15, 14select Name,[Time],Age,row_number() over(Order By [Time]) from #Temp

  2. Ritesh Shah Says:

    I have been asked one question by Raju at my other blog, but answering the same here as that word press blog is dead now.https://riteshshah.wordpress.com/2009/03/03/use-of-rank-and-partition-by-clause-in-sql-server-2005/Here is the answer:create table #Temp( Name varchar(10), [Time] int, age int)GOinsert into #Tempselect 'Steve', 12, 33 UNION ALLselect 'Tim', 34 ,28 UNION ALLselect 'Mark', 22 ,37 UNION ALLselect 'Tom', 21 ,30 UNION ALLselect 'Cliff', 13, 33 UNION ALLselect 'Vini', 17, 28 UNION ALLselect 'Matt', 10 ,28 UNION ALLselect 'Ben', 9 ,29 UNION ALLselect 'Brandon', 15, 14select Name,[Time],Age,row_number() over(Order By [Time]) from #Temp


Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: