lo mismo que pense yo :P
Código SQL:
Ver originalCREATE TABLE #temp
(
id INT,
nombre VARCHAR(20),
fecha DATE,
entrada TIME,
salida TIME
)
INSERT INTO #temp VALUES (22122005,'CHAUR','04/06/2013',NULL,'13:17:23')
INSERT INTO #temp VALUES (22122005,'CHAUR','04/06/2013', '06:20:21', NULL)
INSERT INTO #temp VALUES (42910017,'ESCOBAR','04/06/2013', '06:27:15', NULL)
INSERT INTO #temp VALUES (43114011,'CACERES','04/06/2013','06:31:12', NULL)
INSERT INTO #temp VALUES (52999015,'JARAMILLO','04/06/2013', '06:08:03', NULL)
INSERT INTO #temp VALUES (52999015,'JARAMILLO','04/06/2013', NULL ,'06:48:17')
INSERT INTO #temp VALUES (52999015,'JARAMILLO','04/06/2013', '06:52:51', NULL)
INSERT INTO #temp VALUES (63126005,'BARRERA','04/06/2013', '06:14:57', NULL)
INSERT INTO #temp VALUES (92109002,'SUAREZ','04/06/2013', '06:25:34', NULL)
INSERT INTO #temp VALUES (92109002,'SUAREZ','04/06/2013', NULL, '13:17:15')
INSERT INTO #temp VALUES (92129008,'RODRIGUEZ','04/06/2013', '06:12:28',NULL)
INSERT INTO #temp VALUES (92129008,'RODRIGUEZ','04/06/2013', NULL,'13:17:20')
INSERT INTO #temp VALUES (93119011,'VEGA','04/06/2013', '06:09:14',NULL)
SELECT SUM(horas) horas ,SUM(minutos) minutos ,id INTO #temp2 FROM(
SELECT id,DATEDIFF(hh,entrada,salida) horas,datediff(mi,entrada,salida) minutos,entrada,salida FROM(
SELECT t1.id,
CASE WHEN t1.entrada IS NULL THEN t2.entrada ELSE t1.entrada END AS entrada,
CASE WHEN t1.salida IS NULL THEN t2.salida ELSE t1.salida END AS salida
--t1.entrada,t1.salida,t2.entrada,t2.salida
FROM #temp AS t1
LEFT JOIN #temp AS t2 ON (t1.id=t2.id)
) AS t3 WHERE (entrada IS NOT NULL OR salida IS NOT NULL)
GROUP BY id,entrada,salida
) t4 GROUP BY id