Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 closet match

Author  Topic 

jonathan.hoang
Starting Member

2 Posts

Posted - 2012-08-10 : 18:20:42
Hello,

I'm new to SQL and I ran into a problem how to select the closest match?

For example if I have a table Chart which has three columns (Code, Modifier, MappingCode)

let say it has the following rows:
1) 1110, 50, xxxxx
2) 1110, null, yyyyy
3) 2220, 50, zzzzz

and the input example are:
1) 1110 - the closest match we want is row 2

2) 1110,50 - the closest match we want is row 1

3) 2220 - the closest match we want is row 3


Thanks for your help,
-Jonathan


yosiasz
Master Smack Fu Yak Hacker

1635 Posts

Posted - 2012-08-10 : 18:38:30
are code and modifier always int?

<><><><><><><><><><><><><><><><><>
If you don't have the passion to help people, you have no passion
Go to Top of Page

jonathan.hoang
Starting Member

2 Posts

Posted - 2012-08-10 : 18:47:15
There both Char defined. Sorry, I did not explain correctly. Thanks.
Go to Top of Page
   

- Advertisement -