我的任务是提供每月成功完成的百分比。我已经查看了其他问题中的示例,它们对我来说没有意义。
我运行查询以显示 30 天内的完成情况(见下文)。但是,将 <10405> 代码的数量除以所有代码的总数让我感到困惑。
有人可以引导我找到解决方案吗?谢谢。以下是总完成的当前查询:
SELECT groups.description AS Group,notes.date_service, services.code AS Service,
clients.client_id, clients.name_lastfirst_cs AS Client, staff.staff_name_cs AS Staff
from notes, services, clients, staff, groups, address
WHERE notes.zrud_service = services.zzud_service
AND notes.zrud_client = clients.zzud_client
AND notes.zrud_staff = staff.zzud_staff
AND notes.zrud_group = groups.zzud_group
AND services.code IN '10401','10402','10403','10405')
-- 10401 - 403 = successful; 10405 unsuccessful
AND notes.date_service BETWEEN (now() - '30 days'::interval)::timestamp AND now()