0

我正在尝试使用选择查询来显示我的数据库中过去提出超过 5 次投诉的所有客户。我试过这个查询:

SELECT customer_ID, COUNT(customer_feedback.feedback_type) AS complaints
FROM customer_feedback
WHERE complaints>5 
GROUP BY customer_ID;

但它不起作用。Access 无法识别 WHERE 子句中的表达式“投诉”。所以我尝试了这个,更糟糕的是:

SELECT customer_ID, COUNT(customer_feedback.feedback_type) AS complaints
FROM customer_feedback
WHERE COUNT(customer_feedback.feedback_type)>1 
GROUP BY customer_ID;

我确信有一个我现在想不出的简单解决方案。

4

2 回答 2

2
SELECT customer_ID, COUNT(customer_feedback.feedback_type) AS complaints
FROM customer_feedback
GROUP BY customer_ID
HAVING COUNT(customer_feedback.feedback_type)>5; 
于 2013-04-18T17:52:20.763 回答
1

在 SQL Server 中,这将是 group by 的“having”子句的一部分

select something, count(*)
from somewhere
group by something
having count(*) > 5
于 2013-04-18T17:47:51.223 回答