According to the superscription of Psalm 60, David was on campaign against two Aramean leaders/armies (Aram-Naharim and Aram-Zobah) when the Edomites invaded and attacked Judah (an inference drawn from Psalm 60:1–4). Hearing this news, Joab was then sent to return
and fight against the Edomites, a battle which took place in the Valley of Salt. Joab is said to have struck down 12,000 Edomites in this valley. It appears as if the victory of Joab was credited to David.
13 And David made a name for himself when he returned from striking down 18,000 Edomites in the Valley of Salt.