2 Samuel 23-24 (ESV)
The Last Words of David
23:1 Now these are the last words of David:
The oracle of David, the son of Jesse,
the oracle of the man who was raised on high,
the anointed of the God of Jacob,
the sweet psalmist of Israel: 
2 “The Spirit of the Lord speaks by me;
his word is on my tongue.
3 The God of Israel has spoken;
the Rock of Israel has said to me:
When one rules justly over men,
ruling in the fear of God,
4 he dawns on them like the morning light,
like the sun shining forth on a cloudless morning,
like rain  that makes grass to sprout from the earth.
5 “For does not my house stand so with God?
For he has made with me an everlasting covenant,
ordered in all things and secure.
For will he not cause to prosper
all my help and my desire?
6 But worthless men  are all like thorns that are thrown away,
for they cannot be taken with the hand;
7 but the man who touches them
arms himself with iron and the shaft of a spear,
and they are utterly consumed with fire.” 
David’s Mighty Men
9 And next to him among the three mighty men was Eleazar the son of Dodo, son of Ahohi. He was with David when they defied the Philistines who were gathered there for battle, and the men of Israel withdrew. 10 He rose and struck down the Philistines until his hand was weary, and his hand clung to the sword. And the Lord brought about a great victory that day, and the men returned after him only to strip the slain.
11 And next to him was Shammah, the son of Agee the Hararite. The Philistines gathered together at Lehi, where there was a plot of ground full of lentils, and the men fled from the Philistines. 12 But he took his stand in the midst of the plot and defended it and struck down the Philistines, and the Lord worked a great victory.
13 And three of the thirty chief men went down and came about harvest time to David at the cave of Adullam, when a band of Philistines was encamped in the Valley of Rephaim. 14 David was then in the stronghold, and the garrison of the Philistines was then at Bethlehem. 15 And David said longingly, “Oh, that someone would give me water to drink from the well of Bethlehem that is by the gate!” 16 Then the three mighty men broke through the camp of the Philistines and drew water out of the well of Bethlehem that was by the gate and carried and brought it to David. But he would not drink of it. He poured it out to the Lord 17 and said, “Far be it from me, O Lord, that I should do this. Shall I drink the blood of the men who went at the risk of their lives?” Therefore he would not drink it. These things the three mighty men did.
18 Now Abishai, the brother of Joab, the son of Zeruiah, was chief of the thirty.  And he wielded his spear against three hundred men  and killed them and won a name beside the three. 19 He was the most renowned of the thirty  and became their commander, but he did not attain to the three.
20 And Benaiah the son of Jehoiada was a valiant man  of Kabzeel, a doer of great deeds. He struck down two ariels  of Moab. He also went down and struck down a lion in a pit on a day when snow had fallen. 21 And he struck down an Egyptian, a handsome man. The Egyptian had a spear in his hand, but Benaiah went down to him with a staff and snatched the spear out of the Egyptian’s hand and killed him with his own spear. 22 These things did Benaiah the son of Jehoiada, and won a name beside the three mighty men. 23 He was renowned among the thirty, but he did not attain to the three. And David set him over his bodyguard.
24 Asahel the brother of Joab was one of the thirty; Elhanan the son of Dodo of Bethlehem, 25 Shammah of Harod, Elika of Harod, 26 Helez the Paltite, Ira the son of Ikkesh of Tekoa, 27 Abiezer of Anathoth, Mebunnai the Hushathite, 28 Zalmon the Ahohite, Maharai of Netophah, 29 Heleb the son of Baanah of Netophah, Ittai the son of Ribai of Gibeah of the people of Benjamin, 30 Benaiah of Pirathon, Hiddai of the brooks of Gaash, 31 Abi-albon the Arbathite, Azmaveth of Bahurim, 32 Eliahba the Shaalbonite, the sons of Jashen, Jonathan, 33 Shammah the Hararite, Ahiam the son of Sharar the Hararite, 34 Eliphelet the son of Ahasbai of Maacah, Eliam the son of Ahithophel of Gilo, 35 Hezro  of Carmel, Paarai the Arbite, 36 Igal the son of Nathan of Zobah, Bani the Gadite, 37 Zelek the Ammonite, Naharai of Beeroth, the armor-bearer of Joab the son of Zeruiah, 38 Ira the Ithrite, Gareb the Ithrite, 39 Uriah the Hittite: thirty-seven in all.
24:1 Again the anger of the Lord was kindled against Israel, and he incited David against them, saying, “Go, number Israel and Judah.” 2 So the king said to Joab, the commander of the army,  who was with him, “Go through all the tribes of Israel, from Dan to Beersheba, and number the people, that I may know the number of the people.” 3 But Joab said to the king, “May the Lord your God add to the people a hundred times as many as they are, while the eyes of my lord the king still see it, but why does my lord the king delight in this thing?” 4 But the king’s word prevailed against Joab and the commanders of the army. So Joab and the commanders of the army went out from the presence of the king to number the people of Israel. 5 They crossed the Jordan and began from Aroer,  and from the city that is in the middle of the valley, toward Gad and on to Jazer. 6 Then they came to Gilead, and to Kadesh in the land of the Hittites;  and they came to Dan, and from Dan  they went around to Sidon, 7 and came to the fortress of Tyre and to all the cities of the Hivites and Canaanites; and they went out to the Negeb of Judah at Beersheba. 8 So when they had gone through all the land, they came to Jerusalem at the end of nine months and twenty days. 9 And Joab gave the sum of the numbering of the people to the king: in Israel there were 800,000 valiant men who drew the sword, and the men of Judah were 500,000.
The Lord‘s Judgment of David’s Sin
10 But David’s heart struck him after he had numbered the people. And David said to the Lord, “I have sinned greatly in what I have done. But now, O Lord, please take away the iniquity of your servant, for I have done very foolishly.” 11 And when David arose in the morning, the word of the Lord came to the prophet Gad, David’s seer, saying, 12 “Go and say to David, ‘Thus says the Lord, Three things I offer  you. Choose one of them, that I may do it to you.’” 13 So Gad came to David and told him, and said to him, “Shall three  years of famine come to you in your land? Or will you flee three months before your foes while they pursue you? Or shall there be three days’ pestilence in your land? Now consider, and decide what answer I shall return to him who sent me.” 14 Then David said to Gad, “I am in great distress. Let us fall into the hand of the Lord, for his mercy is great; but let me not fall into the hand of man.”
15 So the Lord sent a pestilence on Israel from the morning until the appointed time. And there died of the people from Dan to Beersheba 70,000 men. 16 And when the angel stretched out his hand toward Jerusalem to destroy it, the Lord relented from the calamity and said to the angel who was working destruction among the people, “It is enough; now stay your hand.” And the angel of the Lord was by the threshing floor of Araunah the Jebusite. 17 Then David spoke to the Lord when he saw the angel who was striking the people, and said, “Behold, I have sinned, and I have done wickedly. But these sheep, what have they done? Please let your hand be against me and against my father’s house.”
David Builds an Altar
18 And Gad came that day to David and said to him, “Go up, raise an altar to the Lord on the threshing floor of Araunah the Jebusite.” 19 So David went up at Gad’s word, as the Lord commanded. 20 And when Araunah looked down, he saw the king and his servants coming on toward him. And Araunah went out and paid homage to the king with his face to the ground. 21 And Araunah said, “Why has my lord the king come to his servant?” David said, “To buy the threshing floor from you, in order to build an altar to the Lord, that the plague may be averted from the people.” 22 Then Araunah said to David, “Let my lord the king take and offer up what seems good to him. Here are the oxen for the burnt offering and the threshing sledges and the yokes of the oxen for the wood. 23 All this, O king, Araunah gives to the king.” And Araunah said to the king, “May the Lord your God accept you.” 24 But the king said to Araunah, “No, but I will buy it from you for a price. I will not offer burnt offerings to the Lord my God that cost me nothing.” So David bought the threshing floor and the oxen for fifty shekels  of silver. 25 And David built there an altar to the Lord and offered burnt offerings and peace offerings. So the Lord responded to the plea for the land, and the plague was averted from Israel.