Riyad as-SalihinChapter 18Hadith 1151
Full Sharh — Riyad as-Salihin 1151
وعن ابن عمر رضي الله عنهما قال : قال رسولُ اللهِ : « إذَا أنْزَلَ اللهُ تَعَالَى بِقَومٍ عَذَاباً ، أصَابَ العَذَابُ مَنْ كَانَ فِيهِمْ ، ثُمَّ بُعِثُوا عَلَى أَعْمَالِهِمْ » . متفق عليه .
English Translation
Ibn 'Umar (May Allah be pleased with them) said:: The Messenger of Allah (ﷺ) said, "If Allah afflicts punishment upon a nation, it befalls the whole population indiscriminately and then they will be resurrected and judged according to their deeds.".
Source
Riyad as-Salihin(رياض الصالحين)
The Book of Miscellaneous ahadith of Significant Values
Hadith Number
1151