>I need some help with this code in trying to determine why the system will not take more than the first description record from the table. What it is supposed to be doing is inputing data from 2 tables into a cursor. A majority of the data comes from a table called Report1 while the description comes from a table called reportnames. All reportnames has is the summary description and the printorder number. However, whenever brought over, the only description issued is the repeated first item in the table. For instance:
>
>the first record in the table reportnames is: Gross Mold Income.
>
>When brought into the cursor:
>
>GROSS MOLD INCOME 10
>GROSS MOLD INCOME 20
>GROSS MOLD INCOME 30
>GROSS MOLD INCOME 40
>
>I have tried changing the process numerous times, but keep on getting stuck. I have changed the table structure to match exactly, but no luck. Any suggestions? The code is below:
>
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.
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
HTH
Insanity: Doing the same thing over and over and expecting different results.