Given table:
Agreement:
id: int
type: string
version: int
Given Records like:
1 | Terms | 1
2 | Terms | 2
3 | Privacy | 1
I'd like a query that outputs:
2 | Terms | 2
3 | Privacy | 1
I've tried all manner of distinct and self joins to max(version), I just can't seem to crack it.
The easiest thing would probably be to use the
rank
window function: