SQL
-
그룹 별 중복값이 있는지 확인하기SQL 2023. 1. 16. 10:48
points 테이블은 프란시스 앤스컴이 만든 Anscombe's quartet 데이터를 담고 있습니다. 이 데이터는 quartet 컬럼에 의해 4개의 서브셋으로 나뉘어지고, 각 서브셋은 평균, 표본 분산, 상관계수 등이 거의 동일하나 데이터의 분포를 시각화하면 전혀 다른 분포를 가지는 특징이 있습니다. 각 quartet 안에 같은 x 값이 2개 이상인 경우를 찾아, 몇 개의 값이 중복되는지 구하는 쿼리를 작성해주세요. 결과 데이터에는 아래 3개의 컬럼이 존재해야 합니다. select count(x) as cnt, x, quartet from points group by quartet, x having count(x) >= 2
-
평점 높은 영화 찾기SQL 2023. 1. 8. 13:04
최신 개봉작 중 평점이 높은 영화를 넷플릭스에서 보려고 합니다. 넷플릭스에 있는 2020년 개봉작 중, IMDb 평점이 9.0 이상이거나 로튼토마토 지수가 90 이상인 영화의 제목, 개봉연도, 시청 가능 연령, IMDb 평점, 로튼토마토 지수를 출력하는 쿼리를 작성해주세요. select title, year, age, imdb, rotten_tomatoes from movies where (year = '2020') and (netflix = '1') having (imdb >= '9.0') or (rotten_tomatoes >= '90') select로 보고자 하는 컬럼들을 정리해줄 수 있다. from으로 원하는 테이블을 불러온다. where로 year 기준과 netflix에 개봉작을 선택해준다. h..
-
HackerRank / Revising the Select Query 2SQL 2022. 12. 8. 16:38
Query the NAME field for all American cities in the CITY table with populations larger than 120000. The CountryCode for America is USA. The CITY table is described as follows: select name from city where CountryCode = 'USA' and population > 120000
-
HackerRank / Revising the Select Query 1SQL 2022. 12. 8. 16:35
Query all columns for all American cities in the CITY table with populations larger than 100000. The CountryCode for America is USA. The CITY table is described as follows: select * from city where CountryCode = 'USA' and POPULATION > 100000
-
HackerRank / Weather Observation Station 3SQL 2022. 12. 8. 16:13
Weather Observation Station 3 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. select distinct city from station where (id % 2) = 0