I have this query:
SELECT DISTINCT Q.[creation_date], Round(Now()-Q.[creation_date],0) AS Diferenc,
Q.[Nº Siniest], Q.Asunt, Q.Usu, Q.Obs
FROM [HISTORIC] AS Q
WHERE (((Q.[creation_date])=(SELECT MAX([creation_date])
FROM [HISTORIC] As T
WHERE T.[Nº Siniest] = Q.[Nº Siniest])) AND ((Q.Asunt) Not Like
"Autofact*") AND ((Q.Asunt) Not Like "Final*"))
ORDER BY Q.[creation_date];
[HISTORIC] has this format:
Nº Siniest creation_date Asunt
10408002464 18/11/2008 11:08:00 Repar cur
10408002464 18/11/2008 13:45:00 Pendiente Tramitador
10408002464 19/11/2008 10:15:00 Pendiente Tramitador
10408002464 25/11/2008 17:59:00 Reparaci¢n en curso
10408002464 02/12/2008 14:38:00 Pendiente Tramitador
10408002464 03/12/2008 12:17:00 Pendiente Tramitador
10408002464 05/12/2008 11:55:00 Valoración aceptada
10408002464 05/12/2008 11:55:00 Autofactur
I have a problem in the above case, where the last two rows have the same creation_date and should take the last row, however it takes the previous row (10408002464 05/12/2008 11:55:00 Valoración aceptada)
Any ideas?
SELECT DISTINCT Q.[creation_date], Round(Now()-Q.[creation_date],0) AS Diferenc,
Q.[Nº Siniest], Q.Asunt, Q.Usu, Q.Obs
FROM [HISTORIC] AS Q
WHERE (((Q.[creation_date])=(SELECT MAX([creation_date])
FROM [HISTORIC] As T
WHERE T.[Nº Siniest] = Q.[Nº Siniest])) AND ((Q.Asunt) Not Like
"Autofact*") AND ((Q.Asunt) Not Like "Final*"))
ORDER BY Q.[creation_date];
[HISTORIC] has this format:
Nº Siniest creation_date Asunt
10408002464 18/11/2008 11:08:00 Repar cur
10408002464 18/11/2008 13:45:00 Pendiente Tramitador
10408002464 19/11/2008 10:15:00 Pendiente Tramitador
10408002464 25/11/2008 17:59:00 Reparaci¢n en curso
10408002464 02/12/2008 14:38:00 Pendiente Tramitador
10408002464 03/12/2008 12:17:00 Pendiente Tramitador
10408002464 05/12/2008 11:55:00 Valoración aceptada
10408002464 05/12/2008 11:55:00 Autofactur
I have a problem in the above case, where the last two rows have the same creation_date and should take the last row, however it takes the previous row (10408002464 05/12/2008 11:55:00 Valoración aceptada)
Any ideas?