/* 1. For each employee, find their order number according to their salary (salary column). Employees with the same salary should have the same order number. */ /* 2. For each employee, write the difference between his salary and the average salary in his department.*/ /* 3. For each employee, list the number of employees with a salary no higher than theirs. */ /* 4. For each employee, list his order number according to his salary within the employees from the same city, the difference from the average salary in the given city and the number of employees in this city.*/ /* 5. For each department, list the employee with the third-lowest salary (including all such employees if there are multiple).*/ /* 6. List the 20% of employees with the highest salaries.*/ /* 7. Find the median salary for each department. (https://wiki.postgresql.org/wiki/Aggregate_Median (how to) - Before the introduction of PERCENTILE_CONT in PostgreSQL 9.4 in 2014, computing the median was highly non-trivial.)*/ /* 8. For each employee, print the multiple of their salary against the median salary in their department. [The combination of percentile_cont and OVER is not supported in PostgreSQL.]*/ /* 9. List the employees whose salary is in the lowest quartile within their department.*/ /* 10. The company needs to save 8000 USD per month on salaries. Display the longest possible list of lowest-paid employees whose total salaries are less than 8000 (i.e., starting with the lowest-paid employee and ending with the employee whose salary, together with previous employees, is closest to 8000).*/ /* 11. Similar to the previous exercise, but we want to end just above 8000 (i.e. the list ends as soon as the sum of salaries exceeds 8000).*/ /* 12. For each employee, list their rank among employees from the same city (based on an alphabetical ordering of names), the difference from the average salary in that city, and the total number of employees in that city. */ /* 13. For each department, calculate the proportion of the department's total salaries accounted for by salaries that are below the overall median salary (not the median for the individual department). */