冷凡社长
冷凡社长
全部文章
分类
题解(2)
归档
标签
去牛客网
登录
/
注册
冷凡社长的博客
TA的专栏
0篇文章
0人订阅
SQL题解
0篇文章
0人学习
全部文章
(共136篇)
题解 | #返回购买 prod_id 为 BR01 的#
与93题一样 多表链接 select cust_email from Customers t inner join Orders t1 on t.cust_id=t1.cust_id inner join OrderItems t2 on t1.order_num = t2.order_num ...
Mysql
2022-08-15
6
319
题解 | #确定哪些订单购买了 #
与92题一样 1、子查询 select cust_id, order_date from Orders where order_num in( select order_num from OrderItems where prod_id = "BR01" ) ...
Mysql
2022-08-15
3
264
题解 | #返回顾客名称和相关订单号以及每个订单的总价#
select cust_name,t1.order_num,sum(quantity*item_price) as OrderTotal from Customers t inner join Orders t1 on t.cust_id = t1.cust_id inner join OrderI...
Mysql
2022-08-15
2
437
题解 | #返回顾客名称和相关订单号#
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
252
题解 | #从 Products 表中检索所有的产#
注意要使用groupby这样的题好多呀,累了,毁灭吧。 select prod_name,sum(quantity) as quant_sold from Products t inner join OrderItems t1 on t.prod_id = t1.prod_id group by p...
Mysql
2022-08-15
2
390
题解 | #返回每个顾客不同订单的总金额#
select t.cust_id,SUM(quantity*item_price) as total_ordered from Orders t inner join OrderItems t1 on t.order_num=t1.order_num group by cust_id ORDER B...
Mysql
2022-08-15
1
296
题解 | #返回购买 prod_id 为 BR01 的产品#
多表链接 select cust_email from Customers t inner join Orders t1 on t.cust_id=t1.cust_id inner join OrderItems t2 on t1.order_num = t2.order_num where pr...
Mysql
2022-08-15
3
274
题解 | #确定哪些订单购买了 p#
1、子查询 select cust_id, order_date from Orders where order_num in( select order_num from OrderItems where prod_id = "BR01" ) order by...
Mysql
2022-08-15
0
243
题解 | #返回购买价格为 10 美元或以上产品的顾客列表#
1、表链接 select t1.cust_id from OrderItems t inner join Orders t1 on t.order_num = t1.order_num where t.item_price >=10 看到题目首先想到的是关联表,然后按条件筛选。 2、子查询 ...
Mysql
2022-08-15
7
370
题解 | #纠错3#
SELECT order_num, COUNT(*) AS items FROM OrderItems GROUP BY order_num -- 仅仅修改了分组的字段 HAVING COUNT(*) >= 3 ORDER BY items, order_num;
Mysql
2022-08-15
2
270
首页
上一页
2
3
4
5
6
7
8
9
10
11
下一页
末页