Advertisement

TrimwebsolutionsTrimwebsolutions

Problem and Solutions

SQL Oracle select second max [duplicate] ?

By M.K. Verma · 4 May 2022

SQL Oracle select second max [duplicate] ?

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