既然“所有id都在规定的值内”,应该可以,不过写起来很长。select dt,
sum(case when id='101' then [count] else 0 end) as f1,
sum(case when id='201' then [count] else 0 end) as f2,
.....
sum(case when id='999' then [count] else 0 end) as f35
from V1
group by dt
sum(case when id='101' then [count] else 0 end) as f1,
sum(case when id='201' then [count] else 0 end) as f2,
.....
sum(case when id='999' then [count] else 0 end) as f35
from V1
group by dt
我就觉得太长了才...