Raul Guerrero
Raul Guerrero

Reputation: 15

There is a way to query the first coincidence in DB2?

The table I'm trying to fetch has several numbers of Vendors with coincidences, so I am trying to fetch clean and get one.

for example:

MyVendorSA CV
MyVendo SA
MyVendorsSACV

what i want to achieve with this is just have 1 record

the output i was looking for is: ** MyVendor **

Upvotes: 0

Views: 114

Answers (1)

Satya
Satya

Reputation: 583

Use soundex to match similar sounding names and use row_number olap function to get first row from matching set.

select vendor from ( select vendor , row_number() over ( partition by soundex( VENDOR ) ) as rn1 from VENDORSTABLE ) T where rn1 = 1

Upvotes: 1

Related Questions