Skip to content
Advertisement

Get products which had a price update last week

This is my table History:

I need to have every product which its price change last week AND the difference between last price and new price is more than 15 percent.

The desired result:

With this SQL query I have all products which their price changed last week :

But I have no idea how can reach the desired result.

Advertisement

Answer

You can use the analytic functions to find the previous values:

If you want to compare the latest productnr to the previous:

or, if you want to compare the first price per productnr this week to the last price last week:

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement