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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM