Page 1 of 1

Get the data where count is greate than 2 using SORT or DB2.

Posted: Sun Sep 27, 2015 10:03 am
by Rohit Khanna
The data is like this. It can be considered in a DB2 table or a in a file.

Code: Select all

0910001 00 00008 2015-09-12 
0910002 00 00015 2015-09-12 
0910003 00 00017 2015-09-12 
0910003 00 00028 2015-09-11 
0910004 00 00028 2015-09-12 
0910005 00 00112 2015-09-12 
0910007 01 00008 2015-09-12 
0910007 01 00015 2015-09-12 
0910008 01 00017 2015-09-12 
.....  
...... 
...... 		
Write a DB2 query or Sort to get only those values in output where I've have duplicates for the column1. Can we modify the code for duplicate count more than 2, say 3. I was not able to write a code, could someone please help.

Re: Get the data where count is greate than 2 using SORT or DB2.

Posted: Sun Sep 27, 2015 2:27 pm
by zprogrammer
1. Using SQL you could check for count of COLUMN1 having count greater than 2
2. Using sort you could use GROUP function pushing SEQ and get values after 2 for each group

Please try this if you have any further questions someone here will be happy to assist you :)