当前位置:网站首页>Daily sql-employee bonus filtering and answer rate ranking first
Daily sql-employee bonus filtering and answer rate ranking first
2022-08-11 07:14:00 【Eating too much sugar will not gain weight】
每日sql 1-员工奖金
Ask for a bonus less than1000employee names and bonuses
DDL
Create table If Not Exists Employee (EmpId int, Name varchar(255), Supervisor int, Salary int);Create table If Not Exists Bonus (EmpId int, Bonus int);insert into Employee (EmpId, Name, Supervisor, Salary) values (3, 'Brad', null, 4000);insert into Employee (EmpId, Name, Supervisor, Salary) values (1, 'John', 3, 1000);insert into Employee (EmpId, Name, Supervisor, Salary) values (2, 'Dan', 3, 2000);insert into Employee (EmpId, Name, Supervisor, Salary) values (4, 'Thomas', 3, 4000);insert into Bonus (EmpId, Bonus) values (2, 500);insert into Bonus (EmpId, Bonus) values (4, 2000);
sql
select Employee.Name,Bonus.Bonus FROM Employee join Bonus on Employee.EmpId=Bonus.EmpId where Bonus.Bonus <1000 or Bonus.Bonus is null;
2-Find the question with the highest answer rate
A table records the presentation of each questionshow和回答answer状态,Use if no answerskip代替answer状态.Find the question with the highest answer rate
DDL
Create table If Not Exists survey_log (uid int, action varchar(255), question_id int, answer_id int, q_num int, timestamp int);insert into survey_log (uid, action, question_id, answer_id, q_num, timestamp) values (5, 'show', 285, null, 1, 123);insert into survey_log (uid, action, question_id, answer_id, q_num, timestamp) values (5, 'answer', 285, 124124, 1, '124');insert into survey_log (uid, action, question_id, answer_id, q_num, timestamp) values (5, 'show', 369, null, 2, 125);insert into survey_log (uid, action, question_id, answer_id, q_num, timestamp) values (5, 'skip', 369, null, 2, 126);
sql
select question_id
from survey_log
group by question_id
order by sum(case when action ="answer" then 1 else 0 end )/sum(case when action = "show" then 1 else 0 end) desc limit 1;
边栏推荐
猜你喜欢
随机推荐
抖音分享口令url API工具
OA项目之项目简介&会议发布
Douyin API interface
HCIP Republish/Routing Policy Experiment
HCIA experiment
会议OA项目之我的会议
sql--Users who have purchased more than 3 times (inclusive) within 7 days (including the current day), and the purchase amount in the past 7 days exceeds 1,000
配置dns服务
OA项目之我的会议(会议排座&送审)
一种用于EEG超扫描研究的分析流程
daily sql - user retention rate for two days
类的定义、类的继承以及super的使用
torch.cat()使用方法
arcgis填坑_4
radix-4 FFT 原理和C语言代码实现
抖音API接口
iptables nat
grep、sed、awk
My approval of OA project (inquiry & meeting signature)
HCIP experiments (pap, chap, HDLC, MGRE, RIP)