-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtables_gen.sql
More file actions
63 lines (57 loc) · 1.38 KB
/
tables_gen.sql
File metadata and controls
63 lines (57 loc) · 1.38 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
-- CREATION OF DATABASE TABLES FOR AWS-RDS
-- Credit Card Aplications
CREATE TABLE credit_card_applications (
id_no INT NOT NULL,
code_gender VARCHAR(1) NOT NULL,
flag_own_car VARCHAR(1) NOT NULL,
flag_own_realty VARCHAR(1) NOT NULL,
cnt_children VARCHAR,
amt_income_total MONEY NOT NULL,
education_type VARCHAR,
family_status VARCHAR,
housing_type VARCHAR,
days_birth INT NOT NULL,
days_employed INT NOT NULL,
flag_mobil BOOLEAN,
flag_work_phone BOOLEAN,
flag_phone BOOLEAN,
flag_email BOOLEAN,
job VARCHAR,
begin_months INT NOT NULL,
status VARCHAR(1)
);
-- Credit Applications Results Table
CREATE TABLE credit_applications_results (
id_no INT NOT NULL,
begin_months INT NOT NULL,
target INT NOT NULL
);
-- DISPLAY EMPTY TABLES
SELECT * FROM credit_card_applications;
SELECT * FROM credit_applications_results;
-- JOIN ON ID WHERE TARGET = 1
SELECT cca.id_no,
cca.code_gender,
cca.flag_own_car,
cca.flag_own_realty,
cca.cnt_children,
cca.amt_income_total,
cca.education_type,
cca.family_status,
cca.housing_type,
cca.days_birth,
cca.days_employed,
cca.flag_mobil,
cca.flag_work_phone,
cca.flag_phone,
cca.flag_email,
cca.job,
cca.begin_months,
cca.status,
car.target
INTO credit_join
FROM credit_card_applications as cca
LEFT JOIN credit_applications_results as car
ON cca.id_no = car.id_no
AND cca.begin_months = car.begin_months;
SELECT * FROM credit_join;