嗨,我想在下面的查询

时间:2015-11-23 05:54:15

标签: mysql oracle10g

 $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 =我希望将最高金额显示为最大值

1 个答案:

答案 0 :(得分:0)

你可以尝试使用类似的东西

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