|
Home > Archive > Microsoft SQL Server forum > March 2006 > Update the salary of each manager to be double the average salary of the employees he/she manages
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Update the salary of each manager to be double the average salary of the employees he/she manages
|
|
| satish 2006-03-23, 7:38 am |
|
create table employee(empid int,empname varchar(20),manageri
d int not
null, sal int)
insert into employee values(1,'ranga',22,
5000)
insert into employee values(2,'satish',22
,8000)
insert into employee values(3,'sunil',11,
4500)
insert into employee values(4,'sridhar',2
2,2000)
insert into employee values(5,'ramesh',33
,12000)
insert into employee values(6,'srini',22,
16000)
insert into employee values(7,'sashi',33,
54000)
insert into employee values(8,'rajani',22
,71000)
insert into employee values(9,'praveen',1
1,6060)
insert into employee values(10,'bhaskar',
22,11120)
insert into employee values(11,'baba',33,
9000)
create table employment (managerid int,managername varchar(20),sal int)
insert into employment values(11,'rob',2500
)
insert into employment values(22,'babu',500
0)
insert into employment values(33,'ram',6000
)
now my problem is
Update the salary of each manager to be double the average
salary of the employees he/she manages
pls help
sati
| |
| markc600@hotmail.com 2006-03-23, 7:38 am |
|
UPDATE employment
SET sal=(
SELECT AVG(employee.sal)*2
FROM employee
WHERE employment.managerid=employee.managerid)
| |
| satish 2006-03-23, 7:38 am |
| thank u very much
| |
| Eric J. Holtman 2006-03-23, 8:34 pm |
| "satish" <satishkumar.gourabathina@gmail.com> wrote in
news:1143108467.298649.60900@j33g2000cwa.googlegroups.com:
>
>
> now my problem is
>
> Update the salary of each manager to be double the average
> salary of the employees he/she manages
>
> pls help
>
> sati
>
What are you going to do when you actually have to answer
this question on the exam, and you can't cheat using
the newsgroup?
|
|
|
|
|