• shani19831 (8/6/2013)


    Hi

    Thanks for the query, its returning what i want, but i have never used CTE and have no knowledge of it, guess its time to learn.

    is there no easy way of doing it instead of the way you did it cause its so complicated.

    How easy is it, say i want to join other tabes to ln and dp tables in order to display other information?

    The reason is, i need extra information but its hosted in other different tables that i normally join to ln or dp.

    Thank you in advance

    Unless you get into recursive CTE's just think of a CTE as a sub-query in the FROM clause (known as a derived table) except it's not in the FROM clause. It's still just a "derived table" or "inline view" just like a sub-query in a FROM clause.

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