I am trying to count the number of 'Shipped' orders with an amount greater than 1000 from two tables.
I have table Orders(Status column) and table Payments(Amount column)
select count(o.status, p.amount)
from orders o, payments p
where (o.status = 'Shipped' AND p.amount>1000);
After getting an error I broke up the problem into two with the first finding all 'Shipped' status in Orders. This works just fine.
select count(o.status)
from orders o
where o.status = 'Shipped';
But trying to count all payments above 1000 doesn't seem to work.
select count(p.amount)
from payments p
where p.amount>=1000;
In case anyone needs the file, I am using the sample DB from MySQl sample database http://www.mysqltutorial.org/mysql-sample-database.aspx