Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1,
- SELECT `customerNumber`, SUM(`amount`) as `totalAmount`
- FROM `payments`
- WHERE `customerNumber` < 100 or `customerNumber` > 150
- GROUP BY `customerNumber`;
- 2,
- SELECT `productCode`, `productName`, `buyPrice`, `MSRP`
- FROM `products`
- WHERE (`MSRP` BETWEEN 50 and 100) and (`productName` LIKE '%00' or `productName` LIKE '%10' or `productName` LIKE '%12')
- ORDER BY `buyPrice`
- LIMIT 2;
- 3,
- ALTER TABLE `employees`
- ADD `salary` DECIMAL(15) NOT NULL AFTER `jobTitle`;
- INSERT INTO `employees` (`employeeNumber`, `lastName`, `firstName`, `extension`, `email`, `officeCode`, `reportsTo`, `jobTitle`, `salary`) VALUES ('123456', 'Nguyen', 'Quan', 'x5800', 'minhquan@gmail.com', '1', '1401', 'bonjour', '100000000000');
- UPDATE `customers`
- SET `salesRepEmployeeNumber` = '123456'
- WHERE `salesRepEmployeeNumber` = '1401' or `salesRepEmployeeNumber` = '1501'
- 4,
- SELECT `orderNumber`, `requiredDate`, `orderDate`, IF(`comments` is NULL, '', SUBSTR(`comments`, 1, 10)) AS `shortComments`
- FROM `orders`
- WHERE (MONTH(`orderDate`) BETWEEN 7 and 8) and (DATEDIFF(`requiredDate`, `orderDate`) >= 5)
- 5,
- ALTER TABLE `offices`
- ADD `manager` INT(11) AFTER `phone`;
- ALTER TABLE `offices`
- ADD CONSTRAINT `relation_manager`
- FOREIGN KEY (`manager`) REFERENCES `employees`(`employeeNumber`)
- ON DELETE RESTRICT ON UPDATE CASCADE;
- UPDATE `offices`
- SET `manager` = '1002';
- ALTER TABLE `offices`
- CHANGE `manager` `manager` INT(11) NOT NULL;
Add Comment
Please, Sign In to add comment