-
Notifications
You must be signed in to change notification settings - Fork 0
/
CS3550TylerSmithA9.SQL
35 lines (31 loc) · 1.33 KB
/
CS3550TylerSmithA9.SQL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
--SELECT THE FIRST NAME, LAST NAME,SALES ORDER NUMBER,ORDER DATE, AND TAX RATE FOR CUSTOMERS THAT ORDERED ON July 08 2005.
--TAX RATE IS DETERMINED BY THE SHIP TO ADDRESS.
SELECT p.FirstName, p.LastName, soh.SalesOrderNumber, CONVERT(VARCHAR(10), soh.OrderDate, 101) AS "Order Date", str.TaxRate
FROM person.Person p
INNER JOIN sales.PersonCreditCard pcc
ON p.BusinessEntityID = pcc.BusinessEntityID
INNER JOIN sales.CreditCard cc
ON pcc.CreditCardID = cc.CreditCardID
INNER JOIN sales.SalesOrderHeader soh
ON cc.CreditCardID = soh.CreditCardID
INNER JOIN person.Address ad
ON soh.ShipToAddressID = ad.AddressID
INNER JOIN person.StateProvince sp
ON ad.StateProvinceID = sp.StateProvinceID
INNER JOIN sales.SalesTaxRate str
ON sp.StateProvinceID = str.StateProvinceID
WHERE soh.OrderDate = '07/08/2005'
--SELECT THE ProductID, Product Name, list price, and LargePhotoFileName of the most expensive product(s).
--Sort by the Product Name.
SELECT p.ProductID, p.Name, p.ListPrice AS Price, ph.LargePhotoFileName
FROM Production.Product p
INNER JOIN Production.ProductProductPhoto pp
ON p.ProductID = pp.ProductID
INNER JOIN Production.ProductPhoto ph
ON pp.ProductPhotoID = ph.ProductPhotoID
WHERE p.ListPrice =
(SELECT MAX(k.Price)
FROM
(SELECT p.Name, p.ListPrice AS Price
FROM Production.Product p) k)
ORDER BY p.Name;