• Another way of doing this using GROUP BY,

    with cte1 as (

    select DT from dp group by DT having COUNT(distinct type)=1 and count(nr)>1

    ),

    cte2 as (

    select DT from ln group by DT having COUNT(distinct type)=1 and count(nr)>1

    )

    select dp.* from dp join cte1 on dp.dt=cte1.DT

    UNION

    select ln.* from ln join cte2 on ln.dt=cte2.DT