Created
March 10, 2015 01:26
-
-
Save blooski/6e7f0635149ca61b7e16 to your computer and use it in GitHub Desktop.
SUM, TRUNCATE, IFNULL,left join, left outer join, where, group by, limit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$rs = mysql_query("select p.participant_id, stu_first_name, stu_last_name, | |
SUM(laps_run) as laps, | |
SUM(TRUNCATE(IFNULL(pledge_amt / maxlaps,0),0)) as pledge, | |
SUM(IFNULL(amt_collected,0)) collected | |
from participants as p | |
left join teachers as t on t.teacher_id = p.teacher_id | |
left outer join pledges as pl on pl.participant_id = p.participant_id | |
where pl.teacher_id=$teacher_id | |
group by p.participant_id | |
limit $offset,$rows"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment