Está en la página 1de 4

Alumno: Jorge Rodriguez – 61611648

Catedratico: Ing.Osman Bobadilla

Fecha: 07/02/2022

Asignatura: Admin Base de Datos


create database Tarea3

create table departamento (

dept_no varchar(3) not null primary key,

nombre_dept varchar(50),

localizacion varchar(50)

);

create table empleado (

codigo_c varchar(5) not null primary key,

nombre varchar(50),

edad int,

oficio varchar(50),

dir varchar(50),

fecha_alt date,

salario float,

comision float,

dept_no varchar(3)

);

ALTER TABLE empleado ADD CONSTRAINT kf_cod_dep FOREIGN KEY (dept_no) REFERENCES

departamento(dept_no);

INSERT INTO departamento values('10','Desarrollo software','El Coyolar');

INSERT INTO departamento values('20','Análisis Sistema','Guadalupe');

INSERT INTO departamento values('30','Contabilidad','Subtiava');

INSERT INTO departamento values('40','Ventas','San Felipe');

INSERT INTO empleado values('5f','Rocha Vargas Hector',27,


'Vendedor','Leon','1983/05/12',12000,0,'40');

INSERT INTO empleado values('6p','Lopez Hernandez Julio',27,


'Analista','Chinandega','1982/07/14',13000,1500,'20');

INSERT INTO empleado values('4s','Esquivel Jose',31,


'Director','Juigalpa','1981/06/05',16700,1200,'30');

INSERT INTO empleado values('9q','Delgado Carmen',37,


'Vendedor','Leon','1983/03/02',13400,0,'40');

INSERT INTO empleado values('55f','Castillo Montes Luis',17,

'Vendedor','Masaya','1982/08/12',16309,1000,'40');

INSERT INTO empleado values('4y','Esquivel Leonel Alfonso',26,

'Presidente','Nagarote','1981/09/12',15000,0,'30');

INSERT INTO empleado values('8r','Perez Luis',32,


'Empleado','Managua','1980/03/02',16890,0,'10');

Select nombre,salario, nombre_dept from EMPLEADO, DEPARTAMENTO where


EMPLEADO.dept_no=DEPARTAMENTO.dept_no and oficio = ( select oficio from empleado
where nombre='Esquivel Leonel Alfonso')

select * from empleado

Select nombre, salario, nombre_dept from EMPLEADO, DEPARTAMENTO where


EMPLEADO.dept_no=DEPARTAMENTO.dept_no and oficio = ( select oficio from empleado
where nombre='Castillo Montes Luis') and comision is null

select nombre from EMPLEADO, DEPARTAMENTO where EMPLEADO.dept_no =


DEPARTAMENTO.dept_no and nombre_dept = 'VENTAS' and salario = (select max(salario) from
EMPLEADO,DEPARTAMENTO where EMPLEADO.dept_no = DEPARTAMENTO.dept_no and
nombre_dept = 'VENTAS')
select dept_no from EMPLEADO group by count(*) having count(*) = (select max(count(*))
from EMPLEADO group by dept_no)

select dept_no from EMPLEADO where oficio = 'Empleado' group by dept_no having count(*) =
(select max(count(*)) from EMPLEADO where oficio = 'Empleado' group by dept_no)

También podría gustarte