MYSQL exercises
Sub-queries and grouping
Use the school database for the following questions
1. Find instructors whose salary is greater than average salary. Show instructor name and salary on
your result. Order the result by salary from highest to lowest (using sub-queries)
2. Select department name of all departments whose number of courses are greater than 2. Order
by the number of courses in descending order
3. Find instructors (instructor name) whose salary are either 30,000 or 15,000 without using logical
operators
4. Find instructors (name and salary) whose salary is greater than the minimum salary
Join operations
5. Show all instructors (instructor name) and year who have taught courses in 2016
6. Find all instructors (instructor name, department name and semester) who have taught in first
semester and are from electrical department
7. Find all courses (course name, department name, semester) that are given in SECE in second
semester
8. Select the instructor ID and the number of courses thought by each instructor
Procedures and functions
9. Create a function that computes the bonus of each instructor, the bonus is 30% of the salary
10. Write a stored procedure that is used to insert information on course table