Lovelace_Wan
Lovelace_Wan
全部文章
分类
题解(2)
归档
标签
去牛客网
登录
/
注册
Lovelace_Wan的博客
TA的专栏
35篇文章
0人订阅
SQL错题
35篇文章
364人学习
全部文章
(共51篇)
*题解 | #确定最佳顾客的另一种方式(二)# 直接表联合
来自专栏
# 【问题】编写 SQL 语句,返回订单总价不小于1000 的客户名称和总额(OrderItems 表中的order_num)。 # 提示:需要计算总和(item_price 乘以 quantity)。按总额对结果进行排序,请使用INNER JOIN 语法。 # 使用innerjoin selec...
2024-03-16
0
222
***难题解|select 中的非聚合要在groupby出现
来自专栏
# 3个表直接连接 select cust_name,b.order_num, sum(quantity*item_price) as OrderTotal from Customers a,Orders b,OrderItems c where a.cust_id = b.cust_id and...
2024-03-16
0
331
题解 | #从 Products表中检索-子查询和连接表
来自专栏
# 法1 直接使用子查询 select prod_name, (select sum(quantity) # from OrderItems ,Products from OrderItems # 不要忘记这样一个 where 等式连接 where OrderIt...
2024-03-16
0
235
**难 题解 | #返回每个顾客不同订单的总金额#
来自专栏
select cust_id, sum(item_price*quantity) AS total_ordered FROM Orders a, OrderItems b where a.order_num =b.order_num group by cust_id order by ...
2024-03-16
0
189
题解 | #顾客登录名#concat substring
来自专栏
select cust_id, cust_name, upper(concat(substring(cust_name,1,2),substring(cust_city,1,3))) as user_login from Customers # 提取前2个字符 # substring(str...
2024-03-15
0
138
***题解 | #统计复旦用户8月练题情况#难
来自专栏
# 现在运营想要了解复旦大学的每个用户在8月份练习的总题目数和回答正确的题目数情况,请取出相应明细数据,对于在8月份没有练习过的用户,答题数结果返回0. # 需要判断月份 # 通过IF语句可以设置值 # 用SUM统计所有值 /* 解题思路 一看到这种题还是比较懵的,又是要分组,又是要判断,又要连接...
2024-03-15
0
205
**题解 | #找出每个学校GPA最低的同学#窗口函数
来自专栏
# 这个题用到了窗口函数 select device_id,university,gpa from (select * , row_number() over(partition by university order by gpa) as ranking from user_p...
2024-03-15
0
162
**题解|统计每种性别的人数substring_index
来自专栏
/* substring_index(str,delim,count) str:要处理的字符串 delim:分隔符 count:计数 例子:str=www.wikidm.cn substring_index(str,'.',1) 结果是:...
2024-03-15
0
153
**题解 | #查看不同年龄段的用户明细#caseif嵌套
来自专栏
# 法1 使用case when select device_id,gender, case when age<20 then '20岁以下' when age>=20 and age<=24 then '20-24岁' when age>=25 then '25岁及以上'...
2024-03-15
0
222
**题解 | #计算25岁以上和以下的用户数量#caseif
来自专栏
# 法1 case函数的使用 # CASE 测试表达式 # WHEN 简单表达式1 THEN 结果表达式1 # WHEN 简单表达式2 THEN 结果表达式2 … # WHEN 简单表达式n THEN 结果表达式n # [ ELSE 结果表达式n+1 ] # END AS 字段别名 select ...
2024-03-15
0
196
首页
上一页
1
2
3
4
5
6
下一页
末页