How to update the database?
I have two tables:
emp(employee_no, ename, job, manager_no, hiredate, sal, comm, deptno)
dept(deptno, dname, location)
The manager_no is the manager who manage that employee, and manager is also
a employee in the emp table.
Q. How can I give all managers a commission(comm) equal to 10% of the sum
of salaries of employees they directly manage. Update the emp table accordingly.
Q. How can I add a new column No_Of_Emp to the dept table, and store in it
the number of employees in the corresponding department by using update.
Re: How to update the database?
Welcome to the world of hierarchies! SQL (the language) does not handle them
I've got a couple of resources that you should check out:
Joe Celko's SQL For Smarties book; Ben-Gan had an article in SQL Server Mag.
that discussed handling hierarchies like this; and David Rozenshtein et al,
put together a little booked called Tree Processing in SQL.
Michael Levy MCDBA, MCSD, MCT
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center