Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 Can we limit length in concatenation ... balaji81_k DB2 7 Tue Aug 22, 2017 2:50 am
No new posts Select numeric portion from CHAR data... balaji81_k DB2 6 Sat Aug 19, 2017 1:51 am
No new posts SQL - select data available in index Nileshkul DB2 3 Mon Jun 26, 2017 1:30 am
No new posts Using ICETOOL, how we can seperate th... bshkris SYNCSORT 5 Tue May 09, 2017 8:33 pm
No new posts Occurrence of various strings within ... TS70363 JCL & VSAM 1 Thu Apr 27, 2017 8:18 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us