Reputation: 77
SELECT Cust
FROM Orders
WHERE Amount < 250 AND COUNT(Cust)>1);
How can I remove the error such that it satisfies to show customers from order that have order two times or more of amount 250 dollar?
Upvotes: 0
Views: 49
Reputation: 540
SELECT Cust
FROM Orders
WHERE Amount < 250
So far this is right, the problem is you cannot use an aggregate function E.G Count
or Sum
in the WHERE
clause like that.
You'd need to Group
it by the Cust
and then use HAVING Count(*)>1
.
Like so:
SELECT Cust
FROM Orders
WHERE Amount < 250
GROUP BY Cust
HAVING Count(*)>1
Upvotes: 2
Reputation: 1780
I'm guessing it should be this?
SELECT Cust
FROM Orders
WHERE Amount < 250
GROUP BY Cust
HAVING Count(*)>1
Upvotes: 2