Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Data Science
emergency-calls
Commits
a13a0f80
Commit
a13a0f80
authored
Nov 03, 2016
by
Craig Earley
Browse files
added views for call,city and complaint,type,cat,group
parent
aa18d48b
Changes
2
Hide whitespace changes
Inline
Side-by-side
911_populate.sql
View file @
a13a0f80
...
...
@@ -2,15 +2,10 @@
begin
;
--15-00016033,2015-02-27,7:48:59,BUSINESS CK,10000 BLOCK OF WILLIAMSON RD,WILLIAMSBURG,,
--15-00028812,2015-04-12,9:29:48,BUSINESS CK,10000 BLOCK OF WILLIAMSON RD,WILLIAMSBURG,,
--15-00037121,2015-05-10,9:16:52,BUSINESS CK,10000 BLOCK OF WILLIAMSON RD,WILLIAMSBURG,,
--15-00009972,2015-02-05,7:55:16,BUSINESS CK,10000 BLOCK OF WILLIAMSON RD,WILLIAMSBURG,,
--15-00069858,2015-09-05,21:13:44,TRAFFIC STOP,1000 BLK E MAIN ST,RICHMOND,39.829063,-84.889087
-- -- Populate them from the raw and uncleaned csv
\
copy
calls_csv
from
'/cluster/home/cjearley13/DataScience/emergency-calls/2015calls.csv'
with
delimiter
','
csv
header
;
\
copy
response_csv
from
'/cluster/home/datascience/911calls/raw/departmentsdispatched.csv'
with
delimiter
','
csv
;
--\copy response_csv from '/cluster/home/cjearley13/DataScience/emergency-calls/2016departmentsdispatched.csv' with delimiter ',' csv header;
-- set to initcap so as to make life easier
update
calls_csv
set
city
=
initcap
(
city
);
...
...
911_tables.sql
View file @
a13a0f80
...
...
@@ -47,4 +47,8 @@ update call_category set group_id = call_group.group_id from call_group where ca
-- -- create any useful views
create
view
responding_agencies
as
(
select
response
.
call_id
,
agency
.
agency_name
from
response
inner
join
agency
on
response
.
agency_id
=
agency
.
agency_id
);
create
view
type_cat_group
as
(
select
call_type
.
complaint_name
,
call_type
.
type_name
,
call_category
.
cat_name
,
call_group
.
group_name
from
call_type
inner
join
call_category
on
call_type
.
category_id
=
call_category
.
cat_id
inner
join
call_group
on
call_category
.
group_id
=
call_group
.
group_id
);
create
view
calls_cities
as
(
select
calls
.
call_id
,
place
.
city
from
calls
inner
join
place
on
calls
.
place_id
=
place
.
place_id
);
commit
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment