저번 글과 마찬가지로 풀 때 썼던 메모 그대로 가져옴 1. Japan Populationhttps://www.hackerrank.com/challenges/japan-population/problem Japan Population | HackerRankQuery to the sum of the populations of all Japanese cities in CITY.www.hackerrank.com SELECT SUM(population)FROM cityWHERE countrycode = 'JPN' 2. Weather Observation Station 2https://www.hackerrank.com/challenges/weather-observation-station-2/problem Weath..
CASEpython의 if문처럼 경우에 따른 조건을 걸어줄 때 사용 기본 코드SELECT CASE WHEN 칼럼명 = '특정 값' THEN '출력할 값' WHEN 칼럼명2 = '특정 값2' THEN '출력할 값2' ELSE '출력할 값3' ENDFROM 테이블명 1. Products 테이블에서 CategoryID가 1인 데이터는 '음료', 2인 데이터는 '조미료', 나머지는 '기타'로 표시해라.SELECT CASE WHEN categoryid = 1 then '음료' WHEN categoryid = 2 then '조미료' ELSE '기타' END AS 'CategoryName..
JOIN이 필요한 이유관계형 데이터베이스 RDBMS에서 데이터를 더 효율적으로 관리하기 위함테이블을 따로 두고, 같은 값이 중복되지 않게 ex) 유저 아이디, 연락처, 배송 주소, 구매 상품, 상품 가격, 구매 개수 등이 쭉 나열되어 있음아이디연락처주소구매 상품가격개수결제 수단A010-****-1111영등포구 여의도동NULLNULLNULLNULLB010-****-2222송파구 석촌동샴푸50001국민카드B 010-****-2222 송파구 석촌동 식빵60001계좌이체B 010-****-2222 송파구 석촌동 티백80004국민카드B 010-****-2222 송파구 석촌동 냄비70001우리카드 B라는 고객은 구매 횟수가 많아서 아이디, 연락처, 주소 등이 계속 중복됨이런식으로 한 테이블에 무수히 많은 데이..
https://www.w3schools.com/sql/sql_groupby.asp Demo Database GROUP BY특정 칼럼을 기준으로 모아보고 싶을 때 사용, python에서 pandas 라이브러리를 활용하여 그룹화하는거랑 마찬가지 1. SupplierID를 기준으로 평균 가격을 출력하자SELECT supplierID , AVG(Price)FROM ProductsGROUP BY supplierID 이때, GROUPBY에 있는 칼럼명은 항상 SELECT에도 들어가 있어야함 (→ 여기서 18번 SupplierID의 평균 공급 가격이 상대적으로 높게 나오니까, 얘를 유의해서 데이터를 살펴볼 수 있음) 2. 추가로 SupplierID가 1인 사람의 CategoryID도 같이 보고 싶으면,..
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..
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..