www.hackerrank.com/challenges/weather-observation-station-3/problem
Query a list of CITY names from STATION for cities that have an even ID number. Print the results in any order, but exclude duplicates from the answer.
The STATION table is described as follows:
where LAT_N is the northern latitude and LONG_W is the western longitude.'
Answer
select distinct city
from station
where (id % 2) = 0;
www.hackerrank.com/challenges/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:
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
select count(*) - count(distinct city)
from station;
'SQL & DB > HackerRank SQL Problem' 카테고리의 다른 글
[HackerRank SQL] Weather Observation Station 11, 12(MySQL) (0) | 2021.02.27 |
---|---|
[HackerRank SQL] Weather Observation Station 9, 10(MySQL) (0) | 2021.02.27 |
[HackerRank SQL] Weather Observation Station 7, 8(MySQL) (0) | 2021.02.27 |
[HackerRank SQL] Weather Observation Station 5, 6(MySQL) (0) | 2021.02.27 |
[HackerRank SQL] Weather Observation Station 1, 2 (MySQL) (0) | 2021.02.27 |