title: get las record from group in postgres?
body: <p>i have the next structure for db, i need to get only the most recent row by id, for example the most recen row for id 1, the most recen row for id 2, etc, for the moment i have this query:</p>
  
  <pre><code>SELECT  max(fecha), id_transaccion, id_movimiento
  FROM transaccion_movimiento 
  group by (id_transaccion, id_movimiento, fecha);
  </code></pre>
  
  <p>To later adapt to this:</p>
  
  <pre><code>LEFT JOIN (SELECT  max(fecha), id_transaccion, id_movimiento FROM transaccion_movimiento  group by (id_transaccion, id_movimiento, fecha) ORDER BY ID_TRANSACCION asc LIMIT 1)nn ON T.id_transaccion = nn.id_transaccion LEFT JOIN ctl_tipo_movimiento IM ON IM.id_tipo_movimiento = nn.id_movimiento " +
  </code></pre>
  
  <p>Please i need help</p>
  
  <p><img src="https://i.stack.imgur.com/hEMVK.png" alt="Imge with commands and results"></p>