Both Ezra 2 and Nehemiah 7 record those who came in the first return under Zerubbabel. The two accounts agree on the total number of the congregation (42,360) and the total number of servants (7,337); see Ezra 2:64-65 and Nehemiah 7:66-67. However, on lesser details, there are a number of differences (for instance, compare Ezra 2:5 with Nehemiah 7:10). Why would this be the case?
Ezra gave the number of those "that went up out of the captivity, of those which had been carried away, whom Nebuchadnezzar the king of Babylon had carried away unto Babylon, and came again unto Jerusalem and Judah, every one unto his city" (Ezra 2:1). That is, he is giving the original list of people who left Babylon and joined the trip to Israel.
However, Nehemiah "found a register of the genealogy of them which came up at the first" (Nehemiah 7:5). According to the best chronology I can find, Nehemiah came to build the walls of Jerusalem 92 years after the original return of Jews under Zerubbabel. Most people have no idea that the time between these returns is so long. This is one of the very interesting details I discovered years ago when I studied the Return from Babylonian Captivity. What Nehemiah found was the official registry of the returning Jews that had been kept for the establishment of genealogical lines. As the official registry, it was probably updated for a time to include the effects of births, deaths, marriages, etc. The total numbers of those who returned did not change, but their numbers in the official registry did change for a time.
In neither of the accounts is everyone listed according to family, city, or occupation. Those particularly mentioned in Ezra add up to only 29,818; in Nehemiah to only 31,089. There are over 10,000 people who are not mentioned by family or city but are included in the total. These people probably included those who made up very small groups and those who were from tribes other than Judah, Benjamin, or Levi.