Master Posted March 14, 2003 Share Posted March 14, 2003 I have a table with three records - player_id, year, and points. Is there a way to compute a total points from point values stored in different records, in the initial query. Or do I need to execute a different query for every player, or add a total record for each player (call year 0000), and update both each time? Example records. player_id year points 1 2000 424 1 2001 313 2 2001 131 1 2002 242 2 2002 431 I want to return the total points for every player on the database. The number of years involved is a lot, so having all the years in the one record isn\'t really possible. thanks Quote Link to comment Share on other sites More sharing options...
benW Posted March 15, 2003 Share Posted March 15, 2003 Not sure what you\'re trying to do but here you go. [php:1:06593fc386]<?php SELECT TOTAL(points) AS Total FROM table; ?>[/php:1:06593fc386] OR [php:1:06593fc386]<?php //Choose year range $year_range = \'2001, 2002\'; SELECT TOTAL(points) AS Total FROM table WHERE (year IN (\".$year_range.\")); ?>[/php:1:06593fc386] 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.