select id,
MIN(case when stage=1 then code else NULL END) as code1,
MIN(case when stage=1 then aaa else null END) as aaa1,
MIN(case when stage=2 then code else null END) as code2,
MIN(case when stage=2 then aaa else null END) as aaa2,
MIN(case when stage=3 then code else null END) as code3,
MIN(case when stage=3 then aaa else null END) as aaa3,
MIN(case when stage=4 then code else null END) as code4,
MIN(case when stage=4 then aaa else null END) as aaa4,
MIN(case when stage=5 then code else null END) as code5,
ISNULL(MIN(case when stage=5 then aaa else null END),0) as aaa5
from abc group by id
一个表中的多条数据插入到一个临时表
最新推荐文章于 2021-02-22 06:28:55 发布