|
1 | 1 | -- 1806 Distribution of age by measurement_concept_id
|
2 | 2 |
|
3 |
| ---HINT DISTRIBUTE_ON_KEY(subject_id) |
| 3 | +--HINT DISTRIBUTE_ON_KEY(measurement_concept_id) |
4 | 4 | SELECT
|
5 |
| - o.measurement_concept_id AS subject_id, |
| 5 | + o.measurement_concept_id, |
6 | 6 | p.gender_concept_id,
|
7 | 7 | o.measurement_start_year - p.year_of_birth AS count_value
|
8 | 8 | INTO
|
|
35 | 35 | --HINT DISTRIBUTE_ON_KEY(stratum1_id)
|
36 | 36 | with overallStats (stratum1_id, stratum2_id, avg_value, stdev_value, min_value, max_value, total) as
|
37 | 37 | (
|
38 |
| - select subject_id as stratum1_id, |
| 38 | + select measurement_concept_id as stratum1_id, |
39 | 39 | gender_concept_id as stratum2_id,
|
40 | 40 | CAST(avg(1.0 * count_value) AS FLOAT) as avg_value,
|
41 | 41 | CAST(stdev(count_value) AS FLOAT) as stdev_value,
|
42 | 42 | min(count_value) as min_value,
|
43 | 43 | max(count_value) as max_value,
|
44 | 44 | count_big(*) as total
|
45 | 45 | FROM #rawData_1806
|
46 |
| - group by subject_id, gender_concept_id |
| 46 | + group by measurement_concept_id, gender_concept_id |
47 | 47 | ),
|
48 | 48 | statsView (stratum1_id, stratum2_id, count_value, total, rn) as
|
49 | 49 | (
|
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 |
51 | 51 | FROM #rawData_1806
|
52 |
| - group by subject_id, gender_concept_id, count_value |
| 52 | + group by measurement_concept_id, gender_concept_id, count_value |
53 | 53 | ),
|
54 | 54 | priorStats (stratum1_id, stratum2_id, count_value, total, accumulated) as
|
55 | 55 | (
|
|
0 commit comments