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;
相关推荐
什巳2 小时前
JAVA练习306- 翻转二叉树
java·数据结构·算法·leetcode
smj2302_796826522 小时前
解决leetcode第3989题网格中保持一致的最大列数
python·算法·leetcode
笨蛋不要掉眼泪2 小时前
MySQL架构揭秘:慢查询日志详解
数据库·mysql·架构
pulinzt3 小时前
Tableau的基础使用
数据库·numpy
糖果店的幽灵3 小时前
【langgraph 从入门到精通graphApi 篇】LangGraphAPI 方式调用 - 初识与核心概念
数据库·人工智能·langgraph
Urbano3 小时前
卫衣生产工艺科普与智能自动化设备应用解析
大数据·运维·人工智能
TlSfoward3 小时前
TLSFOWARD TLS指纹
开发语言·数据库·爬虫·搜索引擎·https·php
Geeys3 小时前
拼多多投产比(ROI)越高好还是越低好?深度拆解合理阈值与高效提效工具
大数据
️学习的小王3 小时前
MySQL 实战:从建表到索引管理的完整指南
数据库·mysql·oracle
QC777LX4 小时前
运营岗位怎么借AI提升内容、活动和复盘效率?
大数据·人工智能