1st, the data should not be stored this way in a table. It appears you only need 2 columns, then the sum is easy.
so, as is, create some queries,
Q1, to sum P1,A1
Q2, to sum P2,A2, etc
Q3,etc
then make a UNION query to collect Q1 thru 3
select * from Q1
union
select * from Q2
union
select * from Q3
then the final query can sum items from the union.