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 |
|
antgaudi
Starting Member
4 Posts |
Posted - 2009-04-19 : 16:15:06
|
| I have the following code:select pil_pilotname, pil_flight_payfrom pilotsgroup by pil_pilotname, pil_flight_payhaving pil_flight_pay > 2586.67/I wanted to use avg(pil_flight_pay) instead of 2586.67. SQL, however, does not allow.I'm trying to get the flight pays that exceed the average flight pay for all pilots.What should I modify?Thanks. |
|
|
nathans
Aged Yak Warrior
938 Posts |
Posted - 2009-04-19 : 16:39:21
|
You can move into subquery:select pil_pilotname, pil_flight_payfrom pilotswhere pay > (select avg(pil_flight_pay) from pilots) Nathan Skerl |
 |
|
|
nathans
Aged Yak Warrior
938 Posts |
Posted - 2009-04-19 : 16:44:54
|
| Just realized you ref SQL Plus... this is a MSSQL forum, though I believe the tsql I posted will work in Oracle as well :) |
 |
|
|
antgaudi
Starting Member
4 Posts |
Posted - 2009-04-19 : 18:24:13
|
It worked! Thanks! |
 |
|
|
|
|
|