0% found this document useful (0 votes)
2 views40 pages

SQL Assigment2

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views40 pages

SQL Assigment2

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 40

-- HW3.

ddl -- Homework 3

--

-- NGUYỄN THỊ QUỲNH NHI

-- UT EID: , UTCS username: XXXXXXXX

-- C S f347, Summer 2013, Dr. P. Cannata

-- Department of Information System, The University of Information and


Technology

--

drop table s_item ;

drop table s_ord ;

drop table s_warehouse ;

drop table s_customer ;

drop table s_dept ;

drop table s_emp ;

drop table s_inventory ;

drop table s_product ;

drop table s_region ;

CREATE TABLE s_customer

id VARCHAR (255) NOT NULL ,

name VARCHAR (255) NOT NULL ,

phone VARCHAR (255) NOT NULL ,

address VARCHAR (255) ,

city VARCHAR (255) ,


state VARCHAR (255) ,

country VARCHAR (255) ,

zip_code VARCHAR (255) ,

credit_rating VARCHAR (255) ,

comments VARCHAR (255) ,

region_id VARCHAR (255) ,

sales_rep_id VARCHAR (255)

ALTER TABLE s_customer ADD CONSTRAINT s_customer_id_pk PRIMARY KEY


( id ) ;

CREATE TABLE s_dept

id VARCHAR (255) NOT NULL ,

name VARCHAR (255) NOT NULL ,

region_id VARCHAR (255)

ALTER TABLE s_dept ADD CONSTRAINT s_dept_id_pk PRIMARY KEY ( id ) ;

ALTER TABLE s_dept ADD CONSTRAINT s_dept_name_region_id_uk UNIQUE


( name , region_id ) ;

CREATE TABLE s_emp


(

id VARCHAR (255) NOT NULL ,

last_name VARCHAR (255) NOT NULL ,

first_name VARCHAR (255) ,

userid VARCHAR (255) NOT NULL ,

start_DATE DATETIME NOT NULL ,

comments VARCHAR (255) ,

title VARCHAR (255) ,

salary NUMERIC (11,2) ,

commission_pct NUMERIC (4,2) ,

dept_id VARCHAR (255) ,

manager_id VARCHAR (255)

ALTER TABLE s_emp ADD CONSTRAINT s_emp_id_pk PRIMARY KEY ( id ) ;

ALTER TABLE s_emp ADD CONSTRAINT s_emp_userid_uk UNIQUE ( userid ) ;

CREATE TABLE s_inventory

s_product_id VARCHAR (255) NOT NULL ,

s_warehouse_id VARCHAR (255) NOT NULL ,

amount_in_stock NUMERIC (9) ,

reorder_point NUMERIC (9) ,

max_in_stock NUMERIC (9) ,

out_of_stock_explanation VARCHAR (255) ,


restock_DATE DATETIME

ALTER TABLE s_inventory ADD CONSTRAINT s_inventory__IDX PRIMARY KEY


( s_product_id, s_warehouse_id ) ;

CREATE TABLE s_item

item_id VARCHAR (255) NOT NULL ,

price NUMERIC (11,2) ,

quantity NUMERIC (9) ,

quantity_shipped NUMERIC (9) ,

ord_id VARCHAR (255) NOT NULL ,

product_id VARCHAR (255) NOT NULL

ALTER TABLE s_item ADD CONSTRAINT s_item_ordid_itemid_pk PRIMARY KEY


( item_id, ord_id ) ;

-- Error - Unique Constraint s_item.s_item_ordid_prodid_uk doesn't have


columns

CREATE TABLE s_ord

id VARCHAR (255) NOT NULL ,

DATE_ordered DATETIME NOT NULL ,


DATE_shipped DATETIME ,

total NUMERIC (11,2) ,

payment_type VARCHAR (255) NOT NULL ,

order_filled VARCHAR (255) ,

customer_id VARCHAR (255) ,

sales_rep_id VARCHAR (255)

ALTER TABLE s_ord ADD CONSTRAINT s_ord_id_pk PRIMARY KEY ( id ) ;

CREATE TABLE s_product

id VARCHAR (255) NOT NULL ,

name VARCHAR (255) NOT NULL ,

short_desc VARCHAR (255) ,

suggested_whlsl_price NUMERIC (11,2) ,

whlsl_units VARCHAR (255)

ALTER TABLE s_product ADD CONSTRAINT s_product_id_pk PRIMARY KEY ( id )


;

ALTER TABLE s_product

ADD CONSTRAINT s_product_name_uk UNIQUE ( name ) ;


CREATE TABLE s_region

id VARCHAR (255) NOT NULL ,

name VARCHAR (255) NOT NULL

ALTER TABLE s_region ADD CONSTRAINT s_region_id_pk PRIMARY KEY ( id ) ;

ALTER TABLE s_region ADD CONSTRAINT s_region_name_uk UNIQUE


( name ) ;

CREATE TABLE s_warehouse

id VARCHAR (255) NOT NULL ,

address VARCHAR (255) ,

city VARCHAR (255) ,

state VARCHAR (255) ,

country VARCHAR (255) ,

zip_code VARCHAR (255) ,

phone VARCHAR (255) ,

region_id VARCHAR (255) ,

manager_id VARCHAR (255)

;
ALTER TABLE s_warehouse ADD CONSTRAINT s_warehouse_id_pk PRIMARY
KEY ( id ) ;

INSERT INTO s_customer(id, name, phone, address, city, state, country,


zip_code, credit_rating, sales_rep_id, region_id, comments) VALUES ('301',
'Sports,Inc', '540-123-4567','72 High St',

'Harrisonburg', 'VA','US', '22809','EXCELLENT', '12', '1', NULL);

INSERT INTO s_customer(id, name, phone, address, city, state, country,


zip_code, credit_rating, sales_rep_id, region_id, comments) VALUES ('302',
'Toms Sporting Goods', '540-987-6543','6741 Main St',

'Harrisonburg', 'VA','US', '22809','POOR', '14', '1', NULL);

INSERT INTO s_customer(id, name, phone, address, city, state, country,


zip_code, credit_rating, sales_rep_id, region_id, comments) VALUES ('303',
'Athletic Attire', '540-123-6789','54 Market St',

'Harrisonburg', 'VA','US', '22808','GOOD', '14', '1', NULL);

INSERT INTO s_customer(id, name, phone, address, city, state, country,


zip_code, credit_rating, sales_rep_id, region_id, comments)

VALUES ('304', 'Athletics For All', '540-987-1234','286 Main St',


'Harrisonburg', 'VA',

'US', '22808','EXCELLENT', '12', '1', NULL);

INSERT INTO s_customer(id, name, phone, address, city, state, country,


zip_code, credit_rating, sales_rep_id, region_id, comments) VALUES ('305',
'Shoes for Sports', '540-123-9876','538 High St',

'Harrisonburg', 'VA','US', '22809','EXCELLENT', '14', '1', NULL);

INSERT INTO s_customer(id, name, phone, address, city, state, country,


zip_code, credit_rating, sales_rep_id, region_id, comments) VALUES ('306', 'BJ
Athletics', '540-987-9999','632 Water St',

'Harrisonburg', 'VA','US', '22810','POOR', '12', '1', NULL);

INSERT INTO s_customer(id, name, phone, address, city, state, country,


zip_code, credit_rating, sales_rep_id, region_id, comments) VALUES ('403',
'Athletics One', '717-234-6786','912 Columbia Rd',

'Lancaster', 'PA','US', '17601','GOOD', '14', '1', NULL);


INSERT INTO s_customer(id, name, phone, address, city, state, country,
zip_code, credit_rating, sales_rep_id, region_id, comments) VALUES ('404',
'Great Athletes', '717-987-2341','121 Litiz Pike',

'Lancaster', 'PA','US', '17602','EXCELLENT', '12', '1', NULL);

INSERT INTO s_customer(id, name, phone, address, city, state, country,


zip_code, credit_rating, sales_rep_id, region_id, comments) VALUES ('405',
'Athletics Two', '717-987-9875','435 High Rd',

'Lancaster', 'PA','US', '17602','EXCELLENT', '14', '1', NULL);

INSERT INTO s_customer(id, name, phone, address, city, state, country,


zip_code, credit_rating, sales_rep_id, region_id, comments) VALUES ('406',
'Athletes Attic', '717-234-9888','101 Greenfield Rd',

'Lancaster', 'PA','US', '17601','POOR', '12', '1', NULL);

INSERT INTO s_customer(id, name, phone, address, city, state, country,


zip_code, credit_rating, sales_rep_id, region_id, comments) VALUES ('201',
'One Sport', '55-112066222','82 Via Bahia', 'Sao Paolo',

NULL, 'Brazil', NULL,'EXCELLENT', '12', '2', NULL);

INSERT INTO s_customer(id, name, phone, address, city, state, country,


zip_code, credit_rating, sales_rep_id, region_id, comments) VALUES ('202',
'Deportivo Caracas', '58-28066222','31 Sabana Grande',

'Caracas', NULL, 'Venezuela', NULL,'EXCELLENT', '12', '2', NULL);

INSERT INTO s_customer(id, name, phone, address, city, state, country,


zip_code, credit_rating, sales_rep_id, region_id, comments) VALUES ('203',
'New Delhi Sports', '91-11903338','11368 Chanakya',

'New Delhi', NULL, 'India', NULL,'GOOD', '11', '4', NULL);

INSERT INTO s_customer(id, name, phone, address, city, state, country,


zip_code, credit_rating, sales_rep_id, region_id, comments) VALUES ('204',
'Ladysport', '1-206-104-0111','281 Queen Street',

'Seattle', 'Washington', 'US', NULL,'EXCELLENT', '11', '1', NULL);

INSERT INTO s_customer(id, name, phone, address, city, state, country,


zip_code, credit_rating, sales_rep_id, region_id, comments) VALUES ('205',
'Kim''s Sporting Goods', '852-3693888','15 Henessey Road',
'Hong Kong', NULL, NULL, NULL,'EXCELLENT', '11', '4', NULL);

INSERT INTO s_customer(id, name, phone, address, city, state, country,


zip_code, credit_rating, sales_rep_id, region_id, comments) VALUES ('206',
'Sportique', '33-93425722253','172 Rue de Place',

'Cannes', NULL, 'France', NULL,'EXCELLENT', '13', '5', NULL);

INSERT INTO s_customer(id, name, phone, address, city, state, country,


zip_code, credit_rating, sales_rep_id, region_id, comments) VALUES ('207',
'Tall Rock Sports', '234-16036222','10 Saint Antoine',

'Lagos', NULL, 'Nigeria', NULL,'GOOD', NULL, '3', NULL);

INSERT INTO s_customer(id, name, phone, address, city, state, country,


zip_code, credit_rating, sales_rep_id, region_id, comments) VALUES ('208',
'Muench Sports', '49-895274449','435 Gruenestrasse',

'Munich', NULL, 'Germany', NULL,'GOOD', '13', '5', NULL);

INSERT INTO s_customer(id, name, phone, address, city, state, country,


zip_code, credit_rating, sales_rep_id, region_id, comments) VALUES ('209',
'Beisbol Si!', '809-352666','415 Playa Del Mar',

'San Pedro de Macoris', NULL, 'Dominican Republic', NULL, 'EXCELLENT', '11',


'6', NULL);

INSERT INTO s_customer(id, name, phone, address, city, state, country,


zip_code, credit_rating, sales_rep_id, region_id, comments) VALUES ('210',
'Futbol Sonora', '52-404555','5 Via Saguaro', 'Nogales',

NULL, 'Mexico', NULL,'EXCELLENT', '12', '2', NULL);

INSERT INTO s_customer(id, name, phone, address, city, state, country,


zip_code, credit_rating, sales_rep_id, region_id, comments) VALUES ('211',
'Helmut''s Sports', '42-2111222','45 Modrany', 'Prague',

NULL, 'Czechoslovakia', NULL,'EXCELLENT', '11', '5', NULL);

INSERT INTO s_customer(id, name, phone, address, city, state, country,


zip_code, credit_rating, sales_rep_id, region_id, comments) VALUES ('212',
'Hamada Sport', '20-31209222','47A Corniche',

'Alexandria', NULL, 'Egypt', NULL,'EXCELLENT', '13', '3', NULL);


INSERT INTO s_customer(id, name, phone, address, city, state, country,
zip_code, credit_rating, sales_rep_id, region_id, comments) VALUES ('213',
'Sports Emporium', '1-415-555-6281','4783 168th Street',

'San Francisco', 'CA', 'US', NULL,'EXCELLENT', '11', '1', NULL);

INSERT INTO s_customer(id, name, phone, address, city, state, country,


zip_code, credit_rating, sales_rep_id, region_id, comments) VALUES ('214',
'Sports Retail', '1-716-555-7777','115 Main Street',

'Buffalo', 'NY', 'US', NULL, 'POOR', '11', '1', NULL);

INSERT INTO s_customer(id, name, phone, address, city, state, country,


zip_code, credit_rating, sales_rep_id, region_id, comments) VALUES ('215',
'Sports Russia', '7-0953892444','7070 Yekatamina',

'Saint Petersburg', NULL, 'Russia', NULL,'POOR', '11', '5', NULL);

INSERT INTO s_dept(id, name, region_id) VALUES ('10', 'Finance', '1');

INSERT INTO s_dept(id, name, region_id) VALUES ('31', 'Sales', '1');

INSERT INTO s_dept(id, name, region_id) VALUES ('32', 'Sales', '2');

INSERT INTO s_dept(id, name, region_id) VALUES ('33', 'Sales', '3');

INSERT INTO s_dept(id, name, region_id) VALUES ('34', 'Sales', '4');

INSERT INTO s_dept(id, name, region_id) VALUES ('35', 'Sales', '5');

INSERT INTO s_dept(id, name, region_id) VALUES ('41', 'Operations', '1');

INSERT INTO s_dept(id, name, region_id) VALUES ('42', 'Operations', '2');

INSERT INTO s_dept(id, name, region_id) VALUES ('43', 'Operations', '3');

INSERT INTO s_dept(id, name, region_id) VALUES ('44', 'Operations', '4');

INSERT INTO s_dept(id, name, region_id) VALUES ('45', 'Operations', '5');

INSERT INTO s_dept(id, name, region_id) VALUES ('50', 'Administration', '1');


INSERT INTO s_emp(id, last_name, first_name, userid, start_date, comments,
manager_id, title, dept_id, salary, commission_pct) VALUES ('1',
'Martin','Carmen','martincu','03-MAR-1990', NULL,NULL, 'President', '50',
4500, NULL);

INSERT INTO s_emp(id, last_name, first_name, userid, start_date, comments,


manager_id, title, dept_id, salary, commission_pct) VALUES
('2','Smith','Doris','smithdj','08-MAR-1990',NULL,'1', 'VP, Operations','41',
2450,NULL);

INSERT INTO s_emp(id, last_name, first_name, userid, start_date, comments,


manager_id, title, dept_id, salary, commission_pct) VALUES ('3',
'Norton','Michael','nortonma','17-JUN-1991',NULL,'1', 'VP, Sales', '31',
2400,NULL);

INSERT INTO s_emp(id, last_name, first_name, userid, start_date, comments,


manager_id, title, dept_id, salary, commission_pct) VALUES ('4', 'Quentin',
'Mark','quentiml','07-APR-1990',NULL,'1', 'VP, Finance', '10', 2450, NULL);

INSERT INTO s_emp(id, last_name, first_name, userid, start_date, comments,


manager_id, title, dept_id, salary, commission_pct) VALUES ('5', 'Roper',
'Joseph','roperjm','04-MAR-1990',NULL,'1', 'VP, Administration', '50', 2550,
NULL);

INSERT INTO s_emp(id, last_name, first_name, userid, start_date, comments,


manager_id, title, dept_id, salary, commission_pct) VALUES ('6', 'Brown',
'Molly','brownmr','18-JAN-1991',NULL,'2', 'Warehouse Manager', '41', 1600,
NULL);

INSERT INTO s_emp(id, last_name, first_name, userid, start_date, comments,


manager_id, title, dept_id, salary, commission_pct) VALUES ('7', 'Hawkins',
'Roberta','hawkinrt','14-MAY-1990',NULL,'2', 'Warehouse Manager','42', 1650,
NULL);

INSERT INTO s_emp(id, last_name, first_name, userid, start_date, comments,


manager_id, title, dept_id, salary, commission_pct) VALUES ('8', 'Burns',
'Ben','burnsba','07-APR-1990',NULL,'2', 'Warehouse Manager','43', 1500,
NULL);

INSERT INTO s_emp(id, last_name, first_name, userid, start_date, comments,


manager_id, title, dept_id, salary, commission_pct) VALUES ('9', 'Catskill',
'Antoinette','catskiaw','09-FEB-1992',NULL,'2', 'Warehouse Manager','44',
1700,NULL);

INSERT INTO s_emp(id, last_name, first_name, userid, start_date, comments,


manager_id, title, dept_id, salary, commission_pct) VALUES ('10', 'Jackson',
'Marta','jacksomt','27-FEB-1991',NULL,'2', 'Warehouse Manager','45',
1507,NULL);

INSERT INTO s_emp(id, last_name, first_name, userid, start_date, comments,


manager_id, title, dept_id, salary, commission_pct) VALUES ('11',
'Henderson', 'Colin','hendercs','14-MAY-1990',NULL,'3', 'Sales Representative',
'31', 1400, 10);

INSERT INTO s_emp(id, last_name, first_name, userid, start_date, comments,


manager_id, title, dept_id, salary, commission_pct) VALUES ('12', 'Gilson',
'Sam', 'gilsonsj','18-JAN-1992',NULL,'3', 'Sales Representative','32', 1490,
12.5);

INSERT INTO s_emp(id, last_name, first_name, userid, start_date, comments,


manager_id, title, dept_id, salary, commission_pct) VALUES ('13', 'Sanders',
'Jason', 'sanderjk','18-FEB-1991',NULL,'3', 'Sales Representative','33', 1515,
10);

INSERT INTO s_emp(id, last_name, first_name, userid, start_date, comments,


manager_id, title, dept_id, salary, commission_pct) VALUES ('14', 'Dameron',
'Andre', 'dameroap','09-OCT-1991',NULL,'3', 'Sales Representative','35', 1450,
17.5);

INSERT INTO s_emp(id, last_name, first_name, userid, start_date, comments,


manager_id, title, dept_id, salary, commission_pct) VALUES ('15', 'Hardwick',
'Elaine', 'hardwiem','07-FEB-1992',NULL,'6', 'Stock Clerk','41', 1400, NULL);

INSERT INTO s_emp(id, last_name, first_name, userid, start_date, comments,


manager_id, title, dept_id, salary, commission_pct) VALUES ('16', 'Brown',
'George', 'browngw','08-MAR-1990',NULL,'6', 'Stock Clerk','41', 940, NULL);

INSERT INTO s_emp(id, last_name, first_name, userid, start_date, comments,


manager_id, title, dept_id, salary, commission_pct) VALUES ('17',
'Washington', 'Thomas', 'washintl','09-FEB-1991',NULL,'7', 'Stock Clerk', '42',
1200, NULL);
INSERT INTO s_emp(id, last_name, first_name, userid, start_date, comments,
manager_id, title, dept_id, salary, commission_pct) VALUES ('18', 'Patterson',
'Donald', 'patterdv','06-AUG-1991',NULL,'7', 'Stock Clerk','42', 795, NULL);

INSERT INTO s_emp(id, last_name, first_name, userid, start_date, comments,


manager_id, title, dept_id, salary, commission_pct) VALUES ('19', 'Bell',
'Alexander', 'bellag','26-MAY-1991',NULL,'8', 'Stock Clerk','43', 850, NULL);

INSERT INTO s_emp(id, last_name, first_name, userid, start_date, comments,


manager_id, title, dept_id, salary, commission_pct) VALUES ('20', 'Gantos',
'Eddie', 'gantosej','30-NOV-1990',NULL,'9', 'Stock Clerk','44', 800, NULL);

INSERT INTO s_emp(id, last_name, first_name, userid, start_date, comments,


manager_id, title, dept_id, salary, commission_pct) VALUES ('21',
'Stephenson', 'Blaine', 'stephebs','17-MAR-1991',NULL,'10', 'Stock Clerk','45',
860, NULL);

INSERT INTO s_emp(id, last_name, first_name, userid, start_date, comments,


manager_id, title, dept_id, salary, commission_pct) VALUES ('22', 'Chester',
'Eddie', 'chesteek','30-NOV-1990', NULL, '9', 'Stock Clerk','44', 800, NULL);

INSERT INTO s_emp(id, last_name, first_name, userid, start_date, comments,


manager_id, title, dept_id, salary, commission_pct) VALUES ('23', 'Pearl',
'Roger', 'pearlrg','17-OCT-1990', NULL, '9', 'Stock Clerk','34', 795, NULL);

INSERT INTO s_emp(id, last_name, first_name, userid, start_date, comments,


manager_id, title, dept_id, salary, commission_pct) VALUES ('24', 'Dancer',
'Bonnie', 'dancerbw','17-MAR-1991', NULL, '7', 'Stock Clerk','45', 860, NULL);

INSERT INTO s_emp(id, last_name, first_name, userid, start_date, comments,


manager_id, title, dept_id, salary, commission_pct) VALUES ('25', 'Schmitt',
'Sandra', 'schmitss','09-MAY-1991', NULL, '8', 'Stock Clerk','45', 1100, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('10011', '101', 650, 625, 1100, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('10012', '101', 600, 560, 1000, NULL, NULL);
INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,
reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('10013', '101', 400, 400, 700, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('10021', '101', 500, 425, 740, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('10022', '101', 300, 200, 350, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('10023', '101', 400, 300, 525, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('20106', '101', 993, 625, 1000, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('20108', '101', 700, 700, 1225, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('20201', '101', 802, 800, 1400, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('20510', '101', 1389, 850, 1400, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('20512', '101', 850, 850, 1450, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('30321', '101', 2000, 1500, 2500, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('30326', '101', 2100, 2000, 3500, NULL, NULL);
INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,
reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('30421', '101', 1822, 1800, 3150, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('30426', '101', 2250, 2000, 3500, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('30433', '101', 650, 600, 1050, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('32779', '101', 2120, 1250, 2200, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('32861', '101', 505, 500, 875, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('40421', '101', 578, 350, 600, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('40422', '101', 0, 350, 600, 'Phenomenal sales...', '08-FEB-93');

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('41010', '101', 250, 250, 437, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('41020', '101', 471, 450, 750, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('41050', '101', 501, 450, 750, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('41080', '101', 400, 400, 700, NULL, NULL);
INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,
reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('41100', '101', 350, 350, 600, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('50169', '101', 2530, 1500, 2600, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('50273', '101', 233, 200, 350, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('50417', '101', 518, 500, 875, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('50418', '101', 244, 100, 275, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('50419', '101', 230, 120, 310, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('50530', '101', 669, 400, 700, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('50532', '101', 0, 100, 175, 'Wait for Spring.', '12-APR-93');

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('50536', '101', 173, 100, 175, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('20106', '201', 220, 150, 260, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('20108', '201', 166, 150, 260, NULL, NULL);
INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,
reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('20201', '201', 320, 200, 350, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('20510', '201', 175, 100, 175, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('20512', '201', 162, 100, 175, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('30321', '201', 96, 80, 140, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('30326', '201', 147, 120, 210, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('30421', '201', 102, 80, 140, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('30426', '201', 200, 120, 210, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('30433', '201', 130, 130, 230, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('32779', '201', 180, 150, 260, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('32861', '201', 132, 80, 140, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('50169', '201', 225, 220, 385, NULL, NULL);
INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,
reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('50273', '201', 75, 60, 100, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('50417', '201', 82, 60, 100, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('50418', '201', 98, 60, 100, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('50419', '201', 77, 60, 100, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('50530', '201', 62, 60, 100, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('50532', '201', 67, 60, 100, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('50536', '201', 97, 60, 100, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('20510', '301', 69, 40, 100, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('20512', '301', 28, 20, 50, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('30321', '301', 85, 80, 140, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('30421', '301', 102, 80, 140, NULL, NULL);
INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,
reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('30433', '301', 35, 20, 35, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('32779', '301', 102, 95, 175, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('32861', '301', 57, 50, 100, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('40421', '301', 70, 40, 70, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('40422', '301', 65, 40, 70, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('41010', '301', 59, 40, 70, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('41020', '301', 61, 40, 70, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('41050', '301', 49, 40, 70, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('41080', '301', 50, 40, 70, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('41100', '301', 42, 40, 70, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('20510', '401', 88, 50, 100, NULL, NULL);
INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,
reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('20512', '401', 75, 75, 140, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('30321', '401', 102, 80, 140, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('30326', '401', 113, 80, 140, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('30421', '401', 85, 80, 140, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('30426', '401', 135, 80, 140, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('30433', '401', 0, 100, 175, NULL, NULL );

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('32779', '401', 135, 100, 175, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('32861', '401', 250, 150, 250, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('40421', '401', 47, 40, 70, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('40422', '401', 50, 40, 70, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('41010', '401', 80, 70, 220, NULL, NULL);
INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,
reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('41020', '401', 91, 70, 220, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('41050', '401', 169, 70, 220, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('41080', '401', 100, 70, 220, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('41100', '401', 75, 70, 220, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('50169', '401', 240, 200, 350, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('50273', '401', 224, 150, 280, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('50417', '401', 130, 120, 210, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('50418', '401', 156, 100, 175, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('50419', '401', 151, 150, 280, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('50530', '401', 119, 100, 175, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('50532', '401', 233, 200, 350, NULL, NULL);
INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,
reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('50536', '401', 138, 100, 175, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('10012', '10501', 300, 300, 525, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('10013', '10501', 314, 300, 525, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('10022', '10501', 502, 300, 525, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('10023', '10501', 500, 300, 525, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('20106', '10501', 150, 100, 175, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('20108', '10501', 222, 200, 350, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('20201', '10501', 275, 200, 350, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('20510', '10501', 57, 50, 87, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('20512', '10501', 62, 50, 87, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('30321', '10501', 194, 150, 275, NULL, NULL);
INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,
reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('30326', '10501', 277, 250, 440, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('30421', '10501', 190, 150, 275, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('30426', '10501', 423, 250, 450, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('30433', '10501', 273, 200, 350, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('32779', '10501', 280, 200, 350, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('32861', '10501', 288, 200, 350, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('40421', '10501', 97, 80, 140, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('40422', '10501', 90, 80, 140, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('41010', '10501', 151, 140, 245, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('41020', '10501', 224, 140, 245, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('41050', '10501', 157, 140, 245, NULL, NULL);
INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,
reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('41080', '10501', 159, 140, 245, NULL, NULL);

INSERT INTO s_inventory(s_product_id, s_warehouse_id, amount_in_stock,


reorder_point, max_in_stock, out_of_stock_explanation, restock_date) VALUES
('41100', '10501', 141, 140, 245, NULL, NULL);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('100', '1', '10011', 135, 500, 500);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('100', '2', '10013', 380, 400, 400);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('100', '3', '10021', 14, 500, 500);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('100', '5', '30326', 582, 600, 600);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('100', '7', '41010', 8, 250, 250);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('100', '6', '30433', 20, 450, 450);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('100', '4', '10023', 36, 400, 400);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('101', '1', '30421', 16, 15, 15);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('101', '3', '41010', 8, 20, 20);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('101', '5', '50169', 4.29, 40, 40);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('101', '6', '50417', 80, 27, 27);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('101', '7', '50530', 45, 50, 50);
INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,
quantity_shipped) VALUES ('101', '4', '41100', 45, 35, 35);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('101', '2', '40422', 50, 30, 30);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('102', '1', '20108', 28, 100, 100);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('102', '2', '20201', 123, 45, 45);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('103', '1', '30433', 20, 15, 15);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('103', '2', '32779', 7, 11, 11);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('104', '1', '20510', 9, 7, 7);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('104', '4', '30421', 16, 35, 35);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('104', '2', '20512', 8, 12, 12);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('104', '3', '30321', 1669, 19, 19);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('105', '1', '50273', 22.89, 16, 16);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('105', '3', '50532', 47, 28, 28);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('105', '2', '50419', 80, 13, 13);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('106', '1', '20108', 28, 46, 46);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('106', '4', '50273', 22.89, 75, 75);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('106', '5', '50418', 75, 98, 98);
INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,
quantity_shipped) VALUES ('106', '6', '50419', 80, 27, 27);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('106', '2', '20201', 123, 21, 21);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('106', '3', '50169', 4.29, 125, 125);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('107', '1', '20106', 11, 50, 50);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('107', '3', '20201', 115, 130, 130);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('107', '5', '30421', 16, 55, 55);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('107', '4', '30321', 1669, 75, 75);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('107', '2', '20108', 28, 22, 22);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('108', '1', '20510', 9, 9, 9);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('108', '6', '41080', 35, 50, 50);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('108', '7', '41100', 45, 42, 42);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('108', '5', '32861', 60, 57, 57);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('108', '2', '20512', 8, 18, 18);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('108', '4', '32779', 7, 60, 60);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('108', '3', '30321', 1669, 85, 85);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('109', '1', '10011', 140, 150, 150);
INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,
quantity_shipped) VALUES ('109', '5', '30426', 18.25, 500, 500);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('109', '7', '50418', 75, 43, 43);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('109', '6', '32861', 60, 50, 50);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('109', '4', '30326', 582, 1500, 1500);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('109', '2', '10012', 175, 600, 600);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('109', '3', '10022', 21.95, 300, 300);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('110', '1', '50273', 22.89, 17, 17);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('110', '2', '50536', 50, 23, 23);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('111', '1', '40421', 65, 27, 27);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('111', '2', '41080', 35, 29, 29);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('97', '1', '20106', 9, 1000, 1000);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('97', '2', '30321', 1500, 50, 50);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('98', '1', '40421', 85, 7, 7);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('99', '1', '20510', 9, 18, 18);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('99', '2', '20512', 8, 25, 25);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('99', '3', '50417', 80, 53, 53);
INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,
quantity_shipped) VALUES ('99', '4', '50530', 45, 69, 69);

INSERT INTO s_item(ord_id, item_id, product_id, price, quantity,


quantity_shipped) VALUES ('112', '1', '20106', 11, 50, 50);

INSERT INTO s_ord(id, customer_id, date_ordered, date_shipped,


sales_rep_id, total, payment_type, order_filled) VALUES ('100', '204', '31-AUG-
1992',

'10-SEP-1992','11', 601100, 'CREDIT', 'Y');

INSERT INTO s_ord(id, customer_id, date_ordered, date_shipped,


sales_rep_id, total, payment_type, order_filled) VALUES ('101', '205', '31-AUG-
1992',

'15-SEP-1992','14', 8056.6, 'CREDIT', 'Y');

INSERT INTO s_ord(id, customer_id, date_ordered, date_shipped,


sales_rep_id, total, payment_type, order_filled) VALUES ('102', '206', '01-SEP-
1992',

'08-SEP-1992','12', 8335, 'CREDIT', 'Y');

INSERT INTO s_ord(id, customer_id, date_ordered, date_shipped,


sales_rep_id, total, payment_type, order_filled) VALUES ('103', '208', '02-SEP-
1992',

'22-SEP-1992','11', 377, 'CASH', 'Y');

INSERT INTO s_ord(id, customer_id, date_ordered, date_shipped,


sales_rep_id, total, payment_type, order_filled) VALUES ('104', '208', '03-SEP-
1992',

'23-SEP-1992','13', 32430, 'CREDIT', 'Y');

INSERT INTO s_ord(id, customer_id, date_ordered, date_shipped,


sales_rep_id, total, payment_type, order_filled) VALUES ('105', '209', '04-SEP-
1992',
'18-SEP-1992','11', 2722.24, 'CREDIT', 'Y');

INSERT INTO s_ord(id, customer_id, date_ordered, date_shipped,


sales_rep_id, total, payment_type, order_filled) VALUES ('106', '210', '07-SEP-
1992',

'15-SEP-1992','12', 15634, 'CREDIT', 'Y');

INSERT INTO s_ord(id, customer_id, date_ordered, date_shipped,


sales_rep_id, total, payment_type, order_filled) VALUES ('107', '211', '07-SEP-
1992',

'21-SEP-1992','14', 142171, 'CREDIT', 'Y');

INSERT INTO s_ord(id, customer_id, date_ordered, date_shipped,


sales_rep_id, total, payment_type, order_filled) VALUES ('108', '212', '07-SEP-
1992',

'10-SEP-1992','13', 149570, 'CREDIT', 'Y');

INSERT INTO s_ord(id, customer_id, date_ordered, date_shipped,


sales_rep_id, total, payment_type, order_filled) VALUES ('109', '213', '08-SEP-
1992',

'28-SEP-1992','11', 1020935, 'CREDIT', 'Y');

INSERT INTO s_ord(id, customer_id, date_ordered, date_shipped,


sales_rep_id, total, payment_type, order_filled) VALUES ('110', '214', '09-SEP-
1992',

'21-SEP-1992','11', 1539.13, 'CASH', 'Y');

INSERT INTO s_ord(id, customer_id, date_ordered, date_shipped,


sales_rep_id, total, payment_type, order_filled) VALUES ('111', '204', '09-SEP-
1992',

'21-SEP-1992','11', 2770, 'CASH', 'Y');

INSERT INTO s_ord(id, customer_id, date_ordered, date_shipped,


sales_rep_id, total, payment_type, order_filled) VALUES ('97', '201', '28-AUG-
1992',

'17-SEP-1992','12', 84000, 'CREDIT', 'Y');


INSERT INTO s_ord(id, customer_id, date_ordered, date_shipped,
sales_rep_id, total, payment_type, order_filled) VALUES ('98', '202', '31-AUG-
1992',

'10-SEP-1992','14', 595, 'CASH', 'Y');

INSERT INTO s_ord(id, customer_id, date_ordered, date_shipped,


sales_rep_id, total, payment_type, order_filled) VALUES ('99', '203', '31-AUG-
1992',

'18-SEP-1992','14', 7707, 'CREDIT', 'Y');

INSERT INTO s_ord(id, customer_id, date_ordered, date_shipped,


sales_rep_id, total, payment_type, order_filled) VALUES ('112', '210', '31-AUG-
1992',

'10-SEP-1992','12', 550, 'CREDIT', 'Y');

INSERT INTO s_product(id, name, short_desc, suggested_whlsl_price,


whlsl_units) VALUES ('10011', 'Bunny Boot','Beginner''s ski boot',150, NULL);

INSERT INTO s_product(id, name, short_desc, suggested_whlsl_price,


whlsl_units) VALUES ('10012', 'Ace Ski Boot','Intermediate ski boot',200,
NULL);

INSERT INTO s_product(id, name, short_desc, suggested_whlsl_price,


whlsl_units) VALUES ('10013', 'Pro Ski Boot','Advanced ski boot',410, NULL);

INSERT INTO s_product(id, name, short_desc, suggested_whlsl_price,


whlsl_units) VALUES ('10021', 'Bunny Ski Pole','Beginner''s ski pole',16.25,
NULL);

INSERT INTO s_product(id, name, short_desc, suggested_whlsl_price,


whlsl_units) VALUES ('10022', 'Ace Ski Pole','Intermediate ski pole',21.95,
NULL);

INSERT INTO s_product(id, name, short_desc, suggested_whlsl_price,


whlsl_units) VALUES ('10023', 'Pro Ski Pole','Advanced ski pole',40.95, NULL);

INSERT INTO s_product(id, name, short_desc, suggested_whlsl_price,


whlsl_units) VALUES ('20106', 'Junior Soccer Ball','Junior soccer ball',11,
NULL);
INSERT INTO s_product(id, name, short_desc, suggested_whlsl_price,
whlsl_units) VALUES ('20108', 'World Cup Soccer Ball','World cup soccer
ball',28, NULL);

INSERT INTO s_product(id, name, short_desc, suggested_whlsl_price,


whlsl_units) VALUES ('20201', 'World Cup Net','World cup net',123, NULL);

INSERT INTO s_product(id, name, short_desc, suggested_whlsl_price,


whlsl_units) VALUES ('20510', 'Black Hawk Knee Pads','Knee pads, pair',9,
NULL);

INSERT INTO s_product(id, name, short_desc, suggested_whlsl_price,


whlsl_units) VALUES ('20512', 'Black Hawk Elbow Pads','Elbow pads, pair',8,
NULL);

INSERT INTO s_product(id, name, short_desc, suggested_whlsl_price,


whlsl_units) VALUES ('30321', 'Grand Prix Bicycle','Road bicycle',1669, NULL);

INSERT INTO s_product(id, name, short_desc, suggested_whlsl_price,


whlsl_units) VALUES ('30326', 'Himalaya Bicycle','Mountain bicycle',582,
NULL);

INSERT INTO s_product(id, name, short_desc, suggested_whlsl_price,


whlsl_units) VALUES ('30421', 'Grand Prix Bicycle Tires','Road bicycle
tires',16, NULL);

INSERT INTO s_product(id, name, short_desc, suggested_whlsl_price,


whlsl_units) VALUES ('30426', 'Himalaya Tires','Mountain bicycle tires',18.25,
NULL);

INSERT INTO s_product(id, name, short_desc, suggested_whlsl_price,


whlsl_units) VALUES ('30433', 'New Air Pump','Tire pump',20, NULL);

INSERT INTO s_product(id, name, short_desc, suggested_whlsl_price,


whlsl_units) VALUES ('32779', 'Slaker Water Bottle','Water bottle',7, NULL);

INSERT INTO s_product(id, name, short_desc, suggested_whlsl_price,


whlsl_units) VALUES ('32861', 'Safe-T Helmet','Bicycle helmet',60, NULL);

INSERT INTO s_product(id, name, short_desc, suggested_whlsl_price,


whlsl_units) VALUES ('40421', 'Alexeyer Pro Lifting Bar','Straight bar',65,
NULL);

INSERT INTO s_product(id, name, short_desc, suggested_whlsl_price,


whlsl_units) VALUES ('40422', 'Pro Curling Bar','Curling bar',50, NULL);
INSERT INTO s_product(id, name, short_desc, suggested_whlsl_price,
whlsl_units) VALUES ('41010', 'Prostar 10 Pound Weight','Ten pound weight',8,
NULL);

INSERT INTO s_product(id, name, short_desc, suggested_whlsl_price,


whlsl_units) VALUES ('41020', 'Prostar 20 Pound Weight','Twenty pound
weight',12, NULL);

INSERT INTO s_product(id, name, short_desc, suggested_whlsl_price,


whlsl_units) VALUES ('41050', 'Prostar 50 Pound Weight','Fifty pound
weight',25, NULL);

INSERT INTO s_product(id, name, short_desc, suggested_whlsl_price,


whlsl_units) VALUES ('41080', 'Prostar 80 Pound Weight','Eighty pound
weight',35, NULL);

INSERT INTO s_product(id, name, short_desc, suggested_whlsl_price,


whlsl_units) VALUES ('41100', 'Prostar 100 Pound Weight','One hundred
pound weight',45, NULL);

INSERT INTO s_product(id, name, short_desc, suggested_whlsl_price,


whlsl_units) VALUES ('50169', 'Major League Baseball','Baseball',4.29, NULL);

INSERT INTO s_product(id, name, short_desc, suggested_whlsl_price,


whlsl_units) VALUES ('50273', 'Chapman Helmet','Batting helmet',22.89,
NULL);

INSERT INTO s_product(id, name, short_desc, suggested_whlsl_price,


whlsl_units) VALUES ('50417', 'Griffey Glove','Outfielder''s glove',80, NULL);

INSERT INTO s_product(id, name, short_desc, suggested_whlsl_price,


whlsl_units) VALUES ('50418', 'Alomar Glove','Infielder''s glove',75, NULL);

INSERT INTO s_product(id, name, short_desc, suggested_whlsl_price,


whlsl_units) VALUES ('50419', 'Steinbach Glove','Catcher''s glove',80, NULL);

INSERT INTO s_product(id, name, short_desc, suggested_whlsl_price,


whlsl_units) VALUES ('50530', 'Cabrera Bat','Thirty inch bat',45, NULL);

INSERT INTO s_product(id, name, short_desc, suggested_whlsl_price,


whlsl_units) VALUES ('50532', 'Puckett Bat','Thirty-two inch bat',47, NULL);

INSERT INTO s_product(id, name, short_desc, suggested_whlsl_price,


whlsl_units) VALUES ('50536', 'Winfield Bat','Thirty-six inch bat',50, NULL);
INSERT INTO s_region(id, name) VALUES ('1', 'North America');

INSERT INTO s_region(id, name) VALUES ('2', 'South America');

INSERT INTO s_region(id, name) VALUES ('3', 'Africa / Middle East');

INSERT INTO s_region(id, name) VALUES ('4', 'Asia');

INSERT INTO s_region(id, name) VALUES ('5', 'Europe');

INSERT INTO s_region(id, name) VALUES ('6', 'Central America /Caribbean');

INSERT INTO s_warehouse(id, region_id, address, city, state, country,


zip_code, phone, manager_id) VALUES ('101', '1','283 King Street','Seattle',
'WA', 'US', NULL,

NULL, '6');

INSERT INTO s_warehouse(id, region_id, address, city, state, country,


zip_code, phone, manager_id) VALUES ('10501', '5','5 Modrany','Bratislava',
NULL, 'Czechozlovakia',

NULL, NULL, '10');

INSERT INTO s_warehouse(id, region_id, address, city, state, country,


zip_code, phone, manager_id) VALUES ('201', '2','68 Via Centrale','Sao Paolo',
NULL, 'Brazil',NULL,

NULL, '7');

INSERT INTO s_warehouse(id, region_id, address, city, state, country,


zip_code, phone, manager_id) VALUES ('301', '3','6921 King Way','Lagos',
NULL, 'Nigeria',NULL,

NULL, '8');

INSERT INTO s_warehouse(id, region_id, address, city, state, country,


zip_code, phone, manager_id) VALUES ('401', '4','86 Chu Street','Hong Kong',
NULL, NULL,NULL,

NULL, '9');
--1. Show the structure of the S_DEPT table. Select all information from the
S_DEPT table, S_CUSTOMER table (hint DESCRIBE s_customer,...)

exec sp_help's_dept';

select * from s_dept;

select * from s_customer;

--2. Display the name and phone number for each customer

select name, phone from s_customer;

--3. Display the phone number and name for each customer, with phone
number appearing first.

select phone, name from s_customer;

--4. Display the user name for employee 23

select userid as 'user name of employee 23' from s_emp where id = 23;

--5. Display the first name, last name, and department number of the
employees in departments 10 and 50 in alphabetical order of last name.
Group

select concat(first_name, last_name) as Employees , dept_id from s_emp


where dept_id= '10' or dept_id = '50' order by last_name;

--6. Display all employees whose last names contain an “s”.

select last_name from s_emp where last_name like '%s%';

--7. Display the user names and start date of employees hired between May
5, 1990 and May 26, 1991. Order the query results by start date ascending
order.

select userid, start_DATE from s_emp where start_DATE between '1990-05-


05' and '1991-05-26';

--8. Write a query to show the last name and salary of all employees who are
not making between 1000 and 2500 per month

select last_name, salary from s_emp where salary not between 1000 and
2500;

--9. List the last name and salary of employees who earn more than 1350
who are in department 31, 42, or 50. Label the last name column Employee
Name, and label the salary column Monthly Salary
select last_name, salary from s_emp where salary > 1350 and dept_id = 31
or dept_id=42 or dept_id = 50;

--10. Display the last name and start date of every employee who was hired
in 1991

select last_name, start_DATE from s_emp where year(start_DATE) = '1991';

--11. Display the full name of all employees with no manager

select first_name, last_name from s_emp where manager_id is null;

--12. Alphabetically display all products having a name beginning with Pro

select * from s_product where name like 'Pro%';

--13. Display all product names and short descriptions for all descriptions
containing the word bicycle

select name, short_desc from s_product where short_desc like '%bicycle%';

--14. Display all short descriptions. Compare the results from above question.

--Did your response in above question return all descriptions containing


“bicycle”?

select name,short_desc from s_product;

--Yes

--15. Display the employee number, last name, and salary increased by 15%
and expressed as a whole number

update s_emp set salary = salary *1.15;

select id, last_name, salary from s_emp;

--16. Display the employee last name and title in parentheses for all
employees.

--The report should look like the output below : Jonh Herry (Director)

--CONCAT(): combine columns

select concat( last_name, ' (',title,')') from s_emp;

--17. Display each employee’s last name, hire date, and salary review date,
which is the first Monday after six months of service.

--Format the dates to appear in the format similar to Eighth of May 1992
/* select s_emp.last_name,

format (s_emp.start_DATE, 'dd') + ' of ' + format(s_emp.start_DATE, 'MMMM')


+ ' ' + format(s_emp.start_DATE, 'yyyy') AS HireDate,

FORMAT(DATEADD(DAY, (7 - DATEPART(WEEKDAY, DATEADD(MONTH, 6,


s_emp.start_DATE)) + 1) % 7, DATEADD(MONTH, 6, s_emp.start_DATE)), 'dd')
+ ' of '

+ FORMAT(DATEADD(DAY, (7 - DATEPART(WEEKDAY, DATEADD(MONTH, 6,


s_emp.start_DATE)) + 1) % 7, DATEADD(MONTH, 6, s_emp.start_DATE)),
'MMMM') + ' '

+ FORMAT(DATEADD(DAY, (7 - DATEPART(WEEKDAY, DATEADD(MONTH, 6,


s_emp.start_DATE)) + 1) % 7, DATEADD(MONTH, 6, s_emp.start_DATE)),
'yyyy') AS SalaryReviewDate

from s_emp;*/

--18. Display the product name for products that have “ski” in the name

select pr.name from s_product pr where pr.name like '%ski%';

--19. For each employee, calculate the number of months between today and
the date the employee was hired.

--Order your result by the number of months employed.

select getdate() as currdate; --test

SELECT s_emp.userid,

DATEDIFF(MONTH, start_DATE, GETDATE()) AS MonthsEmployed

FROM s_emp

ORDER BY MonthsEmployed;

--20. Display the last name for all employees and the day of the week they
started

select s_emp.last_name, datepart(weekday,start_DATE) as MMMMM from


s_emp;
select s.last_name, case datepart(weekday,start_DATE)

when 1 then 'Monday'

when 2 then 'Tuesday'

when 3 then 'Wednesday'

when 4 then 'Thursday'

when 5 then 'Friday'

when 6 then 'Saturday'

when 7 then 'Sunday'

end as WeekDay

from s_emp s;

/*21. Write a query that produces the following for each employee:

<employee name> earns <salary> monthly but wants <3 times salary>.

For example: ALLEN earns $1,100 monthly but wants $3,300.*/

select concat( first_name,' ', last_name, ' earns $', salary, ' monthly but
wants $', salary*3, '.' ) as
argggggggggggggggggggggggggggggggggggggggggggggggggg from s_emp
;

--22. Write a report containing each employee’s last name, department


number, and name of their department.

select distinct last_name, s_dept.id, s_dept.name from s_emp join s_dept on


s_emp.dept_id=s_dept.id;

--23. Write a query to display the last name, department name, and region
name of all employees who earn a commission.

select s.last_name,d.name as 'Department name', r.name as 'Region name'


from s_emp s join s_dept d on s.dept_id = d.id join s_region r on d.region_id
= r.id where s.commission_pct is not null;

/*select distinct last_name, commission_pct from s_emp;*/


--24. Display the employee name and department name for Smith

select s.first_name, s.last_name, d.name from s_emp s join s_dept d on


s.dept_id=d.id where s.last_name = 'Smith';

--25. Display the product name, product number, and quantity ordered of all
items in order number 101. Label the quantity column ORDERED.

select pr.name, pr.id, i.quantity_shipped as 'ORDERED' from s_product pr join


s_item i on i.product_id = pr.id where i.ord_id = 101

--26. Display the customer number and the last name of their sales
representative.Order the list by last name.

select o.id, e.last_name from s_ord o join s_emp e on o.sales_rep_id =e.id


order by e.last_name;

--27. Display the customer number, customer name, and order number of all
customers and their orders.

--Display the customer number and name, even if they have not placed an
order

select s_customer.id, s_customer.name, s_ord.id from s_customer left join


s_ord on s_ord.customer_id =s_customer.id;

--28. Display all employees by last name name and employee number along
with their manager’s last name and manager number

select e.last_name, e.id, e2.last_name as manager, e.manager_id from


s_emp e, s_emp e2 where e.manager_id = e2.id;

--29. Display all employees who has no manager

select * from s_emp where manager_id is null;

--30. Display all customers and the product number and quantities they
ordered for those customers whose order totaled more than 100,000

select c.*, s_item.product_id, s_item.quantity_shipped

from s_customer c join s_ord s on s.customer_id =c.id join s_item on


s_item.ord_id = s.id

where s.total >100000;

--31. Display the highest and lowest order totals in the S_ORD. Label the
columns Highest and Lowest, respectively.
select max(total) as Highest, min(total) as Lowest from s_ord;

--32. Write a query to display the minimum and maximum salary for each job
type ordered alphabetically

select title, min(s_emp.salary) as 'Min Salary', max (s_emp.salary) as 'Max


Salary' from s_emp group by title order by title ;

--33. Determine the number of managers without listing them

select distinct count (manager_id) from s_emp;

--34. Display the number of line items in each order under each order
number, labeled number of Items

select count (item_id) as 'Items' from s_item group by s_item.ord_id order by


s_item.ord_id;

--35. Display the manager number and the salary of the lowest paid
employee for that manager.

--Exclude any groups where the minimum salary is less than 1000. Sort the
output by salary

select manager_id, min (salary) as MinSalary from s_emp group by


manager_id having min(salary) >=1000 order by salary asc;

--36. Display the product number and number of times it was ordered,
labeled Times

--Ordered. Only show those products that have been ordered at least three
times. Order the data by the number of products ordered.

select s_product.id as PrID , count (s_item.ord_id) as N

from s_product join s_item on s_item.product_id = s_product.id join s_ord on


s_ord.id = s_item.ord_id group by s_product.id having count
(s_item.ord_id)>=3 order by s_product.id;

--37. Retrieve the region number, region name, and the number of
departments within region.

select s_region.id, s_region.name, count(s_dept.id) as DeptwRe from


s_region left join s_dept on s_dept.region_id = s_region.id group by
s_region.id, s_region.name;

--38. Display the order number and total item count for each order of 100 or
more items.
--For example, if order number 99 contains quantity 30 of one item, and
quantity 75 of another item, then the total item count for that order is 105.

select s_item.item_id, sum (s_item.quantity) as TotalOrd from s_item right


join s_ord on s_ord.id = s_item.ord_id group by s_item.item_id having sum
(s_item.quantity) >=100;

--39. Display the customer name and the number of orders for each
customer.

select s_customer.name as CusName, count (s_ord.id) as OrderNum from


s_customer join s_ord on s_ord.customer_id = s_customer.id group by
s_customer.name;

--40. Display the first name, last name, and start date for all employees in
the same department as Magee

select s.first_name, s.last_name, s.start_DATE from s_emp s where dept_id in


(select dept_id from s_emp where first_name = 'Magee');

--41. Display the employee number, first name, last name, and user name for
all employees with salaries above the average salary.

select id , first_name, last_name, userid from s_emp where salary > (select
avg (salary) from s_emp);

--42. Display the name and short description for any product that did not
appear on an order in the month of September, 1992.

select s_product.name, s_product.short_desc from s_product where


s_product.id not in ( select s_product.id from s_product join s_item on
s_item.product_id = s_product.id join s_ord on s_ord.id = s_item.ord_id where
DATE_ordered >='1992-09-01' and DATE_ordered <='1992-9-30');

--43. Display each sales representative’s last name in region 1 and region 2,
their customers’ names and each customer’s total sales orders.

select s_emp.last_name, s_customer.name, count(s_ord.id) as OrdID from


s_emp join s_customer on s_customer.sales_rep_id = s_emp.id join s_region
on s_region.id = s_customer.region_id join s_ord on s_ord.customer_id =
s_customer.id where s_region.id =1 or s_region.id =2 group by
s_emp.last_name, s_emp.first_name, s_customer.name;

You might also like