반응형
▶ SQL > Basic Select > Weather Observation Station 4
Problem
Find the difference between the total number of CITY entries in the table and the number of distinct CITY entries in the table. The STATION table is described as follows:
> 표에 있는 총 CITY 항목 수와 표에 있는 고유 CITY 항목 수의 차이를 구하라.
My Answer
SELECT COUNT(CITY) - COUNT(DISTINCT(CITY))
FROM STATION
NOTE
*집계함수 COUNT : 행 개수 구하기
SELECT COUNT(열1), COUNT(열2) FROM 테이블 명→ 별도로 개수를 셈, NULL은 세지 않음
반응형
'CODING TEST > SQL : HackerRank' 카테고리의 다른 글
[MySQL] Weather Observation Station 8 (0) | 2021.04.03 |
---|---|
[MySQL] Weather Observation Station 7 (0) | 2021.04.02 |
[MySQL] Weather Observation Station 6 (0) | 2021.04.01 |
[MySQL] Weather Observation Station 5 (0) | 2021.03.31 |
[MySQL] Weather Observation Station 3 (0) | 2021.03.30 |
[MySQL] Weather Observation Station 1 (0) | 2021.03.30 |
[MySQL] Japanese Cities' Names (0) | 2021.03.29 |
[MySQL] Japanese Cities Attributes (0) | 2021.03.29 |
댓글