BananMoon / SQL-Practice

It is Study Place to practice SQL.
0 stars 0 forks source link

집계 함수 + HackerRank문제풀이 #1

Open BananMoon opened 4 months ago

BananMoon commented 4 months ago

집계 함수

관련 HacerRank 문제

  1. Revising Aggregations - Averages
  2. Revising Aggregations - The Sum Function
  3. Revising Aggregations - The Count Function
  4. Average Population
BananMoon commented 4 months ago

1) Revising Aggregations - Averages

MySQL / Oracle

select avg(population)
from city
where district = 'California';
BananMoon commented 4 months ago

2) Revising Aggregations - The Sum Function

MySQL / Oracle

select sum(population)
from city
where district = 'California';
BananMoon commented 4 months ago

3) Revising Aggregations - The Count Function

MySQL / Oracle

select count(id)
from city
where population > 100000;
BananMoon commented 4 months ago

4) Average Population

MySQL

select round(avg(population))
from city
BananMoon commented 4 months ago

5) Population Density Difference

MySQL

select max(population) -  min(population)
from city;
BananMoon commented 4 months ago

6) Weather Observation Station 4

MySQL

select count(*) - count(distinct city)
from STATION