sky丶Mamba2
sky丶Mamba2
全部文章
分类
c++(1)
c语言(2)
Java后端(1)
mysql(2)
PAT(1)
PAT (Basic Level)(76)
其它(5)
大学文档(7)
数据分析(6)
社区发现(1)
算法(1)
题解(80)
归档
标签
去牛客网
登录
/
注册
sky丶Mamba2的博客
TA的专栏
80篇文章
0人订阅
sql题
80篇文章
1717人学习
全部文章
(共183篇)
题解 | 43#将所有to_date为9999-01-01的全部更新为NULL#
来自专栏
update titles_test set to_date = null, from_date = '2001-01-01' where to_date = '9999-01-01'思路:使用update,set语句,注意字符型数据加单引号。
2021-08-03
0
432
题解 | 8#找出所有员工当前薪水salary情况#
来自专栏
select distinct salary from salaries order by salary desc;思路:题目很简单,利用distinct去重
2021-08-03
3
267
题解 | 44#将id=5以及emp_no=10001的行数据替换成id=5以及emp_no=10005#
来自专栏
UPDATE titles_test SET emp_no = REPLACE(emp_no, 10001, 10005) WHERE id = 5;注意使用update关键字,使用条件id=5,然后使用replace替换
2021-08-03
0
370
题解 | 52#获取Employees中的first_name#
来自专栏
select first_name from employees order by right(first_name,2)使用right函数,取first_name的最后俩个字符,然后排序
2021-08-02
0
330
题解 | 51#查找字符串 10,A,B 中逗号,出现的次数cnt#
来自专栏
select (length("10,A,B")-length(replace("10,A,B",",","")))要了解length函数和replace函数的用法
2021-08-02
0
430
题解 | 45#将titles_test表名修改为titles_2017#
来自专栏
alter table titles_test rename to titles_2017看这个图就好了
2021-08-02
0
341
题解 | 55#分页查询employees表,每5行一页,返回第2页的数据#
来自专栏
select * from employees limit 5,5从此题开始,按通过率顺序刷使用limit就好了,很简单
2021-08-02
0
435
题解 | 7#查找薪水记录超过15次的员工号emp_no以及其对应的记录次数t#
来自专栏
select emp_no,count(salary) as t from salaries group by emp_no having t>15使用聚合函数和分组判断就好了
2021-08-02
1
396
题解 | 5#查找所有员工的last_name和first_name以及对应部门编号dept_no#
来自专栏
select last_name,first_name,d.dept_no from employees as e left join dept_emp as d on e.emp_no=d.emp_no相比于上题,使用一个左外连接就好了,left outer join,其中outer可以省略。
2021-08-01
1
369
题解 | 4#查找所有已经分配部门的员工的last_name和first_name以及dept_no#
来自专栏
select last_name,first_name,d.dept_no from employees as e join dept_emp as d on e.emp_no=d.emp_no;使用一个内连接就好了,注意第一行的最后一个字段只能使用d表里的,因为d表是附表。
2021-08-01
1
342
首页
上一页
10
11
12
13
14
15
16
17
18
19
下一页
末页