Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Group by clause in vfp8
Message
 
À
16/04/2003 03:08:17
Walter Meester
HoogkarspelPays-Bas
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00774269
Message ID:
00778650
Vues:
26
>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,

I'd have to disagree completely. First, you obscure the intended output. Second, you're messing with working code (If it ain't broke, don't fix it). Third, and most importantly, you're introducing completely unnecessary processing overhead with the function calls.

This was intended to be, as I said originally, an extremely simple sample. In a reply to Jim Booth on this thread, I clarified by using a much more complex, but real world scenario.

Using SET ENGINEBEHAVIOR avoids all three of the above complications.
George

Ubi caritas et amor, deus ibi est
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform