So my table looks like this
PK1 | PK2 | User(not unique)| value 1 | value 2| timestamp
when added
I want to get most recent values for value 1 and value 2 for every user. How would I achieve this?
Also, PKs are not unique on their own, but in combination.
2
Answers
We can use
ROW_NUMBER()
here:Another alternative is to use PostgreSQL’s proprietary
distinct on ()