Thursday, February 3, 2011

challenging SQL queries

Recently got chance to work on a typical query. Sql query was find out second highest salary of employee without using max ? I think you guys are aware oracle default employee and department tables. so after some brainstorming finally got cool solution.
Here i am mentioning few more queries for fun. Hope you will enjoy.

1. display the all employees whom salary is greater than average salary of their own department and average salary if their department should be greater than the highest salary of department that has lowest no of employee?
2. display department wise first three highest salary ?
3. display 3rd lowest paid salary got employees detail ?
4. display the details of lowest paid manager ?
5. display the details of employees who having highest salary in diff dept ?
6. display the details of employee to whome max numbers of employees reporting ?
7. display the details of having highest salary details belonging department having highest no of employees ?
8. display the details employees if department have highest no of employees ?
9. select highest salary without using max ?

If you have any devastating query , you can post here.