try this if you want 2nd max by id_dependent
-- untested
select id_dependent, max(data) from
gest gest_out where data not in
(SELECT MAX (data), id_dependent
FROM gest gest_in where gest_out.id_dependent = gest_in.id_dependent
group by id_dependent)
group by id_dependent
* Be the first to Make Comment