Hjwwwww_
Hjwwwww_
全部文章
分类
归档
标签
去牛客网
登录
/
注册
Hjwwwww_的博客
全部文章
(共42篇)
题解 | #插入记录(三)#
如果原表有重复数据,需要先删除,不然会出现重复数据 方法一: insert into examination_info(exam_id,tag,difficulty,duration,release_time) VALUES('SQL','hard', 90, '2021-01-01 00:00:...
2023-01-07
0
245
题解 | #将两个 SELECT 语句结合起来(一)#
1、union all 需要两个表的结果集字段完全一样,但不排除重复项(补充:union是合并两个查询语句的结果集,并排除重复项) 2、匹配串中可包含如下四种通配符: _:匹配任意一个字符; %:匹配0个或多个字符; [ ]:匹配[ ]中的任意一个字符(若要比较的字符是连续的,则可以用连字符“-”表...
2023-01-07
0
323
题解 | #返回产品名称和与之相关的订单号#
mysql不支持outer join,所以用left join代替 select prod_name, order_num from Products left join OrderItems using(prod_id) order by prod_name
2023-01-07
0
230
题解 | #截取出年龄#
先截取出第二个逗号后面的字符串,再截图第一个逗号前的字符串 记得按年龄分组 select substring_index(substring_index(profile,",",-2),",",1) age, count(*) number from user_submit group by age
2023-01-07
0
274
题解 | #找出每个学校GPA最低的同学#
right join 是以u2表数据为基础去显示u2全部数据及u1表符合搜索条件的数据 select device_id ,u2.university ,u2.gpa from user_profile u1 right join (select university,min(gpa) gpa f...
2023-01-07
0
213
题解 | #统计复旦用户8月练题情况#
注意点: device_i非唯一码,所以要区分来自哪个表 要注意多层括号 where 要放在join后面 left join:以u表为基础 运算: select u.device_id, university, count(question_id) question_cnt, sum(if(r...
2023-01-07
0
210
题解 | #浙大不同难度题目的正确率#
注意 1、inner join 保留两个表之前能成功匹配的部分,匹配不到不取 2、on 后面写入两个表可以连接的唯一值 3、where 在表格嵌套后做条件筛选 select difficult_level, avg(if (qpd.result= "right",1,0)) correct_rat...
2023-01-07
0
204
题解 | #计算总和#
注意 having的运算在sum函数、select函数、as函数后面 SELECT order_num, SUM(item_price*quantity) total_price FROM OrderItems GROUP BY order_num HAVING total_price>=1...
2023-01-07
0
226
题解 | #确定最佳顾客的另一种方式(二)#
inner join 同 join where后面不能接聚集函数,如sum(),having才可以 同一字段涉及不同表,选择的时候要记得加上具体表名,如cust_name 方法一:join on select c.cust_name, sum(oi.item_price*oi.quantity)...
2023-01-07
0
275
题解 | #提取博客URL中的用户名#
“-1”表示从后面开始取数,截取/后的字符串 select device_id, substring_index(blog_url,"/",-1) user_name from user_submit
2023-01-06
0
172
首页
上一页
1
2
3
4
5
下一页
末页