title: Teradata SQL - Grouping Observations Close In Time Together?
body: <p>I have a table that has line item transactions by account, date, and time (two separate fields) but there is not a unique identifier for each individual transaction.  I want to take a best guess at this by grouping line items that are done around the same time, say within an hour of each other to be conservative.  My initial thought was extract the hour from the time field and use that but there are instances where a transaction can cross an hour.  For example, line 1 was done at 8:57 AM and line 2 was done at 9:01 AM.  I would want these to be grouped together but just using the hour would not accomplish that.</p>
  
  <p>Any thoughts?  Example data is provided below with an added field showing if I would group them together or not.</p>
  
  <pre><code>Account | Date   | Time      | Group
  A       | 1/1/16 | 8:57:00   | 1
  A       | 1/1/16 | 9:01:00   | 1
  A       | 1/1/16 | 9:16:00   | 1
  A       | 1/1/16 | 12:15:00  | 2
  A       | 1/1/16 | 12:32:00  | 2
  B       | 1/2/16 | 7:23:00   | 3
  B       | 1/2/16 | 7:24:00   | 3
  B       | 1/3/16 | 9:18:00   | 4
  B       | 1/3/16 | 11:24:00  | 5
  </code></pre>