The annihilation of all Midianites except for virgin women occurs in Numbers 31; the killing of all Amalekites is ordered in 1 Samuel 15.