PDA

View Full Version : OPNQRYF Grouping



Guest.Visitor
01-01-1995, 02:00 AM
I have two separate files (UHHST and HRHST) Both contain the same fields for different event types. I am try to join the files with a JFILE and JFLD on the Key field. I am then grouping this key field to try to total points for each grouping. The UHHST and HRHST contain the fields: KEY and POINTS The format QFHRUH contain: KEY and T_POINTS I'm wondering if a query can group the Key and give me a total points. This is what I have so far OPNQRYF FILE((HRHST) (UHHST)) + FORMAT(QFHRUHPNT) + JFLD((HRHST/UKC# UHHST/UKC# *EQ)) + JDFTVAL(*YES) + GRPFLD(UKC#) I am working with the MAPFLD and %SUM on POINTS but, of course it wants these qualified and I just want a total regardless of what file it came from. Can this be done and if so how? Thanks

Guest.Visitor
10-03-2000, 10:45 AM
Kelli, Even if you defined your MAPFLD as MAPFLD( RESULT '%SUM(1/POINTs + 2/T_POINTS)'), you should also use the POINTs/T_POINTS fields in the join. But then you have an inner join or a left join. You should write three queries: First query on file 1 and output to file RESULT Second query on file 2 and output to file RESULT (adding records) Three query on file RESULT and summing on this file. This is the simplest solution I can think of at the moment. Regards, Carel.