- 博客(25)
- 收藏
- 关注
原创 608. Tree Node
https://leetcode.com/articles/tree-node/懒得粘过来了学习一下case then和if语句神奇的sql
2017-08-09 09:02:27
402
原创 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
1159
原创 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
382
原创 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
464
原创 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
998
原创 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
925
原创 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
836
原创 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
270
原创 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
205
原创 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
295
原创 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
800
原创 595. Big Countries
题目很简单 看一下怎么用union完成 union的速度会更快些 There is a table World+-----------------+------------+------------+--------------+---------------+| name | continent | area | population |
2017-07-19 09:48:20
304
转载 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
575
原创 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
248
原创 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
177
原创 笨方法34-39
习题 34: 访问列表的元素记住: 序数ordinal == 有序,以 1 开始;基数cardinal == 随机选取, 以 0 开始。习题 35: 分支和函数习题 36: 设计和调试If 语句的规则1. 每一个“if 语句”必须包含一个 else .2. 如果这个 else 永远都不应该被执行到,因为它本身没有任何意义,那你
2017-07-13 09:53:23
275
原创 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
158
原创 笨方法27-33
习题 27: 记住逻辑关系习题 28: 布尔表达式练习习题 29: 如果(if)习题 30: Else 和 IfPython 的规则里,只要一行以“冒号(colon)” : 结尾,它接下来的内容就应该有缩进。一个if语句可以跟多个elif语句,但最后只能有一个else语句习题 31: 作出决定习题
2017-07-12 09:19:43
225
原创 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
213
原创 笨方法18-26
习题 18: 命名、变量、代码、函数函数可以做三样事情: 1. 它们给代码片段命名,就跟“变量”给字符串和数字命名一样。 2. 它们可以接受参数,就跟你的脚本接受 argv 一样。 3. 通过使用 #1 和 #2,它们可以让你创建“微型脚本”或者“小命令”。 你可以使用 def 新建函数错误:定义时忘了加:使用时没有参数的函数忘了加()
2017-07-11 08:58:17
225
原创 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
278
原创 笨方法6-17
习题 6: 字符串(string)和文本解释一下为什么 w 和 e 用 + 连起来就可以生成一个更长的字符串。因为:w和e 分别都赋值了字符串 ,所以显示的是w和(+)e的字符串。习题 7: 更多打印print "." * 10打印出10个.print a,print b输出a b 若没有逗号,结果换行显示 输出 a
2017-07-10 09:53:15
385
原创 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
195
原创 笨方法0-5
前言:笨办法更简单这本书的目的是教会你编程新手所需的三种最重要的技能:读和写、注重细节、发现不同习题 0: 准备工作这节练习的准备工作的目的,也就是让你可以在以后的练习中顺利地做到下面的这些事情: 1. 使用 gedit 编写代码。2. 运行你写的习题。 3. 修改错误的习题。 4. 重复上述步骤。其他的事情只会让你更
2017-07-07 15:18:12
203
转载 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
185
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人