Forum Replies Created

Viewing 15 posts - 31 through 45 (of 76 total)

  • RE: Sum DISTINCT fields only

    DROP TABLE #T;

    CREATE TABLE #T(Col1 INT)

    INSERT INTO #T

    SELECT 1 UNION ALL

    SELECT 1 UNION ALL

    SELECT 2 UNION ALL

    SELECT 3 UNION ALL

    SELECT 4 UNION ALL

    SELECT 1

    --SELECT SUM(DISTINCT(Col1)) AS 'Sum of distinct values',SUM(Col1)...

  • RE: Aggregate Query question

    Here's the entire SQL set that solves the challenge using negation. SW1.doc and SW2.doc are separated versions of the previous attachment. I can now process the entire set in under...

  • RE: Aggregate Query question

    For those who want to explore this a bit further, I'm attaching the SQL that JC provided to create the 'Sweden' table, and a 'Map' table to associate all old...

  • RE: Aggregate Query question

    FWIW, with some interesting results, I did solve the challenge, but ironically, it was with my original SQL on a screaming database server using the divide and conquer method. What...

  • RE: Aggregate Query question

    >>Les - One other thing. Would you mind posting your final row counts (input and output), CPU and elapsed times to solution?

    Will do. It's still running. If it doesn't...

  • RE: Aggregate Query question

    After putting the route issue to bed, I was mulling over how well this performed. So, to escalate its application, I tossed this at the Jan. '98 Dr. Dobbs...

  • RE: Aggregate Query question

    Thanks folks. Brilliant! It made mincemeat out of the Route problem. It worked so well though that I'm now tossing it at a much bigger NP problem that we attempted...

  • RE: Aggregate Query question

    Sheesh...quite the brain trust up here. It's going to take me a bit to wade through these. I'll report the results after I come up for air 🙂

    ~Les

  • RE: Aggregate Query question

    Chris,

    Oddly...I haven't seen that one. Any idea where I might track it down?

    ~Les

  • RE: Aggregate Query question

    So, the permutation count for David's scenario is 50*49*48*47*46 = 50!/45! = 254,251,200

    That would leave 120 (5*4*3*2*1) permutations for each distinct combination, so the combination count = 50!/(45!*5!) = 2,118,760...

  • RE: Aggregate Query question

    >>Is there adjacency data missing from the description?

    The adjacencies have already been resolved.

    Thx,

    ~Les

  • RE: Aggregate Query question

    >>And so, a link to Hugo Kornelis's bin packing series, which may spark an idea or 2.

    Thanks. It does have similarities. I'll have to give it a thorough read.

  • RE: Aggregate Query question

    Lynn,

    It's a redistricting (route) requirement, where we're looking to contain each district to roughly the same number of meters (service locations). Urban growth and all that.

  • RE: Aggregate Query question

    >>All the possible combinations of those rows that added to 5?

    All the possible DISTINCT combinations.

    ~Les

  • RE: Aggregate Query question

    G[]...

    I'd come to the same conclusion, but thought it might be worth a toss up here. I thumbed through all of Celko's books, but nothing jumped out. Intuitively I think...

Viewing 15 posts - 31 through 45 (of 76 total)