Database
해커랭크 SQL문제_0717
starlikedh
2021. 7. 17. 17:53
Weather Observation Station4
문제: Find the difference between the total number of CITY entries in the table and the number of distinct CITY entries in the table. Where LAT_N is the northern latitude and LONG_W is the western longitude.
For example, if there are three records in the table with CITY values 'New York', 'New York', 'Bengalaru',
there are 2 different city names: 'New York' and 'Bengalaru'. The query returns 1.
풀이: 예제를 통해 무슨 문제인지 유추할 수 있었다. 도시명의 종류를 구하는 문제라고 보면 될 것 같다.
CITY 카운트해서 전체 컬럼 수를 구하고 중복 제거해서 CITY 카운트 한 후 차이를 구하면 끝.
SELECT COUNT(CITY) - COUNT(DISTINCT CITY) FROM STATION; |