sql - Calculate percentage -


hi code gives me employee salaries , manager salaries.

select e.emp_fname manager, e.emp_salary, d.dept_no, a.emp_fname employee, a.emp_salary  employee e, employee a, department d  e.emp_nin = a.emp_manager  , a.emp_manager = d.emp_manager; 

![alt text][1]

how can show employees have salary within 10% of manager salary?

assuming want allow employees earning more managers (you know happen, in different, better world) include in clause:

and  a.salary between (e.salary * 0.9) , (e.salary * 1.1) 

edit

this uses simple mathematics. 0.9 = 90% , 1.1 = 110%; line restricts resultset employee records salary +/- 10% of manager's salary. if employees can never earn more manager need simpler greater test...

and  a.salary >= (e.salary * 0.9)   

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -