Created
September 10, 2024 19:00
-
-
Save diegoolipa/3d7ef887a795aa85d42e21659dc14ef3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- ejercicio 01 | |
-- de 5 tablas usar la funcion count(*) --Contar | |
SELECT * FROM PERSONA; --LISTAR TODO LOS DATOS | |
SELECT | |
NOMBRE, | |
apellido_materno AS MATERNO, | |
apellido_paterno AS PATERNO | |
FROM PERSONA; | |
SELECT COUNT(*) AS cantidad_persona | |
FROM PERSONA; | |
--EJERCICIO 02 | |
--Uso de la clausula WHERE | |
SELECT * FROM PERSONA where fecha_nacimiento > '01/01/1990'; | |
--EJERCICIO 03 | |
--Uso de la clausula LIKE | |
select * from persona where nombre like 'M%'; | |
--EJERCICIO 04 | |
--Uso de la funcion SUBSTR | |
SELECT * FROM PERSONA WHERE SUBSTR(NOMBRE,1,1) = 'M'; | |
select SUBSTR(numero_celular,1,1) from persona_celular; | |
--EJERCICIO 05 | |
--Uso de la clausula AND | |
SELECT * FROM PERSONA | |
WHERE id_genero='1' | |
AND id_estado_civil='2' | |
AND apellido_materno = 'Mamani' | |
AND apellido_paterno = 'Quispe'; | |
--EJERCICIO 06 | |
--Uso de la FUNCION UPPER --Mayuscula | |
SELECT | |
UPPER(NOMBRE), | |
UPPER(apellido_materno) | |
FROM PERSONA; | |
--EJERCICIO 07 | |
--Uso de la FUNCION LOWER --Minuscula | |
SELECT | |
LOWER(NOMBRE), | |
LOWER(apellido_materno) | |
FROM PERSONA; | |
--EJERCICIO 08 | |
--Uso de la FUNCION INITCAP --Capitalice | |
SELECT | |
INITCAP(NOMBRE), | |
INITCAP(apellido_materno) | |
FROM PERSONA; | |
--EJERCICIO 09 | |
--ACTUALIZACIÓN DE REGISTROS --3 tablas | |
SELECT celular, correo FROM PERSONA; | |
UPDATE PERSONA | |
SET celular = '999999000',correo = '[email protected]' | |
where id_estado_civil = 2 | |
--where apellido_materno = 'Mamani' | |
--WHERE id_persona = 10 | |
--WHERE LENGTH(CELULAR) = 9 | |
; | |
--EJERCICIO 10 | |
--ELIMINAR REGISTROS --1 REGISTRO | |
SELECT * FROM ALUMNO; | |
DELETE FROM ALUMNO | |
WHERE id_alumno = 13; | |
--EJERCICIO 11 | |
--Uso de la FUNCION DISTINCT -1 TABLA | |
SELECT DISTINCT(apellido_materno) FROM PERSONA; | |
--EJERCICIO 12 | |
--Uso de la FUNCION NVL | |
SELECT nvl(to_char(fecha_registro),'Sin Datos') FROM PERSONA; | |
--EJERCICIO 12 | |
--ORDENAR RESULTADOS -2 TABLAS | |
SELECT NOMBRE, apellido_paterno, apellido_materno | |
FROM PERSONA | |
ORDER BY NOMBRE,apellido_paterno ASC --DESC | |
; | |
--EJERCICIO 13 | |
--Uso de la FUNCION SUM --SUMA | |
SELECT fecha_nacimiento, SYSDATE FROM PERSONA; | |
SELECT | |
SUM( | |
EXTRACT(YEAR FROM SYSDATE)- | |
EXTRACT(YEAR FROM fecha_nacimiento) | |
) | |
FROM PERSONA; | |
--EJERCICIO 14 | |
--Uso de la FUNCION AVG --PROMEDIO | |
SELECT | |
ROUND( | |
AVG( | |
EXTRACT(YEAR FROM SYSDATE)- | |
EXTRACT(YEAR FROM fecha_nacimiento) | |
) | |
,2) AS SUMA_EDAD | |
FROM PERSONA; | |
SELECT ROUND(50.878156546,2) FROM DUAL; | |
--EJERCICIO 15 | |
--Uso de la FUNCION MAX Y MIN -- MAXIMO Y MINIMO | |
SELECT | |
MAX( | |
EXTRACT(YEAR FROM SYSDATE)- | |
EXTRACT(YEAR FROM fecha_nacimiento) | |
) | |
FROM PERSONA; | |
-- | |
SELECT | |
MIN( | |
EXTRACT(YEAR FROM SYSDATE)- | |
EXTRACT(YEAR FROM fecha_nacimiento) | |
) | |
FROM PERSONA; | |
--EJERCICIO 15 | |
--Uso de la CLAUSULA GROUP BY | |
SELECT apellido_paterno, count(*) FROM PERSONA | |
GROUP BY apellido_paterno; | |
select id_genero, count(*) from persona | |
group by id_genero | |
; | |
--EJERCICIO 16 | |
--Uso de la CLAUSULA HAVING | |
------------------------------------------------ | |
SELECT * FROM PERSONA; | |
SELECT * FROM genero; | |
SELECT * FROM alumno; | |
SELECT * FROM estado_civil; | |
SELECT * FROM PERSONA_CELULAR; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment