Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a table of Promotion where a employee has given four promotions. I want to find out the previous promotion (3th) of last promotions date .

share|improve this question
You should add further detail to this question. The table definition, and any queries you've attempted along with the output would be nice. – Max Vernon Nov 5 '12 at 19:55

This returns, for every employee their 2nd last promotion date.

select *
  from (
select *,
       row_number() over (partition by employee order by promoted_date desc) rn
  from Promotion
       ) numbered
 where rn=2;
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.