Question 2


Please login or register to vote for this query.

(click on this box to dismiss)

Joomla Meta

Q&A about the site for Joomla! administrators, users, developers and designers

/* 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
  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

Enter Parameters

Switch sites:
loading Hold tight while we fetch your results