trungore10

Untitled

Mar 29th, 2021 (edited)
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 1,
  2. SELECT `customerNumber`, SUM(`amount`) as `totalAmount`
  3. FROM `payments`
  4. WHERE `customerNumber` < 100 or `customerNumber` > 150
  5. GROUP BY `customerNumber`;
  6.  
  7. 2,
  8. SELECT `productCode`, `productName`, `buyPrice`, `MSRP`
  9. FROM `products`
  10. WHERE (`MSRP` BETWEEN 50 and 100) and (`productName` LIKE '%00' or `productName` LIKE '%10' or `productName` LIKE '%12')
  11. ORDER BY `buyPrice`
  12. LIMIT 2;
  13.  
  14. 3,
  15. ALTER TABLE `employees`
  16. ADD `salary` DECIMAL(15) NOT NULL AFTER `jobTitle`;
  17.  
  18. INSERT INTO `employees` (`employeeNumber`, `lastName`, `firstName`, `extension`, `email`, `officeCode`, `reportsTo`, `jobTitle`, `salary`) VALUES ('123456', 'Nguyen', 'Quan', 'x5800', 'minhquan@gmail.com', '1', '1401', 'bonjour', '100000000000');
  19.  
  20. UPDATE `customers`
  21. SET `salesRepEmployeeNumber` = '123456'
  22. WHERE `salesRepEmployeeNumber` = '1401' or `salesRepEmployeeNumber` = '1501'
  23.  
  24. 4,
  25. SELECT `orderNumber`, `requiredDate`, `orderDate`, IF(`comments` is NULL, '', SUBSTR(`comments`, 1, 10)) AS `shortComments`
  26. FROM `orders`
  27. WHERE (MONTH(`orderDate`) BETWEEN 7 and 8) and (DATEDIFF(`requiredDate`, `orderDate`) >= 5)
  28.  
  29. 5,
  30. ALTER TABLE `offices`
  31. ADD `manager` INT(11) AFTER `phone`;
  32.  
  33. ALTER TABLE `offices`
  34. ADD CONSTRAINT `relation_manager`
  35. FOREIGN KEY (`manager`) REFERENCES `employees`(`employeeNumber`)
  36. ON DELETE RESTRICT ON UPDATE CASCADE;
  37.  
  38. UPDATE `offices`
  39. SET `manager` = '1002';
  40.  
  41. ALTER TABLE `offices`
  42. CHANGE `manager` `manager` INT(11) NOT NULL;
Add Comment
Please, Sign In to add comment