Re: select & sort on calculated value ... On Wed, 31 Oct 2007 00:14:54 +0100, Josselin <josselin@wanadoo.fr> wrote:
> I have a table 'posts' , each record has 2 fields 'post_count' and
> 'post_value'
>
> I would like to find all records, sorted on the calculated ratio value:
> 'post_value' / 'post_count'
>
> how can I write the select to get all records sorted on the calculated
> value ?
What have you tried?
Either:
SELECT post_count, post_value, post_count / post_value as 'ratio'
FROM posts
ORDER BY ratio;
Or, if you don't need the ratio column in the result:
SELECT post_count, post_value
FROM posts
ORDER BY post_count / post_value ;
--
Rik Wasmus |