SQL - Basic_Select_1

Gino·2022년 3월 12일
1

SQL #1 문제풀이

목록 보기
11/35

문제출처 HACKER RANK
문제의 저작권은 해커랭크에 있습니다.

해커랭크 basic select_1

-- SELECT QUERY (1)
SELECT * FROM CITY
WHERE POPULATION >= 100000
AND CountryCode = 'USA'

-- SELECT QUERY (2)
SELECT NAME FROM CITY
WHERE POPULATION >= 120000
AND COUNTRYCODE = 'USA'

-- SELECT ALL
SELECT * FROM CITY

-- SELECT BY ID
SELECT * FROM CITY 
WHERE ID = '1661'

-- Japanese Cities' Attributes
SELECT * FROM CITY 
WHERE COUNTRYCODE = 'JPN'

-- Japanese Cities' Names
SELECT NAME FROM CITY 
WHERE COUNTRYCODE = 'JPN'

-- Weather Observation Station 1
SELECT CITY, STATE FROM STATION 

-- Weather Observation Station 3
-- ID가 even number(짝수)인 데이터 조회
-- exclude duplicates (중복제거) 
SELECT DISTINCT CITY FROM STATION 
WHERE (ID % 2) = 0 

-- Weather Observation Station 4
-- 총 CITY 항목수 - 고유 CITY 항목수
-- COUNT 활용 
SELECT COUNT(CITY) - COUNT(DISTINCT CITY)
FROM STATION;
profile
나무를 심는 사람

0개의 댓글