Você pode usar uma subconsulta que atribui uma classificação a cada linha, de modo que, onde houver uma chave duplicada (um KB, qualquer outra coisa), a linha KB seja classificada mais alta; e, em seguida, filtre sobre isso:
-- CTE for sample data
with your_table (clientkey, clientname, department, hostkey) as (
select '0201967/6', 'PPBOP1BOP01-JO,BLOGS', 'KB', 'PPBOP1BOP01/MSC/PPBOP1BOP01/2/B1KI0' from dual
union all
select '0201967/6', 'PPBOP1BOP01-JO,BLOGS', 'BS', 'PPBOP1BOP01/MSC/PPBOP1BOP01/2/B1KI0' from dual
union all
select '0024028/2', 'PPBOP1BOP01-FOO,BAR', 'KB', 'PPBOP1BOP01/MSC/PPBOP1BOP01/2/B2KI0' from dual
union all
select '0024028/2', 'PPBOP1BOP01-FOO,BAR', 'BS', 'PPBOP1BOP01/MSC/PPBOP1BOP01/2/B2KI0' from dual
union all
select '1746947/1', 'BSM1BSM03-THING,BOB', 'BS', 'BSM1BSM03/BSHVS/BSM1BSM03/2/B1KI0' from dual
union all
select '1612105/1', 'WIBU1IBU03-TREE,GREEN', 'BS', 'WIBU1IBU03/SHVS/WIBU1IBU03/3/B1KI0' from dual
)
-- actual query
select clientkey, clientname, department, hostkey
from (
select clientkey, clientname, department, hostkey,
rank () over (partition by clientkey
order by case when department = 'KB' then 0 else 1 end) as rnk
from your_table
)
where rnk = 1;
CLIENTKEY CLIENTNAME DE HOSTKEY
--------- --------------------- -- -----------------------------------
0024028/2 PPBOP1BOP01-FOO,BAR KB PPBOP1BOP01/MSC/PPBOP1BOP01/2/B2KI0
0201967/6 PPBOP1BOP01-JO,BLOGS KB PPBOP1BOP01/MSC/PPBOP1BOP01/2/B1KI0
1612105/1 WIBU1IBU03-TREE,GREEN BS WIBU1IBU03/SHVS/WIBU1IBU03/3/B1KI0
1746947/1 BSM1BSM03-THING,BOB BS BSM1BSM03/BSHVS/BSM1BSM03/2/B1KI0
Isso ainda permitirá duplicatas em outros departamentos, se isso acontecer, e incluirá todas essas linhas; ele só excluirá duplicatas para KB.