Sql 计算中的Where子句

Sql 计算中的Where子句,sql,sql-server,tsql,count,where-clause,Sql,Sql Server,Tsql,Count,Where Clause,有没有办法在t-sql中为count指定where子句 我想做的是,这是威士忌编码: SELECT COUNT([column] WHERE [column]>20) AS [a], COUNT([column] WHERE [column]<20 AND [column]>10) AS [b] FROM [table]; 而不是有两个查询 SELECT COUNT(*) FROM [table] WHERE [column]>20; SELECT C

有没有办法在t-sql中为count指定where子句

我想做的是,这是威士忌编码:

SELECT COUNT([column] WHERE [column]>20) AS [a], 
       COUNT([column] WHERE [column]<20 AND [column]>10) AS [b] 
FROM [table];
而不是有两个查询

SELECT COUNT(*) FROM [table] WHERE [column]>20;
SELECT COUNT(*) FROM [table] WHERE [column]<20 AND [column]>10;

使用一个简单的case语句:

select
count (case when [column]>20 then 1 else null end) as [a],
count (case when [column]<20 and [column]>10 then 1 else null end) as [b]
from
table

用一个箱子和一笔钱就行了。这一定是一个复制品。@blam的可能复制品:我没想过,我也不知道它可以写在count里面。