Grouping problem

  • Jeff Moden (6/21/2009)


    WayneS (6/20/2009)


    You used: ROW_NUMBER() OVER(ORDER BY Seq)It is producing the same thing as the Seq column by itself. Is there a reason why you went through the trouble to use the code you did instead of the column?

    In this case it is. There's no guarantee that no deletes will have been done on the source table in real life. Better to be safe by including the ROW_NUMBER to guarantee the proper operation.

    Ahh, yes. Makes sense.

    forest..... trees.....

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2

  • Jeff Moden (6/21/2009)


    WayneS (6/20/2009)


    Jeff Moden (6/20/2009)


    BWAA-HAAA!!!! I felt exactly the same way waiting for the folks at work to do an upgrade (they're still not there). I finally broke down in Dec 2007 and bought a copy of the Developer's Edition just so I could try to keep up with the rest of the world.

    And have you since bought the 2008 Dev Edition? 😉

    Nope... not yet.

    Aw, come on Jeff. It's only $50, less at some of the online places if you look around. I'll probably spend that much buying your book when it comes out.

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2

  • Ok, guys. Here's the progression ...

    - Google: nope

    - MSDN Help on Ranking functions: nope

    - Experts Exchange: nope

    - Start to write some God-awful RBAR code: hear mental admonishment from Jeff

    - Search SQL Server Central: BINGO!!!

    And it works over 7M rows like a charm!

    You guys are awesome!

    Kevin

    --
    Please upgrade to .sig 2.0

  • knechod (1/4/2011)


    Ok, guys. Here's the progression ...

    - Google: nope

    - MSDN Help on Ranking functions: nope

    - Experts Exchange: nope

    - Start to write some God-awful RBAR code: hear mental admonishment from Jeff

    - Search SQL Server Central: BINGO!!!

    And it works over 7M rows like a charm!

    You guys are awesome!

    Kevin

    Heh... ya gotta love one stop shopping, Kevin. 😀 Start here next time. 🙂

    --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)
    Intro to Tally Tables and Functions

Viewing 4 posts - 16 through 18 (of 18 total)

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