title: Get values from first and last row per group
body: <p>I'm new to Postgres, coming from MySQL and hoping that one of y'all would be able to help me out. </p>
  
  <p>I have a table with three columns: <code>name</code>, <code>week</code>, and <code>value</code>. This table has a record of the names, the week at which they recorded the height, and the value of their height.
  Something like this:</p>
  
  <pre><code>Name  |  Week  | Value
  ------+--------+-------
  John  |  1     | 9
  Cassie|  2     | 5
  Luke  |  6     | 3
  John  |  8     | 14
  Cassie|  5     | 7
  Luke  |  9     | 5
  John  |  2     | 10
  Cassie|  4     | 4
  Luke  |  7     | 4
  </code></pre>
  
  <p>What I want is a list per user of the value at the minimum week and the max week. Something like this:</p>
  
  <pre><code>Name  |minWeek | Value |maxWeek | value
  ------+--------+-------+--------+-------
  John  |  1     | 9     | 8      | 14
  Cassie|  2     | 5     | 5      | 7
  Luke  |  6     | 3     | 9      | 5
  </code></pre>
  
  <p>In Postgres, I use this query:</p>
  
  <pre><code>select name, week, value
  from table t
  inner join(
  select name, min(week) as minweek
  from table
  group by name)
  ss on t.name = ss.name and t.week = ss.minweek
  group by t.name
  ;
  </code></pre>
  
  <p>However, I receive an error:</p>
  
  <blockquote>
    <p>column "w.week" must appear in the GROUP BY clause or be used in an aggregate function<br>
    Position: 20</p>
  </blockquote>
  
  <p>This worked fine for me in MySQL so I'm wondering what I'm doing wrong here?</p>