念_长征
念_长征
全部文章
分类
归档
标签
去牛客网
登录
/
注册
念_长征的博客
全部文章
(共166篇)
题解 | #查找字符串中逗号出现的次数#
# 使用char_length和replace函数来计数 select id, char_length(string) - char_length(replace(string,',','')) cnt from strings;
2024-02-01
0
136
题解 | #将所有获取奖金的员工当前的薪水增加10%#
update salaries set salary = salary * 1.1 where to_date = '9999-01-01' and emp_no in ( select emp_no from emp_bonus );
2024-02-01
0
118
题解 | #在audit表上创建外键约束
# 修改表,是alter alter table audit add foreign key(emp_no) references employees_test(id); 列级约束:六大约束语法上都支持,但外键约束没有效果 表级约束:除了非空、默认,其他都支持;且可以为约束取名字添加表级...
2024-02-01
0
161
题解 | 修改表名
alter table titles_test rename to titles_2017;
2024-02-01
0
123
题解 |更新操作
update titles_test set to_date = null, from_date = '2001-01-01' where to_date = '9999-01-01';
2024-02-01
0
161
题解 | #删除emp_no重复的记录,保留最小id
delete from titles_test where id not in ( select id from( select emp_no, min(id) id from titles_test group by emp_no ...
2024-02-01
0
133
题解 |表添加新列
alter table actor add column create_date datetime not null default '2020-10-01 00:00:00' after last_update;
2024-02-01
2
172
题解 |创建视图actor_name_view#
create view actor_name_view as select first_name first_name_v, last_name last_name_v from actor;
2024-02-01
0
111
题解 | #2021年11月每天的人均浏览文章时长#
# 先筛选出2021年11月的数据,然后按日期分组,再计算人均浏览时长 select date(in_time), round(sum(timestampdiff(second, in_time, out_time))/count(distinct uid),1) avg_viiew_len_se...
2024-02-01
0
133
题解 | #国庆期间每类视频点赞量和转发量#
# 思路:先把所需字段tag连接到tb_user_video_log表中,然后使用自连接将属于国庆头三天某天近一周的数据作相对应连接 with t as( select tl.*, tag from tb_user_video_log tl join ( se...
2024-02-01
0
142
首页
上一页
1
2
3
4
5
6
7
8
9
10
下一页
末页