Results 1 to 7 of 7
  1. #1
    Join Date
    Sep 2003
    Posts
    522

    Unanswered: computation and promutation

    i am trying to set up a quick and dirty, but efficient way to calculate permutation and combination. anyone out there dealt with this?

  2. #2
    Join Date
    Sep 2003
    Posts
    522
    any takers?

  3. #3
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    The method depends on what kind of permutations you want to do.

    Given N objects in X different positions, do you want to allow repetitions? Do you want to include permutations with less than X values?

    There are formulas available that will calculate these. Excel actually has some good statistical functions that not only do the calculations, but the help file does a good job of explaining the formula used. You might run a couple test on a spreadsheet until you are sure what kind of permutation you want, and then port the formula from Excel's help file into a TSQL statement.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  4. #4
    Join Date
    Sep 2003
    Posts
    522
    ok, it's been awhile, and i barely passed it, but knowing the total number (9999), what is the n in this combination formula:

    9999 = n! / (4!(n-4)!)

  5. #5
    Join Date
    Sep 2003
    Posts
    522
    never mind, it doesn't jive, back to the drawing board

  6. #6
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    N is the number of items, and I believe 4 is the number of locations.

    N! is N Factorial, which SQL Server does not have as a standard function, but is simply 1*2*3*4*5...*N, so you could write the function easily enough.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  7. #7
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    ...and 9999 factorial would be HUGE! We're way beyond "grains of sand" and into "atoms in the universe" here...
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

Posting Permissions

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