Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Fixing SQL statements for VFP8
Message
De
16/06/2004 15:33:08
 
 
À
16/06/2004 15:19:04
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00914398
Message ID:
00914406
Vues:
9
Aggregate functions are MAX (), SUM (), COUNT (), etc. What the help say is that the followinf SELECT-SQL is illegal because MyField2 is not in the GROUP BY clause:
SELECT MyField1, MyField2, COUNT (*) FROM MyTable GROUP BY MyField1
It should be written like this:
SELECT MyField1, MyField2, COUNT (*) FROM MyTable GROUP BY MyField1, MyField2
This make sense when you think of it. With this table:
MyField1   MyField2
1          1
1          2
2          1
what would the first SELECT return?
MyField1   MyField2   Cnt
1          1          2
2          1          1
or
MyField1   MyField2   Cnt
1          2          2
2          1          1
HTH

>I am going to play the redneck programmer this time. I am trying to convert my sql strings from vfp 6 to vfp 8 with group by clauses in ‘um. But reading over the documents I have found, they talk about “aggregate functions”. I am taking that to mean that the field is in a user-defined function in the select area – like upper(file.fieldname) OR right(alltrim(file.fieldname), 3). If I am wrong, please tell me.
>
>The documentation states that all fields in the select area need to be in the group by area, but how can that be if the field is in that “aggregate function”?
>
>So, how do I know what fields need to be in the group by area? I have a program (QueryMaker) that can change those fields on the fly, and I need to know which fields to be sure are in the area(clause?)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform