title: Getting the outer range of a grouped column of range types in Postgres
body: <p>I have a table with a column <code>name</code> consisting of text values that I want to group by. Additionally I have a table <code>value</code> consisting of numerical range values (of <a href="https://www.postgresql.org/docs/current/rangetypes.html" rel="nofollow noreferrer">range type</a>). I want to group by the <code>name</code> column and get the outer bounds for each of the groups.</p>
  <p>Here is an example:</p>
  <p><strong>Parameter table</strong></p>
  <pre><code>name                  value
  -----                 -----
  Nominal power         [1,2]
  Nominal power         [2,3]
  Nominal power ratio   [10,15]
  Nominal power ratio   [17,19]
  Hydrogen production   [1,6]
  Hydrogen production   [2,9]
  </code></pre>
  <p>Wanted output is something like this (or lower, upper bound in separate columns):</p>
  <pre><code>name                  outer range
  -----                 -----
  Nominal power         [1,3]
  Nominal power ratio   [10,19]
  Hydrogen production   [1,9]
  </code></pre>
  <p>Here is a query I attempted to run, but it failed:</p>
  <pre><code>select name, upper(value), lower(value) from parameters
  group by name
  </code></pre>
  <p>Is there a way to achieve this is Postgresql?</p>