Suppose we have this database
codigo, data, valor,seq
(1, '2014-01-01', 10,2),
(1, '2014-01-02', 20,1),
(2, '2014-01-03', 30,1),
(2, '2014-01-05', 40,1),
(2, '2014-01-05', 50,2),
(3, '2014-01-06', 60,1);
I want to get the most recent date for each code, however, there will be repeated dates, and when this occurs I will have to pick up the largest Seq.
That is, the expected result is
1, '2014-01-02', 20,1
2, '2014-01-05', 50,2
3, '2014-01-06', 60,1