How to retrieve a row, biased by populatity?
David Hodgkinson
davehodg at gmail.com
Wed Aug 22 10:15:57 BST 2012
On 21 Aug 2012, at 21:54, Fahad Khan <fahad.aj.khan at gmail.com> wrote:
> On Tue, Aug 21, 2012 at 9:22 PM, Dave Hodgkinson <davehodg at gmail.com> wrote:
>
>>
>> Possibly a perl question. SQL would do...
>>
>> Given a set of data, say bands, with each having a ranking, either a
>> review metric or a sales ranking, how would you retrieve a random
>> row, but biased towards the higher ranking?
>>
>>
> SELECT * FROM band ORDER BY ranking - RAND() * $BIAS DESC LIMIT 1;
>
> Fahad.
I like this one best. I know I have 850k rows, just pick the n'th on
some form of log curve.
More information about the london.pm
mailing list