TSQL Lab 09 習題
LAB 09 Exercise 1 --------------------------------------------------------------------- -- Task 2 -- -- Write a SELECT statement that will return groups of customers that made a purchase. -- The SELECT clause should include the custid column from the Sales.Orders table -- and the contactname column from the Sales.Customers table. -- Group by both columns and filter only the orders from the sales employee -- whose empid equals five. --------------------------------------------------------------------- 寫法1 select c.custid,c.contactname from Sales.Customers c inner join Sales.Orders o on c.custid = o.custid where o.empid = 5 group by c.custid,c.contactname 寫法2 select distinct(o.custid), c.contactname,o.empid from Sales.Orders o inner join Sales.Customers c on o.custid = c.custid where o.empid = 5 order by o.custid asc --------------------------------------------------------------------- -- Task 3 -- -- Copy the T-SQL statement ...