select VAT01,
max(case when ACE01=21 then BCE03 else '' end) as A,
max(case when ACE01=23 then BCE03 else '' end) as B,
max(case when ACE01=22 then BCE03 else '' end) as C
from t group by VAT01这样试试
max(case when ACE01=21 then BCE03 else '' end) as A,
max(case when ACE01=23 then BCE03 else '' end) as B,
max(case when ACE01=22 then BCE03 else '' end) as C
from t group by VAT01这样试试
insert T
select 45346,1642103,21,'张燕' union all
select 45347,1642103,22,'王正'union all
select 45348,1642103,23,'陈方' union all
select 45349,1642103,02,'周梅'union all
select 45350,1642103,01,'李强' union all
select 45351,1642103,11,'吕布'union all
select 45352,1642106,11,'刘伟' union all
select 45353,1642106,22,'王正'union all
select 45354,1642106,23,'周青'select vat01 ,
max(case when ace01='21' then bce03 end) as A,
max(case when ace01='23' then bce03 end) as B,
max(case when ace01='22' then bce03 end) as C
from t
group by vat01
非要max吗