Review: Simple SELECT Queries Flashcards

(5 cards)

1
Q

List all the Canadian cities and their populations

A

SELECT city, population FROM north_american_cities
WHERE country = “Canada”;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Order all the cities in the United States by their latitude from north to south

A

SELECT city, latitude FROM north_american_cities
WHERE country = “United States”
ORDER BY latitude DESC;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

List all the cities west of Chicago, ordered from west to east

A

SELECT city, longitude FROM north_american_cities
WHERE longitude < -87.629798
ORDER BY longitude ASC;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

List the two largest cities in Mexico (by population)

A

SELECT city, population FROM north_american_cities
WHERE country LIKE “Mexico”
ORDER BY population DESC
LIMIT 2;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

List the third and fourth largest cities (by population) in the United States and their population

A

SELECT city, population FROM north_american_cities
WHERE country LIKE “United States”
ORDER BY population DESC
LIMIT 2 OFFSET 2;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly