<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>DBExpert</title>
	<atom:link href="https://dbexpert.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>https://dbexpert.wordpress.com</link>
	<description>Deals with DataBase</description>
	<lastBuildDate>Wed, 11 May 2011 14:30:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='dbexpert.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>https://s-ssl.wordpress.com/i/buttonw-com.png</url>
		<title>DBExpert</title>
		<link>https://dbexpert.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="https://dbexpert.wordpress.com/osd.xml" title="DBExpert" />
	<atom:link rel='hub' href='https://dbexpert.wordpress.com/?pushpress=hub'/>
		<item>
		<title>How to generate rownumbers using RANK(),DENSE_RANK(),ROW_NUMBER Functions</title>
		<link>https://dbexpert.wordpress.com/2011/05/11/how-to-generate-rownumbers-using-rankdense_rankrow_number-functions/</link>
		<comments>https://dbexpert.wordpress.com/2011/05/11/how-to-generate-rownumbers-using-rankdense_rankrow_number-functions/#comments</comments>
		<pubDate>Wed, 11 May 2011 14:23:52 +0000</pubDate>
		<dc:creator>vijayanj</dc:creator>
				<category><![CDATA[SQL General]]></category>

		<guid isPermaLink="false">http://dbexpert.wordpress.com/?p=317</guid>
		<description><![CDATA[Hi All, In different kind of situation we may required to generate rownumber on a table. Here I have explained three methods to get the rownumber on a table. You can decide yourself to find the best approach based on your requirement. Method: 1 USING RANK()FUNCTION: Rank function generates the rownumber based on the Order by column [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dbexpert.wordpress.com&amp;blog=8710838&amp;post=317&amp;subd=dbexpert&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hi All,</p>
<p>In different kind of situation we may required to generate rownumber on a table. Here I have explained three methods to get the rownumber on a table.</p>
<p>You can decide yourself to find the best approach based on your requirement.</p>
<p><span style="text-decoration:underline;"><strong>Method: 1</strong></span></p>
<p><span style="text-decoration:underline;"><strong>USING RANK()FUNCTION:</strong></span></p>
<p>Rank function generates the rownumber based on the Order by column and it considers same rank for same value in the given order by column and<strong> it will consider actual row number as next rank</strong>.</p>
<p>Ex:</p>
<p>&#8212;&#8212;&#8211;USING RANK()&#8212;&#8212;&#8212;</p>
<p>SELECT RANK() OVER (</p>
<p>ORDER BY Title) AS [RANK],</p>
<p>LoginID, ManagerID, Title, BirthDate, MaritalStatus, Gender</p>
<p>FROM [HumanResources].[Employee]</p>
<p><a href="http://dbexpert.files.wordpress.com/2011/05/rank.png"><img class="alignnone size-medium wp-image-318" title="rank" src="http://dbexpert.files.wordpress.com/2011/05/rank.png?w=300&#038;h=191" alt="" width="300" height="191" /></a></p>
<p><span style="text-decoration:underline;"><strong>Method: 2</strong></span></p>
<p><span style="text-decoration:underline;"><strong>USING DENSE_RANK()FUNCTION:</strong></span></p>
<p>DENSE_RANK () function generates the rownumber based on the Order by column and it considers same rank for same value in the given order by column and <strong>it will consider actual rank number as next rank</strong>.</p>
<p>Ex:</p>
<p>&#8212;&#8212;&#8211;DENSE_RANK()&#8212;&#8212;&#8212;</p>
<p>SELECT DENSE_RANK() OVER (</p>
<p>ORDER BY Title) AS DENSE_RANK,</p>
<p>LoginID, ManagerID, Title, BirthDate, MaritalStatus, Gender</p>
<p>FROM [HumanResources].[Employee]</p>
<p><a href="http://dbexpert.files.wordpress.com/2011/05/dense_rank.png"><img class="alignnone size-medium wp-image-319" title="Dense_rank" src="http://dbexpert.files.wordpress.com/2011/05/dense_rank.png?w=300&#038;h=232" alt="" width="300" height="232" /></a></p>
<p><span style="text-decoration:underline;"><strong>Method: 3</strong></span></p>
<p><span style="text-decoration:underline;"><strong>USING ROW_NUMBER() FUNCTION:</strong></span></p>
<p>ROW_NUMBER () function generates the rownumber based on the Order by column and<strong> it considers identity number for the given order by column.</strong></p>
<p>EX:</p>
<p>&#8212;&#8212;&#8211;ROW_NUMBER()&#8212;&#8212;&#8212;</p>
<p>SELECT ROW_NUMBER() OVER (</p>
<p>ORDER BY Title) AS RowNumber,</p>
<p>LoginID, ManagerID, Title, BirthDate, MaritalStatus, Gender</p>
<p>FROM [HumanResources].[Employee]</p>
<p><a href="http://dbexpert.files.wordpress.com/2011/05/rownumber.png"><img class="alignnone size-medium wp-image-320" title="RowNumber" src="http://dbexpert.files.wordpress.com/2011/05/rownumber.png?w=300&#038;h=251" alt="" width="300" height="251" /></a></p>
<br />Filed under: <a href='https://dbexpert.wordpress.com/category/sql-general/'>SQL General</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dbexpert.wordpress.com/317/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dbexpert.wordpress.com/317/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dbexpert.wordpress.com/317/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dbexpert.wordpress.com/317/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/dbexpert.wordpress.com/317/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/dbexpert.wordpress.com/317/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/dbexpert.wordpress.com/317/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/dbexpert.wordpress.com/317/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dbexpert.wordpress.com/317/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dbexpert.wordpress.com/317/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dbexpert.wordpress.com/317/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dbexpert.wordpress.com/317/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dbexpert.wordpress.com/317/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dbexpert.wordpress.com/317/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dbexpert.wordpress.com&amp;blog=8710838&amp;post=317&amp;subd=dbexpert&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>https://dbexpert.wordpress.com/2011/05/11/how-to-generate-rownumbers-using-rankdense_rankrow_number-functions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="https://secure.gravatar.com/avatar/9cc2c61e4673cd42bc15f6fb4eafaab7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">vijayanj</media:title>
		</media:content>

		<media:content url="http://dbexpert.files.wordpress.com/2011/05/rank.png?w=300" medium="image">
			<media:title type="html">rank</media:title>
		</media:content>

		<media:content url="http://dbexpert.files.wordpress.com/2011/05/dense_rank.png?w=300" medium="image">
			<media:title type="html">Dense_rank</media:title>
		</media:content>

		<media:content url="http://dbexpert.files.wordpress.com/2011/05/rownumber.png?w=300" medium="image">
			<media:title type="html">RowNumber</media:title>
		</media:content>
	</item>
	</channel>
</rss>
