Sahih Bukhari Volume 4, Book 52, Hadith Number 146.

Narated By Abu Said Al-Khudri : The Prophet said, “A time will come when groups of people will go for Jihad and it will be asked, ‘Is there anyone amongst you who has enjoyed the company of the Prophet?’ The answer will be, ‘Yes.’ Then they will be given victory (by Allah) (because of him). Then a time will come when it will be asked. ‘Is there anyone amongst you who has enjoyed the company of the companions of the Prophet?’ It will be said, ‘Yes,’ and they will be given victory (by Allah). Then a time will come when it will be said. ‘Is there anyone amongst you who has enjoyed the company of the companions of the companions of the Prophet?’ It will be said, ‘Yes,’ and they will be given victory (by Allah).”