Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Group by clause
Message
De
27/02/2012 08:31:30
 
 
À
27/02/2012 08:25:20
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Divers
Thread ID:
01536615
Message ID:
01536618
Vues:
36
>Hi friends:
>
>This is what I always wanted to do but I've never got it.
>
>Anyone can tell me what is the correct way for "grouping by" in a SELECT SQL command?
>
>I tried FROM field table, INTO CURSOR field and 1 (result column field) and none of them worked.
>
>This is just one of my tests:
>
> SELECT SUBSTR(f850nfac,2,4) as cpues, f850grav as cgrav, f850ivai as civai, f850exen as cexen, f850tota as ctota, .t. as celijo ;
> FROM &ivaventa WHERE LEFT(DTOS(f850ffac),6)==thisform.peri GROUP BY CPUES NOCONSOLE INTO CURSOR cpuesto
>

What are you trying to do? GROUP BY is designed for aggregating results, that is, for combining data from multiple records into a single record. It's always used in conjunction with the aggregate functions: COUNT(), SUM(), AVG(), MIN() and MAX().

I'm wondering if you really want ORDER BY in your query to organize the results in order by the value of cPues.

Also, while you're there, get rid of the macro operator and use a name expression instead: FROM (ivaventa)

Tamar
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform