Advertisement
AmidamaruZXC

Untitled

Oct 25th, 2020
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 1.47 KB | None | 0 0
  1. 1select hre.*, to_char(hre.salary * 1.0 / max(salary) over (), '0.99') as ans from hr.employees hre
  2. 2select hre.*, to_char(hre.salary * 1.0 / (AVG(hre.salary) over(PARTITION BY hre.department_id)), '0.99') as ans from hr.employees hre
  3. 3select hre.*, (avg(hre.salary) over (partition by hre.department_id)) as avg_sal_dep, (avg(hre.salary) over (partition by hre.job_id)) as avg_SAL_JOB, avg(hre.salary) over (partition by hre.department_id) / avg(hre.salary) over (partition by hre.job_id) as ans  from hr.employees hre
  4. 4select employee_id, first_name, last_name, email, phone_number, hire_date, job_id, salary, commission_pct, manager_id, department_id from (select hre.*, min(salary) over (partition by department_id order by last_name) minsal, first_value(last_name) over (partition by department_id order by last_name) lname from hr.employees hre) where minsal = salary and lname = last_name
  5. 5select man_id, division, score from (select man_id, division, score, row_number() over(partition by division order by score desc) r from (select employee_id as man_id, department_id as division, salary as score from hr.employees)) where r < 3
  6. 6select employee_id, first_name, last_name, email, phone_number, hire_date, job_id, salary, commission_pct, manager_id, department_id, salary - avgsal as ans from (select t.*, avg(salary) over (partition by round(5 * r / cnt)) as avgsal from (select hre.*, row_number() over (order by last_name) as r, count(*) over() as cnt from hr.employees hre) t)
  7.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement