vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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 ? thanks fyh joss |
| |||
| 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 |
| ||||
| On 2007-10-31 00:24:45 +0100, "Rik Wasmus" <luiheidsgoeroe@hotmail.com> said: > 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 ; thanks I did not know I could use your second proposition ..... ;-)) joss |
| Thread Tools | |
| Display Modes | |
|
|