troubleshooting Question

SQl Help - Get Only 1 product

Avatar of JRockFL
JRockFLFlag for United States of America asked on
Microsoft SQL Server
2 Comments1 Solution293 ViewsLast Modified:
How can I return only the orders that have 1 item with a productid of 46?
This query will return orders that contain multiple products including 46.
I want only orders that have 1 product and that has productid of 46

select *
from Orders a
inner join LineItems b
on a.OrderID = b.OrderID
and b.ProductID = 46
where a.OrderStatusID = 3
and a.GatewaySuccessful = 1
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
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 2 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