



Prepara tus exámenes y mejora tus resultados gracias a la gran cantidad de recursos disponibles en Docsity
Gana puntos ayudando a otros estudiantes o consíguelos activando un Plan Premium
Esta página no es visible en la vista previa
¡No te pierdas las partes importantes!




select c.Municipio, Count (*) as total, --RECUPERADOS --consultamos y contamos la cantidad de personas que estan recuperados Count (case c.Ubicacion when 'Recuperado' then 1 else Null end) as Recuperados, --hacemos una regla de 3 para saber el porcentaje de recuperados frente al pais Count (case c.Ubicacion when 'Recuperado' then 1 else Null end) 100. --subconsulta para saber cuantos recuperados hay en el pais /(select count() from Casos where Ubicacion = 'Recuperado' ) as PorcentajePais, --CON LOS DEMAS ESTADOS ES PRACTICAMENTE LO MISMO --MUERTOS Count (case c.Ubicacion when 'Fallecido' then 1 else Null end) as Muertos, Count (case c.Ubicacion when 'Fallecido' then 1 else Null end) 100. /(select count() from Casos where Ubicacion = 'Fallecido' ) as PorcentajePais, --UCI
Count (case c.Ubicacion when 'Hospital UCI' then 1 else Null end) as UCI, Count (case c.Ubicacion when 'Hospital UCI' then 1 else Null end) 100. /(select count() from Casos where Ubicacion = 'Hospital UCI' ) as PorcentajePais, --CASA Count (case c.Ubicacion when 'Casa' then 1 else Null end) as CASA, Count (case c.Ubicacion when 'Casa' then 1 else Null end) 100. /(select count() from Casos where Ubicacion = 'Casa' ) as PorcentajePais, --HOSPITAL Count (case c.Ubicacion when 'Hospital' then 1 else Null end) as HOSPITAL, Count (case c.Ubicacion when 'Hospital' then 1 else Null end) 100. /(select count() from Casos where Ubicacion = 'Hospital' ) as PorcentajePais, --N/A Count (case c.Ubicacion when 'N/A' then 1 else Null end) as 'N/A', Count (case c.Ubicacion when 'N/A' then 1 else Null end) 100. /(select count() from Casos where Ubicacion = 'N/A' ) as PorcentajePais from Casos c where c.Departamento = 'Cundinamarca' group by c.Municipio
select c.Municipio, Count (*) as TOTAL_CASOS,
select c.Municipio, --dos count con cada uno se cuenta un genero de persona Count (case c.Sexo when 'M' then 1 else Null end) as machos, Count (case c.Sexo when 'F' then 1 else Null end) as Hembras, --PORCENTAJE HOMBRES POR DPTO Count (case c.Sexo when 'M' then 1 else Null end) 100. /(select count() from Casos where Sexo = 'M' and Departamento ='Cundinamarca' ) as PorcentajeDepartamentoMachos, --PORCENTAJE MUJERES DPTO Count (case c.Sexo when 'F' then 1 else Null end) 100. /(select count() from Casos where Sexo = 'F' and Departamento ='Cundinamarca' ) as PorcentajeDepartamentoHembras, --PORCENTAJE HOMBRES PAIS Count (case c.Sexo when 'M' then 1 else Null end) 100. /(select count() from Casos where Sexo = 'M' ) as PorcentajeMachosPais, --PORCENTAJE MUJERES PAIS Count (case c.Sexo when 'F' then 1 else Null end) 100. /(select count() from Casos where Sexo = 'F' ) as PorcentajeMujeresPais
from Casos c where c.Departamento ='Cundinamarca' group by c.Municipio
select c.Municipio, --UN COUNT PARA CADA PROCEDENCIA DE TIPO DE CONTAGIO Count (case c.FuenteTipoContagio when 'Importado' then 1 else Null end) as Importados, Count (case c.FuenteTipoContagio when 'Relacionado' then 1 else Null end) as Relacionado, Count (case c.FuenteTipoContagio when 'En estudio' then 1 else Null end) as Estudio from Casos c where c.Departamento = 'Cundinamarca' group by c.Municipio order by c.Municipio
count (Case when c.Edad between 60 and 69 then 1 else null end ) as '60-69 Años', count (Case when c.Edad between 70 and 79 then 1 else null end ) as '70-79 Años', count (Case when c.Edad between 80 and 89 then 1 else null end ) as '80-89 Años' from Casos c where c.Departamento = 'Cundinamarca' group by c.Municipio order by c.Municipio