title: Getting data from first and last row of each group
body: <p>I've found many similar topics to this but none I can understand well enough to solve my specific case.</p>
  
  <p>A have a table with the following basic structure:</p>
  
  <pre><code>+------------------------+
  | id | session ID | bal  |
  +------------------------+
  | 0  | 00000002 | 100    |
  | 1  | 00000002 | 120    |
  | 2  | 00000002 | 140    |
  | 3  | 00000001 | 900    |
  | 4  | 00000001 | 800    |
  | 5  | 00000001 | 500    |
  +------------------------+ 
  </code></pre>
  
  <p>I need to create a (Microsoft SQL) query which returns each unique sessionID along with the first ("start") and last ("end") bal entries based on sequencial value of the ID column. The result would look like this:</p>
  
  <pre><code>+---------------------------+
  | session ID | start | end  |
  +---------------------------+
  | 00000002   | 100   | 140  |
  | 00000001   | 900   | 500  |
  +---------------------------+
  </code></pre>
  
  <p>How can I achieve this?</p>