
leetcode database
文章平均质量分 72
pepi_xxx
这个作者很懒,什么都没留下…
展开
-
181. Employees Earning More Than Their Managers--自连接
题目:The Employee table holds all employees including their managers. Every employee has an Id, and there is also a column for the manager Id.+----+-------+--------+-----------+| Id | Name |原创 2017-07-11 08:36:52 · 286 阅读 · 0 评论 -
602. Friend Requests II: Who Has Most Friend?
QuestionIn social network like Facebook or Twitter, people send friend requests and accept others' requests as well.Table request_accepted holds the data of friend acceptance, while requester_原创 2017-08-01 08:56:04 · 1168 阅读 · 0 评论 -
620. Not Boring Movies--MOD()取余
题目X city opened a new cinema, many people would like to go to this cinema. The cinema also gives out a poster indicating the movies’ ratings and descriptions.Please write a SQL query to output原创 2017-07-24 08:57:47 · 301 阅读 · 0 评论 -
627. Swap Salary--UPDATE and CASE...WHEN
Given a table salary, such as the one below, that has m=male and f=female values. Swap all f and m values (i.e., change all f values to m and vice versa) with a single update query and no intermedia原创 2017-07-24 09:01:57 · 209 阅读 · 0 评论 -
608. Tree Node
https://leetcode.com/articles/tree-node/懒得粘过来了学习一下case then和if语句神奇的sql原创 2017-08-09 09:02:27 · 409 阅读 · 0 评论 -
180. Consecutive Numbers
Write a SQL query to find all numbers that appear at least three times consecutively.+----+-----+| Id | Num |+----+-----+| 1 | 1 || 2 | 1 || 3 | 1 || 4 | 2 || 5 | 1 || 6 | 2原创 2017-07-25 08:50:24 · 274 阅读 · 0 评论 -
619. Biggest Single Number--MAX()
QuestionTable number contains many numbers in column num including duplicated ones.Can you write a SQL query to find the biggest number, which only appears once.+---+|num|+---+| 8 || 8原创 2017-07-26 08:59:55 · 841 阅读 · 0 评论 -
584. Find Customer Referee
QuestionGiven a table customer holding customers information and the referee.+------+------+-----------+| id | name | referee_id|+------+------+-----------+| 1 | Will | NULL ||原创 2017-07-26 09:06:55 · 933 阅读 · 0 评论 -
613. Shortest Distance in a Line--ABS() and MIN()
QuestionTable point holds the x coordinate of some points on x-axis in a plane, which are all integers.Write a query to find the shortest distance between two points in these points.| x原创 2017-07-27 09:16:26 · 1001 阅读 · 0 评论 -
595. Big Countries
题目很简单 看一下怎么用union完成 union的速度会更快些 There is a table World+-----------------+------------+------------+--------------+---------------+| name | continent | area | population |原创 2017-07-19 09:48:20 · 310 阅读 · 0 评论 -
184. Department Highest Salary
The Employee table holds all employees. Every employee has an Id, a salary, and there is also a column for the department Id.+----+-------+--------+--------------+| Id | Name | Salary | Departme原创 2017-07-31 09:12:24 · 390 阅读 · 1 评论 -
182. Duplicate Emails
题目:Write a SQL query to find all duplicate emails in a table named Person.+----+---------+| Id | Email |+----+---------+| 1 | a@b.com || 2 | c@d.com || 3 | a@b.com |+----+------原创 2017-07-12 08:52:52 · 216 阅读 · 0 评论 -
183. Customers Who Never Order
题目Suppose that a website contains two tables, the Customers table and the Orders table. Write a SQL query to find all customers who never order anything.Table: Customers.+----+-------+| I原创 2017-07-13 08:39:12 · 161 阅读 · 0 评论 -
196. Delete Duplicate Emails
题目:Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique emails based on its smallest Id.+----+------------------+| Id | Email |+-原创 2017-07-14 09:05:11 · 184 阅读 · 0 评论 -
175. Combine Two Tables--left join
我的答案select FirstName, LastName, City, Statefrom Person,Addresswhere Person.PersonId=Address.PersonId答案错误,因为题目中有提到regardless if there is an address for each of those people没有地址的信息也要显示出来 因此不能使转载 2017-07-07 09:34:23 · 193 阅读 · 0 评论 -
197. Rising Temperature--DATEDIFF()
题目:Given a Weather table, write a SQL query to find all dates' Ids with higher temperature compared to its previous (yesterday's) dates.+---------+------------+------------------+| Id(INT)原创 2017-07-17 08:58:10 · 256 阅读 · 0 评论 -
610. Triangle Judgement--case...when...
QuestionA pupil Tim gets homework to identify whether three line segments could possibly form a triangle.However, this assignment is very heavy because there are hundreds of records to calcula原创 2017-07-21 09:00:31 · 805 阅读 · 0 评论 -
577. Employee Bonus
转自http://bookshadow.com/weblog/2017/05/05/leetcode-employee-bonus/题目描述:Select all employee's name and bonus whose bonus is Table:Employee+-------+--------+-----------+--------+| emp转载 2017-07-18 08:45:14 · 581 阅读 · 0 评论 -
176. Second Highest Salary--MAX,UNION,LIMIT
题目:Write a SQL query to get the second highest salary from the Employee table.+----+--------+| Id | Salary |+----+--------+| 1 | 100 || 2 | 200 || 3 | 300 |+----+--------+原创 2017-07-10 09:25:23 · 197 阅读 · 0 评论 -
580. Count Student Number in Departments
QuestionA university uses 2 data tables, student and department, to store data about its students and the departments associated with each major.Write a query to print the respective departmen原创 2017-07-28 09:10:54 · 472 阅读 · 0 评论