Usernames used in possible comment replies to posts by a deleted user

0

Please login or register to vote for this query.

(click on this box to dismiss)

Mathematics

Q&A for people studying math at any level and professionals in related fields

; with texts_cte as
(
SELECT DISTINCT c.Text AS Text
FROM Comments c JOIN Posts p ON (c.PostId=p.Id)
  AND (p.OwnerDisplayName='user' + Convert(nvarchar(20), ##UserId##)) 
WHERE (c.Text LIKE '%@%')
)
, substrings_cte AS
(
SELECT substring(Text,charindex('@',Text), len(Text)) AS TextFrom
FROM texts_cte
),
names AS
(
SELECT substring(TextFrom,1,charindex(' ',TextFrom)) AS Reply
FROM substrings_cte
)

SELECT Reply, Count(*)
FROM Names
GROUP BY Reply
ORDER BY Count(*) DESC

Enter Parameters

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