Exercise
-
Create a database named “employee”
-
Create the following tables inside the “employee” database
- department (department_id, department_name)
- department_id is the primary key
- employee (employee_id, employee_name, salary,department_id)
- employee_id is the primary key
- department_id is the foreign key that refers to department_id in the department table
-
Write Queries for the following -
- Write a Query that prints the following - employee_id, employee_name and department_name
- Write a Query that prints all the employees and their salaries in descending order of their salary
- Write a Query that prints the average salary of employees in each department with the department name.