title: select max sum of user from table, as user with maximum amount?
body: <p>I have a table as</p>
  <pre><code>create table mock_sales
  (
      first_name character varying,
      last_name character varying,
      amount integer
  );
  
  insert into mock_sales(first_name, last_name, amount) 
  values('ted','mosby', 100),
  ('lily', 'aldrin', 400),
  ('ted', 'mosby', 350),
  ('barney', 'Stinson',180)
  </code></pre>
  <p><strong>Output Desired</strong></p>
  <p>Person with max sum amount</p>
  <p><em><strong>ted mosby</strong></em> // As ted mosby sum  = 450 (100 + 350), which is largest</p>
  <p><strong>I tried</strong></p>
  <pre><code>Select first_name, last_name from mock_sales group by first_name, last_name where amount in (
  select max(amount) from t
  (select sum(amount) as amount from mock_sales as t group by first_name, last_name)
  
  or 
  
  select t.first_name, t.last_name from mock_sales where max(amount) == t.amount and t.amount in (
  Select first-name, last_name, sum(amount) as amount from mock_sales as t group by first_name, last_name)
  </code></pre>
  <p>But they both gave syntax errors. Any help will be appreciated.</p>
  <p>Having trouble joining the result of 2 queries.</p>