杀鸡焉用牛刀 发表于 2025-3-19 04:26:03

高频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

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页: [1]
查看完整版本: 高频SQL50题 第一天 | 1757. 可回收且低脂的产品、584. 探求用户保举人、595. 大的国家、1683. 无效的推文、1148. 文章浏览 I