Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
KK_Disco
Starting Member
1 Post |
Posted - 2009-04-05 : 05:50:50
|
| Is it possible to make the following statement into only 1 select statement? select last_namefrom employeeswhere salary < ( select avg(salary) from employees); |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-04-05 : 11:23:59
|
no No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
darkdusky
Aged Yak Warrior
591 Posts |
Posted - 2009-04-06 : 05:01:18
|
| Yes it's possible - here is one way - I'm sure some-one will probably show a better one.select last_name,salary, AvgSalaryfrom(SELECT last_name,avg(salary) over (partition by 1)as AvgSalary,salaryFROM employeesgroup by last_name,salary) as Empwhere salary < AvgSalary |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-04-06 : 05:29:21
|
quote: Originally posted by KK_Disco Is it possible to make the following statement into only 1 select statement? select last_namefrom employeeswhere salary < ( select avg(salary) from employees);
Why?MadhivananFailing to plan is Planning to fail |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-04-09 : 09:38:18
|
quote: Originally posted by darkdusky Yes it's possible - here is one way - I'm sure some-one will probably show a better one.select last_name,salary, AvgSalaryfrom(SELECT last_name,avg(salary) over (partition by 1)as AvgSalary,salaryFROM employeesgroup by last_name,salary) as Empwhere salary < AvgSalary
Hi darkdusky,this is not what I call "only 1 select statement".GreetingsWebfred No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-04-10 : 06:28:14
|
| is this an interview question? |
 |
|
|
tosscrosby
Aged Yak Warrior
676 Posts |
Posted - 2009-04-10 : 12:25:11
|
quote: Originally posted by visakh16 is this an interview question?
Sure smells like it.......Terry-- Procrastinate now! |
 |
|
|
|
|
|
|
|