Código SQL:
Ver originalCREATE TABLE #temp
(
id INT,
cliente VARCHAR(20),
rn INT IDENTITY(1,1)
)
INSERT INTO #temp VALUES (10,'Cliente A')
INSERT INTO #temp VALUES (10,'Cliente B')
INSERT INTO #temp VALUES (10,'Cliente C')
INSERT INTO #temp VALUES (10,'Cliente D')
INSERT INTO #temp VALUES (20,'Cliente A')
INSERT INTO #temp VALUES (20,'Cliente B')
INSERT INTO #temp VALUES (20,'Cliente C')
SELECT t1.id AS workcenter,t1.cliente,t1.rn AS id, t2.cliente AS inyectado, t2.rn AS idinyectado FROM #temp AS t1
LEFT JOIN #temp AS t2 ON (t1.rn+1=t2.rn AND t1.id=t2.id)
Resultado:
workcenter cliente id inyectado idinyectado
10 Cliente A 1 Cliente B 2
10 Cliente B 2 Cliente C 3
10 Cliente C 3 Cliente D 4
10 Cliente D 4 NULL NULL
20 Cliente A 5 Cliente B 6
20 Cliente B 6 Cliente C 7
20 Cliente C 7 NULL NULL