View Full Version : SQL Dual Sort?
mrbee2828
Jan 23rd 2006, 8:19 pm
I'm trying to sort records twice based on a vote average and second on the number of votes. I'd like to have a top 5 vote display. The issue is that I don't want an item that has 100 votes and an average of 4.9 to be second to an item that has 1 vote and an average of 5.0. Is this possible?
digitalpoint
Jan 23rd 2006, 8:20 pm
You probably are going to define some sort of weighting system for your sort since a straight sort wouldn't work.
mrbee2828
Jan 23rd 2006, 8:26 pm
Great.. does anyone have any idea how to do this? Is it done in the SQL statement or the DB?
vrsane
Jan 24th 2006, 12:53 pm
what database you are using ....?
T0PS3O
Jan 24th 2006, 1:07 pm
Easiest would be to include a treshold for the number of votes. If it's below 10 then don't use it. From there on the average becomes normalized and trustworthy. The actual figure depends on the average number of votes you get I guess.
mrbee2828
Jan 24th 2006, 8:07 pm
Thanks TOPS30, I think that's a pretty decent solution.. seems to work.
rembrandt
Feb 8th 2006, 5:10 pm
sort records using a union clause and order by your required fields
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.