[HackerRank|MySQL] Revising Aggregations

히끼·2020년 8월 22일
0

HackerRank

목록 보기
12/13

Revising Aggregations - The Count Function

Problem

Query a count of the number of cities in CITY having a Population larger than 100,000.

Solution

SELECT COUNT(NAME)
FROM CITY
WHERE POPULATION > 100000

Revising Aggregations - The Sum Function

Problem

Query the total population of all cities in CITY where District is California.

Solution

SELECT SUM(POPULATION)
FROM CITY
WHERE DISTRICT = 'California'

Revising Aggregations - Averages

Problem

Query the average population of all cities in CITY where District is California.

Solution

SELECT AVG(POPULATION)
FROM CITY
WHERE DISTRICT = 'California'

0개의 댓글