The Messenger of Allah ﷺ said, "When Allah sends down punishment upon a people, it strikes everyone among them, then they will be resurrected according to their deeds."
قال رسول الله ﷺ: إذا أنزل الله بقوم عذابا، أصاب العذاب من كان فيهم، ثم بعثوا على أعمالهم.
Bukhari narrated it in the Book of Tribulations (7108) and Muslim in the Book of Paradise, Its Description of Bliss, and Its People (2879), both through the route of Abdullah bin Wahb, who said, Yunus informed us, from Ibn Shihab Zuhri, who said, Hamza bin Abdullah bin Umar informed me, that he heard Ibn Umar say, and he mentioned it. The wording given is that of Bukhari, and the wording of Muslim is similar.