Msg 102, Level 15, State 1, Line 3
Sintaxis incorrecta cerca de ' '.
De hecho no se por que se pone un asterisco, cuando copio y pego el mensaje se pone el asterisco entre las comillas.. estuve revisando todo y nada.. :(
Estoy copiando tu Qry tal cual:
Código SQL:
Ver originalSELECT Route, Version,Leg, DATE, MIN(TIME) AS Inicial, MAX (TIME) AS Final FROM
(SELECT r.ruta AS Route,v.version AS Version,l.leg AS Leg,CONVERT(DATE,e.fecha_agendada,105) AS DATE,CONVERT(VARCHAR,e.fecha_agendada,108)AS TIME
*FROM d_rutas AS r
*INNER JOIN d_versiones AS v ON r.id=v.id_ruta
*INNER JOIN d_legs AS l ON l.id_version=v.id
*INNER JOIN d_paradas AS p ON p.id_leg=l.id
*INNER JOIN d_eventos AS e ON e.id_parada=p.id
*LEFT *JOIN tm_transfer_bodegas AS tb ON tb.id_Bodega=p.id_bodega
WHERE tb.nombre='TTL'AND v.STATUS='A'
GROUP BY r.ruta,v.version,l.leg,e.fecha_agendada) AS Table1
GROUP BY Route, Version, Leg, DATE