H homage Registered User. Local time Today, 02:13 Joined Dec 30, 2013 Messages 16 Jan 23, 2014 #1 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?
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?
jdraw Super Moderator Staff member Local time Today, 02:13 Joined Jan 23, 2006 Messages 15,498 Jan 23, 2014 #2 Can you tell us about your database? What other tables are involved?
P plog Banishment Pending Local time Today, 01:13 Joined May 11, 2011 Messages 12,055 Jan 23, 2014 #3 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.
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.
pbaldy Wino Moderator Staff member Local time Yesterday, 23:13 Joined Aug 30, 2003 Messages 36,157 Jan 23, 2014 #4 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.
pbaldy Wino Moderator Staff member Local time Yesterday, 23:13 Joined Aug 30, 2003 Messages 36,157 Jan 23, 2014 #5 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.