From fe2bbef219291727bd867b32ccec40651057b106 Mon Sep 17 00:00:00 2001 From: hemacrimson Date: Wed, 14 Feb 2018 15:39:23 -0500 Subject: [PATCH] fix syntax errors in examples/solutions --- tutorials/sql-intro.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tutorials/sql-intro.md b/tutorials/sql-intro.md index 4a930847e..ae9350471 100644 --- a/tutorials/sql-intro.md +++ b/tutorials/sql-intro.md @@ -341,7 +341,7 @@ It is sometimes helpful to create temporary views or tables to break a large que ``` WITH patient_dates AS ( SELECT p.subject_id, p.dob, a.hadm_id, a.admittime, - (cast(a.admittime as date) - cast(p.dob as date) / 365.2 ) as age + ( (cast(a.admittime as date) - cast(p.dob as date)) / 365.2 ) as age FROM patients p INNER JOIN admissions a ON p.subject_id = a.subject_id @@ -358,7 +358,7 @@ Another method is "materialised views", which create a new table on your databas DROP MATERIALIZED VIEW IF EXISTS patient_dates_view; CREATE MATERIALIZED VIEW patient_dates_view AS SELECT p.subject_id, p.dob, a.hadm_id, a.admittime, - (cast(a.admittime as date) - cast(p.dob as date) / 365.2 ) as age + ( (cast(a.admittime as date) - cast(p.dob as date)) / 365.2 ) as age FROM patients p INNER JOIN admissions a ON p.subject_id = a.subject_id @@ -459,7 +459,7 @@ SELECT icustay_id, max(valuenum) as HeartRate_Max FROM chartevents WHERE itemid = 211 GROUP BY icustay_id -HAVING max(valuenum) > 140; +HAVING max(valuenum) <= 140; ``` # Window functions