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
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL