将多行转换为多列SQL Server

时间:2019-02-09 11:41:23

标签: sql-server pivot multiple-columns multiple-records

我想在delayElements()convert multiple rows to multiple columns。我使用以下查询:

sql server 2017 (v17.6)

获得的结果如下所示:

before pivoting

我想得到如下结果:

after pivoting

换句话说,我想根据select CapturedFrame.capturedFrame_id, CapturedFrame.fileName, LicensePlate.licensePlate_id, CharacterName.characterName_id, CharacterName.name from CapturedFrame join LicensePlate on CapturedFrame.capturedFrame_id = LicensePlate.capturedFrame_id join Character on LicensePlate.licensePlate_id = Character.licensePlate_id join CharacterName on Character.characterName_id = CharacterName.characterName_id order by licensePlate_id, x0 每8行进行分组,并添加lp_idch_id#(#是从1到8的数字)作为列。

我如何得到这样的结果?

0 个答案:

没有答案