From 949a62652e0f0174a871a6509a48ddf67d34c583 Mon Sep 17 00:00:00 2001 From: Alistair Johnson Date: Fri, 19 May 2017 10:24:58 -0400 Subject: [PATCH] fix row number bug --- concepts/code-status.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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