Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit447d73a

Browse files
add 1173
1 parent8975473 commit447d73a

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,7 @@ _If you like this project, please leave me a star._ ★
848848
|1280|[Students and Examinations](https://leetcode.com/problems/students-and-examinations/)|[Solution](../master/database/_1280.sql)|[:tv:](https://www.youtube.com/watch?v=ThbkV4Fs7iE)| Easy|
849849
|1251|[Average Selling Price](https://leetcode.com/problems/average-selling-price//)|[Solution](../master/database/_1251.sql)|| Easy|
850850
|1179|[Reformat Department Table](https://leetcode.com/problems/reformat-department-table/)|[Solution](../master/database/_1179.sql)|| Easy|
851+
|1173|[Immediate Food Delivery I](https://leetcode.com/problems/immediate-food-delivery-i/)|[Solution](../master/database/_1173.sql)|| Easy|
851852
|1069|[Product Sales Analysis II](https://leetcode.com/problems/product-sales-analysis-ii/)|[Solution](../master/database/_1069.sql)|| Easy|
852853
|1068|[Product Sales Analysis I](https://leetcode.com/problems/product-sales-analysis-i/)|[Solution](../master/database/_1068.sql)|| Easy|
853854
|627|[Swap Salary](https://leetcode.com/problems/swap-salary/)|[Solution](../master/database/_627.sql)|| Easy|

‎database/_1173.sql

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
--1173. Immediate Food Delivery I
2+
--
3+
--Table: Delivery
4+
--+-----------------------------+---------+
5+
--| Column Name | Type |
6+
--+-----------------------------+---------+
7+
--| delivery_id | int |
8+
--| customer_id | int |
9+
--| order_date | date |
10+
--| customer_pref_delivery_date | date |
11+
--+-----------------------------+---------+
12+
--delivery_id is the primary key of this table.
13+
--The table holds information about food delivery to customers that make orders at some date and specify a preferred delivery date (on the same order date or after it).
14+
--If the preferred delivery date of the customer is the same as the order date then the order is called immediate otherwise it's called scheduled.
15+
--
16+
--Write an SQL query to find the percentage of immediate orders in the table, rounded to 2 decimal places.
17+
--The query result format is in the following example:
18+
--Delivery table:
19+
--+-------------+-------------+------------+-----------------------------+
20+
--| delivery_id | customer_id | order_date | customer_pref_delivery_date |
21+
--+-------------+-------------+------------+-----------------------------+
22+
--| 1 | 1 | 2019-08-01 | 2019-08-02 |
23+
--| 2 | 5 | 2019-08-02 | 2019-08-02 |
24+
--| 3 | 1 | 2019-08-11 | 2019-08-11 |
25+
--| 4 | 3 | 2019-08-24 | 2019-08-26 |
26+
--| 5 | 4 | 2019-08-21 | 2019-08-22 |
27+
--| 6 | 2 | 2019-08-11 | 2019-08-13 |
28+
--+-------------+-------------+------------+-----------------------------+
29+
--
30+
--Result table:
31+
--+----------------------+
32+
--| immediate_percentage |
33+
--+----------------------+
34+
--| 33.33 |
35+
--+----------------------+
36+
--The orders with delivery id 2 and 3 are immediate while the others are scheduled.
37+
38+
39+
# Write your MySQL query statement below
40+
select round(
41+
(
42+
100* (selectcount(*)from Delivery dwhered.order_date=d.customer_pref_delivery_date)/
43+
(selectcount(*)from Delivery)
44+
),
45+
2)as immediate_percentage;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp