전체 글
-
[programmers] DATETIME에서 DATE로 형 변환공부/PS ( SQL) 2022. 5. 20. 23:57
https://programmers.co.kr/learn/courses/30/lessons/59414 코딩테스트 연습 - DATETIME에서 DATE로 형 변환 ANIMAL_INS 테이블은 동물 보호소에 들어온 동물의 정보를 담은 테이블입니다. ANIMAL_INS 테이블 구조는 다음과 같으며, ANIMAL_ID, ANIMAL_TYPE, DATETIME, INTAKE_CONDITION, NAME, SEX_UPON_INTAKE는 각각 동물의 아이디 programmers.co.kr SELECT ANIMAL_ID, NAME, date_format(DATETIME, '%Y-%m-%d') AS 날짜 FROM ANIMAL_INS ORDER BY ANIMAL_ID DATETIME 형식의 데이터를 원하는 형식으로 출력할..
-
[programmers] 입양 시각 구하기(2)공부/PS ( SQL) 2022. 5. 20. 23:53
https://programmers.co.kr/learn/courses/30/lessons/59413 코딩테스트 연습 - 입양 시각 구하기(2) ANIMAL_OUTS 테이블은 동물 보호소에서 입양 보낸 동물의 정보를 담은 테이블입니다. ANIMAL_OUTS 테이블 구조는 다음과 같으며, ANIMAL_ID, ANIMAL_TYPE, DATETIME, NAME, SEX_UPON_OUTCOME는 각각 동물의 아이디, 생물 programmers.co.kr SET @HOUR := -1; SELECT @HOUR:= @HOUR + 1 AS HOUR, (SELECT COUNT(*) FROM ANIMAL_OUTS WHERE HOUR(DATETIME) = @HOUR) AS COUNT FROM ANIMAL_OUTS WHERE..
-
[programmers] 없어진 기록 찾기공부/PS ( SQL) 2022. 5. 20. 23:32
https://programmers.co.kr/learn/courses/30/lessons/59042 코딩테스트 연습 - 없어진 기록 찾기 ANIMAL_INS 테이블은 동물 보호소에 들어온 동물의 정보를 담은 테이블입니다. ANIMAL_INS 테이블 구조는 다음과 같으며, ANIMAL_ID, ANIMAL_TYPE, DATETIME, INTAKE_CONDITION, NAME, SEX_UPON_INTAKE는 각각 동물의 아이디 programmers.co.kr SELECT O.ANIMAL_ID, O.NAME FROM ANIMAL_OUTS AS O LEFT JOIN ANIMAL_INS AS I ON O.ANIMAL_ID = I.ANIMAL_ID WHERE I.ANIMAL_ID IS NULL ORDER BY O...
-
[HackerRank/Basic Join] The Report공부/PS ( SQL) 2022. 5. 19. 01:02
https://www.hackerrank.com/challenges/the-report/problem The Report | HackerRank Write a query to generate a report containing three columns: Name, Grade and Mark. www.hackerrank.com 문제 풀이 SELECT IF(G.Grade >= 8, S.Name, "NULL"), G.Grade, S.Marks FROM Students AS S INNER JOIN Grades AS G ON S.Marks >= G.Min_Mark AND S.Marks = 8, S.Name, "NULL"), G.Grade, S.Marks FROM Students AS S INNER JOIN Gra..
-
[HackerRank/Basic Join] Average Population of Each Continent공부/PS ( SQL) 2022. 5. 18. 23:11
https://www.hackerrank.com/challenges/average-population-of-each-continent/problem Average Population of Each Continent | HackerRank Query the names of all continents and their respective city populations, rounded down to the nearest integer. www.hackerrank.com 문제 풀이 SELECT COUNTRY.CONTINENT, TRUNCATE(AVG(CITY.POPULATION),0) FROM COUNTRY JOIN CITY ON CITY.COUNTRYCODE = COUNTRY.CODE GROUP BY COUN..
-
[HackerRank/Basic Join] African Cities공부/PS ( SQL) 2022. 5. 18. 21:27
https://www.hackerrank.com/challenges/african-cities/problem African Cities | HackerRank Query the names of all cities on the continent 'Africa'. www.hackerrank.com 문제 풀이 SELECT CITY.NAME FROM CITY INNER JOIN COUNTRY ON CITY.COUNTRYCODE = COUNTRY.CODE WHERE COUNTRY.CONTINENT = 'Africa'
-
[MYSQL] JOIN 참고공부/PS ( SQL) 2022. 5. 18. 21:22
https://yoo-hyeok.tistory.com/98 [MySQL] Join 깔끔한 이해와 사용법 상단의 그림 정말 정리가 잘 되어 있습니다. 처음 접할 때 보고도 저게뭔가 싶었는데 초심자의 입장에서 이해하기 쉽도록 설명해보려합니다. 1. LEFT JOIN A, B 테이블 중에 A값의 전체와, A의 KEY 값 yoo-hyeok.tistory.com https://www.w3schools.com/mysql/default.asp MySQL Tutorial W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML,..
-
[HackerRank/Basic Join] Population Census공부/PS ( SQL) 2022. 5. 18. 21:20
https://www.hackerrank.com/challenges/asian-population/problem Population Census | HackerRank Query the sum of the populations of all cities on the continent 'Asia'. www.hackerrank.com 문제 풀이 SELECT SUM(CITY.POPULATION) FROM CITY INNER JOIN COUNTRY ON CITY.COUNTRYCODE = COUNTRY.CODE WHERE COUNTRY.CONTINENT = 'Asia' INNER JOIN SELECT FROM TABLE A A INNER JOIN TABLE B B ON A.Key = B.Key WHERE