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) REVISAR SI EXISTE EN SISTEMA ACTUAL. EGRESO Y DETALLES | |
select * from finanzas_egreso where numero = 502; | |
select * from finanzas_egreso_documento_tributario where egreso_id in (4517); | |
-- 2) SI NO EXISTEN, REVISARLAS EN EL SISTEMA ANTIGUO | |
select * from saludcor_adquisiciones.egresospagos where EGPA_NUMERO = 502; | |
-- 3) INSERTARLAS DESDE EL SISTEMA ANTIGUO, AL NUEVO | |
-- insert into finanzas_egreso_documento_tributario (egreso_id, documento_tributario_id, tabla) | |
select 4828, id, 'finanzas_otro_documento_tributario' from finanzas_otro_documento_tributario where id in ( | |
select EGPA_FK_PAG from saludcor_adquisiciones.egresospagos where egpa_numero = 502); |
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
select | |
NOD_NODO.RAZON_SOCIAL, (NOMBRES+' '+APELLIDO_PATERNO+' '+APELLIDO_MATERNO) as nombre, rut, FECHA_DE_NACIMIENTO, DIRECCION, | |
f.TELEFONO1, f.TELEFONO2, | |
DATEDIFF(year,FECHA_DE_NACIMIENTO,getdate() )+ | |
case | |
when ( Month(getdate()) < Month(FECHA_DE_NACIMIENTO) Or | |
(Month(getdate()) = Month(FECHA_DE_NACIMIENTO) And | |
Day(getdate()) < day(FECHA_DE_NACIMIENTO))) Then -1 else 0 end | |
as edad | |
from USP_USUARIO_APS |
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
-- EXPORT DESDE SQL SERVER A MYSQL, PARA TOTEM | |
-- TABLA FAMILIA | |
SELECT ID, SEC_ID FROM IquiqueCom.dbo.FAM_FAMILIA; | |
-- TABLA SECTOR | |
SELECT ID,NOMBRE FROM IquiqueCom.dbo.SEC_SECTOR; | |
-- TABLA NODO | |
SELECT ID, RAZON_SOCIAL FROM IquiqueCom.dbo.NOD_NODO; |
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
SELECT * | |
FROM 2015_1 | |
WHERE run IN ( | |
SELECT run | |
FROM `2014_2` | |
WHERE motivo_rechazo = 'F' | |
) AND motivo_rechazo IS null | |
limit 9999 |
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
update t | |
set t.licencia = p.licencia | |
from temporal_licencias_historicas as t | |
inner join rrhh_licencia_pago as p | |
on (t.rut = p.usuario_id) and (t.inicio = p.inicio_at) and (t.termino = p.termino_at) |
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
select e.nodo, LPAD(CONCAT(e.run, e.dv), 10, '0') run, e.fecha_inscripcion, CONCAT('G', e.fonasa) fonasa | |
from 2015_1 as e | |
left join 2015_2_E_R as r on e.run = r.run | |
where r.run is null and e.motivo_rechazo is null |
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
select nodo, xrut, xdv, ID_PREVISION, min(xfecha) from | |
(select 2016 as nodo, cast(rtrim(ltrim(a.xrut)) as decimal) as xrut, a.xdv, date_format(a.xfecha, '%Y-%m-%d') as xfecha, a.ID_PREVISION | |
from atenciones as a | |
inner join sapu as s on s.id = a.id_sapu | |
where (hour(a.xfecha) >= 8 and hour(a.xfecha) <= 17) and | |
weekday(a.xfecha) not in (1,7) | |
and a.xrut < 43000000 and a.xdv <> "" and a.xrut <> 0 and CONVERT(a.xrut, SIGNED INTEGER) IS NOT NULL) as Z | |
group by xrut, nodo, xdv, ID_PREVISION |
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
DELETE FROM USP_USUARIO_APS WHERE YEAR(FECHA_DE_NACIMIENTO) < 1900 OR YEAR(FECHA_DE_NACIMIENTO) > YEAR(GETDATE()) | |
OR NOD_ID NOT IN (225,226,227,2957,3003); | |
SELECT | |
(char(34)+u.RUT+char(34)) AS RUT, | |
(char(34)+u.NOMBRES+char(34)) AS NOMBRES, | |
(char(34)+u.APELLIDO_PATERNO+char(34)) AS APELLIDO_PATERNO, | |
(char(34)+u.APELLIDO_MATERNO+char(34)) AS APELLIDO_MATERNO, | |
char(34)+CONVERT(VARCHAR(10),u.FECHA_DE_NACIMIENTO,20)+char(34) AS FECHA_NACIMIENTO, | |
sexo = CASE u.HL7_0001_U_ID |
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
select l.licencia, u.nombres, u.apellidop, u.apellidom, n.nombre_completo | |
from rrhh_licencia as l | |
inner join rrhh_usuario as u on u.id = l.usuario_id | |
left join rrhh_orden_trabajo as ot on ot.usuario_id = l.usuario_id | |
left join unisag_nodo as n on n.id = ot.nodo_id | |
where now() between inicio_at and termino_at |
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
select id_sapu, xrut, dv, min(xfecha) from | |
(select s.id_sapu, cast(rtrim(ltrim(s.rut_paciente)) as decimal) as xrut, | |
'dv', date_format(s.lblfechahoraingreso, '%Y-%m-%d') as xfecha | |
from historia_sapu as s | |
where | |
(hour(s.lblfechahoraingreso) >= 8 and hour(s.lblfechahoraingreso) <= 17) | |
and weekday(s.lblfechahoraingreso) not in (1,7) | |
and (s.lblfechahoraingreso between '2015-10-01' and '2016-03-31') | |
and s.rut_paciente not like '%-%' | |
and s.rut_paciente < 43000000 and s.rut_paciente <> 0 |