how to use distinct and sum together?
Posted by:
Leo xmccay
Date: March 04, 2012 07:29AM
Hi,
I tried to run this query but it doesn't seem to work. Can some guru assist me on this? thanks
$get_rating = mysql_query("select distinct sum(crating), sum(srating) FROM myscore where roundID ='12'") or die(mysql_error());
there are multiple records with roundID value 12 and some of the records will have the same crating and srating. What I want to accomplish is do not sum those records with the same crating and srating values.
e.g :
srating - crating - roundID
12 - 500 - 12
31 - 500 - 12
12 - 566 - 12
45 - 500 - 12
Final output I want is
total srating will be 12 + 31 + 45 ( the record with 12 will be excluded.)
same for total crating where 500 will be calculated once only 500+566
Please advise
Subject
Written By
Posted
how to use distinct and sum together?
March 04, 2012 07:29AM
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.