title: Extremities selectio
body: <p>I have table with hundreds of rows such as the following example
  Input</p>
  <pre><code>Node-1 | Node-2 | ID
  Strt1  | Bg2    | 567
  Bf1    | Bg2    | 567
  Hr     | Bf1    | 567
  Strt2  | Al3    | 788
  Al3    | Bo67   | 788
  </code></pre>
  <p>The output should find the last node per group ID. The starting node on each ID is known (in the example str1 and strt2).
  The ouput should be something like that:
  Output</p>
  <pre><code>Start-node | Last-node | ID
  Strt1      | Hr        | 567
  Strt2      | Bo67      | 788
  </code></pre>
  <p>NB: The number of rows in the inputs per ID is variable. In a programming language i think it could done via looping starting from starting point but i m not sure how it s possible with an sql.
  Please advise how this can be achieved.</p>