database
文章平均质量分 69
keep moving 123
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
1070. 产品销售分析 III(SQL)
题目:https://leetcode-cn.com/problems/product-sales-analysis-iii/销售表Sales:+-------------+-------+| Column Name | Type |+-------------+-------+| sale_id | int || product_id | int || year | int || quantity | int || price ...原创 2021-02-24 13:19:23 · 224 阅读 · 0 评论 -
1341. 电影评分(SQL)
题目:https://leetcode-cn.com/problems/movie-rating/表:Movies+---------------+---------+| Column Name | Type |+---------------+---------+| movie_id | int || title | varchar |+---------------+---------+movie_id 是这个表的主键。title 是电影...原创 2021-02-24 11:03:54 · 850 阅读 · 0 评论 -
180. 连续出现的数字(SQL)
题目:https://leetcode-cn.com/problems/consecutive-numbers/表:Logs+-------------+---------+| Column Name | Type |+-------------+---------+| id | int || num | varchar |+-------------+---------+id 是这个表的主键。编写一个 SQL 查询,查找所有至少连...原创 2021-02-24 10:33:32 · 121 阅读 · 0 评论 -
578. 查询回答率最高的问题(SQL)
此题有问题,题目要求与测试集不符,不用看了题目:https://leetcode-cn.com/problems/get-highest-answer-rate-question/从 survey_log 表中获得回答率最高的问题,survey_log 表包含这些列:id, action, question_id, answer_id, q_num, timestamp。id 表示用户 id;action 有以下几种值:"show","answer","skip";当 action 值为 "an原创 2021-02-24 09:39:57 · 318 阅读 · 0 评论 -
580. 统计各专业学生人数(SQL)
题目:https://leetcode-cn.com/problems/count-student-number-in-departments/一所大学有 2 个数据表,分别是student和department,这两个表保存着每个专业的学生数据和院系数据。写一个查询语句,查询department表中每个专业的学生人数 (即使没有学生的专业也需列出)。将你的查询结果按照学生人数降序排列。 如果有两个或两个以上专业有相同的学生数目,将这些部门按照部门名字的字典序从小到大排列。stu...原创 2021-02-23 15:56:41 · 10134 阅读 · 0 评论 -
1158. 市场分析 I(SQL)
题目:https://leetcode-cn.com/problems/market-analysis-i/Table: Users+----------------+---------+| Column Name | Type |+----------------+---------+| user_id | int || join_date | date || favorite_brand | varchar |+-----------...原创 2021-02-23 15:38:48 · 204 阅读 · 0 评论 -
178. 分数排名(SQL)
题目:https://leetcode-cn.com/problems/rank-scores/编写一个 SQL 查询来实现分数排名。如果两个分数相同,则两个分数排名(Rank)相同。请注意,平分后的下一个名次应该是下一个连续的整数值。换句话说,名次之间不应该有“间隔”。+----+-------+| Id | Score |+----+-------+| 1 | 3.50 || 2 | 3.65 || 3 | 4.00 || 4 | 3.85 || 5 | 4....原创 2021-02-23 15:09:38 · 175 阅读 · 1 评论 -
1264. 页面推荐(SQL)
题目:https://leetcode-cn.com/problems/page-recommendations/朋友关系列表:Friendship+---------------+---------+| Column Name | Type |+---------------+---------+| user1_id | int || user2_id | int |+---------------+---------+这张表的主键是 (...原创 2021-02-23 14:48:10 · 267 阅读 · 0 评论 -
1174. 即时食物配送 II(SQL)
题目:https://leetcode-cn.com/problems/immediate-food-delivery-ii/配送表: Delivery+-----------------------------+---------+| Column Name | Type |+-----------------------------+---------+| delivery_id | int || custom...原创 2021-02-23 11:28:43 · 344 阅读 · 0 评论 -
585. 2016年的投资(SQL)
题目:https://leetcode-cn.com/problems/investments-in-2016/写一个查询语句,将2016 年 (TIV_2016) 所有成功投资的金额加起来,保留 2 位小数。对于一个投保人,他在 2016 年成功投资的条件是:他在 2015 年的投保额(TIV_2015) 至少跟一个其他投保人在 2015 年的投保额相同。他所在的城市必须与其他投保人都不同(也就是说维度和经度不能跟其他任何一个投保人完全相同)。输入格式:表insurance 格式如...原创 2021-02-23 10:48:02 · 300 阅读 · 0 评论 -
1501. 可以放心投资的国家(SQL)
题目:https://leetcode-cn.com/problems/countries-you-can-safely-invest-in/表Person:+----------------+---------+| Column Name | Type |+----------------+---------+| id | int || name | varchar || phone_number | varchar ...原创 2021-02-23 10:07:53 · 310 阅读 · 0 评论 -
1321. 餐馆营业额变化增长(SQL)
题目:https://leetcode-cn.com/problems/restaurant-growth/表: Customer+---------------+---------+| Column Name | Type |+---------------+---------+| customer_id | int || name | varchar || visited_on | date || amount | i...原创 2021-02-23 14:25:29 · 374 阅读 · 0 评论 -
1532. 最近的三笔订单(SQL)
题目:https://leetcode-cn.com/problems/the-most-recent-three-orders/表:Customers+---------------+---------+| Column Name | Type |+---------------+---------+| customer_id | int || name | varchar |+---------------+---------+customer...原创 2021-02-22 15:06:35 · 1044 阅读 · 0 评论 -
1193. 每月交易 I(SQL)
题目:https://leetcode-cn.com/problems/monthly-transactions-i/Table: Transactions+---------------+---------+| Column Name | Type |+---------------+---------+| id | int || country | varchar || state | enum || amou...原创 2021-02-22 14:51:56 · 284 阅读 · 0 评论 -
1112. 每位学生的最高成绩(SQL)
题目:https://leetcode-cn.com/problems/highest-grade-for-each-student/表:Enrollments+---------------+---------+| Column Name | Type |+---------------+---------+| student_id | int || course_id | int || grade | int |+---...原创 2021-02-22 14:35:35 · 1639 阅读 · 0 评论 -
1164. 指定日期的产品价格 (SQL)
题目:https://leetcode-cn.com/problems/product-price-at-a-given-date/产品数据表: Products+---------------+---------+| Column Name | Type |+---------------+---------+| product_id | int || new_price | int || change_date | date |+--...原创 2021-02-22 14:14:52 · 459 阅读 · 0 评论 -
602. 好友申请 II :谁有最多的好友(SQL)
题目:https://leetcode-cn.com/problems/friend-requests-ii-who-has-the-most-friends/在 Facebook 或者 Twitter 这样的社交应用中,人们经常会发好友申请也会收到其他人的好友申请。表request_accepted存储了所有好友申请通过的数据记录,其中, requester_id和 accepter_id都是用户的编号。| requester_id | accepter_id | acce...原创 2021-02-22 13:49:55 · 582 阅读 · 0 评论 -
574. 当选者(SQL)
题目:https://leetcode-cn.com/problems/winning-candidate/表: Candidate+-----+---------+| id | Name |+-----+---------+| 1 | A || 2 | B || 3 | C || 4 | D || 5 | E |+-----+---------+ 表: Vote+-----+------...原创 2021-02-22 11:16:49 · 213 阅读 · 0 评论 -
1549. 每件商品的最新订单(SQL)
题目:https://leetcode-cn.com/problems/the-most-recent-orders-for-each-product/表: Customers+---------------+---------+| Column Name | Type |+---------------+---------+| customer_id | int || name | varchar |+---------------+-------...原创 2021-02-22 11:07:38 · 348 阅读 · 0 评论 -
1045. 买下所有产品的客户(SQL)
题目:https://leetcode-cn.com/problems/customers-who-bought-all-products/Customer表:+-------------+---------+| Column Name | Type |+-------------+---------+| customer_id | int || product_key | int |+-------------+---------+product_key 是 C...原创 2021-02-22 10:17:55 · 358 阅读 · 0 评论 -
1355. 活动参与者(SQL)
题目:https://leetcode-cn.com/problems/activity-participants/表: Friends+---------------+---------+| Column Name | Type |+---------------+---------+| id | int || name | varchar || activity | varchar |+---------------...原创 2021-02-22 10:00:28 · 399 阅读 · 0 评论 -
612. 平面上的最近距离(SQL)
题目:https://leetcode-cn.com/problems/shortest-distance-in-a-plane/表point_2d保存了所有点(多于 2 个点)的坐标 (x,y) ,这些点在平面上两两不重合。写一个查询语句找到两点之间的最近距离,保留 2 位小数。| x | y ||----|----|| -1 | -1 || 0 | 0 || -1 | -2 |最近距离在点 (-1,-1) 和(-1,2) 之间,距离为 1.00 。所以...原创 2021-02-22 09:40:16 · 278 阅读 · 0 评论 -
608. 树节点(SQL)
题目:https://leetcode-cn.com/problems/tree-node/给定一个表tree,id 是树节点的编号,p_id是它父节点的id 。+----+------+| id | p_id |+----+------+| 1 | null || 2 | 1 || 3 | 1 || 4 | 2 || 5 | 2 |+----+------+树中每个节点属于以下三种类型之一:叶子:如果这个节点没有任何孩子节点。根:如...原创 2021-02-20 22:09:35 · 391 阅读 · 0 评论 -
570. 至少有5名直接下属的经理(SQL)
题目:https://leetcode-cn.com/problems/managers-with-at-least-5-direct-reports/Employee 表包含所有员工和他们的经理。每个员工都有一个 Id,并且还有一列是经理的 Id。+------+----------+-----------+----------+|Id |Name |Department |ManagerId |+------+----------+-----------+---------...原创 2021-02-20 21:52:58 · 222 阅读 · 0 评论 -
534. 游戏玩法分析 III(SQL)
题目:https://leetcode-cn.com/problems/game-play-analysis-iii/Table:Activity+--------------+---------+| Column Name | Type |+--------------+---------+| player_id | int || device_id | int || event_date | date || games_played |...原创 2021-02-20 21:44:14 · 171 阅读 · 0 评论 -
1709. 访问日期之间最大的空档期(SQL)
题目:https://leetcode-cn.com/problems/biggest-window-between-visits/表:UserVisits+-------------+------+| Column Name | Type |+-------------+------+| user_id | int || visit_date | date |+-------------+------+该表没有主键。该表包含用户访问某特定零售商的日期日志。假设今...原创 2021-02-20 11:24:07 · 337 阅读 · 0 评论 -
1126. 查询活跃业务(SQL)
题目:https://leetcode-cn.com/problems/active-businesses/事件表:Events+---------------+---------+| Column Name | Type |+---------------+---------+| business_id | int || event_type | varchar || occurences | int |+---------------+--...原创 2021-02-20 11:28:52 · 181 阅读 · 0 评论 -
1440. 计算布尔表达式的值(SQL)
题目:https://leetcode-cn.com/problems/evaluate-boolean-expression/表 Variables:+---------------+---------+| Column Name | Type |+---------------+---------+| name | varchar || value | int |+---------------+---------+name 是该表...原创 2021-02-20 16:07:47 · 708 阅读 · 0 评论 -
1077. 项目员工 III(SQL)
题目:https://leetcode-cn.com/problems/project-employees-iii/项目表Project:+-------------+---------+| Column Name | Type |+-------------+---------+| project_id | int || employee_id | int |+-------------+---------+(project_id, employee_id) ...原创 2021-02-19 16:04:19 · 262 阅读 · 0 评论 -
1747. Leetflex Banned Accounts(SQL)
题目:https://leetcode-cn.com/problems/leetflex-banned-accounts/Table: LogInfo+-------------+----------+| Column Name | Type |+-------------+----------+| account_id | int || ip_address | int || login | datetime || logout |...原创 2021-02-19 15:55:21 · 220 阅读 · 0 评论 -
1204. 最后一个能进入电梯的人(SQL)
题目:https://leetcode-cn.com/problems/last-person-to-fit-in-the-elevator/表: Queue+-------------+---------+| Column Name | Type |+-------------+---------+| person_id | int || person_name | varchar || weight | int || turn | i...原创 2021-02-19 15:52:58 · 393 阅读 · 0 评论 -
1468. 计算税后工资(SQL)
题目:https://leetcode-cn.com/problems/calculate-salaries/Salaries 表:+---------------+---------+| Column Name | Type |+---------------+---------+| company_id | int || employee_id | int || employee_name | varchar || salary | ...原创 2021-02-19 15:43:47 · 457 阅读 · 0 评论 -
1596. 每位顾客最经常订购的商品(SQL)
题目:https://leetcode-cn.com/problems/the-most-frequently-ordered-products-for-each-customer/表:Customers+---------------+---------+| Column Name | Type |+---------------+---------+| customer_id | int || name | varchar |+---------...原创 2021-02-19 14:18:40 · 966 阅读 · 0 评论 -
1308. 不同性别每日分数总计(SQL)
题目:https://leetcode-cn.com/problems/running-total-for-different-genders/表: Scores+---------------+---------+| Column Name | Type |+---------------+---------+| player_name | varchar || gender | varchar || day | date || s...原创 2021-02-19 14:15:28 · 411 阅读 · 0 评论 -
1421. 净现值查询(SQL)
题目:https://leetcode-cn.com/problems/npv-queries/表: NPV+---------------+---------+| Column Name | Type |+---------------+---------+| id | int || year | int || npv | int |+---------------+---------+(i...原创 2021-02-19 11:22:08 · 611 阅读 · 0 评论 -
1398. 购买了产品A和产品B却没有购买产品C的顾客(SQL)
题目:https://leetcode-cn.com/problems/customers-who-bought-products-a-and-b-but-not-c/Customers表:+---------------------+---------+| Column Name | Type |+---------------------+---------+| customer_id | int || customer_name ...原创 2021-02-19 10:34:32 · 578 阅读 · 0 评论 -
1715. 苹果和橘子的个数(SQL)
题目:https://leetcode-cn.com/problems/count-apples-and-oranges/表:Boxes+--------------+------+| Column Name | Type |+--------------+------+| box_id | int || chest_id | int || apple_count | int || orange_count | int |+--------------...原创 2021-02-19 10:14:02 · 547 阅读 · 0 评论 -
1270. 向公司CEO汇报工作的所有人(SQL)
题目:https://leetcode-cn.com/problems/all-people-report-to-the-given-manager/员工表:Employees+---------------+---------+| Column Name | Type |+---------------+---------+| employee_id | int || employee_name | varchar || manager_id | int ...原创 2021-02-19 10:10:48 · 263 阅读 · 0 评论 -
1445. 苹果和桔子(SQL)
题目:https://leetcode-cn.com/problems/apples-oranges/表: Sales+---------------+---------+| Column Name | Type |+---------------+---------+| sale_date | date || fruit | enum || sold_num | int |+---------------+------...原创 2021-02-18 18:04:40 · 308 阅读 · 0 评论 -
1393. 股票的资本损益(SQL)
Stocks表:+---------------+---------+| Column Name | Type |+---------------+---------+| stock_name | varchar || operation | enum || operation_day | int || price | int |+---------------+---------+(stock_name, day) 是这张...原创 2021-02-18 17:59:32 · 497 阅读 · 0 评论
分享