You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Display the ProductName and CategoryName for all products in the database. Shows 76 records.
SELECTp.productNameas Product
, c.categoryNameas Category
FROM [Products] as p
join Categories as c onp.categoryId=c.categoryId
Display the OrderID and ShipperName for all orders placed before January 9, 1997. Shows 161 records.
SELECTo.orderID
, o.orderDate
, s.shipperNamefrom orders as o
join shippers as s ono.shipperId=s.shipperIDwhereo.orderDate<'1997-01-09'
Display all ProductNames and Quantities placed on order 10251. Sort by ProductName. Shows 3 records.
SELECTo.orderId
,p.productName
, o.quantityFROM [OrderDetails] as o
join products as p ono.productId=p.productIdwhereo.orderId=10251order byp.productName
Display the OrderID, CustomerName and the employee's LastName for every order. All columns should be labeled clearly. Displays 196 records.
SELECTo.orderId
, c.customerNameas Customer
, e.lastnameas EmployeeLastName
from orders as o
join customers as c ono.customerId=c.customerIdjoin employees as e ono.employeeId=e.employeeId
(Stretch) Displays CategoryName and a new column called Count that shows how many products are in each category. Shows 9 records.
SELECTc.categoryName
, count(*) as count
FROM [Products] as p
join categories as c onp.categoryId=c.categoryIdgroup byp.categoryId
(Stretch) Display OrderID and a column called ItemCount that shows the total number of products placed on the order. Shows 196 records.
SELECT orderID
, sum(quantity) as ItemCount
FROM [OrderDetails]
group by orderId