Hi Tom,
what do you want to have as a result if your datas are
1 A 10
1 B 20
1 A 30
If you want
1 A 40
1 B 20
you can write
SELECT stock_id, location, SUM(quantity) as mysum FROM mytable
GROUP BY stock_id, location
INTO ....
but in this case (and except with VFP) you can't have a 'quantity' field in the
result.
If you want as a result
1 A 10 40
1 B 20 20
1 A 30 40
(so in each line of your table you have the total number of the current id in
the location)
you can write
SELECT stock_id, location, quantity,
(SELECT SUM(quantity) FROM mytable s
WHERE m.stock_id = s.stock_id AND m.location = s.location) as mysum
FROM mytable m
INTO ....
Note : I haven't check syntax so may be you must adjust the command !
Is this help ?
The foxil
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.