use single table

Question

I want a column to show a variance of sales using the same table which has data date wise in rows.
I will declare at the starting 01-09-2020 as Last month and 01-10-2020 as the current month

ProductID – Period – sales

9819 – 01-09-2020 – 100

9819 – 01-10-2020 – 200

8827 – 01-09-2020 – 50

8827 – 01-10-2020 – 200

4453 – 01-10-2020 – 300

so I want to get result for only 01-10-2020 of all prodcut ID which are there in 01-10-2020
It should show 3 lines for 1-10-2020

Expected result

ProductID – Period – Last month – Current month – variance

9819 – 01-10-2020 – 100 – 200 – 100

8827 – 01-10-2020 – 50 – 200 – 150

4453 – 01-10-2020 – 0 – 300 – 300

0
Sandy 2 months 0 Answers 21 views 0

Leave an answer