Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL statement problem ?
Message
From
04/11/1998 11:54:34
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
SQL statement problem ?
Miscellaneous
Thread ID:
00154383
Message ID:
00154383
Views:
45
i tried to join three table and use sql statement to calculate the result (sum of quantity).
let me list out the tree table.
table1: stock
field: item_name (printer,harddisk)

table2: purchase
field: item_name , quantity
record: printer, 2
harddisk, 4
printer,4
harddisk, 3

table3: sales
field: item_name, quantity
record: harddisk, 4
printer, 3

i use sql to calculate the sum of quatity for table2 and table3
but the result give me two times of the actual result
my code is like this:

>SELECT stock.item_name,SUM(purchase.quantity) AS quantity1,SUMsales.quantity) AS quantity2;
>FROM database1!stock,database1!purchase,database1!sales;
>WHERE stock.item_name=purchase.item_name;
>AND stock.item_name=sales.item_name;
>group by stock.item_name;
>order by stock.item_name

Can anyone tell me what's wrong and give me the right sql statement.
thanks
Next
Reply
Map
View

Click here to load this message in the networking platform