title: SQL Server : find store that has 4 or more transactions within 10 minutes
body: <p>I want to find a list of the stores that have 4 or more transactions within 10 minutes interval</p>
  
  <p>Sample data in SQL Server 2012:</p>
  
  <pre><code>IF OBJECT_ID('tempdb..#t') is not null DROP TABLE #t;
  create TABLE #t
  (
   cID int,  trans_time  datetime,  store_address varchar(20)
  )
  insert into #t values
   (111, '5/27/18 6:36 AM', '79 street, NY')
  ,(112, '5/27/18 6:53 AM', '79 street, NY')
  ,(113, '5/27/18 6:54 AM', '79 street, NY')
  ,(114, '5/27/18 6:55 AM', '79 street, NY')
  ,(115, '5/27/18 6:59 AM', '79 street, NY')
  ,(116, '5/27/18 9:45 PM', '79 street, NY')
  ,(117, '3/24/18 6:35 AM', '44 tree ave,FL')
  ,(118, '3/24/18 6:36 AM', '44 tree ave,FL')
  ,(119, '3/24/18 6:36 AM', '44 tree ave,FL')
  ,(120, '3/24/18 6:36 AM', '2 pop ave, NJ')
  </code></pre>
  
  <p>Expected output</p>
  
  <pre><code>cID   transa_time       store_address
  -------------------------------------
  112   5/27/18 6:53 AM   79 street, NY
  113   5/27/18 6:54 AM   79 street, NY
  114   5/27/18 6:55 AM   79 street, NY
  115   5/27/18 6:59 AM   79 street, NY
  </code></pre>
  
  <p>my solution not working properly</p>
  
  <pre><code>with CTE as (select #t.*, isnull( lead(trans_time, 3) over (partition by store_address order by trans_time),trans_time) as t3 from #t)
  select CTE.*
  from CTE
  where DATEDIFF(minute, trans_time,t3) &lt;= 10
  order by cID
  </code></pre>