I have a table that gives me data regarding the journey of a proposal. A proposal may hit different statuses, which are then mapped to a milestone. A status may be hit more than once in succession, but we don't want the milestone to repeat.
ID | MilestoneID |
---|---|
1 | 1 |
1 | 2 |
1 | 3 |
1 | 3 |
So in the example above, this would be a problem. How can I write a query that tells me if a milestone ID is the same on the next row in the journey table?
SELECT ID, MilestoneID, count(*) as vol
FROM Journey
GROUP BY ID, MilestoneID
HAVING count(*) > 1
The above code tells me that we have instances where the Milestone is repeated, but I need to know if they are on successive rows.