当前位置:网站首页>行程和用户[阅读理解法]
行程和用户[阅读理解法]
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 行程与用户
边栏推荐
- 记录本项目中用到的系统调用与C库函数-2
- 如何求最大公约数?
- 5G China unicom AP:B SMS ASCII Transcoding Requirements
- [MRCTF2020]套娃-1
- 【FPGA教程案例48】图像案例8——基于FPGA的RGB图像转化为HSV图像的实现,通过MATLAB进行辅助验证
- novel research
- Anta and Huawei Sports Health jointly verify the champion running shoes and lead Chinese sports with innovation
- 5G China unicom 直放站 网管协议 实时性要求
- glibc 内存管理模型 释放 C库内存缓存
- 30行代码实现蚂蚁森林自动偷能量
猜你喜欢

乐东消防救援大队应邀为干部开展消防安全培训

面试题精选:神奇的斐波那契数列

Final assignment of R language data analysis in a university

npm install失败

Clock frequency and baud rate count for serial communication in FPGA

Uni - app - uview Swiper shuffling figure component, click on the links to jump (click to get the item after the row data, remove data operation)

面试攻略系列(四)-- 你不知道的大厂面试

kustomize入门示例及基本语法使用说明

Periodic sharing of Alibaba Da Tao system model governance

GET POST PUT DELETE request in GIN
随机推荐
5G Unicom Network Management Design Ideas
Dry+Bean+Dataset R语言数据分析,报告英文
JVM之配置介绍(一)
现在40系显卡都快出来了,为何1060型号的显卡还有这么多人用?
Unicom network management protocol block diagram
用plot_hist_numeric()实现画直方图
万物皆可柯里化的 Ramda.js
Jenkins API groovy调用实践: Jenkins Core Api & Job DSL创建项目
Professor Chen Qiang the machine learning and R application course chapter 18 assignments
uni-app - uview Swiper 轮播图组件点击跳转链接(点击后拿到 item 行数据, 取出数据做操作)
剑指 Offer 21. 调整数组顺序使奇数位于偶数前面(循环不变量)
Redis源码剖析之跳表(skiplist)
阿里大淘系模型治理阶段性分享
ArcEngine(八) 选择要素并高亮显示
The sword refers to Offer 57 - II. and is a continuous positive sequence of s (sliding window)
leetcode 20. Valid Parentheses 有效的括号(中等)
WSA工具箱安装应用商店提示无法工作怎么解决?
Rmarkdown Tutorial
农村区县域农业电商如何做?数字化转型如何进行?
19、学习MySQL 索引