0

例如,我在 MS SQL Server 中有一个表:

Feature, Option1, Option2
-------------------------
Agent, Yes, No
Agent, No, No
Console, No, Yes,
Console, Yes, Yes

我需要编写一个返回的查询:

Feature, Option1 Yes Count, Option2 Yes Count
---------------------------------
Agent, 1, 0
Console, 1, 2

我应该使用什么查询?

4

1 回答 1

1
select Feature,
       count(nullif(Option1,'no')) as 'Option1 Yes Count',
       count(nullif(Option2,'no')) as 'Option2 Yes Count'
from    table_name
group by feature
于 2013-01-21T09:57:49.390 回答