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
 

 

Select first occurrence of Duplicate!!!

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
ssowmya

New User


Joined: 10 Oct 2006
Posts: 40

PostPosted: Tue Jan 02, 2007 2:10 pm    Post subject: Select first occurrence of Duplicate!!!
Reply with quote

Hi All

I have a table with following info

Vendor-ID Vendor-Name Loc-Name Loc-Seq
00001 Vendor1 A 1
00001 Vendor1 B 1
00002 Vendor2 A 2
00002 Vendor2 A 2
00002 Vendor2 B 1
00003 Vendor3 A 3

I want to extract the records in following format

Vendor-ID Vendor-Name Loc-Name Loc-Seq
00001 Vendor1 A 1
00002 Vendor2 A 2
00003 Vendor3 A 3

That is the first occurrence of Vendor_ID

Please help.....
Back to top
View user's profile Send private message

vicky10001
Warnings : 1

Active User


Joined: 13 Jul 2005
Posts: 136

PostPosted: Tue Jan 02, 2007 4:43 pm    Post subject:
Reply with quote

Please find the below link

http://www.databasejournal.com/features/postgresql/article.php/3437821

I think its helpfull you
Back to top
View user's profile Send private message
raghunathns

Active User


Joined: 08 Dec 2005
Posts: 127
Location: rochester

PostPosted: Wed Jan 03, 2007 12:08 am    Post subject: Select first occurrence of Duplicate!!!
Reply with quote

You mean the column loc-seq is duplicate and find the location which is occuring first.


try this.

select * from tbl1 x
where 0 = (select count(*) from tbl1 y
where y.vendor-name = x.vendor-name
and y.Loc-Seq = x.Loc-Seq
and y.loc-name < x.loc-name)
order by x.vendor-id

.
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 Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts Two Selects in a single select query Rohit Umarjikar DB2 1 Fri Nov 04, 2016 8:46 pm
No new posts Select first 2 group data vice_versa DFSORT/ICETOOL 10 Mon Jun 13, 2016 2:21 pm
No new posts how to find the duplicate list RAVIGUPTA1990 DB2 6 Wed Mar 30, 2016 12:11 am
No new posts Query to select Null row on priority RahulG31 DB2 24 Thu Jan 21, 2016 5:45 pm


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