Q&A about the site for administrators, end users, developers and designers for Craft CMS
-- Ranks open bounties on previously unbountied questions by amount -- This doesn't seem to work, however... declare @latestDate datetime select @latestDate = max(CreationDate) from Posts SELECT TOP 100 RANK() OVER (ORDER BY v.BountyAmount DESC) AS [Rank], v.BountyAmount as Bounty, p.Title as Title,p.Body as Body FROM Posts p INNER JOIN Votes v ON p.Id = v.PostId WHERE v.VoteTypeId = 8 AND datediff(day, @latestDate, v.CreationDate) < 7 AND p.PostTypeId = 1 AND p.Id not in (SELECT p.ParentId FROM Posts p INNER JOIN Votes v ON p.Id = v.PostId WHERE p.PostTypeId != 1 AND v.VoteTypeId = 9)