troubleshooting Question

What Am I missing in this SQL Query?

Avatar of niceoneishere
niceoneishere asked on
ASP.NETMicrosoft SQL Server 2005SQL
21 Comments1 Solution291 ViewsLast Modified:
I wrote a small SQL Query in SQL Server 2005 to return Customer Order Number, Email and their order details.

The query works but it returns the email address and order id multiple times as each customer can have more than one item in their order.

I am posting my Query. anyway to modify it so that only once the order number and email is returned even if the customer has more than one item

I think I am missing something very simple here.

SELECT [Order].Id, [Order].Email, [Order].PromotionCode, [Order].ShippingCost, OrderItem.ItemNumber, Size.Name, OrderItem.Price, Size.Id AS Expr1
FROM [Order] INNER JOIN OrderItem ON [Order].Id = OrderItem.OrderId
             INNER JOIN Size ON OrderItem.SizeId = Size.Id 
WHERE ([Order].PromotionCode = 'M123') OR ([Order].PromotionCode = 'T4444') OR ([Order].PromotionCode = 'WABD') OR ([Order].PromotionCode = 'Q695') OR ([Order].PromotionCode = 'P675')

Thanks and appreciate it

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 21 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 21 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros