sql 코테 대비.. 전에 공부하면서 풀었던 문제 제외 1. https://www.hackerrank.com/challenges/weather-observation-station-9/problem?isFullScreen=true Weather Observation Station 9 | HackerRank Query an alphabetically ordered list of CITY names not starting with vowels. www.hackerrank.com Q: Query the list of CITY names from STATION that do not start with vowels. Your result cannot contain duplicates. Input Format The..
COUNT 개수를 세어줌 SELECT COUNT(* 또는 칼럼명) FROM 테이블명 Products ProductID ProductName SupplierID Price 1 A 1 18 2 A 2 19 3 B 3 Null 4 C 5 22 5 Null Null 5 - 전체 개수 세기 SELECT COUNT (*) FROM products >> 5 - ProductName 개수 세기, 유일값만 세기 SELECT COUNT(productname) FROM products >> 4 -- Null 값은 빼고 세줌 SELECT COUNT(DISTINCT productname) FROM products >> 3 -- Null값 빼고 중복 안되게 SUM 숫자 데이터를 가진 칼럼의 합을 계산해줌 SELECT SUM(칼럼..
1. https://www.hackerrank.com/challenges/weather-observation-station-7/problem?isFullScreen=true Weather Observation Station 7 | HackerRank Query the list of CITY names ending with vowels (a, e, i, o, u) from STATION. www.hackerrank.com Q: Query the list of CITY names ending with vowels (a, e, i, o, u) from STATION. Your result cannot contain duplicates. Input Format The STATION table is describ..
ORDER BY SELECT * 또는 칼럼명 FROM 테이블명 WHERE 조건절 ORDER BY 칼럼명 DESC - 내림차순 DESC - 오름차순 ASC(디폴트이기 때문에 쓸 일이 별로 없음) - ORDER BY는 데이터베이스에 저장된 데이터 자체의 순서를 바꾸진 않는다 Q1: products 테이블에서 가격이 20 이상인 물건들 중에 가장 비싼 것부터 정렬해라 SELECT * FROM Products WHERE price >= 20 ORDER BY price DESC Q2: products 테이블에서 가격이 가장 비싼 물건 1개만 출력해라 SELECT * FROM Products ORDER BY price DESC LIMIT 1 - 결과의 개수를 제한하는 LIMIT 활용 - '가격이 비싼 물건 상위 n..
1. https://www.hackerrank.com/challenges/revising-the-select-query-2/problem?isFullScreen=true Revising the Select Query II | HackerRank Query the city names for all American cities with populations larger than 120,000. www.hackerrank.com Q: 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 de..
1. https://www.hackerrank.com/challenges/revising-the-select-query/problem?isFullScreen=true Revising the Select Query I | HackerRank Query the data for all American cities with populations larger than 100,000. www.hackerrank.com Q: 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 f..