I’m using this Query but I have it wrong…
SELECT * FROM [Orders]
JOIN [Customers]
ON [Orders].[CustomerID] = [Customers].[CustomerID]
WHERE [Orders].[OrderDate] BETWEEN '2010/1/1' AND '2011/1/1'
AND [Orders].[Total] > 1
I’m getting a Duplicate Column name error for CustomerID. I’m not sure how to use an Alias for this to work.
Could someone show me how to write it correctly.
EDIT:
Thanks for all the suggestions, here’s what I can out with.
SELECT DISTINCT Orders.CustomerID, Orders.ShipToID, Orders.ShipName, Orders.ShipAddress, Orders.ShipAddress2, Orders.ShipCity, Orders.ShipStateOrProvince, Orders.ShipPostalCode, Orders.Total, Orders.OrderDate, Customers.Profession
FROM Orders
JOIN Customers
ON Orders.CustomerID = Customers.CustomerID
WHERE Orders.OrderDate BETWEEN '4/3/2010' AND '2/20/2011'
AND Orders.Total > 1
Thanks Again!
Be explicit about the columns you’re selecting, rather than
SELECT *, and when you must get a similarly named column from both tables, use an alias.