Note that there are some explanatory texts on larger screens.

plurals
  1. POSQL Server - Return sets with repeating values in sequential records
    primarykey
    data
    text
    <p>I have data that looks like the following:<br> The data is ordered by processID, then by step start date.<br> Step start date determines the sequence of the steps. Each step is approved by an approver (the approver ID's below are arbitrary)</p> <pre><code>╔═══════════╦══════════════════════════╦═══════════════╦════════════╗ ║ ProcessID ║ StepName ║Step Start Date║ ApproverID ║ ╠═══════════╬══════════════════════════╬═══════════════╬════════════╣ ║ 1 ║ Supervisor Approval ║1/1/2013 07:24 ║ A ║ ║ 1 ║ Sales Manager Approval ║1/1/2013 13:35 ║ B ║ ║ 1 ║ General Manager Approval ║1/3/2013 08:00 ║ B ║ ║ 1 ║ CEO Approval ║1/5/2013 14:40 ║ C ║ ║ 2 ║ Supervisor Approval ║1/2/2013 07:00 ║ A ║ ║ 2 ║ Sales Manager Approval ║1/2/2013 08:00 ║ B ║ ║ 2 ║ General Manager Approval ║1/2/2013 09:00 ║ C ║ ║ 2 ║ CEO Approval ║1/2/2013 10:00 ║ B ║ ╚═══════════╩══════════════════════════╩═══════════════╩════════════╝ </code></pre> <p>I need a TSQL query that would return the [ProcessID]'s for any process that has the same ApproverID in 2 or more consecutive steps.</p> <p>So in the example above, ProcessID #1 would be returned because Approver B approved steps 2 and 3 (consecutively). ProcessID #2 would not be returned because even though Approver B approved steps 2 and 4, they were not consecutive.</p> <p>Here is a SQL fiddle with the schema setup and some sample data: <a href="http://sqlfiddle.com/#!3/48589/1" rel="nofollow">SQL Fiddle</a></p> <p>Any help would be greatly appreciated!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload