Say I have a table like this:
column 1 | timestamp |
---|---|
a | 1 |
a | 2 |
a | 3 |
b | 4 |
b | 5 |
a | 6 |
a | 7 |
I need the output of the query like this:
column 1 | timestamp |
---|---|
a | 1 |
b | 4 |
a | 6 |
i.e., I just need to track the changes in columns, and the min timestamp against it, but I’m not able to think of a way to do this. Suggest me the optimal query which can help me do this. Please try to keep the CTEs/Subqueries to the minimum, as the data is huge. Thanks. The SQL I’m using is PrestoSQL.