SELECT DISTINCT(t1.Num) as ConsecutiveNums FROM Logs t1, Logs t2, Logs t3 WHERE t1.Id = t2.Id - 1 AND t2.Id = t3.Id - 1 AND t1.Num = t2.Num AND t2.Num = t3.Num ;
select t2.Name as Department,t1.Name as Employee,Salary from ( (select Name, DepartmentId,Salary from Employee) t1 left join (select Id,Name from Department) t2 on t1.DepartmentId = t2.Id ) WHERE (t2.Id,t1.Salary) in ( (select DepartmentId, MAX(Salary) from Employee group by DepartmentId) )
# t2表中有多少个大于t1当前score的 select Score, (select count(distinct(Score)) from Scores t1 where t1.Score > t2.Score ) +1 as `Rank` from Scores t2 order by Score DESC;