I want to convert multiple rows to multiple columns
in sql server 2017 (v17.6)
. I use this query:
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
Obtained result is depicted below:
I want to get results as below:
In other words, I want to group each 8 rows according to lp_id
and add ch_id#
and name#
(# is a number from 1 to 8) as columns.
How can I get such result?