Nicolas Beuzeboc <nicolasb@norchemlab.com> writes:
> I was looking for a simple solution to this problem. I can't find a way
> to group on b and n by just collapsing sequential n's (identical n's
> right next to each other) the sorting condition is the timestamp.
I'm not totally certain that I understand what you need, but it sounds
like the SELECT DISTINCT ON feature might solve it for you. Look into
our SELECT reference page at the "weather reports" example.
regards, tom lane