Skip to content

Commit 5a6d4ee

Browse files
committed
ensure greatest returns max value if one item is null
postgres and bigquery handle greatest(null,x) differently. bigquery returns null. postgres returns x.
1 parent 0edce4c commit 5a6d4ee

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

mimic-iv/concepts/organfailure/kdigo_stages.sql

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@ select
7979
, uo.uo_rt_24hr
8080
, uo.aki_stage_uo
8181
-- Classify AKI using both creatinine/urine output criteria
82-
, GREATEST(cr.aki_stage_creat, uo.aki_stage_uo) AS aki_stage
82+
, GREATEST(
83+
COALESCE(cr.aki_stage_creat,0),
84+
COALESCE(uo.aki_stage_uo,0)
85+
) AS aki_stage
8386
FROM `physionet-data.mimic_icu.icustays` ie
8487
-- get all possible charttimes as listed in tm_stg
8588
LEFT JOIN tm_stg tm

0 commit comments

Comments
 (0)