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 9216931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:31:30+00:00 2026-06-18T02:31:30+00:00

I have requirement to remove the duplicate values from result set based on some

  • 0

I have requirement to remove the duplicate values from result set based on some unique identifier.

I need to remove the duplicates from the result set.

  while(resultSet.next())
  {     
   int seqNo = resultSet.getInt("SEQUENCE_NO");

   String tableName = resultSet.getString("TABLE_NAME");

   String columnName = resultSet.getString("COLUMN_NAME");

  String filter = resultSet.getString("FILTER");

 }

from the above iteration, i m getting 2 rows from result set. There is same seq no,same table name, different columnname, same filter.

1 PRODUCTFEES CHARGETYPE PRODUCTID

1 PRODUCTFEES PRODUCTCODE PRODUCTID

My requirement is to remove the duplicate table name, duplicate seq no, duplicate filter.

I want to get output something below,

1 PRODUCTFEES CHARGETYPE PRODUCTCODE PRODUCTID
  • 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-06-18T02:31:32+00:00Added an answer on June 18, 2026 at 2:31 am

    By the example you provide, it seems like you want to output all distinct values for each column indidivually (there are 4 columns in the table, but you output 5 values).

    Being the question tagged java, an approach you could take would be using an implementation of Set for each of the columns, so that duplicates won’t get through. Then output all the elements of each Set.

    LinkedHashSet[] sets = new LinkedHashSet[]{
        new LinkedHashSet(), 
        new LinkedHashSet(),
        new LinkedHashSet(),
        new LinkedHashSet() };
    
    while(resultSet.next()) {     
        sets[0].add(resultSet.getInt("SEQUENCE_NO"));
        sets[1].add(resultSet.getString("TABLE_NAME")););
        sets[2].add(resultSet.getString("COLUMN_NAME"));
        sets[3].add(resultSet.getString("FILTER"));
    }
    
    StringBuilder buf = new StringBuilder();
    for (LinkedHashSet set : sets) {
        // append to buf all elements of each set
    }
    

    But it might be simpler to address this from the very same SQL query and just make SELECT DISTINCT columnX for each of the columns and output the result without further manipulation. Or use an aggregation function that will concatenate all distinct values. The implementation will be highly dependent on the DBMS you’re using (GROUP_CONCAT for MySQL, LISTAGG for Oracle, …). This would be a similar question for Oracle: How to use Oracle’s LISTAGG function with a unique filter?

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

Sidebar

Related Questions

I have a requirement where at first I need to remove all space from
I have a requirement in which I need to remove the semicolon if it
We have a requirement in our iOS5/6 app to remove the badge number from
As a prepossessing requirement of my project I have to remove skin hairs from
To remove white space from text i have written the below code.my requirement was
I have a requirement to download multiple CSV files from a remote FTP site.
I have requirement where some times I would like to load children as well
I have requirement as following like showing ABPeoplePickerNavigationController in tabbar based application. I researched
In our project we have requirement that, after receiving sms message from third party
I am using a Telerik RadGrid and have custom filters set up on some

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.