How to extract the max of the sum of ~120k rows in postgresql?
<p>I have a database for a bike store, with a table I called
<code>"SalesOrderHeader"</code> that has, among others, these 2 columns: <code>CustomerID</code>, <code>TotalDue</code>.</p>

<p>It holds information about all sales of the bike store. So if f.e. a customer bought 2 times in total from the store, there will be 2 registries of his <code>CustomerID</code> with the amount of money (<code>TotalDue</code>) he paid each time.<br>
<img src="https://i.stack.imgur.com/DSBV8.jpg" alt="Here is a screenshot of the table in excel, just to get the idea."></p>

<p>How to write a select query that will show the 1 (or more, in case of a tie) customer that has paid the most in total. The result has to bring up 2 columns one with the <code>CustomerID</code> and one with the <code>TotalMoneyHePaid</code>.</p>