Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Summing the Sum of variants in Select Statement
Message
 
 
À
30/07/2008 08:44:52
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP2
Divers
Thread ID:
01335216
Message ID:
01335218
Vues:
14
An expression cannot be used in the GROUP BY, unless it evaluates to an integer representing a field # in the query field list
SELECT substring(ID,1,5) AS quant , SUM(QUANT) as xQuant FROM TEST GROUP BY quant 
>Here's my current sql statement:
>SELECT ID, desc, SUM(QUANT) as xQuant FROM TEST GROUP BY ID
>
>The ID has variants, AB001HB, AB001SB, etc. Right now the statement shows the sum of the quant for each variant. I want to show the sum of the quantity (quant) of the substring(ID,1,5), thus combining the sums for the variants.
>
>SELECT substring(ID,1,5), desc, SUM(QUANT) as xQuant FROM TEST GROUP BY substring(ID,1,5) gives an error message stating that this is an illegal group by clause.
>
> What changes should I make to the sql statement to make this work?
>
>Thanks in advance.
--sb--
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform