Page 1 of 1

Order by Desc

Posted: Sun Jul 10, 2011 4:47 am
by shafiq2626
Hi
I want to display my records order by DESC but I have problem
my query is

Code: Select all

$gamesqry="select team.*,sum(scores.score) as score from tbl_teams team,tbl_result scores where scores.team_id=team.team_id group by team.team_id order by scores.score DESC";
and this dispaly records like that

China 6
Danish 3
Italy 4
English 2
Argentine 0

It must show

China 6
Italy 4
Danish 3
English 2
Argentine 0

Please help what is wrong
thanks

Re: Order by Desc

Posted: Fri Sep 02, 2011 11:17 pm
by 2-d
Hello,

Can we see an example of your table structure and some entries to see why that query is displaying the order incorrectly?

Thanks

Re: Order by Desc

Posted: Mon Sep 05, 2011 1:57 am
by manohoo
try this:

Code: Select all

$gamesqry="
   SELECT team.*,  sum(scores.score) as score
   FROM tbl_teams team, tbl_result scores
   WHERE scores.team_id = team.team_id 
   GROUP BY team.team_id 
   ORDER BY sum(scores.score) DESC";