-
Notifications
You must be signed in to change notification settings - Fork 0
/
candidate_views.sql
103 lines (103 loc) · 2.14 KB
/
candidate_views.sql
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
-- Candidate Views of MLS listings
DROP VIEW IF EXISTS ian_candidates;
CREATE OR REPLACE VIEW ian_candidates AS
SELECT
link,
price,
mls_insert_dt,
price_change_dt,
scrape_dt,
flood_risk,
downtown_walk_time,
downtown_walk_transit_time,
gf_work_car_time,
brother_car_time,
to_bc_car_time,
grocery_store_name,
m_to_grocery,
sq_feet_in,
listing_description
FROM mls_wide
WHERE
price BETWEEN 300000 AND 650000
AND bedrooms >= 3
AND gf_work_car_30 = TRUE
AND brother_car_40 = TRUE
AND bathrooms >= 2
AND (
parking LIKE '%Garage%'
OR parking LIKE '%Underground%'
)
AND listing_type NOT IN ('Mobile Home', 'Apartment')
AND downtown_walk_transit_40
ORDER BY GREATEST(mls_insert_dt, price_change_dt) DESC
;
DROP VIEW IF EXISTS parents_candidates;
CREATE OR REPLACE VIEW parents_candidates AS
SELECT
link,
price,
mls_insert_dt,
price_change_dt,
scrape_dt,
flood_risk,
brother_car_time,
downtown_car_time,
gf_work_car_time,
grocery_store_name,
m_to_grocery,
listing_description
FROM mls_wide
WHERE
price BETWEEN 300000 AND 550000
AND sq_feet_in >= 1000
AND bathrooms >= 2
AND bedrooms_above >= 2
AND bedrooms <= 3
AND (
parking LIKE '%Garage%'
OR parking LIKE '%Underground%'
)
AND brother_car_20 = TRUE
AND (
(listing_type != 'Apartment' AND stories < 3)
OR (listing_type = 'Apartment')
)
ORDER BY GREATEST(mls_insert_dt, price_change_dt) DESC
;
DROP VIEW IF EXISTS jill_candidates;
CREATE OR REPLACE VIEW jill_candidates AS
SELECT
mls_number,
link,
price,
mls_insert_dt,
price_change_dt,
scrape_dt,
flood_risk,
listing_description,
downtown_walk_time,
downtown_walk_transit_time,
downtown_car_time,
to_bc_car_time,
momma_jill_car_time
grocery_store_name,
m_to_grocery
FROM mls_wide
WHERE
price BETWEEN 900000 AND 1500000
AND bedrooms_above >= 3
AND bathrooms > 3
AND parking_spaces >= 2
AND (
(downtown_car_25 = TRUE)
OR (downtown_walk_30 = TRUE)
)
AND (
(listing_type = 'House')
OR (listing_type is NULL)
)
AND momma_jill_car_10 = False
AND sq_feet_in >= 2000
ORDER BY GREATEST(mls_insert_dt, price_change_dt) DESC
;