I am trying to replicate the top user page with user sorted by number of post. Suppose there are two users . User 'A' with 5608 post (Answers + questions) And User 'B' with 2627 post(Answers + question). Query results List User A User B So far I have written query to list top 100 users with most post( answers and questions) The query is below Select Top 100 OwnerUserId as [User Link] , sum(score) score , count(*) [# posts] , sum(case posttypeid when 1 then score else 0 end) [question score] , sum(case posttypeid when 2 then score else 0 end) [answer score] , sum(case posttypeid when 1 then 1 else 0 end) [# questions] , sum(case posttypeid when 2 then 1 else 0 end) [# answers] from Posts p inner join posttags pt on pt.postid = coalesce(p.parentid, p.id) WHERE owneruserid is not null and posttypeid in (1,2) -- only questions and answers and communityowneddate is null group by owneruserid order by sum(score) desc This query sorting results incorrectly. It shows 2. BalusC (Post 17035 post) 3. Darin Dimitrov (post 21486) The one with more post is at third rank. I could not figure out what is wrong? But I could not write correct query for it? I have refered to these post - [Retrieve list of top user tags on data.stackexchange.com][1] - [Incorrect syntax near the keyword 'where'][2] [1]: https://meta.stackoverflow.com/questions/325827/retrieve-list-of-top-user-tags-on-data-stackexchange-com [2]: https://stackoverflow.com/questions/10408866/incorrect-syntax-near-the-keyword-where