I've been playing around with CONTAINSTABLE
for keyword matching in my query. I've been asked to extend what we have so that it ranks on weighting on specific columns. I've a simpler query to show below:
SELECT [KEY], sum(rnk) as weightRank
FROM
(
SELECT RANK * 0.05 as rnk, * from CONTAINSTABLE (FundraisingPages, Description, 'marathon')
union all
SELECT RANK * 1 as rnk, * from CONTAINSTABLE (FundraisingPages, Title, 'marathon')
) as t
group by [KEY]
order by weightRank desc
This is fine, it returns the [Key]
and weightRank
as I have asked, but I would also like it to return all of FundraisingPages
columns. However, I can't seem to be able to translate that into the SELECT
statement.
I have tried both *
and FundraisingPages.*
but I get the following error message
Column 't.rnk' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
Now I know that I am only selecting rnk
from within the FROM
part of my query, but any attempt to return more I get the following message
The column 'KEY' was specified multiple times for 't'.
I understand that I'm selecting KEY
and what I can only assume is the matching ID
in FundraisingPages
more than once and that's probably why I'm seeing these errors, but it seems that I can't even select a singular column from that table without getting further errors.