PostgreSQL EXAM
PostgreSQL EXAM
SECTION 2
Practical Exam Section: Make table corrections where necessary…..
CREATE TABLE Employees (
Employee id serial primary_key,
First_name varcha(50),
Last_name varchar(50),
Department varchar(50),
Position varchar(50),
Salary Numeric (10, 2),
Hire_date DATE,
Manager id INTEGER
);
1. Write an SQL query to retrieve all employee records from the employees table, sorted by hire_date in
descending order.
2. Write an SQL query to select all employees in the "Engineering" department who have a salary above 75,000.
3. Write an SQL query to list the first_name and last_name of all employees hired in 2020.
4. Write an SQL query to find the total number of employees in each department.
5. Write an SQL query to calculate the average salary of employees in the HR department.
6. Write an SQL query to display all unique positions available in the company.
7. Write an SQL command that updates the employee_id uniquely e.g. EMP0001.
8. Write an SQL command to insert a new employee record in the employees table with your own sample values.
9. Write an SQL query to limit the result to only the top 3 highest-paid employees.
10. Write an SQL query to select all employees but skip the first 2 records.
11. Write an SQL command to count the total number of employees who report to a manager.
12. Write an SQL command to add a new column named email to the employees table.
13. Write an SQL command to grant SELECT and INSERT permissions on the employees table to a user named
data_user.
14. Write an SQL command to revoke the INSERT permission on the employees table from the user data_user.
15. Write an SQL command to drop the employees table from the database.