Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
What is wrong with my Group By
Message
 
 
To
14/04/2005 13:14:59
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP1
Network:
SAMBA Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01004733
Message ID:
01004770
Views:
13
>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--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform