SELECT s.id, s.item,
SUM(ISNULL(e.in,0)) as 'total_in',
SUM(ISNULL(e.out,0)) as 'total_out',
SUM(ISNULL(e.in,0)-ISNULL(e.out,0)) as 'total_stock'
FROM stock s
LEFT OUTER JOIN event e
ON s.id = e.item_id
GROUP BY s.id, s.item
ORDER BY s.id, s.item
Edited by - davidburrows on 12/05/2003 08:05:24 AM
Far away is close at hand in the images of elsewhere.
Anon.