Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- Gaimification
- MS SQL Server
- ProfileReport
- oracle
- 데이터분석
- 신경쓰기의 기술
- 프로그래머스
- MySQL
- pandas profiling
- Labor Management System
- ModelCheckPoint
- 웨어하우스 보관 최적화
- ABC Analysis
- Product Demand
- tensorflow
- 코딩테스트연습
- 파이썬
- forecast
- leetcode
- kaggle
- Inventory Optimization
- TensorFlowGPU
- 당신의 인생이 왜 힘들지 않아야 한다고 생각하십니까
- SKU Consolidation
- eda
- SQL
- 딥러닝
- 피그마인디언
- 코딩테스트
- HackerRank
Archives
- Today
- Total
오늘도 배운다
1174. Immediate Food Delivery II / LeetCode, SQL, MySQL 본문
코딩테스트연습(SQL)
1174. Immediate Food Delivery II / LeetCode, SQL, MySQL
LearnerToRunner 2023. 4. 11. 23:05문제
source: LeetCode
If the customer's preferred delivery date is the same as the order date, then the order is called immediate; otherwise, it is called scheduled.
The first order of a customer is the order with the earliest order date that the customer made. It is guaranteed that a customer has precisely one first order.
Write an SQL query to find the percentage of immediate orders in the first orders of all customers, rounded to 2 decimal places.
제출답안(MySQL)
SELECT
ROUND(AVG(is_imt)*100, 2) AS immediate_percentage
FROM
(SELECT
CASE WHEN order_date = customer_pref_delivery_date THEN 1 ELSE 0 END AS is_imt
FROM
delivery
WHERE
(customer_id, order_date ) IN (SELECT customer_id, MIN(order_date) AS first_order
FROM delivery
GROUP BY customer_id)) AS ords_1st
문제 바로가기(MySQL)
728x90
'코딩테스트연습(SQL)' 카테고리의 다른 글
1204. Last Person to Fit in the Bus / LeetCode, SQL, MS SQL Server (0) | 2023.04.15 |
---|---|
550. Game Play Analysis IV / LeetCode, SQL, MS SQL Server (0) | 2023.04.14 |
1193. Monthly Transactions I / LeetCode, SQL, MS SQL Server (0) | 2023.04.10 |
1070. Product Sales Analysis III / LeetCode, SQL, MySQL (0) | 2023.04.10 |
585. Investments in 2016 / LeetCode, SQL, MySQL (0) | 2023.04.10 |
Comments