SELECT 'X' AS report_1, ; reportnames.descript AS descript, ; ROUND(SUM(IIF(groupcode = groupcode AND !EMPTY(I_L),total, 0)),2) AS Total, ; reportnames.printorder AS printorder, ; groupcode AS groupcode, ; "X" AS I_L ; FROM Reportnames, Report1 ; JOIN reportnames ON Report1.printorder= reportnames.printorder; GROUP BY Report1.Groupcode, Report1.printorder ; ORDER BY I_L ; INTO CURSOR SummaryTable COPY ALL TO ARRAY gaTempCursor>Hi there!
> SELECT 'X' AS report_1, ; > reportnames.descript AS descript, ; > ROUND(SUM(IIF(groupcode = groupcode AND !EMPTY(I_L),total, 0)),2) AS Total, ; > reportnames.printorder AS printorder, ; > groupcode AS groupcode, ; > "X" AS I_L ; > FROM Reportnames, Report1 ; > JOIN reportnames ON Report1.printorder= reportnames.printorder; > GROUP BY Report1.Groupcode ; > ORDER BY I_L ; > INTO CURSOR SummaryTable > COPY ALL TO ARRAY gaTempCursor > > >>The problem is in here: The reportnames table needs to be in the select's from clause. >>As it is, it's just using the current record in reportnames. If you moved to the 5th record, e.g., you would get that description in all records of the result. The end result is just like using 'X' as report_1. >> >>I don't know what common field the reportnames table and report1 table should be joined on, so I put in report_1 as an example. >>Of course, this will need to be replaced with the appropriate field, and if they have more fields in common, those fields will need to be aliased in the select - I have aliased the group by field as an example. >> >> >>**-- SECTION 2: Copies and calculates all data into a cursor --** >>SELECT 'X' AS report_1, ; >> reportnames.descript AS descript, ; >> ROUND(SUM(IIF(groupcode = groupcode AND !EMPTY(I_L),total, 0)),2) AS Total, ; >> printorder AS printorder, ; >> groupcode AS groupcode, ; >> "X" AS I_L ; >> FROM Report1 ; >> Join reportnames On Report1.report_1 = reportnames.report_1 ; >> GROUP BY Report1.Groupcode ; >> ORDER BY I_L ; >> INTO CURSOR SummaryTable