Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Group by clause error in sql with NO group by clause
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00801354
Message ID:
00801384
Vues:
17
VFP8 has been modified to bring its SQL up to modern standards. This means that if you have any aggregated field [SUM(), MAX(), etc] in the SELECT field list, ALL non-aggregated fields in the list MUST be in a GROUP BY clause. Omitting the clause completely is not an option. Just totalling several fields is not an aggregate. If you do not have a GROUP BY on these fields then the data in them is meaningless with respect to the data in the aggregated fields.

>I don't understand what that has to do with grouping. I tried it anyway, though and got the same error, here's what I changed the sql to read...
>
>SELECT SUM(aTmpData.nBegin), ;
> SUM(aTmpData.NADDS),;
> SUM(aTmpData.nNew) , ;
> (aTmpData.nRein0 + ;
> aTmpData.nRein30 + ;
> aTmpData.nrein90 + ;
> aTmpData.nrein91 + ;
> aTmpData.nrein181), ;
> SUM(aTmpData.nRein0), ;
> SUM(aTmpData.nRein30), ;
> SUM(aTmpData.nrein90), ;
> SUM(aTmpData.nrein91), ;
> SUM(aTmpData.nrein181), ;
> SUM(aTmpData.nterms), ;
> SUM(aTmpData.nLOE), ;
> SUM(aTmpData.nRiteShare), ;
> SUM(aTmpData.nOther), ;
> SUM(aTmpData.nEnd), ;
> SUM(aTmpData.nSwitchout) ;
> FROM aTmpData ;
> WHERE aTmpData.cSite = junk.cSite ;
> AND aTmpData.ddate = aDatelist(i2-1,1) ;
> group by (aTmpData.nRein0 + ;
> aTmpData.nRein30 + ;
> aTmpData.nrein90 + ;
> aTmpData.nrein91 + ;
> aTmpData.nrein181) ;
> INTO TABLE dkstep1
>
>
>then, just in case that was wrong.... i tried
>
>SELECT SUM(aTmpData.nBegin), ;
> SUM(aTmpData.NADDS),;
> SUM(aTmpData.nNew) , ;
> (aTmpData.nRein0 + ;
> aTmpData.nRein30 + ;
> aTmpData.nrein90 + ;
> aTmpData.nrein91 + ;
> aTmpData.nrein181) as total, ;
> SUM(aTmpData.nRein0), ;
> SUM(aTmpData.nRein30), ;
> SUM(aTmpData.nrein90), ;
> SUM(aTmpData.nrein91), ;
> SUM(aTmpData.nrein181), ;
> SUM(aTmpData.nterms), ;
> SUM(aTmpData.nLOE), ;
> SUM(aTmpData.nRiteShare), ;
> SUM(aTmpData.nOther), ;
> SUM(aTmpData.nEnd), ;
> SUM(aTmpData.nSwitchout) ;
> FROM aTmpData ;
> WHERE aTmpData.cSite = junk.cSite ;
> AND aTmpData.ddate = aDatelist(i2-1,1) ;
> group by total;
> INTO TABLE dkstep1
>
>both gave me the same error...
>
>I don't understand 1) why I need a group clause or 2) how should it read if I do need one?
>
>(Not trying to sound difficult, I really just don't understand why one would be required)
Mark McCasland
Midlothian, TX USA
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform