Add SQL SELECT function exercises.

This commit is contained in:
Nicolás A. Ortega Froysa 2022-02-02 17:27:29 +01:00
parent c184bb86cd
commit 3472008749
3 changed files with 57 additions and 0 deletions

17
1/GBD/tema4-ej14.sql Normal file
View File

@ -0,0 +1,17 @@
-- 4
SELECT DISTINCT INITCAP(POSICION) FROM FUTBOLISTAS ORDER BY POSICION ASC;
-- 5
SELECT '--' || SUBSTR(NOMBRE,1,3) FROM FUTBOLISTAS WHERE EQUIPO=(
SELECT ID FROM EQUIPOS WHERE NOMBRE='A'
);
-- 6
SELECT SUBSTR(NOMBRE,1,3) || '--' FROM FUTBOLISTAS WHERE EQUIPO=(
SELECT ID FROM EQUIPOS WHERE NOMBRE='A'
);
-- 8
SELECT SUBSTR(APELLIDOS, 1, 3) FROM FUTBOLISTAS;
-- 9
SELECT replace(NOMBRE, 'LUIS', 'L.'), length(APELLIDOS) FROM FUTBOLISTAS;

17
1/GBD/tema4-ej15.sql Normal file
View File

@ -0,0 +1,17 @@
-- 1
SELECT EXTRACT(DAY FROM SYSDATE), EXTRACT(MONTH FROM SYSDATE), EXTRACT(YEAR FROM SYSDATE) FROM DUAL;
-- 2
SELECT ADD_MONTHS(SYSDATE, 6) FROM DUAL;
-- 3
SELECT MONTHS_BETWEEN(SYSDATE, NACIMIENTO) FROM FUTBOLISTAS;
-- 4
SELECT LAST_DAY(SYSDATE) FROM DUAL;
-- 5
SELECT NEXT_DAY(SYSDATE, "LUNES") FROM DUAL;
-- 6
SELECT TO_CHAR(SYSDATE - 4, "DAY") "Four Days Ago", TO_CHAR(SYSDATE + 1, "DAY") "Tomorrow" FROM DUAL;

23
1/GBD/tema4-ej16.sql Normal file
View File

@ -0,0 +1,23 @@
-- 1
SELECT TO_NUMBER("1000.45", "9999.99") FROM DUAL;
-- 2
SELECT TO_NUMBER("1000.45€", "9999.99L") FROM DUAL;
-- 3
SELECT TO_NUMBER("-$1000.45", "S$9999.99") FROM DUAL;
-- 4
SELECT TO_CHAR(SYSDATE, "DD/MM/YYYY") FROM DUAL;
SELECT TO_CHAR(SYSDATE, "DD/MM/YY") FROM DUAL;
SELECT LOWER(TO_CHAR(SYSDATE, "DD-MON-YYYY")) FROM DUAL;
SELECT TO_CHAR(SYSDATE, "DD") || " de " ||
trim(LOWER(TO_CHAR(SYSDATE, "MONTH"))) || " de " ||
TO_CHAR(SYSDATE, "YYYY")
FROM DUAL;
-- 5
SELECT TO_NUMBER(SUBSTR(id, 2, LENGTH(id))) FROM FUTBOLISTAS;
-- 6
SELECT TO_CHAR(FECHA_NACIMIENTO, "YYYY") FROM FUTBOLISTAS ORDER BY 1 ASC;