IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

separating duplicates by using sql query


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
umasankarmf

New User


Joined: 08 Sep 2008
Posts: 43
Location: india

PostPosted: Fri Sep 12, 2008 4:25 pm
Reply with quote

Hi,
I have one table in that one calumny has 1 to 10 numbers, every num is 2times. I need to write a query separate those nums.
can any one please suggest me........
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Fri Sep 12, 2008 4:33 pm
Reply with quote

Uma,

Quote:
I need to write a query separate those nums


I did not understand this.

Nyways, Going by the subject you can use DISTINCT keyword to eliminate the duplicates in that column.

Post if your reqt is different.
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Fri Sep 12, 2008 4:33 pm
Reply with quote

Check with keyword search in db2 forum ...ull get lots of posts ..
Back to top
View user's profile Send private message
sri_mf

Active User


Joined: 31 Aug 2006
Posts: 218
Location: India

PostPosted: Fri Sep 12, 2008 4:34 pm
Reply with quote

umasankarmf wrote:
Hi,
I have one table in that one calumny has 1 to 10 numbers, every num is 2times. I need to write a query separate those nums.
can any one please suggest me........


Hope thsi may help you

ibmmainframes.com/viewtopic.php?t=33912&highlight=duplicates
Back to top
View user's profile Send private message
umasankarmf

New User


Joined: 08 Sep 2008
Posts: 43
Location: india

PostPosted: Fri Sep 12, 2008 5:31 pm
Reply with quote

hi,
sorry for the insufficient information. Exactly my req is if one value is repeted 5 times then I need to write a query to get the 4 dups as output.
Back to top
View user's profile Send private message
Bharath Bhat

Active User


Joined: 20 Mar 2008
Posts: 283
Location: chennai

PostPosted: Fri Sep 12, 2008 5:41 pm
Reply with quote

research about Count function.....
Back to top
View user's profile Send private message
birdy K

New User


Joined: 05 Mar 2008
Posts: 72
Location: chennai

PostPosted: Fri Sep 12, 2008 5:44 pm
Reply with quote

Hi

Try this. I didnt execute.

select * from tablename where count(id)>4 and id =123 fetch first 4 rows only;

Correct me If I am wrong
Back to top
View user's profile Send private message
umasankarmf

New User


Joined: 08 Sep 2008
Posts: 43
Location: india

PostPosted: Fri Sep 12, 2008 5:52 pm
Reply with quote

Hi birdy,
I gave only one example like that another value repeated 3times then I need 2only and if another value repeted 6times then I need 5values as output.

Any suggestions..........
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Sat Sep 13, 2008 1:28 am
Reply with quote

Hello,

Which row among the duplicates is to be considered the "original"? How are th original and the duplicate(s) to be "separated"?

What output should be created from your "query"?

If you completely explain what you want to do rather than some incomplete requirement, someone may have a more useful suggestion.

It may be that unloading the table, separating the duplicates by whatever rule(s), and reloading is better suited.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts RC query -Time column CA Products 3
No new posts Dynamically pass table name to a sele... DB2 2
No new posts Query on edit primary command CLIST & REXX 5
No new posts Query on edit primary command CLIST & REXX 1
No new posts Issue with EXEC CICS QUERY SECURITY c... CICS 6
Search our Forums:

Back to Top