Created
February 14, 2020 16:04
-
-
Save MarioCares/1933269b920dfe4fbe4cdc70daef63cb to your computer and use it in GitHub Desktop.
Para los correos que manda Pablo Lira pidiendo sacar última atención desde SENAME
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
-- 1) IMPORTAR LISTADO DE RUTS | |
-- 2) SACAR LISTADO EN BRUTO. POR EJEMPLO, TODAS LAS ATENCIONES DE PSICÓLOGOS | |
select s.rut, aten.FECHA_HORA_INICIO | |
from sename_1 as s | |
left join (select max(fecha_inscripcion) as t, RUT, ID, APELLIDO_PATERNO, APELLIDO_MATERNO, NOMBRES from USP_USUARIO_APS group by RUT, ID, APELLIDO_PATERNO, APELLIDO_MATERNO, NOMBRES) as usp on usp.rut Collate Modern_Spanish_CI_AS = s.rut1 | |
left join ATEN_ATENCION as aten on (aten.USP_ID = usp.ID and aten.OBSERVACION != 'Inasistencia Registrada' and aten.INS_ID = 15) | |
order by s.rut, aten.FECHA_HORA_INICIO DESC | |
-- 3) DESPUÉS, EN EXCEL ELIMINAR DUPLICADOS (BASADOS EN EL RUT) | |
-- 4) SIGUIENDO CON EXCEL, BUSCARV |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment