LeetCode(数据库)- 即时食物配送 II
Posted 程序员牧码
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LeetCode(数据库)- 即时食物配送 II相关的知识,希望对你有一定的参考价值。
题目链接:点击打开链接
题目大意:略。
解题思路:略。
AC 代码
-- 解决方案(1)
SELECT ROUND(COUNT(1) / (SELECT COUNT(DISTINCT customer_id) FROM Delivery) * 100, 2) immediate_percentage
FROM Delivery
WHERE order_date = customer_pref_delivery_date AND (customer_id, order_date) IN (SELECT customer_id, MIN(order_date) order_date FROM Delivery GROUP BY customer_id)
-- 解决方案(2)
select round (
sum(order_date = customer_pref_delivery_date) * 100 /
count(*),
2
) as immediate_percentage
from Delivery
where (customer_id, order_date) in (
select customer_id, min(order_date)
from delivery
group by customer_id
)
以上是关于LeetCode(数据库)- 即时食物配送 II的主要内容,如果未能解决你的问题,请参考以下文章
每日SQL打卡DAY 18丨即时食物配送 II难度中等