본문 바로가기

언어 & 라이브러리/SQL10

[SQL] 프로그래머스 SQL 고득점 KIT 문제 풀이 정답 -2 JOIN 풀이 없어진 기록 찾기 -- 코드를 입력하세요 SELECT outs.ANIMAL_ID, outs.NAME from ANIMAL_OUTS as outs left join ANIMAL_INS as ins on outs.ANIMAL_ID=ins.ANIMAL_ID where ins.ANIMAL_ID is null order by outs.ANIMAL_ID 있었는데요 없었습니다 SELECT ins.ANIMAL_ID, ins.NAME FROM ANIMAL_INS as ins JOIN ANIMAL_OUTS as outs ON ins.ANIMAL_ID = outs.ANIMAL_ID WHERE ins.DATETIME > outs.DATETIME ORDER BY ins.DATETIME 오랜 기간 보호한 동물 1 .. 2022. 4. 2.
[SQL] 프로그래머스 SQL 고득점 KIT 문제 풀이 정답 -1 SELECT 모든 레코드 조회하기 SELECT * FROM ANIMAL_INS 역순 정렬하기 SELECT NAME, DATETIME FROM ANIMAL_INS ORDER BY ANIMAL_ID DESC 아픈 동물 찾기 SELECT ANIMAL_ID, NAME FROM ANIMAL_INS WHERE INTAKE_CONDITION = "Sick" 어린 동물 찾기 SELECT ANIMAL_ID, NAME FROM ANIMAL_INS WHERE NOT INTAKE_CONDITION = "Aged" 동물의 아이디와 이름 SELECT ANIMAL_ID, NAME FROM ANIMAL_INS 여러 기준으로 정렬하기 SELECT ANIMAL_ID, NAME, DATETIME FROM ANIMAL_INS ORDER B.. 2022. 3. 30.
SQLZOO The JOIN operation 문제 풀이 1. Modify it to show the matchid and player name for all goals scored by Germany. To identify German players, check for: teamid = 'GER SELECT matchid,player FROM game join goal on matchid=id WHERE teamid='GER' 2. Notice in the that the column matchid in the goal table corresponds to the id column in the game table. We can look up information about game 1012 by finding that row in the game table .. 2022. 1. 19.
해커랭크 HackerRank New Companies Advanced Select 문제 설명 Given the table schemas below, write a query to print the company_code, founder name, total number of lead managers, total number of senior managers, total number of managers, and total number of employees. Order your output by ascending company_code. Note: The tables may contain duplicate records. The company_code is string, so the sorting should not be numeric. For example, if the compan.. 2022. 1. 19.
해커랭크 HackerRank Binary Tree Nodes Advanced Select 문제 Write a query to find the node type of Binary Tree ordered by the value of the node. Output one of the following for each node: Root: If node is root node. Leaf: If node is leaf node. Inner: If node is neither root nor leaf node. Sample Output 1 Leaf 2 Inner 3 Leaf 5 Root 6 Leaf 8 Inner 9 Leaf 문제 풀이 노드 상태에 따라 출력되는 값이 달라져야 하기 때문에 case문을 적용 시킨다. order by로 N의 오름차순에 따라 값을 정렬하고 nodeType을 결정하는 것은 부.. 2022. 1. 19.
해커랭크 HackerRank The PADS Advanced Select The PADS Query an alphabetically ordered list of all names in OCCUPATIONS, immediately followed by the first letter of each profession as a parenthetical (i.e.: enclosed in parentheses). Query the number of ocurrences of each occupation in OCCUPATIONS. Sort the occurrences in ascending order, and output them in the following format: where [occupation_count] is the number of occurrences of an occ.. 2022. 1. 19.
SQLZOO SELECT BASIC 문제 풀이 2. name,population을 보여주고 Sweden,Norway,Denmark를 선택한다. SELECT name, population FROM world WHERE name IN ('Sweden', 'Norway', 'Denmark'); 3. 200000과 250000 area를 구하라 SELECT name, area FROM world WHERE area BETWEEN 200000 AND 250000 4. Show the name and population in millions for the countries of the continent 'South America'. Divide the population by 1000000 to get population in millions. select n.. 2022. 1. 19.
해커랭크 HackerRank The Report Basic Join The Report Students 테이블은 ID, NAME, MARKS / Grades 테이블은 Grade, Min_Mark, Max_Mark가 있다. Students의 Marks를 통해 Grade 테이블의 점수 범위대로 Grade를 구해야 한다. 또한 Grade가 8 미만인 학생은 이름이 아닌 NULL을 출력해야 한다. 정렬은 1. Grade 내림차순, 2. 이름 오름차순이다. SELECT IF(GRADE < 8, NULL, NAME), GRADE, MARKS FROM STUDENTS JOIN GRADES WHERE MARKS BETWEEN MIN_MARK AND MAX_MARK ORDER BY GRADE DESC, NAME 2022. 1. 19.
해커랭크 HackerRank Type of Triangle Advanced Select Type of Triangle - CASE END를 활용해야 합니다. Write a query identifying the type of each record in the TRIANGLES table using its three side lengths. Equilateral: It's a triangle with 3 sides of equal length. Isosceles: It's a triangle with 2 sides of equal length. Scalene: It's a triangle with 3 sides of differing lengths. Not A Triangle: The given values of A, B, and C don't form a triangle SELECT CAS.. 2022. 1. 19.
해커랭크 Hackerrank SQL BASIC Select 문제풀이 MYSQL 기준 풀이입니다.!! Revising the Select Query I - City 테이블에서 countrycode가 USA이며 population이 100000 초과인 컬럼을 호출하라는 문제입니다. SELECT * FROM CITY WHERE countrycode = "USA" AND population > 100000; Revising the Select Query 2 - 같은 맥락의 문제로 생략하겠습니다. Select By ID - id가 1661인 컬럼을 찾으라는 문제입니다. SELECT * FROM CITY WHERE id=1661 Weather Observation Station 4 - 전체 city의 개수와 중복이 제거된 city의 개수를 빼라는 문제입니다. SELECT COUNT.. 2022. 1. 19.