当前位置:网站首页>Daily sql: request for friend application pass rate
Daily sql: request for friend application pass rate
2022-08-11 07:14:00 【Eating too much sugar will not gain weight】
每日sql :Ask friends applicants
背景
Simulate the two tables.1As a friend form,2For application through the table
问题1:Buddy applicants
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)
边栏推荐
猜你喜欢
Concurrent programming in eight-part essay
The ramdisk practice 1: the root file system integrated into the kernel
grep、sed、awk
OA项目之待开会议&历史会议&所有会议
SECURITY DAY06 ( iptables firewall, filter table control, extended matching, typical application of nat table)
FusionCompute8.0.0实验(1)CNA及VRM安装
每日sql-员工奖金过滤和回答率排序第一
每日sql--统计员工近三个月的总薪水(不包括最新一个月)
每日sql-求2016年成功的投资总和
1688商品详情接口
随机推荐
矩阵分析——矩阵分解
每日sql-找到每个学校gpa最低的同学(开窗)
《Generative Adversarial Networks》
Arcgis小工具_实现重叠分析
淘宝API接口参考
求过去半年内连续30天以上每天都有1000元以上成交的商铺
ETCD containerized to build a cluster
Class definition, class inheritance, and the use of super
MySQl进阶之索引结构
获取拼多多商品信息操作详情
HCIP MGRE\OSPF Comprehensive Experiment
Open Set Domain Adaptation 开集领域适应
淘宝sku API 接口(PHP示例)
概念名词解释
HCIP 重发布/路由策略实验
损失函数——负对数似然
【LeetCode】306.累加数(思路+题解)
OA项目之项目简介&会议发布
Eight-legged text of mysql
OA项目之会议通知(查询&是否参会&反馈详情)