Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Group by clause in vfp8
Message
From
16/04/2003 03:08:17
Walter Meester
HoogkarspelNetherlands
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00774269
Message ID:
00778197
Views:
22
George, and all,

>In 8.0, you can't do something like the following
SELECT sku, stockcolor, SUM(quantity);
>  FROM Products;
>  GROUP BY sku;
>  INTO CURSOR resultset
>because the query involves an aggregate function (SUM) and the stockcolor field is not in the GROUP BY clause. In previous versions you could. The workaround is to issue SET ENGINEBEHAVIOR 70 immediately prior to issuing the query then SET ENGINEBEHAVIOR 80 afterwards.


I think the best workarround is to ensure that all fields not included in the group by clause are aggregated fields by including the MAX function for those fields which are not:
SELECT sku, MAX(stockcolor) as Stockcolor, SUM(quantity);
   FROM Products;
   GROUP BY sku;
   INTO CURSOR resultset
Walter,
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform