'How to code a query in postgres and show each record when price changes in a series of data

enter image description here

Highlighted in yellow are the records that will be the result set.

enter image description here



Solution 1:[1]

You can try to use ROW_NUMBER window function.

SELECT *
FROM (
    SELECT *,ROW_NUMBER() OVER(PARTITION BY beast_bid_price ORDER BY posted DESC) rn
    FROM T
) t1
WHERE rn = 1

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 D-Shih