forked from bloominstituteoftechnology/node-db3-project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqueries.sql
20 lines (16 loc) · 1011 Bytes
/
queries.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
-- Multi-Table Query Practice
-- Display the ProductName and CategoryName for all products in the database. Shows 77 records.
SELECT ProductName, CategoryName FROM Product
JOIN Category ON Product.CategoryId = Category.Id;
-- Display the order Id and shipper CompanyName for all orders placed before August 9 2012. Shows 429 records.
SELECT Id, CompanyName FROM [Order]
JOIN Shipper ON [Order].ShipVia = Shipper.Id
WHERE [Order].OrderDate < '2012-08-09';
-- Display the name and quantity of the products ordered in order with Id 10251. Sort by ProductName. Shows 3 records.
SELECT OrderId, Quantity, ProductName FROM OrderDetail
JOIN Product ON OrderDetail.ProductId = Product.Id
WHERE OrderId = 10251;
-- Display the OrderID, Customer's Company Name and the employee's LastName for every order. All columns should be labeled clearly. Displays 16,789 records.
SELECT Id, CompanyName, LastName FROM [Order]
JOIN Customer ON [Order].CustomerId = Customer.Id
JOIN Employee ON [Order].EmployeeId = Employee.Id;