I calculated this:
molar mass (M) of Mg(NO3)2 is 148,32 (24,3 + 2*14,01 + 6*16)
so when there is 7 grams Mg(NO3)2 there is 0,0472 mol (7/148,32)

But how do i find out how much of that is oxygen? Do i just divide by 8 and multiply by 6? (because 8 atoms of with 6 are oxygen)