Código SQL:
Ver originalCREATE TABLE #temp
(
cliente VARCHAR(20),
compra VARCHAR(20),
fecha VARCHAR(20),
hora VARCHAR(20)
)
INSERT INTO #temp VALUES ('juan','12B','2012-08-16','16:30:00')
INSERT INTO #temp VALUES ('María','13A','2012-08-15','20:30:00')
INSERT INTO #temp VALUES ('Juan','23C','2012-08-16','16:35:00')
INSERT INTO #temp VALUES ('Julián','13C','2012-08-14','10:20:00')
INSERT INTO #temp VALUES ('Juan','22A','2012-08-13','18:40:00')
INSERT INTO #temp VALUES ('María','23I','2012-08-16','16:30:00')
INSERT INTO #temp VALUES ('José','34F','2012-08-16','16:30:00')
SELECT * FROM #temp WHERE compra IN
(
SELECT compra FROM(
SELECT MAX(columna) AS columna1, cliente,MAX(compra) AS compra FROM(
SELECT CONVERT(datetime, fecha + ' ' + hora) AS columna, compra,cliente FROM #temp
) t1 GROUP BY cliente
) t2
)
saludos!