I am running into some slight trouble with the following query:
SELECT * FROM SaleItems WHERE SalesID = (SELECT SaleID FROM Sale WHERE TotalPrice > (SELECT AVG(TotalPrice) FROM Sale))
The second part of the query:
SELECT SaleID FROM Sale WHERE TotalPrice > (SELECT AVG(TotalPrice) FROM Sale)
returns 5 entries.
But, when I run the first query, I only get one result back. It only bases the WHERE off of only the first result from the second part of the query.
How can I solve this? I want the first query to return all where the SalesID is any of the 5 SaleIDs returned by the second part, not just the first row.
Aucun commentaire:
Enregistrer un commentaire