假设我有一个这样的表:
ID Result
-------------
1 , 'pass'
2 , 'pass'
3 , 'fail'
4 , 'fail'
5 , 'fail'
6 , 'fail'
有什么简单的方法可以找到COUNT WHERE result = 'fail' AND total COUNT
。
预期输出:
FailCount TotalCount
-----------------------
4 6
是的,我们可以使用这样的子查询来做到这一点:
SELECT
(SELECT COUNT(result) FROM t WHERE result='fail') AS FAILCount
, COUNT(result)
AS TotalCount FROM t;
但是有没有办法这样做:
SELECT COUNT(WHERE Result='fail') , COUNT(Result) FROM ...