LeetCode 1173.即时食物配送

数据准备

sql 复制代码
drop table Delivery;

Create table If Not Exists Delivery (delivery_id int, customer_id int, order_date date, customer_pref_delivery_date date);
Truncate table Delivery;
insert into Delivery (delivery_id, customer_id, order_date, customer_pref_delivery_date) values ('1', '1', '2019-08-01', '2019-08-02');
insert into Delivery (delivery_id, customer_id, order_date, customer_pref_delivery_date) values ('2', '5', '2019-08-02', '2019-08-02');
insert into Delivery (delivery_id, customer_id, order_date, customer_pref_delivery_date) values ('3', '1', '2019-08-11', '2019-08-11');
insert into Delivery (delivery_id, customer_id, order_date, customer_pref_delivery_date) values ('4', '3', '2019-08-24', '2019-08-26');
insert into Delivery (delivery_id, customer_id, order_date, customer_pref_delivery_date) values ('5', '4', '2019-08-21', '2019-08-22');
insert into Delivery (delivery_id, customer_id, order_date, customer_pref_delivery_date) values ('6', '2', '2019-08-11', '2019-08-13');

需求

写一条 SQL查询语句获取即时订单所占的百分比,保留两位小数。

输入

输出

sql 复制代码
select round(count(if(order_date=customer_pref_delivery_date,1,null))/count(1)*100,2) as immediate_percentage
from Delivery;
相关推荐
大布布将军31 分钟前
⚡️ 深入数据之海:SQL 基础与 ORM 的应用
前端·数据库·经验分享·sql·程序人生·面试·改行学it
sakoba35 分钟前
flink消费pulsar
大数据·flink·pulsar
唐人街都是苦瓜脸38 分钟前
踩坑记:ORA-01722 无效数字错误排查与解决(附实战案例)
sql·oracle
JIngJaneIL1 小时前
基于java+ vue农产投入线上管理系统(源码+数据库+文档)
java·开发语言·前端·数据库·vue.js·spring boot
LYFlied1 小时前
【每日算法】LeetCode 153. 寻找旋转排序数组中的最小值
数据结构·算法·leetcode·面试·职场和发展
源代码•宸2 小时前
goframe框架签到系统项目(BITFIELD 命令详解、Redis Key 设计、goframe 框架教程、安装MySQL)
开发语言·数据库·经验分享·redis·后端·mysql·golang
川贝枇杷膏cbppg2 小时前
Redis 的 AOF
java·数据库·redis
TG:@yunlaoda360 云老大2 小时前
如何在华为云国际站代理商控制台进行SFS Turbo的性能与容量核查?
服务器·网络·数据库·华为云
ytttr8732 小时前
MATLAB基于LDA的人脸识别算法实现(ORL数据库)
数据库·算法·matlab
云老大TG:@yunlaoda3603 小时前
如何进行华为云国际站代理商跨Region适配?
大数据·数据库·华为云·负载均衡