Skip to content
Advertisement

Iterate through timestamps and calculate difference between them

DB-Fiddle:

Expected Result:


I want to calculate the difference of the sales_quantity of different timestamps of products that are also existing in the table products.

Therefore, I created this query:

The query itself works but my issue is that I can only query two timestamps separately.

Therefore, I am wondering if there is a solution that iterates through all the timestamps and gives me the expected result?

Advertisement

Answer

You can try the below – DEMO

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