当前位置:网站首页>每日sql:求好友申请通过率
每日sql:求好友申请通过率
2022-08-11 05:35:00 【吃再多糖也不长胖】
每日sql :求好友申请通过率
背景
模拟两张表。1为好友申请表,2为申请通过表
问题1:好友申请通过率
ddl
Create table If Not Exists friend_request ( sender_id INT NOT NULL, send_to_id INT NULL, request_date DATE NULL);Create table If Not Exists request_accepted ( requester_id INT NOT NULL, accepter_id INT NULL, accept_date DATE NULL);insert into friend_request (sender_id, send_to_id, request_date) values (1, 2, '2016/06/01');insert into friend_request (sender_id, send_to_id, request_date) values (1, 3, '2016/06/01');insert into friend_request (sender_id, send_to_id, request_date) values (1, 4, '2016/06/01');insert into friend_request (sender_id, send_to_id, request_date) values (2, 3, '2016/06/02');insert into friend_request (sender_id, send_to_id, request_date) values (3, 4, '2016/06/09');insert into request_accepted (requester_id, accepter_id, accept_date) values (1, 2, '2016/06/03');insert into request_accepted (requester_id, accepter_id, accept_date) values (1, 3, '2016/06/08');insert into request_accepted (requester_id, accepter_id, accept_date) values (2, 3, '2016/06/08');insert into request_accepted (requester_id, accepter_id, accept_date) values (3, 4, '2016/06/09');insert into request_accepted (requester_id, accepter_id, accept_date) values (3, 4, '2016/06/10');
sql
select round( (select count(*) from (select distinct requester_id,accepter_id from request_accepted) as b) / (select count(*) from (select distinct sender_id,send_to_id from friend_request) as a) ,2)
边栏推荐
- lvm multi-disk mount, combined use
- TOP2 Add two numbers
- Solve win10 installed portal v13 / v15 asked repeatedly to restart problem.
- iptables入门
- OA project meeting notice (query & whether attending & feedback for details)
- HCIA实验
- 核方法 Kernel method
- My approval of OA project (inquiry & meeting signature)
- 矩阵分析——微分、积分、极限
- OA项目之项目简介&会议发布
猜你喜欢
SECURITY DAY04 (Prometheus server, Prometheus monitored terminal, Grafana, monitoring database)
HCIP-BGP的选路实验
MySQL之函数
Concurrent programming in eight-part essay
抖音API接口
ETCD Single-Node Fault Emergency Recovery
arcgis填坑_3
八股文之并发编程
Solve win10 installed portal v13 / v15 asked repeatedly to restart problem.
HCIP-生成树(802.1D ,标准生成树/802.1W : RSTP 快速生成树/802.1S : MST 多生成树)
随机推荐
HCIP BGP建邻、联邦、汇总实验
pytorch下tensorboard可视化深坑
vnc remote desktop installation (available for personal testing on 2021-10-20)
MySQL导入导出&视图&索引&执行计划
详解BLEU的原理和计算
Raspberry Pi set static IP address
Eight-legged text of mysql
OA项目之待开会议&历史会议&所有会议
window7开启远程桌面功能
SECURITY DAY06 ( iptables firewall, filter table control, extended matching, typical application of nat table)
HCIP-生成树(802.1D ,标准生成树/802.1W : RSTP 快速生成树/802.1S : MST 多生成树)
HCIP MGRE\OSPF综合实验
Class definition, class inheritance, and the use of super
矩阵分析——Jordan标准形
矩阵分析——矩阵分解
安装cuda10.2下paddlepaddle的安装
cloudreve使用体验
TOP2两数相加
HCIP BGP neighbor building, federation, and aggregation experiments
华为防火墙-1-安全区域