DEV Community

Nw3965
Nw3965

Posted on

Big Countries

LeetCode

1st try.
SELECT area >= 3000000 and population >= 25000000 from World table

2nd try with AI.

SELECT*
FROM World
WHERE area >= 3000000 and population >= 25000000;
Enter fullscreen mode Exit fullscreen mode

It shows unnecessarily column so I had to edit query again.

Message From ChatGPT as follows.

To find the name, population, and area of countries that meet the specified criteria (area at least 3 million km² or population at least 25 million), you can use the following SQL query:

SELECT name, population, area
FROM World
WHERE area >= 3000000 OR population >= 25000000;
Enter fullscreen mode Exit fullscreen mode

This query selects the "name," "population," and "area" columns from the "World" table where the country has an area of at least 3 million km² or a population of at least 25 million. The result will include countries that meet either of these conditions.
Make sure to run this query in your SQL database to get the desired result.

I realized that it can be reduced by notating the columns to be displayed as follows
SELECT name, population, area

Top comments (0)