@@ -31,62 +31,62 @@ Populates and references:
31
31
values (0 , ' 9.1.0' )
32
32
33
33
insert into tlsa_CountPops (PopID, HouseholdID, Step)
34
- select 10 , HouseholdID, ' 9.1.1'
34
+ select distinct 10 , HouseholdID, ' 9.1.1'
35
35
from tlsa_HHID
36
36
where AHAR = 1 and HHAdultAge = 18
37
37
and ActiveHHType = 1
38
38
39
39
insert into tlsa_CountPops (PopID, HouseholdID, Step)
40
- select 11 , HouseholdID, ' 9.1.2'
40
+ select distinct 11 , HouseholdID, ' 9.1.2'
41
41
from tlsa_HHID
42
42
where AHAR = 1 and HHAdultAge = 24
43
43
and ActiveHHType = 1
44
44
45
45
insert into tlsa_CountPops (PopID, HouseholdID, Step)
46
- select 12 , HouseholdID, ' 9.1.3'
46
+ select distinct 12 , HouseholdID, ' 9.1.3'
47
47
from tlsa_HHID
48
48
where AHAR = 1 and HHParent = 1 and HHAdultAge in (18 ,24 )
49
49
and ActiveHHType = 2
50
50
51
51
insert into tlsa_CountPops (PopID, HouseholdID, Step)
52
- select 13 , HouseholdID, ' 9.1.4'
52
+ select distinct 13 , HouseholdID, ' 9.1.4'
53
53
from tlsa_HHID
54
54
where AHAR = 1 and HHVet = 1
55
55
56
56
insert into tlsa_CountPops (PopID, HouseholdID, Step)
57
- select 14 , HouseholdID, ' 9.1.5'
57
+ select distinct 14 , HouseholdID, ' 9.1.5'
58
58
from tlsa_HHID
59
59
where AHAR = 1 and HHVet = 0 and HHAdultAge in (25 ,55 )
60
60
and ActiveHHType = 1
61
61
62
62
insert into tlsa_CountPops (PopID, HouseholdID, Step)
63
- select 15 , HouseholdID, ' 9.1.6'
63
+ select distinct 15 , HouseholdID, ' 9.1.6'
64
64
from tlsa_HHID
65
65
where AHAR = 1 and HHChronic = 1
66
66
67
67
insert into tlsa_CountPops (PopID, HouseholdID, Step)
68
- select 18 , HouseholdID, ' 9.1.7'
68
+ select distinct 18 , HouseholdID, ' 9.1.7'
69
69
from tlsa_HHID
70
70
where AHAR = 1 and HHDisability = 1
71
71
72
72
insert into tlsa_CountPops (PopID, HouseholdID, Step)
73
- select 19 , HouseholdID, ' 9.1.8'
73
+ select distinct 19 , HouseholdID, ' 9.1.8'
74
74
from tlsa_HHID
75
75
where AHAR = 1 and HHFleeingDV = 1
76
76
77
77
insert into tlsa_CountPops (PopID, HouseholdID, Step)
78
- select 45 , HouseholdID, ' 9.1.9'
78
+ select distinct 45 , HouseholdID, ' 9.1.9'
79
79
from tlsa_HHID
80
80
where AHAR = 1 and HHAdultAge = 55
81
81
and ActiveHHType = 1
82
82
83
83
insert into tlsa_CountPops (PopID, HouseholdID, Step)
84
- select 46 , HouseholdID, ' 9.1.10'
84
+ select distinct 46 , HouseholdID, ' 9.1.10'
85
85
from tlsa_HHID
86
86
where AHAR = 1 and HHParent = 1 and ActiveHHType = 3
87
87
88
88
insert into tlsa_CountPops (PopID, HouseholdID, Step)
89
- select 48 , HouseholdID, ' 9.1.11'
89
+ select distinct 48 , HouseholdID, ' 9.1.11'
90
90
from tlsa_HHID
91
91
where AHAR = 1 and HHFleeingDV = 2
92
92
@@ -97,12 +97,12 @@ Populates and references:
97
97
where n .AHAR = 1 and lp .VetStatus = 1
98
98
99
99
insert into tlsa_CountPops (PopID, PersonalID, HouseholdID, Step)
100
- select 51 , hhid .HoHID , hhid .HouseholdID , ' 9.1.13'
100
+ select distinct 51 , hhid .HoHID , hhid .HouseholdID , ' 9.1.13'
101
101
from tlsa_HHID hhid
102
102
where hhid .AHAR = 1 and hhid .HHAdultAge in (18 ,24 ) and hhid .HHParent = 1 and hhid .ActiveHHType = 2
103
103
104
104
insert into tlsa_CountPops (PopID, PersonalID, HouseholdID, Step)
105
- select 52 , hhid .HoHID , hhid .HouseholdID , ' 9.1.14'
105
+ select distinct 52 , hhid .HoHID , hhid .HouseholdID , ' 9.1.14'
106
106
from tlsa_HHID hhid
107
107
where hhid .AHAR = 1 and hhid .HHParent = 1 and hhid .ActiveHHType = 3
108
108
@@ -149,43 +149,43 @@ Populates and references:
149
149
where n .AHAR = 1 and lp .RaceEthnicity not in (98 ,99 )
150
150
151
151
insert into tlsa_CountPops (PopID, PersonalID, Step)
152
- select 71 , n .PersonalID , ' 9.1.19'
152
+ select distinct 71 , n .PersonalID , ' 9.1.19'
153
153
from tlsa_Enrollment n
154
154
inner join tlsa_Person lp on lp .PersonalID = n .PersonalID
155
155
where n .AHAR = 1 and cast(lp .RaceEthnicity as nvarchar) like ' %1%'
156
156
157
157
insert into tlsa_CountPops (PopID, PersonalID, Step)
158
- select 72 , n .PersonalID , ' 9.1.20'
158
+ select distinct 72 , n .PersonalID , ' 9.1.20'
159
159
from tlsa_Enrollment n
160
160
inner join tlsa_Person lp on lp .PersonalID = n .PersonalID
161
161
where n .AHAR = 1 and cast(lp .RaceEthnicity as nvarchar) like ' %2%'
162
162
163
163
insert into tlsa_CountPops (PopID, PersonalID, Step)
164
- select 73 , n .PersonalID , ' 9.1.21'
164
+ select distinct 73 , n .PersonalID , ' 9.1.21'
165
165
from tlsa_Enrollment n
166
166
inner join tlsa_Person lp on lp .PersonalID = n .PersonalID
167
167
where n .AHAR = 1 and cast(lp .RaceEthnicity as nvarchar) like ' %3%'
168
168
169
169
insert into tlsa_CountPops (PopID, PersonalID, Step)
170
- select 74 , n .PersonalID , ' 9.1.22'
170
+ select distinct 74 , n .PersonalID , ' 9.1.22'
171
171
from tlsa_Enrollment n
172
172
inner join tlsa_Person lp on lp .PersonalID = n .PersonalID
173
173
where n .AHAR = 1 and cast(lp .RaceEthnicity as nvarchar) like ' %6%'
174
174
175
175
insert into tlsa_CountPops (PopID, PersonalID, Step)
176
- select 75 , n .PersonalID , ' 9.1.23'
176
+ select distinct 75 , n .PersonalID , ' 9.1.23'
177
177
from tlsa_Enrollment n
178
178
inner join tlsa_Person lp on lp .PersonalID = n .PersonalID
179
179
where n .AHAR = 1 and cast(lp .RaceEthnicity as nvarchar) like ' %7%'
180
180
181
181
insert into tlsa_CountPops (PopID, PersonalID, Step)
182
- select 76 , n .PersonalID , ' 9.1.24'
182
+ select distinct 76 , n .PersonalID , ' 9.1.24'
183
183
from tlsa_Enrollment n
184
184
inner join tlsa_Person lp on lp .PersonalID = n .PersonalID
185
185
where n .AHAR = 1 and cast(lp .RaceEthnicity as nvarchar) like ' %4%'
186
186
187
187
insert into tlsa_CountPops (PopID, PersonalID, Step)
188
- select 77 , n .PersonalID , ' 9.1.25'
188
+ select distinct 77 , n .PersonalID , ' 9.1.25'
189
189
from tlsa_Enrollment n
190
190
inner join tlsa_Person lp on lp .PersonalID = n .PersonalID
191
191
where n .AHAR = 1 and cast(lp .RaceEthnicity as nvarchar) like ' %5%'
@@ -206,7 +206,7 @@ Populates and references:
206
206
where n .AHAR = 1 and lp .Gender not in (98 , 99 )
207
207
208
208
insert into tlsa_CountPops (PopID, PersonalID, Step)
209
- select case max (n .ActiveAge )
209
+ select distinct case max (n .ActiveAge )
210
210
when 0 then 86
211
211
when 2 then 87
212
212
when 5 then 88
@@ -255,19 +255,19 @@ Populates and references:
255
255
*/
256
256
257
257
update n
258
- set PITOctober = (select case when cd .Cohort is null then 0 else 1 end
258
+ set PITOctober = (select distinct case when cd .Cohort is null then 0 else 1 end
259
259
from tlsa_CohortDates cd
260
260
where (cd .CohortStart < n .ExitDate or n .ExitDate is NULL )
261
261
and n .EntryDate <= cd .CohortStart and cd .Cohort = 10 )
262
- , PITJanuary = (select case when cd .Cohort is null then 0 else 1 end
262
+ , PITJanuary = (select distinct case when cd .Cohort is null then 0 else 1 end
263
263
from tlsa_CohortDates cd
264
264
where (cd .CohortStart < n .ExitDate or n .ExitDate is NULL )
265
265
and n .EntryDate <= cd .CohortStart and cd .Cohort = 11 )
266
- , PITApril = (select case when cd .Cohort is null then 0 else 1 end
266
+ , PITApril = (select distinct case when cd .Cohort is null then 0 else 1 end
267
267
from tlsa_CohortDates cd
268
268
where (cd .CohortStart < n .ExitDate or n .ExitDate is NULL )
269
269
and n .EntryDate <= cd .CohortStart and cd .Cohort = 12 )
270
- , PITJuly = (select case when cd .Cohort is null then 0 else 1 end
270
+ , PITJuly = (select distinct case when cd .Cohort is null then 0 else 1 end
271
271
from tlsa_CohortDates cd
272
272
where (cd .CohortStart < n .ExitDate or n .ExitDate is NULL )
273
273
and n .EntryDate <= cd .CohortStart and cd .Cohort = 13 )
@@ -283,7 +283,7 @@ Populates and references:
283
283
, n .PITJuly = PIT .PITJuly
284
284
, n .Step = ' 9.2.2'
285
285
from tlsa_Enrollment n
286
- inner join (select nbn .EnrollmentID
286
+ inner join (select distinct nbn .EnrollmentID
287
287
, PITOctober = max (case when cd1 .Cohort is null then 0 else 1 end)
288
288
, PITJanuary = max (case when cd2 .Cohort is null then 0 else 1 end)
289
289
, PITApril = max (case when cd3 .Cohort is null then 0 else 1 end)
@@ -303,19 +303,19 @@ Populates and references:
303
303
group by nbn .EnrollmentID ) PIT on PIT .EnrollmentID = n .EnrollmentID
304
304
305
305
update n
306
- set PITOctober = (select case when cd .Cohort is null then 0 else 1 end
306
+ set PITOctober = (select distinct case when cd .Cohort is null then 0 else 1 end
307
307
from tlsa_CohortDates cd
308
308
where (cd .CohortStart < n .ExitDate or n .ExitDate is NULL )
309
309
and n .MoveInDate <= cd .CohortStart and cd .Cohort = 10 )
310
- , PITJanuary = (select case when cd .Cohort is null then 0 else 1 end
310
+ , PITJanuary = (select distinct case when cd .Cohort is null then 0 else 1 end
311
311
from tlsa_CohortDates cd
312
312
where (cd .CohortStart < n .ExitDate or n .ExitDate is NULL )
313
313
and n .MoveInDate <= cd .CohortStart and cd .Cohort = 11 )
314
- , PITApril = (select case when cd .Cohort is null then 0 else 1 end
314
+ , PITApril = (select distinct case when cd .Cohort is null then 0 else 1 end
315
315
from tlsa_CohortDates cd
316
316
where (cd .CohortStart < n .ExitDate or n .ExitDate is NULL )
317
317
and n .MoveInDate <= cd .CohortStart and cd .Cohort = 12 )
318
- , PITJuly = (select case when cd .Cohort is null then 0 else 1 end
318
+ , PITJuly = (select distinct case when cd .Cohort is null then 0 else 1 end
319
319
from tlsa_CohortDates cd
320
320
where (cd .CohortStart < n .ExitDate or n .ExitDate is NULL )
321
321
and n .MoveInDate <= cd .CohortStart and cd .Cohort = 13 )
@@ -337,7 +337,7 @@ Populates and references:
337
337
else count (distinct hhid .HoHID + cast(hhid .ActiveHHType as varchar )) end
338
338
, rv .Cohort , rv .Universe , ph .HHType , rp .PopID , rv .SystemPath
339
339
, case when rv .Universe = 10 then hhid .ProjectID else null end
340
- , rv .RowID , (select ReportID from lsa_Report), ' 9.3.1'
340
+ , rv .RowID , (select distinct ReportID from lsa_Report), ' 9.3.1'
341
341
from ref_RowValues rv
342
342
inner join ref_RowPopulations rp on rv .RowID between rp .RowMin and rp .RowMax
343
343
inner join ref_PopHHTypes ph on ph .PopID = rp .PopID
@@ -375,7 +375,7 @@ Populates and references:
375
375
select distinct count (distinct n .PersonalID )
376
376
, rv .Cohort , rv .Universe , ph .HHType , rp .PopID , rv .SystemPath
377
377
, case when rv .Universe = 10 then hhid .ProjectID else null end
378
- , rv .RowID , (select ReportID from lsa_Report), ' 9.4.1'
378
+ , rv .RowID , (select distinct ReportID from lsa_Report), ' 9.4.1'
379
379
from ref_RowValues rv
380
380
inner join ref_RowPopulations rp on rv .RowID between rp .RowMin and rp .RowMax
381
381
inner join ref_PopHHTypes ph on ph .PopID = rp .PopID
@@ -423,10 +423,10 @@ Populates and references:
423
423
424
424
425
425
insert into lsa_Calculated (Value, Cohort, Universe, HHType, Population, SystemPath, ProjectID, ReportRow, ReportID, Step)
426
- select count (distinct n .PersonalID + cast(bn .DateProvided as varchar )), 1 , 10 , ph .HHType , pop .PopID , - 1
426
+ select distinct count (distinct n .PersonalID + cast(bn .DateProvided as varchar )), 1 , 10 , ph .HHType , pop .PopID , - 1
427
427
, hhid .ProjectID
428
428
, case when pop .PopID in (0 ,10 ,11 ) then 56 else 57 end
429
- , (select ReportID from lsa_Report), ' 9.5.1'
429
+ , (select distinct ReportID from lsa_Report), ' 9.5.1'
430
430
from hmis_Services bn
431
431
inner join tlsa_Enrollment n on n .EnrollmentID = bn .EnrollmentID
432
432
and (n .ExitDate is null or n .ExitDate > bn .DateProvided )
@@ -444,7 +444,7 @@ Populates and references:
444
444
insert into lsa_Calculated
445
445
(Value, Cohort, Universe, HHType
446
446
, Population, SystemPath, ReportRow, ProjectID, ReportID, Step)
447
- select count (distinct n .PersonalID + cast(cal .theDate as nvarchar))
447
+ select distinct count (distinct n .PersonalID + cast(cal .theDate as nvarchar))
448
448
, 1 , 10 , ph .HHType
449
449
, pop .PopID , - 1
450
450
, case when pop .PopID in (0 ,10 ,11 ) then 56 else 57 end
@@ -470,9 +470,9 @@ Populates and references:
470
470
471
471
-- All ES (Universe 11)
472
472
insert into lsa_Calculated (Value, Cohort, Universe, HHType, Population, SystemPath, ProjectID, ReportRow, ReportID, Step)
473
- select count (distinct es .bn ), 1 , 11 , es .HHType , es .PopID , - 1 , NULL
473
+ select distinct count (distinct es .bn ), 1 , 11 , es .HHType , es .PopID , - 1 , NULL
474
474
, case when es .PopID in (0 ,10 ,11 ) then 56 else 57 end
475
- , (select ReportID from lsa_Report), ' 9.5.3'
475
+ , (select distinct ReportID from lsa_Report), ' 9.5.3'
476
476
from
477
477
(select distinct n .PersonalID + cast(bn .DateProvided as varchar ) as bn, ph .HHType as HHType, pop .PopID
478
478
from hmis_Services bn
@@ -506,7 +506,7 @@ Populates and references:
506
506
insert into lsa_Calculated
507
507
(Value, Cohort, Universe, HHType
508
508
, Population, SystemPath, ReportRow, ReportID, Step)
509
- select count (distinct n .PersonalID + cast(cal .theDate as nvarchar))
509
+ select distinct count (distinct n .PersonalID + cast(cal .theDate as nvarchar))
510
510
, 1 , case n .LSAProjectType
511
511
when 8 then 12
512
512
when 2 then 13
@@ -538,9 +538,9 @@ Populates and references:
538
538
539
539
-- Unduplicated ES/SH/TH (Universe 16)
540
540
insert into lsa_Calculated (Value, Cohort, Universe, HHType, Population, SystemPath, ProjectID, ReportRow, ReportID, Step)
541
- select count (distinct est .bn ), 1 , 16 , est .HHType , est .PopID , - 1 , NULL
541
+ select distinct count (distinct est .bn ), 1 , 16 , est .HHType , est .PopID , - 1 , NULL
542
542
, case when est .PopID in (0 ,10 ,11 ) then 56 else 57 end
543
- , (select ReportID from lsa_Report), ' 9.5.5'
543
+ , (select distinct ReportID from lsa_Report), ' 9.5.5'
544
544
from
545
545
(select distinct n .PersonalID + cast(bn .DateProvided as varchar ) as bn, ph .HHType as HHType, pop .PopID
546
546
from hmis_Services bn
0 commit comments