Big Countries

Write an SQL query to report the name, population, and area of the big countries.

Return the result table in any order.

A country is big if:

·       it has an area of at least three million (i.e., 3000000 km2), or

·       it has a population of at least twenty-five million (i.e., 25000000).


table name: World

Solution:

Select name,population,area from World where area >= 300000 and population >=25000000

Output:

SQL Script:

CREATE TABLE [dbo].[World](
       [name][varchar](50) NOT NULL,
       [continent][varchar](50) NULL,
       [area][int] NULL,
       [population][int] NULL,
       [gdp][bigint] NULL,
 CONSTRAINT [PK_World] PRIMARY KEY CLUSTERED
(
       [name] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
INSERT [dbo].[World] ([name], [continent], [area], [population], [gdp]) VALUES (N'Afghanistan', N'Asia', 652230, 25500100, 20343000000)
GO
INSERT [dbo].[World] ([name], [continent], [area], [population], [gdp]) VALUES (N'Albania', N'Europe', 28748, 2831741, 12960000000)
GO
INSERT [dbo].[World] ([name], [continent], [area], [population], [gdp]) VALUES (N'Algeria', N'Africa', 2381741, 37100000, 188681000000)
GO
INSERT [dbo].[World] ([name], [continent], [area], [population], [gdp]) VALUES (N'Andorra', N'Europe', 468, 7811, 3712000000)
GO
INSERT [dbo].[World] ([name], [continent], [area], [population], [gdp]) VALUES (N'Angola', N'Africa', 1246700, 20609294, 100990000000)
GO


Comments (0)