自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

王昕的博客

用于记录本人在数据科学学习过程中的各种项目总结、心得体会等

  • 博客(41)
  • 收藏
  • 关注

原创 LeetCode刷题-数据库(MySQL)-585. Investments in 2016

585. Investments in 2016一、题目描述Write a query to print the sum of all total investment values in 2016 (TIV_2016), to a scale of 2 decimal places, for all policy holders who meet the following criteria...

2019-08-22 11:29:20 536

原创 LeetCode刷题-数据库(MySQL)-580. Count Student Number in Department

580. Count Student Number in Department一、题目描述A university uses 2 data tables, student and department, to store data about its students and the departments associated with each major.Write a query t...

2019-08-22 11:13:57 398

原创 LeetCode刷题-数据库(MySQL)-578. 查询回答率最高的问题

578. 查询回答率最高的问题一、题目描述从 survey_log 表中获得回答率最高的问题,survey_log 表包含这些列:uid, action, question_id, answer_id, q_num, timestamp。uid 表示用户 id;action 有以下几种值:“show”,“answer”,“skip”;当 action 值为 “answer” 时 answer...

2019-08-22 10:54:05 1001 1

原创 LeetCode刷题-数据库(MySQL)-574. 当选者

574. 当选者一、题目描述表: CandidateidName1A2B3C4D5E表: VoteidCandidateId1224334255id 是自动递增的主键,CandidateId 是 Candidate 表中的 id.请编写 sql 语句来找到当选者的名字...

2019-08-22 10:33:38 978

原创 LeetCode刷题-数据库(MySQL)-570. 至少有5名直接下属的经理

570. 至少有5名直接下属的经理一、题目描述Employee 表包含所有员工和他们的经理。每个员工都有一个 Id,并且还有一列是经理的 Id。IdNameDepartmentManagerId101JohnAnull102DanA101103JamesA101104AmyA101105AnneA101106...

2019-08-21 15:51:12 1674

原创 LeetCode刷题-数据库(MySQL)-550. Game Play Analysis IV

550. Game Play Analysis IV一、题目描述Table: ActivityColumn NameTypeplayer_idintdevice_idintevent_datedategames_playedint(player_id, event_date) is the primary key of this table...

2019-08-21 14:26:02 963

原创 LeetCode刷题-数据库(MySQL)-534. Game Play Analysis III

534. Game Play Analysis III一、题目描述Table: ActivityColumn NameTypeplayer_idintdevice_idintevent_datedategames_playedint(player_id, event_date) is the primary key of this tabl...

2019-08-21 12:39:20 1756 1

原创 LeetCode刷题-数据库(MySQL)-184. 部门工资最高的员工

184. 部门工资最高的员工一、题目描述Employee 表包含所有员工信息,每个员工有其对应的 Id, salary 和 department Id。IdNameSalaryDepartmentId1Joe7000012Henry8000023Sam6000024Max900001Department 表包含公司所有部...

2019-08-21 11:00:09 364

原创 LeetCode刷题-数据库(MySQL)-180. 连续出现的数字

180. 连续出现的数字一、题目描述编写一个 SQL 查询,查找所有至少连续出现三次的数字。IdNum11213142516272例如,给定上面的 Logs 表, 1 是唯一连续出现至少三次的数字。ConsecutiveNums1来源:力扣(LeetCode)链接:https://leet...

2019-08-21 09:59:21 557

原创 LeetCode刷题-数据库(MySQL)-178. 分数排名

178. 分数排名一、题目描述编写一个 SQL 查询来实现分数排名。如果两个分数相同,则两个分数排名(Rank)相同。请注意,平分后的下一个名次应该是下一个连续的整数值。换句话说,名次之间不应该有“间隔”。IdScore13.5023.6534.0043.8554.0063.65例如,根据上述给定的 Scores 表,你的查...

2019-08-21 09:29:10 552

原创 LeetCode刷题-数据库(MySQL)-177. 第N高的薪水

177. 第N高的薪水一、题目描述编写一个 SQL 查询,获取 Employee 表中第 n 高的薪水(Salary)。IdSalary110022003300例如上述 Employee 表,n = 2 时,应返回第二高的薪水 200。如果不存在第 n 高的薪水,那么查询应返回 null。getNthHighestSalary(2)...

2019-08-20 11:11:57 261

原创 LeetCode刷题-数据库(MySQL)-1083. Sales Analysis III

1083. Sales Analysis III一、题目描述Table: ProductColumn NameTypeproduct_idintproduct_namevarcharunit_priceintproduct_id is the primary key of this table.Table: SalesColumn Na...

2019-08-20 10:42:26 986

原创 LeetCode刷题-数据库(MySQL)-1083. Sales Analysis II

1082. Sales Analysis II一、题目描述Table: ProductColumn NameTypeproduct_idintproduct_namevarcharunit_priceintproduct_id is the primary key of this table.Table: SalesColumn Nam...

2019-08-20 10:07:40 1552

原创 LeetCode刷题-数据库(MySQL)-1082. Sales Analysis I

Table: ProductColumn NameTypeproduct_idintproduct_namevarcharunit_priceintproduct_id is the primary key of this table.Table: SalesColumn NameTypeseller_idintprod...

2019-08-20 09:42:49 1595

原创 LeetCode刷题-数据库(MySQL)-1076. Project Employees II

1076. Project Employees II一、题目描述Table: ProjectColumn NameTypeproject_idintemployee_idint(project_id, employee_id) is the primary key of this table.employee_id is a foreign key to...

2019-08-19 16:37:01 818

原创 LeetCode刷题-数据库(MySQL)-1075. Project Employees I

1075. Project Employees I一、题目描述Table: ProjectColumn NameTypeproject_idintemployee_idint(project_id, employee_id) is the primary key of this table.employee_id is a foreign key to ...

2019-08-19 15:35:09 571

原创 LeetCode刷题-数据库(MySQL)- 1069.销售分析II

销售表:SalesColumn NameTypesale_idintproduct_idintyearintquantityintpriceintsale_id 是这个表的主键。product_id 是 Product 表的外键。请注意价格是每单位的。产品表:ProductColumn NameTypepro...

2019-08-19 14:17:16 716 1

原创 LeetCode刷题-数据库(MySQL)- 1068. Product Sales Analysis I

1068. Product Sales Analysis I一、题目描述Table: SalesColumn NameTypesale_idintproduct_idintyearintquantityintpriceint(sale_id, year) is the primary key of this table.produ...

2019-08-19 13:59:12 819

原创 LeetCode刷题-数据库(MySQL)- 1050.合作过至少三次的演员和导演

ActorDirector 表:Column NameTypeactor_idintdirector_idinttimestampinttimestamp 是这张表的主键.写一条SQL查询语句获取合作过至少三次的演员和导演的 id 对 (actor_id, director_id)示例:ActorDirector 表:actor_id...

2019-08-19 13:52:02 754

原创 LeetCode刷题-数据库(MySQL)- 627.交换工资

627.交换工资一、题目描述给定一个 salary 表,如下所示,有 m = 男性 和 f = 女性 的值。交换所有的 f 和 m 值(例如,将所有 f 值更改为 m,反之亦然)。要求只使用一个更新(Update)语句,并且没有中间的临时表。注意,您必只能写一个 Update 语句,请不要编写任何 Select 语句。例如:idnamesexsalary1Am...

2019-08-19 11:06:51 208

原创 LeetCode刷题-数据库(MySQL)- 620.有趣的电影

620.有趣的电影一、题目描述某城市开了一家新的电影院,吸引了很多人过来看电影。该电影院特别注意用户体验,专门有个 LED显示板做电影推荐,上面公布着影评和相关电影描述。作为该电影院的信息部主管,您需要编写一个 SQL查询,找出所有影片描述为非 boring (不无聊) 的并且 id 为奇数 的影片,结果请按等级 rating 排列。例如,下表 cinema:idmovied...

2019-08-19 10:55:06 531 1

原创 LeetCode刷题-数据库(MySQL)- 619.只出现一次的最大数字

表 my_numbers 的 num 字段包含很多数字,其中包括很多重复的数字。你能写一个 SQL 查询语句,找到只出现过一次的数字中,最大的一个数字吗?num88331456对于上面给出的样例数据,你的查询语句应该返回如下结果:num6注意:如果没有只出现一次的数字,输出 null 。来源:力扣(...

2019-08-19 10:30:20 524

原创 LeetCode刷题-数据库(MySQL)- 613.直线上的最近距离

613.直线上的最近距离一、题目描述表 point 保存了一些点在 x 轴上的坐标,这些坐标都是整数。写一个查询语句,找到这些点中最近两个点之间的距离。x-102最近距离显然是 ‘1’ ,是点 ‘-1’ 和 ‘0’ 之间的距离。所以输出应该如下:shortest1注意:每个点都与其他点坐标不同,表 table 不会有重复坐标出现...

2019-08-19 09:54:51 687

原创 LeetCode刷题-数据库(MySQL)- 610.判断三角形

610.判断三角形一、题目描述一个小学生 Tim 的作业是判断三条线段是否能形成一个三角形。然而,这个作业非常繁重,因为有几百组线段需要判断。假设表 table 保存了所有三条线段的三元组 x, y, z ,你能帮 Tim 写一个查询语句,来判断每个三元组是否可以组成一个三角形吗?xyz131530102015对于如上样例数据,你的查询语句应该返...

2019-08-19 09:45:15 791 1

原创 LeetCode刷题-数据库(MySQL)- 607.销售员

607.销售员一、题目描述描述给定 3 个表: salesperson, company, orders。输出所有表 salesperson 中,没有向公司 ‘RED’ 销售任何东西的销售员。解释输入表: salespersonsales_idnamesalarycommission_ratehire_date1John10000064/1/200...

2019-08-14 16:56:31 590 1

原创 LeetCode刷题-数据库(MySQL)- 603.连续空余座位

603.连续空余座位一、题目描述几个朋友来到电影院的售票处,准备预约连续空余座位。你能利用表 cinema ,帮他们写一个查询语句,获取所有空余座位,并将它们按照 seat_id 排序后返回吗?seat_idfree1120314151对于如上样例,你的查询语句应该返回如下结果。seat_id345...

2019-08-13 17:16:20 1705 2

原创 LeetCode刷题-数据库(MySQL)- 597.好友申请 I :总体通过率

597.好友申请 I :总体通过率一、题目描述在 Facebook 或者 Twitter 这样的社交应用中,人们经常会发好友申请也会收到其他人的好友申请。现在给如下两个表:表: friend_requestsender_idsend_to_idrequest_date122016_06-01132016_06-01142016_06-01...

2019-08-13 16:54:27 1161

原创 LeetCode刷题-数据库(MySQL)- 596.超过5名学生的课

596.超过5名学生的课一、题目描述有一个 courses 表 ,有: student (学生) 和 class (课程)。请列出所有超过或等于5名学生的课。例如,表:studentclassAMathBEnglishCMathDBiologyEMathFComputerGMathHMathIMath...

2019-08-13 15:38:27 173

原创 LeetCode刷题-数据库(MySQL)- 595.大的国家

595.大的国家一、题目描述这里有张 World 表namecontinentareapopulationgdpAfghanistanAsia6522302550010020343000AlbaniaEurope28748283174112960000AlgeriaAfrica238174137100000188681000...

2019-08-13 15:07:40 296

原创 LeetCode刷题-数据库(MySQL)- 586.订单最多的客户

586.订单最多的客户一、题目描述在表 order 中找到订单数最多客户对应的 customer_number 。数据能够保证订单数最多的客户恰好只有一位。表 orders 定义如下:ColumnTypeorder_number (PK)intcustomer_numberintorder_datedaterequired_datedate...

2019-08-13 13:13:47 1376

原创 LeetCode刷题-数据库(MySQL)- 584.寻找用户推荐人

584.寻找用户推荐人一、题目描述给定表 customer ,里面保存了所有客户信息和他们的推荐人。idnamereferee_id1WillNULL2JaneNULL3Alex24BillNULL5Zack16Mark2写一个查询语句,返回一个编号列表,列表中编号的推荐人的编号都 不是 2。对于上面的示例数...

2019-08-12 17:42:33 426

原创 LeetCode刷题-数据库(MySQL)- 577.员工奖金

577.员工奖金一、题目描述选出所有 bonus < 1000 的员工的 name 及其 bonus。Employee 表单empIdnamesupervisorsalary1John310002Dan320003Bradnull40004Thomas34000empId 是这张表单的主键。Bonus 表单...

2019-08-12 17:11:48 829

原创 LeetCode刷题-数据库(MySQL)- 512.Game Play Analysis II

512.Game Play Analysis II一、题目描述Table: ActivityColumn NameTypeplayer_idintdevice_idintevent_datedategames_playedint(player_id, event_date) is the primary key of this table....

2019-08-12 17:00:15 1268 1

原创 LeetCode刷题-数据库(MySQL)- 511.Game Play Analysis I

511.Game Play Analysis I一、题目描述Table: ActivityColumn NameTypeplayer_idintdevice_idintevent_datedategames_playedint(player_id, event_date) is the primary key of this table....

2019-08-12 15:44:57 1493

原创 LeetCode刷题-数据库(MySQL)- 197.上升的温度

197.上升的温度一、题目描述给定一个Weather表,编写一个SQL查询,来查找与之前(昨天的)日期相比温度更高的所有日期的Id。Id(INT)RecordDate(DATE)Temperature(INT)12015-01-011022015-01-022532015-01-032042015-01-0430例如,根据上述给定...

2019-08-12 15:22:16 300

原创 LeetCode刷题-数据库(MySQL)- 183.从不订购的客户

183.从不订购的客户一、题目描述某网站包含两个表,Customers表和Orders表。编写一个SQL查询,找出所有从不订购任何东西的客户。Customers表:IdName1Joe2Henry3Sam4MaxOrders表:IdCustomerId1321例如给定上述表格,你的查询应返回:...

2019-08-12 14:42:19 310

原创 LeetCode刷题-数据库(MySQL)- 196.删除重复的电子邮箱

196. 删除重复的电子邮箱一、题目描述编写一个SQL查询,来删除Person表中所有重复的电子邮箱,重复的邮箱只保留Id最小的那个。IdEmail1john@example.com2bob@example.com3john@example.comId是这个表的主键例如,在运行你的查询语句之后,上面的Person表应返回以下几行:Id...

2019-08-12 14:12:50 565

原创 LeetCode刷题-数据库(MySQL)- 182.查找重复的电子邮箱

182.查找重复的电子邮箱一、题目描述编写一个SQL查询,查找Person表中所有重复的电子邮箱。示例:IdEmail1a@b.com2c@d.com3a@b.com根据以上输入,你的查询应返回以下结果:Emaila@b.com说明: 所有电子邮箱都是小写字母。二、思路分析对Email列GROUP BY,然后找出CO...

2019-08-12 11:47:02 588

原创 LeetCode刷题-数据库(MySQL)- 181.超过经理收入的员工

181.超过经理收入的员工一、题目描述Employee表包含所有员工,他们的经理也属于员工。每个员工都有一个Id,此外还有一列对应员工的经理的Id。IdNameSalaryManagerId1Joe7000032Henry8000043Sam60000NULL4Max90000NULL给定Employee表,编写一个SQ...

2019-08-12 11:36:30 273

原创 LeetCode刷题-数据库(MySQL)- 176.第二高的薪水

176.第二高的薪水一、题目描述编写一个SQL查询,获取Employee表中第二高的薪水(Salary)。IdSalary110022003300例如上述Employee表,SQL查询应该返回200作为第二高的薪水。如果不存在第二高的薪水,那么查询应返回null。SecondHighestSalary200二、题目解析将...

2019-08-12 11:14:59 327

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除