Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Group by
Message
De
14/02/2003 10:15:44
 
 
À
14/02/2003 09:28:58
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Divers
Thread ID:
00753201
Message ID:
00753229
Vues:
18
>Below is from the help file. If I understand this change I can nolonger just list the fields I want grouped. I have to list the field grouping of all the fields.
>
>So if I have table with 5 fields I must list all 5 as in
>"Group by 3,2,1,4,5" even if all I'm concern with is with fields 3 and 2. Can anybody confirm? TIA
>

More or less. It's always been bad design to have fields in the query that neither include an aggregate function or appear in the GROUP BY clause. You couldn't count on the data in those fields--VFP took it randomly from the last record in the group.

For example, the following query produces unexpected results:

SELECT Name, State, MAX(birthdate) ;
FROM People ;
GROUP BY State

You'd think it gives you the youngest person for each state, but in fact, it gives you the birthdate of the youngest person and the name of one person at random.

In VFP 8, they've tightened up the query engine to prevent you from writing that sort of query. However, because many of us have older code that does it, there's a new SYS() function and the SET ENGINEBEHAVIOR command to let you run such queries.

My recommendation is to use SET ENGINEBEHAVIOR only with older code, and to make sure all new code is compliant with the VFP 8 behavior.

Tamar
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform