MySQL Forums
Forum List  »  Newbie

Re: SUM problem.
Posted by: Patric Andersson
Date: March 13, 2009 07:10PM

Hmm... interesting... but that solution is made for 1 user with 10 scores.
However, now it's way over 100 users....

Is there any way you can put it into one select to actually "scroll" through all users, and sort it with that solution ?

Well, to show my current SELECT.

SELECT 
lepok_user.id AS userid, 
firstname, 
lastname,
type, 
lepok_torney.id, 
date, 
YEAR(date), 
YEAR(CURRENT_DATE()),
SUM(points), 
MAX(points), 
user, 
torney

FROM 
lepok_user, 
lepok_result, 
lepok_torney

WHERE 
lepok_user.id=user
AND 
typ='$pligan' 
AND 
lepok_torney.id=torney
AND 
YEAR(date)=YEAR(CURRENT_DATE())

GROUP BY 
lepok_user.id 

ORDER BY 
SUM(points) DESC, 
MAX(points) DESC
(I translated the names of the variables as I use swedish variable names and not english, so I might have made a type here in this code where I forgot a letter somewhere, but I hope you get the picture)



Edited 2 time(s). Last edit at 03/13/2009 07:33PM by Patric Andersson.

Options: ReplyQuote


Subject
Written By
Posted
March 12, 2009 03:29AM
March 12, 2009 09:52AM
Re: SUM problem.
March 13, 2009 07:10PM
March 13, 2009 11:10PM
March 14, 2009 04:01PM
March 14, 2009 06:40PM
March 15, 2009 07:54AM
March 15, 2009 10:41AM
March 15, 2009 10:35PM
March 16, 2009 09:33AM
March 16, 2009 09:52AM
March 16, 2009 02:46PM
March 16, 2009 04:15PM
March 17, 2009 02:11PM
March 17, 2009 05:03PM
March 17, 2009 06:31PM
March 17, 2009 10:17PM
March 18, 2009 06:03AM
March 15, 2009 05:41PM
March 15, 2009 07:14PM
March 16, 2009 08:34AM
March 18, 2009 12:52AM
March 21, 2009 05:58AM
March 21, 2009 11:13AM
March 22, 2009 05:01PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.