title: Generalize a query that involves multiple instances of three tables SQL
body: <p>I am doing a formula to make some statistics in SQL, but I do not know how to improve a query I am working on...</p>
  
  <p>I made a <a href="http://sqlfiddle.com/#!2/d2ff6/9" rel="nofollow">sqlfiddle so you can understand me better</a></p>
  
  <p>So I have 3 tables and I need to solve  a formula varying the indexes, i,j... </p>
  
  <pre><code>i j
  ---
  1 1
  1 2
  1 3
  2 1
  2 2
  2 3
  3 1
  3 2
  3 3
  </code></pre>
  
  <p>and then do some sqrt and pow. I want the result in a table but I do not know how to generalize all those long queries into one...</p>