title: Ranking combination of columns with rank using Dense_Rank in SQL Server
body: <p>I have a requirement where I have the data as </p>
  
  <pre><code>StageID         Department Number       UserEmail
  
  732                60012                user1@testing.com
  733                60012                user1@testing.com
  734                60012                user1@testing.com
  735                60012                user2@testing.com
  736                60012                user2@testing.com
  737                60013                user3@testing.com   
  738                60013                user3@testing.com
  </code></pre>
  
  <p>I want to get the output like this</p>
  
  <pre><code>StageID         Department Number       UserEmail       DRank
  
  732              60012              user1@testing.com   1
  733              60012              user1@testing.com   1
  734              60012              user1@testing.com   1
  735              60012              user2@testing.com   2
  736              60012              user2@testing.com   2
  737              60013              user3@testing.com   1
  738              60013              user3@testing.com   1
  </code></pre>
  
  <p>I want the combination of <strong>DepartmentNumber</strong> and <strong>UserEmail</strong> to be considered when ranking the records. I am using <strong>DENSE_RANK()</strong> over partition to achieve this, but somehow I am not able to get my desired output. I am not sure where I am going wrong. Could anyone please help me in this</p>
  
  <p>This is the query I used</p>
  
  <pre><code>SELECT StageID, DepartmentNumber, UserEmail
          ,DENSE_RANK() OVER (PARTITION BY DepartmentNumber, UserEmail
           ORDER BY DepartmentNumber, UserEmail ASC) AS DRANK 
     FROM mytable 
  </code></pre>