Order by Desc

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
shafiq2626
Forum Commoner
Posts: 88
Joined: Wed Mar 04, 2009 1:54 am
Location: Lahore
Contact:

Order by Desc

Post 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
2-d
Forum Newbie
Posts: 6
Joined: Fri Sep 02, 2011 9:50 pm

Re: Order by Desc

Post 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
User avatar
manohoo
Forum Contributor
Posts: 201
Joined: Wed Dec 23, 2009 12:28 pm

Re: Order by Desc

Post 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";
Post Reply