How to divide results into two somewhat-equal piles?

  • Jeff Moden (8/9/2009)


    Beverley (8/9/2009)


    Thanks so much for the replies, guys! I'm on holidays for a week but will try these out when I get back!

    Perfect! Hey guys... I've got this really nasty problem... would you do all my work for me so I don't have to worry about it when I go on holiday next week? Thanks so much! 😛

    LMAO!!!

    Y'all can look forward to a bunch of posts from me when I take a holiday later this year!

    (@Beverley: Jeff is kidding)

  • Paul White (8/9/2009)


    (@Beverley: Jeff is kidding)

    Heh... not quite. 😉

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Jeff Moden (8/9/2009)


    Paul White (8/9/2009)


    (@Beverley: Jeff is kidding)

    Heh... not quite. 😉

    I stand corrected! :w00t:

  • Sorry folks... I'm just a bit sour on things like this. We had one guy at work that would get other people to help him do his work while he basically sat on his fists and used his thumbs as a back rest... so he could go home at 4. He became the victim of some really high velocity pork chops.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • I should just take a long vacation and send all my problems to you guys. The quality AND quantity of my throughput would probably go up. 😛

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • Wow, Jeff. Way to make someone feel really good.

    I had about a day to get this working before I went on a week off due to the fire situation in my province going suddenly totally insane (our worst year in the 12 years I've been working here - houses have burned down and at least one person has died) and needed to get it done fast. The initial replies got me most of the way there, and I implemented it and hoped for the best, but I could see the one limitation about it not having the ability to keep the categories together. I asked for more help which was very kindly given but unfortuantely too close to the end of my day to take a risk at implementing a change and then leaving it for a week so I expressed my appreciation quickly so they would know it had been received and appreciated.

    Yours was such a great response to come back to. When the other person said you were kidding I felt better for a second but then saw your followup confirming you meant to be rude.

    Remind me never to ask for help when in need again, someone might get offended that I don't know everything about SQL and don't have anyone else in my organization to ask.

    If you look at my original question, you'll see I never asked for a delivered solution. I asked to be pointed in the right direction. It's very difficult to find a way to do something in the help file if you don't know the name of a function to look up.

  • Here's what you said, Beverly...

    Thanks so much for the replies, guys! I'm on holidays for a week but will try these out when I get back!

    Think about it... based on that statement, what I said was not rude. 😉

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Jeff Moden (8/17/2009)


    Here's what you said, Beverly...

    Thanks so much for the replies, guys! I'm on holidays for a week but will try these out when I get back!

    Think about it... based on that statement, what I said was not rude. 😉

    Perhaps I should have said something more like "I have spent 6 or 8 hours working on this problem in the past day and a half, and have it working in a stable manner and don't want to take any chances of breaking it as I only have an hour or two left before the end of the day. I will spend some more time looking at this when I return."

    Would that have made you happier?

    Don't bother answering that. I'm not going to waste any more of my time thinking about your response. I have more important things to do.

  • Scott Coleman (8/7/2009)


    Some problems call for an actual algorithm that can't be expressed in a single query. You might consider doing the column split in your web code instead of trying to do it in T-SQL, but it can be done. This code splits the sample data into two columns by assigning each group (in descending group size order) to the shortest column.

    I've now had a chance to go through each of the posts carefully and understand how everyone was approaching the problem. Scott, your solution makes a lot of sense to me. The list of fires has changed significantly in the past week (down to 33 now) and when I tried it with the new list it came out to 16 in col1 and 17 in col2, so that's fabulous. I added a line to reverse them if the first column is shorter (just for looks)

    Thank you so much to everyone who took some time to help me out. I've learned some functions I hadn't seen before!

  • Beverley,

    I just had a coworker send me this link today - http://www.dailymail.co.uk/news/worldnews/article-1204394/Take-seats--The-jaw-dropping-row-spectacle-wildfire-devours-Canadian-mountains.html And coincidentally, almost immediately after reading the article, I came across this thread. My heart goes out to everyone in your area dealing with this problem.

  • Beverly,

    I guess it's a difference in language... In the absence of anything else, I erroneously took your saying you were going on "holiday" to mean on "vacation". Like I said, I've had several bad bouts with folks at work doing that same thing but for real. I was so ticked about it that I never got past the first sentence of your reply. I didn't realize that your "holiday" was forced time off due to the fire situation.

    My most sincere apologies and I hope that all whom you know are safe and sound.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 11 posts - 16 through 25 (of 25 total)

You must be logged in to reply to this topic. Login to reply