PHP_Idiot Posted July 5, 2009 Share Posted July 5, 2009 Hi I need to sort this query to only select records from between two dates! Anyone got any idea how to do it? //mySQL queries $query = "SELECT Player.MembershipNo, Player.FirstName, Player.LastName, SubSelect.VenueName AS Venue, SubSelect.sum_points as Venue_Points, SubSelect.count_results as Venue_Play_Count, SubSelect3.sum_points3 as Total_Points FROM Player, (SELECT Player1.MembershipNo, Venue1.VenueName, SUM(Position1.Points) AS sum_points, COUNT(Player1.MembershipNo) AS count_results FROM Player Player1, Results Results1, Position Position1, Venue Venue1 WHERE Player1.MembershipNo = Results1.MembershipNo AND Results1.Position = Position1.Position AND Venue1.VenueID = Results1.VenueID GROUP BY Player1.MembershipNo, Venue1.VenueID) SubSelect, (SELECT Player3.MembershipNo, SUM(Position3.Points) AS sum_points3 FROM Player Player3, Results Results3, Position Position3 WHERE Player3.MembershipNo = Results3.MembershipNo AND Results3.Position = Position3.Position GROUP BY Player3.MembershipNo) SubSelect3 WHERE Player.MembershipNo = SubSelect.MembershipNo AND SubSelect.sum_points=(SELECT MAX(SubSelect1.sum_points2) FROM (SELECT Player2.MembershipNo, Venue2.VenueName, SUM(Position2.Points) AS sum_points2 FROM Player Player2, Results Results2, Position Position2, Venue Venue2 WHERE Player2.MembershipNo = Results2.MembershipNo AND Results2.Position = Position2.Position AND Venue2.VenueID = Results2.VenueID GROUP BY Player2.MembershipNo, Venue2.VenueID) SubSelect1 WHERE SubSelect1.MembershipNo = SubSelect.MembershipNo) AND Player.MembershipNo = SubSelect3.MembershipNo AND SubSelect.sum_points >= 750 ORDER BY SubSelect.sum_points DESC"; The Date field is held in the Results Table by the way, just in case you needed to know! The query calculates a players total points in each venue then lists all the players and the venue names of where they score of over 750 points, if the player has more than 750 in multiple venues, it only shows the highest scoring venue. But now I need it to do this but for specific date periods, so I can show season 1 or season 2 etc.. Thanks in advance Quote Link to comment Share on other sites More sharing options...
fenway Posted July 10, 2009 Share Posted July 10, 2009 Are you serious??? How do you intend to work with such a query at all? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.