Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
What is wrong with my Group By
Message
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:
01004783
Views:
20
Check SET("ENGINEBEHAVIOR").

>
>Jeff, I just copied your select statement almost as you posted it, changing only the "from" and it works for me, although you still need to put group by in both sides, it wont give you an error if you miss the first one:
>
>
>create cursor c1 (item C(1), price I, qtyshp I, cost I)
>
>insert into c1 values ('A', 5, 100, 4)
>insert into c1 values ('A', 3, 20, 1)
>insert into c1 values ('B', 7, 4, 1)
>insert into c1 values ('C', 2, 111, 1)
>insert into c1 values ('C', 2, 6, 3)
>
>
>create cursor c2 (item C(1), price I, qtyshp I, cost I)
>
>insert into c2 values ('H', 4, 8, 3)
>insert into c2 values ('H', 6, 6, 3)
>insert into c2 values ('E', 7, 9, 2)
>insert into c2 values ('R', 2, 6, 1)
>insert into c2 values ('T', 2, 6, 1)
>
>
>SELECT item,((SUM(price * qtyshp) - SUM(cost * qtyshp)) / SUM(price * qtyshp)) * 100 AS Margin ;
>FROM c1 ;
>UNION ALL;
>SELECT item,((SUM(price * qtyshp) - SUM(cost * qtyshp)) / SUM(price * qtyshp)) * 100 AS Margin ;
>FROM c2 ;
>group BY item ;
>into cursor tcCursor
>
>
>Does not give me any error, but gives bad results as I said in a previous message
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform