This question already has an answer here:
We read in 1 Samuel 17: "David killed Goliath"
And as he talked with them, behold, there came up the champion, the Philistine of Gath, Goliath by name, out of the ranks of the Philistines, and spake according to the same words: and David heard them. 1 Samuel 17:23 ASV
Then David ran, and stood over the Philistine, and took his sword, and drew it out of the sheath thereof, and slew him, and cut off his head therewith. And when the Philistines saw that their champion was dead, they fled. 1 Samuel 17:51 ASV
But we read in 2 Samuel 21: "Elhanan killed the giant Goliath"
And there was again war with the Philistines at Gob; and Elhanan the son of Jaareoregim the Beth-lehemite slew Goliath the Gittite, the staff of whose spear was like a weaver’s beam. 2 Samuel 21:19 ASV
So, who killed Goliath?