Take the 2-minute tour ×
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. It's 100% free, no registration required.

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

1 Answer 1

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

 
discard

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.