|
Posted by David Portas on 11/29/06 07:26
Here's a guess. I am assuming that Office is the key of the Offices
table even though the presence of DISTINCT in your original query makes
me doubt it (an example of why it's important to include DDL with keys
in your posts).
SELECT T.storeloc, -SUM(linecost) AS WriteOff
FROM Invtrans AS T
JOIN Inventory AS I
ON I.location = T.storeloc
AND I.itemnum = T.itemnum
JOIN Offices AS O
ON T.storeloc = O.Office
WHERE transtype IN ('blah','blah','blah')
AND T.linecost <= 0
AND O.OfficeDesignation IN ('WE','BE')
GROUP BY T.storeloc ;
Hope this helps.
--
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--
Navigation:
[Reply to this message]
|