当前位置:网站首页>行程和用户[阅读理解法]
行程和用户[阅读理解法]
2022-08-09 13:00:00 【REN_林森】
前言
对于一种SQL复杂题类型之一,就是阅读理解题,而解决方式也可以按照阅读理解的方式解决。抽出需求的主干句子,状语定语作为筛选,句子内再套一个句子,那就分层写view。
一、行程与用户
二、阅读理解
target:国庆前3天,非禁止用户的取消率,保留2位小数。
1-国庆前3天,where request_at between ‘2013-10-01’ and ‘2013-10-03’
2-非禁止用户,where banned = ‘No’
注:通过with view as的方式,将状语筛选逻辑限定在各自的表内。
3-取消率,被司机|乘客取消的订单数 / 用户生成的订单数。
# Write your MySQL query statement below
/* target:国庆前3天,非禁止用户的取消率,保留2位小数。 1-国庆前3天,where request_at between '2013-10-01' and '2013-10-03' 2-非禁止用户,where banned = 'Yes' 注:通过with view as的方式,将状语筛选逻辑限定在各自的表内。 3-取消率,被司机|乘客取消的订单数 / 用户生成的订单数。 */
with view4trips as(
select client_id,driver_id,status,request_at
from Trips
where request_at between '2013-10-01' and '2013-10-03'
),view4users as(
select users_id
from Users
where banned = 'No'
)
select
date_format(request_at,'%Y-%m-%d') Day,
round(
count(if(status != 'completed',1,null)) / count(1)
,2) `Cancellation Rate`
from view4users v1 join view4trips v2 on v1.users_id = v2.client_id
join view4users v3 on v2.driver_id = v3.users_id
group by Day
order by Day
总结
1)阅读理解题要抓主干,分语言成分,来进行筛选/表瘦身成view/view的同步(句子嵌套)。
参考文献
[1] LeetCode 行程与用户
边栏推荐
- FFmpeg多媒体文件处理(ffmpeg处理流数据的基本概念)
- ftplib+ tqdm upload and download progress bar
- FFmpeg多媒体文件处理(ffmpeg操作目录及list的实现)
- How to reduce the size of desktop icons after the computer is reinstalled
- telnet+ftp to control and upgrade the device
- 陈强教授《机器学习及R应用》课程 第十三章作业
- 第六届“强网杯”全国网络安全挑战赛
- FFmpeg multimedia file processing (FFMPEG logging system)
- 自己做了个nodejs+epxress+mysql的小项目,怎么才能让别人通过互联网访问呢?
- [MRCTF2020]套娃-1
猜你喜欢
ctfshow七夕杯2022
FPGA-近日工作总结
jenkins api创建自定义pipeline
Clock frequency and baud rate count for serial communication in FPGA
问题系列-如何修改或更新localhost里的值
安踏携手华为运动健康共同验证冠军跑鞋 创新引领中国体育
Jenkins API groovy调用实践: Jenkins Core Api & Job DSL创建项目
GIN中GET POST PUT DELETE请求
面试攻略系列(四)-- 你不知道的大厂面试
Ledong Fire Rescue Brigade was invited to carry out fire safety training for cadres
随机推荐
gin的中间件和路由分组
5G China unicom AP:B SMS ASCII Transcoding Requirements
[HCIP Continuous Update] Principle and Configuration of IS-IS Protocol
Flutter entry and advanced tour (6) Layout Widget
某高校的R语言数据分析期末作业
Professor Chen Qiang's "Machine Learning and R Application" course Chapter 16 Assignment
ARM board adds routing function
Rmarkdown Tutorial
R language kaggle game data exploration and visualization
2.微服务'黑话'集锦及Eureka注册中心相关概念
Professor Chen Qiang "application in machine learning and R" course chapter 17
Redis源码剖析之robj(redisObject)
Realization of RTSP Protocol
FFmpeg multimedia file processing (the basic concept of ffmpeg processing stream data)
43. The sword refers to Offer 1 ~ 1 the number of occurrences of n integers (recursive, mathematics)
RTSP协议讲解
面试攻略系列(三)-- 高级开发工程师面试问些啥?
Draw a histogram with plot_hist_numeric()
为什么文字不贴合边
陈强教授《机器学习及R应用》课程 第十四章作业