title: TSQL Syntax to increment on group of two columns
body: <p>I need help with syntax to increment a column based on grouping of 2 columns.</p>
  
  <p>The following shows the desired output where I want to show an increment for each ID split by DateTime</p>
  
  <p><a href="https://i.stack.imgur.com/J0UPC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/J0UPC.png" alt="enter image description here"></a></p>
  
  <p>I've tried the following without success</p>
  
  <pre><code>SELECT hl.ts_DateTime,  
         hl.Tagname as [ID],  
         hl.TagValue as [Value],
         DENSE_RANK() OVER (ORDER BY hl.Tagname, ts_datetime) AS RowFilter
  FROM   Table1 hl 
  ORDER  BY hl.Tagname,  hl.ts_DateTime
  
  
  SELECT hl.ts_DateTime,  
         hl.Tagname as [ID],  
         hl.TagValue as [Value],
         ROW_NUMBER() OVER (PARTITION BY ts_DateTime, Tagname  ORDER BY ts_DateTime ASC)  AS RowFilter
  FROM   Table1 hl 
  ORDER  BY hl.Tagname,  hl.ts_DateTime
  </code></pre>
  
  <p>Example sqlfiddle => <a href="http://sqlfiddle.com/#!18/131c8/1" rel="nofollow noreferrer">http://sqlfiddle.com/#!18/131c8/1</a></p>