Skip to content

Commit 365bc4d

Browse files
committed
Upload 115
1 parent f911a76 commit 365bc4d

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ To make the daily tasks of creating a new file and updating the index easier, th
143143
| 112 | [Percentage of Users Attended a Contest](https://leetcode.com/problems/percentage-of-users-attended-a-contest/description/) | [Solution](solutions/112_percentage_of_users_attended_a_contest.md) | LeetCode | Easy | |
144144
| 113 | [Queries Quality and Percentage](https://leetcode.com/problems/queries-quality-and-percentage/description/) | [Solution](solutions/113_queries_quality_and_percentage.md) | LeetCode | Easy | |
145145
| 114 | [Monthly Transactions I](https://leetcode.com/problems/monthly-transactions-i/description/) | [Solution](solutions/114_monthly_transactions_i.md) | LeetCode | Medium | |
146+
| 115 | [Immediate Food Delivery II](https://leetcode.com/problems/immediate-food-delivery-ii/description/) | [Solution](solutions/115_immediate_food_delivery_ii.md) | LeetCode | Medium | |
146147

147148
## Author(s)
148149

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# SQL Everyday \#115
2+
3+
## Immediate Food Delivery II
4+
5+
Site: LeetCode\
6+
Difficulty per Site: Medium
7+
8+
## Problem
9+
10+
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*.
11+
12+
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.
13+
14+
Write a solution to find the percentage of immediate orders in the first orders of all customers, *rounded to 2 decimal places*. [[Full Description](https://leetcode.com/problems/immediate-food-delivery-ii/description/)]
15+
16+
## Submitted Solution
17+
18+
```sql
19+
-- Submitted Solution
20+
SELECT
21+
ROUND(SUM(IF(order_date = customer_pref_delivery_date, 1, 0)) / COUNT(*) * 100, 2) as immediate_percentage
22+
FROM Delivery
23+
WHERE (customer_id, order_date) IN
24+
(
25+
SELECT
26+
customer_id
27+
,min(order_date)
28+
FROM Delivery
29+
GROUP BY customer_id
30+
)
31+
;
32+
```
33+
34+
## Site Solution
35+
36+
```sql
37+
-- LeetCode Solution
38+
-- None provided
39+
```
40+
41+
## Notes
42+
43+
TODO
44+
45+
Go to [Table of Contents](/README.md#contents)\
46+
Go to [Overview](/README.md)

0 commit comments

Comments
 (0)