查询显示故障率的百分比 [英] Query to display the % of the failure rate

查看:109
本文介绍了查询显示故障率的百分比的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了这个查询来获取我的数据,所有的数据都很好。

I have written this query to get my data, and all the data is fine.

我有一个列有Pass或Fail。我想计算失败的预订次数的百分比,并将其输出为单个值。

I have one column which has either Pass Or Fail. I want to calculate the % of number of bookings that failed, and output it in a single value.

我必须写另一个查询来显示一个数字。 / p>

I will have to write another query to show that one number.

推荐答案

也许这个?你真的没有提供太多的东西:

Perhaps this? You didn't really offer much to go on:

SELECT
    SUM(CASE
        WHEN trip_rating.rating <= 3 OR
           TIMESTAMPDIFF(MINUTE, booking_activity.activity_time, booking.pick_up_time) < 0 
    THEN 1.00 ELSE NULL END
    ) / COUNT(*)
FROM ...

这篇关于查询显示故障率的百分比的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆