The records of David's family reveal profound stories of both blessing and personal tragedy. When recounting the sons born to David in Jerusalem, a noticeable gap emerges between different historical accounts. The Book of Samuel counts only seven sons, while the Book of Chronicles lists nine, with the names Elishama and Eliphelet appearing twice.
The primary explanation for this duplication and the differing totals is that the first sons to bear these names died. When David later had more sons, he named them Elishama and Eliphelet in memory of their deceased brothers. The Book of Samuel focuses strictly on the seven sons who survived. In contrast, the Book of Chronicles includes all nine to honor David and his lineage, highlighting that he was blessed with a large family [רש״י].
A different perspective connects the mention of these deceased sons directly to the consequences of David's actions with Bathsheba. When confronted about his sin, David declared that he must repay the stolen lamb fourfold, unknowingly bringing upon himself a punishment of losing four of his own children. While certain traditions attempt to complete this count by including Tamar, who did not actually die, or the very first child whose death was a separate decree, the inclusion of these two deceased sons provides a precise answer. Their deaths accurately complete the tragic count of the four sons David lost as a result of his sin [מלבי״ם].
Additionally, there is a variation regarding the name Elishama, as other biblical records refer to this son as Elishua. This difference exists because his name was altered to Elishua after his younger brother was given the name Elishama. The account here simply chooses to record his original, primary name before the change took place [מלבי״ם].