14/08/2014, 15:16
|
| Colaborador | | Fecha de Ingreso: agosto-2006 Ubicación: En la hermosa perla de occidente
Mensajes: 7.412
Antigüedad: 18 años, 4 meses Puntos: 774 | |
Respuesta: Sumar horas con criterio en comun
Código SQL:
Ver originalCREATE TABLE #temp ( campo1 VARCHAR(20), campo2 VARCHAR(20) ) INSERT INTO #temp VALUES ('S_YOMBLON','00:04:55') INSERT INTO #temp VALUES ('S_YOMBLON','01:16:55') INSERT INTO #temp VALUES ('S_YOMBLON','07:10:15') INSERT INTO #temp VALUES ('S_YOMBLON','07:12:45') INSERT INTO #temp VALUES ('S_YOMBLON','07:24:30') INSERT INTO #temp VALUES ('S_YOMBLON','07:29:38') INSERT INTO #temp VALUES ('S_YOMBLON','07:31:58') INSERT INTO #temp VALUES ('S_YOMBLON','07:34:50') INSERT INTO #temp VALUES ('S_YOMBLON','07:41:30') SELECT campo1, RIGHT(100+SUM(CAST(PARSENAME(REPLACE(campo2,':','.'),3) AS INT)) +SUM((CAST(PARSENAME(REPLACE(campo2,':','.'),2) AS INT) +CAST(PARSENAME(REPLACE(campo2,':','.'),1) AS INT)))/60,2) +':' +RIGHT(100+SUM((CAST(PARSENAME(REPLACE(campo2,':','.'),2) AS INT) +CAST(PARSENAME(REPLACE(campo2,':','.'),1) AS INT)))%60,2) +':' +RIGHT(100+SUM(CAST(PARSENAME(REPLACE(campo2,':','.'),1) AS INT))%60,2) FROM #temp GROUP BY campo1
Busquele en google: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=121027
__________________ What does an execution plan say to t-sql query? Go f**k yourself, if you are not happy with me |