>WITH THIS > .mTableOpen('report1','printorder') > .mTableOpen('report1','printorder',.F.,'a_report1',.F.) > .mTableOpen('reportnames','printorder') > .mTableOpen('gl_acct','report_1') > > **-- PRE-SQL-SELECT-STATEMENT: Creates the 3 cursors to be used --** > CREATE CURSOR OriginalTable ; > (report_1 C(3), descript C(35), total N(12,2), printorder N(3), groupcode c(3), I_L C(1)) > > CREATE CURSOR SummaryTable ; > (report_1 C(3), descript C(35), total N(12,2), printorder N(3), groupcode c(3), I_L C(1)) > > CREATE CURSOR DisplayTable ; > (report_1 C(3), descript C(35), total N(12,2), printorder N(3),groupcode c(3), I_L C(1)) > **-- END OF PRE-SQL-SELECT-STATEMENT --** > > **-- SECTION 1: Copies all table data from report1 into a cursor called OriginalTable --** > SELECT report1 > COPY ALL TO ARRAY gaTempOriginal > > SELECT OriginalTable > APPEND FROM ARRAY gaTempOriginal > > **-- END OF SECTION 1: final completion of copy from original database. --* > > **-- 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 ; > GROUP BY Groupcode ; > ORDER BY I_L ; > INTO CURSOR SummaryTable > COPY ALL TO ARRAY gaTempCursor > **-- END OF SECTION 2: final completion of summary calculations --** > BROW > > **-- SECTION 3: Union joins the two SQL-SELECT statements above for grid display --** > SELECT DisplayTable > APPEND FROM ARRAY gaTempCursor > APPEND FROM ARRAY gaTempOriginal > INDEX ON groupcode + I_L to overall > > **-- END OF SECTION 3: final completion of UNION JOIN --** > BROW > >ENDWITH