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 2000 Forums
 Transact-SQL (2000)
 Ranking

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-09-27 : 09:05:53
Beni Angek writes "Hi,

I saw one of your other articles on ranking, but I'm trying to do 1 up on that result.

I'm doing a query to find some results and sort them in ranking order by using difference. I'm trying to do it via 3 fields instead of one. Trying to rank the direct link e.g. search for Tax will rank Tax above Tax FAQ...

Fields:
ID
Name
ShortDescr
WholeDescr

Searching for the string 'tax'

Query looks like this:
select *
difference(Name) as NameResult
from Table
where (Name like '%tax%' or ShortDescr like '%tax%' or WholeDesc like '%tax%
order by difference(Name) desc,difference(ShortDescr) desc,difference(WholeDescr) desc

Records:
ID | Name
*********
1 | Tax Page
2 | 2004 Tax returns
3 | AGA syllabi
4 | Testing's tax page
5 | Tax

The funny thing is that record 2 has a difference result of 2 even though it has a direct Tax record.

I found out that the soundex takes the first letter of the record then uses the binary (or something).

How can i do the query that so that if there is a direct match then it ranks higher e.g rank them in this order:
ID
*********
5
1
2
4
3

Many thanks,

Beni"

Shurgenz
Yak Posting Veteran

51 Posts

Posted - 2004-09-29 : 03:32:24
The difference function requires 2 arguments.
Go to Top of Page
   

- Advertisement -