SQL发生以下几次

时间:2016-12-27 12:48:25

标签: mysql sql

我想找出系统结果no_answer超过5次的每个不同数字

是否有人知道如何找到以下内容,即

Table Name Calls

Field 1 - Phone_number
Field 2 - System_outcome

Phone_number      System_outcome
07777778999       Answered
07777778123       No Answer
07777778999       No Answer
07777778999       No Answer
07777778999       No Answer
07777778999       No Answer
07777778124       No Answer
07777778128       Answered
07777778074       Answered

4 个答案:

答案 0 :(得分:1)

SELECT Phone_number, COUNT(*) AS no_answer_count
FROM Calls
WHERE System_outcome = 'no_answer'
GROUP BY Phone_number
HAVING no_answer_count > 5

答案 1 :(得分:1)

你需要使用group by和where where condition

的组合
select Phone_number 
from Calls
where System_outcome='No Answer'
group by Phone_number      
having count(Phone_number) > 5

答案 2 :(得分:0)

您可以group by电话号码并过滤那些大于5的having

select phone_number
from Calls
where System_outcome = 'No Answer'
group by phone_number
having count(*) > 5;

答案 3 :(得分:0)

public (bool success, string message, LotInfo lotInfo) GetLotInfo(string SupplierCode)
{
    // collect info
    return (true, "message lot info retrieved successfully", new LotInfo()); // put actual values here
}