欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 科技 > IT业 > 高频SQL50题 第一天 | 1757. 可回收且低脂的产品、584. 寻找用户推荐人、595. 大的国家、1683. 无效的推文、1148. 文章浏览 I

高频SQL50题 第一天 | 1757. 可回收且低脂的产品、584. 寻找用户推荐人、595. 大的国家、1683. 无效的推文、1148. 文章浏览 I

2025/4/22 10:48:45 来源:https://blog.csdn.net/m0_45175414/article/details/146341763  浏览:    关键词:高频SQL50题 第一天 | 1757. 可回收且低脂的产品、584. 寻找用户推荐人、595. 大的国家、1683. 无效的推文、1148. 文章浏览 I

1757. 可回收且低脂的产品

题目链接:https://leetcode.cn/problems/recyclable-and-low-fat-products/description/?envType=study-plan-v2&envId=sql-free-50
状态:已完成

考点:无

select product_id
from Products
where low_fats = 'Y' and recyclable = 'Y'

584. 寻找用户推荐人

题目链接:https://leetcode.cn/problems/find-customer-referee/description/?envType=study-plan-v2&envId=sql-free-50
状态:已完成

考点:where子句的等值判断会自动忽略null值,因此需要增加判空逻辑

select name
from Customer
where referee_id != 2 or referee_id is null

595. 大的国家

题目链接:https://leetcode.cn/problems/big-countries/description/?envType=study-plan-v2&envId=sql-free-50
状态:已完成

考点:无

select name, population, area
from World
where area >= 3000000 or population >= 25000000

1683. 无效的推文

题目链接:https://leetcode.cn/problems/invalid-tweets/description/?envType=study-plan-v2&envId=sql-free-50
状态:已完成

考点:length()函数求解字符串的长度

select tweet_id
from Tweets
where length(content) > 15

1148. 文章浏览 I

题目链接:https://leetcode.cn/problems/article-views-i/description/?envType=study-plan-v2&envId=sql-free-50
状态:已完成

考点:修改列名(as),去重(distinct),排序(order by,默认升序)

select distinct author_id as id
from Views
where author_id = viewer_id
order by author_id

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词