목록Data/SQL (27)
짜리몽땅 매거진

문제1. 레스토랑의 일일 매출출처 : solvesql 연습문제문제 정보 : 난이도 2 / 정답률 69.23%https://solvesql.com/problems/daily-revenue/ https://solvesql.com/problems/daily-revenue/ solvesql.com 정답 쿼리select day, sum(total_bill) as revenue_dailyfrom tipsgroup by dayhaving revenue_daily >=1000order by revenue_daily desc 문제 해설문제2. 쇼핑몰의 일일 매출액과 ARPPU출처 : solvesql 데이터리안 sql캠프 입문반문제 정보 : 난이도 3 / 정답률 37.09%https://solvesql.com/prob..

문제1. 우리 플랫폼에 정착한 판매자 2 출처 : solvesql 연습문제 문제 정보 : 난이도 2 / 정답률 28.17% https://solvesql.com/problems/settled-sellers-2/ https://solvesql.com/problems/settled-sellers-2/ solvesql.com 정답 쿼리 select seller_id, count(distinct order_id) as orders from olist_order_items_dataset where price >= 50 group by seller_id having orders >=100 order by orders desc 문제 해설 1. 주요 포인트 1 - 조건에 대하여 where절과 having절의 차이 wh..

문제1. 쇼핑몰의 일일 매출액 출처 : solvesql 연습문제 문제 정보 : 난이도 2 / 정답률 55.27% https://solvesql.com/problems/olist-daily-revenue/ 정답 쿼리 select strftime('%Y-%m-%d', order_purchase_timestamp) as dt, round(sum(payment_value),2) as revenue_daily from olist_orders_dataset a join olist_order_payments_dataset b on a.order_id = b.order_id where dt >= '2018-01-01' group by dt order by dt 문제 해설 1. 주요 포인트 1 - select 절 sel..

문제1. 레스토랑의 대목 출처 : solvesql 데이터리안 sql 캠프 실전반 문제 정보 : 난이도 2 / 정답률 61.07% https://solvesql.com/problems/high-season-of-restaurant/ 정답 쿼리 select * from tips where day in (select day from tips group by day having sum(total_bill)>1500) 문제 해설 1. 주요 포인트 1 - where절 서브쿼리 where day in (select day from tips group by day having sum(total_bill)>1500) insert절의 스칼라 서브쿼리, from절의 인라인뷰, where절의 일반 서브쿼리로 분류되는 서브쿼리..

문제1. 레스토랑 웨이터의 팁 분석출처 : solvesql 연습문제문제 정보 : 난이도 2 / 정답률 44.53%https://solvesql.com/problems/tip-analysis/ 정답 쿼리select day, time, round(avg(tip),2)as avg_tip, round(avg(size),2)as avg_sizefrom tipsgroup by day, timeorder by day, time 문제 해설1. 주요 포인트 1 - round, avgselect day, time, round(avg(tip),2)as avg_tip, round(avg(size),2)as avg_size 팁과 일행 수의 경우 날짜와 시간대에 따라 평균값으로 집계 후 소수 둘째 자리까지만 표현해야하므로 ro..

문제1. 멘토링 짝꿍 리스트 출처 : solvesql 연습문제 문제 정보 : 난이도 3 / 정답률 40.68% https://solvesql.com/problems/mentor-mentee-list/ 정답 쿼리 SELECT a.employee_id AS mentee_id, a.name AS mentee_name, b.employee_id AS mentor_id, b.name AS mentor_name FROM employees a cross join employees b WHERE a.join_date BETWEEN '2021-10-01' and '2021-12-31' AND b.join_date = o.order_delivered_customer_date THEN o.order_id END) AS su..

문제1. 모든 데이터 조회하기 출처 : solvesql 데이터리안 sql캠프 입문반 문제 정보 : 난이도 1 / 정답률 98.61% https://solvesql.com/problems/select-all/ 정답 쿼리 select * from points 문제 해설 아주아주 기초 of 기초 문제 문제2. 복수 국적 메달 수상한 선수 찾기 출처 : solvesql 연습문제 문제 정보 : 난이도 3 / 정답률 29% https://solvesql.com/problems/multiple-medalist/ 정답 쿼리 select name from athletes a join records r on a.id = r.athlete_id join games g on r.game_id = g.id where g.yea..

문제1. Managers with at Least 5 Direct Reports 출처 : Leetcode - Medium https://leetcode.com/problems/managers-with-at-least-5-direct-reports/description/?envType=study-plan-v2&envId=top-sql-50 정답 쿼리 select name from employee where id in (select managerID from employee group by managerID having count(*)>=5) 문제 해설 1. 주요 포인트 1 - where절 서브쿼리 where id in (select managerID from employee group by managerI..