>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--