I am quite certain you can't do this with one or two SQL - SELECT commands.
I would just go ahead and write a UDF that finds the closest match for one record (doing a comparison with string functions), adding the records to the result table, one by one.
This can take a long while to run, because, if I understand the specification correctly, for each record you add, you have to examine ALL the remaining records, to see which one gives you the closest match. This has to be repeated for each record, right?
>I need to sort out the records by similairity of 4 fields :
>
>eg.
>
>field1,field2,field3,field4
>
>1,2,3,4
>0,5,6,4
>5,3,4,2
>5,6,7,8
>
>
>
>so, the sort result sould be
>
>1,2,3,4
>5,3,4,2 Because 2,3,4 match 1st record, 3 similairity
>0,5,6,4 Because 5,4 match 2nd record
>5,6,7,8 because 5,6 match 3th record
>
>
>
>
>Anyone have solution for this.
>
>thanks.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)