0

I have created code. Please check the link from the comment. i'm trying to write code which gives unique records for specific column but not for all columns. also tried [while(rs.next())]. but it prints all records with duplicated column values. i want to print table which is unique for specific two columns and duplicated values contain in other columns.Please prefer image which provide below then you will get exact idea what i'm looking for.enter image description here

now here you can see left side table contain all duplicated values of column are extracted from result set. but i want all records but not duplicate values for first two columns.

Arch8
  • 41
  • 7

1 Answers1

1

You want to do it in SQL or in Java? In Java, you can just (I'll do it for one value, you can figure it out for the others):

    String lastUsername;
    while (rs.next()) {
       String username = rs.getString("username");
       if (username.equals(lastUsername)) username = "";
       else lastUsername = username;

       // print username or whatever you need to do with it
    }

You should also make sure that your data set is actually ordered by something, at least the columns you want to replace:

SELECT DISTINCT username, empid, leavetype,remainingleave,requiredleave,STATUS 
  FROM request 
 ORDER BY username, empid
MarcinJ
  • 3,471
  • 2
  • 14
  • 18