SQL review

python需要把空格去掉,不然读取一行raw_input()就会出问题
我还以为是2.7.4和2.7.6的差别呢。

versatile: 全能的
pessimistic: 悲观的
optimistic: 乐观的
Marbles:大理石
falsity: 错误
理解loop invariant的好turorial, mark
http://www.cs.uofs.edu/~mccloske/courses/cmps144/invariants_lec.html

https://leetcode.com/problems/department-highest-salary/

select D.Name, E.Name, D.Salary
from Employee E
(select DepartmentId, Max(Employee.Salary) MS
from Department
group by Name) T,
Department D
where E.DepartmentId=T.DepartmentId
and E.DepartmentId=D.Id
and E.Salary=T.MS

Write your MySQL query statement below
找到连续的出现至少三次的数
select distinct l1.num
from Logs as l1, Logs as l2, Logs as l3
where l3.id-l2.id=1
and l2.id-l1.id=1
and l1.num=l2.num
and l2.num=l3.num;

https://leetcode.com/problems/rising-temperature/

好久没写SQL了,都快不会写了。

这题两个表Join,区分名字用Weather as w1,

https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_datediff 官方文档

DATEDIFF(DATE d1, DATE d2)
表示d1-d2的天数

然后注意一下温度的差别就好了

这题居然遇到了Internal Error 第一次遇到= =

# Write your MySQL query statement below
select w2.id 
from Weather as w1, Weather as w2
where DATEDIFF(w2.Date, w1.Date)=1
and w1.Temperature<w2.Temperature;

Posted by richard爱闹 - 6月 3 2015
如需转载,请注明: 本文来自 Richard