Results 1 to 2 of 2

Thread: Sorting records

  1. #1
    Join Date
    Jun 2009
    Posts
    3

    Unanswered: Sorting records

    Who can help me ...

    I created a querry called " SCORES" with the following structure:

    POINTS | NAME | OPTION1 | OPTION2 | OPTION3

    8 | John | 2 | 1 | 3

    9 | Robert | 1 | 2 | 3

    10 | Willy | 3 | 1 | 2

    7 | Wu | 1 | 2 | 3
    and so on

    or otherwise

    POINTS | NAME | 1 | 2 | 3

    8 | John | OPTION2 | OPTION1 | OPTION3

    9 |Robert | OPTION1 | OPTION2 | OPTION3

    10 |Willy | OPTION2 | OPTION3 | OPTION1

    7 |Wu | OPTION1 | OPTION2 | OPTION3
    and so on

    where OPTION1, OPTION2 and OPTION3 with values 1, 2, 3 are the preferences of the candidates for the options with interest value of 1, 2 or 3.

    OPT1 has a maximum of X winners
    OPT2 has a maximum of Y winners
    OPT3 has a maximum of Z winners


    I want to order the candidate in the following way:

    Each candidate must be tested separately according to the score obtained and expressed choices, if it can occupy a place in the first option is taken, if in that option there are no longer places it must be tested if he can occupy a place on the second option, if there are places on this option he will be assigned to this option, and if there aren't any places it must be tested if he can occupy a place in the third.
    Just proceed with the next candidate and repeat the operations from the first option.

    Thank you anticipated for your help!

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by BravoEcho
    Just proceed with the next candidate and repeat the operations from the first option.
    SQL doesn't work like that, it operates on all rows simultaneously

    maybe you should do this logic in your application
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •