• T.Ashish (4/4/2013)


    Hi All,

    I have attached two queries with table definition and sample data.

    Query 2 is working better then query 1.

    Now the actual question is:

    Should I follow query 2 in big and very complex queries?

    Is there any other better way to handle this type of scenarios?

    Thanks.

    What is the code supposed to be doing?

    Hard to tell you anything when we don't what it is you are trying to accomplish.

    In the first query the CTE selects one record then cross joins it to one hundred records from another table. The second query selects the top 1 record based on a value and includes it with 100 records from another table.

    In both queries there is no apparent relation between the two tables. And also, the value you are using in your queries doesn't exist in your data.