Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Finding unique combination of 2 columns

Peter7734 hours ago

DB version: 19c

In the below table, I want to find the combination of item_proc_code and region_code which are unique.

So, in the below table, the following 2 sets of item_proc_code + region_code are unique.

  ITEM_ID ITEM_PROC_ REGION_COD
---------- ---------- ----------
       75 SB7YUTH    CY
       77 SB7YUTH    CY
       78 RMYN84U    BN
       81 RMYN84U    BN

How can I retrieve it ? My below query threw ORA-00907 error

create table item_master (item_id number, item_proc_code varchar2(10), region_code varchar2(10) );

insert into item_master values (75,'SB7YUTH', 'CY');
insert into item_master values (76,'XBUR83Y', 'KN');
insert into item_master values (77,'SB7YUTH', 'CY');
insert into item_master values (78,'RMYN84U', 'BN');
insert into item_master values (79,'HZLPR6Y', 'KA');
insert into item_master values (80,'LNVR2BH', 'YU');
insert into item_master values (81,'RMYN84U', 'BN');

commit;

SQL> select * from item_master;

  ITEM_ID ITEM_PROC_ REGION_COD
---------- ---------- ----------
       75 SB7YUTH    CY
       76 XBUR83Y    KN
       77 SB7YUTH    CY
       78 RMYN84U    BN
       79 HZLPR6Y    KA
       80 LNVR2BH    YU
       81 RMYN84U    BN
       
7 rows selected.

SQL> select distinct(item_proc_code, region_code) from item_master;

select distinct(item_proc_code, region_code) from item_master
                             *
ERROR at line 1:
ORA-00907: missing right parenthesis
This post has been answered by stom on Oct 7 2025
Jump to Answer
Comments
Post Details
Added 34 hours ago
5 comments
82 views