title: sql in oracle to find ratio with grouping by a column
body: <p>Can anyone please help me to find the following by using a sql in oracle</p>
  
  <pre><code>Input in oracle TableX --
  
  ColumnA |ColumnB      
  1      |20  
  1      |10  
  1      |30  
  2      |10  
  2      |30  
  3      |20  
  
  -- Desired result 
  
  ColumnA |ColumnB  |Ratio   
  1    |20    |0.333333333  
  1    |10    |0.166666667  
  1    |30    |0.5  
  2    |10    |0.25  
  2    |30    |0.75  
  3    |20    |1  
  
  SELECT
      ColumnA,
      ColumnB,
      ColumnA/sum(ColumnB) group ColumnA by as Ratio 
  FROM
      TableX
  GROUP BY
      ColumnA
  ORDER BY
      ColumnA
  </code></pre>
  
  <p>I can't figure out how to calculate percentage within the GROUP BY</p>
  
  <p>+++++++++<br>
      Explanation:<br>
      Trying to get the ratio by grouping ColumnA<br>
      First row results is grouping 1 from ColumnA like 20/(20+10+30) = 0.333333333<br>
      Grouping 2 from ColumnA 10/(10+30) = 0.25<br>
      last row result grouping 3 from ColumnA is like 20/20 = 1  </p>
  
  <pre><code>Hence the sum of 0.333333333+0.166666667+0.5 = 1  
  sum of 0.25  + 0.75  = 1  
  sum of 1+0 = 1
  </code></pre>