Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
richard_chilvers
Specialist
Specialist

Finding a max (or min) value in a loaded table


I feel there should be an elegant way to find a maximum value for a field in a table which has been loaded in a script. For example, if I am loading sales of products, can I find the last date something was sold? I do not wish to use PEEK in case the loaded data is not in date order.

Any ideas ?

What I am trying to achieve is an incremental load, based on date.

Thanks in advance.

Richard

1 Solution

Accepted Solutions
jagannalla
Partner - Specialist III
Partner - Specialist III

Hi,

Main:

Load * from MainData;

Load Max(Date) as MaxDate Resident Main;

Let vMax=peek('MaxDate',-1,'Main');

Thanks,

Jagan

View solution in original post

6 Replies
sujeetsingh
Master III
Master III

jagannalla
Partner - Specialist III
Partner - Specialist III

Hi,

Main:

Load * from MainData;

Load Max(Date) as MaxDate Resident Main;

Let vMax=peek('MaxDate',-1,'Main');

Thanks,

Jagan

richard_chilvers
Specialist
Specialist
Author

Yes - that is elegant. Thank you!

Richard

Anonymous
Not applicable

If your Resident data set is large MAX or MIN functions can take a while to resolve.

Here's a useful post on how to optimise this.

Extracting Min(Date) and Max(Date) from large QVD

richard_chilvers
Specialist
Specialist
Author

Thanks guys.

Sorry to have repeated a question from previous posts, but I didn't pick up earlier answers in my search.

Richard

richard_chilvers
Specialist
Specialist
Author

Thanks. Its a good post from Steve and he has helped me several times with my queries