Correlated subquery examples

 Correlated Subquery example and interview questions

Basics Questions

  1. What is correlated subquery. 
  2. What is the difference between correlated subquery and normal subquery. 

Employee Table :


Department Employee Salary
IT Aditya 5000
IT Joseph 5500
IT Arya 6500
SALESRamu 8000
SALES Geeta 7500
SALES Rita 10000
SALES Pushpendra 11000

Queries on above table

  1. From the above table find the employees whose salary is greater than the average salary of department. 
  2. Display the employees who are not earning the minimum salary in each department. 
  3. Display the top 2 salary holder employee details in each department. 
  4. Display bottom 2 salary holder employee details in each department.
  5. Display the employees with their salary difference with department average. 

Note :- Correlated subquery can be part of select or where condition and the two queries. 

No comments:

Post a Comment

Write a python program to find factorial of a number ?

Factorial  When we recursively multiply number incrementing from 1 to a given number then its called factorial of that number. We use the no...