Using SQL Server. Ok, I'm making an in webpage cache system. I wanted to make a simple page rank system along with output. The problem is, I want to display the recordset with the highest relevance score per unique domain. One domain may have multiple records but with different titles, descriptions, etc. he probem is,instead of getting 1 recordset containing a unique domain, it groups all the recordsets of that unique domain and outputs them all. I just want the recordset with the highest relevance score per unique domain per group before it outputs the next (and different domain with the highest relevance for that group)
SELECT title, html, sum(relevance) FROM
(
SELECT title, html, 10 AS relevance FROM page WHERE title like ‘%about%’ UNION
SELECT title, html, 7 AS relevance FROM page WHERE html like ‘%about%’ UNION
SELECT title, html, 5 AS relevance FROM page WHERE keywords like ‘%about%’ UNION
SELECT title, html, 2 AS relevance FROM page WHERE description like ‘%about%’
) results
GROUP BY title, html
ORDER BY relevance desc;
I'm getting:
domain1 title html
domain1 title html
domain1 title html
domain2 title html
domain2 title html
domain2 title html
What I want is
domain1 title html
domain2 title html
domain3 title html
domain4 title html
domain5 title html
Thanks in advance