Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
What is wrong with my Group By
Message
 
 
À
14/04/2005 13:14:59
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 8 SP1
OS:
Windows XP SP1
Network:
SAMBA Server
Database:
Visual FoxPro
Divers
Thread ID:
01004733
Message ID:
01004770
Vues:
14
>I have read this thread and the MS KB article but I do not see what is wrong with my code. I understand that the changes required that all fields included in the select statement be included in the group by clause. However I understood that calculated fields did not meet this requirement. In any event this example only includes two fields, if I include only one it bombs, if I include both it bombs.

Jeff,

The GROUP BY clause belongs to each SELECT statement in the UNION. In your case the first SELECT doesn't have GROUP BY. It should be
SELECT item,((SUM(price * qtyshp) - SUM(cost * qtyshp)) / SUM(price * qtyshp)) * 100 AS Margin;
FROM Prodata!artran99 ;
group BY item ;
UNION ALL;
SELECT item,((SUM(price * qtyshp) - SUM(cost * qtyshp)) / SUM(price * qtyshp)) * 100 AS Margin;
FROM Prodata!arytrn99 ;
group BY item ;
into cursor tcCursor
You'll have to run one more select on the result of this one to get them combined.
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform