 (
   SELECT
     icustay_id,
-    FIRST_VALUE(valuenum) over W AS height_first,
-    MIN(valuenum) over W AS height_min,
-    MAX(valuenum) over W AS height_max
+    FIRST_VALUE(height) over W AS height_first,
+    MIN(height) over W AS height_min,
+    MAX(height) over W AS height_max
     FROM ht_fix
     WINDOW W AS
     (

  ie.icustay_id,
  ROUND(CAST(wt.weight_first AS NUMERIC), 2) AS weight_first,
  ROUND(CAST(wt.weight_min AS NUMERIC), 2) AS weight_min,
  ROUND(CAST(wt.weight_max AS NUMERIC), 2) AS weight_max
  ROUND(CAST(h.height_first AS NUMERIC), 2) AS height_first,
  ROUND(CAST(h.height_min AS NUMERIC), 2) AS height_min,
  ROUND(CAST(h.height_max AS NUMERIC), 2) AS height_max
FROM icustays ie
LEFT JOIN wt
  ON ie.icustay_id = wt.icustay_id

(
  SELECT
    icustay_id,
    FIRST_VALUE(weight) over W AS weight_first,
    MIN(weight) over W AS weight_min,
    MAX(weight) over W AS weight_max
    FROM weightdurations
    WINDOW W AS
    (
      PARTITION BY icustay_id
      ORDER BY starttime
      ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
    )
)
