1.

SQL Query to find min, max and average salary from a table?

Answer»

Suppose ASSUME the table is in the format shown below,:

Employee table:

NameSalary
Ravi25000
Sunil12000
Tarak95000

To FIND the maximum salary,

SELECT MAX(Salary) from Employee; // To just get the max salarySELECT * from Employee where Salary = (SELECT MAX(Salary) from Employee); // Employees with highest salary

To find the average salary,

SELECT AVG(Salary) from Employee;

To find the MINIMUM salary,

SELECT MIN(Salary) from Employee; // To just get the min salarySELECT * from Employee where Salary = (SELECT MIN(Salary) from Employee); // Employees with lowest salaryUseful Interview Resources
  • Free Mock CODING Interview
  • DSA Tutorial
  • Coding Interview Questions for Practice
  • Technical Interview Questions for Practice
  • Interview Preparation


Discussion

No Comment Found