Ver Mensaje Individual
  #2 (permalink)  
Antiguo 17/11/2011, 09:32
Avatar de Libras
Libras
Colaborador
 
Fecha de Ingreso: agosto-2006
Ubicación: En la hermosa perla de occidente
Mensajes: 7.412
Antigüedad: 17 años, 8 meses
Puntos: 774
Respuesta: consulta para hallar el utlimo registrado

Código SQL:
Ver original
  1. CREATE TABLE #temp
  2. (
  3. usuario VARCHAR(20),
  4. fecha datetime
  5. )
  6.  
  7.  
  8. INSERT INTO #temp VALUES ('juan', '10/11/2011')
  9. INSERT INTO #temp VALUES ('jose', '10/11/2011')
  10. INSERT INTO #temp VALUES ('pedro', '10/11/2011')
  11. INSERT INTO #temp VALUES ('luis', '10/12/2011')
  12. INSERT INTO #temp VALUES ('jose', '10/12/2011')
  13. INSERT INTO #temp VALUES ('juan', '10/12/2011')
  14. INSERT INTO #temp VALUES ('antonio', '10/12/2011')
  15. INSERT INTO #temp VALUES ('jose', '10/13/2011')
  16. INSERT INTO #temp VALUES ('luis', '10/13/2011')
  17. INSERT INTO #temp VALUES ('pedro', '10/13/2011')
  18.  
  19.  
  20. SELECT * FROM #temp WHERE fecha = (SELECT MAX(fecha) FROM #temp)

Saludos!
__________________
What does an execution plan say to t-sql query? Go f**k yourself, if you are not happy with me