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!

Select only the data that has duplicates strictly with case-sensitivity

RanagalApr 6 2022

Hi all,
Hope you all are doing good.
I have a table (a simplified version of what I have) like below.
My requirement is to select only the values that are duplicates considering with case-sensitivity. I mean strictly case-sensitive. I don't really care if the same values are present in two or more rows as long as they are one and the same with case-sensitivity. If they differ in case, only then I will expect them to be part of the result set.

with tab(names, some_column) as
(
  select 'Sam', 'xyz' from dual union all
  select 'SAM', 'abc' from dual union all
  select 'SaM', 'ijk' from dual union all
  select 'Sam', 'opq' from dual union all
  select 'Ram', 'def' from dual union all
  select 'Tom', 'pqr' from dual union all
  select 'Tom', 'John' from dual
)
select * from tab;

Sample Output:
image.png

Explanation:
SAM and SaM are same as Sam but different only in terms of Case.
Ram does not have any such data so, does not come up in the result set
Tom and Tom are one and the same. And hence it too does not come up in the result

This post has been answered by Frank Kulash on Apr 6 2022
Jump to Answer
Comments
Post Details
Added on Apr 6 2022
8 comments
1,941 views