Question 2

0

Please login or register to vote for this query.

(click on this box to dismiss)

Japanese Language Meta

Q&A about the site for students, teachers, and linguists wanting to discuss the finer points of the Japanese language

/* 10.	For each Post, display its’ Id, Title, Type and Score. In 
addition, display the max score for its’ type, the position of the 
current post in comparison to other posts of the same type and the 
percentile of the position. Filter the results to display 10 random 
posts where the percentile is between 64 and 88. 
*/

/* selects the correct info
SELECT TOP 100 Id, PostTypeId, Title, Score
FROM Posts
*/

/*
SELECT TOP 100 Posts.Id, Posts.Title, Posts.PostTypeId, Posts.Score, a.MaxScoreByType
FROM Posts
LEFT JOIN (
  SELECT PostTypeId, MAX(Score) as MaxScoreByType
  FROM Posts
  GROUP BY PostTypeId
  ) AS a
ON Posts.PostTypeId = a.PostTypeId
*/

SELECT Id, PostTypeId, Score, RANK() OVER (PARTITION BY (PostTypeId)
  ORDER BY (Score) DESC) AS CountRank
FROM Posts
WHERE PostTypeId = 1
ORDER BY CountRank ASC

Enter Parameters

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