Order
- зарезервированное ключевое слово, поэтому я использовал order_column
.
Сначала тестовые данные:
create table order_route_table(order_column varchar2(20)
, route number);
insert into order_route_table
select 'Order_1', 100 from dual
union all select 'Order_1', 101 from dual
union all select 'Order_2', 102 from dual
union all select 'Order_3', 103 from dual
union all select 'Order_4', 104 from dual;
Затем традиционно:
select order_column, min(route)
from order_route_table
group by order_column
having count(*) = 1;
С аналитикой:
select order_column, route
from (select order_column
, route
, count(*) over (partition by order_column) as order_count
from order_route_table)
where order_count = 1;
Результаты в любом случае:
ORDER_COLUMN ROUTE
-------------------- ----------
Order_2 102
Order_3 103
Order_4 104