【问题标题】:Calculating Acceptance Rate/Percentage计算接受率/百分比
【发布时间】:2018-01-05 22:25:48
【问题描述】:

我有一份关于申请人offer状态的数据摘要如下:

Status       Count(status)
accepted        2303
rejected        736
unresolved      75

我想通过接受的数量/总和(接受的数量+拒绝的数量)获得接受率

你能帮忙吗?提前非常感谢

【问题讨论】:

标签: mysql sql percentage rate


【解决方案1】:

在 MySQL 中,您可以这样做:

select (sum(case when status = 'accepted' then cnt else 0 end) /
        sum(case when status in ('accepted', 'rejected') then cnt else 0 end)
       ) as ratio
from t;

【讨论】:

  • 嗨,戈登。感谢您的回复。此查询向我抛出了一个错误,其中 cnt 作为未知字段。您在这里使用过任何别名吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-04-03
  • 2011-06-01
  • 2021-01-10
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多