我正在使用 MySQL 经典模型数据库。以下查询工作正常(注意 where 子句)
select
customers.customerNumber as 'Customer ID',
customers.customerName as 'Customer Name',
count(orders.orderNumber) as 'Total Orders Placed'
from customers
left join orders on customers.customerNumber = orders.customerNumber
where customers.customerNumber > 200
group by
customers.customerNumber
order by
3 asc
但是以下会导致错误。目的是仅在结果行集中显示那些下达 3 个以上订单的客户。我究竟做错了什么?
select
customers.customerNumber as 'Customer ID',
customers.customerName as 'Customer Name',
count(orders.orderNumber) as 'Total Orders Placed'
from customers
left join orders on customers.customerNumber = orders.customerNumber
where count(orders.orderNumber) > 3
group by
customers.customerNumber
order by
3 asc
MySQL错误是:错误代码:1111。组函数的使用无效