• SQL_By_Chance (1/10/2012)


    G,

    your query has 2 input tables but if you check CTE it is taking input from the same table.

    On the first thought, I too thought of using a function and applying it to outer query but that was degrading performance.

    Regards,

    Ankit

    What function? My query doesn't use a function. It uses an inline derived table.

    As for two tables vs one, a Distinct operator on one table will be more expensive than a query of a table that has the aggregate-base properly normalized, unless we're talking about very small datasets.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon