Joining for customised Pre and Post event Transactions

Copper Contributor

Hi,

 

I have 2 tables and would like to capture the pre and post event transactions.

If the event period is less than or equal to 7 then Pre Event Sales should be for 7 days prior from Event BeginDate and 7 days post from EventEnd Days and actual days of event sales for EventSales.

 

For example:

If EventDays is 1 day which is <=7 then PreEvent_Sales should be captured for 7 days prior from event BeginDate. PostEvent Sales should be captured for 7 days post from event EndDate. EventSales should be captured for 1 day since Event is only for 1 day.

 

If EventDays is 11 days which is >=7 then PreEvent_Sales should be captured for 11 days prior from event BeginDate. PostEvent Sales should be captured for 11 days post from event EndDate. EventSales should be captured for 11 days since Event is only for 11 days.

 

I have attached the sample data in excel in 3 different sheets. Please educate how to achieve this.

 

Thanks

 

 

1 Reply

I need to achieve this in SQL server management studio.