April 10

More frequently asked MySql query interview questions

As per My experience, i found some of MySQL queries are repeat in interview questions, ans they are as follows;

 

1: Query to find second highest salary of Employee

select MAX(Salary) from Employee WHERE Salary NOT IN (select MAX(Salary) from Employee );

2: SQL Query to find Max Salary from each department

SELECT DeptID, MAX(Salary) FROM Employee GROUP BY DeptID.

3. Write an SQL Query to find employee whose Salary is equal or greater than 10000.

SELECT EmpName FROM Employees WHERE Salary>=10000;

4. Write an SQL Query to find name of employee whose name Start with ‘M’

SELECT * FROM Employees WHERE EmpName like ‘M%’;

5. find all Employee records containing the word “Joe”, regardless of whether it was stored as JOE, Joe, or joe.

SELECT * from Employees WHERE UPPER(EmpName) like ‘%JOE%’;

6. Write a SQL Query to find year from date.

SELECT YEAR(GETDATE()) as “Year”;

 

Category: MySQL | LEAVE A COMMENT