Focal Point
MAX vs LST

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/9251097191

October 19, 2006, 10:59 AM
gregson06
MAX vs LST
Okay, this is the situation, I need to use a function that will retrieve a set of fields from a table that has repeating rows and a given identifier. For example:

CARTYPE CARNAME CARDATE CARPHONE CARLETTER
A ALPHA 10/1/2006 PHONE1 X
A ALPHA 10/2/2006 PHONE2 Y
B BETA 10/1/2006 PHONE3 X
B BETA 10/3/2006 PHONE4 Z
C CHI 10/4/2006 PHONE5 Z

Okay, if I ran the following script
TABLE FILE CARDATA
SUM
MAX.CARTYPE
CARNAME
CARDATE
CARPHONE
BY CARID
END

Would that get each item accordingly or would I have to put MAX. in front of each field?

Also, would that be the same thing as using the LST. prefix?

Thanks! this one has been really hounding me so I want to make sure I'm using the right one! It's either this or using various holds and matching them to a base table!

This message has been edited. Last edited by: gregson06,
October 19, 2006, 11:28 AM
N.Selph
It depends on what you want. LST depends on how the table is sorted. The data you show is sorted by Cartype alphabetically. So LST will get you the same results as MAX will. If your real data is not sorted that way, the results would be different.


(Prod: WebFOCUS 7.7.03: Win 2008 & AIX hub/Servlet Mode; sub: AS/400 JDE; mostly Self Serve; DBs: Oracle, JDE, SQLServer; various output formats)
October 19, 2006, 12:04 PM
gregson06
Well that's just the thing, there can be multiple entries that only change by date, however if I only wanted the last entry for each record sorted by type, would I use LST to get the last transaction for that type? If I had an order of preference for if a certain type is available then I should get that one, other wise go to the next one? It just so happens the order I'd like to retrieve them is C then B then A, which goes with the MAX usage, is it okay to do so?

Thanks!
October 23, 2006, 03:23 AM
Tewy
If you want one line of data for each date / type combination, use your sort fields. For the last entry for each type, try

PRINT
fieldnames
BY HIGHEST CARTYPE
BY HIGHEST 1 CARDATE


WF 7.6.11
Output: HTML, PDF, Excel