I have a table with last and first names in separate columns. I need to return all rows containing duplicate last and first names. I have this so far and it works to filter by last name only but not sure how to filter by the first name too. Would appreciate some guidance. Thanks!
with cte1 as (
select
distinct lastName as last_name,
count(lastName) over (partition by lastName) as ln_count
from peoplelist
),
cte2 as (
select
ng.*
from
peoplelist ng
left join
cte1 on cte1.last_name = ng.LastName
where cte1.ln_count > 1
order by LastName desc
)
select * from cte2