1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

SQL Dual Sort?

Discussion in 'Databases' started by mrbee2828, Jan 23, 2006.

  1. #1
    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?
     
    mrbee2828, Jan 23, 2006 IP
  2. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #2
    You probably are going to define some sort of weighting system for your sort since a straight sort wouldn't work.
     
    digitalpoint, Jan 23, 2006 IP
  3. mrbee2828

    mrbee2828 Peon

    Messages:
    44
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Great.. does anyone have any idea how to do this? Is it done in the SQL statement or the DB?
     
    mrbee2828, Jan 23, 2006 IP
  4. vrsane

    vrsane Active Member

    Messages:
    465
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    60
    #4
    what database you are using ....?
     
    vrsane, Jan 24, 2006 IP
  5. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #5
    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.
     
    T0PS3O, Jan 24, 2006 IP
    digitalpoint likes this.
  6. mrbee2828

    mrbee2828 Peon

    Messages:
    44
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thanks TOPS30, I think that's a pretty decent solution.. seems to work.
     
    mrbee2828, Jan 24, 2006 IP
  7. rembrandt

    rembrandt Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    sort records using a union clause and order by your required fields
     
    rembrandt, Feb 8, 2006 IP