Cross Apply 2
Cross Apply 2
Struc
(
ID int NOT NULL
, Person nvarchar(30) NOT NULL
, Age int NOT NULL
, Gender char(1) NOT NULL
, Month1 int NOT NULL
, Value1 int NOT NULL
, Month2 int NOT NULL
, Value2 int NOT NULL
);
INSERT INTO dbo.Struc (ID, Person, Age, Gender, Month1, Value1, Month2, Value2)
VALUES (1, 'Jane', 20, 'F', 201507, 1, 201508, 0)
, (2, 'John', 30, 'M', 201507, 0, 201508, 1);
SELECT s.ID
, s.Person
, s.Age
, s.Gender
, v.Month
, v.Value
FROM dbo.Struc s
CROSS APPLY (VALUES
(Month1, Value1)
, (Month2, Value2)
) v(Month, Value);