<?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/"
	>

<channel>
	<title>DENSE_RANK () &#8211; Hostry Help Center</title>
	<atom:link href="https://help.hostry.com/article-tags/dense_rank/feed/" rel="self" type="application/rss+xml" />
	<link>https://help.hostry.com</link>
	<description>Full information on how to use HOSTRY, provided by 24/7 community based support</description>
	<lastBuildDate>Wed, 14 Apr 2021 06:46:11 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.9.12</generator>

<image>
	<url>https://help.hostry.com/wp-content/uploads/cache/2021/01/cropped-apple-icon-180x180-1/836712163.png</url>
	<title>DENSE_RANK () &#8211; Hostry Help Center</title>
	<link>https://help.hostry.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How To Use The DENSE_RANK () Function on MySQL</title>
		<link>https://help.hostry.com/knowledge-base/how-to-use-the-dense_rank-function-on-mysql/</link>
					<comments>https://help.hostry.com/knowledge-base/how-to-use-the-dense_rank-function-on-mysql/#comments</comments>
		
		<dc:creator><![CDATA[Alex]]></dc:creator>
		<pubDate>Tue, 12 May 2020 07:03:43 +0000</pubDate>
				<guid isPermaLink="false">https://help.hostry.com/?post_type=ht_kb&#038;p=1684</guid>

					<description><![CDATA[DENSE_RANK () is a window function that assigns the rank of each row within a section or result set without spaces in the ranking of values.The row rank is increased by one from among the different rank values ​​that go before the row. The syntax for the DENSE_RANK () function [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p><strong>DENSE_RANK ()</strong> is a window function that assigns the rank of each row within a section or result set without spaces in the ranking of values.The row rank is increased by one from among the different rank values ​​that go before the row. The syntax for the DENSE_RANK () function is as follows:</p>



<pre class="wp-block-preformatted">DENSE_RANK() OVER (
PARTITION BY &lt;expression&gt;[{,&lt;expression&gt;...}]
ORDER BY &lt;expression&gt; [ASC|DESC], [{,&lt;expression&gt;...}]
)</pre>



<p>Here is needs to specify some clarifications:</p>



<blockquote class="wp-block-quote"><p>The <strong>PARTITION BY </strong>clause divides the result sets created by this FROM clause into sections. The <strong>DENSE_RANK ()</strong> function is applied to each section</p><p>The <strong>ORDER BY</strong> clause determines the order of the rows in each section in which the <strong>DENSE_RANK () </strong>function works</p></blockquote>



<p>Unlike the RANK () function, the DENSE_RANK () function always returns consecutive rank values.</p>



<p>Suppose we have a table <strong><em>a</em></strong> with some data examples:</p>



<pre class="wp-block-preformatted">CREATE TABLE а (
val INT
);

INSERT INTO а(val)
VALUES(1),(2),(2),(3),(4),(4),(5);

SELECT
*
FROM
а;</pre>



<p>The next statement uses the <strong>DENSE_RANK () </strong>function to rank each row:</p>



<pre class="wp-block-preformatted">SELECT
val,
DENSE_RANK() OVER (
ORDER BY val
) my_rank
FROM
a;</pre>



<h2 id="dense_rank-function-example-in-mysql" > DENSE_RANK () function example in MySQL </h2>



<p>For demonstration, the sales table created in the window function guide will be used. The following statement uses the <strong>DENSE_RANK ()</strong> function to rank sales employees by sales amount. </p>



<pre class="wp-block-preformatted">SELECT
sales_employee,
fiscal_year,
sale,
DENSE_RANK() OVER (PARTITION BY
fiscal_year
ORDER BY
sale DESC
) sales_rank
FROM
sales;</pre>



<p>Explanations will be given below:</p>



<ul><li>The <strong>PARTITION BY </strong>clause divides the result sets into sections using the fiscal year</li><li>The <strong>ORDER BY</strong> clause indicates the sales order of the sales staff in descending order.</li><li>The <strong>DENSE_RANK () </strong>function is applied to each section with the row order specified in the ORDER BY clause.</li></ul>



<p>Now&#8217;s Done! Yoy know how to use the  &nbsp;DENSE_RANK() MySQL!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://help.hostry.com/knowledge-base/how-to-use-the-dense_rank-function-on-mysql/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
	</channel>
</rss>
