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

All sort of Mainframes Interview Questions.
Post Reply
Rohit Khanna
New Member
Posts: 2
Joined: Sun Feb 15, 2015 11:55 pm

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

Post 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.
zprogrammer
Global Moderator
Global Moderator
Posts: 588
Joined: Wed Nov 20, 2013 11:53 am
Location: Mars

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

Post 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 :)
zprogrammer
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “Interview Questions.”