SQL COUNT一个表中特定字段出现的次数
比如表UsingDayMondayTuesdayMondayMonday希望得到结果:Monday3Tuesday1即统计多个词在同一字段出现的次数比如tablepool...
比如表
UsingDay
Monday
Tuesday
Monday
Monday
希望得到结果:
Monday 3
Tuesday 1
即统计多个词在同一字段出现的次数
比如table pool.UsingDay有以下数据
Monday
Tuesday
Monday
Sunday
得到结果
Monday Tuesday Sunday
2 1 1 展开
UsingDay
Monday
Tuesday
Monday
Monday
希望得到结果:
Monday 3
Tuesday 1
即统计多个词在同一字段出现的次数
比如table pool.UsingDay有以下数据
Monday
Tuesday
Monday
Sunday
得到结果
Monday Tuesday Sunday
2 1 1 展开
3个回答
展开全部
select UsingDay,count(UsingDay)
from table
group by UsingDay
select count(case UsingDay when 'Monday' then Monday else null end) as Monday
,count(case UsingDay when 'Tuesday' then Monday else null end) as Tuesday
,,count(case UsingDay when 'Sunday' then Monday else null end) as Sunday
from pool
from table
group by UsingDay
select count(case UsingDay when 'Monday' then Monday else null end) as Monday
,count(case UsingDay when 'Tuesday' then Monday else null end) as Tuesday
,,count(case UsingDay when 'Sunday' then Monday else null end) as Sunday
from pool
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询