From 10a6c70131388d8494afb1159f0ad981629084d6 Mon Sep 17 00:00:00 2001 From: Alistair Johnson Date: Thu, 25 May 2017 10:45:14 -0400 Subject: [PATCH] hard-code columns --- tutorials/sql-crosstab.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tutorials/sql-crosstab.md b/tutorials/sql-crosstab.md index 16861b0..8be0fdb 100644 --- a/tutorials/sql-crosstab.md +++ b/tutorials/sql-crosstab.md @@ -65,7 +65,8 @@ FROM crosstab( ORDER BY 1,2' -- below, we list all the unique values in admission_type -- these will become the columns - ,'SELECT DISTINCT admission_type FROM admissions ORDER BY 1' + -- hard-coding them ensures that the order matches what we specify later + ,$$VALUES ('ELECTIVE'::text), ('EMERGENCY'::text), ('NEWBORN'::text), ('URGENT'::text)$$ ) AS ct ( -- first column has each unique value for the rows