• I really liked it, so my second response !

    Sergiy (3/17/2013)


    Lynn Pettis (3/17/2013)


    Really, CTEs are

    complex? I find them to make writing queries easier as you don't have to write derived tables.

    🙂

    Let's compare:

    ;WITH MyData AS (

    SELECT TOP 2 *

    FROM dbo.NFFeeds

    ORDER BY id DESC

    )

    SELECT * FROM MyData

    ORDER BY id

    VS.

    SELECT * FROM (

    SELECT TOP 2 *

    FROM dbo.NFFeeds

    ORDER BY id DESC) MyData

    ORDER BY id

    Derived table wins as it does not contain extra words ";WITH MyData AS ".

    Apparently, CTE's are more complex comparing to derived tables.

    😎

    I want to be part of your competition. So, my version wins over yours one as it contains less number of characters:

    SELECT * FROM (SELECT TOP 2 * FROM dbo.NFFeeds ORDER BY id DESC) m ORDER BY id

    It wins as:

    1. It has less New Line characters

    2. It doesn't have tabs (or extra spaces) for indent

    3. Most important one - my alias "m" is 7 (seven!) times shorter than yours one "MyData"!

    May I have a medal now?

    :hehe::hehe::hehe::hehe::hehe:

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]