Need a sql query: retrive all duplicate records in table

Answers were Sorted based on User's Feedback



Need a sql query: retrive all duplicate records in table..

Answer / chiranjeevi ch

let us assume we have some duplicate records in sample table
and we can identify duplicates with eid.

The the query looks like this.

Select * from sample
where eid=any
(select eid from sample having count(eid)>1 group by eid);

Note: This should be used SQl .. but i never tried in as400
when ever it is necessary means i use following sql
statement in as400 .......

select * from sample where eid=111

it displays all duplicate records related to 111

Is This Answer Correct ?    7 Yes 1 No

Need a sql query: retrive all duplicate records in table..

Answer / kusum

For duplicate records retrieval::::

Select * from employee a where rrn(employee) > (select
min(rrn(employee)) from employee b where a.empno = b.empno)

Is This Answer Correct ?    4 Yes 0 No

Need a sql query: retrive all duplicate records in table..

Answer / sbakshi4

File name : FLNM
Field name : FLD

Query :
SELECT FLD ,COUNT(*) FROM FLNM GROUP BY FLD HAVING COUNT(*) > 1

This will give the field values repeatation with the number of times it is been duplicated.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More RPG400 Interview Questions

Can AnyOne tell me how to read join logical file in rpg from starting to end?

2 Answers  


What is the diff bw PF/LF Name and their Record format name? what is restriction in record format then file name?

0 Answers   Wipro,


1.What is the Maximum field length we can declare in RLU?? 2. What is the difference if your designing RLU using DDS and using the option 19 for the RLU??

2 Answers  


If record-format name in an externally-described file has already been defined as a file-name.how to solve this?

2 Answers   CTS,


How to get only unique records from a file which contains duplicate data using CPYF command ? Example : FILEA has duplicate records and FILEB is a UNIQUE defined.... and I want to get the data from FILEA to FILEB by eliminating all the duplicate records...

2 Answers  






How to print Superscript / Subscript from RPG400

1 Answers  


When a object will be locked & when a record will be locked? Plz explain.

2 Answers  


what is the rpg system?

0 Answers   IBM,


how we create binder member for updating service program and where we type this code on command line or in program ? strpgmexp pgmlvl(*current) export symbol (xyz0 endpgmexp. plz explain me this step by step .

2 Answers  


we hav job which is running as batch. it takes atleast 06hours to complete tht job. bu i wana do tht job with in 3hours.........? so plz post ur answers

8 Answers   Cap Gemini, IBM,


How can we find out whether the job is interactive or Batch through RPG program? 2) How can we find out through CL program?

6 Answers   CSC,


I have file with data as follows data 1 2 3 4 5 I need to read 1 and 5 ,then 2 and 4 then like.. upto end of file, can any one help on this

3 Answers   ISG,


Categories