This is a very simple question and I feel like the answer should be obvious, but it's been two hours I'm not finding a solution.
I am willing to transform discrete data flux stored in PostgreSQL. They are originally stored as high frequency samples. So for a single timestamp, I have may have multiple similar values. I wanted to make a variable-length sampling, so similar values would only be stored once in the sequence. It sounds like a simple count(*) group by, but since I want to keep the lowest timestamp of the sequence, it can't be handled that way.
t1 2
t2 2 t1 2 3
t3 2 -> t4 3 1
t4 3 t5 2 1
t5 2
I would like to have a request that is as fast as possible. Any help would be greatly appreciated.