Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. 1. How many users are there? 50
  2. SELECT COUNT(*) FROM users;
  3.  
  4. 2. What are the 5 most expensive items?
  5. 25|Small Cotton Gloves|Automotive, Shoes & Beauty|Multi-layered modular service-desk|9984
  6. 83|Small Wooden Computer|Health|Re-engineered fault-tolerant adapter|9859
  7. 100|Awesome Granite Pants|Toys & Books|Upgradable 24/7 access|9790
  8. 40|Sleek Wooden Hat|Music & Baby|Quality-focused heuristic info-mediaries|9390
  9. 60|Ergonomic Steel Car|Books & Outdoors|Enterprise-wide secondary firmware|9341
  10. SELECT * FROM items ORDER BY price DESC LIMIT 5;
  11.  
  12. 3. What's the cheapest book? 76|Ergonomic Granite Chair|Books|De-engineered bi-directional portal|1496
  13.  
  14. SELECT * FROM items WHERE category = 'Books' ORDER BY price LIMIT 1;
  15.  
  16. return does not change by using
  17. SELECT * FROM items WHERE category LIKE '%Books%' ORDER BY price LIMIT 1;
  18.  
  19. 4. Who lives at "6439 Zetta Hills, Willmouth, WY"? Do they have another address? user_id 40, Corrine Little
  20. SELECT * FROM addresses WHERE street ='6439 Zetta Hills';
  21.  
  22. and yes, their second address is 54369 Wolff Forges|Lake Bryon|CA|31587
  23.  
  24. SELECT * FROM users WHERE id ="40"
  25. 40|Corrine|Little|rubie_kovacek@grimes.net
  26.  
  27.  
  28. 5. Correct Virginie Mitchell's address to " New York, NY 12345".
  29. SELECT * FROM addresses WHERE user_id = "39";
  30. UPDATE addresses SET zip="12345" WHERE id = "41";
  31.  
  32. 6. How many total items did we sell? 2125
  33. SELECT SUM(quantity) FROM orders;
  34.  
  35.  
  36. 7. Simulate buying an item by inserting a User for yourself and an Order for that User.
  37. INSERT INTO users (id, first_name, last_name, email) VALUES ("51", "Huy", "Luong", "huy@tiy.com");
  38. INSERT INTO orders (id, user_id, item_id,quantity, created_at) VALUES ("378", "51", "69","100", "2017-01-18 16:00:27:123677");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement