0

I'm trying to calculate price elasticity in product level, where I have to find Δprice/Δvolume for elasticity calculations. We have a weekly aggregated sales data with start and end date of each week. I know this is not the optimal solution but I try to create temp tables and then join them week over week to find Δprice/Δvolume, from the table:

sales2022YTD TABLE Example

with the code:

with X as 
(SELECT DATE_FROM, PRODUCT_NAME, VOLUME as volume1, NET_SALES/VOLUME as netprice1
FROM sales2022YTD
WHERE DATE_FROM = '2022-01-03'),

Y as
(SELECT DATE_FROM, PRODUCT_NAME, VOLUME as volume2, NET_SALES/VOLUME as netprice2
FROM sales2022YTD
WHERE DATE_FROM = '2022-08-03')

SELECT netprice2/netprice1 as pricediff, volume2/volume1 as volumediff
FROM Y as y1
LEFT JOIN X as x1
ON y1.PRODUCT_NAME = x1.PRODUCT_NAME
WHERE x1.PRODUCT_NAME = y1.PRODUCT_NAME

So basically I want to merge the two temp tables on the common product names and see weekly price and volume differences. With this query, I get only pricediff and volumediff columns without any value. I also would like to note that I have common product names in the two seperate weeks.

As a further step, I will extend the code to 52 weeks to calculate weekly elasticity. Any easier/less bulkier approach would be really appreciated.

Much thanks!!

NickW
  • 8,430
  • 2
  • 6
  • 19
canerman
  • 1
  • 1
  • Please don’t link to images, add all relevant information directly to your question preferably as editable text – NickW Dec 06 '22 at 08:09
  • I tried to add to question but the format is sketched so I added a snapshot instead. Thank you for the recommendation! – canerman Dec 06 '22 at 10:53
  • This post explains how to format tables in Stackoverflow: https://meta.stackoverflow.com/questions/277716/how-can-i-create-a-table-in-a-post – NickW Dec 06 '22 at 12:09

0 Answers0