-- Comparativa técnica de claves para asegurar el JOIN
SELECT 
    'LOCAL' as origen, 
    mz, 
    lote, 
    snc_cuenta, 
    ccatastral,
    ('21-' || LPAD(mz::text, 4, '0') || '-' || LPAD(lote::text, 2, '0')) as clave_generada
FROM public.e505_lotes_activos 
WHERE mz IS NOT NULL AND lote IS NOT NULL
LIMIT 5;

SELECT 
    'REMOTO (FDW)' as origen, 
    inm_ctacatastral, 
    REPLACE(inm_ctacatastral, '-', '') as limpia_fdw,
    inm_ficha
FROM fdw_505.v_liq_entidad_totalxobjeto 
LIMIT 5;
