CTE

  • in Which Sensory we use CTE

  • You might want to start by reading this:

    http://www.4guysfromrolla.com/webtech/071906-1.shtml

    and then if you have specific questions ask those questions in a new posting.

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • coolrana.kumar69 (9/7/2013)


    in Which Sensory we use CTE

    I use CTEs now routinely instead of using sub-queries. Just a new way of doing it that seems more clear and structured to me.

    So, instead of:

    SELECT

    r.Val

    FROM

    someTable AS r

    WHERE

    r.Val IN

    (SELECT foo FROM someOtherTable)

    Using CTE:

    WITH

    cteTest (foo)

    AS (

    SELECT foo FROM someOtherTable

    ),

    cteResult (val)

    AS (

    SELECT

    r.val

    ,t.foo

    FROM someTable AS r

    INNER JOIN cteTest AS t

    ON r.val = t.foo

    )

    SELECT * FROM cteResult

    CTEs can also be written to do recursive queries and that is a more complex subject.

     

Viewing 3 posts - 1 through 2 (of 2 total)

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