1 Chronicles 21:1-9 NLT

1 Satan rose up against Israel and caused David to take a census of the Israelites.
2 David gave these orders to Joab and his commanders: "Take a census of all the people in the land -- from Beersheba in the south to Dan in the north -- and bring me the totals so I may know how many there are."
3 But Joab replied, "May the LORD increase the number of his people a hundred times over! But why, my lord, do you want to do this? Are they not all your servants? Why must you cause Israel to sin?"
4 But the king insisted that Joab take the census, so Joab traveled throughout Israel to count the people. Then he returned to Jerusalem
5 and reported the number of people to David. There were 1,100,000 men of military age in Israel, and 470,000 in Judah.
6 But Joab did not include the tribes of Levi and Benjamin in the census because he was so distressed at what the king had made him do.
7 God was very displeased with the census, and he punished Israel for it.
8 Then David said to God, "I have sinned greatly and shouldn't have taken the census. Please forgive me for doing this foolish thing."
9 Then the LORD spoke to Gad, David's seer. This was the message: