My Answer Count Per Language

0

Please login or register to vote for this query.

(click on this box to dismiss)

Programming Puzzles and Code Golf

Q&A for programming puzzle enthusiasts and code golfers

declare @UserId int = ##UserID##;



with EndIndex as (
  select 
      Id, ParentId as QuestionId, Body,
      charindex('|', 
      replace(replace(replace(replace(body, ' ', '|'), '<', '|'), ':', '|'), ',', '|')
        , 5) as LanguageNameEndIndex
  from
      Posts
  where 
      OwnerUserId = @UserId
      and PostTypeId = 2 --answer
      and Body like '<h[1-3]>%'
), AnswerLanguages as (
  select 
    Id, QuestionId, Body, 
    'http://codegolf.stackexchange.com/a/' + convert(varchar(99), Id) as Link,
    lower(substring(Body, 5, LanguageNameEndIndex-5)) as Language
  from EndIndex
)
--select * from AnswerLanguages where Language like 'tsql%'
select Language, count(1) as AnswerCount
from AnswerLanguages
group by Language
order by count(1) desc
;

Enter Parameters

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