-
Notifications
You must be signed in to change notification settings - Fork 2
/
data.jsonl
121 lines (121 loc) · 900 KB
/
data.jsonl
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: what was the most expensive zip code to rent in Los Angeles county in May 2022? [/INST] To answer the user's question, I'll be working with the following tables: renthub_median_rent. From these tables, I'll be using the following columns: location_name, metric_value, dh_county_name, dh_state_name, property_type, period_start, geo_type.\n\nHere is the SQL query:\n\n```sql\nSELECT location_name, metric_value FROM renthub_median_rent WHERE dh_county_name = 'Los Angeles' AND dh_state_name = 'California' AND property_type = 'All Residential' AND period_start='2022-05-01' AND geo_type='zip' ORDER BY metric_value DESC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: what was the median home sale price in Califronia in Q1 2021? [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_sale_price. From these tables, I'll be using the following columns: location_name, period_end, metric_value, geo_type, property_type, period_start.\n\nHere is the SQL query:\n\n```sql\nSELECT location_name, period_end, metric_value FROM redfin_median_sale_price rmsp WHERE geo_type = 'state' AND location_name='California' AND property_type = 'All Residential' AND period_start BETWEEN '2021-01-01' AND '2021-03-31' ORDER BY period_end;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: How many townhomes have been sold in Austin, TX so far in 2023? [/INST] To answer the user's question, I'll be working with the following tables: redfin_homes_sold. From these tables, I'll be using the following columns: dh_state_name, location_name, metric_value, geo_type, property_type, period_start.\n\nHere is the SQL query:\n\n```sql\nSELECT dh_state_name, location_name, sum(metric_value) as townhomes_sold FROM redfin_homes_sold rhs WHERE geo_type='city' AND dh_state_name = 'Texas' AND location_name ='Austin' AND property_type='Townhouse' AND period_start >= '2023-01-1' GROUP BY location_name, dh_state_name;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: Did property prices increase or descrease in the US in 2020? [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_list_price. From these tables, I'll be using the following columns: period_start, metric_value, geo_type, property_type, is_seasonally_adjusted.\n\nHere is the SQL query:\n\n```sql\nSELECT period_start, metric_value FROM redfin_median_list_price rmlp WHERE geo_type ='national' AND property_type = 'All Residential' AND is_seasonally_adjusted = False AND period_start BETWEEN '2020-1-1' AND '2020-12-31' ORDER BY period_start;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: compare home prices in los angeles vs austin since 2022 [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_sale_price. From these tables, I'll be using the following columns: period_end, location_name, dh_state_name, metric_value, geo_type, property_type.\n\nHere is the SQL query:\n\n```sql\nSELECT period_end, location_name, dh_state_name, metric_value FROM redfin_median_sale_price WHERE geo_type='city' AND property_type = 'All Residential' AND period_end >= '2022-01-01' AND ((location_name='Los Angeles' AND dh_state_name='California') OR (location_name = 'Austin' AND dh_state_name='Texas')) ORDER BY period_end, dh_state_name, location_name;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: average home price 90405 [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_list_price. From these tables, I'll be using the following columns: period_start, period_end, metric_value, geo_type, location_name, dh_state_name, property_type.\n\nHere is the SQL query:\n\n```sql\nSELECT period_start, period_end, metric_value FROM redfin_median_list_price rmlp WHERE geo_type='zip' AND location_name = '90405' AND dh_state_name = 'California' AND property_type = 'All Residential' ORDER BY period_start DESC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: how many homes were sold in orange county in 2022 broken down by property type [/INST] To answer the user's question, I'll be working with the following tables: redfin_homes_sold. From these tables, I'll be using the following columns: property_type, metric_value, geo_type, location_name, dh_state_name, period_end.\n\nHere is the SQL query:\n\n```sql\nSELECT property_type, SUM(metric_value) FROM redfin_homes_sold rhs WHERE geo_type='county' AND location_name='Orange' AND dh_state_name='California' AND property_type <> 'All Residential' AND period_end BETWEEN '2022-01-01' AND '2022-12-31' GROUP BY property_type;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: rents in santa monica 2021 till jan 2023 [/INST] To answer the user's question, I'll be working with the following tables: renthub_median_rent. From these tables, I'll be using the following columns: period_start, period_end, metric_value, geo_type, location_name, dh_state_name, property_type.\n\nHere is the SQL query:\n\n```sql\nSELECT period_start, period_end, metric_value FROM renthub_median_rent WHERE geo_type = 'city' AND location_name = 'Santa Monica' AND dh_state_name = 'California' AND property_type = 'All Residential' AND period_start BETWEEN '2021-01-01' AND '2023-01-31' ORDER BY period_start;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: What is the median rent price for each property type in Los angeles city? [/INST] To answer the user's question, I'll be working with the following tables: renthub_median_rent. From these tables, I'll be using the following columns: property_type, metric_value, geo_type, dh_state_name, dh_place_name, period_start.\n\nHere is the SQL query:\n\n```sql\nSELECT property_type, metric_value FROM renthub_median_rent WHERE geo_type='city' AND dh_state_name = 'California' AND dh_place_name = 'Los Angeles' AND period_start = (SELECT max(period_start) FROM renthub_median_rent WHERE geo_type='city' AND dh_state_name = 'California' AND dh_place_name = 'Los Angeles') ORDER BY property_type ASC;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: What is the median sale price for each property type in California state? [/INST] To answer the user's question, I'll be working with the following tables: renthub_median_rent. From these tables, I'll be using the following columns: property_type, metric_value, geo_type, dh_state_name, period_start.\n\nHere is the SQL query:\n\n```sql\nSELECT property_type, metric_value FROM renthub_median_rent WHERE geo_type='state' AND dh_state_name = 'California' AND period_start = (SELECT max(period_start) FROM renthub_median_rent WHERE geo_type='state' AND dh_state_name = 'California') ORDER BY property_type ASC;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: What is the total number of listings for each property type in New York city? [/INST] To answer the user's question, I'll be working with the following tables: redfin_inventory. From these tables, I'll be using the following columns: property_type, metric_value, geo_type, dh_state_name, dh_place_name, period_start.\n\nHere is the SQL query:\n\n```sql\nSELECT property_type, metric_value FROM redfin_inventory WHERE geo_type='city' AND dh_state_name='New York' AND dh_place_name='New York' AND property_type <> 'All Residential' AND period_start = (SELECT max(period_start) FROM redfin_inventory WHERE geo_type='city' AND dh_state_name='New York' AND dh_place_name='New York' AND property_type <> 'All Residential') ORDER BY metric_value DESC;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: How many new listings are there for each property type in Orange county? [/INST] To answer the user's question, I'll be working with the following tables: redfin_inventory. From these tables, I'll be using the following columns: property_type, metric_value, geo_type, dh_state_name, dh_county_name, period_start.\n\nHere is the SQL query:\n\n```sql\nSELECT property_type, metric_value FROM redfin_inventory WHERE geo_type='county' AND dh_state_name='California' AND dh_county_name='Orange' AND property_type <> 'All Residential' AND period_start = (SELECT max(period_start) FROM redfin_inventory WHERE geo_type='county' AND dh_state_name='California' AND dh_county_name='Orange' AND property_type <> 'All Residential') ORDER BY metric_value DESC;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: Which city has the highest median sale price overall in Orange County, California? [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_sale_price. From these tables, I'll be using the following columns: period_end, location_name, metric_value, geo_type, dh_county_name, dh_state_name, property_type.\n\nHere is the SQL query:\n\n```sql\nSELECT period_end, location_name, metric_value FROM redfin_median_sale_price WHERE geo_type='city' AND dh_county_name= 'Orange' AND dh_state_name='California' AND property_type = 'All Residential' ORDER BY period_end DESC, metric_value DESC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: Which county has the highest median rent price overall in Florida? [/INST] To answer the user's question, I'll be working with the following tables: renthub_median_rent. From these tables, I'll be using the following columns: period_end, location_name, metric_value, geo_type, dh_state_name, property_type.\n\nHere is the SQL query:\n\n```sql\nSELECT period_end, location_name, metric_value FROM renthub_median_rent WHERE geo_type='county' AND dh_state_name='Florida' AND property_type = 'All Residential' ORDER BY period_end DESC, metric_value DESC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: Which ZIP Code has the largest inventory overall in Chicago? [/INST] To answer the user's question, I'll be working with the following tables: redfin_inventory. From these tables, I'll be using the following columns: period_end, location_name, metric_value, geo_type, dh_state_name, dh_place_name, property_type.\n\nHere is the SQL query:\n\n```sql\nSELECT period_end, location_name, metric_value FROM redfin_inventory WHERE geo_type='zip' AND dh_state_name='Illinois' AND dh_place_name = 'Chicago' AND property_type = 'All Residential' ORDER BY period_end DESC, metric_value DESC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: Which State has the largest number of inventory overall? [/INST] To answer the user's question, I'll be working with the following tables: redfin_inventory. From these tables, I'll be using the following columns: period_end, location_name, metric_value, geo_type, property_type.\n\nHere is the SQL query:\n\n```sql\nSELECT period_end, location_name, metric_value FROM redfin_inventory WHERE geo_type='state' AND property_type = 'All Residential' ORDER BY period_end DESC, metric_value DESC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: Which county has the lowest median sale price in Florida? [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_sale_price. From these tables, I'll be using the following columns: period_end, location_name, metric_value, geo_type, dh_state_name, property_type.\n\nHere is the SQL query:\n\n```sql\nSELECT period_end, location_name, metric_value FROM redfin_median_sale_price WHERE geo_type='county' AND dh_state_name = 'Florida' AND property_type = 'All Residential' ORDER BY period_end DESC, metric_value ASC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: Which city has the lowest median rent price in Orange county? [/INST] To answer the user's question, I'll be working with the following tables: renthub_median_rent. From these tables, I'll be using the following columns: period_end, location_name, metric_value, geo_type, dh_state_name, dh_county_name, property_type.\n\nHere is the SQL query:\n\n```sql\nSELECT period_end, location_name, metric_value FROM renthub_median_rent WHERE geo_type='city' AND dh_state_name = 'California' AND dh_county_name = 'Orange' AND property_type = 'All Residential' ORDER BY period_end DESC, metric_value ASC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: Which state has the lowest inventory overall? [/INST] To answer the user's question, I'll be working with the following tables: redfin_inventory. From these tables, I'll be using the following columns: period_end, location_name, metric_value, geo_type, property_type.\n\nHere is the SQL query:\n\n```sql\nSELECT period_end, location_name, metric_value FROM redfin_inventory WHERE geo_type='state' AND property_type = 'All Residential' ORDER BY period_end DESC, metric_value ASC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: Which city has the lowest number of new listings overall in Ohio? [/INST] To answer the user's question, I'll be working with the following tables: redfin_new_listings. From these tables, I'll be using the following columns: period_end, location_name, metric_value, geo_type, dh_state_name, property_type.\n\nHere is the SQL query:\n\n```sql\nSELECT period_end, location_name, metric_value FROM redfin_new_listings WHERE geo_type='city' AND dh_state_name = 'Ohio' AND property_type = 'All Residential' ORDER BY period_end DESC, metric_value ASC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: which is the city with the highest increase in the median rent price in Texas from July 2022 to July 2023? [/INST] To answer the user's question, I'll be working with the following tables: renthub_median_rent. From these tables, I'll be using the following columns: location_name, metric_value, period_start, geo_type, property_type, dh_state_name, cd.location_name, cd.median_price, ld.median_price, ld.location_name, cd.period_start, ld.period_start.\n\nHere is the SQL query:\n\n```sql\nWITH DATA AS (SELECT location_name, metric_value AS median_price, period_start FROM renthub_median_rent WHERE geo_type = 'city' AND property_type = 'All Residential' AND dh_state_name = 'Texas' AND (period_start = '2023-07-01' OR period_start = '2022-07-01')) SELECT cd.location_name, cd.median_price AS new_median_price, ld.median_price AS old_median_price, ((cd.median_price - ld.median_price) * 100 / ld.median_price) AS pct_change FROM DATA cd JOIN DATA ld ON cd.location_name = ld.location_name WHERE cd.period_start = '2023-07-01' AND ld.period_start = '2022-07-01' ORDER BY pct_change DESC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: which is the city with the highest increase in the median sale price in North Carolina from March 2022 to March 2023? [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_sale_price. From these tables, I'll be using the following columns: location_name, metric_value, period_start, geo_type, property_type, dh_state_name, cd.location_name, cd.median_price, ld.median_price, ld.location_name, cd.period_start, ld.period_start.\n\nHere is the SQL query:\n\n```sql\nWITH DATA AS (SELECT location_name, metric_value AS median_price, period_start FROM redfin_median_sale_price WHERE geo_type = 'city' AND property_type = 'All Residential' AND dh_state_name = 'North Carolina' AND (period_start = '2023-03-01' OR period_start = '2022-03-01')) SELECT cd.location_name, cd.median_price AS new_median_price, ld.median_price AS old_median_price, ((cd.median_price - ld.median_price) * 100 / ld.median_price) AS pct_change FROM DATA cd JOIN DATA ld ON cd.location_name = ld.location_name WHERE cd.period_start = '2023-03-01' AND ld.period_start = '2022-03-01' ORDER BY pct_change DESC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: which is the city with the highest increase in the inventory of Real Estate in Illinois from March 2022 to March 2023? [/INST] To answer the user's question, I'll be working with the following tables: redfin_inventory. From these tables, I'll be using the following columns: location_name, metric_value, period_start, geo_type, property_type, dh_state_name, cd.location_name, cd.inventory, ld.inventory, ld.location_name, cd.period_start, ld.period_start.\n\nHere is the SQL query:\n\n```sql\nWITH DATA AS (SELECT location_name, metric_value AS inventory, period_start FROM redfin_inventory WHERE geo_type = 'city' AND property_type = 'All Residential' AND dh_state_name = 'Illinois' AND (period_start = '2023-03-01' OR period_start = '2022-03-01')) SELECT cd.location_name, cd.inventory AS new_inventory, ld.inventory AS old_inventory, ((cd.inventory - ld.inventory) * 100 / ld.inventory) AS pct_change FROM DATA cd JOIN DATA ld ON cd.location_name = ld.location_name WHERE cd.period_start = '2023-03-01' AND ld.period_start = '2022-03-01' ORDER BY pct_change DESC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: which is the city with the highest increase in the number of new listings of Real Estate in Texas from March 2022 to March 2023? [/INST] To answer the user's question, I'll be working with the following tables: redfin_new_listings. From these tables, I'll be using the following columns: location_name, metric_value, period_start, geo_type, property_type, dh_state_name, cd.location_name, cd.new_listings, ld.new_listings, ld.location_name, cd.period_start, ld.period_start.\n\nHere is the SQL query:\n\n```sql\nWITH DATA AS (SELECT location_name, metric_value AS new_listings, period_start FROM redfin_new_listings WHERE geo_type = 'city' AND property_type = 'All Residential' AND dh_state_name = 'Texas' AND (period_start = '2023-03-01' OR period_start = '2022-03-01')) SELECT cd.location_name, cd.new_listings AS new_new_listings, ld.new_listings AS old_new_listings, ((cd.new_listings - ld.new_listings) * 100 / ld.new_listings) AS pct_change FROM DATA cd JOIN DATA ld ON cd.location_name = ld.location_name WHERE cd.period_start = '2023-03-01' AND ld.period_start = '2022-03-01' ORDER BY pct_change DESC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: which is the city with the highest decrease in the median rent price in Texas from July 2022 to July 2023? [/INST] To answer the user's question, I'll be working with the following tables: renthub_median_rent. From these tables, I'll be using the following columns: location_name, metric_value, period_start, geo_type, property_type, dh_state_name, cd.location_name, cd.median_price, ld.median_price, ld.location_name, cd.period_start, ld.period_start.\n\nHere is the SQL query:\n\n```sql\nWITH DATA AS (SELECT location_name, metric_value AS median_price, period_start FROM renthub_median_rent WHERE geo_type = 'city' AND property_type = 'All Residential' AND dh_state_name = 'Texas' AND (period_start = '2023-07-01' OR period_start = '2022-07-01')) SELECT cd.location_name, cd.median_price AS new_median_price, ld.median_price AS old_median_price, ((cd.median_price - ld.median_price) * 100 / ld.median_price) AS pct_change FROM DATA cd JOIN DATA ld ON cd.location_name = ld.location_name WHERE cd.period_start = '2023-07-01' AND ld.period_start = '2022-07-01' ORDER BY pct_change ASC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: which is the city with the highest decrease in the median sale price in Texas from March 2022 to March 2023? [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_sale_price. From these tables, I'll be using the following columns: location_name, metric_value, period_start, geo_type, property_type, dh_state_name, cd.location_name, cd.median_price, ld.median_price, ld.location_name, cd.period_start, ld.period_start.\n\nHere is the SQL query:\n\n```sql\nWITH DATA AS (SELECT location_name, metric_value AS median_price, period_start FROM redfin_median_sale_price WHERE geo_type = 'city' AND property_type = 'All Residential' AND dh_state_name = 'Texas' AND (period_start = '2023-03-01' OR period_start = '2022-03-01')) SELECT cd.location_name, cd.median_price AS new_median_price, ld.median_price AS old_median_price, ((cd.median_price - ld.median_price) * 100 / ld.median_price) AS pct_change FROM DATA cd JOIN DATA ld ON cd.location_name = ld.location_name WHERE cd.period_start = '2023-03-01' AND ld.period_start = '2022-03-01' ORDER BY pct_change ASC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: which is the city with the highest decrease in the inventory of Real Estate in North Carolina from March 2022 to March 2023? [/INST] To answer the user's question, I'll be working with the following tables: redfin_inventory. From these tables, I'll be using the following columns: location_name, metric_value, period_start, geo_type, property_type, dh_state_name, cd.location_name, cd.inventory, ld.inventory, ld.location_name, cd.period_start, ld.period_start.\n\nHere is the SQL query:\n\n```sql\nWITH DATA AS (SELECT location_name, metric_value AS inventory, period_start FROM redfin_inventory WHERE geo_type = 'city' AND property_type = 'All Residential' AND dh_state_name = 'North Carolina' AND (period_start = '2023-03-01' OR period_start = '2022-03-01')) SELECT cd.location_name, cd.inventory AS new_inventory, ld.inventory AS old_inventory, ((cd.inventory - ld.inventory) * 100 / ld.inventory) AS pct_change FROM DATA cd JOIN DATA ld ON cd.location_name = ld.location_name WHERE cd.period_start = '2023-03-01' AND ld.period_start = '2022-03-01' ORDER BY pct_change ASC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: which is the city with the highest decrease in the number of new listings of Real Estate in Ohio from March 2022 to March 2023? [/INST] To answer the user's question, I'll be working with the following tables: redfin_new_listings. From these tables, I'll be using the following columns: location_name, metric_value, period_start, geo_type, property_type, dh_state_name, cd.location_name, cd.new_listings, ld.new_listings, ld.location_name, cd.period_start, ld.period_start.\n\nHere is the SQL query:\n\n```sql\nWITH DATA AS (SELECT location_name, metric_value AS new_listings, period_start FROM redfin_new_listings WHERE geo_type = 'city' AND property_type = 'All Residential' AND dh_state_name = 'Ohio' AND (period_start = '2023-03-01' OR period_start = '2022-03-01')) SELECT cd.location_name, cd.new_listings AS new_new_listings, ld.new_listings AS old_new_listings, ((cd.new_listings - ld.new_listings) * 100 / ld.new_listings) AS pct_change FROM DATA cd JOIN DATA ld ON cd.location_name = ld.location_name WHERE cd.period_start = '2023-03-01' AND ld.period_start = '2022-03-01' ORDER BY pct_change ASC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: How much did median rent price change from July 2022 to July 2023 in Miami city? [/INST] To answer the user's question, I'll be working with the following tables: renthub_median_rent. From these tables, I'll be using the following columns: location_name, metric_value, period_start, geo_type, property_type, dh_state_name, dh_place_name, cd.location_name, cd.median_price, ld.median_price, ld.location_name, cd.period_start, ld.period_start.\n\nHere is the SQL query:\n\n```sql\nWITH DATA AS (SELECT location_name, metric_value AS median_price, period_start FROM renthub_median_rent WHERE geo_type = 'city' AND property_type = 'All Residential' AND dh_state_name = 'Florida' AND dh_place_name = 'Miami' AND (period_start = '2023-07-01' OR period_start = '2022-07-01')) SELECT cd.location_name, cd.median_price AS new_median_price, ld.median_price AS old_median_price, ((cd.median_price - ld.median_price) * 100 / ld.median_price) AS pct_change FROM DATA cd JOIN DATA ld ON cd.location_name = ld.location_name WHERE cd.period_start = '2023-07-01' AND ld.period_start = '2022-07-01';\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: How much did median sale price change from March 2022 to March 2023 in Dade county? [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_sale_price. From these tables, I'll be using the following columns: location_name, metric_value, period_start, geo_type, property_type, dh_state_name, dh_county_name, cd.location_name, cd.median_price, ld.median_price, ld.location_name, cd.period_start, ld.period_start.\n\nHere is the SQL query:\n\n```sql\nWITH DATA AS (SELECT location_name, metric_value AS median_price, period_start FROM redfin_median_sale_price WHERE geo_type = 'county' AND property_type = 'All Residential' AND dh_state_name = 'Florida' AND dh_county_name = 'Miami-Dade' AND (period_start = '2023-03-01' OR period_start = '2022-03-01')) SELECT cd.location_name, cd.median_price AS new_median_price, ld.median_price AS old_median_price, ((cd.median_price - ld.median_price) * 100 / ld.median_price) AS pct_change FROM DATA cd JOIN DATA ld ON cd.location_name = ld.location_name WHERE cd.period_start = '2023-03-01' AND ld.period_start = '2022-03-01';\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: How much did real estate inventory change from March 2022 to March 2023 in Los Angeles county? [/INST] To answer the user's question, I'll be working with the following tables: redfin_inventory. From these tables, I'll be using the following columns: location_name, metric_value, period_start, geo_type, property_type, dh_state_name, dh_county_name, cd.location_name, cd.inventory, ld.inventory, ld.location_name, cd.period_start, ld.period_start.\n\nHere is the SQL query:\n\n```sql\nWITH DATA AS (SELECT location_name, metric_value AS inventory, period_start FROM redfin_inventory WHERE geo_type = 'county' AND property_type = 'All Residential' AND dh_state_name = 'California' AND dh_county_name = 'Los Angeles' AND (period_start = '2023-03-01' OR period_start = '2022-03-01')) SELECT cd.location_name, cd.inventory AS new_inventory, ld.inventory AS old_inventory, ((cd.inventory - ld.inventory) * 100 / ld.inventory) AS pct_change FROM DATA cd JOIN DATA ld ON cd.location_name = ld.location_name WHERE cd.period_start = '2023-03-01' AND ld.period_start = '2022-03-01';\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: How much did real estate new listings number change from March 2022 to March 2023 in Queens county? [/INST] To answer the user's question, I'll be working with the following tables: redfin_new_listings. From these tables, I'll be using the following columns: location_name, metric_value, period_start, geo_type, property_type, dh_state_name, dh_county_name, cd.location_name, cd.new_listings, ld.new_listings, ld.location_name, cd.period_start, ld.period_start.\n\nHere is the SQL query:\n\n```sql\nWITH DATA AS (SELECT location_name, metric_value AS new_listings, period_start FROM redfin_new_listings WHERE geo_type = 'county' AND property_type = 'All Residential' AND dh_state_name = 'New York' AND dh_county_name = 'Queens' AND (period_start = '2023-03-01' OR period_start = '2022-03-01')) SELECT cd.location_name, cd.new_listings AS new_new_listings, ld.new_listings AS old_new_listings, ((cd.new_listings - ld.new_listings) * 100 / ld.new_listings) AS pct_change FROM DATA cd JOIN DATA ld ON cd.location_name = ld.location_name WHERE cd.period_start = '2023-03-01' AND ld.period_start = '2022-03-01';\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: Which property type had the highest median sale price in Miami city? [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_sale_price. From these tables, I'll be using the following columns: period_end, property_type, metric_value, geo_type, dh_state_name, dh_place_name.\n\nHere is the SQL query:\n\n```sql\nSELECT period_end, property_type, metric_value FROM redfin_median_sale_price WHERE geo_type = 'city' AND dh_state_name = 'Florida' AND dh_place_name = 'Miami' AND property_type <> 'All Residential' ORDER BY period_end DESC, metric_value DESC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: Which property type had the highest median rent price in Dade county? [/INST] To answer the user's question, I'll be working with the following tables: renthub_median_rent. From these tables, I'll be using the following columns: period_end, property_type, metric_value, geo_type, dh_state_name, dh_county_name.\n\nHere is the SQL query:\n\n```sql\nSELECT period_end, property_type, metric_value FROM renthub_median_rent WHERE geo_type = 'county' AND dh_state_name = 'Florida' AND dh_county_name = 'Miami-Dade' AND property_type <> 'All Residential' ORDER BY period_end DESC, metric_value DESC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: Which property type had the highest inventory of real estate in Los Angeles county? [/INST] To answer the user's question, I'll be working with the following tables: redfin_inventory. From these tables, I'll be using the following columns: period_end, property_type, metric_value, geo_type, dh_state_name, dh_county_name.\n\nHere is the SQL query:\n\n```sql\nSELECT period_end, property_type, metric_value FROM redfin_inventory WHERE geo_type = 'county' AND dh_state_name = 'California' AND dh_county_name = 'Los Angeles' AND property_type <> 'All Residential' ORDER BY period_end DESC, metric_value DESC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: Which property type had the highest new listings number in Queens county? [/INST] To answer the user's question, I'll be working with the following tables: redfin_new_listings. From these tables, I'll be using the following columns: period_end, property_type, metric_value, geo_type, dh_state_name, dh_county_name.\n\nHere is the SQL query:\n\n```sql\nSELECT period_end, property_type, metric_value FROM redfin_new_listings WHERE geo_type = 'county' AND dh_state_name = 'New York' AND dh_county_name = 'Queens' AND property_type <> 'All Residential' ORDER BY period_end DESC, metric_value DESC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: How does the median sale price compare across Dade county and Los Angeles county? [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_sale_price. From these tables, I'll be using the following columns: period_end, location_name, metric_value, geo_type, property_type, dh_state_name, dh_county_name, dade.period_end, dade.median_price, la.median_price, la.period_end.\n\nHere is the SQL query:\n\n```sql\nWITH Dade_county_data AS ( SELECT period_end, location_name, metric_value AS median_price FROM redfin_median_sale_price WHERE geo_type = 'county' AND property_type = 'All Residential' AND dh_state_name = 'Florida' AND dh_county_name = 'Miami-Dade' ORDER BY period_end DESC), Los_Angeles_county_data AS ( SELECT period_end, location_name, metric_value AS median_price FROM redfin_median_sale_price WHERE geo_type = 'county' AND property_type = 'All Residential' AND dh_state_name = 'California' AND dh_county_name = 'Los Angeles' ORDER BY period_end DESC) SELECT dade.period_end, dade.median_price AS dade_median_price, la.median_price AS la_median_price, (dade.median_price - la.median_price) * 100 / la.median_price AS pct_diff FROM Dade_county_data dade JOIN Los_Angeles_county_data la ON dade.period_end = la.period_end ORDER BY dade.period_end DESC LIMIT 5;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: How does the median rent price compare across Los Angeles county and Queens county? [/INST] To answer the user's question, I'll be working with the following tables: renthub_median_rent. From these tables, I'll be using the following columns: period_end, location_name, metric_value, geo_type, property_type, dh_state_name, dh_county_name, la.period_end, la.median_price, queens.median_price, queens.period_end.\n\nHere is the SQL query:\n\n```sql\nWITH Los_Angeles_county_data AS (SELECT period_end, location_name, metric_value AS median_price FROM renthub_median_rent WHERE geo_type = 'county' AND property_type = 'All Residential' AND dh_state_name = 'New York' AND dh_county_name = 'Queens' ORDER BY period_end DESC), Queens_county_data AS (SELECT period_end, location_name, metric_value AS median_price FROM renthub_median_rent WHERE geo_type = 'county' AND property_type = 'All Residential' AND dh_state_name = 'California' AND dh_county_name = 'Los Angeles' ORDER BY period_end DESC) SELECT la.period_end, la.median_price AS la_median_price, queens.median_price AS queens_median_price, (la.median_price - queens.median_price) * 100 / queens.median_price AS pct_diff FROM Los_Angeles_county_data la JOIN Queens_county_data queens ON la.period_end = queens.period_end ORDER BY la.period_end DESC LIMIT 5;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: How does the inventory of real estate compare across Miami city and Orlando? [/INST] To answer the user's question, I'll be working with the following tables: redfin_inventory. From these tables, I'll be using the following columns: period_end, location_name, metric_value, geo_type, property_type, dh_state_name, dh_place_name, miami.period_end, miami.inventory, orlando.inventory, orlando.period_end.\n\nHere is the SQL query:\n\n```sql\nWITH Miami_city_data AS (SELECT period_end, location_name, metric_value AS inventory FROM redfin_inventory WHERE geo_type = 'city' AND property_type = 'All Residential' AND dh_state_name = 'Florida' AND dh_place_name = 'Miami' ORDER BY period_end DESC), Orlando_city_data AS (SELECT period_end, location_name, metric_value AS inventory FROM redfin_inventory WHERE geo_type = 'city' AND property_type = 'All Residential' AND dh_state_name = 'Florida' AND dh_place_name = 'Orlando' ORDER BY period_end DESC) SELECT miami.period_end, miami.inventory AS miami_inventory, orlando.inventory AS orlando_inventory, (miami.inventory - orlando.inventory) * 100 / orlando.inventory AS pct_diff FROM Miami_city_data miami JOIN Orlando_city_data orlando ON miami.period_end = orlando.period_end ORDER BY miami.period_end DESC LIMIT 5;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: How does the new listings in real estate compare across Chicago and San Francisco? [/INST] To answer the user's question, I'll be working with the following tables: redfin_new_listings. From these tables, I'll be using the following columns: period_end, location_name, metric_value, geo_type, property_type, dh_state_name, dh_place_name, chicago.period_end, chicago.new_listings, sf.new_listings, sf.period_end.\n\nHere is the SQL query:\n\n```sql\nWITH Chicago_city_data AS (SELECT period_end, location_name, metric_value AS new_listings FROM redfin_new_listings WHERE geo_type = 'city' AND property_type = 'All Residential' AND dh_state_name = 'Illinois' AND dh_place_name = 'Chicago' ORDER BY period_end DESC), San_Francisco_city_data AS (SELECT period_end, location_name, metric_value AS new_listings FROM redfin_new_listings WHERE geo_type = 'city' AND property_type = 'All Residential' AND dh_state_name = 'California' AND dh_place_name = 'San Francisco' ORDER BY period_end DESC) SELECT chicago.period_end, chicago.new_listings AS chicago_new_listings, sf.new_listings AS sf_new_listings, (chicago.new_listings - sf.new_listings) * 100 / sf.new_listings AS pct_diff FROM Chicago_city_data chicago JOIN San_Francisco_city_data sf ON chicago.period_end = sf.period_end ORDER BY chicago.period_end DESC LIMIT 5;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: What's the percent change in median sale price for Angeles county from Feb 2023 to March 2023? [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_sale_price. From these tables, I'll be using the following columns: location_name, metric_value, period_start, geo_type, property_type, dh_state_name, dh_place_name, cd.location_name, cd.median_price, ld.median_price, ld.location_name, cd.period_start, ld.period_start.\n\nHere is the SQL query:\n\n```sql\nWITH DATA AS (SELECT location_name, metric_value AS median_price, period_start FROM redfin_median_sale_price WHERE geo_type = 'city' AND property_type = 'All Residential' AND dh_state_name = 'California' AND dh_place_name = 'Los Angeles' AND (period_start = '2023-03-01' OR period_start = '2023-02-01')) SELECT cd.location_name, cd.median_price AS new_median_price, ld.median_price AS old_median_price, ((cd.median_price - ld.median_price) * 100 / ld.median_price) AS pct_change FROM DATA cd JOIN DATA ld ON cd.location_name = ld.location_name WHERE cd.period_start = '2023-03-01' AND ld.period_start = '2023-02-01';\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: What's the percent change in median rent price for Queens county from June 2023 to July 2023? [/INST] To answer the user's question, I'll be working with the following tables: renthub_median_rent. From these tables, I'll be using the following columns: location_name, metric_value, period_start, geo_type, property_type, dh_state_name, dh_county_name, cd.location_name, cd.median_price, ld.median_price, ld.location_name, cd.period_start, ld.period_start.\n\nHere is the SQL query:\n\n```sql\nWITH DATA AS (SELECT location_name, metric_value AS median_price, period_start FROM renthub_median_rent WHERE geo_type = 'county' AND property_type = 'All Residential' AND dh_state_name = 'New York' AND dh_county_name = 'Queens' AND (period_start = '2023-07-01' OR period_start = '2023-06-01')) SELECT cd.location_name, cd.median_price AS new_median_price, ld.median_price AS old_median_price, ((cd.median_price - ld.median_price) * 100 / ld.median_price) AS pct_change FROM DATA cd JOIN DATA ld ON cd.location_name = ld.location_name WHERE cd.period_start = '2023-07-01' AND ld.period_start = '2023-06-01';\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: What's the percent change in inventory of real estatea for Orlando from Feb 2023 to March 2023? [/INST] To answer the user's question, I'll be working with the following tables: redfin_inventory. From these tables, I'll be using the following columns: location_name, metric_value, period_start, geo_type, property_type, dh_state_name, dh_place_name, cd.location_name, cd.inventory, ld.inventory, ld.location_name, cd.period_start, ld.period_start.\n\nHere is the SQL query:\n\n```sql\nWITH DATA AS (SELECT location_name, metric_value AS inventory, period_start FROM redfin_inventory WHERE geo_type = 'city' AND property_type = 'All Residential' AND dh_state_name = 'Florida' AND dh_place_name = 'Orlando' AND (period_start = '2023-03-01' OR period_start = '2023-02-01')) SELECT cd.location_name, cd.inventory AS new_inventory, ld.inventory AS old_inventory, ((cd.inventory - ld.inventory) * 100 / ld.inventory) AS pct_change FROM DATA cd JOIN DATA ld ON cd.location_name = ld.location_name WHERE cd.period_start = '2023-03-01' AND ld.period_start = '2023-02-01';\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: What's the percent change in new listings in real estate for San Francisco from Feb 2023 to March 2023? [/INST] To answer the user's question, I'll be working with the following tables: redfin_new_listings. From these tables, I'll be using the following columns: location_name, metric_value, period_start, geo_type, property_type, dh_state_name, dh_place_name, cd.location_name, cd.new_listings, ld.new_listings, ld.location_name, cd.period_start, ld.period_start.\n\nHere is the SQL query:\n\n```sql\nWITH DATA AS (SELECT location_name, metric_value AS new_listings, period_start FROM redfin_new_listings WHERE geo_type = 'city' AND property_type = 'All Residential' AND dh_state_name = 'California' AND dh_place_name = 'San Francisco' AND (period_start = '2023-03-01' OR period_start = '2023-02-01')) SELECT cd.location_name, cd.new_listings AS new_new_listings, ld.new_listings AS old_new_listings, ((cd.new_listings - ld.new_listings) * 100 / ld.new_listings) AS pct_change FROM DATA cd JOIN DATA ld ON cd.location_name = ld.location_name WHERE cd.period_start = '2023-03-01' AND ld.period_start = '2023-02-01';\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: What is the median rent price in Dade county for Apartment Building? [/INST] To answer the user's question, I'll be working with the following tables: renthub_median_rent. From these tables, I'll be using the following columns: period_end, metric_value, geo_type, property_type, dh_state_name, dh_county_name.\n\nHere is the SQL query:\n\n```sql\nSELECT period_end, metric_value AS median_price, FROM renthub_median_rent WHERE geo_type = 'county' AND property_type = 'Apartment Building' AND dh_state_name = 'Florida' AND dh_county_name = 'Miami-Dade' ORDER BY period_end DESC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: What is the median sale price in Orlando for Multi-family? [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_sale_price. From these tables, I'll be using the following columns: period_end, metric_value, geo_type, property_type, dh_state_name, dh_place_name.\n\nHere is the SQL query:\n\n```sql\nSELECT period_end, metric_value AS median_price FROM redfin_median_sale_price WHERE geo_type = 'city' AND property_type = 'Multi-family' AND dh_state_name = 'Florida' AND dh_place_name = 'Orlando' ORDER BY period_end DESC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: What is the total number of listings in San Francisco for Single-family? [/INST] To answer the user's question, I'll be working with the following tables: redfin_inventory. From these tables, I'll be using the following columns: period_end, metric_value, geo_type, property_type, dh_state_name, dh_place_name.\n\nHere is the SQL query:\n\n```sql\nSELECT period_end, metric_value AS inventory FROM redfin_inventory WHERE geo_type = 'city' AND property_type = 'Single-family' AND dh_state_name = 'California' AND dh_place_name = 'San Francisco' ORDER BY period_end DESC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: How many new listings are there in San antonio texas for Townhouse? [/INST] To answer the user's question, I'll be working with the following tables: redfin_new_listings. From these tables, I'll be using the following columns: period_end, metric_value, geo_type, property_type, dh_state_name, dh_place_name.\n\nHere is the SQL query:\n\n```sql\nSELECT period_end, metric_value AS new_listings FROM redfin_new_listings WHERE geo_type = 'city' AND property_type = 'Townhouse' AND dh_state_name = 'Texas' AND dh_place_name = 'San Antonio' ORDER BY period_end DESC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: How much did median rent price change from Feb 2022 to Feb 2023 in Miami city for Condo? [/INST] To answer the user's question, I'll be working with the following tables: renthub_median_rent. From these tables, I'll be using the following columns: location_name, metric_value, period_start, geo_type, property_type, dh_state_name, dh_place_name, cd.location_name, cd.median_price, ld.median_price, ld.location_name, cd.period_start, ld.period_start.\n\nHere is the SQL query:\n\n```sql\nWITH DATA AS (SELECT location_name, metric_value AS median_price, period_start FROM renthub_median_rent WHERE geo_type = 'city' AND property_type = 'Condo' AND dh_state_name = 'Florida' AND dh_place_name = 'Miami' AND (period_start = '2023-02-01' OR period_start = '2022-02-01') ) SELECT cd.location_name, cd.median_price AS new_median_price, ld.median_price AS old_median_price, ((cd.median_price - ld.median_price) * 100 / ld.median_price) AS pct_change FROM DATA cd JOIN DATA ld ON cd.location_name = ld.location_name WHERE cd.period_start = '2023-02-01' AND ld.period_start = '2022-02-01';\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: How much did median sale price change from Feb 2022 to Feb 2023 in North Carolina for Single-family? [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_sale_price. From these tables, I'll be using the following columns: location_name, metric_value, period_start, geo_type, property_type, dh_state_name, cd.location_name, cd.median_price, ld.median_price, ld.location_name, cd.period_start, ld.period_start.\n\nHere is the SQL query:\n\n```sql\nWITH DATA AS (SELECT location_name, metric_value AS median_price, period_start FROM redfin_median_sale_price WHERE geo_type = 'state' AND property_type = 'Single-family' AND dh_state_name = 'North Carolina' AND (period_start = '2023-02-01' OR period_start = '2022-02-01') ) SELECT cd.location_name, cd.median_price AS new_median_price, ld.median_price AS old_median_price, ((cd.median_price - ld.median_price) * 100 / ld.median_price) AS pct_change FROM DATA cd JOIN DATA ld ON cd.location_name = ld.location_name WHERE cd.period_start = '2023-02-01' AND ld.period_start = '2022-02-01';\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: How much did real estate inventory change from Feb 2022 to Feb 2023 in Illinois for Multi-family? [/INST] To answer the user's question, I'll be working with the following tables: redfin_inventory. From these tables, I'll be using the following columns: location_name, metric_value, period_start, geo_type, property_type, dh_state_name, cd.location_name, cd.inventory, ld.inventory, ld.location_name, cd.period_start, ld.period_start.\n\nHere is the SQL query:\n\n```sql\nWITH DATA AS (SELECT location_name, metric_value AS inventory, period_start FROM redfin_inventory WHERE geo_type = 'state' AND property_type = 'Multi-family' AND dh_state_name = 'Illinois' AND (period_start = '2023-02-01' OR period_start = '2022-02-01') ) SELECT cd.location_name, cd.inventory AS new_inventory, ld.inventory AS old_inventory, ((cd.inventory - ld.inventory) * 100 / ld.inventory) AS pct_change FROM DATA cd JOIN DATA ld ON cd.location_name = ld.location_name WHERE cd.period_start = '2023-02-01' AND ld.period_start = '2022-02-01';\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: How much did real estate new listings number change from Feb 2022 to Feb 2023 in Queens county for Townhouse? [/INST] To answer the user's question, I'll be working with the following tables: redfin_new_listings. From these tables, I'll be using the following columns: location_name, metric_value, period_start, geo_type, property_type, dh_state_name, dh_county_name, cd.location_name, cd.new_listings, ld.new_listings, ld.location_name, cd.period_start, ld.period_start.\n\nHere is the SQL query:\n\n```sql\nWITH DATA AS (SELECT location_name, metric_value AS new_listings, period_start FROM redfin_new_listings WHERE geo_type = 'county' AND property_type = 'Townhouse' AND dh_state_name = 'New York' AND dh_county_name = 'Queens' AND (period_start = '2023-02-01' OR period_start = '2022-02-01') ) SELECT cd.location_name, cd.new_listings AS new_new_listings, ld.new_listings AS old_new_listings, ((cd.new_listings - ld.new_listings) * 100 / ld.new_listings) AS pct_change FROM DATA cd JOIN DATA ld ON cd.location_name = ld.location_name WHERE cd.period_start = '2023-02-01' AND ld.period_start = '2022-02-01';\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: Which property type had the highest median sale price in Florida? [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_sale_price. From these tables, I'll be using the following columns: period_end, property_type, metric_value, geo_type, dh_state_name.\n\nHere is the SQL query:\n\n```sql\nSELECT period_end, property_type, metric_value AS median_price FROM redfin_median_sale_price WHERE geo_type = 'state' AND dh_state_name = 'Florida' AND property_type <> 'All Residential' ORDER BY period_end DESC, metric_value DESC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: Which property type had the highest median rent price in Dade county? [/INST] To answer the user's question, I'll be working with the following tables: renthub_median_rent. From these tables, I'll be using the following columns: period_end, property_type, metric_value, geo_type, dh_state_name, dh_county_name.\n\nHere is the SQL query:\n\n```sql\nSELECT period_end, property_type, metric_value AS median_price FROM renthub_median_rent WHERE geo_type = 'county' AND dh_state_name = 'Florida' AND dh_county_name = 'Miami-Dade' AND property_type <> 'All Residential' ORDER BY period_end DESC, metric_value DESC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: Which property type had the highest inventory of real estate in Nevada? [/INST] To answer the user's question, I'll be working with the following tables: redfin_inventory. From these tables, I'll be using the following columns: period_end, property_type, metric_value, geo_type, dh_state_name.\n\nHere is the SQL query:\n\n```sql\nSELECT period_end, property_type, metric_value AS inventory FROM redfin_inventory WHERE geo_type = 'state' AND dh_state_name = 'Nevada' AND property_type <> 'All Residential' ORDER BY period_end DESC, metric_value DESC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: Which property type had the highest new listings number in Queens county? [/INST] To answer the user's question, I'll be working with the following tables: redfin_new_listings. From these tables, I'll be using the following columns: period_end, property_type, metric_value, geo_type, dh_state_name, dh_county_fullname.\n\nHere is the SQL query:\n\n```sql\nSELECT period_end, property_type, metric_value AS new_listings FROM redfin_new_listings WHERE geo_type = 'county' AND dh_state_name = 'New York' AND dh_county_fullname = 'Queens County' AND property_type <> 'All Residential' ORDER BY period_end DESC, metric_value DESC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: Did median sale price increase/decrease in Orlando for Single-family from Feb 2022 to Feb 2023? [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_sale_price. From these tables, I'll be using the following columns: location_name, metric_value, period_start, geo_type, property_type, dh_state_name, dh_place_name, cd.location_name, cd.median_price, ld.median_price, ld.location_name, cd.period_start, ld.period_start.\n\nHere is the SQL query:\n\n```sql\nWITH DATA AS (SELECT location_name, metric_value AS median_price, period_start FROM redfin_median_sale_price WHERE geo_type = 'city' AND property_type = 'Single-family' AND dh_state_name = 'Florida' AND dh_place_name = 'Orlando' AND (period_start = '2023-02-01' OR period_start = '2022-02-01') ) SELECT cd.location_name, cd.median_price AS new_median_price, ld.median_price AS old_median_price, ((cd.median_price - ld.median_price) * 100 / ld.median_price) AS pct_change FROM DATA cd JOIN DATA ld ON cd.location_name = ld.location_name WHERE cd.period_start = '2023-02-01' AND ld.period_start = '2022-02-01';\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: Did median rent price increase/decrease in Sacramento for House from Feb 2022 to Feb 2023? [/INST] To answer the user's question, I'll be working with the following tables: renthub_median_rent. From these tables, I'll be using the following columns: location_name, metric_value, period_start, geo_type, property_type, dh_state_name, dh_place_name, cd.location_name, cd.median_price, ld.median_price, ld.location_name, cd.period_start, ld.period_start.\n\nHere is the SQL query:\n\n```sql\nWITH DATA AS (SELECT location_name, metric_value AS median_price, period_start FROM renthub_median_rent WHERE geo_type = 'city' AND property_type = 'House' AND dh_state_name = 'California' AND dh_place_name = 'Sacramento' AND (period_start = '2023-02-01' OR period_start = '2022-02-01') ) SELECT cd.location_name, cd.median_price AS new_median_price, ld.median_price AS old_median_price, ((cd.median_price - ld.median_price) * 100 / ld.median_price) AS pct_change FROM DATA cd JOIN DATA ld ON cd.location_name = ld.location_name WHERE cd.period_start = '2023-02-01' AND ld.period_start = '2022-02-01';\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: Did inventory of real estate increase/decrease in Las Vegas for Townhouse from Feb 2022 to Feb 2023? [/INST] To answer the user's question, I'll be working with the following tables: redfin_inventory. From these tables, I'll be using the following columns: location_name, metric_value, period_start, geo_type, property_type, dh_state_name, dh_place_name, cd.location_name, cd.inventory, ld.inventory, ld.location_name, cd.period_start, ld.period_start.\n\nHere is the SQL query:\n\n```sql\nWITH DATA AS (SELECT location_name, metric_value AS inventory, period_start FROM redfin_inventory WHERE geo_type = 'city' AND property_type = 'Townhouse' AND dh_state_name = 'Nevada' AND dh_place_name = 'Las Vegas' AND (period_start = '2023-02-01' OR period_start = '2022-02-01') ) SELECT cd.location_name, cd.inventory AS new_inventory, ld.inventory AS old_inventory, ((cd.inventory - ld.inventory) * 100 / ld.inventory) AS pct_change FROM DATA cd JOIN DATA ld ON cd.location_name = ld.location_name WHERE cd.period_start = '2023-02-01' AND ld.period_start = '2022-02-01';\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: Did new listings in real estate increase/decrease in San Antonio for Single-family from Feb 2022 to Feb 2023? [/INST] To answer the user's question, I'll be working with the following tables: redfin_new_listings. From these tables, I'll be using the following columns: location_name, metric_value, period_start, geo_type, property_type, dh_state_name, dh_place_name, cd.location_name, cd.new_listings, ld.new_listings, ld.location_name, cd.period_start, ld.period_start.\n\nHere is the SQL query:\n\n```sql\nWITH DATA AS (SELECT location_name, metric_value AS new_listings, period_start FROM redfin_new_listings WHERE geo_type = 'city' AND property_type = 'Single-family' AND dh_state_name = 'Texas' AND dh_place_name = 'San Antonio' AND (period_start = '2023-02-01' OR period_start = '2022-02-01') ) SELECT cd.location_name, cd.new_listings AS new_new_listings, ld.new_listings AS old_new_listings, ((cd.new_listings - ld.new_listings) * 100 / ld.new_listings) AS pct_change FROM DATA cd JOIN DATA ld ON cd.location_name = ld.location_name WHERE cd.period_start = '2023-02-01' AND ld.period_start = '2022-02-01';\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: Which city showed the highest total increase in median rent price for condo in Texas from March 2022 to March 2023? [/INST] To answer the user's question, I'll be working with the following tables: renthub_median_rent. From these tables, I'll be using the following columns: location_name, metric_value, period_start, geo_type, property_type, dh_state_name, cd.location_name, cd.median_price, ld.median_price, ld.location_name, cd.period_start, ld.period_start.\n\nHere is the SQL query:\n\n```sql\nWITH DATA AS (SELECT location_name, metric_value AS median_price, period_start FROM renthub_median_rent WHERE geo_type = 'city' AND property_type = 'Condo' AND dh_state_name = 'Texas' AND (period_start = '2023-03-01' OR period_start = '2022-03-01') ) SELECT cd.location_name, cd.median_price AS new_median_price, ld.median_price AS old_median_price, (cd.median_price - ld.median_price) AS total_increase FROM DATA cd JOIN DATA ld ON cd.location_name = ld.location_name WHERE cd.period_start = '2023-03-01' AND ld.period_start = '2022-03-01' ORDER BY total_increase DESC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: In how many cities in California are the median sale prices higher for single family compared to Townhouses? [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_sale_price. From these tables, I'll be using the following columns: location_name, property_type, metric_value, period_start, geo_type, dh_state_name, single_family.location_name, townhouse.location_name, single_family.property_type, townhouse.property_type, single_family.median_price, townhouse.median_price.\n\nHere is the SQL query:\n\n```sql\nWITH DATA AS (SELECT location_name, property_type, metric_value AS median_price, period_start FROM redfin_median_sale_price WHERE geo_type = 'city' and dh_state_name = 'California' AND (property_type = 'Single-family' OR property_type = 'Townhouse') AND period_start = (SELECT max(period_start) FROM redfin_median_sale_price WHERE geo_type = 'city' and dh_state_name = 'California') ) SELECT COUNT(single_family.location_name) AS num_cities FROM DATA single_family JOIN DATA townhouse ON single_family.location_name = townhouse.location_name WHERE single_family.property_type = 'Single-family' AND townhouse.property_type = 'Townhouse' AND single_family.median_price > townhouse.median_price;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: In how many cities in Texas are the median rent prices higher for Townhouses compared to Condos? [/INST] To answer the user's question, I'll be working with the following tables: renthub_median_rent. From these tables, I'll be using the following columns: location_name, property_type, metric_value, period_start, geo_type, dh_state_name, townhouse.location_name, condo.location_name, townhouse.property_type, condo.property_type, townhouse.median_price, condo.median_price.\n\nHere is the SQL query:\n\n```sql\nWITH DATA AS (SELECT location_name, property_type, metric_value AS median_price, period_start FROM renthub_median_rent WHERE geo_type = 'city' and dh_state_name = 'Texas' AND (property_type = 'Townhouse' OR property_type = 'Condo') AND period_start = (SELECT max(period_start) FROM renthub_median_rent WHERE geo_type = 'city' and dh_state_name = 'Texas') ) SELECT COUNT(townhouse.location_name) AS num_cities FROM DATA townhouse JOIN DATA condo ON townhouse.location_name = condo.location_name WHERE townhouse.property_type = 'Townhouse' AND condo.property_type = 'Condo' AND townhouse.median_price > condo.median_price;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: In how many cities in Nevada are the median rent prices higher for condos compared to Apartment buildings? [/INST] To answer the user's question, I'll be working with the following tables: renthub_median_rent. From these tables, I'll be using the following columns: location_name, property_type, metric_value, period_start, geo_type, dh_state_name, condo.location_name, apartment_buildings.location_name, condo.property_type, apartment_buildings.property_type, condo.median_price, apartment_buildings.median_price.\n\nHere is the SQL query:\n\n```sql\nWITH DATA AS (SELECT location_name, property_type, metric_value AS median_price, period_start FROM renthub_median_rent WHERE geo_type = 'city' and dh_state_name = 'Nevada' AND (property_type = 'Condo' OR property_type = 'Apartment Building') AND period_start = (SELECT max(period_start) FROM renthub_median_rent WHERE geo_type = 'city' and dh_state_name = 'Nevada') ) SELECT COUNT(condo.location_name) AS num_cities FROM DATA condo JOIN DATA apartment_buildings ON condo.location_name = apartment_buildings.location_name WHERE condo.property_type = 'Condo' AND apartment_buildings.property_type = 'Apartment Building' AND condo.median_price > apartment_buildings.median_price;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: In which cities in Texas are the median rent prices higher for condos compared to Apartment buildings? [/INST] To answer the user's question, I'll be working with the following tables: renthub_median_rent. From these tables, I'll be using the following columns: location_name, property_type, metric_value, period_start, geo_type, dh_state_name, condo.location_name, condo.median_price, apartment_buildings.median_price, apartment_buildings.location_name, condo.property_type, apartment_buildings.property_type.\n\nHere is the SQL query:\n\n```sql\nWITH DATA AS (SELECT location_name, property_type, metric_value AS median_price, period_start FROM renthub_median_rent WHERE geo_type = 'city' and dh_state_name = 'Texas' AND (property_type = 'Condo' OR property_type = 'Apartment Building') AND period_start = (SELECT max(period_start) FROM renthub_median_rent WHERE geo_type = 'city' and dh_state_name = 'Texas') ) SELECT condo.location_name, condo.median_price AS condo_median_price, apartment_buildings.median_price AS apartment_building_median_price FROM DATA condo JOIN DATA apartment_buildings ON condo.location_name = apartment_buildings.location_name WHERE condo.property_type = 'Condo' AND apartment_buildings.property_type = 'Apartment Building' AND condo.median_price > apartment_buildings.median_price;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: Can you provide data on historical property rent prices in San Antonio, Texas from Feb 2022? [/INST] To answer the user's question, I'll be working with the following tables: renthub_median_rent. From these tables, I'll be using the following columns: period_start, metric_value, geo_type, property_type, dh_state_name, dh_place_name, period_end.\n\nHere is the SQL query:\n\n```sql\nSELECT period_start, metric_value AS median_price FROM renthub_median_rent WHERE geo_type = 'city' AND property_type = 'All Residential' AND dh_state_name = 'Texas' AND dh_place_name = 'San Antonio' AND period_start >= '2022-02-01' ORDER BY period_end DESC;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: how did rent prices change bewteen 2020 and 2022 in Miami? [/INST] To answer the user's question, I'll be working with the following tables: renthub_median_rent. From these tables, I'll be using the following columns: period_start, metric_value, geo_type, property_type, dh_state_name, dh_place_name.\n\nHere is the SQL query:\n\n```sql\nSELECT period_start, metric_value AS median_price FROM renthub_median_rent WHERE geo_type = 'city' AND property_type = 'All Residential' AND dh_state_name = 'Florida' AND dh_place_name = 'Miami' AND period_start BETWEEN '2020-01-01' AND '2022-12-31' ORDER BY period_start DESC;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: which are the top 3 ZIP Codes with the highest property sale prices in Los Angeles? [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_sale_price. From these tables, I'll be using the following columns: location_name, metric_value, geo_type, property_type, dh_state_name, dh_place_name, period_start.\n\nHere is the SQL query:\n\n```sql\nSELECT location_name, metric_value AS median_price FROM redfin_median_sale_price WHERE geo_type = 'zip' AND property_type = 'All Residential' AND dh_state_name = 'California' AND dh_place_name = 'Los Angeles' AND period_start = (SELECT max(period_start) FROM redfin_median_sale_price WHERE geo_type = 'zip' AND property_type = 'All Residential' AND dh_state_name = 'California' AND dh_place_name = 'Los Angeles') ORDER BY metric_value DESC LIMIT 3;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: what is the difference between the ZIP Code with the highest median home sale value in Los Angeles and the LA median? [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_sale_price. From these tables, I'll be using the following columns: period_end, location_name, metric_value, geo_type, property_type, dh_state_name, dh_place_name, redfin_median_sale_price.metric_value, redfin_median_sale_price.period_end, redfin_median_sale_price.geo_type, redfin_median_sale_price.property_type, redfin_median_sale_price.dh_state_name, redfin_median_sale_price.dh_place_name.\n\nHere is the SQL query:\n\n```sql\nWITH highest_zip_data AS (SELECT period_end, location_name, metric_value AS median_price FROM redfin_median_sale_price WHERE geo_type = 'zip' AND property_type = 'All Residential' AND dh_state_name = 'California' AND dh_place_name = 'Los Angeles' ORDER BY period_end DESC, metric_value DESC LIMIT 1) SELECT highest_zip_data.location_name AS highest_zip, highest_zip_data.median_price AS highest_zip_median_price, la_data.metric_value AS la_median_price, (la_data.metric_value - highest_zip_data.median_price) * 100 / highest_zip_data.median_price as pct_diff FROM redfin_median_sale_price la_data INNER JOIN highest_zip_data ON la_data.period_end = highest_zip_data.period_end WHERE la_data.geo_type = 'city' AND la_data.property_type = 'All Residential' AND la_data.dh_state_name = 'California' AND la_data.dh_place_name = 'Los Angeles' ORDER BY la_data.period_end DESC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: what is the difference between the most expensive ZIP Code in NY and Miami? [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_sale_price. From these tables, I'll be using the following columns: location_name, metric_value, geo_type, property_type, dh_state_name, dh_place_name, period_end, ny.location_name, ny.median_price, miami.location_name, miami.median_price.\n\nHere is the SQL query:\n\n```sql\nWITH most_expensive_zip_NY AS (SELECT location_name, metric_value AS median_price FROM redfin_median_sale_price WHERE geo_type = 'zip' AND property_type = 'All Residential' AND dh_state_name = 'New York' AND dh_place_name = 'New York' ORDER BY period_end DESC, metric_value DESC LIMIT 1) , most_expensive_zip_Miami AS ( SELECT location_name, metric_value AS median_price FROM redfin_median_sale_price WHERE geo_type = 'zip' AND property_type = 'All Residential' AND dh_state_name = 'Florida' AND dh_place_name = 'Miami' ORDER BY period_end DESC, metric_value DESC LIMIT 1 ) SELECT ny.location_name AS NY_most_expensive_zip, ny.median_price AS ny_zip_median_price, miami.location_name AS Miami_most_expensive_zip, miami.median_price AS miami_zip_median_price, (ny.median_price - miami.median_price) * 100 / miami.median_price AS pct_diff FROM most_expensive_zip_NY ny, most_expensive_zip_Miami miami;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: which are the 3 states with the lowest median sale prices? [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_sale_price. From these tables, I'll be using the following columns: location_name, metric_value, geo_type, property_type, period_start.\n\nHere is the SQL query:\n\n```sql\nSELECT location_name AS state_name, metric_value AS median_price FROM redfin_median_sale_price WHERE geo_type = 'state' AND property_type = 'All Residential' ORDER BY period_start DESC, metric_value ASC LIMIT 3;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: What are the most popular types of properties (e.g., single-family homes, condos, apartments) in California? [/INST] To answer the user's question, I'll be working with the following tables: redfin_inventory. From these tables, I'll be using the following columns: period_start, property_type, metric_value, geo_type, dh_state_name.\n\nHere is the SQL query:\n\n```sql\nSELECT period_start, property_type, metric_value AS inventory FROM redfin_inventory WHERE geo_type = 'state' AND dh_state_name = 'California' AND property_type <> 'All Residential' AND period_start = (SELECT max(period_start) FROM redfin_inventory WHERE geo_type = 'state' AND dh_state_name = 'California' AND property_type <> 'All Residential') ORDER BY metric_value DESC;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: What are the current listings for single-family homes in LA? [/INST] To answer the user's question, I'll be working with the following tables: redfin_inventory. From these tables, I'll be using the following columns: metric_value, geo_type, dh_state_name, dh_place_name, property_type, period_end.\n\nHere is the SQL query:\n\n```sql\nSELECT metric_value AS inventory FROM redfin_inventory WHERE geo_type = 'city' AND dh_state_name = 'California' AND dh_place_name = 'Los Angeles' AND property_type = 'Single-family' ORDER BY period_end DESC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: what is the proportion of the total number of listings in LA over California? [/INST] To answer the user's question, I'll be working with the following tables: redfin_inventory. From these tables, I'll be using the following columns: redfin_inventory.metric_value, redfin_inventory.dh_state_name, redfin_inventory.property_type, redfin_inventory.period_end, redfin_inventory.geo_type, redfin_inventory.dh_place_name.\n\nHere is the SQL query:\n\n```sql\nSELECT la_data.metric_value AS la_inventory, ca_data.metric_value AS ca_inventory, (la_data.metric_value / ca_data.metric_value) * 100 AS la_proportion FROM redfin_inventory la_data INNER JOIN redfin_inventory ca_data ON la_data.dh_state_name = ca_data.dh_state_name AND la_data.property_type = ca_data.property_type AND la_data.period_end = ca_data.period_end WHERE ca_data.geo_type = 'state' AND la_data.geo_type = 'city' AND la_data.dh_state_name = 'California' AND la_data.dh_place_name = 'Los Angeles' AND la_data.property_type = 'All Residential' ORDER BY la_data.period_end DESC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: Which are the top 10 zips with the highest new listings numbers in New York city? [/INST] To answer the user's question, I'll be working with the following tables: redfin_new_listings. From these tables, I'll be using the following columns: location_name, metric_value, geo_type, dh_place_name, property_type, period_start.\n\nHere is the SQL query:\n\n```sql\nSELECT location_name as zip_code, metric_value as new_listings FROM redfin_new_listings WHERE geo_type = 'zip' AND dh_place_name = 'New York' AND property_type = 'All Residential' AND period_start = (SELECT max(period_start) FROM redfin_new_listings WHERE geo_type = 'zip' AND dh_place_name = 'New York' AND property_type = 'All Residential') ORDER BY metric_value DESC LIMIT 10;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: how did the new listings increased/decreased in New Orleans from March 2022 to March 2023? [/INST] To answer the user's question, I'll be working with the following tables: redfin_new_listings. From these tables, I'll be using the following columns: location_name, metric_value, period_start, geo_type, property_type, dh_state_name, dh_place_name, cd.location_name, cd.new_listings, ld.new_listings, ld.location_name, cd.period_start, ld.period_start.\n\nHere is the SQL query:\n\n```sql\nWITH DATA AS (SELECT location_name, metric_value AS new_listings, period_start FROM redfin_new_listings WHERE geo_type = 'city' AND property_type = 'All Residential' AND dh_state_name = 'Louisiana' AND dh_place_name = 'New Orleans' AND (period_start = '2023-03-01' OR period_start = '2022-03-01')) SELECT cd.location_name, cd.new_listings AS new_new_listings, ld.new_listings AS old_new_listings, ((cd.new_listings - ld.new_listings) * 100 / ld.new_listings) AS pct_change FROM DATA cd JOIN DATA ld ON cd.location_name = ld.location_name WHERE cd.period_start = '2023-03-01' AND ld.period_start = '2022-03-01';\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: What is the price per square foot for each property type in Sacramento? [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_ppsf. From these tables, I'll be using the following columns: property_type, metric_value, geo_type, dh_state_name, dh_place_name, period_start.\n\nHere is the SQL query:\n\n```sql\nSELECT property_type, metric_value FROM redfin_median_ppsf WHERE geo_type='city' AND dh_state_name = 'California' AND dh_place_name = 'Sacramento' AND period_start = (SELECT max(period_start) FROM redfin_median_ppsf WHERE geo_type='city' AND dh_state_name = 'California' AND dh_place_name = 'Sacramento') ORDER BY property_type ASC;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: which is the city with the highest increase in the price per sq ft in Oklahoma from July 2022 to July 2023? [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_ppsf. From these tables, I'll be using the following columns: location_name, metric_value, period_start, geo_type, property_type, dh_state_name, cd.location_name, cd.median_ppsf, ld.median_ppsf, ld.location_name, cd.period_start, ld.period_start.\n\nHere is the SQL query:\n\n```sql\nWITH DATA AS ( SELECT location_name, metric_value AS median_ppsf, period_start FROM redfin_median_ppsf WHERE geo_type = 'city' AND property_type = 'All Residential' AND dh_state_name = 'Oklahoma' AND (period_start = '2023-07-01' OR period_start = '2022-07-01') ) SELECT cd.location_name, cd.median_ppsf AS new_median_ppsf, ld.median_ppsf AS old_median_ppsf, ((cd.median_ppsf - ld.median_ppsf) * 100 / ld.median_ppsf) AS pct_change FROM DATA cd JOIN DATA ld ON cd.location_name = ld.location_name WHERE cd.period_start = '2023-07-01' AND ld.period_start = '2022-07-01' ORDER BY pct_change DESC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: How much did ppsf change from March 2022 to March 2023 in Allegheny county? [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_ppsf. From these tables, I'll be using the following columns: location_name, metric_value, period_start, geo_type, property_type, dh_state_name, dh_county_name, cd.location_name, cd.median_ppsf, ld.median_ppsf, ld.location_name, cd.period_start, ld.period_start.\n\nHere is the SQL query:\n\n```sql\nWITH DATA AS ( SELECT location_name, metric_value AS median_price, period_start FROM redfin_median_ppsf WHERE geo_type = 'county' AND property_type = 'All Residential' AND dh_state_name = 'Pennsylvania' AND dh_county_name = 'Allegheny' AND (period_start = '2023-03-01' OR period_start = '2022-03-01') ) SELECT cd.location_name, cd.median_ppsf AS new_median_ppsf, ld.median_ppsf AS old_median_ppsf, ((cd.median_ppsf - ld.median_ppsf) * 100 / ld.median_ppsf) AS pct_change FROM DATA cd JOIN DATA ld ON cd.location_name = ld.location_name WHERE cd.period_start = '2023-03-01' AND ld.period_start = '2022-03-01';\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: Which property type has the highest price per square foot in Alameda county? [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_ppsf. From these tables, I'll be using the following columns: period_end, property_type, metric_value, geo_type, dh_state_name, dh_county_name.\n\nHere is the SQL query:\n\n```sql\nSELECT period_end, property_type, metric_value FROM redfin_median_ppsf WHERE geo_type = 'county' AND dh_state_name = 'California' AND dh_county_name = 'Alameda' AND property_type <> 'All Residential' ORDER BY period_end DESC, metric_value DESC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: How much did ppsf change from Feb 2022 to Feb 2023 in Raleigh for townhouses? [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_ppsf. From these tables, I'll be using the following columns: location_name, metric_value, period_start, geo_type, property_type, dh_state_name, dh_place_name, cd.location_name, cd.median_ppsf, ld.median_ppsf, ld.location_name, cd.period_start, ld.period_start.\n\nHere is the SQL query:\n\n```sql\nWITH DATA AS ( SELECT location_name, metric_value AS median_ppsf, period_start FROM redfin_median_ppsf WHERE geo_type = 'city' AND property_type = 'Townhouse' AND dh_state_name = 'North Carolina' AND dh_place_name = 'Raleigh' AND (period_start = '2023-02-01' OR period_start = '2022-02-01') ) SELECT cd.location_name, cd.median_ppsf AS new_median_ppsf, ld.median_ppsf AS old_median_ppsf, ((cd.median_ppsf - ld.median_ppsf) * 100 / ld.median_ppsf) AS pct_change FROM DATA cd JOIN DATA ld ON cd.location_name = ld.location_name WHERE cd.period_start = '2023-02-01' AND ld.period_start = '2022-02-01';\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: what is the difference between the ZIP codes with the highest ppsf in Boulder and Las Vegas? [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_ppsf. From these tables, I'll be using the following columns: location_name, metric_value, geo_type, property_type, dh_state_name, dh_place_name, period_end, boulder.location_name, boulder.median_ppsf, lv.location_name, lv.median_ppsf.\n\nHere is the SQL query:\n\n```sql\nWITH most_expensive_zip_Boulder AS ( SELECT location_name, metric_value AS median_ppsf FROM redfin_median_ppsf WHERE geo_type = 'zip' AND property_type = 'All Residential' AND dh_state_name = 'Colorado' AND dh_place_name = 'Boulder' ORDER BY period_end DESC, metric_value DESC LIMIT 1), most_expensive_zip_LV AS ( SELECT location_name, metric_value AS median_ppsf FROM redfin_median_ppsf WHERE geo_type = 'zip' AND property_type = 'All Residential' AND dh_state_name = 'Nevada' AND dh_place_name = 'Las Vegas' ORDER BY period_end DESC, metric_value DESC LIMIT 1) SELECT boulder.location_name AS Boulder_most_expensive_zip, boulder.median_ppsf AS boulder_zip_median_ppsf, lv.location_name AS LV_most_expensive_zip, lv.median_ppsf AS LV_zip_median_ppsf, (boulder.median_ppsf - lv.median_ppsf) * 100 / lv.median_ppsf AS pct_diff FROM most_expensive_zip_Boulder boulder, most_expensive_zip_LV lv;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: In how many cities in Georgia is the price per square foot higher for condos compared to townhouses? [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_ppsf. From these tables, I'll be using the following columns: location_name, property_type, metric_value, period_start, geo_type, dh_state_name, condo.location_name, townhouse.location_name, condo.property_type, townhouse.property_type, condo.median_ppsf, townhouse.median_ppsf.\n\nHere is the SQL query:\n\n```sql\nWITH DATA AS ( SELECT location_name, property_type, metric_value AS median_ppsf, period_start FROM redfin_median_ppsf WHERE geo_type = 'city' AND dh_state_name = 'Georgia' AND (property_type = 'Condo/Co-op' OR property_type = 'Townhouse') AND period_start = ( SELECT max(period_start) FROM redfin_median_ppsf WHERE geo_type = 'city' AND dh_state_name = 'Georgia' ) ) SELECT COUNT(condo.location_name) AS num_cities FROM DATA condo JOIN DATA townhouse ON condo.location_name = townhouse.location_name WHERE condo.property_type = 'Condo/Co-op' AND townhouse.property_type = 'Townhouse' AND condo.median_ppsf > townhouse.median_ppsf;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: How does price per sq ft compare across Allegheny county and Dade county? [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_ppsf. From these tables, I'll be using the following columns: period_end, location_name, metric_value, geo_type, property_type, dh_state_name, dh_county_name, allegheny.period_end, allegheny.median_ppsf, dade.median_ppsf, dade.period_end.\n\nHere is the SQL query:\n\n```sql\nWITH Allegheny_county_data AS ( SELECT period_end, location_name, metric_value AS median_ppsf FROM redfin_median_ppsf WHERE geo_type = 'county' AND property_type = 'All Residential' AND dh_state_name = 'Pennsylvania' AND dh_county_name = 'Allegheny' ORDER BY period_end DESC), Dade_county_data AS ( SELECT period_end, location_name, metric_value AS median_ppsf FROM redfin_median_ppsf WHERE geo_type = 'county' AND property_type = 'All Residential' AND dh_state_name = 'Florida' AND dh_county_name = 'Miami-Dade' ORDER BY period_end DESC) SELECT allegheny.period_end, allegheny.median_ppsf AS allegheny_median_ppsf, dade.median_ppsf AS dade_median_ppsf, (allegheny.median_ppsf - dade.median_ppsf) * 100 / dade.median_ppsf AS pct_diff FROM Allegheny_county_data allegheny JOIN Dade_county_data dade ON allegheny.period_end = dade.period_end ORDER BY allegheny.period_end DESC LIMIT 5;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: What is the median ppsf in Austin texas for multi-family homes? [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_ppsf. From these tables, I'll be using the following columns: period_end, metric_value, geo_type, property_type, dh_state_name, dh_place_name.\n\nHere is the SQL query:\n\n```sql\nSELECT period_end, metric_value AS median_ppsf FROM redfin_median_ppsf WHERE geo_type = 'city' AND property_type = 'Multi-family' AND dh_state_name = 'Texas' AND dh_place_name = 'Austin' ORDER BY period_end DESC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: median price per square foot 15213 [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_ppsf. From these tables, I'll be using the following columns: period_start, period_end, metric_value, geo_type, location_name, dh_state_name, property_type.\n\nHere is the SQL query:\n\n```sql\nSELECT period_start, period_end, metric_value FROM redfin_median_ppsf WHERE geo_type='zip' AND location_name = '15213' AND dh_state_name = 'Pennsylvania' AND property_type = 'All Residential' ORDER BY period_start DESC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: Which state has the lowest median price per square foot overall? [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_ppsf. From these tables, I'll be using the following columns: period_end, location_name, metric_value, geo_type, property_type.\n\nHere is the SQL query:\n\n```sql\nSELECT period_end, location_name, metric_value FROM redfin_median_ppsf WHERE geo_type='state' AND property_type = 'All Residential' ORDER BY period_end DESC, metric_value ASC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: median ppsf in sonoma county in 2022 broken down by property type [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_ppsf. From these tables, I'll be using the following columns: period_start, property_type, metric_value, geo_type, location_name, dh_state_name.\n\nHere is the SQL query:\n\n```sql\nSELECT period_start, property_type, metric_value FROM redfin_median_ppsf WHERE geo_type='county' AND location_name='Sonoma' AND dh_state_name='California' AND property_type <> 'All Residential' AND period_start BETWEEN '2022-01-01' AND '2022-12-31' ORDER BY period_start ASC, property_type ASC;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: compare median ppsf in seattle vs houston since 2022 [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_ppsf. From these tables, I'll be using the following columns: period_end, location_name, dh_state_name, metric_value, geo_type, property_type.\n\nHere is the SQL query:\n\n```sql\nSELECT period_end, location_name, dh_state_name, metric_value FROM redfin_median_ppsf WHERE geo_type='city' AND property_type = 'All Residential' AND period_end >= '2022-01-01' AND ((location_name='Seattle' AND dh_state_name='Washington') OR (location_name = 'Houston' AND dh_state_name='Texas')) ORDER BY period_end, dh_state_name, location_name;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: what zip code had the highest ppsf in Dade county in Oct 2022? [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_ppsf. From these tables, I'll be using the following columns: location_name, metric_value, dh_county_name, dh_state_name, property_type, period_start, geo_type.\n\nHere is the SQL query:\n\n```sql\nSELECT location_name, metric_value FROM redfin_median_ppsf WHERE dh_county_name = 'Miami-Dade' AND dh_state_name = 'Florida' AND property_type = 'All Residential' AND period_start='2022-10-01' AND geo_type='zip' ORDER BY metric_value DESC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: what was the median price per square foot in New Hampshire in Q1 2021? [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_ppsf. From these tables, I'll be using the following columns: location_name, period_end, metric_value, geo_type, property_type, period_start.\n\nHere is the SQL query:\n\n```sql\nSELECT location_name, period_end, metric_value FROM redfin_median_ppsf WHERE geo_type = 'state' AND location_name='New Hampshire' AND property_type = 'All Residential' AND period_start BETWEEN '2021-01-01' AND '2021-03-31' ORDER BY period_end;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: What is the list price for each property type in San Jose? [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_list_price. From these tables, I'll be using the following columns: property_type, metric_value, geo_type, dh_state_name, dh_place_name, period_start.\n\nHere is the SQL query:\n\n```sql\nSELECT property_type, metric_value FROM redfin_median_list_price WHERE geo_type='city' AND dh_state_name = 'California' AND dh_place_name = 'San Jose' AND period_start = (SELECT max(period_start) FROM redfin_median_list_price WHERE geo_type='city' AND dh_state_name = 'California' AND dh_place_name = 'Sacramento') ORDER BY property_type ASC;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: which is the city with the highest increase in listing price in Mississippi from July 2022 to July 2023? [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_list_price. From these tables, I'll be using the following columns: location_name, metric_value, period_start, geo_type, property_type, dh_state_name, cd.location_name, cd.median_price, ld.median_price, ld.location_name, cd.period_start, ld.period_start.\n\nHere is the SQL query:\n\n```sql\nWITH DATA AS ( SELECT location_name, metric_value AS median_price, period_start FROM redfin_median_list_price WHERE geo_type = 'city' AND property_type = 'All Residential' AND dh_state_name = 'Mississippi' AND (period_start = '2023-07-01' OR period_start = '2022-07-01') ) SELECT cd.location_name, cd.median_price AS new_median_price, ld.median_price AS old_median_price, ((cd.median_price - ld.median_price) * 100 / ld.median_price) AS pct_change FROM DATA cd JOIN DATA ld ON cd.location_name = ld.location_name WHERE cd.period_start = '2023-07-01' AND ld.period_start = '2022-07-01' ORDER BY pct_change DESC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: How much did the list price change from March 2022 to March 2023 in Maricopa county? [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_list_price. From these tables, I'll be using the following columns: location_name, metric_value, period_start, geo_type, property_type, dh_state_name, dh_county_name, cd.location_name, cd.median_price, ld.median_price, ld.location_name, cd.period_start, ld.period_start.\n\nHere is the SQL query:\n\n```sql\nWITH DATA AS ( SELECT location_name, metric_value AS median_price, period_start FROM redfin_median_list_price WHERE geo_type = 'county' AND property_type = 'All Residential' AND dh_state_name = 'Arizona' AND dh_county_name = 'Maricopa' AND (period_start = '2023-03-01' OR period_start = '2022-03-01') ) SELECT cd.location_name, cd.median_price AS new_median_price, ld.median_price AS old_median_price, ((cd.median_price - ld.median_price) * 100 / ld.median_price) AS pct_change FROM DATA cd JOIN DATA ld ON cd.location_name = ld.location_name WHERE cd.period_start = '2023-03-01' AND ld.period_start = '2022-03-01';\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: Which property type has the highest listing price in Lincoln County, NV? [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_list_price. From these tables, I'll be using the following columns: period_end, property_type, metric_value, geo_type, dh_state_name, dh_county_name.\n\nHere is the SQL query:\n\n```sql\nSELECT period_end, property_type, metric_value FROM redfin_median_list_price WHERE geo_type = 'county' AND dh_state_name = 'Nevada' AND dh_county_name = 'Lincoln' AND property_type <> 'All Residential' ORDER BY period_end DESC, metric_value DESC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: How much did list price change from Feb 2022 to Feb 2023 in Denver for townhouses? [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_list_price. From these tables, I'll be using the following columns: location_name, metric_value, period_start, geo_type, property_type, dh_state_name, dh_place_name, cd.location_name, cd.median_price, ld.median_price, ld.location_name, cd.period_start, ld.period_start.\n\nHere is the SQL query:\n\n```sql\nWITH DATA AS ( SELECT location_name, metric_value AS median_price, period_start FROM redfin_median_list_price WHERE geo_type = 'city' AND property_type = 'Townhouse' AND dh_state_name = 'Colorado' AND dh_place_name = 'Denver' AND (period_start = '2023-02-01' OR period_start = '2022-02-01') ) SELECT cd.location_name, cd.median_price AS new_median_price, ld.median_price AS old_median_price, ((cd.median_price - ld.median_price) * 100 / ld.median_price) AS pct_change FROM DATA cd JOIN DATA ld ON cd.location_name = ld.location_name WHERE cd.period_start = '2023-02-01' AND ld.period_start = '2022-02-01';\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: what is the difference between the ZIP codes with the highest list price in Denver and Reno? [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_list_price. From these tables, I'll be using the following columns: location_name, metric_value, geo_type, property_type, dh_state_name, dh_place_name, period_end, denver.location_name, denver.median_price, reno.location_name, reno.median_price.\n\nHere is the SQL query:\n\n```sql\nWITH most_expensive_zip_Denver AS ( SELECT location_name, metric_value AS median_price FROM redfin_median_list_price WHERE geo_type = 'zip' AND property_type = 'All Residential' AND dh_state_name = 'Colorado' AND dh_place_name = 'Denver' ORDER BY period_end DESC, metric_value DESC LIMIT 1), most_expensive_zip_Reno AS ( SELECT location_name, metric_value AS median_price FROM redfin_median_list_price WHERE geo_type = 'zip' AND property_type = 'All Residential' AND dh_state_name = 'Nevada' AND dh_place_name = 'Reno' ORDER BY period_end DESC, metric_value DESC LIMIT 1) SELECT denver.location_name AS Denver_most_expensive_zip, denver.median_price AS denver_zip_median_price, reno.location_name AS Reno_most_expensive_zip, reno.median_price AS Reno_zip_median_price, (denver.median_price - reno.median_price) * 100 / reno.median_price AS pct_diff FROM most_expensive_zip_Denver denver, most_expensive_zip_Reno reno;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: In how many cities in Missouri is listing price higher for condos compared to townhouses? [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_list_price. From these tables, I'll be using the following columns: location_name, property_type, metric_value, period_start, geo_type, dh_state_name, condo.location_name, townhouse.location_name, condo.property_type, townhouse.property_type, condo.median_price, townhouse.median_price.\n\nHere is the SQL query:\n\n```sql\nWITH DATA AS ( SELECT location_name, property_type, metric_value AS median_price, period_start FROM redfin_median_list_price WHERE geo_type = 'city' AND dh_state_name = 'Missouri' AND (property_type = 'Condo/Co-op' OR property_type = 'Townhouse') AND period_start = ( SELECT max(period_start) FROM redfin_median_list_price WHERE geo_type = 'city' AND dh_state_name = 'Missouri' ) ) SELECT COUNT(condo.location_name) AS num_cities FROM DATA condo JOIN DATA townhouse ON condo.location_name = townhouse.location_name WHERE condo.property_type = 'Condo/Co-op' AND townhouse.property_type = 'Townhouse' AND condo.median_price > townhouse.median_price;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: How does list price compare across Philadelphia county and Sarasota county? [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_list_price. From these tables, I'll be using the following columns: period_end, location_name, metric_value, geo_type, property_type, dh_state_name, dh_county_name, philadelphia.period_end, philadelphia.median_price, sarasota.median_ppsf, sarasota.median_price, sarasota.period_end.\n\nHere is the SQL query:\n\n```sql\nWITH Philadelphia_county_data AS ( SELECT period_end, location_name, metric_value AS median_price FROM redfin_median_list_price WHERE geo_type = 'county' AND property_type = 'All Residential' AND dh_state_name = 'Pennsylvania' AND dh_county_name = 'Philadelphia' ORDER BY period_end DESC), Sarasota_county_data AS ( SELECT period_end, location_name, metric_value AS median_price FROM redfin_median_list_price WHERE geo_type = 'county' AND property_type = 'All Residential' AND dh_state_name = 'Florida' AND dh_county_name = 'Sarasota' ORDER BY period_end DESC) SELECT philadelphia.period_end, philadelphia.median_price AS philadelphia_median_price, sarasota.median_ppsf AS sarasota_median_price, (philadelphia.median_price - sarasota.median_price) * 100 / sarasota.median_price AS pct_diff FROM Philadelphia_county_data philadelphia JOIN Sarasota_county_data sarasota ON philadelphia.period_end = sarasota.period_end ORDER BY philadelphia.period_end DESC LIMIT 5;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: What is the median list price in Houston texas for multi-family homes? [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_list_price. From these tables, I'll be using the following columns: period_end, metric_value, geo_type, property_type, dh_state_name, dh_place_name.\n\nHere is the SQL query:\n\n```sql\nSELECT period_end, metric_value AS median_price FROM redfin_median_list_price WHERE geo_type = 'city' AND property_type = 'Multi-family' AND dh_state_name = 'Texas' AND dh_place_name = 'Houston' ORDER BY period_end DESC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: median list price 94555 [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_list_price. From these tables, I'll be using the following columns: period_start, period_end, metric_value, geo_type, location_name, dh_state_name, property_type.\n\nHere is the SQL query:\n\n```sql\nSELECT period_start, period_end, metric_value FROM redfin_median_list_price WHERE geo_type='zip' AND location_name = '94555' AND dh_state_name = 'California' AND property_type = 'All Residential' ORDER BY period_start DESC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: Which state has the lowest median list price? [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_list_price. From these tables, I'll be using the following columns: period_end, location_name, metric_value, geo_type, property_type.\n\nHere is the SQL query:\n\n```sql\nSELECT period_end, location_name, metric_value FROM redfin_median_list_price WHERE geo_type='state' AND property_type = 'All Residential' ORDER BY period_end DESC, metric_value ASC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: median list price in Napa county in 2022 broken down by property type [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_list_price. From these tables, I'll be using the following columns: period_start, property_type, metric_value, geo_type, location_name, dh_state_name.\n\nHere is the SQL query:\n\n```sql\nSELECT period_start, property_type, metric_value FROM redfin_median_list_price WHERE geo_type='county' AND location_name='Napa' AND dh_state_name='California' AND property_type <> 'All Residential' AND period_start BETWEEN '2022-01-01' AND '2022-12-31' ORDER BY period_start ASC, property_type ASC;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: compare median list price in tacoma vs austin since 2022 [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_list_price. From these tables, I'll be using the following columns: period_end, location_name, dh_state_name, metric_value, geo_type, property_type.\n\nHere is the SQL query:\n\n```sql\nSELECT period_end, location_name, dh_state_name, metric_value FROM redfin_median_list_price WHERE geo_type='city' AND property_type = 'All Residential' AND period_end >= '2022-01-01' AND ((location_name='Tacoma' AND dh_state_name='Washington') OR (location_name = 'Austin' AND dh_state_name='Texas')) ORDER BY period_end, dh_state_name, location_name;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: what zip code had the highest list price in Putnam county, FL in Oct 2022? [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_list_price. From these tables, I'll be using the following columns: location_name, metric_value, dh_county_name, dh_state_name, property_type, period_start, geo_type.\n\nHere is the SQL query:\n\n```sql\nSELECT location_name, metric_value FROM redfin_median_list_price WHERE dh_county_name = 'Putnam' AND dh_state_name = 'Florida' AND property_type = 'All Residential' AND period_start='2022-10-01' AND geo_type='zip' ORDER BY metric_value DESC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: what was the median list price in New Jersey in Q1 2021? [/INST] To answer the user's question, I'll be working with the following tables: redfin_median_list_price. From these tables, I'll be using the following columns: location_name, period_end, metric_value, geo_type, property_type, period_start.\n\nHere is the SQL query:\n\n```sql\nSELECT location_name, period_end, metric_value FROM redfin_median_list_price WHERE geo_type = 'state' AND location_name='New Jersey' AND property_type = 'All Residential' AND period_start BETWEEN '2021-01-01' AND '2021-03-31' ORDER BY period_end;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: How many houses were sold for each property type in Columbus, OH? [/INST] To answer the user's question, I'll be working with the following tables: redfin_homes_sold. From these tables, I'll be using the following columns: property_type, metric_value, geo_type, dh_state_name, dh_place_name, period_start.\n\nHere is the SQL query:\n\n```sql\nSELECT property_type, metric_value FROM redfin_homes_sold WHERE geo_type='city' AND dh_state_name = 'Ohio' AND dh_place_name = 'Columbus' AND period_start = (SELECT max(period_start) FROM redfin_homes_sold WHERE geo_type='city' AND dh_state_name = 'Ohio' AND dh_place_name = 'Columbus') ORDER BY property_type ASC;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: which is the city with the highest increase in houses sold in Virginia from July 2022 to July 2023? [/INST] To answer the user's question, I'll be working with the following tables: redfin_homes_sold. From these tables, I'll be using the following columns: location_name, metric_value, period_start, geo_type, property_type, dh_state_name, cd.location_name, cd.homes_sold, ld.homes_sold, ld.location_name, cd.period_start, ld.period_start.\n\nHere is the SQL query:\n\n```sql\nWITH DATA AS ( SELECT location_name, metric_value AS homes_sold, period_start FROM redfin_homes_sold WHERE geo_type = 'city' AND property_type = 'All Residential' AND dh_state_name = 'Virginia' AND (period_start = '2023-07-01' OR period_start = '2022-07-01') ) SELECT cd.location_name, cd.homes_sold AS new_homes_sold, ld.homes_sold AS old_homes_sold, ((cd.homes_sold - ld.homes_sold) * 100 / ld.homes_sold) AS pct_change FROM DATA cd JOIN DATA ld ON cd.location_name = ld.location_name WHERE cd.period_start = '2023-07-01' AND ld.period_start = '2022-07-01' ORDER BY pct_change DESC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: How much did the number of properties sold change from March 2022 to March 2023 in Graham county? [/INST] To answer the user's question, I'll be working with the following tables: redfin_homes_sold. From these tables, I'll be using the following columns: location_name, metric_value, period_start, geo_type, property_type, dh_state_name, dh_county_name, cd.location_name, cd.homes_sold, ld.homes_sold, ld.location_name, cd.period_start, ld.period_start.\n\nHere is the SQL query:\n\n```sql\nWITH DATA AS ( SELECT location_name, metric_value AS homes_sold, period_start FROM redfin_homes_sold WHERE geo_type = 'county' AND property_type = 'All Residential' AND dh_state_name = 'Arizona' AND dh_county_name = 'Graham' AND (period_start = '2023-03-01' OR period_start = '2022-03-01') ) SELECT cd.location_name, cd.homes_sold AS new_homes_sold, ld.homes_sold AS old_homes_sold, ((cd.homes_sold - ld.homes_sold) * 100 / ld.homes_sold) AS pct_change FROM DATA cd JOIN DATA ld ON cd.location_name = ld.location_name WHERE cd.period_start = '2023-03-01' AND ld.period_start = '2022-03-01';\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: Which property type has the highest houses sold in Humboldt County, NV? [/INST] To answer the user's question, I'll be working with the following tables: redfin_homes_sold. From these tables, I'll be using the following columns: period_end, property_type, metric_value, geo_type, dh_state_name, dh_county_name.\n\nHere is the SQL query:\n\n```sql\nSELECT period_end, property_type, metric_value FROM redfin_homes_sold WHERE geo_type = 'county' AND dh_state_name = 'Nevada' AND dh_county_name = 'Humboldt' AND property_type <> 'All Residential' ORDER BY period_end DESC, metric_value DESC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: How much did condos sold change from Feb 2022 to Feb 2023 in Tuscaloosa AL? [/INST] To answer the user's question, I'll be working with the following tables: redfin_homes_sold. From these tables, I'll be using the following columns: location_name, metric_value, period_start, geo_type, property_type, dh_state_name, dh_place_name, cd.location_name, cd.homes_sold, ld.homes_sold, ld.location_name, cd.period_start, ld.period_start.\n\nHere is the SQL query:\n\n```sql\nWITH DATA AS ( SELECT location_name, metric_value AS homes_sold, period_start FROM redfin_homes_sold WHERE geo_type = 'city' AND property_type = 'Condo/Co-op' AND dh_state_name = 'Alabama' AND dh_place_name = 'Tuscaloosa' AND (period_start = '2023-02-01' OR period_start = '2022-02-01') ) SELECT cd.location_name, cd.homes_sold AS new_homes_sold, ld.homes_sold AS old_homes_sold, ((cd.homes_sold - ld.homes_sold) * 100 / ld.homes_sold) AS pct_change FROM DATA cd JOIN DATA ld ON cd.location_name = ld.location_name WHERE cd.period_start = '2023-02-01' AND ld.period_start = '2022-02-01';\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: what is the difference between the ZIP codes with the most houses sold in San Antonio and Carson City? [/INST] To answer the user's question, I'll be working with the following tables: redfin_homes_sold. From these tables, I'll be using the following columns: location_name, metric_value, geo_type, property_type, dh_state_name, dh_place_name, period_end, sa.location_name, sa.homes_sold, CC.location_name, cc.homes_sold.\n\nHere is the SQL query:\n\n```sql\nWITH most_expensive_zip_SA AS ( SELECT location_name, metric_value AS homes_sold FROM redfin_homes_sold WHERE geo_type = 'zip' AND property_type = 'All Residential' AND dh_state_name = 'Texas' AND dh_place_name = 'San Antonio' ORDER BY period_end DESC, metric_value DESC LIMIT 1), most_expensive_zip_CC AS ( SELECT location_name, metric_value AS homes_sold FROM redfin_homes_sold WHERE geo_type = 'zip' AND property_type = 'All Residential' AND dh_state_name = 'Nevada' AND dh_place_name = 'Carson City' ORDER BY period_end DESC, metric_value DESC LIMIT 1) SELECT sa.location_name AS SA_most_expensive_zip, sa.homes_sold AS SA_zip_homes_sold, CC.location_name AS CC_most_expensive_zip, cc.homes_sold AS CC_zip_homes_sold, (sa.homes_sold - cc.homes_sold) * 100 / cc.homes_sold AS pct_diff FROM most_expensive_zip_SA sa, most_expensive_zip_CC cc;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: In how many cities in Arkansas is number of sold condos higher than townhouses? [/INST] To answer the user's question, I'll be working with the following tables: redfin_homes_sold. From these tables, I'll be using the following columns: location_name, property_type, metric_value, period_start, geo_type, dh_state_name, condo.location_name, townhouse.location_name, condo.property_type, townhouse.property_type, condo.homes_sold, townhouse.homes_sold.\n\nHere is the SQL query:\n\n```sql\nWITH DATA AS ( SELECT location_name, property_type, metric_value AS homes_sold, period_start FROM redfin_homes_sold WHERE geo_type = 'city' AND dh_state_name = 'Arkansas' AND (property_type = 'Condo/Co-op' OR property_type = 'Townhouse') AND period_start = ( SELECT max(period_start) FROM redfin_homes_sold WHERE geo_type = 'city' AND dh_state_name = 'Arkansas' ) ) SELECT COUNT(condo.location_name) AS num_cities FROM DATA condo JOIN DATA townhouse ON condo.location_name = townhouse.location_name WHERE condo.property_type = 'Condo/Co-op' AND townhouse.property_type = 'Townhouse' AND condo.homes_sold > townhouse.homes_sold;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: How does sold properties compare across Erie county and Broward county? [/INST] To answer the user's question, I'll be working with the following tables: redfin_homes_sold. From these tables, I'll be using the following columns: period_end, location_name, metric_value, geo_type, property_type, dh_state_name, dh_county_name, erie.period_end, erie.homes_sold, broward.homes_sold, broward.period_end.\n\nHere is the SQL query:\n\n```sql\nWITH Erie_county_data AS ( SELECT period_end, location_name, metric_value AS homes_sold FROM redfin_homes_sold WHERE geo_type = 'county' AND property_type = 'All Residential' AND dh_state_name = 'Pennsylvania' AND dh_county_name = 'Erie' ORDER BY period_end DESC), Broward_county_data AS ( SELECT period_end, location_name, metric_value AS homes_sold FROM redfin_homes_sold WHERE geo_type = 'county' AND property_type = 'All Residential' AND dh_state_name = 'Florida' AND dh_county_name = 'Broward' ORDER BY period_end DESC) SELECT erie.period_end, erie.homes_sold AS erie_homes_sold, broward.homes_sold AS broward_homes_sold, (erie.homes_sold - broward.homes_sold) * 100 / broward.homes_sold AS pct_diff FROM Erie_county_data erie JOIN Broward_county_data broward ON erie.period_end = broward.period_end ORDER BY erie.period_end DESC LIMIT 5;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: multi-family homes sold in El Paso texas? [/INST] To answer the user's question, I'll be working with the following tables: redfin_homes_sold. From these tables, I'll be using the following columns: period_end, metric_value, geo_type, property_type, dh_state_name, dh_place_name.\n\nHere is the SQL query:\n\n```sql\nSELECT period_end, metric_value AS homes_sold FROM redfin_homes_sold WHERE geo_type = 'city' AND property_type = 'Multi-family' AND dh_state_name = 'Texas' AND dh_place_name = 'El Paso' ORDER BY period_end DESC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: properties sold 99337 [/INST] To answer the user's question, I'll be working with the following tables: redfin_homes_sold. From these tables, I'll be using the following columns: period_start, period_end, metric_value, geo_type, location_name, dh_state_name, property_type.\n\nHere is the SQL query:\n\n```sql\nSELECT period_start, period_end, metric_value FROM redfin_homes_sold WHERE geo_type='zip' AND location_name = '99337' AND dh_state_name = 'Washington' AND property_type = 'All Residential' ORDER BY period_start DESC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: Which state has the lowest number of houses sold? [/INST] To answer the user's question, I'll be working with the following tables: redfin_homes_sold. From these tables, I'll be using the following columns: period_end, location_name, metric_value, geo_type, property_type.\n\nHere is the SQL query:\n\n```sql\nSELECT period_end, location_name, metric_value FROM redfin_homes_sold WHERE geo_type='state' AND property_type = 'All Residential' ORDER BY period_end DESC, metric_value ASC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: houses sold in Yolo county in 2021 broken down by property type [/INST] To answer the user's question, I'll be working with the following tables: redfin_homes_sold. From these tables, I'll be using the following columns: period_start, property_type, metric_value, geo_type, location_name, dh_state_name.\n\nHere is the SQL query:\n\n```sql\nSELECT period_start, property_type, metric_value FROM redfin_homes_sold WHERE geo_type='county' AND location_name='Yolo' AND dh_state_name='California' AND property_type <> 'All Residential' AND period_start BETWEEN '2021-01-01' AND '2021-12-31' ORDER BY period_start ASC, property_type ASC;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: compare homes sold in spokane vs fort worth since 2022 [/INST] To answer the user's question, I'll be working with the following tables: redfin_homes_sold. From these tables, I'll be using the following columns: period_end, location_name, dh_state_name, metric_value, geo_type, property_type.\n\nHere is the SQL query:\n\n```sql\nSELECT period_end, location_name, dh_state_name, metric_value FROM redfin_homes_sold WHERE geo_type='city' AND property_type = 'All Residential' AND period_end >= '2022-01-01' AND ((location_name='Spokane' AND dh_state_name='Washington') OR (location_name = 'Fort Worth' AND dh_state_name='Texas')) ORDER BY period_end, dh_state_name, location_name;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: what zip code had the highest number of sold properties in Bridgeport county, CT in Oct 2022? [/INST] To answer the user's question, I'll be working with the following tables: redfin_homes_sold. From these tables, I'll be using the following columns: location_name, metric_value, dh_county_name, dh_state_name, property_type, period_start, geo_type.\n\nHere is the SQL query:\n\n```sql\nSELECT location_name, metric_value FROM redfin_homes_sold WHERE dh_county_name = 'Bridgeport' AND dh_state_name = 'Connecticut' AND property_type = 'All Residential' AND period_start='2022-10-01' AND geo_type='zip' ORDER BY metric_value DESC LIMIT 1;\n``` </s>"}
{"text": "<s>[INST] Given the following database, your job is to complete the SQL query given the user's question.\nPut your answe inside the ```sql and ``` tags.\n\nCREATE TABLE renthub_median_rent (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT renthub_test_median_rent_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_sale_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_sale_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_homes_sold (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_homes_sold_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_median_list_price (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_median_list_price_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_inventory (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_inventory_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nCREATE TABLE redfin_new_listings (\n\tperiod_start DATE NOT NULL, \n\tperiod_end DATE NOT NULL, \n\tperiod_type TEXT NOT NULL, \n\tgeo_type TEXT NOT NULL, \n\tproperty_type TEXT NOT NULL, \n\tlocation_name TEXT NOT NULL, \n\tdh_state_fips TEXT NOT NULL, \n\tdh_state_name TEXT NOT NULL, \n\tdh_state_abbr CHAR(2) NOT NULL, \n\tdh_county_fips TEXT NOT NULL, \n\tdh_county_name TEXT NOT NULL, \n\tdh_county_fullname TEXT NOT NULL, \n\tdh_place_fips TEXT NOT NULL, \n\tdh_place_name TEXT NOT NULL, \n\tdh_place_fullname TEXT NOT NULL, \n\tdh_city_name TEXT NOT NULL, \n\tdh_city_fullname TEXT NOT NULL, \n\tdh_neighborhood_id TEXT NOT NULL, \n\tdh_neighborhood_name TEXT NOT NULL, \n\tdh_zip_code TEXT NOT NULL, \n\tis_seasonally_adjusted BOOLEAN NOT NULL, \n\tmetric_value DOUBLE PRECISION, \n\thg_date_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()), \n\tCONSTRAINT redfin_new_listings_pkey PRIMARY KEY (period_start, period_end, property_type, location_name, dh_state_fips, dh_county_fips, dh_place_fips, dh_neighborhood_id, dh_zip_code, is_seasonally_adjusted)\n)\n\nQuestion: what was the number of homes sold in New Mexico in Q1 2021? [/INST] To answer the user's question, I'll be working with the following tables: redfin_homes_sold. From these tables, I'll be using the following columns: location_name, period_end, metric_value, geo_type, property_type, period_start.\n\nHere is the SQL query:\n\n```sql\nSELECT location_name, period_end, SUM(metric_value) FROM redfin_homes_sold WHERE geo_type = 'state' AND location_name='New Mexico' AND property_type = 'All Residential' AND period_start BETWEEN '2021-01-01' AND '2021-03-31' GROUP BY location_name, period_end;\n``` </s>"}