Are these two sql statements the same (northwind)?

  • Are both sql statements below functionally the same thing? Is one better than the other?

    -- cut here --

    USE NORTHWIND

    GO

    SELECT SUM(Discount)

    FROM [ORDERS] X INNER JOIN [ORDER DETAILS] Y ON X.ORDERID = Y.ORDERID

    WHERE X.FREIGHT BETWEEN 0 AND 10 AND X.EMPLOYEEID = 5

    GO

    SELECT SUM(Discount)

    FROM [ORDERS] X INNER JOIN [ORDER DETAILS] Y ON (X.ORDERID = Y.ORDERID AND X.EMPLOYEEID = 5)

    WHERE X.FREIGHT BETWEEN 0 AND 10

    GO

    -- cut here --

    thanks in advance

    Billy

  • Yes they are the same,there would be no difference in execution of both..

    i personally prefer to put my constants in the where clause , but that would have no difference in the query plan in this instance

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

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