• S_Kumar_S (8/21/2012)


    But the results of this and previous query doesn't match. Seems ordering on different column changed the results.

    The results will differ if any of the DIM... tables introduce more than one row per row in dbo.FactFares. Without data to analyse, it's impossible for me to say. You will have to look into this. If you need some help, try picking up say the first 50 rather than the first 10, from both queries, and posting here.

    “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden