select *
from (
select artist||' - '||regexp_replace(album, ' \(.*\)', '') as artist_album,
regexp_replace(path, '(?i)\/(CD|DISC) *\d*', '') as path,
sum(1) over (partition by artist||' - '||regexp_replace(album, ' \(.*\)', '')) as count_albums
from (
select distinct artist,
album,
rtrim(path, replace(path, '/', '')) as path
from details
where mime not null
)
group by 1, 2
)
where count_albums > 1;