Record split based on date range of other table

Database
The Teradata Database channel includes discussions around advanced Teradata features such as high-performance parallel database technology, the optimizer, mixed workload management solutions, and other related technologies.
Enthusiast

Record split based on date range of other table

 

Hello every one, 

 

Could someone please help me with the below sceanrio.

 

I want to split the rows of one table based on date range of another table.

 

I have table called sfe and sfe_exp

 

Based on the sfe_exp table date range i want to split the recors in sfe table by altering the data, when add_remove = 1 then i have to add the quantity , when it is 0 i have to substract the quantity.

 

Below is the sample data
sfe

 

Storefe_codevalid_fromvalid_toquantity
2002FE1-Jan-1731-Dec-994

sfe_exp:

 

Storefe_codestart_dateend_dateadd_removeQuantity
2002FE20-Feb-1710-Mar-1712
2002FE20-Apr-1729-May-1701
2002FE5-Jul-1725-Aug-1713

 

output : 

Storefe_codevalid_fromvalid_toquantity
2002FE1-Jan-1719-Feb-174
2002FE20-Apr-1729-May-176
2002FE30-May-174-Jul-173
2002FE5-Jul-1725-Aug-177
2002FE26-Aug-1731-Dec-994

 

Sceanio 2: 

sfe

Storefe_codevalid_fromvalid_toquantity
2002FE1-Jan-1731-Dec-994

 

sfe_exp

Storefe_codestart_dateend_dateadd_removeQuantity
2002FE20-Feb-1719-Apr-1712
2002FE20-Apr-1729-May-1701

 

 

 

Storefe_codevalid_fromvalid_toquantity
2002FE1-Jan-1719-Feb-174
2002FE20-Feb-1719-Apr-176
2002FE20-Apr-1729-May-173
2002FE30-May-1731-Dec-994
1 REPLY
Enthusiast

Re: Record split based on date range of other table

Can someone please help me with this sceanrio