• SQL_FS (10/1/2013)


    I think people are misunderstanding, allow me to clarify. I'm not trying to ask whether or not using ORDER BY [Column Position] is bad form or not. I merely pointed out the "feature" of using ORDER BY [Column Position] to illustrate how reading that code is similar to reading the code of my CASE statement in the ORDER BY clause. My question is relating to people's opinion of using the CASE statement in the where clause versus the subquery/cross apply solution.

    Understood. But, because you wrote the following in your original post...

    Well, something I learned when studying for my Querying SQL Server 2012 exam, which I passed a couple months back (hooray), was that there is an alternate [font="Arial Black"]acceptable syntax in the ORDER BY clause[/font], so this query is functionally identical to the previous one.

    SELECT string, category FROM @SampleData ORDER BY 1 ASC

    ... I thought Id stress that ordinal ORDER BYs do not constitute "acceptable syntax" other than the fact that it unfortunately works.

    --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)