当前位置:网站首页>MySQL面试真题(二十六)——滴滴2020年笔试题
MySQL面试真题(二十六)——滴滴2020年笔试题
2022-06-23 03:58:00 【Socialphobia_FOGO】
打车业务分析
“订单信息表”里记录了巴西乘客使用打车软件的信息,包括订单呼叫、应答、取消、完单时间。(滴滴2020年笔试题)
字段释义:
订单id;呼叫订单识别号
乘客id:乘客识别号
呼叫时间:乘客从应用发起需要用车请求的时间(北京时间)
应答时间:司机点击接单的时间(北京时间)
取消时间:司机或乘客取消订单的时间(北京时间)
完单时间:司机点击到达目的地的时间(北京时间)
注意:
(1)表中的时间是北京时间,巴西比中国慢11小时。
(2)应答时间列的数据值如果是“1970”年(巴西时间),表示该订单没有司机应答,属于无效订单。
#1. 订单的应答率,完单率分别是多少?
select count(distinct case when year(date_sub(t1.应答时间,interval 11 hour))<>1970 then t1.订单id end)/count(t1.订单id) as 应答率,
count(distinct case when year(date_sub(t1.完单时间,interval 11 hour))<>1970 then t1.订单id end)/count(t1.订单id) as 完单率
from 订单信息表 t1;
结果如下:
#2. 呼叫应答平均时间有多长?
select avg(timestampdiff(minute,t1.呼叫时间,t1.应答时间)) as "呼叫应答平均时间(min)"
from 订单信息表 t1
where year(date_sub(t1.应答时间,interval 11 hour))<>1970;
结果如下:
#3. 从这一周的数据来看,呼叫量最高的是哪一个小时(当地时间)?呼叫量最少的是哪一个小时(当地时间)?
#(3.1)呼叫量最高:
SELECT
HOUR(
DATE_SUB(呼叫时间, INTERVAL 11 HOUR)
) AS 当地小时,
COUNT(*) AS 呼叫量
FROM
订单信息表
GROUP BY HOUR(
DATE_SUB(呼叫时间, INTERVAL 11 HOUR)
)
HAVING COUNT(*) >= ALL
(SELECT
COUNT(*) AS 呼叫量
FROM
订单信息表
GROUP BY HOUR(
DATE_SUB(呼叫时间, INTERVAL 11 HOUR)
))
#(3.2)呼叫量最低:
SELECT
HOUR(
DATE_SUB(呼叫时间, INTERVAL 11 HOUR)
) AS 当地小时,
COUNT(*) AS 呼叫量
FROM
订单信息表
GROUP BY HOUR(
DATE_SUB(呼叫时间, INTERVAL 11 HOUR)
)
HAVING COUNT(*) <= ALL
(SELECT
COUNT(*) AS 呼叫量
FROM
订单信息表
GROUP BY HOUR(
DATE_SUB(呼叫时间, INTERVAL 11 HOUR)
))
最高如下:
最低如下:
#4. 呼叫订单第二天继续呼叫的比例有多少?
select
sum(case when next_day-day=1 then 1 else 0 end)/count(*) as 次日呼叫比例
from
(select *,
lead(day)over(partition by 乘客id order by day) as next_day
from
(select t1.乘客id ,day(date_sub(t1.呼叫时间,interval 11 hour)) as day
from订单信息表 t1) t2) t3;
结果如下:
边栏推荐
- 云原生数据库是未来数据库的天下
- Introduction to JDBC (IV) - use of Druid connection pool
- Yingjixin launched 4 series of lithium batteries 100W mobile power supply voltage rise and fall scheme SOC chip ip5389
- fastjson中的@JSONField注解
- 阿里云对象存储oss+picgo+typora实现构建图床
- CF [1700d] D. River locks (DP, bisection, Mathematics)
- Is there a real part-time job online? How do college students find part-time jobs in summer?
- Mathematical analysis_ Notes_ Chapter 1: set and mapping
- 第九章 APP项目测试(1)
- 英文字母pc是什么意思,互联网的pc指的是什么
猜你喜欢
随机推荐
What do Niu B programmers pay attention to when "creating an index"?
啊哈C语言 第7章 有了它你能做更多的事(第27-28讲)
Is there a real part-time job online? How do college students find part-time jobs in summer?
Mathematical analysis_ Notes_ Chapter 1: set and mapping
Spark 离线开发框架设计与实现
数据库连接异常:create connection error, url: jdbc:mysql://ip/数据库名, errorCode 0, state 08S01问题处理
Go language -panic and recover
When I was young, I thought my father was omnipotent
MCS: discrete random variable - uniform distribution
高等数学(第七版)同济大学 习题1-8 个人解答
[opencv450] inter frame difference method
Webrtc[47] - a common way for webrtc to save YUV data
Yingjixin ip6806 wireless charging scheme 5W Qi certified peripheral simplified 14 devices
软件设计开发笔记2:基于QT设计串口调试工具
Build a gocd environment
Cloud native database is the world of future databases
About information disclosure and defense
Implementation of pyGame music related functions
知识点滴 - 折叠锻打和大马士革钢
Composite API









