Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Commit

Permalink
fix division by zero for real (singer-io#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdimercurio authored Nov 29, 2018
1 parent 60a462e commit 09cc793
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions models/meta/medops/medops_video_rate_by_org_monthly.sql
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,20 @@ with videos as (
select paid_employees_monthly.date_month
, paid_employees_monthly.organization_name
, paid_employees_monthly.account_name
, coalesce(paid_employees_monthly.count_paid_employees, 0) as count_paid_employees
, coalesce(videos.count_videos, 0) as count_videos
, coalesce(ubi_consults.nurse_consultations, 0) as nurse_consultations
, coalesce(ubi_consults.gp_consultations, 0) as gp_consultations
, coalesce(ubi_consults.mental_health_consultations, 0) as mental_health_consultations
, coalesce(videos.count_videos, 0) /count_paid_employees::float as video_rate
, coalesce(paid_employees_monthly.count_paid_employees, 0)
as count_paid_employees
, coalesce(videos.count_videos, 0)
as count_videos
, coalesce(ubi_consults.nurse_consultations, 0)
as nurse_consultations
, coalesce(ubi_consults.gp_consultations, 0)
as gp_consultations
, coalesce(ubi_consults.mental_health_consultations, 0)
as mental_health_consultations
, case
when count_paid_employees <> 0
then coalesce(videos.count_videos, 0)::float / count_paid_employees
end as video_rate
from paid_employees_monthly
left join videos using (date_month, organization_name)
left join ubi_consults
Expand Down

0 comments on commit 09cc793

Please sign in to comment.