AdventureWorks 2016 Join/Union question RRS feed

  • Question

  • I am currently working on a question that im having trouble with, I am new to SQL and having some trouble with Joins.

    The question must be answered with Joins or a Union, no subqueries of any kind.
    I am working with AdventureWorks 2016

    I have the following question: 
    List the Sales employees and their sales ytd with the Purchasing employees and their total due ytd (assuming the year is 2013 based on when it was ordered). Have the results listed in the same columns.

    This is what I have so far: 

    SELECT FirstName, LastName, SalesYTD
    FROM HumanResources.Employee AS e
    JOIN Person.Person AS p on e.BusinessEntityID = p.BusinessEntityID
    JOIN Sales.SalesPerson AS s on e.BusinessEntityID = s.BusinessEntityID
    SELECT FirstName, LastName
    FROM HumanResources.Employee AS e
    JOIN Person.Person AS pp on e.BusinessEntityID = pp.BusinessEntityID

    I am mostly having trouble with the purchasing employees, but the Sales could be off as well.

    Any advice would be appreciated. 

    Thank you 

    Wednesday, March 28, 2018 1:00 AM

All replies

  • You need to learn the schema to write queries. So go look at the objects already written to understand it. Example: 

    select * from HumanResources.vEmployeeDepartment where Department in ('Purchasing', 'Sales');

    I don't what what "total due ytd" means - some number calculated from purchase orders most likely. If you don't know what that means, ask your instructor or find someone working on the same coursework. 

    Wednesday, March 28, 2018 1:32 AM