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
 SQL Server Development (2000)
 How to create a query that returns ranking

Author  Topic 

danielhai
Yak Posting Veteran

50 Posts

Posted - 2002-03-01 : 16:04:27

I noticed a lot of search engines that have a rank by them, ie microsoft etc. I was wondering how to get the same effect?

For instance, I have a table that has Document Name in it, how would edit a query to return it's rank?

Let's say the query is:

select DocumentName
from tblDocument
where DocumentName like '%String1%' or
DocumentName like '%String2%'

and the rank would be higher if the Document name contains both of those values. Is this possible to do with SQL without a bunch of logic? Can you do it in one query?

Jay99

468 Posts

Posted - 2002-03-01 : 16:14:08
it depends . . . and . . . maybe.

The complexity of the rank is not in the implementation, but rather in the algorithm. If you only criteria is "the rank would be higher if the Document name contains both of those values", then you can write that without "a bunch of logic" and "in one query". However, the move complex you make the rules the more 'bunches of logic' you will have and potentially the more 'queries' you will have.

If you are looking for a a built in rank function . . . no dice.




Jay
Go to Top of Page

graz
Chief SQLTeam Crack Dealer

4149 Posts

Posted - 2002-03-01 : 16:33:13
You might check out this article: http://www.sqlteam.com/item.asp?ItemID=1876

===============================================
Creating tomorrow's legacy systems today.
One crisis at a time.
Go to Top of Page

danielhai
Yak Posting Veteran

50 Posts

Posted - 2002-03-04 : 18:14:45
Thank you graz, that little snippet helps out a bit.

to jay and anyone else:

is there a way to return the count of how many times a string was found inside a field? or is there a way to find if a string was found in multiple fields without having to use a cursor, or something similar?

thanks again for your help

Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-03-04 : 19:15:20
Try this:

http://www.sqlteam.com/item.asp?ItemID=5857

Go to Top of Page
   

- Advertisement -