title: SQL Get leaderboard of top 50 most earned by table
body: <p>So, I don't really know how to do this in SQL, so that's why I'm here right now. So, I have a website where people can earn points, everything gets logged in a table called <code>earnings</code>. The table structure is <code>id (uniue), uid, username, amount</code>. I want to create a learerboard of "most earned points", where I want to get the total earned points and the username. How can I do this in SQL?</p>
  
  <p>Example:<br>
  Table:  </p>
  
  <pre><code>id | uid | username | amount
  ------------------------------
  1  | 1   | user1    | 5
  2  | 1   | user1    | 1
  3  | 2   | user2    | 3
  4  | 1   | user1    | 4
  5  | 2   | user2    | 10
  </code></pre>
  
  <p>When using the SQL, it should give as result:</p>
  
  <pre><code>user2 | 13
  user1 | 10
  </code></pre>
  
  <p>But then this with a table with 1500 rows, getting the top 50. I don't even know if this is possible, I hope it is.</p>
  
  <p>Thanks for reading/helping!</p>