i have in database like this
say a table X with columns A and B
X
--
A B
1 300
1 400
1 100
2 200
2 400
and i want to write sql query to get result in format
P Q
1 800
2 600
Where Q is sum of all having same value of A.
I thought of selecting the data in same format and then using the logic display it is there a way to do with SQL query?