一种方法是将表与自身连接:
select count(*) as TotalCount, count(s.id) as QualifiedCountfrom MyTable aleft join MyTable s on s.id = a.id and {some conditions}另一种方法是使用子查询:
select (select count(*) from Mytable) as TotalCount, (select count(*) from Mytable where {some conditions}) as QualifiedCount或者,您可以将条件放在一个案例中:
select count(*) as TotalCount, sum(case when {some conditions} then 1 else 0 end) as QualifiedCountfrom MyTable


