1 Chronicles 21:4-7
4-7But David wouldn't take no for an answer, so Joab went off and did it— canvassed the country and then came back to Jerusalem and reported the results of the census: There were 1,100,000 fighting men; of that total, Judah accounted for 470,000. Joab, disgusted by the command—it, in fact, turned his stomach!—protested by leaving Levi and Benjamin out of the census-taking. And God, offended by the whole thing, punished Israel.
8Then David prayed, "I have sinned badly in what I have just done, substituting statistics for trust; forgive my sin—I've been really stupid."