Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

separating duplicates by using sql query

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: separating duplicates by using sql query
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: 1288
Location: Chennai, India

PostPosted: Fri Sep 12, 2008 4:33 pm    Post subject: Reply to: separating duplicates by using sql query
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    Post subject:
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: 216
Location: India

PostPosted: Fri Sep 12, 2008 4:34 pm    Post subject: Re: separating duplicates by using sql query
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

http://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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Sat Sep 13, 2008 1:28 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Omegamon for DB2 query ashek15 DB2 0 Wed Feb 15, 2017 11:25 am
No new posts Query on DB2 WLM stored procedures ashek15 DB2 8 Sun Feb 12, 2017 11:13 pm
No new posts GETMAIN/FREEMAIN query Suja.Sai CICS 9 Tue Jan 31, 2017 12:01 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us