34,587
社区成员
发帖
与我相关
我的任务
分享
set statistics time on
select 高,中,低
from(
select uName,ready1.value('(Ext/quality)[1]','nvarchar(100)') as quality from dbo.Base
where CityCode like ',%3301%,')
as baseTable
pivot(count(uName) for quality in(高,中,低)) as table2
set statistics time off
--SQL Server 执行时间:
-- CPU 时间 = 1968 毫秒,占用时间 = 995 毫秒。
set statistics time on
select
sum(case when quality='高' then 1 else 0 end) as '高',
sum(case when quality='中' then 1 else 0 end) as '中',
sum(case when quality='低' then 1 else 0 end) as '低'
from(
select uName,ready1.value('(Ext/quality)[1]','nvarchar(100)') as quality from dbo.Base
where CityCode like ',%3301%,')
as baseTable
set statistics time off
--SQL Server 执行时间:
-- CPU 时间 = 1938 毫秒,占用时间 = 983 毫秒。