title: Select the top 1 row from each group
body: <p>I have a table that lists the versions of software that are installed:
  </p>
  
  <pre><code>id  | userid | version | datetime
  ----+--------+---------+------------------------
  111 | 75     | 10075   | 2013-03-12 13:40:58.770
  112 | 75     | 10079   | 2013-03-12 13:41:01.583
  113 | 78     | 10065   | 2013-03-12 14:18:24.463
  114 | 78     | 10079   | 2013-03-12 14:22:20.437
  115 | 78     | 10079   | 2013-03-12 14:24:01.830
  116 | 78     | 10080   | 2013-03-12 14:24:06.893
  117 | 74     | 10080   | 2013-03-12 15:31:42.797
  118 | 75     | 10079   | 2013-03-13 07:03:56.157
  119 | 75     | 10080   | 2013-03-13 07:05:23.137
  120 | 65     | 10080   | 2013-03-13 07:24:33.323
  121 | 68     | 10080   | 2013-03-13 08:03:24.247
  122 | 71     | 10080   | 2013-03-13 08:20:16.173
  123 | 78     | 10080   | 2013-03-13 08:28:25.487
  124 | 56     | 10080   | 2013-03-13 08:49:44.503
  </code></pre>
  
  <p>I would like to display all fields of one record from each <code>userid</code> but only the highest version (also version is a <code>varchar</code>).</p>