0% found this document useful (0 votes)
14 views2 pages

Nota de Clases de Base de Datos 2

apuntes de la clase base de datos 2 del 24 de julio del 2019 elavoracion de sentencias en sql en el entorno de toad fororacle

Uploaded by

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

Nota de Clases de Base de Datos 2

apuntes de la clase base de datos 2 del 24 de julio del 2019 elavoracion de sentencias en sql en el entorno de toad fororacle

Uploaded by

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

--mpostrar todos los empleados conytratados en el mes de mayo

select * from EMPLOYEES where to_char(hire_date,'fmMonth')='Mayo';

--2 Desplegar los nombres y salarios de los empleados


--contratados un dia lunes o martes
select FIRST_NAME ,SALARY
from employees
where to_char(hire_date,'fmDay')='Lunes' or
to_char(hire_date,'fmDay')='Martes';

select FIRST_NAME ,SALARY


from employees
where to_char(hire_date,'fmDay')IN('Lunes','Martes');

select FIRST_NAME ,SALARY


from employees
where to_char(hire_date,'fmDay')=ANY('Lunes','Martes');

--3 Mostrar los nombres de los empleados que trabajan de marketing

select FIRST_NAME
from EMPLOYEES, DEPARTMENTS
where EMPLOYEES.DEPARTMENT_ID=DEPARTMENTS.DEPARTMENT_ID
and DEPARTMENTS.DEPARTMENT_NAME='Marketing';

select FIRST_NAME
from EMPLOYEES e inner join DEPARTMENTS d
on e.DEPARTMENT_ID=d.DEPARTMENT_ID
and d.DEPARTMENT_NAME='Marketing';

select FIRST_NAME
from EMPLOYEES e join DEPARTMENTS d
on e.DEPARTMENT_ID=d.DEPARTMENT_ID
and d.DEPARTMENT_NAME='Marketing';

select * from DEPARTMENTS;

--4 Desplegar las posibles combinaciones para crear


--grupos de dos componentes con los empleados
--(mostrar los codigos y nombres)
select a.EMPLOYEE_ID , a.FIRST_NAME ,b.EMPLOYEE_ID,b.FIRST_NAME
from EMPLOYEES a,EMPLOYEES b
where a.EMPLOYEE_ID <> b.EMPLOYEE_ID;

select a.EMPLOYEE_ID, a.FIRST_NAME,


b.EMPLOYEE_ID,b.FIRST_NAME
from EMPLOYEES a,EMPLOYEES b
where a.EMPLOYEE_ID <> b.EMPLOYEE_ID;

--5 desplegar las pocibles combinaciones para crear grupos


--de tres componentes con los empleados en un mismo departamento

select
a.DEPARTMENT_ID,b.DEPARTMENT_ID,c.DEPARTMENT_ID,
a.EMPLOYEE_ID, b.EMPLOYEE_ID,c.EMPLOYEE_ID,
a.FIRST_NAME, b.FIRST_NAME, c.FIRST_NAME

from EMPLOYEES a, EMPLOYEES b, EMPLOYEES c


where
a.DEPARTMENT_ID = b.DEPARTMENT_ID and
a.DEPARTMENT_ID = c.DEPARTMENT_ID and
b.DEPARTMENT_ID = c.DEPARTMENT_ID and(
a.EMPLOYEE_ID <> b.EMPLOYEE_ID and
a.EMPLOYEE_ID <> c.EMPLOYEE_ID and
c.EMPLOYEE_ID <> b.EMPLOYEE_ID);

--mostrar el mayo ymenor salario


select min(SALARY)as minimo,
max( SALARY)as maximo
from EMPLOYEES;

select count(*) from EMPLOYEES ;

select round(avg(salary),2)
from EMPLOYEES;

select sum(salary) from employees;


select sum(salary)*6 from employees;
select employee_id ,salary, salary *1.1 from employees;

select employee_id
from employees
order by employee_id asc;

select DEPARTMENT_ID, count(*)


from EMPLOYEES
group by DEPARTMENT_ID
having count(*)> 1;
--7desplegar los nombres de os empleados que tienen el menor salario
select first_name, salary
from employees
where salary = (select min(SALARY)as minimo
from EMPLOYEES);
--8 desplegar los codigos y nombres de los empleados cuyo codigo de departamento
--se ingresa por teclado
select EMPLOYEE_ID, FIRST_NAME, DEPARTMENT_ID
from EMPLOYEES
where DEPARTMENT_ID =&a;

--8 desplegar los codigos y nombres de los empleados cuyo codigo de oficio
--se ingresa por teclado
select EMPLOYEE_ID, FIRST_NAME, DEPARTMENT_ID
from EMPLOYEES
where JOB_ID ='&a';

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy