I had that question in a code interview, I found a possible solution but I want to hear from you so thanks for your comments and help.
Select max(ID) from table where ID not in (select max(ID) from table)
I had that question in a code interview, I found a possible solution but I want to hear from you so thanks for your comments and help.
Select max(ID) from table where ID not in (select max(ID) from table)
Use a window function:
select *
from (
select x.*,
row_number() over (order by x.id) as rn
from the_table x
) t
where rn = 2;