987 B
David counted the soldiers who were with him and appointed
David did not count all of the people himself, rather other men counted them. Alternate translation: "David commanded for the soldiers who were with him to be counted and he appointed" or "David arranged the soldiers who were with him and appointed" (See: rc://en/ta/man/translate/figs-metonymy)
captains of thousands and captains of hundreds
Possible meanings are 1) these numbers represent the exact amount of soldiers that these captains led. Alternate translation: "captains of 1,000 soldiers and captains of 100 soldiers" or 2) the words translated as "thousands" and "hundreds" do not represent exact numbers, but are the names of larger and smaller military divisions. Alternate translation: "captains of large military divisions and captains of smaller military divisions" (See: rc://en/ta/man/translate/translate-numbers)
captains
A captain is a person who is in authority over a group of soldiers.