More about oxidation states

To deduce the oxidation state at the various atoms in a covalently bonded compound, the compound is viewed as being ionic with all of the bonding electrons "belonging" to the more electronegative atom in the bond.

Thus in water, for the purpose of assigning the oxidation state:
is H and  and H

Each H has no electrons (and is therefore +1)
O has eight electrons (and is therefore -2)

Many compounds and polyatomic ions contain oxygen.  Because oxygen is more electronegative than other elements, the oxidation state of oxygen is nearly always  -2.
except in peroxides where one of the bonds from each oxygen is to another oxygen (as in H-O-O-H) 
and the oxidation state of oxygen is  -1 AND in compounds when oxygen is bonded to fluorine (OF2).

For polyatomic ions and compounds having oxygen bonded to a less electronegative element, the oxidation state of the less electronegative element depends on the number of bonds to oxygen.
 
The oxidation state of nitrogen in NO3 is higher than in NO2 
because there are more bonds from oxygen to nitrogen  in NO3 than in NO2.

The oxidation state of the two sullfur atoms In thiosulfate ion (S2O32– which is S-SO32–) is not the same
because the bonding at the two sulfurs are bonded to different numbers of oxygens.

For binary compounds or ions (other than peroxides), the oxidation state of the atom bonded to oxygen can be calculated by
  • using -2 as the oxidation state of oxygen
  • using the fact that the sum of oxidation numbers of atoms in a polyatomic species equals its overall charge
    Example polyatomic ion:  For NO3  and NO2  the overall charge is -1.  The oxidation state of nitrogen in NO3 is +5.  For NO2 it is +3. 
    Example compounds:  For NH3 the overall charge is 0.
    For  S2O32–, this calculation gives the average oxidation state of the two sulfur atoms.