I have a database with identical entries, i know that using 'DISTINCT' in my query will return one of those identical rows.
If for example 'HRS' is a column in mysql, and once the query (using Distinct) is completed, how can i add the values of 'HRS'?
I have already tried 'Sum(HRS) as TOTAL', but that returns the sum of all the values within 'HRS' in mysql database whereas i am after the sum of all the values 'TOTAL' within 'HRS' as returned by query below.
$query=mysql_query("select distinct sum(HRS) as TOTAL, HRS from mytable group by something");
while($res=mysql_fetch_array($query)){
$total=$res['TOTAL'];
$hrs=$res['HRS'];
}
Can $hrs be totalled in PHP after the query returnsthe results, and how, or is it better to do in mysql but how???
Any help would be appreciated.
seno
😕