title: Find top consecutive rows where a column value is equal between them
body: <p>I need to get all the consecutive top row where a column value is equal between them</p>
  
  <p>my table is:</p>
  
  <pre><code>CREATE TABLE [dbo].[Items](
    [Id] [int]  NOT NULL,
    [IdUser] [int] NOT NULL,
    [CreatedDate] [datetime] NOT NULL,
    [SomeData] nvarchar(50) NOT NULL);
  </code></pre>
  
  <p>and i want the top rows (ordered by <code>Id</code> desc) with the same <code>IdUser</code>   </p>
  
  <p>if table data is:</p>
  
  <pre><code>Id  IdUser  CreatedDate                 SomeData
  --- ------- ------------------------    --------
  1   1       2017-09-21T09:42:01.407Z    sdafsasfa
  2   1       2017-09-21T09:42:01.407Z    sdafsasfa
  4   2       2017-09-21T09:42:01.41Z     sdafsasfa
  5   3       2017-09-21T09:42:01.41Z     sdafsasfa
  7   3       2017-09-21T09:42:01.413Z    sdafsasfa
  8   3       2017-09-21T09:42:01.413Z    sdafsasfa
  9   10      2017-09-21T09:42:01.417Z    sdafsasfa
  11  11      2017-09-21T09:42:01.417Z    sdafsasfa
  12  2       2017-09-21T09:42:01.42Z     sdafsasfa
  15  2       2017-09-21T09:42:01.42Z     sdafsasfa
  </code></pre>
  
  <p>I want :</p>
  
  <pre><code>Id  IdUser  CreatedDate                 SomeData
  --- ------- ------------------------    --------
  12  2       2017-09-21T09:42:01.42Z     sdafsasfa
  15  2       2017-09-21T09:42:01.42Z     sdafsasfa
  </code></pre>
  
  <p>if table data is:</p>
  
  <pre><code>Id  IdUser  CreatedDate                 SomeData
  --- ------- ------------------------    --------
  1   1       2017-09-21T09:42:01.407Z    sdafsasfa
  2   1       2017-09-21T09:42:01.407Z    sdafsasfa
  4   2       2017-09-21T09:42:01.41Z     sdafsasfa
  </code></pre>
  
  <p>I want :</p>
  
  <pre><code>Id  IdUser  CreatedDate                 SomeData
  --- ------- ------------------------    --------
  4   2       2017-09-21T09:42:01.41Z     sdafsasfa
  </code></pre>
  
  <p><a href="http://www.sqlfiddle.com/#!6/e42df/52" rel="nofollow noreferrer">SqlFiddle</a></p>