Lang v Votes

0

Please login or register to vote for this query.

(click on this box to dismiss)

Code Golf and Coding Challenges

Q&A for programming puzzle enthusiasts and code golfers

DECLARE @LANGA varchar(100) = ##LanguageA:string##
DECLARE @LANGB varchar(100) = ##LanguageB:string##

SELECT
@LANGA as [Name],
CAST(SUM(Score) AS float) / CAST(COUNT(*) AS float) as [Mean Score],
COUNT(*) as [Total Posts]
FROM Posts
WHERE PostTypeId = 2
AND (
  Lower(Body) LIKE '%<h_>' + Lower(@LANGA) + '%'
  OR Lower(Body) LIKE '%' + Lower(@LANGA) + '</a>%</h_>%'
)

UNION

SELECT
@LANGB as [Name],
CAST(SUM(Score) AS float) / CAST(COUNT(*) AS float) as [Mean Score],
COUNT(*) as [Total Posts]
FROM Posts
WHERE PostTypeId = 2
AND (
  Lower(Body) LIKE '%<h_>' + Lower(@LANGB) + '%'
  OR Lower(Body) LIKE '%' + Lower(@LANGB) + '</a>%</h_>%'
)

Enter Parameters

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