MS SQL Query showing Random Results and is Not Ordering Results in DESC Order

crackcool

New Member
I am having issues with the following ms sql query. The first query shown below is the one that was working fine historically. There was no date parameter in the query and it just grouped the top scores by user and listed the top scores in descending order. The second query is the one that is not doing what it's supposed to. Basically, instead of ordering the results in descending order from highest to lowest, it's showing the top scores but it shows them in random order.First Query w/ no Date Parameters (this is working as it should showing top scores in descending order)\[code\]WITH GScore AS( SELECT TOP 10 UserID, MAX(GameScore) AS Score FROM RG_gameScore WHERE GameID = 15 GROUP BY UserID ORDER BY MAX(GameScore) DESC)SELECT GScore.Score AS GameScore, Usr.UserID, Usr.DisplayNameFROM GScoreINNER JOIN RG_Users AS UsrON GScore.UserID = Usr.UserID \[/code\]Second Query with Date Parameters (not working as it should, showing top scores but not listing them in descending order, seems to be randomizing them every time I run the query):\[code\]WITH GScore AS( SELECT TOP 10 UserID, MAX(GameScore) AS Score FROM RG_gameScore WHERE GameID = 15 AND ScoreDate > '4/1/2013' AND ScoreDate < '4/30/2013' GROUP BY UserID ORDER BY MAX(GameScore) DESC)SELECT GScore.Score AS GameScore, Usr.UserID, Usr.DisplayNameFROM GScoreINNER JOIN RG_Users AS UsrON GScore.UserID = Usr.UserID \[/code\]Obviously the ScoreDate is affecting the order of the results but I don't know how to fix it. Any help/advice on this one would be appreciated.
 
Top