简体   繁体   English

查询表达式中的SQL语法错误

[英]SQL syntax error in query expression

Im trying to run this query 我正在尝试运行此查询

select customerID, sum(OrderID)
from employee_T
where 2 < select(sum(OrderID) from employee_T)
group by customerID;

I want to list the customer id and the total number of orders placed for every customer that has more than 2 orders. 我想列出客户ID和每个拥有2个以上订单的每个客户的订单总数。

I get the syntax error on this line 我在这行上收到语法错误

where 2 < select(sum(OrderID) from employee_T)

is it because of the 2?s 是因为2吗?

I'm not familiar with ms-access syntax, but this is how you would do that in regular sql: 我不熟悉ms-access语法,但这是您在常规sql中的处理方式:

select customerID, count(OrderID)
from employee_T
group by customerID
having count(orderID) > 2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM