diff --git a/concepts/code-status.sql b/concepts/code-status.sql index 7e4720e..2618d63 100644 --- a/concepts/code-status.sql +++ b/concepts/code-status.sql @@ -10,7 +10,7 @@ with t1 as select icustay_id, charttime, value -- use row number to identify first and last code status , ROW_NUMBER() over (PARTITION BY icustay_id order by charttime) as rnFirst - , ROW_NUMBER() over (PARTITION BY icustay_id order by charttime) as rnLast + , ROW_NUMBER() over (PARTITION BY icustay_id order by charttime desc) as rnLast -- coalesce the values , case