Focal Point
More first and Last info

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

April 26, 2006, 02:46 PM
Ginny
More first and Last info
I have the following fields
DATE LASTODOMREADING Thisodomreading
6/28/2002 535 666
6/30/2002 666 767


If I do a report where I just want the LastOdomreading from the beginning of the date range and the THISodomreading from the ending of the date range how can I do this?

So the data to be returned should be
Date Range Lowest Odom HighestODOM
6/28 - 6/30 535 767
April 26, 2006, 03:21 PM
Spence
this sample is against the employee.foc db
see if this is what you want.

TABLE FILE EMPLOYEE
SUM
COMPUTE START_SAL/D12.2 = LST.SALARY;
COMPUTE END_SAL/D12.2 = FST.SALARY;
BY EMP_ID
END


WF 8 version 8.2.04. Windows.
In focus since 1990.
April 26, 2006, 03:21 PM
reFOCUSing
Could you just use the prefix of MIN. and MAX. to get what you want?
April 26, 2006, 03:32 PM
jimster06
min and max refer to values while fst and lst refer to physical instances.
May 02, 2006, 10:09 AM
dwf
Ginny,

This should do it:

TABLE FILE ODOM
PRINT
LASTREADING
THISREADING
COMPUTE
COUNTER/I5 = COUNTER + 1;
BY RDATE
ON TABLE HOLD AS ODOMETER
END
-RUN

-SET &NUMRECS = &LINES;

DEFINE FILE ODOMETER
FIRSTDATE/MDYY = IF COUNTER EQ 1 THEN RDATE ELSE FIRSTDATE;
LASTDATE/MDYY = IF COUNTER EQ &NUMRECS THEN RDATE ELSE FIRSTDATE;
LASTREAD/I7 = IF COUNTER EQ 1 THEN LASTREADING ELSE 0;
THISREAD/I7 = IF COUNTER EQ &NUMRECS THEN THISREADING ELSE 0;
END

TABLE FILE ODOMETER
PRINT
FIRSTDATE
LASTDATE
LASTREAD
THISREAD
ON TABLE HOLD AS FINAL
END

TABLE FILE FINAL
SUM
FIRSTDATE
LASTDATE
LASTREAD
THISREAD
END

In case it isn't clear: In that first step, ODOM is your source file and RDATE is your date field. It's a lot of steps, I know, but I can't think of a way to do it in fewer. If any of it is confusing, I would suggest taking the HOLD out of the first step to see the results, then putting it back and taking HOLD out of the second step.


dwf
May 16, 2006, 04:39 PM
Ginny
Thanks, I appreciate the help. I have decided it's just easier to do all of the work through views on the SQL server and then just use Webfocus to pull the results.
May 16, 2006, 05:35 PM
TexasStingray
You shoud be able to do a simple table request

  
TABLE FILE xxx
PRINT
MIN.LASTODOMREADING
MAX.Thisodomreading
AND COMPUTE ROWCNT/I9 = IF DATE EQ LAST DATE THEN LAST ROWCNT + 1 ELSE 1; NOPRINT
BY DATE
WHERE TOTAL ROWCNT EQ 1;
END





Scott

I think we went off the deep end with complicating this request. The following should work.

TABLE FILE xxx
SUM FST.LASTODOMREADING LST.Thisodomreading
END

When using an RDBMS as the data source, the rules change a bit for using FST. and LST. so verify that this gives you what you are looking for.

Maybe one of th FOCWizards could expound on the usage of FST. and LST. when reporting from an RDBMS. Is this documented anywhere?


Thanks!

Mickey

FOCUS/WebFOCUS 1990 - 2011
Ginny, There is some information about the usage of FST. and LST. in the Interface Manual specific to your RDBMS. Basically it looks like it should work as advertised as long as the KEYS setting in the FOCUS Access File Descriptions for your SQL Server TABLES are set properly.


Thanks!

Mickey

FOCUS/WebFOCUS 1990 - 2011
An explanation of FST. and LST. with regard to relational databases, is in the FOCUS for S/390 Relational Data Adapter User's Manual Version 7.2 Try page 4-28 (involving KEYORDER), and page 7-12, where it discusses translating FST. and LST. to SQL MIN and MAX.

Hope this helps.

Regards,
Jenn
One frivolous note: M's solution will only work if the lowest odometer reading is associated with the lowest date, and the highest reading is associated with the highest date. However, since your data appears to be so organized, it ought to work, barring any mistakes in data entry.


dwf