I am reporting off of a table that holds records (events) of unit movements. Units move several times a day. The report I am building will show all units, sorted by location, but I only want to show each unit once, by it's newest movement record. Fields are: unit, location, date, time, owner. The preferred format would be:
Unit Location Owner Date Time
UnitB - New York - Bill - 06/13/04 - 2103
UnitD - New York - Jean - 06/13/04 - 2200
UnitC - Chicago - Roy - 06/12/04 - 1535
UnitA - KanCity - Jim - 06/13/04 - 2040
In reality, UnitB has 5 other movement records, all older than 06/13/04 2103 hours. Does anyone out there have a suggestion on how to do this?
you might want to try
BY HIGHEST 1 TIME
Thanks for the suggestion. I have already tried that and it doesn't suppress the duplicates. I think if you have three movement records all showing the same date and time for a unit (it's possible) and those three records are newer than all the others, it outputs the line 3 times.
Yes, I checked the data and that is exactly what it is doing. Even though I am telling it to report the highest (1) date and highest (1) time for the unit, it grabs all of them if they are the same...
in that case you might want to try something like:
-* concat a unique key, you may have to convert your date and time to an alpha or whatever
DEFINE FILE yyy
U_KEY/A99 = LOCATION | USER | ... other fields ;
BY HIGHEST 1 U_KEY
or you might even want to look at something like
WHERE LOCATION NE LAST LOCATION AND
USER NE LAST USER AND
DATE NE LAST DATE AND
TIME NE LAST TIME;
just an idea,
use the lst. prefix operator
assuming you have sorted your file so that the latest date is the bottom of each unit paragraph
SUM LST.OWNER LST.DATE LST.TIME BY UNIT BY LOCATION
works like a charm
umm. can we expect a Scully, from your same org?
My counterpart is not the right gender.
|Powered by Social Strata|