Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding average, flooding table

Status
Not open for further replies.

chris921

Technical User
Mar 9, 2004
82
GB
Hiya,

I was wondering if its possible to find the average price (in my case the average price of footballers sold per football team) and sort it so I can say the average price sold per player at Man United is £11,000,000 or something?

I want to create a new column called average price and put it in there if possible, ive created the column, I can find the average price, but I cant get the two to link together, can someone please explain how?

Cheers,

Chris
 
It would have been nice if you had posted the code you tried that didn't work.

Try this:

Code:
UPDATE TABLE1
SET    average = (SELECT AVG(price) 
                  FROM   TABLE1 AS T2
                  GROUP BY team)
FROM   TABLE1 AS T1
WHERE  T1.id = T2.id ;

If this doesn't work, try something different.



On the other hand, you might always try punching it through a chaos engine...

________________________________________________
Constructed from 100% recycled electrons.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top