Hello experts!

This is a knotty one that I've been puzzling over for some time.

I have a selection of users some of which are online and some of which are not. I can easily pull lists of users who are online (last seen in the last 20 minutes), and users who are offline and random users who may be online or offline.

Trouble is that there are *many* more users who are offline than online.

Is there any way to weight the query to make it more likely that an online user would appear in the selected batch? A selection doesn't *have* to have an online user every time, but it would good if they could pop up a bit more often.

With the current (simplified) select below you'd be lucky to see an online user in 20 or more batches. It would be nice to see an online user every 2 or 3 or more often if more are online.

Here's where I'm at so far...
(UNIX_TIMESTAMP(now()) - UNIX_TIMESTAMP(lastseen))/60 as timeon
from users
left join lastseen on users.userid=lastseen.userid
order by rand()
limit 0,20
Also the ordering by rand() is going to become an issue as the database grows so any hints on that too would help!

Many thanks in advance for any pointers.