Additional SQL Server features and topics not covered by specific categories
Getting rate change
-- --
957
Reputation points
Hi
We have two tables Orders (OrderID, OrderDate, ClientID) and OrderProducts (ID, OrderID, ProductID, Amount).
How can we use T-SQL to find for each client the last two rates (Amount column) for each product and the dates they were first used in orders? Basically we are trying to find rate changes for each product for each client over time.
We need output like below grouped by client and then product.
ClientID, ProductID, Last Rate (Amount), Order Date Last Rate First Used, Current Rate (Amount), Order Date Current Rate First Used
Thanks
SQL Server | Other
SQL Server | Other
Sign in to answer