Re: sorting the average

From: Date: Sat, 24 Aug 2002 00:55:56 +0000
Subject: Re: sorting the average
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-21332@lists.php.net to get a copy of this message
Why not show the complete SELECT? Why are you trying to have two fields with the same name? Have you tried this at the mysql console? Just to double-check, that second line returns a value of 3 if the average of article_comment.vote is null. Have you tried GROUP BY in place of ORDER? Just some thoughts - Miles On Friday 23 August 2002 09:46 pm, JJ Harrison wrote: > I have these two lines in my SELECT clause thingy: > > avg(article_comment.vote) as avg, > IFNULL(avg(article_comment.vote), 3) as avg > > when I sort the later with this: > > order by avg desc > > It only sorts the ones with an average rating take from > article_comment.vote. > > The ones with no votes just stay at the top no matter wheather I say: order > by avg desc or: order by avg asc. > > When I swap them the ones at the bottom will switch into the right order.

« previous php.db (#21332) next »