select * from astoctas where astc_estado=-1;
select * from ptovta order by 1;
select ptv_id, ptv_nombre from ptovta order by 1;
select * from liqegr limit 1;
select * from liqegr where eg_idptov=1 limit 1;
select * from liqegr where eg_idptov=1 and eg_anio=2015 and eg_mes=8 limit 1;
select sum(eg_total) from liqegr where eg_idptov=1 and eg_anio=2015 and eg_mes=8 limit 1;
select * from liqegr where eg_idptov=1 and eg_anio=2015 and eg_mes=8 limit 1;
select sum(eg_importe) from liqegr where eg_idptov=1 and eg_anio=2015 and eg_mes=8 limit 1;
select eg_estado,sum(eg_importe) from liqegr where eg_idptov=1 and eg_anio=2015 and eg_mes=8 group by 1;
select * from astoctas where astc_importe in (900,-900) and astc_idptov=1;
select astc_id,astc_fecval,codcble(astc_ctacble),codcomp(astc_comprob),astc_numero,astc_importe from astoctas where astc_importe in (900,-900) and astc_idptov=1 order by 2 desc;
select eg_estado,sum(eg_importe) from liqegr where eg_idptov=1 and eg_anio=2015 and eg_mes=8 group by 1;
select *  from liqegr where eg_idptov=1 and eg_anio=2015 and eg_mes=8 and eg_estado=999;
select *  from astoctas where astc_idastoh in (31683,34921);
select eg_idastoh,sum(astc_importe),sum(eg_importe) from liqegr where astc_idastoh=eg_idastoh and eg_idptov=1 and astc_importe>0 and eg_anio=2015 and eg_mes=8 and eg_estado=2 group by 1;
select eg_idastoh,sum(astc_importe),sum(eg_importe) from liqegr,astoctas where astc_idastoh=eg_idastoh and eg_idptov=1 and astc_importe>0 and eg_anio=2015 and eg_mes=8 and eg_estado=2 group by 1;
select eg_idastoh,sum(astc_importe)-sum(eg_importe) from liqegr,astoctas where astc_idastoh=eg_idastoh and eg_idptov=1 and astc_importe>0 and eg_anio=2015 and eg_mes=8 and eg_estado=2 group by 1;
select eg_idastoh,sum(astc_importe)-sum(eg_importe) from liqegr,astoctas where astc_idastoh=eg_idastoh and eg_idptov=1 and astc_importe>0 and eg_anio=2015 and eg_mes=8 and eg_estado=2 and (sum(astc_importe)-sum(eg_importe))!=0 group by 1;
select eg_idastoh,sum(astc_importe)-sum(eg_importe) from liqegr,astoctas where astc_idastoh=eg_idastoh and eg_idptov=1 and astc_importe>0 and eg_anio=2015 and eg_mes=8 and group by 1 having sum(astc_importe)-sum(eg_importe)!=0;
select eg_idastoh,sum(astc_importe),sum(eg_importe) from liqegr,astoctas where astc_idastoh=eg_idastoh and eg_idptov=1 and astc_importe>0 and eg_anio=2015 and eg_mes=8 and eg_estado=2 group by 1 having (sum(astc_importe)-sum(eg_importe)!=0);
select eg_idastoh,sum(astc_importe),sum(eg_importe) from liqegr,astoctas where astc_idastoh=eg_idastoh and eg_idptov=1 and astc_importe>0 and eg_anio=2015 and eg_mes=8 and eg_estado=2 group by 1 having (sum(astc_importe)-sum(eg_importe)!=0);
select eg_idastoh,sum(astc_importe)-sum(eg_importe) from liqegr,astoctas where astc_idastoh=eg_idastoh and eg_idptov=1 and astc_importe>0 and eg_anio=2015 and eg_mes=8 and eg_estado=2 group by 1 having (sum(astc_importe)-sum(eg_importe)!=0);
select eg_idastoh,codcomp(astc_comprob),astc_numero,sum(astc_importe)-sum(eg_importe) from liqegr,astoctas where astc_idastoh=eg_idastoh and eg_idptov=1 and astc_importe>0 and eg_anio=2015 and eg_mes=8 and eg_estado=2 group by 1,2,3 having (sum(astc_importe)-sum(eg_importe)!=0);
select gto_idastoh,codcomp(astc_comprob),astc_numero,sum(astc_importe)-sum(gto_importe) from gastos,astoctas where astc_idastoh=gto_idastoh and gto_idptov=1 and astc_importe>0 and gto_anio=2015 and gto_mes=8 and gto_estado=2 group by 1,2,3 having (sum(astc_importe)-sum(gto_importe)!=0);
select gto_idastoh,codcomp(astc_comprob),astc_numero,sum(astc_importe)-sum(gto_importe) from gastos,astoctas where astc_idastoh=gto_idastoh and gto_idptov=1 and astc_importe>0 and gto_anio=2015  and gto_estado=2 group by 1,2,3 having (sum(astc_importe)-sum(gto_importe)!=0);
select * from liqegr where eg_numero=5745;
select * from liqegr limit 1;
select * from liqegr where eg_idastoh=34843;
select * from gastos where gto_idastoh=34843;
select * from gtoxliq;;
select * from gtoxliqe;
select * from gtoxliqe where gxl_gasto=6303;
select * from liqegr where eg_id=5293;
select * from liqegr where eg_id=5131;
select * from liqegr where eg_id=5293;
select eg_importe from liqegr where eg_id=5293;
update liqegr set eg_importe=22874.98+900 where eg_id=5293;
select gto_idastoh,codcomp(astc_comprob),astc_numero,sum(astc_importe)-sum(gto_importe) from gastos,astoctas where astc_idastoh=gto_idastoh and gto_idptov=1 and astc_importe>0 and gto_anio=2015  and gto_estado=2 group by 1,2,3 having (sum(astc_importe)-sum(gto_importe)!=0);
select * from gastos where gto_idastoh=34843;
update gastos set gto_importe=1400 where gto_idastoh=34843;
select * from liqegr where eg_id=5131;
select * from liqegr where eg_id=1;
select * from gastos;
select * from gastos where gto_numero=5131;
select * from gastos where gto_numero=5131;
\pset pager off
select * from gastos where gto_numero=5131;
select * from liqegr where eg_idastoh=31069;
select * from gtoxliqe limit 1;
select * from gtoxliqe where gxl_liqegr=5293;
select * from astoctas where astc_id=342535;
select * from astoctas where astc_id=135059;
select * from astoh where ash_id=39297;
explain anaylse select * from astoh;
explain anaylze select * from astoh;
explain analyze select * from astoh;
explain analyze select * from compliq;
explain analyze select * from cobrxclq;
select * from usermenu;
select * from opermenu;
select * from menues;
select * from relmenu order by 1;
select ('03-07-2018' + interval '1 day')::date;
update eventos set evt_fecha='24-07-2018' where evt_id=83;
update eventos set evt_fecha='24-07-2018',evt_estado=2 where evt_id=83;
select * from gente where gte_nombre ilike '%gise%';
select * from gtexuf where gxu_idgente =127;
select * from gente order by 1 desc;
select * from activi limit 2;
select * from activi order by 1;
select * from activi order by 1 desc limit 3;
select * from gruposactivi where ga_id=22;
select * from cargos where car_nombre ilike '%obra%';
select * from ptovta where ptv_codigo=37;
select * from compliq where clq_idptov=46 and clq_cargo in (38,17) order by 1;
select * from compliq where clq_idptov=46 and clq_cargo in (38) order by 1;
select * from compliq where clq_idptov=46 and clq_cargo in (17) order by 1;
select sum(clq_importe) from compliq where clq_idptov=46 and clq_cargo in (17) order by 1;
select sum(cxc_importe) from cobrxclq where cxc_idclq in (select clq_id from compliq where clq_idptov=46 and clq_cargo in (17) order by 1);
select * from compliq where clq_idptov=46 and clq_cargo in (20) order by 1;
select sum(clq_importe) from compliq where clq_idptov=46 and clq_cargo in (20) order by 1;
select sum(cxc_importe) from cobrxclq where cxc_idclq in (select clq_id from compliq where clq_idptov=46 and clq_cargo in (20) order by 1);
select * from gastos where gto_numero=41845;
update astoh set ash_fecval='01-03-2020' where ash_id=243644;
update astoh set ash_estado=999 where ash_id=243644;
select * from activi order by 1;
update activi set ac_estado=999 where ac_fecha<'05-03-2020';
select * from activi where ac_estado=1 order by 1;
select * from grupos where gpo_id in (27,28);
select * from gruposactivi where ga_id in (27,28);
select * from auxfe where fe_Cae is null;
update auxfe set fe_moneda=2,fe_tc=63.75 where fe_id=3900;
select * from activi where ac_estado=1;
