题解 | 统计快递运输时长
统计快递运输时长
https://www.nowcoder.com/practice/bb4196936f15424dbabe76a501186d91
with
trans_time as (
select
express_tb.exp_number,
express_tb.exp_type,
timestampdiff(minute, exp_action_tb.out_time, exp_action_tb.in_time) / 60 as time
from
express_tb
join exp_action_tb on express_tb.exp_number = exp_action_tb.exp_number
)
select
exp_type,
round(avg(time),1) as time
from
trans_time
group by
exp_type
order by
time
在使用timestampdiff函数时 以minute/60得到小时数 为佳

查看20道真题和解析