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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find the Maximum of the sum of some fields.

Status
Not open for further replies.

ilmaggy

Programmer
Jan 4, 2005
11
NL
Hi,

I want to select the biggest result which I get by adding the fields named "vote" with the same user_id.
I thought of the following (but it didn't work out, unfortunately):

SELECT max(sum(rating)) FROM votes WHERE user_id = $user_id

Could anyone help me with this?
Thanking you in advance,
Ruben.
 
maybe i'm wrong but try this

SELECT sum(rating) AS Maxsum FROM votes WHERE user_id = $user_id GROUP BY user_id ORDER BY Maxsum DESC LIMIT 1

gry online
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top