Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1,
- SELECT title, first_name, last_name, start_date, end_date, CONCAT(title, '. ', first_name, ' ', last_name, ' (', start_date, ' - ', IF(end_date is NULL, "no end date", end_date), ')') AS information
- FROM employee;
- 2,
- ALTER TABLE `account` DROP FOREIGN KEY `account_customer_fk`;
- ALTER TABLE `account` ADD CONSTRAINT `account_customer_fk` FOREIGN KEY (`cust_id`) REFERENCES `customer`(`cust_id`) ON DELETE RESTRICT ON UPDATE CASCADE;
- ALTER TABLE `business` DROP FOREIGN KEY `business_employee_fk`;
- ALTER TABLE `business` ADD CONSTRAINT `business_employee_fk` FOREIGN KEY (`cust_id`) REFERENCES `customer`(`cust_id`) ON DELETE RESTRICT ON UPDATE CASCADE;
- ALTER TABLE `individual` DROP FOREIGN KEY `individual_customer_fk`;
- ALTER TABLE `individual` ADD CONSTRAINT `individual_customer_fk` FOREIGN KEY (`cust_id`) REFERENCES `customer`(`cust_id`) ON DELETE RESTRICT ON UPDATE CASCADE;
- ALTER TABLE `officer` DROP FOREIGN KEY `officer_customer_fk`;
- ALTER TABLE `officer` ADD CONSTRAINT `officer_customer_fk` FOREIGN KEY (`cust_id`) REFERENCES `customer`(`cust_id`) ON DELETE RESTRICT ON UPDATE CASCADE;
- UPDATE customer
- SET cust_id = CONCAT('100', cust_id);
- UPDATE customer
- SET cust_id = SUBSTR(cust_id, 4);
- 3,
- INSERT INTO `customer` (`cust_id`, `address`, `city`, `cust_type_cd`, `fed_id`, `postal_code`, `state`)
- VALUES (NULL, 'Tan Binh', 'Ho Chi Minh', 'h', 'ha', '01942', 'mm'),
- (NULL, 'somewhere', 'Ha Noi', 'a', 'xx', '12344', 'ma'),
- (NULL, 'asgard', 'My Tho', 'b', 'na', '34444', 'ma');
- SELECT postal_code, COUNT(postal_code) AS num_customers
- FROM `customer`
- GROUP BY postal_code
- HAVING postal_code is not NULL;
- 4,
- SELECT txn_id, amount, CAST(txn_date AS DATE) AS date
- FROM `acc_transaction`
- WHERE 1;
- 5,
- SELECT *, (YEAR(CURRENT_DATE()) - YEAR(birth_date)) AS age
- FROM `individual`
- HAVING age > 50
- ORDER BY age;
- 6,
- SELECT CONCAT(LEFT(first_name, 1), RIGHT(first_name, 1), '. ', last_name) AS name, title
- FROM `employee`
- WHERE title LIKE '%teller%'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement