Reputation: 325
So I've got a basic SQL question that I can't seem to work out. The query is: "Obtain all the invoices of customers who have ever had an invoice over $100".
Here's the SQL fiddle I've been using: http://sqlfiddle.com/#!6/99169/22
The things I've been trying is like:
SELECT * from Invoice I
INNER JOIN Customer C ON C.id=I.customer where I.inv_total > 100.00;
But it's not working... any help is appreciated :)
Upvotes: 1
Views: 54
Reputation: 24901
You can use such query:
SELECT * from Invoice I
INNER JOIN Customer C ON C.id=I.customer
WHERE C.id IN (SELECT customer from Invoice WHERE inv_total > 100)
In your where condition you filter customers by invoices that are over 100.
Upvotes: 1