我有一个简单的查询,我只想返回值

SELECT advisor AS advisor,
SUM(`outcome` LIKE '%TPS_Approved%') AS approved
FROM shift_report
WHERE `team`!=6 AND date>20150720 AND date<20150728
GROUP BY `advisor`
ORDER BY `advisor`


如果计数> = 1,我只希望它返回顾问和批准的计数

最佳答案

这会做你想要的吗?

SELECT advisor AS advisor,
count(*) AS approved
FROM shift_report
WHERE `team`!=6 AND date>20150720 AND date<20150728 and `outcome` LIKE '%TPS_Approved%'
GROUP BY `advisor`
ORDER BY `advisor`

关于mysql - SQL SUM仅返回> = 1的值,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/31719088/

10-09 01:29