This is the code I did
SELECT TOP 5 ContactName FROM Customers
INNER JOIN [Order Details]ON OrderId =
CustomerID
INNER JOIN Orders ON ProductID = OrderID
WHERE UnitPrice >= 25000
ORDER BY ContactName ASC
But this is the error I am getting
Msg 209, Level 16, State 1, Line 5
Ambiguous column name 'orderID'
Can someone explain to me why I am getting this error.
This is what I am trying to do is show the most recent five orders that were purchased from a customer who has spent more than $25,000
So i am assuming to use order,product,and customer.
There is probably an
OrderIDcolumn in both yourOrder Detailsand yourOrderstable, and SQL Server doesn’t know which one to take.Solution: specify which one you want to use by putting the table name in front of it:
Orders.OrderIDinstead of justOrderIDSo your query would look like this then: