Good morning,
I have a table, with the following structure: request, itempedo, dt_diver, dt_ultima_alt
in this table, I have several records that are "Duplicates" except, the DT_ULTIMA_ALT field. I need to get a single record of these, with the larger date / time that is recorded in the dt_ultima_alt field.
Does anyone have a notion of how to do this? I tried to bring all the records with Max, however, as has duplicate records, it brings more than one record.
Thanks.
Get registration with larger date / time
Good morning Jerry,
Try something more or less like this:
Try something more or less like this:
select t.PEDIDO, t.ITEMPEDIDO, t.DT_DIVER, t.DT_ULTIMA_AL
from sua_tabela t
where DT_ULTIMA_AL = (select max(s.DT_ULTIMA_AL)
from sua_tabela s
where s.PEDIDO = t.PEDIDO
and s.ITEMPEDIDO = t.ITEMPEDIDO
and s.DT_DIVER = t.DT_DIVER);
-
- Information
-
Who is online
Users browsing this forum: No registered users and 14 guests