There are 2 tables :-  

The Employee table holds all employees. 

```
+----+-------+--------+--------------+  
| Id | Name  | Sa1ary | DepartmentId |   
+----+-------+--------+--------------+  
|  1 | Joe   |  70000 |            1 |  
|  2 | Henry |  80000 |            2 |  
|  3 | Sam   |  60000 |            2 |  
|  4 | Max   |  90000 |            3 |  
|  5 | Janet |  69000 |            4 |  
|  6 | Randy |  85000 |            1 |  
+----+-------+--------+--------------+  

```

Department table is as follows:- 

```
+----+------------+      
|DID |  DNAME     |   
+----+------------+  
|1   |  IT        |  
|2   |  ADMIN     |  
|3   |  HR        |  
|4   |  MARKETING |  
|5   |  SALES     |  
+----+------------+   

```

output should be :- 

```
+-----+--------+--------+------+------+  
|Dname| Best    |Seond best |  Worst |  
+-----+--------+--------+------+------+  
|IT   |  40000  |30000  |10000        |  
+-----+--------+--------+------+------+    
|ADMIN| 50000   |   |50000        |   
+-----+--------+--------+------+------+  
|HR   | 70000   |60000  |60000        |   
+-----+--------+--------+------+------+  

```

we have to consider maximum,second maximum and 3 maximum salary from each department.