티스토리 뷰
1️⃣ 지역별 주문의 특징
Q1. https://solvesql.com/problems/characteristics-of-orders/
solvesql
© Copyright 2021-2022 solvesql.com
solvesql.com
select Region
, sum(case when category = 'Furniture' then orders end) as Furniture
, sum(case when category = 'Office Supplies' then orders end) as 'Office Supplies'
, sum(case when category = 'Technology' then orders end) as Technology
FROM
(select region AS 'Region', category, count(distinct order_id) orders
from records
group by region, category
) as commerce
group by Region
order by Region;
2️⃣ 할부는 몇 개월로 해드릴까요
Q2. https://solvesql.com/problems/installment-month/
solvesql
© Copyright 2021-2022 solvesql.com
solvesql.com
SELECT payment_installments as '할부 개월수'
, count(distinct order_id) as order_count
, min(payment_value) as min_value
, max(payment_value) as max_value
, avg(payment_value) as avg_value
FROM olist_order_payments_dataset
WHERE payment_type = 'credit_card'
GROUP BY payment_installments
//payment_type 생각을 못함.
3️⃣ 우유와 요거트가 담긴 장바구니
Q3. https://programmers.co.kr/learn/courses/30/lessons/62284
Rank Scores - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
-- INNER JOIN 사용
WITH milk AS(
SELECT cart_id, name
FROM cart_products
WHERE name = 'Milk'
), yogurt AS(
SELECT cart_id, name
FROM cart_products
WHERE name = 'Yogurt'
)
SELECT m.cart_id
FROM milk m INNER JOIN yogurt y ON m.cart_id = y.cart_id;
-- HAVING 사용
SELECT cart_id
FROM cart_products
WHERE name IN ('milk', 'yogurt')
GROUP BY cart_id
HAVING COUNT(DISTINCT name) > 1
4️⃣ 동명 동물 수 찾기
Q4. https://leetcode.com/problems/department-highest-salary/
Department Highest Salary - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
SELECT w2.id
FROM Weather w1
INNER JOIN weather w2 ON DATEDIFF(w1.recordDate, w2.recordDate) = -1
WHERE w2.temperature > w1.temperature
5️⃣ Rising Temperature
Q5. https://leetcode.com/problems/rising-temperature/
Rising Temperature - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
SELECT w2.id
FROM Weather w1
INNER JOIN weather w2 ON DATEDIFF(w1.recordDate, w2.recordDate) = -1
WHERE w2.temperature > w1.temperature
'Data Analystics > SQL' 카테고리의 다른 글
주간 SQL Study 6차시 (SolveSQL, Leetcode 문제풀이) (0) | 2022.03.19 |
---|---|
주간 SQL Study 5차시 (SolveSQL, programmers 문제풀이) (0) | 2022.03.16 |
주간 SQL Study 3차시 (SolveSQL, LeetCode 문제풀이) (0) | 2022.03.09 |
주간 SQL Study 2차시 (SolveSQL, Programmers 문제풀이) (0) | 2022.03.05 |
주간 SQL Study 1차시 (SolveSQL, 해커랭크 문제풀이) (0) | 2022.03.01 |
- Total
- Today
- Yesterday
- 농넷
- 비즈니스특강
- 프로그래머스
- 데이터농장팀
- 1기
- SQL Cheet Sheet
- Tableau
- 사이드프로젝트
- SolveSQL
- 222문222답
- 피터 드러커
- 지표설정
- 메스프레소
- subqeury
- 힙데비
- 개소리엔냥소리로
- Sqlstudy
- SQL Study
- 비저블
- 최고의 질문
- 삶이 던지는 질문은 언제나 같다
- leetcode
- 이단자
- 비즈니스케이스스터디
- 데이터분석
- 비즈니스케이스분석
- 비즈니스케이스
- Vizable
- SQL
- 멤버십분석
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |