Unblocking The Main Thread Solving ANRs and Frozen Frames
Sql ejercicio 1
1. -----------------------------------------------------------
-- SQL ejercicio 1
-----------------------------------------------------------
-----------------------
-- Tabla Branch
-----------------------
CREATE TABLE Branch
(
branch_id int NOT NULL,
name_br varchar(20) NOT NULL ,
adress_br varchar(30) NULL ,
city_br varchar(20) NULL ,
state_br varchar(2) NULL ,
zip_br varchar(12) NULL,
);
-----------------------
-- tabla employee
-----------------------
CREATE TABLE employee
(
emp_id int NOT NULL,
fname_emp varchar(20) NOT NULL ,
lname_emp varchar (20) NOT NULL,
"start_date" date NOT NULL ,
end_date date NOT NULL,
dept_id int NOT NULL,
title varchar(20) NULL,
);
-----------------------
-----------------------
-- tabla departamento
-----------------------
CREATE TABLE Department
(
dept_id int NOT NULL ,
name_dept varchar(20) NOT NULL ,
);
-----------------------
-----------------------
-- tabla producto
-----------------------
CREATE TABLE Product
(
product_cd varchar(10) NOT NULL,
name_prod varchar(50) NOT NULL ,
date_offered date NULL ,
date_retired date NULL,
);
-----------------------
-----------------------
-- tabla tipo de producto
2. -----------------------
CREATE TABLE Product_Type
(
product_type_cd varchar(10) NOT NULL,
name_prod varchar(50) NOT NULL ,
);
-----------------------
-----------------------
-- tabla cuenta
-----------------------
CREATE TABLE account
(
account_id int NOT NULL ,
product_cd varchar(10) NULL,
cust_id int NOT NULL,
open_date date NULL,
close_date date NULL,
last_activity_date date NULL,
status_acc varchar(10) NULL,
avan_balance float(10) NULL,
open_brach_id int NOT NULL
);
-----------------------
-----------------------
-- tabla transaciones
-----------------------
CREATE TABLE "transaction"
(
txn_id int NOT NULL,
txn_date datetime NOT NULL ,
account_id int NOT NULL,
txn_type_cd varchar(10) NULL ,
amount decimal(10,2) NOT NULL,
funds_avail_date datetime NULL,
);
-----------------------
-----------------------
-- tabla Clientes
-----------------------
CREATE TABLE customer
(
cust_id int NOT NULL,
fed_id varchar (12) NOT NULL,
cust_type_cd varchar (2) NOT NULL ,
adress_cust varchar(30) NULL ,
city_cust varchar(20) NULl,
"state_cust" varchar(20) NULL,
postal_code_cust varchar(20) NULL
);
-----------------------
3. -----------------------
-- tabla Clientes empresarios
-----------------------
CREATE TABLE business
(
cust_id int NOT NULL,
name_business varchar (40) NULL ,
state_id varchar(10) NULL ,
incorp_date date NULL,
);
-----------------------
-----------------------
-- Tabla de Clientes Oficinas
-----------------------
CREATE TABLE officer
(
officer_id int NOT NULL,
cust_id int NOT NULL,
fname varchar (30) NULL ,
lname varchar (30) NULL ,
title varchar (20) NULL,
"start_date" date NULL,
end_date date null,
);
-----------------------
-----------------------
-- Tabla de Clientes Individuales
-----------------------
CREATE TABLE individual
(
cust_id int NOT NULL,
fname varchar (30) NULL ,
lname varchar (30) NULL ,
birth_date date NULL,
);
-----------------------
----------------------
-- Define primary keys
----------------------
ALTER TABLE Branch WITH NOCHECK ADD CONSTRAINT PK_Branch PRIMARY KEY
CLUSTERED (Branch_id);
ALTER TABLE Employee WITH NOCHECK ADD CONSTRAINT PK_employee PRIMARY KEY
CLUSTERED (emp_id);
ALTER TABLE product WITH NOCHECK ADD CONSTRAINT PK_productc PRIMARY KEY
CLUSTERED (product_cd);
ALTER TABLE Product_Type_cd WITH NOCHECK ADD CONSTRAINT PK_Product_Type
PRIMARY KEY CLUSTERED (product_cd);
ALTER TABLE Department WITH NOCHECK ADD CONSTRAINT PK_Department PRIMARY
KEY CLUSTERED (dept_id);
ALTER TABLE account WITH NOCHECK ADD CONSTRAINT PK_account PRIMARY KEY
CLUSTERED (account_id);
ALTER TABLE "transaction" WITH NOCHECK ADD CONSTRAINT PK_trasaction
PRIMARY KEY CLUSTERED ( txn_id);
5. --------------------------------
---registro de sucursal
--------------------------------
INSERT INTO Branch(branch_id, name_br, adress_br, city_br, state_br,
zip_br)
VALUES('1000000001', 'The angeles', '200 Agust Flor', 'Angeles', 'AP',
'44444');
INSERT INTO Branch(branch_id, name_br, adress_br, city_br,
state_br,zip_br)
VALUES('1000000002', 'Las americas', '300 Americo Vespucio', 'Veracruz',
'MX', '92464');
INSERT INTO Branch(branch_id, name_br, adress_br, city_br,
state_br,zip_br)
VALUES('1000000003', 'J Paulling Salazar', '45 vistamar ', 'Veracruz',
'VR', '12444');
INSERT INTO Branch(branch_id, name_br, adress_br, city_br,
state_br,zip_br)
VALUES('1000000004', 'Sunday', '566-A España ', 'Distrito Federal', 'MX',
'52464');
INSERT INTO Branch(branch_id, name_br, adress_br, city_br,
state_br,zip_br)
VALUES('1000000005', 'Altamirano', '567 Dictamen ', 'Guadalajara', 'GA',
'33346');
INSERT INTO Branch(branch_id, name_br, adress_br, city_br,
state_br,zip_br)
VALUES('1000000006', 'Espino Suarez', '744 Buena Vista ', 'Oaxaca', 'OX',
'84646');
INSERT INTO Branch(branch_id, name_br, adress_br, city_br,
state_br,zip_br)
VALUES('1000000007', 'Serfin', '352 Bella vista ', 'Buenos Aires', 'BA',
'454543');
INSERT INTO Branch(branch_id, name_br, adress_br, city_br,
state_br,zip_br)
VALUES('1000000008', 'Banserfi', '564 Isidro ', 'Santiago', 'TM',
'454542');
INSERT INTO Branch(branch_id, name_br, adress_br, city_br,
state_br,zip_br)
VALUES('1000000009', 'American ', '564 Familia ', 'Nuevo leon', 'MY',
'454542');
INSERT INTO Branch(branch_id, name_br, adress_br, city_br,
state_br,zip_br)
VALUES('1000000010', 'Santa Maria', '4543 Elena Olivares ', 'Tampico',
'VZ', '454542');
INSERT INTO Branch(branch_id, name_br, adress_br, city_br,
state_br,zip_br)
VALUES('1000000011', 'The cid', '5453 Puesta del sol ', 'Veracruz', 'vz',
'454542');
INSERT INTO Branch(branch_id, name_br, adress_br, city_br,
state_br,zip_br)
VALUES('1000000012', 'Zachizone', '553 Amaranto ', 'Zachila', 'OX',
'454542');
INSERT INTO Branch(branch_id, name_br, adress_br, city_br,
state_br,zip_br)
6. VALUES('1000000013', 'Primero de mayo', '5434 Centro ', 'Veracruz', 'VZ',
'5945322');
INSERT INTO Branch(branch_id, name_br, adress_br, city_br,
state_br,zip_br)
VALUES('1000000014', '20 de noviembre', '365 20 de noviembre ',
'Veracruz', 'VZ', '5945442');
INSERT INTO Branch(branch_id, name_br, adress_br, city_br,
state_br,zip_br)
VALUES('1000000015', 'Milan', '365 20 de noviembre ', 'Veracruz', 'VZ',
'5945442');
INSERT INTO Branch(branch_id, name_br, adress_br, city_br,
state_br,zip_br)
VALUES('1000000016', 'felicidad', '34 20 de noviembre ', 'Veracruz',
'VZ', '5945436');
INSERT INTO Branch(branch_id, name_br, adress_br, city_br,
state_br,zip_br)
VALUES('1000000017', 'Astillero', '8676 Mateo', 'cordoba', 'VZ',
'5945442');
INSERT INTO Branch(branch_id, name_br, adress_br, city_br,
state_br,zip_br)
VALUES('1000000018', 'Villa', '64 Villa Pequeña', 'Xalapa', 'VZ',
'1944442');
INSERT INTO Branch(branch_id, name_br, adress_br, city_br,
state_br,zip_br)
VALUES('1000000019', 'Los pinos', '644 Los pinos', 'Perote', 'VZ',
'295442');
INSERT INTO Branch(branch_id, name_br, adress_br, city_br,
state_br,zip_br)
VALUES('1000000020', 'Santiago', '44 Gutierrez Morales', 'Nuevo Leon',
'MY', '655442');
--------------------------------
---registro de productos
--------------------------------
INSERT INTO Product(product_cd, name_prod, date_offered, date_retired)
VALUES('BON01', 'Papel Bond Sol', '2010-02-02', '2010-03-06');
INSERT INTO Product(product_cd, name_prod, date_offered, date_retired)
VALUES('LAG01', 'Lapiz Grafito Print ', '2010-01-31', '2010-02-22');
INSERT INTO Product(product_cd, name_prod, date_offered, date_retired)
VALUES('FOCB1', 'Fomi carta brillante ', '2010-01-31', '2010-02-22');
INSERT INTO Product(product_cd, name_prod, date_offered, date_retired)
VALUES('SSTI1', 'Sony Tinta Impresora ', '2010-02-05', '2010-02-26');
INSERT INTO Product(product_cd, name_prod, date_offered, date_retired)
VALUES('DDL01', 'Durometro de lapiz ', '2010-02-06', '2010-03-01');
INSERT INTO Product(product_cd, name_prod, date_offered, date_retired)
VALUES('VMC01', 'Volantes media carta ', '2010-02-06', '2010-03-01');
INSERT INTO Product(product_cd, name_prod, date_offered, date_retired)
VALUES('GEC42', 'Grapas estandar alterk plus ', '2010-01-06', '2010-03-
01');
INSERT INTO Product(product_cd, name_prod, date_offered, date_retired)
VALUES('IMA01', 'Imanes ok impresos', '2010-03-06', '2010-04-01');
INSERT INTO Product(product_cd, name_prod, date_offered, date_retired)
VALUES('MART1', 'Marcatextos', '2010-03-06', '2010-04-01');
INSERT INTO Product(product_cd, name_prod, date_offered, date_retired)
VALUES('POFV1', 'Postales A color', '2010-04-06', '2010-05-01');
INSERT INTO Product(product_cd, name_prod, date_offered, date_retired)
VALUES('CLIP1', 'Clip alterkl plus', '2010-02-06', '2010-05-01');
7. INSERT INTO Product(product_cd, name_prod, date_offered, date_retired)
VALUES('FTC01', 'Folder Carta Alterkl plus', '2010-02-06', '2010-05-01');
INSERT INTO Product(product_cd, name_prod, date_offered, date_retired)
VALUES('MTB02', 'Marca texto borrable', '2010-02-10', '2010-05-01');
INSERT INTO Product(product_cd, name_prod, date_offered, date_retired)
VALUES('MBF01', 'Marcador para billetes falsos Check it azoe', '2010-02-
10', '2010-05-01');
INSERT INTO Product(product_cd, name_prod, date_offered, date_retired)
VALUES('HC001', 'Hojas color millar', '2011-01-01', '2011-01-31');
INSERT INTO Product(product_cd, name_prod, date_offered, date_retired)
VALUES('FCC01', 'archivador', '2011-01-03', '2011-09-31');
INSERT INTO Product(product_cd, name_prod, date_offered, date_retired)
VALUES('EM001', 'equipo multifuncion', '2010-01-03', '2011-01-31');
INSERT INTO Product(product_cd, name_prod, date_offered, date_retired)
VALUES('DP002', 'destructora de papel', '2010-01-01', '2011-01-31');
INSERT INTO Product(product_cd, name_prod, date_offered, date_retired)
VALUES('RF001', 'Regla flexible Shelly', '2011-02-03', '2011-01-31');
INSERT INTO Product(product_cd, name_prod, date_offered, date_retired)
VALUES('CCP01', 'Chinche Color 100 Piezas', '2011-02-03', '2011-01-31');
--------------------------------
---registro de tipos de productos
--------------------------------
INSERT INTO Product_Type(product_type_cd,name_prod)
VALUES('EQ01', 'Computadora de escritorio HP');
INSERT INTO Product_Type(product_type_cd,name_prod)
VALUES('EQ02', 'Laptop Toshiba Satellite');
INSERT INTO Product_Type(product_type_cd,name_prod)
VALUES('CI01', 'Copia BYN 80%');
INSERT INTO Product_Type(product_type_cd,name_prod)
VALUES('CI02', 'Copia BYN 100%');
INSERT INTO Product_Type(product_type_cd,name_prod)
VALUES('PU01', 'Poster C. 50x50');
INSERT INTO Product_Type(product_type_cd,name_prod)
VALUES('AA01', 'Lapiz Grafito para dibujar Big');
INSERT INTO Product_Type(product_type_cd,name_prod)
VALUES('DG01', 'Edicion Imagen N1');
INSERT INTO Product_Type(product_type_cd,name_prod)
VALUES('UE01', 'Lapiz n°2 Milano ');
INSERT INTO Product_Type(product_type_cd,name_prod)
VALUES('DG02', 'Edicion Imagen N2 ');
INSERT INTO Product_Type(product_type_cd,name_prod)
VALUES('AA02', 'Hojas de dibujo Cari ');
INSERT INTO Product_Type(product_type_cd,name_prod)
VALUES('AA03', 'Paleta para pintar SER');
INSERT INTO Product_Type(product_type_cd,name_prod)
VALUES('EO01', 'Escritorio estandar oficina Bell ');
INSERT INTO Product_Type(product_type_cd,name_prod)
VALUES('EO02', 'Maquina de escribir Olympia ');
INSERT INTO Product_Type(product_type_cd,name_prod)
VALUES('EO03', 'Trituradora de papel Tell ');
INSERT INTO Product_Type(product_type_cd,name_prod)
VALUES('EQ03', 'Scanner HP 2093 ');
INSERT INTO Product_Type(product_type_cd,name_prod)
VALUES('EO04', 'Copiadora ');
8. INSERT INTO Product_Type(product_type_cd,name_prod)
VALUES('DG02', 'Edicion Video ');
INSERT INTO Product_Type(product_type_cd,name_prod)
VALUES('PU02', 'Millar volantes color ');
INSERT INTO Product_Type(product_type_cd,name_prod)
VALUES('RE01', 'Formateo de Laptop ');
INSERT INTO Product_Type(product_type_cd,name_prod)
VALUES('RE02', 'Cambio de memoria ram ');
--------------------------------
---registro de cuentas
--------------------------------
INSERT INTO
account(account_id,open_date,close_date,last_activity_date,status_acc,ava
n_balance)
VALUES('101', '2002-01-01','2009-01-01','2008-11-23','Active','4000');
INSERT INTO
account(account_id,open_date,close_date,last_activity_date,status_acc,ava
n_balance)
VALUES('102', '1990-01-01','2010-01-01','2008-11-01','Inactive','100');
INSERT INTO
account(account_id,open_date,close_date,last_activity_date,status_acc,ava
n_balance)
VALUES('103', '2002-01-01','2009-01-01','2008-11-23','Active','4000');
INSERT INTO
account(account_id,open_date,close_date,last_activity_date,status_acc,ava
n_balance)
VALUES('104', '1995-01-01','2004-01-01','2000-01-03','Inactive','1000');
INSERT INTO
account(account_id,open_date,close_date,last_activity_date,status_acc,ava
n_balance)
VALUES('105', '1988-01-01','2000-01-01','1989-11-23','Inactive','2600');
INSERT INTO
account(account_id,open_date,close_date,last_activity_date,status_acc,ava
n_balance)
VALUES('106', '2002-01-01','2009-01-01','2008-11-23','Active','2500');
INSERT INTO
account(account_id,open_date,close_date,last_activity_date,status_acc,ava
n_balance)
VALUES('107', '2002-03-01','2009-01-01','2008-11-23','Active','2600');
INSERT INTO
account(account_id,open_date,close_date,last_activity_date,status_acc,ava
n_balance)
VALUES('108', '2002-01-01','2004-01-01','2003-09-01','Active','2000');
INSERT INTO
account(account_id,open_date,close_date,last_activity_date,status_acc,ava
n_balance)
VALUES('109', '1999-01-01','2009-01-01','2004-11-23','Active','1500');
INSERT INTO
account(account_id,open_date,close_date,last_activity_date,status_acc,ava
n_balance)
VALUES('110', '2003-03-01','2010-01-01','2008-02-11','Inactive','2600');
INSERT INTO
account(account_id,open_date,close_date,last_activity_date,status_acc,ava
n_balance)
VALUES('110', '2001-01-01','2009-01-01','2008-03-12','Inactive','3000');
9. INSERT INTO
account(account_id,open_date,close_date,last_activity_date,status_acc,ava
n_balance)
VALUES('111', '2002-04-01','2009-01-01','2008-11-23','Active','40000');
INSERT INTO
account(account_id,open_date,close_date,last_activity_date,status_acc,ava
n_balance)
VALUES('112', '2007-01-01','2009-01-01','2008-11-23','Active','100');
INSERT INTO
account(account_id,open_date,close_date,last_activity_date,status_acc,ava
n_balance)
VALUES('113', '2006-01-01','2010-01-01','2008-11-23','Inactive','50');
INSERT INTO
account(account_id,open_date,close_date,last_activity_date,status_acc,ava
n_balance)
VALUES('114', '2002-08-01','2004-01-01','2002-11-23','Inactive','2700');
INSERT INTO
account(account_id,open_date,close_date,last_activity_date,status_acc,ava
n_balance)
VALUES('115', '1999-01-01','2004-01-01','2002-11-23','Active','2700');
INSERT INTO
account(account_id,open_date,close_date,last_activity_date,status_acc,ava
n_balance)
VALUES('116', '1995-01-01','2004-01-01','2002-11-23','Active','2500');
INSERT INTO
account(account_id,open_date,close_date,last_activity_date,status_acc,ava
n_balance)
VALUES('117', '2000-01-01','2009-01-01','2005-12-23','Inactive','700');
INSERT INTO
account(account_id,open_date,close_date,last_activity_date,status_acc,ava
n_balance)
VALUES('118', '1996-01-01','2004-01-01','2003-11-23','Active','1500');
INSERT INTO
account(account_id,open_date,close_date,last_activity_date,status_acc,ava
n_balance)
VALUES('119', '1997-01-01','2005-01-01','2003-11-01','Active','2400');
INSERT INTO
account(account_id,open_date,close_date,last_activity_date,status_acc,ava
n_balance)
VALUES('120', '1997-01-01','2005-01-01','2004-11-01','Active','2501');
--------------------------------
---registro de transaciones
--------------------------------
INSERT INTO "transaction"(txn_id,txn_date,account_id, txn_type_cd,amount,
funds_avail_date)
VALUES('1', '20050222','101','CDT','1000','20050222');
INSERT INTO "transaction"(txn_id,txn_date,account_id,txn_type_cd,amount,
funds_avail_date)
VALUES('2', '20050223','102','CDT','525.75','20050223');
INSERT INTO "transaction"(txn_id,txn_date,account_id,txn_type_cd,amount,
funds_avail_date)
VALUES('3', '20050224','101','DBT','100','20050224');
INSERT INTO "transaction"(txn_id,txn_date,account_id,txn_type_cd,amount,
funds_avail_date)
VALUES('4', '20050224','103','CDT','55','20050224');
10. INSERT INTO "transaction"(txn_id,txn_date,account_id,txn_type_cd,amount,
funds_avail_date)
VALUES('5', '20050225','101','DBT','50','20050225');
INSERT INTO "transaction"(txn_id,txn_date,account_id,txn_type_cd,amount,
funds_avail_date)
VALUES('6', '20050225','106','CDT','100','20050225');
INSERT INTO "transaction"(txn_id,txn_date,account_id,txn_type_cd,amount,
funds_avail_date)
VALUES('7', '20050225','102','CDT','125.37','20050225');
INSERT INTO "transaction"(txn_id,txn_date,account_id,txn_type_cd,amount,
funds_avail_date)
VALUES('8', '20050226','103','DBT','10','20050226');
INSERT INTO "transaction"(txn_id,txn_date,account_id,txn_type_cd,amount,
funds_avail_date)
VALUES('9', '20050226','101','CDT','75','20050226');
INSERT INTO "transaction"(txn_id,txn_date,account_id,txn_type_cd,amount,
funds_avail_date)
VALUES('10', '20050226','103','CDT','30','20050226');
INSERT INTO "transaction"(txn_id,txn_date,account_id,txn_type_cd,amount,
funds_avail_date)
VALUES('11', '20050227','102','DBT','100','20050227');
INSERT INTO "transaction"(txn_id,txn_date,account_id,txn_type_cd,amount,
funds_avail_date)
VALUES('12', '20050228','101','CDT','80','20050228');
INSERT INTO "transaction"(txn_id,txn_date,account_id,txn_type_cd,amount,
funds_avail_date)
VALUES('13', '20050228','104','DBT','200','20050228');
INSERT INTO "transaction"(txn_id,txn_date,account_id,txn_type_cd,amount,
funds_avail_date)
VALUES('14', '20050228','106','CDT','1000','20050228');
INSERT INTO "transaction"(txn_id,txn_date,account_id,txn_type_cd,amount,
funds_avail_date)
VALUES('15', '20050301','101','CDT','70','20050301');
INSERT INTO "transaction"(txn_id,txn_date,account_id,txn_type_cd,amount,
funds_avail_date)
VALUES('16', '20050301','107','DBT','1000','20050301');
INSERT INTO "transaction"(txn_id,txn_date,account_id,txn_type_cd,amount,
funds_avail_date)
VALUES('17', '20050301','111','CDT','2000','20050301');
INSERT INTO "transaction"(txn_id,txn_date,account_id,txn_type_cd,amount,
funds_avail_date)
VALUES('18', '20050302','104','DBT','200','20050302');
INSERT INTO "transaction"(txn_id,txn_date,account_id,txn_type_cd,amount,
funds_avail_date)
VALUES('19', '20050303','106','CDT','900','20050303');
INSERT INTO "transaction"(txn_id,txn_date,account_id,txn_type_cd,amount,
funds_avail_date)
VALUES('20', '20050304','101','CDT','1000','20050222');
--------------------------------
---registro de empleados
--------------------------------
INSERT INTO employee(emp_id, fname_emp, lname_emp,
"start_date",end_date,dept_id, title)
VALUES('1', 'Michael', 'Smith','2003-02-03','2008-11-12', '1','
Supervisor');
11. INSERT INTO employee(emp_id, fname_emp, lname_emp,
"start_date",end_date,dept_id, title)
VALUES('2', 'Susan', 'barker', '2003-02-03','2009-11-12', '2','
Supervisor');
INSERT INTO employee(emp_id, fname_emp, lname_emp,
"start_date",end_date,dept_id, title)
VALUES('3', 'Robert', 'Tyler', '2004-03-12','2009-11-12', '1',' Ejecutivo
de ventas');
INSERT INTO employee(emp_id, fname_emp, lname_emp,
"start_date",end_date,dept_id, title)
VALUES('4', 'Susan', 'Hawthorne', '2003-02-03','2009-11-12', '2','
Supervisor');
INSERT INTO employee(emp_id, fname_emp, lname_emp,
"start_date",end_date,dept_id, title)
VALUES('5', 'John', 'Gooding', '2004-03-12','2010-11-12', '3','
Supervisor');
INSERT INTO employee(emp_id, fname_emp, lname_emp,
"start_date",end_date,dept_id, title)
VALUES('6', 'Helen', 'Fleming', '2008-03-12','2011-12-12', '1','
Supervisor');
INSERT INTO employee(emp_id, fname_emp, lname_emp,
"start_date",end_date,dept_id, title)
VALUES('7', 'Chris', 'Turcker', '2002-01-01','2005-11-06', '4','
Supervisor');
INSERT INTO employee(emp_id, fname_emp, lname_emp,
"start_date",end_date,dept_id, title)
VALUES('8', 'Sarah', 'Turcker', '2002-01-01','2005-11-06', '4','
Supervisor');
INSERT INTO employee(emp_id, fname_emp, lname_emp,
"start_date",end_date,dept_id, title)
VALUES('9', 'Jane', 'Grossman', '2001-01-01','2010-01-01', '5','
Supervisor');
INSERT INTO employee(emp_id, fname_emp, lname_emp,
"start_date",end_date,dept_id, title)
VALUES('10', 'Paula', 'Robers', '2009-01-01','2011-06-01', '4','
Ejecutivo de ventas');
INSERT INTO employee(emp_id, fname_emp, lname_emp,
"start_date",end_date,dept_id, title)
VALUES('11', 'Thomas', 'Ziegler', '2009-01-01','2011-06-01', '2','
Ejecutivo de ventas');
INSERT INTO employee(emp_id, fname_emp, lname_emp,
"start_date",end_date,dept_id, title)
VALUES('12', 'Samantha', 'Jameson', '2003-01-01','2010-06-01', '1','
Ejecutivo de ventas');
INSERT INTO employee(emp_id, fname_emp, lname_emp,
"start_date",end_date,dept_id, title)
VALUES('13', 'John', 'Jameson', '2001-01-01','2004-06-01', '1','
Ejecutivo de ventas');
INSERT INTO employee(emp_id, fname_emp, lname_emp,
"start_date",end_date,dept_id, title)
VALUES('14', 'Cindy', 'Mason', '2003-01-01','2005-06-01', '2',' Ejecutivo
de ventas');
INSERT INTO employee(emp_id, fname_emp, lname_emp,
"start_date",end_date,dept_id, title)
VALUES('15', 'Frank', 'Portman', '2000-01-01','2007-07-07', '3','
Ejecutivo de ventas');
12. INSERT INTO employee(emp_id, fname_emp, lname_emp,
"start_date",end_date,dept_id, title)
VALUES('16', 'Theresa', 'Markman', '2001-03-01','2007-12-01', '3','
Auxiliar de ventas');
INSERT INTO employee(emp_id, fname_emp, lname_emp,
"start_date",end_date,dept_id, title)
VALUES('17', 'Beth', 'Flower', '2001-03-01','2008-12-01', '1',' Auxiliar
de ventas');
INSERT INTO employee(emp_id, fname_emp, lname_emp,
"start_date",end_date,dept_id, title)
VALUES('18', 'Rick', 'Tulman', '2001-04-03','2011-12-01', '2',' Auxiliar
de ventas');
INSERT INTO employee(emp_id, fname_emp, lname_emp,
"start_date",end_date,dept_id, title)
VALUES('18', 'Ray', 'Zagart', '2001-01-03','2011-02-01', '5',' Auxiliar
de ventas');
INSERT INTO employee(emp_id, fname_emp, lname_emp,
"start_date",end_date,dept_id, title)
VALUES('19', 'Alexander', 'Leccardi', '2000-11-13','2011-01-01', '4','
Auxiliar de ventas');
INSERT INTO employee(emp_id, fname_emp, lname_emp,
"start_date",end_date,dept_id, title)
VALUES('20', 'Sam', 'Maslow', '2000-11-13','2011-03-01', '8',' Auxiliar
de ventas');
--------------------------------
---registro de departamentos
--------------------------------
INSERT INTO Department(dept_id, name_dept)
VALUES('01', 'Reparaciones de equipo de computo');
INSERT INTO Department(dept_id, name_dept)
VALUES('02', 'Equipo de computo');
INSERT INTO Department(dept_id, name_dept)
VALUES('03', 'Ventas');
INSERT INTO Department(dept_id, name_dept)
VALUES('04', 'Utiles escolares');
INSERT INTO Department(dept_id, name_dept)
VALUES('05', 'Mercadoctenia');
INSERT INTO Department(dept_id, name_dept)
VALUES('06', 'Equipo y muebleria de oficina');
INSERT INTO Department(dept_id, name_dept)
VALUES('07', 'Articulos Artisticos');
INSERT INTO Department(dept_id, name_dept)
VALUES('08', 'Copias e impresiones');
INSERT INTO Department(dept_id, name_dept)
VALUES('09', 'Diseño grafico');
INSERT INTO Department(dept_id, name_dept)
VALUES('10', 'Material empresarial');
INSERT INTO Department(dept_id, name_dept)
VALUES('11', 'Publicidad');
--------------------------------
---registro de clientes
--------------------------------
13. INSERT INTO customer(cust_id,
fed_id,cust_type_cd,adress_cust,state_cust,postal_code_cust)
VALUES('1', 'BEI900503','OF', '200 Millan Rose', 'Mexico','91500');
INSERT INTO customer(cust_id,
fed_id,cust_type_cd,adress_cust,state_cust,postal_code_cust)
VALUES('2', 'GAM760530','BS', '25 España ', 'Veracruz','91700');
INSERT INTO customer(cust_id,
fed_id,cust_type_cd,adress_cust,state_cust,postal_code_cust)
VALUES('3', 'ZAB911130','BS', '45 Vista del mar ', 'Veracruz','91700');
INSERT INTO customer(cust_id,
fed_id,cust_type_cd,adress_cust,state_cust,postal_code_cust)
VALUES('4', 'SAV910103','IN', '25 Sol de Verano ', 'Oaxaca','91401');
INSERT INTO customer(cust_id,
fed_id,cust_type_cd,adress_cust,state_cust,postal_code_cust)
VALUES('5', 'SAD910503','IN', '25 Sol de Verano ', 'Mexico','91401');
INSERT INTO customer(cust_id,
fed_id,cust_type_cd,adress_cust,state_cust,postal_code_cust)
VALUES('6', 'MAP910304','OF', '45 New Sun ', 'The angeles','10421');
INSERT INTO customer(cust_id,
fed_id,cust_type_cd,adress_cust,state_cust,postal_code_cust)
VALUES('7', 'CAP900110','BS', '146 Art 123 ', 'Nuevo Leon','10400');
INSERT INTO customer(cust_id,
fed_id,cust_type_cd,adress_cust,state_cust,postal_code_cust)
VALUES('8', 'CHR890214','IN', '146 Amaranto', 'Veracruz','91701');
INSERT INTO customer(cust_id,
fed_id,cust_type_cd,adress_cust,state_cust,postal_code_cust)
VALUES('9', 'BAA921116','BS', '23 Sol Naciente', 'Oaxaca','91421');
INSERT INTO customer(cust_id,
fed_id,cust_type_cd,adress_cust,state_cust,postal_code_cust)
VALUES('10', 'GAR911220','OF', '5343 American', 'New York','54332');
INSERT INTO customer(cust_id,
fed_id,cust_type_cd,adress_cust,state_cust,postal_code_cust)
VALUES('11', 'ESA880310','OF', '33 20 Noviembre', 'Veracruz','91942');
INSERT INTO customer(cust_id,
fed_id,cust_type_cd,adress_cust,state_cust,postal_code_cust)
VALUES('12', 'SEA891130','IN', '20 Chapultepec', 'Veracruz','93232');
INSERT INTO customer(cust_id,
fed_id,cust_type_cd,adress_cust,state_cust,postal_code_cust)
VALUES('13', 'ASE921201','IN', '23 Ortiz Rubio', 'Veracruz','91312');
INSERT INTO customer(cust_id,
fed_id,cust_type_cd,adress_cust,state_cust,postal_code_cust)
VALUES('14', 'SEL930411','BS', '123 Margarita', 'Oaxaca','90012');
INSERT INTO customer(cust_id,
fed_id,cust_type_cd,adress_cust,state_cust,postal_code_cust)
VALUES('15', 'SAL910512','OF', '304 Isamara', 'Nuevo Leon','81012');
INSERT INTO customer(cust_id,
fed_id,cust_type_cd,adress_cust,state_cust,postal_code_cust)
VALUES('16', 'ANL910129','IN', '34 Americas', 'California','21012');
INSERT INTO customer(cust_id,
fed_id,cust_type_cd,adress_cust,state_cust,postal_code_cust)
VALUES('17', 'LAN921209','IN', '334 Chapultepec', 'Mexico','91019');
INSERT INTO customer(cust_id,
fed_id,cust_type_cd,adress_cust,state_cust,postal_code_cust)
VALUES('18', 'ANS640209','BS', '394 Arista', 'Mexico','31119');
INSERT INTO customer(cust_id,
fed_id,cust_type_cd,adress_cust,state_cust,postal_code_cust)
VALUES('19', 'SAM790211','BS', '204 Blue station', 'New York','11419');
14. INSERT INTO customer(cust_id,
fed_id,cust_type_cd,adress_cust,state_cust,postal_code_cust)
VALUES('20', 'ESP990722','IN', '204 Pasteur', 'Veracruz','91932');
--------------------------------
---registro de clientes individuales
--------------------------------
INSERT INTO individual(cust_id, fname,lname,birth_date)
VALUES('4', 'Laura','Perez', '1991-02-21');
INSERT INTO individual(cust_id, fname,lname,birth_date)
VALUES('5', 'Gerardo','Gutierrez', '1989-01-22');
INSERT INTO individual(cust_id, fname,lname,birth_date)
VALUES('8', 'Esmeralda','Milan', '1990-11-11');
INSERT INTO individual(cust_id, fname,lname,birth_date)
VALUES('12', 'chistian','Jacome', '1988-01-15');
INSERT INTO individual(cust_id, fname,lname,birth_date)
VALUES('13', 'Esperanza','Barrada', '1990-11-30');
INSERT INTO individual(cust_id, fname,lname,birth_date)
VALUES('16', 'Rodrigo','Campos', '1977-05-24');
INSERT INTO individual(cust_id, fname,lname,birth_date)
VALUES('17', 'Jason','Parker', '1981-04-14');
INSERT INTO individual(cust_id, fname,lname,birth_date)
VALUES('20', 'Willy','Gomez', '1989-09-12');
INSERT INTO individual(cust_id, fname,lname,birth_date)
VALUES('21', 'Jorge','Perez', '1987-12-10');
INSERT INTO individual(cust_id, fname,lname,birth_date)
VALUES('50', 'Samantha','Rodriguez', '1991-02-21');
INSERT INTO individual(cust_id, fname,lname,birth_date)
VALUES('660', 'Arely','Zamora', '1993-09-21');
INSERT INTO individual(cust_id, fname,lname,birth_date)
VALUES('312', 'Catalina','Gutierrez', '1991-02-21');
INSERT INTO individual(cust_id, fname,lname,birth_date)
VALUES('45', 'Carlos','Solano', '1990-01-11');
INSERT INTO individual(cust_id, fname,lname,birth_date)
VALUES('47', 'Enrique','Garcia', '1990-02-21');
INSERT INTO individual(cust_id, fname,lname,birth_date)
VALUES('48', 'Guadalupe','Jimenez', '1981-03-25');
INSERT INTO individual(cust_id, fname,lname,birth_date)
VALUES('94', 'Andres','Granda', '1988-02-21');
INSERT INTO individual(cust_id, fname,lname,birth_date)
VALUES('34', 'Isabel','Martinez', '1966-08-04');
INSERT INTO individual(cust_id, fname,lname,birth_date)
VALUES('46', 'Sergioo','Basalles', '1971-09-21');
INSERT INTO individual(cust_id, fname,lname,birth_date)
VALUES('454', 'Erick','Garcia', '1991-02-21');
INSERT INTO individual(cust_id, fname,lname,birth_date)
VALUES('456', 'Eduardo','Campos', '1991-12-21');
--------------------------------
---registro de clientes empresariales
--------------------------------
INSERT INTO business(cust_id, name_business,state_id,incorp_date)
VALUES('2', 'Fachess','VZ932', '1970-01-02');
INSERT INTO business(cust_id, name_business,state_id,incorp_date)
VALUES('3', 'Myspace','VZ933', '1972-02-01');
15. INSERT INTO business(cust_id, name_business,state_id,incorp_date)
VALUES('7', 'GOMSA logistica','VZ934', '1950-01-01');
INSERT INTO business(cust_id, name_business,state_id,incorp_date)
VALUES('14', 'Estafeta','VZ931', '1950-01-31');
INSERT INTO business(cust_id, name_business,state_id,incorp_date)
VALUES('18', 'Habiplat México','MX132', '1990-01-01');
INSERT INTO business(cust_id, name_business,state_id,incorp_date)
VALUES('313', 'Grupo Bimbo','MX2432', '1870-01-02');
INSERT INTO business(cust_id, name_business,state_id,incorp_date)
VALUES('477', 'Famsa','VZ932', '1970-01-02');
INSERT INTO business(cust_id, name_business,state_id,incorp_date)
VALUES('675', 'elektra','VZ932', '1956-01-01');
INSERT INTO business(cust_id, name_business,state_id,incorp_date)
VALUES('437', 'Terra','VZ202', '1980-01-02');
INSERT INTO business(cust_id, name_business,state_id,incorp_date)
VALUES('246', 'Multipack','VZ102', '1976-01-11');
INSERT INTO business(cust_id, name_business,state_id,incorp_date)
VALUES('23', 'Buro Nacional de recursos humanos','OX932', '1970-01-02');
INSERT INTO business(cust_id, name_business,state_id,incorp_date)
VALUES('21', 'One Digit','VZ900', '1980-01-01');
INSERT INTO business(cust_id, name_business,state_id,incorp_date)
VALUES('22', 'Seguros Banorte','MX122', '1950-01-01');
INSERT INTO business(cust_id, name_business,state_id,incorp_date)
VALUES('26', 'Fundidora dobbie','VZ402', '1990-01-02');
INSERT INTO business(cust_id, name_business,state_id,incorp_date)
VALUES('29', 'Efectivale','MX100', '2000-01-01');
INSERT INTO business(cust_id, name_business,state_id,incorp_date)
VALUES('40', 'Plasticos libertad','VZ966', '1970-01-02');
INSERT INTO business(cust_id, name_business,state_id,incorp_date)
VALUES('30', 'Aba Seguros','VZ636', '1980-01-02');
INSERT INTO business(cust_id, name_business,state_id,incorp_date)
VALUES('225', 'Axa Seguros','VZ132', '1999-01-12');
INSERT INTO business(cust_id, name_business,state_id,incorp_date)
VALUES('66', 'Grupo intercom comercial','MY122', '2000-01-05');
INSERT INTO business(cust_id, name_business,state_id,incorp_date)
VALUES('674', 'Plasticos Habel','VZ902', '1990-01-01');
--------------------------------
---registro de clientes de oficina
--------------------------------
INSERT INTO officer(officer_id,
cust_id,fname,lname,title,"start_date",end_date)
VALUES('1', '1','Alejandro', 'Viñeda','Gerente','2001-01-01','2010-01-
31');
INSERT INTO officer(officer_id,
cust_id,fname,lname,title,"start_date",end_date)
VALUES('2', '6','Mathilda', 'Cepeda','Supervisor','2005-01-01','2010-01-
31');
INSERT INTO officer(officer_id,
cust_id,fname,lname,title,"start_date",end_date)
VALUES('3', '10','Jaqueline', 'Jimenez','Gerente','2003-01-01','2009-01-
11');
INSERT INTO officer(officer_id,
cust_id,fname,lname,title,"start_date",end_date)
VALUES('4', '11','Esperanza', 'Espejo','Supervisor','2005-01-01','2010-
01-31');
16. INSERT INTO officer(officer_id,
cust_id,fname,lname,title,"start_date",end_date)
VALUES('5', '15','Roberto', 'Cepeda','Supervisor','2007-01-01','2011-01-
31');
INSERT INTO officer(officer_id,
cust_id,fname,lname,title,"start_date",end_date)
VALUES('6', '55','Arturo', 'Silva','Gerente','2001-01-01','2009-01-01');
INSERT INTO officer(officer_id,
cust_id,fname,lname,title,"start_date",end_date)
VALUES('7', '64','Ismael', 'Zuñiga','Supervisor','2001-01-01','2006-01-
21');
INSERT INTO officer(officer_id,
cust_id,fname,lname,title,"start_date",end_date)
VALUES('8', '67','Mathilda', 'Colins','Supervisor','2000-01-01','2010-01-
31');
INSERT INTO officer(officer_id,
cust_id,fname,lname,title,"start_date",end_date)
VALUES('9', '30','Sandra', 'Cedeño','Supervisor','2005-01-01','2010-01-
31');
INSERT INTO officer(officer_id,
cust_id,fname,lname,title,"start_date",end_date)
VALUES('10', '60','Dora', 'Dominguez','Supervisor','2011-01-01','2011-01-
31');
INSERT INTO officer(officer_id,
cust_id,fname,lname,title,"start_date",end_date)
VALUES('11', '50','Manuel', 'Torres','Supervisor','2000-01-01','2005-01-
31');
INSERT INTO officer(officer_id,
cust_id,fname,lname,title,"start_date",end_date)
VALUES('12', '66','Arturo', 'Cepeda','Supervisor','2005-01-01','2010-01-
31');
INSERT INTO officer(officer_id,
cust_id,fname,lname,title,"start_date",end_date)
VALUES('13', '67','Enrique', 'Martinez','Gerente','2001-01-01','2008-01-
01');
INSERT INTO officer(officer_id,
cust_id,fname,lname,title,"start_date",end_date)
VALUES('14', '69','Mathilda', 'Cepeda','Supervisor','2005-01-01','2010-
01-31');
INSERT INTO officer(officer_id,
cust_id,fname,lname,title,"start_date",end_date)
VALUES('15', '86','Horlando', 'Campos','Gerente','2006-01-01','2010-01-
21');
INSERT INTO officer(officer_id,
cust_id,fname,lname,title,"start_date",end_date)
VALUES('16', '575','Ismael', 'Cepeda','Supervisor','2005-01-01','2010-01-
31');
INSERT INTO officer(officer_id,
cust_id,fname,lname,title,"start_date",end_date)
VALUES('17', '754','Juan', 'Rodriguez','Supervisor','2005-01-01','2010-
01-31');
INSERT INTO officer(officer_id,
cust_id,fname,lname,title,"start_date",end_date)
VALUES('18', '422','Ignacio', 'Solano','Supervisor','2001-01-01','2009-
01-01');
INSERT INTO officer(officer_id,
cust_id,fname,lname,title,"start_date",end_date)
17. VALUES('19', '96','Jose', 'Reyes','Supervisor','2005-01-01','2010-01-
31');
INSERT INTO officer(officer_id,
cust_id,fname,lname,title,"start_date",end_date)
VALUES('20', '866','Carlos', 'Garcia','Supervisor','1991-01-01','2000-01-
31');
1
Recupere el ID de empleado, el nombre y el apellido de todos los empleados delbanco.
Ordene por apellido y nombre.
SELECT emp_id_fname_emp_lname_emp
From employee
Order by i name_emp,fname;
7 Construya una consulta que recupere todas las cuentas abiertas en 2002.
SELECT
account_id,open_date,close_date,last_activity_date,status_acc,avan_balanc
e
from account
where YEAR(open_date)=2002;