Last active
November 19, 2015 16:40
-
-
Save lyleaf/e6345384ecb73dc8f8c9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--求一列中第二大的数据 | |
select max(PersonId) from Address where PersonID not in (select MAX(PersonId) FROM Address) | |
--Use < is faster than not in | |
SELECT max(Salary) | |
FROM Employee | |
WHERE Salary < | |
(SELECT max(Salary) | |
FROM Employee); | |
--找出最个部门的工资收入最高的3个人 | |
Select dep.Name as Department, emp.Name as Employee, emp.Salary from Department dep, | |
Employee emp where emp.DepartmentId=dep.Id and | |
(Select count(distinct Salary) From Employee where DepartmentId=dep.Id and Salary>emp.Salary)<3 | |
--No more than 2 higher salary can be found in the departement. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment