怎么可能会导致我这样? 在我看来,我可以查询=>
select id, count(no1, no2, no3) where no1='B',no2='B',no3='B'
非常感谢。
怎么可能会导致我这样? 在我看来,我可以查询=>
select id, count(no1, no2, no3) where no1='B',no2='B',no3='B'
非常感谢。
使用Case When
陈述与Count
骨料。最后,集团他们id
:
Select id,
count(case when no1='B' then 1 END) +
count(case when no2='B' then 1 END) +
count(case when no3='B' then 1 END) AS count_all
From yourtable
Group by id
使用Case Statement
select id,
case when no1='B' then 1 else 0 END +
case when no2='B' then 1 else 0 END +
case when no3='B' then 1 else 0 END As Count_All
From yourtable
感谢的非常... Fireblade为感谢 – SimanisJKT48 2015-03-31 02:20:49
的Rigels ...您的权利...〜_^ – SimanisJKT48 2015-03-31 02:20:11
的欢迎^ _^ – Rigel1121 2015-03-31 02:26:30
两个'Count'和'集团by'不需要这是一个不必要的开销 – 2015-03-31 02:34:35