Skip to content

Commit

Permalink
rename subject_id
Browse files Browse the repository at this point in the history
  • Loading branch information
1Anuar committed Sep 16, 2024
1 parent d519971 commit e3dd26f
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 28 deletions.
12 changes: 6 additions & 6 deletions inst/sql/sql_server/analyses/1806.sql
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -35,21 +35,21 @@ 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,
min(count_value) as 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
(
Expand Down
16 changes: 8 additions & 8 deletions inst/sql/sql_server/analyses/1815.sql
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
;
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -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
Expand Down
14 changes: 7 additions & 7 deletions inst/sql/sql_server/analyses/1816.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
;
Expand Down
14 changes: 7 additions & 7 deletions inst/sql/sql_server/analyses/1817.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
;
Expand Down

0 comments on commit e3dd26f

Please sign in to comment.