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