CODING TEST/SQL : HackerRank
[MySQL] Weather Observation Station 4
주 녕
2021. 3. 31. 14:46
반응형
▶ 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은 세지 않음
반응형