cocorig / codingtest Goto Github PK
View Code? Open in Web Editor NEW⚙️ Coding Test Problem Solving Repository
⚙️ Coding Test Problem Solving Repository
SELECT
AO.ANIMAL_ID,
AO.NAME
FROM
ANIMAL_OUTS AO -- 기준
LEFT JOIN
ANIMAL_INS AI ON AO.ANIMAL_ID = AI.ANIMAL_ID
WHERE
AI.ANIMAL_ID IS NULL
SELECT
A.MEMBER_NAME,
B.REVIEW_TEXT,
DATE_FORMAT(B.REVIEW_DATE, "%Y-%m-%d") AS REVIEW_DATE
FROM
MEMBER_PROFILE A
JOIN
REST_REVIEW B ON A.MEMBER_ID = B.MEMBER_ID
WHERE
A.MEMBER_ID = (
SELECT MEMBER_ID
FROM REST_REVIEW
GROUP BY MEMBER_ID
ORDER BY COUNT(*) DESC
LIMIT 1
)
ORDER BY
REVIEW_DATE ASC,
REVIEW_TEXT ASC;
%Y | 연도, 숫자, 4자리 |
---|---|
%m | 월, 숫자( 00.. 12) |
%d | 날짜, 숫자( 00.. 31) |
REST_INFO 테이블에서 음식종류별로 즐겨찾기수가 가장 많은 식당의 음식 종류, ID, 식당 이름, 즐겨찾기수를 조회하는 SQL문을 작성해주세요. 이때 결과는 음식 종류를 기준으로 내림차순 정렬해주세요
SELECT FOOD_TYPE, REST_ID, REST_NAME, FAVORITES,
ROW_NUMBER() OVER(PARTITION BY FOOD_TYPE ORDER BY FAVORITES DESC) as rn
FROM REST_INFO
SELECT FOOD_TYPE, REST_ID, REST_NAME, FAVORITES
FROM (
SELECT FOOD_TYPE, REST_ID, REST_NAME, FAVORITES,
ROW_NUMBER() OVER(PARTITION BY FOOD_TYPE ORDER BY FAVORITES DESC) as rn
FROM REST_INFO
) ranked -- 내부쿼리의 결과를 담은 임시 테이블 이름
WHERE rn = 1
ORDER BY FOOD_TYPE DESC;
ROW_NUMBER() OVER(PARTITION BY [그룹핑할 컬럼] ORDER BY [정렬할 컬럼])
- PARTITION BY는 선택, ORDER BY는 필수
RANK() : 1등이 두명이면, 그 다음 순위는 3등이 된다.
DENSE_RANK() : 1등이 두명이면 그 다음 순위는 2등이 된다.
ROW_NUMBER() 함수는 행에 번호를 부여
OVER() 함수 내부에 PARTITION BY FOOD_TYPE 구문은 데이터를 FOOD_TYPE 컬럼을 기준으로 그룹화한다.
즉, 같은 음식 종류를 가진 데이터끼리 묶어 출력한다.
ORDER BY FAVORITES DESC는 각 그룹 내에서 FAVORITES 컬럼을 내림차순으로 정렬한다.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.