Page 1 of 1

Change Previous record

Posted: Mon Apr 18, 2005 11:10 am
by rcil
Hello All,

How is it possible to make the previous record zero.

Code: Select all

Col1	Col2    Min_Date	Max_Date	Code	COunt
123 	456 	2004-01-01 	2004-12-10 	30 	1
123 	456 	2004-12-11 	2004-12-10 	30 	1
If current.col1 = prev.col1 and current.col2 = prev.col2 and min_date = max_date + 1 and code = 30 then make previous record 0.

Result :

Code: Select all

Col1	Col2    Min_Date	Max_Date	Code	COunt
123 	456 	2004-01-01 	2004-12-10 	30 	0
123 	456 	2004-12-11 	2004-12-10 	30 	1
Thanks

Posted: Mon Apr 18, 2005 3:28 pm
by Sainath.Srinivasan
Do a reverse sort on the required keys and perform the logic using stage variables.

Posted: Mon Apr 18, 2005 5:18 pm
by rcil
Sainath.Srinivasan wrote:Do a reverse sort on the required keys and perform the logic using stage variables.
I am trying to load everything into a Hash File. What kind of sort do I have to perform? and can you please explain how to perform the task with stage variables.

thanks

Posted: Tue Apr 19, 2005 3:30 am
by Sainath.Srinivasan
Sort on col1 asc, col2 asc, Min_Date desc, Max_Date desc.

Store col1, col2, Min_Date and Max_Date in corresponding stage variables to compare with next set.

You can then do
If prevMin_Date = link.Max_Date + 1 And (same keys and 30)
link.1_or_0 = 0
Else
link.1_or_0 = link.1_or_0
End