Question

I currently have the following query that i wish to execute

SELECT Buyer.nCustomerID, Order.[Order Number], SUM(Order.[Order Total Cost])
FROM [Order] INNER JOIN [Buyer] ON Order.nCustomerID = Buyer.nCustomerID
GROUP BY Buyer.nCustomerID,Order.[Order Number];

However My nCustomerID could be duplicated so i wish to do the following: if nCustomerID appears more then once, add the Order Total Cost together. I beleive that my problem is with Group By.

Group By should be set to just Buyer.nCustomerID however if i remove the Order.[Order Number] i Get the following error:

[ODBC Microsoft Access Driver] You tried to execute a query that does not include the specified expression 'Order Number' as part of an aggregate function.

If i leave the Order.[Order Number] in the query then it keeps the duplicate field.

Can anyone offer any advice with this issue?

Was it helpful?

Solution

I think that you mean:

SELECT Buyer.nCustomerID, SUM(Order.[Order Total Cost])
FROM [Order] INNER JOIN [Buyer] ON Order.nCustomerID = Buyer.nCustomerID
GROUP BY Buyer.nCustomerID

It is possible that you do not need two tables.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top