Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
481
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. Use MyGuitarShop
  2.  
  3. Select CategoryName, ProductName, ListPrice
  4. From Categories JOIN Products
  5. ON Products.CategoryID = Categories.CategoryID
  6. Order by CategoryName, ProductName Asc
  7.  
  8. Select FirstName, LastName, Line1, City, [State], ZipCode
  9. From Customers JOIN Addresses
  10. On Customers.CustomerID = Addresses.CustomerID
  11. Where EmailAddress = 'tennaco@gmail.com'
  12.  
  13. Select FirstName, LastName, Line1, City, [State], ZipCode
  14. From Customers JOIN Addresses
  15. On Customers.ShippingAddressID = Addresses.AddressID
  16.  
  17. Select LastName, FirstName, OrderDate, ProductName, ItemPrice, DiscountAmount, Quantity
  18. From Customers JOIN Orders
  19. On Customers.CustomerID = Orders.CustomerID JOIN OrderItems
  20. On Orders.OrderID = OrderItems.OrderID JOIN Products
  21. On OrderItems.ProductID = Products.ProductID
  22. Where LastName Like '[M,F]%R'
  23. Order by LastName, OrderDate, ProductName
  24.  
  25. Select LastName, FirstName, ProductName, ItemPrice, DiscountAmount, Quantity, (ListPrice - DiscountAmount )/100 As DiscountItemPrice, (ListPrice - DiscountAmount) /100 * Quantity As TotalItemPrice
  26. From Customers JOIN Orders
  27. On Customers.CustomerID = Orders.CustomerID JOIN OrderItems
  28. On Orders.OrderID = OrderItems.OrderID JOIN Products
  29. ON OrderItems.ProductID = Products.ProductID
  30. Where DiscountAmount = 0
  31. Order by LastName, ProductName
  32.  
  33. Select CategoryName, ProductID
  34. From Categories Full JOIN Products
  35. On Categories.CategoryID = Products.CategoryID
  36.  
  37. Select Count(ShipAmount) As [Number of Orders], Sum(TaxAmount) As [Sum of Tax Amount]
  38. From Orders
  39.  
  40. Select Count(ProductId) As [Number of Products], AVG(ListPrice) AS [AVG Total], MIN(ListPrice) As [Min Total], Max(ListPrice) As [Max Total]
  41. From Products
  42.  
  43. Select *
  44. From OrderItems
  45.  
  46. Select Count (*) AS Quantity
  47. From OrderItems
  48. Where Quantity > 1
  49.  
  50. Select Count (*) AS AmountofQuantity
  51. From OrderItems
  52. Where Quantity > 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement