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

  • Home
  • SEARCH
  • 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 50205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T16:33:25+00:00 2026-05-10T16:33:25+00:00

SQL to find duplicate entries (within a group) I have a small problem and

  • 0

SQL to find duplicate entries (within a group)

I have a small problem and I’m not sure what would be the best way to fix it, as I only have limited access to the database (Oracle) itself. In our Table ‘EVENT’ we have about 160k entries, each EVENT has a GROUPID and a normal entry has exactly 5 rows with the same GROUPID. Due to a bug we currently get a couple of duplicate entries (duplicate, so 10 rows instead of 5, just a different EVENTID. This may change, so it’s just <> 5). We need to filter all the entries of these groups.

Due to limited access to the database we can not use a temporary table, nor can we add an index to the GROUPID column to make it faster.

We can get the GROUPIDs with this query, but we would need a second query to get the needed data

select A.'GROUPID' from 'EVENT' A group by A.'GROUPID' having count(A.'GROUPID') <> 5 

One solution would be a subselect:

select * from 'EVENT' A where A.'GROUPID' IN (   select B.'GROUPID'   from 'EVENT' B   group by B.'GROUPID'   having count(B.'GROUPID') <> 5 ) 

Without an index on GROUPID and 160k entries, this takes much too long. Tried thinking about a join that can handle this, but can’t find a good solution so far.

Anybody can find a good solution for this maybe?

Small edit: We don’t have 100% duplicates here, as each entry still has a unique ID and the GROUPID is not unique either (that’s why we need to use ‘group by’) – or maybe I just miss an easy solution for it 🙂

Small example about the data (I don’t want to delete it, just find it)

EVENTID | GROUPID | TYPEID
123456    123       12
123457    123       145
123458    123       2612
123459    123       41
123460    123       238

234567    123       12
234568    123       145
234569    123       2612
234570    123       41
234571    123       238

It has some more columns, like timestamp etc, but as you can see already, everything is identical, besides the EVENTID.

We will run it more often for testing, to find the bug and check if it happens again.

  • 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. 2026-05-10T16:33:25+00:00Added an answer on May 10, 2026 at 4:33 pm

    You can get the answer with a join instead of a subquery

    select     a.* from     event as a inner join     (select groupid      from event      group by groupid      having count(*) <> 5) as b   on a.groupid = b.groupid 

    This is a fairly common way of obtaining the all the information out of the rows in a group.

    Like your suggested answer and the other responses, this will run a lot faster with an index on groupid. It’s up to the DBA to balance the benefit of making your query run a lot faster against the cost of maintaining yet another index.

    If the DBA decides against the index, make sure the appropriate people understand that its the index strategy and not the way you wrote the query that is slowing things down.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 57k
  • Answers 57k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Your query is returning all the widget IDs, instead of… May 11, 2026 at 8:29 am
  • added an answer select count(*) from user_indexes where index_name = 'myIndex' sqlplus won't… May 11, 2026 at 8:29 am
  • added an answer One way would be to create a TStringList, and have… May 11, 2026 at 8:29 am

Top Members

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

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

Related Questions

Loading...

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.