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

Select first occurrence of Duplicate!!!


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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
Reply with quote

Please find the below link

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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Duplicate transid's declared using CEDA CICS 3
No new posts Dynamically pass table name to a sele... DB2 2
No new posts Duplicate several members of/in one l... JCL & VSAM 7
No new posts SELECT from data change table DB2 5
No new posts Select two different counts from SQL... DB2 6
Search our Forums:

Back to Top