Page 1 of 2

consolidate the date ranges

Posted: Mon Aug 10, 2009 5:40 am
by n.parameswara.reddy@accen
S.No WSLR_PARTY_ID WSLR_CUST_PARTY_ID BRND_CD PRC_GRP_CD PDCN_ITEM_ID PTR_AMT EFF_START_DT EFF_END_DT
1 Abc Abc123 BUD 411 333 10 20/05/2009 8/19/2009
2 Abc Abc123 BUD 411 333 10 20/08/2009 9/19/2009
3 Abc Abc123 BUD 411 333 11 20/09/2009 10/19/2009
4 Abc Abc123 BUD 411 333 10 20/10/2009 11/19/2009
5 Abc Abc123 BUD 411 333 10 20/11/2009 12/31/3999



On this input dataset we perform operations so as to consolidate the date ranges for the same PTR_AMT while maintaining all the pricing changes in a chronological order.
The result . Note that changes in start and end dates and how the data has been consolidated.
S.No WSLR_PARTY_ID WSLR_CUST_PARTY_ID BRND_CD PRC_GRP_CD PDCN_ITEM_ID PTR_AMT EFF_START_DT EFF_END_DT
1 Abc Abc123 BUD 411 333 10 20/05/2009 9/19/2009
2 Abc Abc123 BUD 411 333 11 20/09/2009 10/19/2009
3 Abc Abc123 BUD 411 333 10 20/10/2009 12/31/3999
This is my requirement please help me on this........................

Posted: Mon Aug 10, 2009 5:41 am
by ArndW
Could you restate your rule in words, I am not certain what you are trying to group by or retrieve from your example.

Posted: Mon Aug 10, 2009 5:42 am
by miwinter
I can't decipher that 'requirement' at all - it is very unclear.

sfsdafsd

Posted: Mon Aug 10, 2009 5:48 am
by n.parameswara.reddy@accen
fasfsdf

Posted: Mon Aug 10, 2009 5:51 am
by miwinter
Sort records in the correct order (amount) - you may also need to aggregate these - and employ stage variables to manage your 'date minus one' requirement.

Posted: Mon Aug 10, 2009 5:56 am
by n.parameswara.reddy@accen
miwinter wrote:Sort records in the correct order (amount) - you may also need to aggregate these - and employ stage variables to manage your 'date minus one' requirement.

no, this amount should be in the same order

Posted: Mon Aug 10, 2009 5:58 am
by miwinter
What should be in the same order - the output? :? If that's the case, sort that again for your requirement.

Posted: Mon Aug 10, 2009 6:13 am
by ShaneMuir
If I understand your requirement, then you will have to do this sequentially. If you have extra key fields that you are not sharing then you would partition by them.
You will have to sort by the start date ascending. You will need several variables which hold the start and end dates of the current incoming record and the previous row. The first new row for a given key you would hold your start date in a variable and the end date in a variable. Then for the next row you would compare the current start date to the previous end date.
If there is an overlap you would set the end date variable to be the current end date, and leave the start date as per the value in the variable.
If there is no overlap then you would reset the start and end dates in the variable with those in the current record.

You will probably have to dedup the records after the fact based on the key and start date and select the last record.

Posted: Mon Aug 10, 2009 6:18 am
by chulett
:evil: Give me a f'ing break. That kind of behaviour - going back and replacing your posts with random crap - falls squarely into the 'childish' camp and pretty much guarantees you a spot on the 'People We Tend To Ignore' list as who knows when you'll pull that crap again.

Re: xzcvxczv

Posted: Mon Aug 10, 2009 6:19 am
by ShaneMuir
n.parameswara.reddy@accen wrote:zxcvxxv
WTF?!

Posted: Mon Aug 10, 2009 6:22 am
by miwinter
A-men... x2... :wink:

Next time I'll pass on replying I think :)

Posted: Mon Aug 10, 2009 6:24 am
by n.parameswara.reddy@accen
miwinter wrote:A-men... x2... :wink:

Next time I'll pass on replying I think :)
hay just i am replacing the requirement

Posted: Mon Aug 10, 2009 6:31 am
by n.parameswara.reddy@accen
chulett wrote::evil: Give me a f'ing break. That kind of behaviour - going back and replacing your posts with random crap - falls squarely into the 'childish' camp and pretty much guarantees you a spot on the 'People We Tend To Ignore' list as who knows when you'll pull that crap again.

hay! just i am replacing the requirement

Posted: Mon Aug 10, 2009 6:36 am
by chulett
Alright, fine. Next time do that without the intermediate shenanigans, please and rather than replace everything posted so far simply add a new post that clarifies your requirement.

No need for all that revisionist history as now existing replies can make little to no sense.

Posted: Mon Aug 10, 2009 7:30 am
by ShaneMuir
In that case - refer back to my previous post as it should give you enough direction to get you on your way.