/* ------------------------------------------------------------------------ */ /* Write and test the following queries ----------------------------------- */ /* ------------------------------------------------------------------------ */ /* You can use aggregate functions, e.g. MIN, SUM, COUNT. */ /* You might want to add records in the tables for testing correctness of your answers. Feel free to modify 'emp.sql'. */ /* 1. How many employees are there? */ /* 2. Find the average salary of employees who work in Dallas. */ /* 3. How many employees work on at least one project? */ /* 4. Which departments have at least two employees such that each of them is assigned to at least two projects? */ /* 5. What is the total yearly payroll (sum of 12 * monthly salaries)? */ /* 6. What is the average yearly payroll per department, including those with no employees? */ /* 7. Using regular expressions, list all projects with name containing the letter V (upper or lower case). Docs: https://www.postgresql.org/docs/current/functions-matching.html */ /* 8. List all projects with name starting with N, each of them with all employees assigned to it. */ /* 9. Which departments have at least one employee for each of the projects? */ /* 10. How many employees participate in all of the projects? */ /* 11. Find all departments such that each of their employees is assigned to a project. */ /* 12. Find tuples [D, J, Sum, Average] which, for each pair [D, J], state the sum of salaries and average salary of employees who work in department D and do job J. */ /* 13. Find the jobs with the maximal standard deviation of salaries. */ /* 14. For each employee, count the number of projects he works on. */ /* 15. Find employees working on all projects except exactly one. */ /* 16. How many times more does the president earn than the lowest-paid employee? */ /* 17. Find tuples [Y, N], where N is number of employees hired in the year Y (the resuslt contains only years when an employee was hired) */ /* 18. For each year since 1990, find number of employees hired in that year (the resuslt must contain also years when no employee was hired). Hint: use PostgreSQL function generate_series(). */