--Query para saber si hay duplicadas
SELECT d.id_direccion_06, c.id_cuenta_05,
    s.id_solicitante_01,
    s.f_baja_01,
    s.f_inicio_01,
    (
        SELECT
            COUNT(1)
        FROM
            ad74a.ad74a91t00 pb
        WHERE
                pb.id_solicitante_91 = s.id_solicitante_01
            AND pb.fecha_inicio_91 <= TO_DATE('28/02/2025', 'dd/mm/yyyy')
            AND ( pb.fecha_fin_91 IS NULL
                  OR pb.fecha_fin_91 > TO_DATE('01/02/2025', 'dd/mm/yyyy') )
    ) AS nprecios,
    (
        SELECT
            COUNT(1)
        FROM
            ad74a.ad74a32t01 ps
        WHERE
                ps.id_solicitante_32 = s.id_solicitante_01
            AND ps.f_desde_32 <= TO_DATE('28/02/2025', 'dd/mm/yyyy')
            AND ( ps.f_hasta_32 IS NULL
                  OR ps.f_hasta_32 > TO_DATE('01/02/2025', 'dd/mm/yyyy') )
    ) AS npisotutelado
FROM
    ad74a.ad74a01t00 s,
    ad74a.ad74a05t00 c,
    ad74a.ad74a06t00 d
WHERE
        s.id_solicitante_01 = c.id_solicitante_05
    AND s.id_direccion_01 = d.id_direccion_06
    AND d.id_provincia_06 = '48'
    AND s.f_inicio_01 <= TO_DATE('28/02/2025', 'dd/mm/yyyy')
    AND ( s.f_baja_01 IS NULL
          OR s.f_baja_01 > TO_DATE('01/02/2025', 'dd/mm/yyyy') )
    AND c.num_cuenta_05 IS NOT NULL
    AND s.id_cuenta_01 = c.id_cuenta_05
    AND c.f_historico_05 IS NULL
    AND s.id_solicitante_01 = 178682
   /* AND NOT EXISTS (
        SELECT
            1
        FROM
            ad74a.ad74a89t00 m
        WHERE
                m.anyo_89 = 2025
            AND m.mes_89 = 02
            AND m.id_solicitante_89 = s.id_solicitante_01
    )*/
ORDER BY
    s.id_solicitante_01;