-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAirbnbChallenge
More file actions
44 lines (41 loc) · 922 Bytes
/
AirbnbChallenge
File metadata and controls
44 lines (41 loc) · 922 Bytes
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
SELECT
id,
name,
price,
neighbourhood,
room_type
FROM
sfo_listings
WHERE
price in (SELECT MAX(price )from sfo_listings)
*********************************************************
SELECT
COUNT(*),
neighbourhood
FROM
sfo_listings
GROUP BY sfo_listings.neighbourhood
ORDER BY 1 DESC
LIMIT 5 (TOP 5 NEIGHBOURHOOD based listing count)
*******************************************************
SELECT
EXTRACT(MONTH FROM sfo_calendar.calender_date) as month,
AVG(CAST(REPLACE(SUBSTR(sfo_calendar.price, 2), ',' ,'') as float)) as average_price
FROM
sfo_calendar
WHERE
price IS NOT NULL
GROUP BY
1;
*********************************************************
SELECT
COUNT(CASE WHEN available = 'f' then 1 END) as vacancy_count,
EXTRACT(MONTH FROM sfo_calendar.calender_date) as month
FROM
sfo_calendar
JOIN
sfo_listings
ON
sfo_listings.id = sfo_calendar.listing_id
GROUP BY 2
ORDER BY vacancy_count DESC;