create table subq_0(p30_localidad int, p30_moneda char(2), p30_saldo_favor numeric);

create table ref_6(z21_usuario char(10));
create index on ref_6 (z21_usuario);

create table ref_7(z31_mes int, z31_moneda char(2)); 

select subq_0.p30_moneda as c1, subq_6.c0 as c2 
  from public.subq_0, 
       lateral (select subq_0.p30_moneda as c0 from (select 1) foo offset 0) as subq_6,
       lateral (select sample_3.parname as c3, ref_6.*, ref_5.*
                  from pg_catalog.pg_parameter_acl as sample_3 
                       left join information_schema.transforms as ref_5 on true 
                       left join ref_6 
         	       left join ref_7
                       right join pg_catalog.pg_partitioned_table as sample_4 
              			on (ref_7.z31_mes = sample_4.partnatts )
            			on ((cast(null as box) ~= cast(null as box)) or (sample_4.partstrat <= sample_4.partstrat))
          			on (false)
    		 where ref_6.z21_usuario = case when ref_5.udt_catalog is NULL then ref_7.z31_moneda else ref_7.z31_moneda end
               ) as subq_7
 where false
