We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Hiring developers?
  1. Prepare
  2. SQL
  3. Aggregation
  4. Population Density Difference
  5. Discussions

Population Density Difference

Problem
Submissions
Leaderboard
Discussions

Sort 301 Discussions, By:

recency

Please Login in order to post a comment

  • roshankumar350
    3 days ago+ 0 comments

    MYSQL SOLUTION Approch 1

    SELECT ABS((SELECT POPULATION FROM CITY ORDER BY POPULATION DESC LIMIT 1) - (SELECT POPULATION FROM CITY ORDER BY POPULATION ASC LIMIT 1)) FROM CITY LIMIT 1
    

    Approch 2

    SELECT (MAX(POPULATION) - MIN(POPULATION)) FROM CITY;
    
    0|
    Permalink
  • zachjames743
    4 days ago+ 0 comments

    MS SQL

    SELECT (MAX(POPULATION) - MIN(POPULATION)) AS DIFF_POP
    FROM CITY;
    

    You don't need brackets on the outside of the aggregate functions.

    0|
    Permalink
  • mayanksingh8295
    1 week ago+ 0 comments

    SELECT (MAX(POPULATION) - MIN(POPULATION)) FROM CITY;

    0|
    Permalink
  • praveen_sulgekar
    1 week ago+ 0 comments

    SELECT MAX(POPULATION) - MIN(POPULATION) FROM CITY

    0|
    Permalink
  • nhipham117
    1 week ago+ 0 comments

    MySQL

    SELECT MAX(POPULATION) - MIN(POPULATION)
    FROM CITY
    
    0|
    Permalink
Load more conversations

Need Help?


View top submissions
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy