SQL 分组后进行相关统计
求每位同学考试成绩90分以上的优秀率
SELECT student_id,ROUND(AVG(score>90),2)
FROM `score`
GROUP BY `student_id`
求每日的乘客取消率
select t.Request_at as `Day`,
(
round(avg(Status!=\'completed\'),2)
) as `Cancellation Rate`
from
Users u inner join Trips t
on
u.Users_id = t.Client_Id
where u.Banned=\'No\'
and t.Request_at >=\'2013-10-01\'
and t.Request_at <=\'2013-10-03\'
group by t.Request_at