Advertisement
timber101

Gimme5 - SQL - Answers

Feb 14th, 2022
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. Gimme5 - SQL
  2.  
  3. Using the database on W3 Schools
  4.  
  5. https://www.w3schools.com/sql/trysql.asp?filename=trysql_select_all
  6.  
  7. Q1: Click on the Products table
  8.  
  9. a. How many records are there? 77
  10.  
  11. b. Create some SQL that selects just the records for Supplierid = 7?
  12. SELECT * FROM [Products]
  13. WHERE supplierId = 7
  14.  
  15. (5 records)
  16.  
  17. Q2: Open the suppliers table
  18.  
  19. a. What is the name of the supplier with suplierid = 7?
  20. SELECT SupplierName FROM [Suppliers]
  21. where supplierid = 7
  22. (Pavlova, Ltd.)
  23.  
  24. b. How many records have the word "son" in the contactname field?
  25. SELECT * FROM [Suppliers]
  26. where contactname like "%son%"
  27. (2 records)
  28.  
  29. Q3: Open the orders table
  30.  
  31. a. How may records are in the orders table? (77)
  32.  
  33. b. What is the ID of the customer with the most orders? (HARD)
  34. SELECT count(*), customerid FROM [Orders]
  35. group by customerid
  36. order by count(*)
  37.  
  38. (20)
  39.  
  40. Q4. Open the customers table
  41.  
  42. a. How many customers are in Mexico or Spain
  43. SELECT * FROM [Customers]
  44. WHERE Country in("Mexico", "SPAIN")
  45. (5)
  46.  
  47. b. What is the name of the customer from Q3 b with the most orders
  48. SELECT * FROM [Customers]
  49. WHERE customerid = 20
  50. (Ernst Handel)
  51.  
  52. Q5. Open the products table and find this product - Gustaf's Knäckebröd
  53. SELECT * FROM [Products]
  54. where productname = "Gustaf's Knäckebröd"
  55.  
  56. a. how much is it? (21)
  57.  
  58. b. what is its category code? ID = 5
  59.  
  60. c. look in the category table and find that code? (ok)
  61.  
  62. d. what type of product
  63. (Grains/Cereals)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement