티스토리 뷰
1️⃣ 일별 블로그 방문자 수 집계
Q1. https://solvesql.com/problems/blog-counter/
solvesql
© Copyright 2021-2022 solvesql.com
solvesql.com
SELECT event_date_kst AS dt, count(distinct user_pseudo_id) AS users
FROM ga
WHERE event_date_kst BETWEEN '2021-08-02' AND '2021-08-09'
GROUP BY event_date_kst
-- HAVING event_date_kst>='2021-08-02' AND event_date_kst <= '2021-08-09'
ORDER BY dt ASC
2️⃣ 일일 매출액 구하기
Q2. https://solvesql.com/problems/olist-daily-revenue/
solvesql
© Copyright 2021-2022 solvesql.com
solvesql.com
SELECT event_date_kst AS dt, count(distinct user_pseudo_id) AS users
FROM ga
WHERE event_date_kst BETWEEN '2021-08-02' AND '2021-08-09'
GROUP BY event_date_kst
-- HAVING event_date_kst>='2021-08-02' AND event_date_kst <= '2021-08-09'
ORDER BY dt ASC
3️⃣ 성적 순위 구하기
Q3. https://leetcode.com/problems/rank-scores/
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
SELECT score
, dense_rank() OVER (ORDER BY score DESC) as 'rank'
FROM Scores
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 d.name as Department
, e.name as Employee
, e.salary as Salary
FROM Employee e
INNER JOIN Department d on e.departmentId = d.id
WHERE e.salary=(SELECT max(salary)
FROM Employee e1
GROUP BY departmentId
HAVING departmentId=e.departmentId);
5️⃣ 여행 취소율 구하기
Q5. https://leetcode.com/problems/trips-and-users/
solvesql
solvesql.com
SELECT d.name as Department
, e.name as Employee
, e.salary as Salary
FROM Employee e
INNER JOIN Department d on e.departmentId = d.id
WHERE e.salary=(SELECT max(salary)
FROM Employee e1
GROUP BY departmentId
HAVING departmentId=e.departmentId);
--
WITH not_banned AS(
SELECT *
FROM trips
WHERE client_id NOT IN (SELECT users_id
FROM users
WHERE banned = "Yes")
AND driver_id NOT IN (SELECT users_id
from users
WHERE banned = "Yes")
)
SELECT request_at AS DAY
, ROUND(SUM(CASE WHEN status != 'completed' THEN 1 ELSE 0 END) / COUNT(*),2) AS 'Cancellation Rate'
FROM not_banned
GROUP BY request_at
WHERE request_at BETWEEN '2013-10-01' AND '2013-10-03'
'Data Analystics > SQL' 카테고리의 다른 글
| 주간 SQL Study 5차시 (SolveSQL, programmers 문제풀이) (0) | 2022.03.16 |
|---|---|
| 주간 SQL Study 4차시 (Group by, Select, Join 문제풀이) (0) | 2022.03.13 |
| 주간 SQL Study 2차시 (SolveSQL, Programmers 문제풀이) (0) | 2022.03.05 |
| 주간 SQL Study 1차시 (SolveSQL, 해커랭크 문제풀이) (0) | 2022.03.01 |
| SQL Basic Cheat -3- ( SQL UNION, JOIN) (0) | 2022.01.24 |
- Total
- Today
- Yesterday
- 사이드프로젝트
- leetcode
- SQL Cheet Sheet
- SolveSQL
- subqeury
- Sqlstudy
- 1기
- Vizable
- 데이터분석
- Tableau
- 삶이 던지는 질문은 언제나 같다
- 비저블
- 비즈니스케이스
- 이단자
- 비즈니스케이스스터디
- SQL
- 데이터농장팀
- 생성형 ai 수요분석
- 222문222답
- 지표설정
- 피터 드러커
- 힙데비
- 메스프레소
- ChatGPT
- 농넷
- 최고의 질문
- 비즈니스케이스분석
- 비즈니스특강
- SQL Study
- 프로그래머스
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |