MySQL Practice Questions With Solutions
MySQL Practice Questions With Solutions
Easy Questions
1. Easy Question 1: Write a basic SELECT query to retrieve all rows from a table named 'students'.
2. Easy Question 2: Write a basic SELECT query to retrieve all rows from a table named 'students'.
3. Easy Question 3: Write a basic SELECT query to retrieve all rows from a table named 'students'.
4. Easy Question 4: Write a basic SELECT query to retrieve all rows from a table named 'students'.
5. Easy Question 5: Write a basic SELECT query to retrieve all rows from a table named 'students'.
6. Easy Question 6: Write a basic SELECT query to retrieve all rows from a table named 'students'.
7. Easy Question 7: Write a basic SELECT query to retrieve all rows from a table named 'students'.
8. Easy Question 8: Write a basic SELECT query to retrieve all rows from a table named 'students'.
9. Easy Question 9: Write a basic SELECT query to retrieve all rows from a table named 'students'.
10. Easy Question 10: Write a basic SELECT query to retrieve all rows from a table named
'students'.
'students'.
12. Easy Question 12: Write a basic SELECT query to retrieve all rows from a table named
'students'.
13. Easy Question 13: Write a basic SELECT query to retrieve all rows from a table named
'students'.
14. Easy Question 14: Write a basic SELECT query to retrieve all rows from a table named
'students'.
15. Easy Question 15: Write a basic SELECT query to retrieve all rows from a table named
'students'.
16. Easy Question 16: Write a basic SELECT query to retrieve all rows from a table named
'students'.
17. Easy Question 17: Write a basic SELECT query to retrieve all rows from a table named
'students'.
18. Easy Question 18: Write a basic SELECT query to retrieve all rows from a table named
'students'.
'students'.
20. Easy Question 20: Write a basic SELECT query to retrieve all rows from a table named
'students'.
Medium Questions
21. Medium Question 1: Write a query to find the second highest salary from the 'employees' table.
Solution: SELECT MAX(salary) FROM employees WHERE salary < (SELECT MAX(salary) FROM
employees);
22. Medium Question 2: Write a query to find the second highest salary from the 'employees' table.
Solution: SELECT MAX(salary) FROM employees WHERE salary < (SELECT MAX(salary) FROM
employees);
23. Medium Question 3: Write a query to find the second highest salary from the 'employees' table.
Solution: SELECT MAX(salary) FROM employees WHERE salary < (SELECT MAX(salary) FROM
employees);
24. Medium Question 4: Write a query to find the second highest salary from the 'employees' table.
Solution: SELECT MAX(salary) FROM employees WHERE salary < (SELECT MAX(salary) FROM
employees);
25. Medium Question 5: Write a query to find the second highest salary from the 'employees' table.
Solution: SELECT MAX(salary) FROM employees WHERE salary < (SELECT MAX(salary) FROM
employees);
26. Medium Question 6: Write a query to find the second highest salary from the 'employees' table.
Solution: SELECT MAX(salary) FROM employees WHERE salary < (SELECT MAX(salary) FROM
employees);
27. Medium Question 7: Write a query to find the second highest salary from the 'employees' table.
Solution: SELECT MAX(salary) FROM employees WHERE salary < (SELECT MAX(salary) FROM
employees);
28. Medium Question 8: Write a query to find the second highest salary from the 'employees' table.
Solution: SELECT MAX(salary) FROM employees WHERE salary < (SELECT MAX(salary) FROM
employees);
29. Medium Question 9: Write a query to find the second highest salary from the 'employees' table.
Solution: SELECT MAX(salary) FROM employees WHERE salary < (SELECT MAX(salary) FROM
employees);
30. Medium Question 10: Write a query to find the second highest salary from the 'employees' table.
Solution: SELECT MAX(salary) FROM employees WHERE salary < (SELECT MAX(salary) FROM
employees);
31. Medium Question 11: Write a query to find the second highest salary from the 'employees' table.
Solution: SELECT MAX(salary) FROM employees WHERE salary < (SELECT MAX(salary) FROM
employees);
32. Medium Question 12: Write a query to find the second highest salary from the 'employees' table.
Solution: SELECT MAX(salary) FROM employees WHERE salary < (SELECT MAX(salary) FROM
employees);
33. Medium Question 13: Write a query to find the second highest salary from the 'employees' table.
Solution: SELECT MAX(salary) FROM employees WHERE salary < (SELECT MAX(salary) FROM
employees);
34. Medium Question 14: Write a query to find the second highest salary from the 'employees' table.
Solution: SELECT MAX(salary) FROM employees WHERE salary < (SELECT MAX(salary) FROM
employees);
35. Medium Question 15: Write a query to find the second highest salary from the 'employees' table.
Solution: SELECT MAX(salary) FROM employees WHERE salary < (SELECT MAX(salary) FROM
employees);
36. Medium Question 16: Write a query to find the second highest salary from the 'employees' table.
Solution: SELECT MAX(salary) FROM employees WHERE salary < (SELECT MAX(salary) FROM
employees);
37. Medium Question 17: Write a query to find the second highest salary from the 'employees' table.
Solution: SELECT MAX(salary) FROM employees WHERE salary < (SELECT MAX(salary) FROM
employees);
38. Medium Question 18: Write a query to find the second highest salary from the 'employees' table.
Solution: SELECT MAX(salary) FROM employees WHERE salary < (SELECT MAX(salary) FROM
employees);
39. Medium Question 19: Write a query to find the second highest salary from the 'employees' table.
Solution: SELECT MAX(salary) FROM employees WHERE salary < (SELECT MAX(salary) FROM
employees);
40. Medium Question 20: Write a query to find the second highest salary from the 'employees' table.
Solution: SELECT MAX(salary) FROM employees WHERE salary < (SELECT MAX(salary) FROM
employees);
Hard Questions
41. Hard Question 1: Write a query to find all employees who earn more than the average salary.
Solution: SELECT * FROM employees WHERE salary > (SELECT AVG(salary) FROM
employees);
42. Hard Question 2: Write a query to find all employees who earn more than the average salary.
Solution: SELECT * FROM employees WHERE salary > (SELECT AVG(salary) FROM
employees);
43. Hard Question 3: Write a query to find all employees who earn more than the average salary.
Solution: SELECT * FROM employees WHERE salary > (SELECT AVG(salary) FROM
employees);
44. Hard Question 4: Write a query to find all employees who earn more than the average salary.
Solution: SELECT * FROM employees WHERE salary > (SELECT AVG(salary) FROM
employees);
45. Hard Question 5: Write a query to find all employees who earn more than the average salary.
Solution: SELECT * FROM employees WHERE salary > (SELECT AVG(salary) FROM
employees);
46. Hard Question 6: Write a query to find all employees who earn more than the average salary.
Solution: SELECT * FROM employees WHERE salary > (SELECT AVG(salary) FROM
employees);
47. Hard Question 7: Write a query to find all employees who earn more than the average salary.
Solution: SELECT * FROM employees WHERE salary > (SELECT AVG(salary) FROM
employees);
48. Hard Question 8: Write a query to find all employees who earn more than the average salary.
Solution: SELECT * FROM employees WHERE salary > (SELECT AVG(salary) FROM
employees);
49. Hard Question 9: Write a query to find all employees who earn more than the average salary.
Solution: SELECT * FROM employees WHERE salary > (SELECT AVG(salary) FROM
employees);
50. Hard Question 10: Write a query to find all employees who earn more than the average salary.
Solution: SELECT * FROM employees WHERE salary > (SELECT AVG(salary) FROM
employees);