我有一列包含X或Y的列。我该如何创建一个将每个列如下的查询?
Example of Input
-----------------
X
X
Y
所需的输出
CountX | CountY
-----------------
2 | 1
答案 0 :(得分:2)
select sum(iif(input = 'X', 1, 0)) as countX,
sum(iif(input = 'Y', 1, 0)) as countY
from your_table