Ubayd bin Khalid reported,

The Messenger of Allah ﷺ established a bond of brotherhood between two men. One of them was killed, and the other died about a week or so later. We performed the funeral prayer over him, and the Messenger of Allah ﷺ asked, "What did you say?"We replied, "We supplicated for him, saying, 'O Allah, forgive him and join him with his companion.'"The Messenger of Allah ﷺ said, "Then what about his prayers after his companion's prayers, and his fasting after his fasting," Shuba was uncertain about the mention of fasting, "and his deeds after his deeds? Between the two of them is a distance like that between the heavens and the earth."

Azami 3525

Sahih

عن عبيد بن خالد السلمي قال

آخي رسول الله ﷺ بين رجلين، فقتل أحدهما، ومات الآخر بعده بجمعة أو نحوها، فصلينا عليه، فقال رسول الله ﷺ: ما قلتم؟ فقلنا: دعونا له، وقلنا: اللهم اغفر له، والحقه بصاحبه، فقال رسول الله ﷺ: فأين صلاته بعد صلاته، وصومه بعد صومه؟ شك شعبة في صومه. وعمله بعد عمله، إن بينهما كما بين السماء والأرض.

الأعظمي 3525صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Funerals
Chapter
Dying person
Section
Virtue of one whose life was long and whose deeds were good
Numbering
Jami al-Kamil 3525 (2nd edition)
Azami 3525