|
Sql2
Estimadoas
utilice el top 1 y me resulto muhas gracias por la ayuda, ahora si yo quiero ponerle un order by en mi ultima linea me sale que el order by no trabaja en sub consultas ya que quieero ordenarlo por apellido a la espera de su ayuda.
select
r.*,convert(char(10),GETDATE(),112) FechaActual ,
(select Top 1 [LogTime]from History as h where [UserID]= r.FingerID AND [FKey]='Entrada'and [LogDate] ='2011/05/17')Entrada,
(select Top 1[LogTime]from History as h where [UserID]= r.FingerID AND [FKey]='InicioAlmuerzo'and [LogDate] ='2011/05/17')InicioAlmuerzo,
(select Top 1[LogTime]from History as h where [UserID]= r.FingerID AND [FKey]='FinAlmuerzo'and [LogDate] ='2011/05/17')FinAlmuerzo,
(select Top 1[LogTime]from History as h where [UserID]= r.FingerID AND [FKey]='Salida'and [LogDate] ='2011/05/17')Salida
FROM
(SELECT [Cod_per]CodPersonal
,[ApePat_per]ApellidoPaterno
,[ApeMat_per]ApellidoMaterno
,[Nom_per] NombrePersonal
,[NomProy_per]Proyecto
,[NomArea_per]Area
,[Estado_per]Estado
,[Cod_Finger]FingerID
FROM T_Personal
where [NomProy_per]='BMP'
and NomArea_per='Sistemas'
and Estado_per='Activo')r;
|