Created
May 28, 2013 18:36
-
-
Save tphummel/5665020 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
1) | |
select e.name from Employees e, Employees b where e.bossID = b.EmployeeID and e.Salary > b.Salary | |
2) | |
select * from ( | |
select d.Name, e.Name, e.Salary, rank() over(partition by e.DepartmentID order by e.Salary DESC) as salRank from Departments d, Employees e where e.DepartmentID = d.DepartmentID) a where salRank = 1 | |
3) | |
select * from (select departmentID , count(*) as ct from Employees group by departmentID) where ct < 3 | |
4) | |
select max(d.Name), count(e.EmployeeID) as emps from Departments d left outer join Employees e on e.departmentID = d.departmentID group by d.DepartmentID | |
5) | |
select e.Name from Employees e, Employees b where e.BossID = b.EmployeeID and e.DepartmentID != b.DepartmentID | |
6) | |
select d.Name, sum(e.Salary) from Departments d, Employees e where e.DepartmentID = d.DepartmentID |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment