Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions tutorials/sql-intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down