方法一、
复制代码代码如下:
SELECT SUM(正确数)+SUM(错误数) AS 总记录数,SUM(正确数),SUM(错误数)
FROM (
SELECT COUNT(1) 正确数,0 错误数
FROM TB
WHERE STATUS=1
UNION ALL
SELECT 0 正确数,COUNT(1) 错误数
FROM TB
WHERE STATUS=0) a
方法二、
复制代码代码如下:
select count(1)总记录数,sum(case when status=1 then 1 else 0 end)正确数,sum(case when status=0 then 1 else 0 end) 错误数 from T