次の出力を達成するのに助けが必要です。私はテーブルを持っています
declare @tblLevels table(
levelsID INT IDENTITY(1,1),
levelNumber INT,
levelDesc VARCHAR(100))
insert into @tblLevels(levelNumber,levelDescription)
values
(1,'L1D1'),
(1,'L1D2'),
(1,'L1D3'),
(1,'L1D4'),
(2,'L2D1'),
(2,'L2D2'),
(2,'L2D3'),
(2,'L2D4'),
(3,'L3D1'),
(3,'L3D2'),
(3,'L3D3')
select * from @tblLevels
levelsID levelNumber levelDesc
========================================
1 1 L1D1
2 1 L1D2
3 1 L1D3
4 1 L1D4
5 2 L2D1
6 2 L2D2
7 2 L2D3
8 2 L2D4
9 3 L3D1
10 3 L3D2
11 3 L3D3
私は構造が以下のようになる別のテーブル(@tblLevelSpreadOut)を持っています
declare @tblLevelSpreadOut table(
levelSpreadOutID INT IDENTITY(1,1),
levelNumber1 INT,
levelDesc1 VARCHAR(100),
levelNumber2 INT,
levelDesc2 VARCHAR(100),
levelNumber3 INT,
levelDesc3 VARCHAR(100))
出力が
select levelNumber1, levelDesc1, levelNumber2 ,levelDesc2 , levelNumber3 ,levelDesc3
from @tblLevelSpreadOut
levelNumber1 levelDesc1 levelNumber2 levelDesc2 levelNumber3 levelDesc3
============================================================================
1 L1D1 2 L2D1 3 L3D1
1 L1D1 2 L2D1 3 L3D2
1 L1D1 2 L2D1 3 L3D3
1 L1D1 2 L2D2 3 L3D1
1 L1D1 2 L2D2 3 L3D2
1 L1D1 2 L2D2 3 L3D3
1 L1D1 2 L2D3 3 L3D1
1 L1D1 2 L2D3 3 L3D2
1 L1D1 2 L2D3 3 L3D3
1 L1D1 2 L2D4 3 L3D1
1 L1D1 2 L2D4 3 L3D2
1 L1D1 2 L2D4 3 L3D3
1 L1D2 2 L2D1 3 L3D1
1 L1D2 2 L2D1 3 L3D2
1 L1D2 2 L2D1 3 L3D3
1 L1D2 2 L2D2 3 L3D1
1 L1D2 2 L2D2 3 L3D2
1 L1D2 2 L2D2 3 L3D3
1 L1D2 2 L2D3 3 L3D1
1 L1D2 2 L2D3 3 L3D2
1 L1D2 2 L2D3 3 L3D3
1 L1D2 2 L2D4 3 L3D1
1 L1D2 2 L2D4 3 L3D2
1 L1D2 2 L2D4 3 L3D3
1 L1D3 2 L2D1 3 L3D1
1 L1D3 2 L2D1 3 L3D2
1 L1D3 2 L2D1 3 L3D3
1 L1D3 2 L2D2 3 L3D1
1 L1D3 2 L2D2 3 L3D2
1 L1D3 2 L2D2 3 L3D3
1 L1D3 2 L2D3 3 L3D1
1 L1D3 2 L2D3 3 L3D2
1 L1D3 2 L2D3 3 L3D3
1 L1D3 2 L2D4 3 L3D1
1 L1D3 2 L2D4 3 L3D2
1 L1D3 2 L2D4 3 L3D3
返信してくださった皆様、そして問題を閲覧してくださった皆様に感謝します。