我正在尝试将where子句添加到以下查询中:
SELECT TOP 200 ROW_NUMBER() OVER (ORDER BY KEY_TBL.RANK DESC) AS RowNumber, FT_TBL.JobId,
FT_TBL.Title, FT_TBL.[Description], FT_TBL.Location, KEY_TBL.RANK
FROM Jobs AS FT_TBL
INNER JOIN
FREETEXTTABLE (Jobs, (Title, [Description]), 'packaging')
AS KEY_TBL ON FT_TBL.JobId = KEY_TBL.[KEY]
WHERE CONTAINS (Location, '"luton*"')
AND PostedDate >= GETDATE() - 7
我想添加到底部的是: AND RowNumber> 5 ,但它无法识别RowNumber,我尝试将其添加到INNER JOIN的行上方,但它仍然无效!有任何想法吗?感谢
答案 0 :(得分:2)
SELECT * FROM (
SELECT TOP 200 ROW_NUMBER() OVER (ORDER BY KEY_TBL.RANK DESC) AS RowNumber, FT_TBL.JobId,
FT_TBL.Title, FT_TBL.[Description], FT_TBL.Location, KEY_TBL.RANK
FROM Jobs AS FT_TBL
INNER JOIN
FREETEXTTABLE (Jobs, (Title, [Description]), 'packaging')
AS KEY_TBL ON FT_TBL.JobId = KEY_TBL.[KEY]
WHERE CONTAINS (Location, '"luton*"')
AND PostedDate >= GETDATE() - 7
) as tmp WHERE tmp.RowNumber > 5