This table, it is necessary with the help of the window function, it is necessary to show what percentage of the total salary in the department (job) is the salary of each employee
name | job | salary -----------+---------+-------- Joe | develop | 2500 Connor | manager | 3500 Callum | sales | 1400 Kyle | develop | 1200 Jacob | sales | 950 John | manager | 1300 It should go like this
name | job | salary | percent -----------+---------+--------+--------- Joe | develop | 2500 | 67% Kyle | develop | 1200 | 33% Connor | manager | 3500 | 73% John | manager | 1300 | 27% Callum | sales | 1400 | 59% Jacob | sales | 950 | 41% My option, but nothing works.
SELECT name, job, salary, percent(sum(salary)*100/salary) OVER (PARTITION BY job) FROM emp;
(sum(salary) OVER (PARTITION BY job)) *100/salary as percent- Mike