PRÁCTICAS DE BASES DE DATOS I - Universidad de Jaén
PRÁCTICAS DE BASES DE DATOS I - Universidad de Jaén
PRÁCTICAS DE BASES DE DATOS I - Universidad de Jaén
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Programación <strong>de</strong> Bases <strong>de</strong> Datos Oracle SQL<br />
WHERE mecanicos.dni=trabajos.dni AND<br />
puesto='CHAPA';<br />
Total CHAPA<br />
-----------<br />
11983<br />
• AVG: calcula la media aritmética <strong>de</strong> un conjunto <strong>de</strong> valores. Su formato es:<br />
AVG ([DISTINCT] columna | expresión)<br />
Devuelve la media aritmética <strong>de</strong> los valores <strong>de</strong> la columna o <strong>de</strong> los <strong>de</strong>vueltos por la expresión. La<br />
columna o expresión <strong>de</strong>be ser numérica.<br />
Ejemplos:<br />
• Obtener la media <strong>de</strong> horas trabajadas con los coches RENAULT:<br />
SQL> SELECT AVG(horas)<br />
FROM coches,trabajos<br />
WHERE coches.mat=trabajos.mat AND<br />
marca='RENAULT';<br />
AVG(HORAS)<br />
----------<br />
3.575<br />
• Obtener la media <strong>de</strong>l número <strong>de</strong> caracteres formados por la marca y el mo<strong>de</strong>lo <strong>de</strong> cada<br />
coche:<br />
SQL> SELECT AVG(LENGTH(marca||mo<strong>de</strong>lo)) FROM coches;<br />
AVG(LENGTH(MARCA||MO<strong>DE</strong>LO))<br />
--------------------------<br />
10.285714<br />
• MAX: calcula el máximo <strong>de</strong> un conjunto <strong>de</strong> valores. Su formato es:<br />
MAX ([DISTINCT] columna | expresión)<br />
Devuelve el valor máximo <strong>de</strong> la columna o la expresión.<br />
Ejemplos:<br />
• Obtener el número máximo <strong>de</strong> horas trabajadas sobre un coche:<br />
SQL> SELECT MAX(horas)<br />
FROM trabajos;<br />
MAX(HORAS)<br />
----------<br />
8<br />
<strong>Universidad</strong> <strong>de</strong> <strong>Jaén</strong> 26