diff --git a/inst/sql/sql_server/analyses/1806.sql b/inst/sql/sql_server/analyses/1806.sql index fd886ba6..25259af0 100755 --- a/inst/sql/sql_server/analyses/1806.sql +++ b/inst/sql/sql_server/analyses/1806.sql @@ -1,8 +1,8 @@ -- 1806 Distribution of age by measurement_concept_id ---HINT DISTRIBUTE_ON_KEY(subject_id) +--HINT DISTRIBUTE_ON_KEY(measurement_concept_id) SELECT - o.measurement_concept_id AS subject_id, + o.measurement_concept_id, p.gender_concept_id, o.measurement_start_year - p.year_of_birth AS count_value INTO @@ -35,7 +35,7 @@ ON --HINT DISTRIBUTE_ON_KEY(stratum1_id) with overallStats (stratum1_id, stratum2_id, avg_value, stdev_value, min_value, max_value, total) as ( - select subject_id as stratum1_id, + select measurement_concept_id as stratum1_id, gender_concept_id as stratum2_id, CAST(avg(1.0 * count_value) AS FLOAT) as avg_value, CAST(stdev(count_value) AS FLOAT) as stdev_value, @@ -43,13 +43,13 @@ with overallStats (stratum1_id, stratum2_id, avg_value, stdev_value, min_value, max(count_value) as max_value, count_big(*) as total FROM #rawData_1806 - group by subject_id, gender_concept_id + group by measurement_concept_id, gender_concept_id ), statsView (stratum1_id, stratum2_id, count_value, total, rn) as ( - select subject_id as stratum1_id, gender_concept_id as stratum2_id, count_value, count_big(*) as total, row_number() over (partition by subject_id, gender_concept_id order by count_value) as rn + select measurement_concept_id as stratum1_id, gender_concept_id as stratum2_id, count_value, count_big(*) as total, row_number() over (partition by measurement_concept_id, gender_concept_id order by count_value) as rn FROM #rawData_1806 - group by subject_id, gender_concept_id, count_value + group by measurement_concept_id, gender_concept_id, count_value ), priorStats (stratum1_id, stratum2_id, count_value, total, accumulated) as ( diff --git a/inst/sql/sql_server/analyses/1815.sql b/inst/sql/sql_server/analyses/1815.sql index 18c85cae..f2c1cc16 100755 --- a/inst/sql/sql_server/analyses/1815.sql +++ b/inst/sql/sql_server/analyses/1815.sql @@ -1,8 +1,8 @@ -- 1815 Distribution of numeric values, by measurement_concept_id and unit_concept_id ---HINT DISTRIBUTE_ON_KEY(subject_id) +--HINT DISTRIBUTE_ON_KEY(measurement_concept_id) SELECT - m.measurement_concept_id AS subject_id, + m.measurement_concept_id, m.unit_concept_id, CAST(m.value_as_number AS FLOAT) AS count_value INTO @@ -22,17 +22,17 @@ WHERE --HINT DISTRIBUTE_ON_KEY(stratum1_id) SELECT - m.subject_id AS stratum1_id, + m.measurement_concept_id AS stratum1_id, m.unit_concept_id AS stratum2_id, m.count_value, COUNT_BIG(*) AS total, - ROW_NUMBER() OVER (PARTITION BY m.subject_id,m.unit_concept_id ORDER BY m.count_value) AS rn + ROW_NUMBER() OVER (PARTITION BY m.measurement_concept_id,m.unit_concept_id ORDER BY m.count_value) AS rn INTO #statsView_1815 FROM #measurementView_1815 m GROUP BY - m.subject_id, + m.measurement_concept_id, m.unit_concept_id, m.count_value ; @@ -64,7 +64,7 @@ view_cte as ( ), measurement_cte as ( SELECT - m.subject_id, + m.measurement_concept_id, m.unit_concept_id, m.count_value FROM @@ -76,7 +76,7 @@ measurement_cte as ( ), measurement_agg_cte as ( SELECT - m.subject_id AS stratum1_id, + m.measurement_concept_id AS stratum1_id, m.unit_concept_id AS stratum2_id, CAST(AVG(1.0 * m.count_value) AS FLOAT) AS avg_value, CAST(stdev(m.count_value) AS FLOAT) AS stdev_value, @@ -86,7 +86,7 @@ measurement_agg_cte as ( FROM measurement_cte m GROUP BY - m.subject_id, + m.measurement_concept_id, m.unit_concept_id ) select diff --git a/inst/sql/sql_server/analyses/1816.sql b/inst/sql/sql_server/analyses/1816.sql index be2ebda0..ee3cfb89 100755 --- a/inst/sql/sql_server/analyses/1816.sql +++ b/inst/sql/sql_server/analyses/1816.sql @@ -3,7 +3,7 @@ --HINT DISTRIBUTE_ON_KEY(stratum1_id) SELECT - m.subject_id AS stratum1_id, + m.measurement_concept_id AS stratum1_id, m.unit_concept_id AS stratum2_id, CAST(AVG(1.0 * m.count_value) AS FLOAT) AS avg_value, CAST(STDEV(m.count_value) AS FLOAT) AS stdev_value, @@ -14,7 +14,7 @@ INTO #overallStats_1816 FROM ( SELECT - m.measurement_concept_id AS subject_id, + m.measurement_concept_id, m.unit_concept_id, CAST(m.range_low AS FLOAT) AS count_value FROM @@ -37,22 +37,22 @@ FROM ( m.range_high IS NOT NULL ) m GROUP BY - m.subject_id, + m.measurement_concept_id, m.unit_concept_id ; --HINT DISTRIBUTE_ON_KEY(stratum1_id) SELECT - m.subject_id AS stratum1_id, + m.measurement_concept_id AS stratum1_id, m.unit_concept_id AS stratum2_id, m.count_value, COUNT_BIG(*) AS total, - ROW_NUMBER() OVER (PARTITION BY m.subject_id,m.unit_concept_id ORDER BY m.count_value) AS rn + ROW_NUMBER() OVER (PARTITION BY m.measurement_concept_id,m.unit_concept_id ORDER BY m.count_value) AS rn INTO #statsView_1816 FROM ( SELECT - m.measurement_concept_id AS subject_id, + m.measurement_concept_id, m.unit_concept_id, CAST(m.range_low AS FLOAT) AS count_value FROM @@ -75,7 +75,7 @@ FROM ( m.range_high IS NOT NULL ) m GROUP BY - m.subject_id, + m.measurement_concept_id, m.unit_concept_id, m.count_value ; diff --git a/inst/sql/sql_server/analyses/1817.sql b/inst/sql/sql_server/analyses/1817.sql index 156d0ff5..42891383 100755 --- a/inst/sql/sql_server/analyses/1817.sql +++ b/inst/sql/sql_server/analyses/1817.sql @@ -3,7 +3,7 @@ --HINT DISTRIBUTE_ON_KEY(stratum1_id) SELECT - m.subject_id AS stratum1_id, + m.measurement_concept_id AS stratum1_id, m.unit_concept_id AS stratum2_id, CAST(AVG(1.0 * m.count_value) AS FLOAT) AS avg_value, CAST(STDEV(m.count_value) AS FLOAT) AS stdev_value, @@ -14,7 +14,7 @@ INTO #overallStats_1817 FROM ( SELECT - measurement_concept_id AS subject_id, + measurement_concept_id, unit_concept_id, CAST(range_high AS FLOAT) AS count_value FROM @@ -37,22 +37,22 @@ FROM ( m.range_high IS NOT NULL ) m GROUP BY - m.subject_id, + m.measurement_concept_id, m.unit_concept_id ; --HINT DISTRIBUTE_ON_KEY(stratum1_id) SELECT - m.subject_id AS stratum1_id, + m.measurement_concept_id AS stratum1_id, m.unit_concept_id AS stratum2_id, m.count_value, COUNT_BIG(*) AS total, - ROW_NUMBER() OVER (PARTITION BY m.subject_id,m.unit_concept_id ORDER BY m.count_value) AS rn + ROW_NUMBER() OVER (PARTITION BY m.measurement_concept_id,m.unit_concept_id ORDER BY m.count_value) AS rn INTO #statsView_1817 FROM ( SELECT - m.measurement_concept_id AS subject_id, + m.measurement_concept_id, m.unit_concept_id, CAST(m.range_high AS FLOAT) AS count_value FROM @@ -75,7 +75,7 @@ FROM ( m.range_high IS NOT NULL ) m GROUP BY - m.subject_id, + m.measurement_concept_id, m.unit_concept_id, m.count_value ;