冷凡社长
冷凡社长
全部文章
分类
题解(2)
归档
标签
去牛客网
登录
/
注册
冷凡社长的博客
TA的专栏
0篇文章
0人订阅
SQL题解
0篇文章
0人学习
全部文章
(共136篇)
题解 | #统计作答次数#
描述 有一个试卷作答记录表exam_record,请从中统计出总作答次数total_pv、试卷已完成作答数complete_pv、已完成的试卷数complete_exam_cnt 重点 主要在于已完成的试卷数的统计,因为这个带有条件,且需要统计聚合结果,很自然可以想到 使用 聚合函数与case wh...
Mysql
2022-08-17
18
813
题解 | #SQL类别高难度试卷得分的截断平均值#
题目描述 牛客的运营同学想要查看大家在SQL类别中高难度试卷的得分情况。 要求 从考试记录的表(exam_record)中,计算 hard 难度的 得分平均值,要求去掉一个最大值和最小值。 解题过程 将测试数据导入到本地数据库 先查询确认一下 标记为 hard ,tag 为sql的答题记录 sele...
Mysql
2022-08-17
2
391
题解 | #纠错4#
SELECT cust_name, cust_contact, cust_email FROM Customers WHERE cust_state = 'MI' UNION SELECT cust_name, cust_contact, cust_email FROM C...
Mysql
2022-08-16
2
235
题解 | #将两个 SELECT 语句结合起来(一)#
select * from OrderItems where quantity =100 union all select * from OrderItems where prod_id like "BNBG%" order by prod_id 知识点:1 union(all)...
Mysql
2022-08-16
1
285
题解 | #列出供应商及其可供产品的数量#
select t.vend_id,count(prod_id) as order_num from Vendors t left join Products t1 on t.vend_id = t1.vend_id group by t.vend_id order by t.vend_id 如果保...
Mysql
2022-08-16
1
263
题解 | #返回产品名称和每一项产品的总订单数#
select t.prod_name,count(order_num) as order_num from Products t left join OrderItems t1 on t.prod_id = t1.prod_id group by t.prod_name order by t.pr...
Mysql
2022-08-16
6
290
题解 | #返回产品名称和与之相关的订单号#
select prod_name,order_num from Products t left join OrderItems t1 on t.prod_id=t1.prod_id order by prod_name 题目说到的 OUTER JOIN 即为LEFT OUTER JOIN平时略写为...
Mysql
2022-08-15
10
280
题解 | #检索每个顾客的名称和所有的订单号(二)#
select cust_name,order_num from Customers t left join Orders t1 on t.cust_id=t1.cust_id order by cust_name 知识点:1、外连接的使用,识别主表2、一般主表都放在左侧,故常用left join
Mysql
2022-08-15
3
328
题解 | #检索每个顾客的名称和所有的订单号(一)#
和96题一样 select cust_name,order_num from Customers t inner join Orders t1 on t.cust_id=t1.cust_id order by cust_name,order_num 建议任何时候都使用 join on 标准的链接...
Mysql
2022-08-15
1
271
题解 | #确定最佳顾客的另一种方式(二)#
与97题差不多,加入了条件筛选,减少了一个分组 select cust_name,sum(quantity*item_price) as total_price from Customers t inner join Orders t1 on t.cust_id = t1.cust_id inne...
Mysql
2022-08-15
7
498
首页
上一页
1
2
3
4
5
6
7
8
9
10
下一页
末页