select * from atencion_ciudadana_estado; select * from atencion_ciudadana_municipio; select * from atencion_ciudadana_localidad WHERE lower(NOMBRE) LIKE 'centro'; select (select array_to_string(array_agg(nombre),', ', '') from atencion_ciudadana_localidad WHERE NOMBRE = (select upper(nombre) from atencion_ciudadana_lugar where id = localidad_id)), ( select nombre from atencion_ciudadana_lugar where id = localidad_id ), * from atencion_ciudadana_solicitud A order by 1 ; select ID, NOMBRE, PADRE_ID, (SELECT NOMBRE FROM atencion_ciudadana_lugar WHERE ID = A.PADRE_ID) AS PADRE, case --when a.id=50 then (select id from atencion_ciudadana_localidad where nombre = 'MÉXICO') when a.id=51 then (select id from atencion_ciudadana_localidad where nombre = 'TABASCO') /*when a.id=52 then (select id from atencion_ciudadana_localidad where nombre = 'CENTRO') when a.id=55 then (select id from atencion_ciudadana_localidad where nombre = 'COMALCALCO') when a.id=56 then (select id from atencion_ciudadana_localidad where nombre = 'MACUSPANA') when a.id=60 then (select id from atencion_ciudadana_localidad where nombre = 'EMILIANO ZAPATA') when a.id=61 then (select id from atencion_ciudadana_localidad where nombre = 'BALANCÁN') when a.id=62 then (select id from atencion_ciudadana_localidad where nombre = 'JALPA DE MENDEZ') when a.id=63 then (select id from atencion_ciudadana_localidad where nombre = 'JALAPA') when a.id=64 then (select id from atencion_ciudadana_localidad where nombre = 'TENOSIQUE') when a.id=65 then (select id from atencion_ciudadana_localidad where nombre = 'NACAJUCA') when a.id=66 then (select id from atencion_ciudadana_localidad where nombre = 'HUIMANGUILLO') when a.id=67 then (select id from atencion_ciudadana_localidad where nombre = 'CÁRDENAS') when a.id=68 then (select id from atencion_ciudadana_localidad where nombre = 'CUNDUACÁN') when a.id=69 then (select id from atencion_ciudadana_localidad where nombre = 'CENTLA') when a.id=70 then (select id from atencion_ciudadana_localidad where nombre = 'PARAISO') when a.id=71 then (select id from atencion_ciudadana_localidad where nombre = 'TEAPA') when a.id=72 then (select id from atencion_ciudadana_localidad where nombre = 'TACOTALPA') when a.id=73 then (select id from atencion_ciudadana_localidad where nombre = 'JONUTA') when a.id=75 then (select id from atencion_ciudadana_localidad where nombre = 'FRACCIONAMIENTO LA VENTA ') when a.id=76 then (select id from atencion_ciudadana_localidad where nombre = 'RA. EL LIMON') when a.id=81 then (select id from atencion_ciudadana_localidad where nombre = 'VILLAHERMOSA') when a.id=87 then (select id from atencion_ciudadana_localidad where nombre = 'TUSHISHAL') when a.id=717 then (select id from atencion_ciudadana_localidad where nombre = 'TABASCO') when a.id=718 then (select id from atencion_ciudadana_localidad where nombre = 'TABASCO') when a.id=720 then (select id from atencion_ciudadana_localidad where nombre = 'X') when a.id=723 then (select id from atencion_ciudadana_localidad where nombre = 'JALAPA') when a.id=726 then (select id from atencion_ciudadana_localidad where nombre = 'CENTRO') when a.id=727 then (select id from atencion_ciudadana_localidad where nombre = 'RAMON') when a.id=730 then (select id from atencion_ciudadana_localidad where nombre = 'RA. AQUILES SERDAN CUARTA SECCION') when a.id=732 then (select id from atencion_ciudadana_localidad where nombre = 'FRANCISCO I. MADERO') when a.id=734 then (select id from atencion_ciudadana_localidad where nombre = 'DISTRITO FEDERAL') when a.id=735 then (select id from atencion_ciudadana_localidad where nombre = 'MEXICO') when a.id=736 then (select id from atencion_ciudadana_localidad where nombre = 'MEXICO DISTRITO FEDERAL') when a.id=737 then (select id from atencion_ciudadana_localidad where nombre = 'RANCHERIA NICOLAS BRAVO') when a.id=738 then (select id from atencion_ciudadana_localidad where nombre = 'VILLAHERMOSA') when a.id=741 then (select id from atencion_ciudadana_localidad where nombre = 'PARAISO ') when a.id=746 then (select id from atencion_ciudadana_localidad where nombre = 'TECMILENIO') when a.id=747 then (select id from atencion_ciudadana_localidad where nombre = 'EMILIANO ZAPATA') when a.id=751 then (select id from atencion_ciudadana_localidad where nombre = 'VILLA EL TRIUNFO') when a.id=753 then (select id from atencion_ciudadana_localidad where nombre = 'RA. PLUTARCO ELIAS CALLES ') when a.id=755 then (select id from atencion_ciudadana_localidad where nombre = 'VILLA TAMULTE DE LAS SABANAS') when a.id=756 then (select id from atencion_ciudadana_localidad where nombre = 'CUNDUACAN CENTRO') when a.id=757 then (select id from atencion_ciudadana_localidad where nombre = 'MEXICO BERRIOZABAL CHIAPAS') when a.id=759 then (select id from atencion_ciudadana_localidad where nombre = 'CENTRO') when a.id=760 then (select id from atencion_ciudadana_localidad where nombre = 'DANELIA') when a.id=761 then (select id from atencion_ciudadana_localidad where nombre = 'PLAYAS DEL ROSARIO') when a.id=766 then (select id from atencion_ciudadana_localidad where nombre = 'INDECO') when a.id=767 then (select id from atencion_ciudadana_localidad where nombre = 'RANCHERIA ACACHAPAN Y COLMENA PRIMERA SECCION') */ end as new , 'when a.id='||id||' then (select id from atencion_ciudadana_localidad where nombre = '''||upper(nombre)||''')' from atencion_ciudadana_lugar a where id in ( select localidad_id from atencion_ciudadana_solicitud where localidad_id is not null group by localidad_id UNION select localidad_id from atencion_ciudadana_persona where localidad_id is not null group by localidad_id ) order by 5 DESC; /* SELECT ID, NOMBRE, (SELECT NOMBRE FROM atencion_ciudadana_MUNICIPIO WHERE ID = A.MUNICIPIO_ID) FROM atencion_ciudadana_localidad A WHERE nombre LIKE '%XICO%' */ SELECT * FROM atencion_ciudadana_SOLICITUD WHERE LOCALIDAD_ID = 51