title: achieve "order by" before "group by" in mysql
body: <p>i have a DB with this structure</p>
  <p><strong>id, UserID, price, Date</strong></p>
  <pre><code>,1, 10.00, 2000-01-01
  ,1, 25.00 ,2022-02-01
  ,2, 12.00 ,2000-01-05
  ,2, 13.00 ,2001-01-05
  ,2, 24.00 ,2022-01-01
  ,3, 23.00 ,2022-01-01
  </code></pre>
  <p>i want to show the price for each user based on newest date.
  So just 1 row per UserID (latest date)</p>
  <p>if we query above table. results need to be like this:</p>
  <pre><code>    ,1, 25.00 ,2022-02-01
      ,2, 24.00 ,2022-01-01
      ,3, 23.00 ,2022-01-01
  </code></pre>
  <p>i have tried those 2 commands but they are not working</p>
  <blockquote>
  <p>SELECT UserID,price,Datee FROM (SELECT UserID,price,Datee FROM tbl
  ORDER BY UserID ASC,datee DESC) as tb_temp  GROUP BY UserID</p>
  </blockquote>
  <p>also this</p>
  <blockquote>
  <p>SELECT UserID,price,max(Datee) FROM tbl Group by UserID ORDER BY UserID ASC,datee DESC</p>
  </blockquote>
  <p>this command show latest date but price is not based on that</p>
  <p>so i need something like <strong>ORDER BY datee then group by userID</strong>  or  L<strong>IMIT 1 per userID</strong></p>