title: How can I query to find max population of country from countries table?
body: <p>I have a table "countries" with <code>columns -&gt; name,continent,area,popualtion.</code>
  Let's say I want to find the <code>name</code> and <code>population</code> of the chosen <code>country</code> with the highest population. </p>
  
  <pre><code>SELECT MAX(population) FROM countries; 
  </code></pre>
  
  <p>The example above returns the maximum population.
  I want it to also see the name of the country with that population.</p>
  
  <pre><code>SELECT name,MAX(population) FROM countries;
  </code></pre>
  
  <p>I am getting the error like below.</p>
  
  <blockquote>
    <p>ERROR:  column "countries.name" must appear in the GROUP BY clause or be used in an aggregate function</p>
  </blockquote>
  
  <p>I can't think of another way to do it.
  Here is an example of my query.</p>
  
  <pre><code>SELECT name,population
  FROM countries
  WHERE population &gt;= (
  SELECT MAX(population) 
  FROM countries)
  ;
  </code></pre>
  
  <p>This query works, but I am also curious why am I getting the error or if anyone knows if there is any better ways to accomplish this?</p>