title: Deleting records that are similar with previous one SQL Server
body: <p>I am looking for a query which fetches me the data that is different compared to the previous row, </p>
  
  <p>A sample code (with table creation and data) </p>
  
  <pre><code>create table #temp 
  (id int, eid int, name char(10),estid int, ecid int, epid int, etc char(5)  )
  
  insert into #temp values (1,1,'a',1,1,1,'a')
  insert into #temp values (2,1,'a',1,1,1,'a')
  insert into #temp values (3,1,'a',2,1,1,'a')
  insert into #temp values (4,1,'a',1,1,1,'a')
  insert into #temp values (5,1,'a',1,1,1,'a')
  insert into #temp values (6,1,'a',1,2,1,'a')
  insert into #temp values (7,1,'a',1,1,1,'a')
  insert into #temp values (8,1,'a',2,1,1,'a')
  insert into #temp values (9,1,'a',1,1,1,'a')
  insert into #temp values (10,1,'a',1,1,1,'a')
  insert into #temp values (11,2,'a',1,1,1,'a')
  insert into #temp values (12,2,'a',1,1,1,'a')
  insert into #temp values (13,2,'a',2,1,1,'a')
  insert into #temp values (14,2,'a',1,1,1,'a')
  insert into #temp values (15,2,'a',1,1,1,'a')
  insert into #temp values (16,2,'a',1,2,1,'a')
  insert into #temp values (17,2,'a',1,1,1,'a')
  insert into #temp values (18,2,'a',2,1,1,'a')
  insert into #temp values (19,2,'a',1,1,1,'a')
  insert into #temp values (20,2,'a',1,1,1,'a')
  </code></pre>
  
  <p>I tried with some ways of getting the data as the way that i expected</p>
  
  <pre><code>SELECT * INTo #Temp_Final
  FROM  #temp
  WHERE #temp.%%physloc%%
        NOT IN (SELECT Min(b.%%physloc%%)
                FROM   #temp b
                GROUP BY eid,name,estid,ecid,epid,etc)
           ORDER BY id
  
  SELECT * FROM #temp WHERE id not in (SELECT id FROM #Temp_Final) ORDER BY id
  </code></pre>
  
  <p>But i wasn't getting the result as i expected...</p>
  
  <p>This is how the result needs to be</p>
  
  <pre><code>select * from #temp where id in (1,3,4,6,7,8,9,11,13,14,16,17,18,19)
  </code></pre>