title: SQL query for selecting sum of multiple column based on other column
body: <p>i have in database like this</p>
  
  <p>say a table X with columns A and B</p>
  
  <pre><code>X
  --
  A B
  1 300
  1 400
  1 100
  2 200
  2 400
  </code></pre>
  
  <p>and i want to write sql query to get result in format</p>
  
  <pre><code>P Q
  1 800
  2 600
  </code></pre>
  
  <p>Where Q is sum of all having same value of A.</p>
  
  <p>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?</p>