select Fid,A=Sum(case cid when 'A' then Nume else NULL end),
B=Sum(case cid when 'B' then Nume else NULL end),
C=Sum(case cid when 'C' then Nume else NULL end)
from table
group by FID
order by FID
B=Sum(case cid when 'B' then Nume else NULL end),
C=Sum(case cid when 'C' then Nume else NULL end)
from table
group by FID
order by FID
select FID
,A=max(case Cid when 'A' then cast(NUME as varchar) else '' end)
,B=max(case Cid when 'B' then cast(NUME as varchar) else '' end)
,C=max(case Cid when 'C' then cast(NUME as varchar) else '' end)
from 表
group by fid
,A=max(case Cid when 'A' then cast(NUME as varchar) else '' end)
,B=max(case Cid when 'B' then cast(NUME as varchar) else '' end)
,C=max(case Cid when 'C' then cast(NUME as varchar) else '' end)
from 表
group by fid
就是 Cid 字段可能有好多,每次查询时,个数不定怎么办啊
A=max(case Cid when 'A' then cast(NUME as varchar) else '' end),
B=max(case Cid when 'B' then cast(NUME as varchar) else '' end),
C=max(case Cid when 'C' then cast(NUME as varchar) else '' end)
from 表
group by fid