[sql] Subqueries with exists
Go to solution
Solved by shadow_ray,
You could join customer and order tables and use the items table as a filter.
select Customer.CustomerName, sum(Orders.Amout) from Orders join Customers on Orders.CustomerID = Customer.CustomerID where exists( select * from Items where Items.OrderId = Orders.OrderId and (Items.Items = 'Milk' or Items.Items = 'Coke')) and (Orders.OrderType = 'Credit' or Orders.Ordertype = 'Check') group by Customer.CustomerID
I think this should work...
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now