declare @median int; -- clasic median SELECT @median = M...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Mi Yodeya Meta

Q&A about the site for those who base their lives on Jewish law and tradition and anyone interested in learning more

declare @median int; -- clasic median

               SELECT @median = MAX(Score) 
               FROM (SELECT TOP 50 percent Score
                     FROM Posts as PU
                     WHERE PostTypeId = 1 and CommunityOwnedDate IS NULL 
                         and (

                       Tags like '%##tagName##%' OR
                       Tags like '##tagName##%' OR
                       Tags like '%##tagName##%'
                      )
                     ORDER BY Score
                     ) as t;

-- report results
SELECT 
    Count(Posts.Id) AS Qns,
    @median as MedianAnswerScore,
    avg(Score) as AverageScore
FROM
    Posts
WHERE 
    PostTypeId = 1 and CommunityOwnedDate IS NULL and (

       Tags like '%##tagName##%' OR
       Tags like '##tagName##%' OR
       Tags like '%##tagName##%'
      )

 --  select @median2_below50, @median2_total ;

Enter Parameters

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