I have a table like this:
OrderID | PhaseID | Timestamp
1 | 1 | 1/1
1 | 2 | 1/2
1 | 3 | 1/3
1 | 2 | 1/4
1 | 4 | 1/5
I’m trying to get a query to return the most recent timestamp for each orderphase combination without being followed by a lesser phaseid. Something like this:
OrderID | PhaseID | MaxTimestampWithoutBeingFollowedByLesserPhaseID
1 | 1 | 1/1
1 | 2 | 1/4
1 | 3 | NULL
1 | 4 | 1/5
I keep running around in circles and coming up with this problem of a conditional aggregate query.
Can anybody figure out the query or give me some pointers?
EDIT ref a.MaxTimestamp