You would have to try like below.
a, b, c
from xyz; // I have loaded all the basic columns
sum(a) as P,
Group by b,c; // deriving basic calculations (add b,c if you want c or b to be used in other tables using resident table 2)
(c + P) as M
resident Table2; // deriving advance calculations
Give this a try and let me know if it helps.
or a simple one to try would be
Sum(a) as P,
(c+sum(a)) as M
Group by b,c; (if you want a,b,c to be included then add them if not just the summation calculations should be sufficient)