Exclude where columns match

homage

Registered User.
Local time
Today, 02:13
Joined
Dec 30, 2013
Messages
16
I have a table that lists Cost Center, Partner, and Cost. I need a query to sum the cost when Cost Center and Partner do not match. How can I write that expression?
 
Can you tell us about your database? What other tables are involved?
 
This will do exactly as you asked:

Code:
SELECT SUM(IIF([Cost Center] <> [Partner], [Cost], 0) AS Total
FROM YourTableNameHere

Be sure to replace 'YourTableNameHere' with the name of your table.
 
Or

SELECT Sum(Cost) AS TotalCost
FROM TableName
WHERE [Cost Center] <> [Partner]

which may be more efficient.
 
Or

SELECT Sum(Cost) AS TotalCost
FROM TableName
WHERE [Cost Center] <> [Partner]

which may be more efficient.
 

Users who are viewing this thread

Back
Top Bottom