title: SQL (Oracle) Updating multiple rows with calculated values (distance by Pythagorean theorem)
body: <p>How do I update all rows with calculated data derived from the values in two other columns of the same record?</p>
  
  <p>Here's the situation: </p>
  
  <p>I have a table called <code>customers</code>. It had 4 columns - <code>Customer_ID</code>, <code>Customer_Name</code>, <code>Coordinate_X</code> and <code>Coordinate_Y</code>'. Since creating and filling the table with data I have added an empty 5th column called <code>Distance</code></p>
  
  <p>What I'd like to do is fill the <code>Distance</code> column with the calculated distances from (0,0) to the locations specified in the <code>Coordinate_X</code> and <code>Coordinate_Y</code> columns of each row. I figured I could use Pythagoras's theory - and the correct values come up when I use the query:</p>
  
  <pre><code>Select SQRT(Power(customers.coordinate_x,2) + Power(customers.coordinate_y,2)) from customers
  </code></pre>
  
  <p>I fiddled about trying to make a trigger - failed that through lack of experience. 
  Then I tried to fill the column using queries - failed that too.</p>
  
  <p>I've been trying things like this; </p>
  
  <pre><code>update customers set distance = (Select SQRT(Power(customers.coordinate_x,2) + Power(customers.coordinate_y,2)) from customers) 
  </code></pre>
  
  <p>Nothing's working - the best I'm getting is <code>ORA-01427: single-row subquery returns more than one row</code> </p>