return only your last move of each code

1

A table records the movement of items by item code, date and time of movement.

Soon the presentation looks like this:

CD_Item | DT_Mov
  15      10/04/2018 08:52:36
  15      21/05/2018 09:32:10
  15      20/05/2018 14:24:08
  15      10/04/2018 08:52:36
  08      26/05/2018 09:32:10
  08      27/05/2018 14:24:08
  69      16/05/2018 09:32:10
  69      20/05/2018 14:24:08

I want to make a select to grab all items, but let it return only its last move of each code.

Result:

CD_Item | DT_Mov
   15     21/05/2018 09:32:10
   08     27/05/2018 14:24:08
   69     20/05/2018 14:24:08

The bank is Oracle.

I researched other questions of the type suggested by the forum, but they did not give me a solution.

    
asked by anonymous 22.05.2018 / 16:38

1 answer

1

If the table structure is the one you have pasted, just:

Select
    cd_item,
    max(dt_mov) as ultima_data
from movimentacao
group by cd_item
    
22.05.2018 / 16:41