Abdullah bin Abi Bakr bin Muhammad narrates from his father, and he from his grandfather (may Allah be pleased with him), that he heard the Messenger of Allah (peace and blessings be upon him) saying: "Whoever visits a sick person remains in the mercy of Allah as long as he sits with him and is immersed in it, and when he gets up from him he keeps wading in it until he returns to where he set out from. And whoever consoles (offers condolence to) his Muslim brother in a calamity, Allah Almighty will clothe him in garments of honour and dignity on the Day of Resurrection."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الجنائز / 7087
It is narrated from Sayyiduna Abdullah bin Mas'ud (may Allah be pleased with him) that the Messenger of Allah (peace and blessings be upon him) said: "Whoever consoles and sympathises with one struck by a calamity will have a reward equal to his."
Only Ali bin Asim narrated it, and it is one of the narrations for which he was criticised; it has also been narrated from others besides him. And Allah knows best.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الجنائز / 7088
Mu'awiyah bin Qurrah narrates from his father (may Allah be pleased with him) the hadith containing the story of a man who had a little son; the two of them used to come to the Prophet (peace and blessings be upon him). His little son died, and grief over him kept him from attending the gathering. The Prophet (peace and blessings be upon him) met him and asked him about his son, and he told him that he had died. So the Prophet (peace and blessings be upon him) consoled him and said: "O so-and-so, which would be dearer to you: that you enjoy him throughout your life, or that tomorrow you do not come to any of the gates of Paradise without finding that he has gone ahead of you to it and opened it for you?" He said: O Prophet of Allah, no; rather, that he goes ahead of me to the gates of Paradise is dearer to me. He (peace and blessings be upon him) said: "That is yours." Then a man from the Ansar stood up and said: O Prophet of Allah (peace and blessings be upon him), may Allah make me your ransom, is this for this man in particular, or will it be for whoever among the Muslims loses a child? He (peace and blessings be upon him) said: "No, rather it will be for whoever among the Muslims loses a child."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الجنائز / 7089