SQL Server Performance

SELECT list ownership

Discussion in 'SQL Server 2005 General Developer Questions' started by xiebo2010cx, Jan 19, 2007.

  1. xiebo2010cx Member

    This is a code example from inside sql 2005 querying

    The first line: SELECT list, 'EmployeeID' is explicitly from table Employees

    But 'OrderID,CustomerID,OrderDate,RequiredDate' do not explicitly specified which table or where they are from, O1, O2 or E???


    Folks, how do you solve this confusion?

    --------------------------------------
    SELECT OrderID, CustomerID, E.EmployeeID, OrderDate, RequiredDate
    FROM dbo.Employees AS E
    JOIN db:confused:rders AS O1
    ON OrderID IN
    ( SELECT TOP(3) OrderID
    FROM db:confused:rders AS O2
    WHERE O2.EmployeeID = E.EmployeeID
    ORDER BY OrderDate DESC, OrderID DESC ) ;

    ------------------
    Bug explorer/finder/seeker/locator
    ------------------
  2. DilliGrg Member

    quote:Originally posted by xiebo2010cx

    This is a code example from inside sql 2005 querying

    The first line: SELECT list, 'EmployeeID' is explicitly from table Employees

    But 'OrderID,CustomerID,OrderDate,RequiredDate' do not explicitly specified which table or where they are from, O1, O2 or E???


    Folks, how do you solve this confusion?

    --------------------------------------
    SELECT OrderID, CustomerID, E.EmployeeID, OrderDate, RequiredDate
    FROM dbo.Employees AS E
    JOIN db:confused:rders AS O1
    ON OrderID IN
    ( SELECT TOP(3) OrderID
    FROM db:confused:rders AS O2
    WHERE O2.EmployeeID = E.EmployeeID
    ORDER BY OrderDate DESC, OrderID DESC ) ;

    ------------------
    Bug explorer/finder/seeker/locator
    ------------------

    Have you looked at rest of the tables?



    Thanks,

    Name
    ---------
    Dilli Grg

    (1 row(s) affected)

Share This Page