몸과 마음이 건전한 SW 개발자

[HackerRank-MSSQL] 해커랭크 basic select Weather Observation Station 4 본문

SQL/MSSQL

[HackerRank-MSSQL] 해커랭크 basic select Weather Observation Station 4

스위태니 2026. 4. 17. 10:55
728x90

문제 링크

https://www.hackerrank.com/challenges/weather-observation-station-4/problem?isFullScreen=true

 

Weather Observation Station 4 | HackerRank

Find the number of duplicate CITY names in STATION.

www.hackerrank.com

정답 코드

SET NOCOUNT ON;

SELECT COUNT(CITY) - COUNT(DISTINCT CITY)
FROM STATION;
/*
Enter your query here.
Please append a semicolon ";" at the end of the query and enter your query in a single line to avoid error.
*/

go

풀이 과정

  • 도시의 숫자를 세고 중복된 도시의 수를 센 다음 빼면 끝.

느낀점

  • 아직 모르는 것이 많다.
  • select로 찾아서 distinct하고 그럴 줄 알았는데 그냥 select에서 count로 세서 뺄 줄은 몰랐다.

 

728x90