"So" leaderboards

0

Please login or register to vote for this query.

(click on this box to dismiss)

Ranking of users based on how many answers begin with a particular word or phrase.

Christianity

Q&A for committed Christians, experts in Christianity and those interested in learning more

-- "So" leaderboards
-- Ranking of users based on how many answers begin with a particular word or phrase.

DECLARE @Phrase nvarchar(50)
SET @Phrase = 'so'
DECLARE @UserId int, @SoCount int, @AllCount int
SET @UserId = 102

SELECT @SoCount = COUNT(*)
FROM Posts
WHERE OwnerUserId = @UserId
AND PostTypeId = 2
AND Body LIKE '<p>' + @phrase + '%'

SELECT @AllCount = COUNT(*)
FROM Posts
WHERE OwnerUserId = @UserId
AND PostTypeId = 2

SELECT @SoCount / @AllCount AS "So here's a percentage"

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results