答案 0 :(得分:0)
这很棘手。基本上,这个想法是不可逆转的,但有一个转折点:
select t.id,
max(case when which = 'codeTaxe1' then val end) as codeTaxe1,
max(case when which = 'codeTaxe2' then val end) as codeTaxe2,
. . .
from t cross apply
(select v.*, row_number() over (order by (select null)) as seqnum
from (values (t.codeTaxe1, 'codeTaxe1'), (t.codeTaxe2, 'codeTaxe2'), . . .
) v(val, which)
where val is not null
) tt
group by t.id, seqnum;