Hey all,
I'm not too familiar with more complicated queries, so I'll try to explain what I'm trying to do here:
I have a DB table that organizes stats for a league. Each player id shows up multiple times with the multiple weeks of the league, so to show a summary of stats I do the following:
$stats_query = "SELECT
SUM(td_pass),
SUM(int_pass),
SUM(td),
SUM(sacks),
SUM(int_d),
SUM(`int`) AS exp
FROM xxx
WHERE player_id = '$player_id'";In addition to summarizing these, there's a "MVP Points" calculation using a formula based on the stats:
if($week == "-1") {
$start_mvp = 20;
} else {
$start_mvp = 0;
}
$tdpass_mvp = 4;
$intpass_mvp = 3;
$td_mvp = 6;
$exp_mvp = 2;
$sacks_mvp = 2;
$intd_mvp = 3;
$mvp_points = $start_mvp + ($tdpass_mvp * $row['SUM(td_pass)']) - ($intpass_mvp * $row['SUM(int_pass)']) + ($td_mvp * $row['SUM(td)']) + ($exp_mvp * $row['exp']) + ($sacks_mvp * $row['SUM(sacks)']) + ($intd_mvp * $row['SUM(int_d)']);
echo $mvp_points;
As you can see above, the MVP Points are derived from this formula and there's not actually a column in the DB table for them... which is where my issue is:
I'm looking to query the leader in MVP points either for a specific week or cumulative. I'm not sure how you would utilize subqueries or expressions to do this, or if there is just another way to do it altogether?
Hopefully this makes sense..
Thanks in advance for any help!