牛客网SQL数据库实战
SQL编程
AI_Younger_Man
这个作者很懒,什么都没留下…
展开
-
nowcoder-sql-19-查找所有员工的last_name和first_name以及对应的dept_name
注意这是三表连接:第一次左连接基于from,第一次左连接之后,在第一次左连接指出之上进行了第二次左连接select e.last_name, e.first_name, d.dept_namefrom employees e left join dept_emp de on e.emp_no = de.emp_noleft join departments d on d.dept_no = de.dept_no...原创 2020-12-08 09:36:28 · 150 阅读 · 0 评论 -
nowcoder-sql-18- 获取当前薪水第二多的员工的emp_no以及其对应的薪水salary
select e.emp_no, s.salary, e.last_name, e.first_namefrom employees einner join salaries son e.emp_no = s.emp_nowhere s.to_date='9999-01-01'order by s.salary desclimit 1, 1原创 2020-12-07 21:46:24 · 143 阅读 · 0 评论 -
nowcoder- sql-17-获取当前薪水第二多的员工的emp_no以及其对应的薪水salary
select s.emp_no, s.salaryfrom salaries swhere s.to_date='9999-01-01'order by s.salary desclimit 1, 1原创 2020-12-07 21:42:16 · 99 阅读 · 0 评论 -
nowcoder-sql-16-统计出当前各个title类型对应的员工当前薪水对应的平均工资
select t.title, avg(s.salary) avgfrom titles tinner join salaries son t.emp_no = s.emp_nowhere t.to_date='9999-01-01'and s.to_date='9999-01-01'group by t.title原创 2020-12-07 21:38:27 · 91 阅读 · 0 评论 -
nowcoder- sql- 15- 查找employees表
select * from employees e where e.emp_no % 2 = 1and e.last_name <> 'Mary'order by e.hire_date desc原创 2020-12-06 23:35:20 · 102 阅读 · 0 评论 -
nowcoder-sql-14- 从titles表获取按照title进行分组
分组之后计数,计数之后去重计数操作select t.title, count(distinct t.emp_no) tfrom titles tgroup by titlehaving count(distinct t.emp_no) >= 2原创 2020-12-06 21:54:20 · 78 阅读 · 0 评论 -
nowcoder-sql-13-从titles表获取按照title进行分组
注意having语句是group分组时候的筛选语句select t.title, count(*) tfrom titles tgroup by titlehaving count(*) >= 2 # hanging 语句是分组之后的筛选条件原创 2020-12-06 21:46:36 · 79 阅读 · 0 评论 -
nowcoder-sql-11-获取所有员工当前的manager
select e.emp_no, m.emp_nofrom dept_emp einner join dept_manager mon e.dept_no = m.dept_nowhere m.to_date = '9999-01-01'and m.emp_no <> e.emp_no原创 2020-12-05 23:30:31 · 90 阅读 · 0 评论 -
nowcoder-sql-10-获取所有非manager的员工emp
select e.emp_nofrom employees ewhere 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 · 62 阅读 · 0 评论 -
nowcoder-sql-09-获取所有部门当前manager的当
select d.dept_no, d.emp_no, s.salaryfrom dept_manager dinner join salaries son d.emp_no = s.emp_nowhere 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 · 125 阅读 · 0 评论 -
nowcoder-sql-08- 找出所有员工当前薪水salary情况
select distinct s.salaryfrom salaries swhere s.to_date = '9999-01-01'order by s.salary desc原创 2020-12-05 23:29:24 · 74 阅读 · 0 评论 -
nowcoder-sql-07-查找薪水变动超过15次的员工号
select s.emp_no, count(*)from salaries sgroup by s.emp_no having count(*) > 15原创 2020-12-04 16:18:25 · 287 阅读 · 0 评论 -
nowcoder-sql-06-查找所有员工入职时候的薪水情况
select e.emp_no, s.salaryfrom salaries sinner join employees eon s.emp_no = e.emp_nowhere s.from_date = e.hire_dateorder by s.emp_no desc原创 2020-12-04 16:12:44 · 83 阅读 · 0 评论 -
nowcoder-sql-05-查找所有员工的last_name和first_name以及对应部门编号dept_no
select last_name, first_name, dept_nofrom employees eleft join dept_emp don e.emp_no = d.emp_no原创 2020-12-04 15:28:35 · 57 阅读 · 0 评论 -
nowcoder-sql2-查找入职员工倒数第三的员工信息
limit:作用:第一个参数是查询结果的偏移量,第二个参数是返回的个数select * from employeeswhere hire_date = ( select hire_date from employees order by hire_date desc limit 2,1)原创 2020-12-04 14:32:30 · 104 阅读 · 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 · 191 阅读 · 0 评论