Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6539897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:54:49+00:00 2026-05-25T10:54:49+00:00

There are some duplicate (appearing twice or more) combinations of (id, name, dept_name). Note:

  • 0

There are some duplicate (appearing twice or more) combinations of (id, name, dept_name). Note: the dept_name is nullable so there are often some nulls in that column.

I am trying to get a result of the duplicate (id, name, dept_name) combos where one record has got a null mgr_id or sal but another record of that same duplicated combo has a non-null mgr_id or sal.

This is what I have so far:

 select t1.id, t1.name, t1.dept_name, t1.mgr_id, t2.mgr_id, t1.sal, t2.sal from employee t1
    inner join employee t2 on t2.id = t1.id and t2.name = t1.name
    where t1.id in
    (select id from 
    (select id, name, dept_name, count(*) from employee
    group by id, name, dept_name
    having count(*) > 1))
    and (nvl(t1.mgr_id,0) <> nvl(t2.mgr_id,0) 
    or nvl(t1.sal,0) <> nvl(t2.sal,0)) 
    and t1.mgr_id is not null ;

If I don’t leave the last line “and t1.mgr_id is not null” in the query I effectively receive the same resultset twice (which I don’t want). However I need some way of incorporating the (t1.sal is not null) clause to not get the same resultset twice.

Also, note there is no PK or sequence number column where I can just go:
t1.seq_no <> t2.seq_no.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T10:54:49+00:00Added an answer on May 25, 2026 at 10:54 am

    Can’t you just add the filter to the OR?:

     select t1.id, t1.name, t1.dept_name, t1.mgr_id, t2.mgr_id, t1.sal, t2.sal from employee t1
        inner join employee t2 on t2.id = t1.id and t2.name = t1.name
        where t1.id in
        (select id from 
        (select id, name, dept_name, count(*) from employee
        group by id, name, dept_name
        having count(*) > 1))
        and ((nvl(t1.mgr_id,0) <> nvl(t2.mgr_id,0) AND t1.mgr_id is not null) 
        or (nvl(t1.sal,0) <> nvl(t2.sal,0) AND t1.sal is not null));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Is there a CSS parent selector? Is there some kind of .this
How to find potentially duplicate files in a given directory? Is there some existing
Possible Duplicate: Is there any working memory profiler for Python3 I have some script
Is there some kind of software that I can feed uploaded images to and
Is there some regex that can be passed to re-seq such that it will
Possible Duplicate: Is there some way to compile a .NET application to native code?
Possible Duplicate: Is there some ninja trick to make a variable constant after its
... or alternatively an Array which prevents duplicate entries. Is there some kind of
I have a table with some duplicate rows that I want to normalize into
I have a MySQL database containing names and addresses, but there are some duplicate

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.