Word count a user


Please login or register to vote for this query.

(click on this box to dismiss)

Internet of Things Meta

Q&A about the site for builders and users of networked sensors and control devices in the contexts of smart homes, industry automation, or environmental sensors

-- How many words a given user posted?
-- use this snippet to word count a user

DECLARE @UserId int = ##UserId##

     , LEN(Body ) - LEN(replace(Body , ' ', '')) [count]
     , sum(LEN(Body ) - LEN(replace(Body , ' ', ''))) 
         OVER (ORDER BY id) [total count]
FROM posts 
WHERE posts.OwnerUserId = @UserId
order by Id

Enter Parameters

Switch sites:
loading Hold tight while we fetch your results