Skip to content

Commit e3dd26f

Browse files
committed
rename subject_id
1 parent d519971 commit e3dd26f

File tree

4 files changed

+28
-28
lines changed

4 files changed

+28
-28
lines changed

inst/sql/sql_server/analyses/1806.sql

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
-- 1806 Distribution of age by measurement_concept_id
22

3-
--HINT DISTRIBUTE_ON_KEY(subject_id)
3+
--HINT DISTRIBUTE_ON_KEY(measurement_concept_id)
44
SELECT
5-
o.measurement_concept_id AS subject_id,
5+
o.measurement_concept_id,
66
p.gender_concept_id,
77
o.measurement_start_year - p.year_of_birth AS count_value
88
INTO
@@ -35,21 +35,21 @@ ON
3535
--HINT DISTRIBUTE_ON_KEY(stratum1_id)
3636
with overallStats (stratum1_id, stratum2_id, avg_value, stdev_value, min_value, max_value, total) as
3737
(
38-
select subject_id as stratum1_id,
38+
select measurement_concept_id as stratum1_id,
3939
gender_concept_id as stratum2_id,
4040
CAST(avg(1.0 * count_value) AS FLOAT) as avg_value,
4141
CAST(stdev(count_value) AS FLOAT) as stdev_value,
4242
min(count_value) as min_value,
4343
max(count_value) as max_value,
4444
count_big(*) as total
4545
FROM #rawData_1806
46-
group by subject_id, gender_concept_id
46+
group by measurement_concept_id, gender_concept_id
4747
),
4848
statsView (stratum1_id, stratum2_id, count_value, total, rn) as
4949
(
50-
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
50+
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
5151
FROM #rawData_1806
52-
group by subject_id, gender_concept_id, count_value
52+
group by measurement_concept_id, gender_concept_id, count_value
5353
),
5454
priorStats (stratum1_id, stratum2_id, count_value, total, accumulated) as
5555
(

inst/sql/sql_server/analyses/1815.sql

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
-- 1815 Distribution of numeric values, by measurement_concept_id and unit_concept_id
22

3-
--HINT DISTRIBUTE_ON_KEY(subject_id)
3+
--HINT DISTRIBUTE_ON_KEY(measurement_concept_id)
44
SELECT
5-
m.measurement_concept_id AS subject_id,
5+
m.measurement_concept_id,
66
m.unit_concept_id,
77
CAST(m.value_as_number AS FLOAT) AS count_value
88
INTO
@@ -22,17 +22,17 @@ WHERE
2222

2323
--HINT DISTRIBUTE_ON_KEY(stratum1_id)
2424
SELECT
25-
m.subject_id AS stratum1_id,
25+
m.measurement_concept_id AS stratum1_id,
2626
m.unit_concept_id AS stratum2_id,
2727
m.count_value,
2828
COUNT_BIG(*) AS total,
29-
ROW_NUMBER() OVER (PARTITION BY m.subject_id,m.unit_concept_id ORDER BY m.count_value) AS rn
29+
ROW_NUMBER() OVER (PARTITION BY m.measurement_concept_id,m.unit_concept_id ORDER BY m.count_value) AS rn
3030
INTO
3131
#statsView_1815
3232
FROM
3333
#measurementView_1815 m
3434
GROUP BY
35-
m.subject_id,
35+
m.measurement_concept_id,
3636
m.unit_concept_id,
3737
m.count_value
3838
;
@@ -64,7 +64,7 @@ view_cte as (
6464
),
6565
measurement_cte as (
6666
SELECT
67-
m.subject_id,
67+
m.measurement_concept_id,
6868
m.unit_concept_id,
6969
m.count_value
7070
FROM
@@ -76,7 +76,7 @@ measurement_cte as (
7676
),
7777
measurement_agg_cte as (
7878
SELECT
79-
m.subject_id AS stratum1_id,
79+
m.measurement_concept_id AS stratum1_id,
8080
m.unit_concept_id AS stratum2_id,
8181
CAST(AVG(1.0 * m.count_value) AS FLOAT) AS avg_value,
8282
CAST(stdev(m.count_value) AS FLOAT) AS stdev_value,
@@ -86,7 +86,7 @@ measurement_agg_cte as (
8686
FROM
8787
measurement_cte m
8888
GROUP BY
89-
m.subject_id,
89+
m.measurement_concept_id,
9090
m.unit_concept_id
9191
)
9292
select

inst/sql/sql_server/analyses/1816.sql

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
--HINT DISTRIBUTE_ON_KEY(stratum1_id)
55
SELECT
6-
m.subject_id AS stratum1_id,
6+
m.measurement_concept_id AS stratum1_id,
77
m.unit_concept_id AS stratum2_id,
88
CAST(AVG(1.0 * m.count_value) AS FLOAT) AS avg_value,
99
CAST(STDEV(m.count_value) AS FLOAT) AS stdev_value,
@@ -14,7 +14,7 @@ INTO
1414
#overallStats_1816
1515
FROM (
1616
SELECT
17-
m.measurement_concept_id AS subject_id,
17+
m.measurement_concept_id,
1818
m.unit_concept_id,
1919
CAST(m.range_low AS FLOAT) AS count_value
2020
FROM
@@ -37,22 +37,22 @@ FROM (
3737
m.range_high IS NOT NULL
3838
) m
3939
GROUP BY
40-
m.subject_id,
40+
m.measurement_concept_id,
4141
m.unit_concept_id
4242
;
4343

4444
--HINT DISTRIBUTE_ON_KEY(stratum1_id)
4545
SELECT
46-
m.subject_id AS stratum1_id,
46+
m.measurement_concept_id AS stratum1_id,
4747
m.unit_concept_id AS stratum2_id,
4848
m.count_value,
4949
COUNT_BIG(*) AS total,
50-
ROW_NUMBER() OVER (PARTITION BY m.subject_id,m.unit_concept_id ORDER BY m.count_value) AS rn
50+
ROW_NUMBER() OVER (PARTITION BY m.measurement_concept_id,m.unit_concept_id ORDER BY m.count_value) AS rn
5151
INTO
5252
#statsView_1816
5353
FROM (
5454
SELECT
55-
m.measurement_concept_id AS subject_id,
55+
m.measurement_concept_id,
5656
m.unit_concept_id,
5757
CAST(m.range_low AS FLOAT) AS count_value
5858
FROM
@@ -75,7 +75,7 @@ FROM (
7575
m.range_high IS NOT NULL
7676
) m
7777
GROUP BY
78-
m.subject_id,
78+
m.measurement_concept_id,
7979
m.unit_concept_id,
8080
m.count_value
8181
;

inst/sql/sql_server/analyses/1817.sql

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
--HINT DISTRIBUTE_ON_KEY(stratum1_id)
55
SELECT
6-
m.subject_id AS stratum1_id,
6+
m.measurement_concept_id AS stratum1_id,
77
m.unit_concept_id AS stratum2_id,
88
CAST(AVG(1.0 * m.count_value) AS FLOAT) AS avg_value,
99
CAST(STDEV(m.count_value) AS FLOAT) AS stdev_value,
@@ -14,7 +14,7 @@ INTO
1414
#overallStats_1817
1515
FROM (
1616
SELECT
17-
measurement_concept_id AS subject_id,
17+
measurement_concept_id,
1818
unit_concept_id,
1919
CAST(range_high AS FLOAT) AS count_value
2020
FROM
@@ -37,22 +37,22 @@ FROM (
3737
m.range_high IS NOT NULL
3838
) m
3939
GROUP BY
40-
m.subject_id,
40+
m.measurement_concept_id,
4141
m.unit_concept_id
4242
;
4343

4444
--HINT DISTRIBUTE_ON_KEY(stratum1_id)
4545
SELECT
46-
m.subject_id AS stratum1_id,
46+
m.measurement_concept_id AS stratum1_id,
4747
m.unit_concept_id AS stratum2_id,
4848
m.count_value,
4949
COUNT_BIG(*) AS total,
50-
ROW_NUMBER() OVER (PARTITION BY m.subject_id,m.unit_concept_id ORDER BY m.count_value) AS rn
50+
ROW_NUMBER() OVER (PARTITION BY m.measurement_concept_id,m.unit_concept_id ORDER BY m.count_value) AS rn
5151
INTO
5252
#statsView_1817
5353
FROM (
5454
SELECT
55-
m.measurement_concept_id AS subject_id,
55+
m.measurement_concept_id,
5656
m.unit_concept_id,
5757
CAST(m.range_high AS FLOAT) AS count_value
5858
FROM
@@ -75,7 +75,7 @@ FROM (
7575
m.range_high IS NOT NULL
7676
) m
7777
GROUP BY
78-
m.subject_id,
78+
m.measurement_concept_id,
7979
m.unit_concept_id,
8080
m.count_value
8181
;

0 commit comments

Comments
 (0)