Merge pull request #33 from cromerc/feature_optimizacion

no message
This commit is contained in:
Chris Cromer 2020-08-08 19:37:01 -04:00 committed by GitHub
commit 2b177ef13d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

19
optimizacion.sql Normal file
View File

@ -0,0 +1,19 @@
SELECT P.ID_PAIS, P.NOMBRE, COUNT(1) AS CANTIDAD_ATLETA
FROM COMPETENCIA C
LEFT JOIN PARTICIPAR_COMPETENCIA PC ON (C.ID_COMPETENCIA = PC.ID_COMPETENCIA)
LEFT JOIN ATLETA A ON A.ID_ATLETA = PC.ID_ATLETA
INNER JOIN DELEGACION D ON (D.ATLETA = A.ID_ATLETA)
INNER JOIN PAIS P ON (P.ID_PAIS = D.PAIS)
INNER JOIN TIPOS_DEPORTES TD ON (C.TIPO = TD.ID_TIPO AND (UPPER(TD.DESCRIPCION) = 'ATLETISMO'))
GROUP BY (P.ID_PAIS, P.NOMBRE);
SELECT P.ID_PAIS, P.NOMBRE, COUNT(*) AS CANTIDAD_ATLETA
FROM COMPETENCIA C
LEFT JOIN PARTICIPAR_COMPETENCIA PC ON (C.ID_COMPETENCIA = PC.ID_COMPETENCIA)
LEFT JOIN ATLETA A ON A.ID_ATLETA = PC.ID_ATLETA
INNER JOIN DELEGACION D ON (D.ATLETA = A.ID_ATLETA)
INNER JOIN PAIS P ON (P.ID_PAIS = D.PAIS)
WHERE TIPO = (SELECT TD.ID_TIPO FROM TIPOS_DEPORTES TD WHERE (UPPER(TD.DESCRIPCION) = 'ATLETISMO'))
GROUP BY (P.ID_PAIS, P.NOMBRE);