![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode
799050408
邮箱:799050408@qq.com
展开
-
leetcode 196. Delete Duplicate Emails delete
题意:删除Email重复的行,保留Id最小的行,也就使每个Email只保留Id最小那个思路:用删除语句进行删除题目链接:https://leetcode.com/problems/delete-duplicate-emails/delete p1from Person as p1, Person as p2where p1.Id > p2.Id and p1原创 2016-05-11 22:27:39 · 1201 阅读 · 0 评论 -
leetcode 183. Customers Who Never Order
题意:查找没有点过单的客人题目链接:https://leetcode.com/problems/customers-who-never-order/select Namefrom Customers as xwhere x.id not in (select distinct CustomerId from Orders);原创 2016-05-10 21:27:11 · 448 阅读 · 0 评论 -
leetcode 182. Duplicate Emails
题意:查找出现一次以上的邮箱题目链接:https://leetcode.com/problems/duplicate-emails/select distinct x.Email /*这里主要要加上distinct*/from Person as x, Person as y where x.id != y.id and x.Email = y.Email;原创 2016-05-10 21:38:15 · 640 阅读 · 0 评论 -
leetcode 181. Employees Earning More Than Their Managers
题意:查询员工工资大于该员工经理的工资的姓名题目链接:https://leetcode.com/problems/employees-earning-more-than-their-managers/select Namefrom Employee as xwhere x.Salary > (select y.Salary from原创 2016-05-10 21:48:46 · 624 阅读 · 0 评论 -
leetcode 175. Combine Two Tables left join
题意:无论一个人的地址是否存在,都要將他的FirstName, .LastName, City, State输出思路:一开始以为只是普通的等值连接,发现wa了,错误提示表名正确答案有输出firstname,lastname,null,null,说明如果只是普通的select,将要投影出的元祖中有一个属性为空,那么该元组将不会被投影出,然后学习了left outer join 学原创 2016-05-10 22:30:15 · 439 阅读 · 0 评论 -
leetcode 197. Rising Temperature to_days()
题意:查询比昨天温度高的日期的id思路:学习了to_days()函数学习链接:http://www.45it.com/database/201210/32985.htmselect w1.Idfrom Weather as w1, Weather as w2where to_days(w1.Date) = to_days(w2.Date) + 1 and w1.Te原创 2016-05-12 00:17:19 · 1095 阅读 · 0 评论 -
leetcode 176. Second Highest Salary
题意:查询第二高的工资,如果不存在,则输出null注意的地方: 排序之前要进行分组, 因为可能存在所有的工资都是一样的,这时候输出第二高的工资实际上是第一高的工资,分组后,一个工资只存在一个元组题目链接:https://leetcode.com/problems/second-highest-salary/select ifnull((select e.Sala原创 2016-05-13 15:03:11 · 925 阅读 · 0 评论 -
leetcode 180. Consecutive Numbers
题意:投影出连续三个num值相等的元组的num题目链接:https://leetcode.com/problems/consecutive-numbers/select distinct l1.numfrom Logs as l1, Logs as l2, Logs as l3where l1.Id + 1 = l2.Id and l1.Id + 2 = l3.Id a原创 2016-05-13 17:30:22 · 730 阅读 · 0 评论