-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathet.sql
More file actions
40 lines (40 loc) · 1.57 KB
/
et.sql
File metadata and controls
40 lines (40 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
select distinct
'nris_etl' as audit_created_by,
nc.record_id as file_number,
nc.date as date_submitted,
coalesce(nc.complaint_referral_processed_date, nc.date) as date_opened,
nc.type::alcs.compliance_and_enforcement_initial_submission_type_enum as initial_submission_type,
(
select
array_agg(
case
when activity = 'Residences' then 'Residence'
when activity = 'Breach of Conditions' then 'Breach of Condition'
when activity = 'Dwellings' then 'Residence'
when activity = 'Commercial Activity' then 'Non-Farm Use'
else activity
end
) as activity
from
(
select
regexp_replace(
initcap(
trim(
both '"'
from
activity
)
),
'\sOf\s',
' of '
) as activity
from
regexp_split_to_table(nc.activity, '\s*,\s*') as nc (activity)
) activities
)::alcs._compliance_and_enforcement_alleged_activity_enum as alleged_activity,
coalesce(concat_ws('; ', nc.internal_notes, nc.description_and_comments), '') as intake_notes,
au.uuid as assignee_uuid
from
nris.complaint nc
left join alcs.user au on lower(au.idir_user_name) = lower(nc.assigned_to);