find prior displaynames of voters

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

;with voters as
(
Select users.UserId
    , users.UserDisplayName
    , CreationDate
From PostHistory
cross apply openjson(Text, '$.Voters') 
       with ( UserId int '$.Id'
            , UserDisplayName nvarchar(150) '$.DisplayName') users
where posthistorytypeid in (10,11,12,13,14,15,19,20,35) 
and Text is not null 
and len(text) > 0 
and users.userid = ##userid?1233251##
)

select UserDisplayName
     , min(creationdate) [first seen]
     , max(creationdate) [last seen]     
from voters
group by UserDisplayName
order by min(creationdate) desc

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results