MySQL Forums
Forum List  »  Newbie

Re: How to get the date of each price change in the Northwind database?
Posted by: Peter Brawley
Date: December 22, 2021 05:43PM

Something like this?

SELECT * 
FROM (
  SELECT
    productid, startdate,enddate,standardcost,
    LAG(standardcost, 1) OVER (
        PARTITION BY productid
        ORDER BY startdate
    ) as prev_cost
  FROM products
) x
WHERE standardcost<>prev_cost;

Options: ReplyQuote


Subject
Written By
Posted
Re: How to get the date of each price change in the Northwind database?
December 22, 2021 05:43PM


This forum is currently read only. You can not log in or make any changes. This is a temporary situation.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.