Practica de repaso sql

Solo disponible en BuenasTareas
  • Páginas : 3 (635 palabras )
  • Descarga(s) : 0
  • Publicado : 9 de junio de 2011
Leer documento completo
Vista previa del texto
select DEPARTMENT_ID, COUNT (EMPLOYEE_ID) TOTAL
FROM EMPLOYEES
WHERE DEPARTMENT_ID >60
HAVING COUNT (EMPLOYEE_ID)>30
GROUP BY DEPARTMENT_ID
ORDER BY DEPARTMENT_ID

select DEPARTMENT_ID, COUNT(EMPLOYEE_ID) TOTAL
FROM EMPLOYEES
HAVING COUNT (EMPLOYEE_ID)>30
GROUP BY DEPARTMENT_ID
ORDER BY DEPARTMENT_ID

select DEPARTMENT_ID, COUNT (EMPLOYEE_ID) TOTAL, SUM(SALARY) SALARIO
FROMEMPLOYEES
--HAVING COUNT (EMPLOYEE_ID)>30
GROUP BY DEPARTMENT_ID
ORDER BY DEPARTMENT_ID

select DEPARTMENT_ID, COUNT (EMPLOYEE_ID) TOTAL,
SUM(SALARY) SALARIO,MAX(SALARY)MAXIMO_SALARIO,
MIN(SALARY)MINIMO_SALARIO,
AVG(SALARY)PROMEDIO_SALARIO
FROM EMPLOYEES T
--HAVING COUNT (EMPLOYEE_ID)>30
GROUP BY DEPARTMENT_ID
ORDER BY DEPARTMENT_ID

select A.DEPARTMENT_ID,B.DEPARTMENT_NAME,
COUNT (EMPLOYEE_ID) TOTAL,
SUM(SALARY) SALARIO,
MAX(SALARY)MAXIMO_SALARIO,
MIN(SALARY)MINIMO_SALARIO,
AVG(SALARY)PROMEDIO_SALARIOFROM employees a, departments b
WHERE A.DEPARTMENT_ID = B.DEPARTMENT_ID
--HAVING COUNT (EMPLOYEE_ID)>30
GROUP BY A.DEPARTMENT_ID, B.DEPARTMENT_NAME
ORDER BY A.DEPARTMENT_ID

SELECT 'XAVIER'FROM DUAL
-- DUAL=> ES PARA ESCOGER UN DATO DE CUALQUIER TABLA ES PARA MANDAR A BUSCAR
SELECT SYSDATE
FROM DUAL
-- SYSDATE=> ES PARA RETORNAR FECHA

EJERCICIO 1 DE LA LECCION
selecta.EMPLOYEE_ID, UPPER(A.FIRST_NAME) NOMBRE, a.LAST_NAME APELLIDO, a.SALARY SALARIO, c.city
FROM employees a,departments b, LOCATIONS c
WHERE a.department_id = b.department_id and b.location_id = c.location_idand lower (c.CITY) = 'oxford'
--WHERE a.department_id = b.department_id and b.location_id = c.location_id and upper (c.CITY) = 'oxford'
--UPPER=> SE ESCRIBE TODO EN MAYUSCULA Y COMPARA Y BUSCA NOIMPORTA SI ESTA EN MINUSCULA O MAYUSCULA
--lower=> SE ESCRIBE TODO EN MINUSCULA Y COMPARA Y BUSCA NO IMPORTA SI ESTA EN MINUSCULA O MAYUSCULA

EJERCICIO 2 DE LA LECCION
select SUM(SALARY)...
tracking img