-- Limpieza de Duplicados en Tabla Maestra Nacional
DELETE FROM public.snc_raw_lotes_activos a
USING public.snc_raw_lotes_activos b
WHERE a.sigem_id > b.sigem_id
  AND a.id_snc = b.id_snc
  AND a.ccatastral = b.ccatastral;

-- Verificación Final tras limpieza
SELECT count(*) as total_lotes_unicos FROM public.snc_raw_lotes_activos;
SELECT count(*) as total_oviedo_unico FROM public.snc_raw_lotes_activos WHERE dpto = 'F' AND dist = 1;
