If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
Hi guys, I have a sports database with 3 tables; Player, Player Performance, Matches.
What I am trying to do is find all the Matches players have played in 2002 only. Then I SUM up the scores for every player from the "Player Performance" table. I then display the player with the highest score in 2002. I have got it to work but now I'm stuck on trying to include MAX in there to find the highest score. Suggestions would be greatly appreciated. Thank you.
Thanks for the reply but I've posted my query above. I'm asking for suggestions on the arithmetic and not asking for someone to do it.
I was thinking of using subqueries but I've already hardcoded the Joins in my PHP files, so now I'm not sure how to go about doing this. Either I replace the SUM and workout the MAX first.
I've tried both DESC and LIMIT but they're only superficial, i.e. effect views only. What I'm trying to do is add the MAX function in there.
I really want my queries and PHP code to stand out, so I've gone from basic recommendation of using subqueries and only INT and VARCHAR to using appropriate variables and JOINS. The only problem I have right now is that I can't workout the logic - should I calculate MAX first and then SUM that up?
another hint (the real one): calculate everyone's score, then, using this as a subquery, find the max, then, using that as a subquery, find the person who has this score using a HAVING clause