title: Retrieve the attributes of a row which has the maximum value for a column
body: <p>I have the following relation <code>Invoice</code>:</p>
  
  <pre><code>Invoice
  -------------------------------------
  | Id | Country | Total | CustomerId |
  -------------------------------------
  | 1  | USA     | 22.32 | 3          |
  -------------------------------------
  | 2  | Belgium | 12.18 | 4          |
  -------------------------------------
  | 3  | USA     | 27.76 | 2          |
  -------------------------------------
  | 4  | France  | 24.52 | 5          |
  -------------------------------------
  | 5  | USA     | 14.29 | 3          |
  -------------------------------------
  </code></pre>
  
  <p>I have to query the attributes <code>Id</code> and <code>Total</code> of the invoice, which has the highest value for <code>Total</code> and <code>Country</code> USA. If there are more than one invoices from USA with the same maximum value, all of them have to be returned in the result set.</p>
  
  <p>What I have so far is as follows:</p>
  
  <pre><code>SELECT
     i."Id",
     i."Total"
  FROM 
     public."Invoice" i
  WHERE
     i."Total" = (SELECT MAX(t."Total") 
                     FROM public."Invoice" t 
                     WHERE t."Country" = 'USA');
  </code></pre>
  
  <p>Is this the right way to do it? I am not sure, because I do not check in the subquery if <code>i.Id = t.Id</code>. If I do this, I get more than one row in the result. How do I make sure that the value that is returned by the subquery actually belongs to the <code>i</code>?</p>