Here’s how you can go about doing this.
I’ll show you how to find the oxidation states of the atoms in copper(II) nitrate ##Cu(NO_3)_2## and you can use this example on potassium nitrate ##KNO_3##.
When dealing with an you can make you life easier by breaking it up into its constituent cation and anion.
In the case of copper(II) nitrate you know that you have
Start with what you know. The oxidation number of oxygen in most is ##(-2)## and the overall charge on the nitrate anion is ##(1-)##.
This means that the oxidation number of the nitrogen atom and the sum of the oxidation state of the oxygen atoms must add up to give the charge of the anion ##(1-)##.
So one nitrogen atom and 3 oxygen atoms will give you
##ON_nitrogen + 3 xx ON_oxygen = -1##
##ON_nitrogen + 3 xx (-2) = -1##
##ON_nitrogen = -1 +6 = +5##
Now for the oxidation number of copper. Since it exists as copper(II) cations its overall charge will equal its oxidation state.
So to sum this up you will get
##stackrel(color(blue)(+2))(Cu)(stackrel(color(blue)(+5))(N) stackrel(color(blue)(-2))(O)_3)_2##