Q&A for science fiction and fantasy enthusiasts
with PossibleQuotes as (
substring(Q.Body, patindex('%scifi.stackexchange.com/a/%', Q.Body) + 26, 7) as Quote,
from Posts Q
--Q.OwnerUserId <> 54887
Q.Body like '%scifi.stackexchange.com/a/%'
P.Id as [Post Link],
Q.Id as [Post Link],
case when Q.OwnerUserId = 54887 then 'yes' else 'no' end as [SelfQuote?]
from Posts P
inner join PossibleQuotes Q
on Q.Quote like cast(P.Id as varchar) + '/%'
where P.OwnerUserId = 54887 and P.PostTypeId = 2