title: SQL: list of points to rectangle
body: <p>I have two tables:</p>
  
  <pre><code>regions &lt;id&gt;
  points &lt;region_id, x, y&gt;
  </code></pre>
  
  <p><em>Assuming</em> there are exactly 4 points per region, and these points describe a rectangle -- is there an SQL query that will bring me this view:</p>
  
  <pre><code>rectangular_regions &lt;region_id, x1, y1, x2, y2&gt;
  </code></pre>
  
  <p>?</p>