SELECT 
    'e505_lotes_activos' as tabla,
    count(*) as total, 
    count(NULLIF(snc_cuenta, '')) as con_cuenta,
    count(CASE WHEN tipo_cuenta = 1 THEN 1 END) as urbanos,
    count(CASE WHEN tipo_cuenta = 0 THEN 1 END) as rurales
FROM public.e505_lotes_activos;

-- Comprobar si ahora el JOIN tiene más éxito
SELECT 
    count(*) as total_vinculados_con_color
FROM public.e505_lotes_activos lot
JOIN fdw_505.v_liq_entidad_totalxobjeto liq ON lot.snc_cuenta = REPLACE(liq.inm_ctacatastral, '-', '');
