Hjwwwww_
Hjwwwww_
全部文章
分类
归档
标签
去牛客网
登录
/
注册
Hjwwwww_的博客
全部文章
(共42篇)
题解 | #删除记录(二)#
最早三条:先用order by升序,再用limit限制选择3条 timestampdiff可以计算时间差,这里选择的是按分钟计算 delete from exam_record where timestampdiff(minute,start_time,submit_time)<5 or ...
2023-01-08
0
216
题解 | #删除记录(三)#
根据条件删除:DELETE FROM tb_name [WHERE options] [ [ ORDER BY fields ] LIMIT n ] 全部删除(表清空,包含自增计数器重置):TRUNCATE tb_name TRUNCATE nowcoder_exam_record
2023-01-08
0
257
题解 | #创建一张新表#
CREATE TABLE IF NOT EXISTS tb_name -- 不存在才创建,存在就跳过 (column_name1 data_type1 -- 列名和类型必选 primary key--->主键(不允许为空,所以不需设置not null) FOREIGN KEY -- 外键,引用...
2023-01-08
0
332
题解 | #删除表#
删除表:DROP TABLE IF EXISTS 表名1 ,表名2。(包括表定义及其数据) drop table IF EXISTs exam_record_2011,exam_record_2012,exam_record_2013,exam_record_2014
2023-01-08
0
214
题解 | #创建索引#
创建 create CREATE INDEX ... ON table_name (column) [UNIQUE INDEX -- 唯一索引 |FULLTEXT INDEX -- 全文索引 ] INDEX index_name -- 不指定唯一或全文时默认普通索引 注意要用分号做好...
2023-01-08
0
228
题解 | #删除索引#
drop table 删除全表 drop index 删除索引 drop index uniq_idx_exam_id on examination_info; drop index full_idx_tag on examination_info;
2023-01-08
0
150
题解 | #SQL类别高难度试卷得分的截断平均值#
也可以用join函数嵌套 (join..USING( ) JOIN..ON..=..) 计算去掉最小值和最大值的平均值有两种方法:一种是除去两个极值的总数/除去2的总数,一种是去掉两个极值的直接平均数 注意要保留一位小数,所以用到round函数 要注意两表连接的唯一码是exam_id selec...
2023-01-08
0
248
题解 | #统计作答次数#
count不计算null值,条件函数划分很重要 select count(exam_id) total_pv, count(submit_time) complete_pv, count(distinct if(submit_time is not null,exam_id, null)) co...
2023-01-08
0
236
题解 | #得分不小于平均分的最低分#
得分分为两部分计算:不小于平均分的分数取数A后,再取A中的最小值 嵌套函数 join select MIN(e.score) min_score_over_avg from exam_record e JOIN examination_info i using(exam_id) WHERE i.t...
2023-01-08
0
242
题解 | #更新记录(二)#
未完成即submit_time是空的,这个是关键 其次做字段的更新,使用update即可 注意同时更新两个字段,需要用逗号隔开 update exam_record set submit_time="2099-01-01 00:00:00", score = 0 where start_time&...
2023-01-07
0
206
首页
上一页
1
2
3
4
5
下一页
末页