mysql>insertinto Employee values(5,'Janet',69000,1),(6,'Randy',85000,1);
mysql>select d.Name as Department, e.Name as Employee, e.Salary
->from Department d, Employee e
->where e.DepartmentId = d.Id and(selectcount(distinct Salary)from Employee where DepartmentId=d.Id and Salary > e.Salary)<3->orderby Department;+------------+----------+--------+| Department | Employee | Salary |+------------+----------+--------+| IT | Max |90000|| IT | Randy |85000|| IT | Joe |70000|| Sales | Henry |80000|| Sales | Sam |60000|+------------+----------+--------+
task 12
mysql> select score, (select count(score)+1 from scores where score>s.score) as r from scores s order by score DESC;
+-------+------+
| score | r |
+-------+------+
| 4.00 | 1 |
| 4.00 | 1 |
| 3.85 | 3 |
| 3.65 | 4 |
| 3.65 | 4 |
| 3.50 | 6 |
+-------+------+