Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Description Sequence...
Message
From
06/08/2001 19:06:39
 
 
To
06/08/2001 16:25:04
N. Lea
Nic Cross Enterprises
Valencia, California, United States
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00540161
Message ID:
00540454
Views:
13
I think the problem is with your from clause.
If you are using a JOIN, you don't list the tables in the FROM.
If you are not using JOIN, you do.
Try the adjustments below (take out struck through items, add in the bold ones)

As for the printorder filtering only on the last one, that's because it's not in the group by clause. The group by is going to use the last of any non-aggregate fields if they are not listed in the group by.
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!
>
>I attempted what you stated. BTW - printorder is the key field. It did work in a sense that it changed the descript field, but now it filtered only on one of the printorders (the last one to be precise).
>
>If I try to change it to anything but the print field I get PRINTORDER is not UNIQUE or QUALIFIED. So I change it and it works fine except for the descript fields still all say the same thing.
>
>I tried an IIF in the 3rd line, but it only took the first line item from reportnames and blanked out the rest of them because I had:
>
>IIF(report1.printorder = reportnames.printorder, reportnames.descript, ' ') AS descript
>
>
>	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
Insanity: Doing the same thing over and over and expecting different results.
Previous
Reply
Map
View

Click here to load this message in the networking platform