Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1090795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:25:30+00:00 2026-05-16T23:25:30+00:00

Help me understand this: In the sqlzoo tutorial for question 3a (Find the largest

  • 0

Help me understand this: In the sqlzoo tutorial for question 3a (“Find the largest country in each region”), why does attaching ‘AND population > 0’ to the nested SELECT statement make this correct?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T23:25:31+00:00Added an answer on May 16, 2026 at 11:25 pm

    The reason is because the:

    AND population > 0
    

    …is filtering out the null row for the region “Europe”, name “Vatican”, which complicates the:

    WHERE population >= ALL (SELECT population 
                               FROM ...)
    

    …because NULL isn’t a value, so Russia won’t be ranked properly. The ALL operator requires that the value you were comparing to be greater or equal to ALL the values returned from the subquery, which can never happen when there’s a NULL in there.

    My query would’ve been either:

    SELECT region, name, population 
      FROM bbc x
     WHERE population = (SELECT MAX(population)
                           FROM bbc y
                          WHERE y.region = x.region)
    

    …or, using a JOIN:

    SELECT x.region, x.name, x.population 
      FROM bbc x 
      JOIN (SELECT y.region, 
                   MAX(y.population) AS max_pop
              FROM bbc y 
          GROUP BY y.region) z ON z.region = x.region 
                              AND z.max_pop = x.population
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created an ExpandableListView with the help of this tutorial: link . I understand
Can someone help me understand this line of jquery code?: $(this).find('input[type=submit]:not(.cancel), button').click(function () I'm
Please help me understand this recursive function... var stack = Array; function power(base, exponent){
I'm a noob; please help me understand this authentication config / bindings stuff that
Can someone help me understand how to write this case statement properly its not
Can you help me understand how I should debug this errors? What information would
can anybody help me understand how Honda achieved this effect: http://testdays.hondamoto.ch/ I mean the
Could someone help me understand the primitive accessors with this example : i don't
Please help me. I can't understand why this function, that uses texture memory __global__
To help me better understand lambda I wrote this short snippet that rotates and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.