[英]Hi, i want to find the max of the following sum in the query below
$test = "select s.student_id, s.lastname, sum(p.amount)as Total, count(s.student_id),
e.VALIDATEDDATE from student s, enroll e, payment p
where s.student_id = e.student_id and s.student_id = p.student_id
and e.VALIDATEDDATE is not null group by s.student_id, e.VALIDATEDDATE, s.lastname;"
$resut
= i want display the highest sum as max $resut
= 我想将最高和显示为最大值
You can give it try with something like this你可以试试这样的东西
select s.student_id, s.lastname, sum(p.amount)as Total, count(s.student_id),
e.VALIDATEDDATE from student s, enroll e, payment p
where s.student_id = e.student_id and s.student_id = p.student_id
and e.VALIDATEDDATE is not null group by s.student_id, e.VALIDATEDDATE, s.lastname ORDER BY sum(p.amount) desc
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.