牛客网SQL数据库实战
SQL编程
AI_Younger_Man
这个作者很懒,什么都没留下…
展开
-
nowcoder-sql-19-查找所有员工的last_name和first_name以及对应的dept_name
注意这是三表连接: 第一次左连接基于from,第一次左连接之后,在第一次左连接指出之上进行了第二次左连接 select e.last_name, e.first_name, d.dept_name from employees e left join dept_emp de on e.emp_no = de.emp_no left join departments d on d.dept_no = de.dept_no ...原创 2020-12-08 09:36:28 · 147 阅读 · 0 评论 -
nowcoder-sql-18- 获取当前薪水第二多的员工的emp_no以及其对应的薪水salary
select e.emp_no, s.salary, e.last_name, e.first_name from employees e inner join salaries s on e.emp_no = s.emp_no where s.to_date='9999-01-01' order by s.salary desc limit 1, 1原创 2020-12-07 21:46:24 · 141 阅读 · 0 评论 -
nowcoder- sql-17-获取当前薪水第二多的员工的emp_no以及其对应的薪水salary
select s.emp_no, s.salary from salaries s where s.to_date='9999-01-01' order by s.salary desc limit 1, 1原创 2020-12-07 21:42:16 · 97 阅读 · 0 评论 -
nowcoder-sql-16-统计出当前各个title类型对应的员工当前薪水对应的平均工资
select t.title, avg(s.salary) avg from titles t inner join salaries s on t.emp_no = s.emp_no where t.to_date='9999-01-01' and s.to_date='9999-01-01' group by t.title原创 2020-12-07 21:38:27 · 89 阅读 · 0 评论 -
nowcoder- sql- 15- 查找employees表
select * from employees e where e.emp_no % 2 = 1 and e.last_name <> 'Mary' order by e.hire_date desc原创 2020-12-06 23:35:20 · 97 阅读 · 0 评论 -
nowcoder-sql-14- 从titles表获取按照title进行分组
分组之后计数,计数之后去重计数操作 select t.title, count(distinct t.emp_no) t from titles t group by title having count(distinct t.emp_no) >= 2原创 2020-12-06 21:54:20 · 76 阅读 · 0 评论 -
nowcoder-sql-13-从titles表获取按照title进行分组
注意having语句是group分组时候的筛选语句 select t.title, count(*) t from titles t group by title having count(*) >= 2 # hanging 语句是分组之后的筛选条件原创 2020-12-06 21:46:36 · 77 阅读 · 0 评论 -
nowcoder-sql-11-获取所有员工当前的manager
select e.emp_no, m.emp_no from dept_emp e inner join dept_manager m on e.dept_no = m.dept_no where m.to_date = '9999-01-01' and m.emp_no <> e.emp_no原创 2020-12-05 23:30:31 · 89 阅读 · 0 评论 -
nowcoder-sql-10-获取所有非manager的员工emp
select e.emp_no from employees e where e.emp_no not in ( select e.emp_no from employees e inner join dept_manager d on e.emp_no = d.emp_no )原创 2020-12-05 23:30:14 · 61 阅读 · 0 评论 -
nowcoder-sql-09-获取所有部门当前manager的当
select d.dept_no, d.emp_no, s.salary from dept_manager d inner join salaries s on d.emp_no = s.emp_no where d.to_date='9999-01-01' and s.to_date='9999-01-01' order by d.dept_no asc原创 2020-12-05 23:29:52 · 124 阅读 · 0 评论 -
nowcoder-sql-08- 找出所有员工当前薪水salary情况
select distinct s.salary from salaries s where s.to_date = '9999-01-01' order by s.salary desc原创 2020-12-05 23:29:24 · 71 阅读 · 0 评论 -
nowcoder-sql-07-查找薪水变动超过15次的员工号
select s.emp_no, count(*) from salaries s group by s.emp_no having count(*) > 15原创 2020-12-04 16:18:25 · 283 阅读 · 0 评论 -
nowcoder-sql-06-查找所有员工入职时候的薪水情况
select e.emp_no, s.salary from salaries s inner join employees e on s.emp_no = e.emp_no where s.from_date = e.hire_date order by s.emp_no desc原创 2020-12-04 16:12:44 · 80 阅读 · 0 评论 -
nowcoder-sql-05-查找所有员工的last_name和first_name以及对应部门编号dept_no
select last_name, first_name, dept_no from employees e left join dept_emp d on e.emp_no = d.emp_no原创 2020-12-04 15:28:35 · 56 阅读 · 0 评论 -
nowcoder-sql2-查找入职员工倒数第三的员工信息
limit:作用:第一个参数是查询结果的偏移量,第二个参数是返回的个数 select * from employees where hire_date = ( select hire_date from employees order by hire_date desc limit 2,1 )原创 2020-12-04 14:32:30 · 101 阅读 · 0 评论 -
nowcode-sql1-查找入职最晚的员工所有信息
时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32M,其他语言64M 热度指数:352288 算法知识视频讲解 题目描述 查找最晚入职员工的所有信息,为了减轻入门难度,目前所有的数据里员工入职的日期都不是同一天(sqlite里面的注释为–,mysql为comment) CREATE TABLE employees ( emp_no int(11) NOT NULL, – ‘员工编号’ birth_date date NOT NULL, first_name varchar(14) NOT原创 2020-12-04 14:07:04 · 189 阅读 · 0 评论