I heard the Messenger of Allah ﷺ say, "When Allah intends punishment for a people, the punishment strikes everyone among them, then they will be raised according to their deeds."
سمعت رسول الله ﷺ يقول: إذا أراد الله بقوم عذابا أصاب العذاب من كان فيهم، ثم بعثوا على أعمالهم.
Bukhari narrated it in the Book of Tribulations (7108), and Muslim narrated it in the Book of Paradise and its Bliss (2879), both through Abdullah bin Wahb, who said, Yunus told me, from Ibn Shihab Zuhri, who said, Hamza bin Abdullah bin Umar told me that he heard Abdullah bin Umar say, then he mentioned it.