|
natural_query,ddl,sql_query |
|
"give me a list of 5 closest primary roads near the property located at 7300 20th St Lot 39, Vero Beach, FL 32966.",05-roads.txt,"with property as ( |
|
SELECT |
|
ST_X(geomout) as lon, |
|
ST_Y(geomout) as lat |
|
from geocode('7300 20th St Lot 39, Vero Beach, FL 32966') |
|
limit 1 |
|
) |
|
select fullname, linearid, geom <-> st_transform(st_setsrid(st_point(property.lon, property.lat), 4326),4269)::geography as dist |
|
from public.tl_2023_us_primaryroads, property |
|
order by dist |
|
Limit 5;" |
|
"which is the closest primary road from 7300 20th St Lot 39, Vero Beach, FL 32966 and how far is it?",05-roads.txt,"with property as ( |
|
SELECT |
|
ST_X(geomout) as lon, |
|
ST_Y(geomout) as lat |
|
from geocode('7300 20th St Lot 39, Vero Beach, FL 32966') |
|
limit 1 |
|
) |
|
select fullname, geom <-> st_transform(st_setsrid(st_point(property.lon, property.lat), 4326),4269)::geography as dist |
|
from public.tl_2023_us_primaryroads, property |
|
order by dist |
|
Limit 1;" |
|
give me a list of 5 longest primary roads in the united states.,05-roads.txt,"select fullname, sum(st_length(geom::geography)) as total_length |
|
from public.tl_2023_us_primaryroads |
|
group by fullname |
|
order by total_length desc |
|
Limit 5;" |
|
how many primary roads are there in the state of florida?,"05-roads.txt,01-state.txt","with state as ( |
|
select geom as state_geom |
|
from public.tl_2023_us_state |
|
where name ilike '%florida%' |
|
limit 1 |
|
) |
|
select count(*) as num_primary_roads |
|
from public.tl_2023_us_primaryroads, state |
|
where st_contains(state_geom, geom);" |
|
which is the longest primary road in florida?,"05-roads.txt,01-state.txt","with state as ( |
|
select geom as state_geom |
|
from public.tl_2023_us_state |
|
where name ilike '%florida%' |
|
limit 1 |
|
) |
|
select fullname, st_length(geom::geography) as length |
|
from public.tl_2023_us_primaryroads, state |
|
where st_contains(state_geom, geom) |
|
order by st_length(geom::geography) desc |
|
limit 1;" |
|
how many primary roads are present in Madison County?,"05-roads.txt,02-county.txt","with county as ( |
|
select geom as county_geom |
|
from public.tl_2023_us_county |
|
where namelsad ilike '%madison%' |
|
limit 1 |
|
) |
|
select count(*) as num_primary_roads |
|
from public.tl_2023_us_primaryroads, county |
|
where st_contains(county_geom, geom) |
|
limit 1; |
|
" |
|
which is the longest primary road in Bronx county?,"05-roads.txt,02-county.txt","with state as ( |
|
select geom as county_geom |
|
from public.tl_2023_us_county |
|
where name ilike '%bronx%' |
|
limit 1 |
|
) |
|
select fullname, st_length(geom::geography) as length |
|
from public.tl_2023_us_primaryroads, state |
|
where st_contains(county_geom, geom) |
|
order by st_length(geom::geography) desc |
|
limit 1;" |
|
what is the total length of primary roads in Florida?,"05-roads.txt,01-state.txt","with state as ( |
|
select geom as state_geom |
|
from public.tl_2023_us_state |
|
where name ilike '%florida%' |
|
limit 1 |
|
) |
|
select sum(st_length(geom::geography)) as road_length_florida |
|
from tl_2023_us_primaryroads, state |
|
where st_contains(state.state_geom, geom); |
|
" |
|
what percentage of the primary roads are in California?,"05-roads.txt,01-state.txt","with state as ( |
|
select geom as state_geom |
|
from public.tl_2023_us_state |
|
where name ilike '%california%' |
|
limit 1 |
|
), |
|
us_total as ( |
|
select count(*) as roads_in_us |
|
from public.tl_2023_us_primaryroads |
|
), |
|
california_total as ( |
|
select count(public.tl_2023_us_primaryroads.gid) as roads_in_california |
|
from public.tl_2023_us_primaryroads, state |
|
where st_contains(state.state_geom, public.tl_2023_us_primaryroads.geom) |
|
) |
|
select (us_total.roads_in_us::float / california_total.roads_in_california::float) as percentage |
|
from us_total, california_total" |
|
in which state does I-77 highway lie?,"05-roads.txt,01-state.txt","with road as ( |
|
select geom as road_geom |
|
from public.tl_2023_us_primaryroads tup |
|
where fullname ilike '%I- 77%' |
|
limit 1 |
|
) |
|
select name |
|
from public.tl_2023_us_state, road |
|
where st_contains(geom, road.road_geom) |
|
limit 1;" |
|
which is the biggest metropolitan city in US?,04-metropolitan.txt,"select geoid, name, st_area(geom::geography) * 0.3048 ^ 2 as area_sqm |
|
from public.tl_2023_us_cbsa |
|
where lsad = 'M1' |
|
order by st_area(geom::geography) desc |
|
limit 1;" |
|
What is the area of New York metropolitan city?,04-metropolitan.txt,"select geoid, name, st_area(geom::geography) * 0.3048 ^ 2 as area_sqm |
|
from public.tl_2023_us_cbsa |
|
where name ilike '%New York%';" |
|
"Is the 8336 104th Ct, Vero Beach, FL 32967 located in a metropolitan statistical area?",04-metropolitan.txt,"with property as ( |
|
SELECT |
|
ST_X(geomout) as lon, |
|
ST_Y(geomout) as lat |
|
from geocode('8336 104th Ct, Vero Beach, FL 32967') |
|
limit 1 |
|
) |
|
select geoid, name |
|
from tl_2023_us_cbsa, property |
|
where st_contains(geom, st_transform(st_setsrid(st_point(property.lon, property.lat), 4326),4269));" |
|
How many metropolitan statistical areas are in Florida state?,"04-metropolitan.txt,01-state.txt","with florida_state as ( |
|
select geom |
|
from tl_2023_us_state |
|
where name ilike '%florida%' |
|
limit 1 |
|
) |
|
select count(*) as num_metro_areas_florida |
|
from tl_2023_us_cbsa, florida_state |
|
where st_contains(florida_state.geom, tl_2023_us_cbsa.geom) and lsad = 'M1';" |
|
"Which is the nearest metropolitan statistical area from the property located at 8336 104th Ct, Vero Beach, FL 32967?",04-metropolitan.txt,"with property as ( |
|
SELECT |
|
ST_X(geomout) as lon, |
|
ST_Y(geomout) as lat |
|
from geocode('8336 104th Ct, Vero Beach, FL 32967') |
|
limit 1 |
|
) |
|
select name, geom <-> st_transform(st_setsrid(st_point(property.lon, property.lat), 4326),4269)::geography as dist |
|
from public.tl_2023_us_cbsa, property |
|
where tl_2023_us_cbsa.lsad = 'M1' |
|
order by dist asc |
|
limit 1;" |
|
List 5 most biggest metropolitan areas in California.,"04-metropolitan.txt,01-state.txt","with cal_state as ( |
|
select geom |
|
from tl_2023_us_state |
|
where name ilike '%california%' |
|
limit 1 |
|
) |
|
select geoid, name, st_area(tl_2023_us_cbsa.geom::geography) * 0.3048 ^ 2 as area_sqm |
|
from tl_2023_us_cbsa, cal_state |
|
where st_contains(cal_state.geom, tl_2023_us_cbsa.geom) and lsad = 'M1' |
|
order by st_area(tl_2023_us_cbsa.geom::geography) desc |
|
limit 5;" |
|
Where is New Haven metropolitan area located?,"04-metropolitan.txt,01-state.txt","with new_haven as ( |
|
select geom |
|
from public.tl_2023_us_cbsa |
|
where name ilike '%new haven%' and lsad = 'M1' |
|
limit 1 |
|
) |
|
select geoid, name |
|
from tl_2023_us_state, new_haven |
|
where st_contains(tl_2023_us_state.geom, new_haven.geom);" |
|
Which state has the highest number of micropolitan areas?,"04-metropolitan.txt,01-state.txt","with state_to_micropolitan as ( |
|
select public.tl_2023_us_cbsa.name as micro_name, |
|
public.tl_2023_us_cbsa.geom as micro_geom, |
|
public.tl_2023_us_state.name as state_name, |
|
public.tl_2023_us_state.geom as state_geom |
|
from public.tl_2023_us_cbsa cross join public.tl_2023_us_state |
|
where tl_2023_us_cbsa.lsad = 'M2' |
|
) |
|
select state_name, count(*) as n_micropolitans |
|
from state_to_micropolitan |
|
where st_contains(state_geom, micro_geom) |
|
group by state_name |
|
order by n_micropolitans desc |
|
limit 1;" |
|
Which state has the highest number of metropolitan areas?,"04-metropolitan.txt,01-state.txt","with state_to_metropolitan as ( |
|
select public.tl_2023_us_cbsa.name as metro_name, |
|
public.tl_2023_us_cbsa.geom as metro_geom, |
|
public.tl_2023_us_state.name as state_name, |
|
public.tl_2023_us_state.geom as state_geom |
|
from public.tl_2023_us_cbsa cross join public.tl_2023_us_state |
|
where tl_2023_us_cbsa.lsad = 'M1' |
|
) |
|
select state_name, count(*) as n_metropolitans |
|
from state_to_metropolitan |
|
where st_contains(state_geom, metro_geom) |
|
group by state_name |
|
order by n_metropolitans desc |
|
limit 1;" |
|
"How far is the property at 8336 104th Ct, Vero Beach, FL 32967 from a major metropolitan city in US?",04-metropolitan.txt,"with property as ( |
|
SELECT |
|
ST_X(geomout) as lon, |
|
ST_Y(geomout) as lat |
|
from geocode('8336 104th Ct, Vero Beach, FL 32967') |
|
limit 1 |
|
) |
|
select name, geom <-> st_transform(st_setsrid(st_point(property.lon, property.lat), 4326),4269)::geography as dist |
|
from public.tl_2023_us_cbsa, property |
|
where tl_2023_us_cbsa.lsad = 'M1' |
|
order by dist asc |
|
limit 1;" |
|
List out all the metropolitan and micropolitan areas in the state of California.,"04-metropolitan.txt,01-state.txt"," |
|
with cal_state as ( |
|
select geom |
|
from tl_2023_us_state |
|
where name ilike '%california%' |
|
limit 1 |
|
) |
|
select geoid, name, lsad |
|
from tl_2023_us_cbsa, cal_state |
|
where st_contains(cal_state.geom, tl_2023_us_cbsa.geom);" |
|
List out all the primary roads that pass through Mansfield Metropolitan Area.,"04-metropolitan.txt,05-roads.txt","with mansfield_metro as ( |
|
select name, geom |
|
from tl_2023_us_cbsa |
|
where name ilike '%mansfield%' and lsad = 'M1' |
|
limit 1 |
|
) |
|
select tl_2023_us_primaryroads.fullname |
|
from public.tl_2023_us_primaryroads, mansfield_metro |
|
where st_intersects(mansfield_metro.geom, tl_2023_us_primaryroads.geom)" |
|
How many primary roads pass through Mansfield Metropolitan area.,"04-metropolitan.txt,05-roads.txt","with mansfield_metro as ( |
|
select name, geom |
|
from tl_2023_us_cbsa |
|
where name ilike '%mansfield%' and lsad = 'M1' |
|
limit 1 |
|
) |
|
select count(distinct tl_2023_us_primaryroads.fullname) as n_primaryroads |
|
from public.tl_2023_us_primaryroads, mansfield_metro |
|
where st_intersects(mansfield_metro.geom, tl_2023_us_primaryroads.geom);" |
|
Which is the smallest metropolitan area in US?,04-metropolitan.txt,"select geoid, name, st_area(tl_2023_us_cbsa.geom::geography) * 0.3048 ^ 2 as area_sqm |
|
from public.tl_2023_us_cbsa |
|
where lsad = 'M1' |
|
order by st_area(tl_2023_us_cbsa.geom::geography) asc |
|
limit 1;" |
|
Which county has the highest number of micropolitan areas?,"04-metropolitan.txt,02-county.txt","with county_to_micropolitan as ( |
|
select public.tl_2023_us_cbsa.name as micro_name, |
|
public.tl_2023_us_cbsa.geom as micro_geom, |
|
public.tl_2023_us_county.name as county_name, |
|
public.tl_2023_us_county.geom as county_geom |
|
from public.tl_2023_us_cbsa cross join public.tl_2023_us_county |
|
where tl_2023_us_cbsa.lsad = 'M2' |
|
) |
|
select county_name, count(*) as n_micropolitans |
|
from county_to_micropolitan |
|
where st_contains(county_geom, micro_geom) |
|
group by county_name |
|
order by n_micropolitans desc |
|
limit 1;" |
|
What is the total count of metropolitan areas in US?,04-metropolitan.txt,"select count(*) as n_metropolitans |
|
from tl_2023_us_cbsa |
|
where lsad = 'M1';" |
|
Provide me a list of US states with its metropolitan areas count.,"04-metropolitan.txt,01-state.txt","with state_to_metropolitan as ( |
|
select public.tl_2023_us_cbsa.name as metro_name, |
|
public.tl_2023_us_cbsa.geom as metro_geom, |
|
public.tl_2023_us_state.name as state_name, |
|
public.tl_2023_us_state.geom as state_geom |
|
from public.tl_2023_us_cbsa cross join public.tl_2023_us_state |
|
where tl_2023_us_cbsa.lsad = 'M1' |
|
) |
|
select state_name, count(*) |
|
from state_to_metropolitan |
|
where st_contains(state_geom, metro_geom) |
|
group by state_name;" |
|
What is the total count of micropolitan areas in US?,04-metropolitan.txt,"select count(*) as n_micropolitans |
|
from tl_2023_us_cbsa |
|
where lsad = 'M2';" |
|
Which is the smallest metropolitan area in Florida?,04-metropolitan.txt,"select geoid, name |
|
from tl_2023_us_cbsa |
|
where lsad = 'M1' |
|
order by st_area(geom::geography) asc |
|
limit 1;" |
|
Which are the closest metropolitan cities in Florida?,04-metropolitan.txt,"with florida as ( |
|
select name, geom |
|
from tl_2023_us_state |
|
where name ilike '%florida%' |
|
limit 1 |
|
) |
|
select t1.name as area_1, t2.name as area_2, t1.geom::geography <-> t2.geom::geography as distance |
|
from tl_2023_us_cbsa as t1 cross join tl_2023_us_cbsa as t2, florida |
|
where t1.lsad = 'M1' and t2.lsad = 'M1' and st_contains(florida.geom, t1.geom) and st_contains(florida.geom, t2.geom) |
|
and t1.geoid <> t2.geoid |
|
order by t1.geom <-> t2.geom asc |
|
limit 5;" |
|
What are the neighboring states of Florida?,01-state.txt,"with florida as ( |
|
select name, geom |
|
from tl_2023_us_state |
|
where name ilike '%florida%' |
|
limit 1 |
|
) |
|
select tl_2023_us_state.name |
|
from public.tl_2023_us_state, florida |
|
where st_intersects(florida.geom, tl_2023_us_state.geom) and florida.name <> tl_2023_us_state.name;" |
|
What is the area of Florida state?,01-state.txt,"select name, st_area(geom::geography) * 0.3048 ^ 2 as area_sqm |
|
from tl_2023_us_state |
|
where name ilike '%florida%';" |
|
Give me a list of 5 biggest US states.,01-state.txt,"select name, st_area(geom::geography) * 0.3048 ^ 2 as area_sqm |
|
from tl_2023_us_state |
|
order by st_area(geom::geography) desc |
|
limit 5;" |
|
Which state has the highest water-to-total-area ratio?,01-state.txt,"select name |
|
from tl_2023_us_state |
|
order by awater / aland desc |
|
limit 1;" |
|
What is the average distance between the states of Michigan and North Dakota?,01-state.txt,"select st_distance(s1.geom, s2.geom) as distance |
|
from tl_2023_us_state as s1 cross join tl_2023_us_state as s2 |
|
where s1.name ilike '%michigan%' and s2.name ilike '%north dakota%' |
|
limit 1;" |
|
Provide me a list of US states with count of primary roads it has.,"01-state.txt,05-roads.txt","select states.name as state_name, count(distinct roads.fullname) |
|
from tl_2023_us_state as states cross join tl_2023_us_primaryroads as roads |
|
where st_contains(states.geom, roads.geom) |
|
group by state_name;" |
|
Which state has the highest number of counties?,"01-state.txt,02-county.txt","select states.name as state_name, count(distinct counties.name) as n_counties |
|
from tl_2023_us_state as states cross join tl_2023_us_county as counties |
|
where st_contains(states.geom, counties.geom) |
|
group by state_name |
|
order by n_counties desc |
|
limit 1;" |
|
List out 10 nearest states from New York.,01-state.txt,"with newyork as ( |
|
select geoid, geom |
|
from tl_2023_us_state |
|
where name ilike '%new york%' |
|
limit 1 |
|
) |
|
select name |
|
from tl_2023_us_state, newyork |
|
where newyork.geoid <> tl_2023_us_state.geoid |
|
order by tl_2023_us_state.geom <-> newyork.geom asc |
|
limit 10;" |
|
"Which US state contains the coordinates 19.2, -155.4?",01-state.txt,"select name |
|
from tl_2023_us_state |
|
where st_contains(geom, st_transform(st_setsrid(st_point(-155.4, 19.2), 4326),4269)) |
|
limit 1;" |
|
Which state is Andrews County located in?,"01-state.txt,02-county.txt","with andrews as ( |
|
select geom |
|
from tl_2023_us_county |
|
where name ilike '%andrews%' |
|
limit 1 |
|
) |
|
select name |
|
from tl_2023_us_state, andrews |
|
where st_contains(tl_2023_us_state.geom, andrews.geom) |
|
limit 1;" |
|
What are the neighboring counties of Andrews County?,02-county.txt,"with andrews as ( |
|
select geoid, geom |
|
from tl_2023_us_county |
|
where name ilike '%andrews%' |
|
limit 1 |
|
) |
|
select name |
|
from tl_2023_us_county, andrews |
|
where st_intersects(tl_2023_us_county.geom, andrews.geom) and andrews.geoid <> tl_2023_us_county.geoid;" |
|
Which county has the highest water-to-total-area ratio?,02-county.txt,"select name |
|
from tl_2023_us_county |
|
order by awater / aland desc |
|
limit 1;" |
|
Provide me a list of US states with total number of counties it has.,"01-state.txt,02-county.txt","select state.name as state_name, count(distinct county.name) as county_name |
|
from tl_2023_us_state as state cross join tl_2023_us_county as county |
|
where st_contains(state.geom, county.geom) |
|
group by state_name;" |
|
Which is the third largest county in United States?,02-county.txt,"select name |
|
from tl_2023_us_county |
|
order by st_area(geom) desc |
|
limit 1 offset 2;" |
|
Which is the largest county that also has a metropolitan area?,"02-county.txt,04-metropolitan.txt","select county.name, st_area(county.geom) |
|
from tl_2023_us_county as county cross join tl_2023_us_cbsa as metro |
|
where metro.lsad = 'M1' and st_contains(county.geom, metro.geom) |
|
order by st_area(county.geom) desc |
|
limit 1;" |
|
How many primary roads does Andrews County have?,"02-county.txt,05-roads.txt","with andrews as ( |
|
select geoid, geom |
|
from tl_2023_us_county |
|
where name ilike '%andrews%' |
|
limit 1 |
|
) |
|
select count(distinct fullname) |
|
from tl_2023_us_primaryroads, andrews |
|
where st_contains(andrews.geom, tl_2023_us_primaryroads.geom); |
|
" |
|
"Which county is the property 8336 104th Ct, Vero Beach, FL 32967 located in?",02-county.txt,"with property as ( |
|
SELECT |
|
ST_X(geomout) as lon, |
|
ST_Y(geomout) as lat |
|
from geocode('8336 104th Ct, Vero Beach, FL 32967') |
|
limit 1 |
|
) |
|
select name |
|
from property, tl_2023_us_county |
|
where st_contains(tl_2023_us_county.geom, st_transform(st_setsrid(st_point(property.lon, property.lat), 4326),4269));" |
|
"List out 5 neighboring counties of the county where property at 8336 104th Ct, Vero Beach, FL 32967 is located?",02-county.txt,"with property as ( |
|
SELECT |
|
ST_X(geomout) as lon, |
|
ST_Y(geomout) as lat |
|
from geocode('8336 104th Ct, Vero Beach, FL 32967') |
|
limit 1 |
|
) |
|
select name |
|
from property, public.tl_2023_us_county |
|
order by tl_2023_us_county.geom <-> st_transform(st_setsrid(st_point(property.lon, property.lat), 4326),4269) asc |
|
limit 5 offset 1;" |
|
Which is the smallest county in Michigan?,"01-state.txt,02-county.txt","with michigan as ( |
|
select geoid, geom |
|
from tl_2023_us_state |
|
where name ilike '%michigan%' |
|
limit 1 |
|
) |
|
select tl_2023_us_county.name |
|
from michigan, tl_2023_us_county |
|
where st_contains(michigan.geom, tl_2023_us_county.geom) |
|
order by st_area(tl_2023_us_county.geom) asc |
|
limit 1;" |
|
40. How many counties are there in California state and what are they?,"01-state.txt,02-county.txt","with california as ( |
|
select geoid, geom |
|
from tl_2023_us_state |
|
where name ilike '%california%' |
|
limit 1 |
|
) |
|
select count(distinct county.name) as n_counties |
|
from california, tl_2023_us_county as county |
|
where st_contains(california.geom, county.geom);" |
|
What is the total length of coastline in Florida?,"01-state.txt,03-coastline.txt","with florida as ( |
|
select geoid, geom |
|
from tl_2023_us_state |
|
where name ilike '%florida%' |
|
limit 1 |
|
) |
|
select sum(st_length(coastline.geom::geography))/1000 as total_length_km |
|
from florida, tl_2023_us_coastline as coastline |
|
where st_intersects(florida.geom, coastline.geom);" |
|
Which state has the longest coastline?,"01-state.txt,03-coastline.txt","select state.name, sum(st_length(coastline.geom::geography))/1000 as coastline_len_km |
|
from tl_2023_us_state as state cross join tl_2023_us_coastline as coastline |
|
where st_intersects(state.geom, coastline.geom) |
|
group by state.name |
|
order by sum(st_length(coastline.geom::geography)) desc |
|
limit 1;" |
|
Which is the longest coastline in Florida?,"01-state.txt,02-county.txt,03-coastline.txt","with florida as ( |
|
select geoid, geom |
|
from tl_2023_us_state |
|
where name ilike '%florida%' |
|
limit 1 |
|
) |
|
select coastline.name, sum(st_length(coastline.geom::geography))/1000 as length_km |
|
from florida, public.tl_2023_us_coastline as coastline |
|
where st_contains(florida.geom, coastline.geom) |
|
group by coastline.name |
|
order by length_km desc |
|
limit 1;" |
|
List out counties in Florida are exposed to a sea/ocean.,"01-state.txt,03-coastline.txt","with florida as ( |
|
select geoid, geom |
|
from tl_2023_us_state |
|
where name ilike '%florida%' |
|
limit 1 |
|
) |
|
select county.name, count(distinct coastline.name) |
|
from public.tl_2023_us_county as county cross join public.tl_2023_us_coastline as coastline, florida |
|
where st_intersects(county.geom, coastline.geom) and st_contains(florida.geom, county.geom) |
|
group by county.name;" |
|
How many US states are exposed to a sea/ocean?,"01-state.txt,03-coastline.txt","select state.name |
|
from tl_2023_us_state as state cross join tl_2023_us_coastline as coastline |
|
where st_intersects(state.geom, coastline.geom) |
|
group by state.name;" |
|
How many US counties are exposed to sea?,"02-county.txt,03-coastline.txt","select count(distinct county.name) |
|
from tl_2023_us_county as county cross join tl_2023_us_coastline as coastline |
|
where st_intersects(county.geom, coastline.geom);" |
|
Which is the largest landlocked state in US?,"01-state.txt,03-coastline.txt","with states_with_coastline as ( |
|
select distinct state.name |
|
from tl_2023_us_state as state cross join tl_2023_us_coastline as coastline |
|
where st_contains(state.geom, coastline.geom) |
|
) |
|
select state.name, st_area(state.geom::geography) |
|
from tl_2023_us_state as state, states_with_coastline |
|
where state.name not in (select name from states_with_coastline) |
|
order by st_area(state.geom) desc |
|
limit 1;" |
|
Which is the largest landlocked county in US?,"02-county.txt,03-coastline.txt","with county_with_coastline as ( |
|
select distinct county.name |
|
from tl_2023_us_county as county cross join tl_2023_us_coastline as coastline |
|
where st_contains(county.geom, coastline.geom) |
|
) |
|
select county.name, st_area(county.geom::geography) |
|
from tl_2023_us_county as county, county_with_coastline |
|
where county.name not in (select name from county_with_coastline) |
|
order by st_area(county.geom) desc |
|
limit 1;" |
|
Which is the name of longest coastline in US?,03-coastline.txt,"select name, sum(st_length(geom::geography)) as tot_length |
|
from tl_2023_us_coastline |
|
group by name |
|
order by tot_length desc |
|
limit 1;" |
|
Which is the shortest coastline in US?,03-coastline.txt,"select name, sum(st_length(geom::geography)) as tot_length |
|
from tl_2023_us_coastline |
|
group by name |
|
order by tot_length asc |
|
limit 1;" |
|
Which is the longest coastline in New York?,"01-state.txt,03-coastline.txt","with new_york as ( |
|
select geoid, geom |
|
from tl_2023_us_state |
|
where name ilike '%new york%' |
|
limit 1 |
|
) |
|
select coastline.name, sum(st_length(coastline.geom::geography)) as length_meter |
|
from tl_2023_us_coastline as coastline, new_york |
|
where st_intersects(new_york.geom, coastline.geom) |
|
group by coastline.name |
|
order by length_meter desc |
|
limit 1;" |
|
What states do the longest coastline in US belong to?,"01-state.txt,03-coastline.txt","with longest_coastline as ( |
|
select name, sum(st_length(geom::geography)) as total_length, st_collect(geom) as geom |
|
from tl_2023_us_coastline |
|
group by name |
|
order by total_length |
|
limit 1 |
|
) |
|
select state.name |
|
from longest_coastline, tl_2023_us_state as state |
|
where st_intersects(longest_coastline.geom, state.geom);" |
|
What is the length of shortest coastline in California?,"01-state.txt,03-coastline.txt","with california as ( |
|
select geoid, geom |
|
from tl_2023_us_state |
|
where name ilike '%california%' |
|
limit 1 |
|
) |
|
select coastline.name, sum(st_length(coastline.geom::geography))/1000 as length_km |
|
from tl_2023_us_coastline as coastline, california |
|
where st_intersects(california.geom, coastline.geom) |
|
group by coastline.name |
|
order by sum(st_length(coastline.geom::geography)) asc |
|
limit 1;" |
|
What is the length of longest coastline in California?,"01-state.txt,03-coastline.txt","with california as ( |
|
select geoid, geom |
|
from tl_2023_us_state |
|
where name ilike '%california%' |
|
limit 1 |
|
) |
|
select coastline.name, sum(st_length(coastline.geom::geography))/1000 as length_km |
|
from tl_2023_us_coastline as coastline, california |
|
where st_intersects(california.geom, coastline.geom) |
|
group by coastline.name |
|
order by sum(st_length(coastline.geom::geography)) desc |
|
limit 1;" |
|
What is the average length of a coastline in US?,03-coastline.txt,"with coastlines as ( |
|
select coastline.name, sum(st_length(coastline.geom::geography))/1000 as length_km |
|
from tl_2023_us_coastline as coastline |
|
group by coastline.name |
|
) |
|
select avg(coastlines.avg_length_km) |
|
from coastlines;" |
|
What is the average length of a coastline in Florida?,"01-state.txt,03-coastline.txt","with florida as ( |
|
select geoid, geom |
|
from tl_2023_us_state |
|
where name ilike '%florida%' |
|
limit 1 |
|
), |
|
coastlines as ( |
|
select coastline.name, sum(st_length(coastline.geom::geography))/1000 as length_km |
|
from tl_2023_us_coastline as coastline, florida |
|
where st_intersects(florida.geom, coastline.geom) |
|
group by coastline.name |
|
) |
|
select avg(coastlines.length_km) |
|
from coastlines;" |
|
"How far is the nearest coastline from the property located at 8336 104th Ct, Vero Beach, FL 32967?",,"with property as ( |
|
SELECT |
|
ST_X(geomout) as lon, |
|
ST_Y(geomout) as lat |
|
from geocode('8336 104th Ct, Vero Beach, FL 32967') |
|
limit 1 |
|
) |
|
select coastline.name, (geom <-> st_transform(st_setsrid(st_point(property.lon, property.lat), 4326),4269)::geography) / 1000 as dist_km |
|
from property, tl_2023_us_coastline as coastline |
|
order by dist_km asc |
|
limit 1;" |
|
"Is there any coastline within 1000 km radius of the location 8336 104th Ct, Vero Beach, FL 32967?",03-coastline.txt,"with property as ( |
|
SELECT |
|
ST_X(geomout) as lon, |
|
ST_Y(geomout) as lat |
|
from geocode('8336 104th Ct, Vero Beach, FL 32967') |
|
limit 1 |
|
) |
|
select coastline.name, (geom <-> st_transform(st_setsrid(st_point(property.lon, property.lat), 4326),4269)::geography) / 1000 as dist_km |
|
from property, tl_2023_us_coastline as coastline |
|
order by dist_km asc |
|
limit 1;" |
|
How far is the nearest coastline from the state of Nevada?,"01-state.txt,03-coastline.txt","with nevada as ( |
|
select geoid, geom |
|
from tl_2023_us_state |
|
where name ilike '%nevada%' |
|
limit 1 |
|
) |
|
select coastline.name, (nevada.geom <-> coastline.geom) / 1000 as dist_km |
|
from nevada, tl_2023_us_coastline as coastline |
|
order by dist_km asc |
|
limit 1;" |
|
Where is Stone Ranch military resident located?,"01-state.txt,06-military.txt","with stone_ranch as ( |
|
select geom |
|
from tl_2023_us_mil |
|
where fullname ilike '%stone ranch%' |
|
limit 1 |
|
) |
|
select name |
|
from tl_2023_us_state as state, stone_ranch |
|
where st_contains(state.geom, stone_ranch.geom);" |
|
Which state has the highest no of military residential areas?,"01-state.txt,06-military.txt","select state.name, count(military_areas.fullname) as num_military_areas |
|
from tl_2023_us_state as state cross join tl_2023_us_mil as military_areas |
|
where st_contains(state.geom, military_areas.geom) |
|
group by state.name |
|
order by num_military_areas desc |
|
limit 1;" |
|
Which is the largest military installation area?,06-military.txt,"select fullname |
|
from tl_2023_us_mil |
|
order by st_area(geom) |
|
limit 1;" |
|
How many military installation areas are present in California?,"01-state.txt,06-military.txt","with california as ( |
|
select geoid, geom |
|
from tl_2023_us_state |
|
where name ilike '%california%' |
|
limit 1 |
|
) |
|
select count(fullname) as num_military_areas |
|
from public.tl_2023_us_mil as military_areas, california |
|
where st_contains(california.geom, military_areas.geom);" |
|
Which county has the highest number of military installations?,"02-county.txt,06-military.txt","select county.name, count(military_areas.fullname) as num_military_areas |
|
from tl_2023_us_county as county cross join tl_2023_us_mil as military_areas |
|
where st_contains(county.geom, military_areas.geom) |
|
group by county.name |
|
order by num_military_areas desc |
|
limit 1;" |
|
Provide me a list of all military installations in California with their areas.,"01-state.txt,06-military.txt","with california as ( |
|
select geoid, geom |
|
from tl_2023_us_state |
|
where name ilike '%california%' |
|
limit 1 |
|
) |
|
select military_areas.fullname, st_area(military_areas.geom::geography) * 0.3048 ^ 2 as area_sqm |
|
from public.tl_2023_us_mil as military_areas, california |
|
where st_contains(california.geom, military_areas.geom);" |
|
Which is the smallest military installation in US?,06-military.txt,"select fullname, st_area(geom::geography) * 0.3048 ^ 2 as area_sqm |
|
from tl_2023_us_mil |
|
order by st_area(geom) asc |
|
limit 1;" |
|
"How far is the nearest military installation from 8336 104th Ct, Vero Beach, FL 32967?",06-military.txt,"with property as ( |
|
SELECT |
|
ST_X(geomout) as lon, |
|
ST_Y(geomout) as lat |
|
from geocode('8336 104th Ct, Vero Beach, FL 32967') |
|
limit 1 |
|
) |
|
select fullname, military_areas.geom <-> st_transform(st_setsrid(st_point(property.lon, property.lat), 4326),4269)::geography as dist |
|
from property, public.tl_2023_us_mil as military_areas |
|
order by dist asc |
|
limit 1;" |
|
"Are there any military installation within 1000km radius of 8336 104th Ct, Vero Beach, FL 32967?",06-military.txt,"with property as ( |
|
SELECT |
|
ST_X(geomout) as lon, |
|
ST_Y(geomout) as lat |
|
from geocode('8336 104th Ct, Vero Beach, FL 32967') |
|
limit 1 |
|
) |
|
select fullname, (military_areas.geom <-> st_transform(st_setsrid(st_point(property.lon, property.lat), 4326),4269)::geography)/1000 as dist_km |
|
from property, public.tl_2023_us_mil as military_areas |
|
order by dist_km asc |
|
limit 1;" |
|
Which military installation has the highest water area occupancy?,06-military.txt,"select fullname |
|
from tl_2023_us_mil |
|
order by awater desc |
|
limit 1;" |
|
What percentage of military installations are purely based on land?,06-military.txt,"with all_military as ( |
|
select count(*) as total_areas |
|
from tl_2023_us_mil |
|
), |
|
land_military as ( |
|
select count(*) as total_land |
|
from tl_2023_us_mil |
|
where awater = 0 |
|
) |
|
select land_military.total_land::float / all_military.total_areas::float as percent_military |
|
from all_military, land_military;" |
|
Which county is Ft Riley located in?,"02-county.txt,06-military.txt","with fort_riley as ( |
|
select geom |
|
from tl_2023_us_mil |
|
where fullname ilike '%fort riley%' |
|
limit 1 |
|
) |
|
select county.name |
|
from public.tl_2023_us_county as county, fort_riley |
|
where st_contains(county.geom, fort_riley.geom);" |
|
Which military installation is the largest in Washington?,"01-state.txt,06-military.txt","with washington as ( |
|
select geoid, geom |
|
from tl_2023_us_state |
|
where name ilike '%washington%' |
|
limit 1 |
|
) |
|
select fullname |
|
from public.tl_2023_us_mil |
|
order by st_area(geom) desc |
|
limit 1;" |
|
Which state has the least number of military installations?,"01-state.txt,06-military.txt","select state.name, count(military.fullname) as num_military_installations |
|
from tl_2023_us_state as state cross join tl_2023_us_mil as military |
|
where st_contains(state.geom, military.geom) |
|
group by state.name |
|
order by num_military_installations asc |
|
limit 1;" |
|
List 5 states with most no of military installations?,"01-state.txt,06-military.txt","select state.name, count(military.fullname) as num_military_installations |
|
from tl_2023_us_state as state cross join tl_2023_us_mil as military |
|
where st_contains(state.geom, military.geom) |
|
group by state.name |
|
order by num_military_installations desc |
|
limit 5;" |
|
How many naval stations are there in Florida?,"01-state.txt,06-military.txt","with florida as ( |
|
select geoid, geom |
|
from tl_2023_us_state |
|
where name ilike '%florida%' |
|
limit 1 |
|
) |
|
select count(*) as num_naval_stations |
|
from florida, public.tl_2023_us_mil as military |
|
where fullname ilike '%naval%' and st_contains(florida.geom, military.geom); |
|
" |
|
How many naval stations are there in entire US?,06-military.txt,"select count(*) as num_naval_stations |
|
from public.tl_2023_us_mil as military |
|
where fullname ilike '%naval%';" |
|
"Are there any coast guard station near 8336 104th Ct, Vero Beach, FL 32967?",06-military.txt,"with property as ( |
|
SELECT |
|
ST_X(geomout) as lon, |
|
ST_Y(geomout) as lat |
|
from geocode('8336 104th Ct, Vero Beach, FL 32967') |
|
limit 1 |
|
) |
|
select tl_2023_us_mil.fullname, (tl_2023_us_mil.geom <-> st_transform(st_setsrid(st_point(property.lon, property.lat), 4326),4269)::geography)/1000 as dist_km |
|
from property, public.tl_2023_us_mil |
|
where fullname ilike '%coast guard%' |
|
order by dist_km asc;" |
|
How many coast guard station are present in Florida?,"01-state.txt,06-military.txt","with florida as ( |
|
select geoid, geom |
|
from tl_2023_us_state |
|
where name ilike '%florida%' |
|
limit 1 |
|
) |
|
select count(distinct fullname) |
|
from florida, public.tl_2023_us_mil |
|
where st_contains(florida.geom, tl_2023_us_mil.geom) and fullname ilike '%coast guard%';" |
|
Which state has the most no of railways?,"01-state.txt,06-military.txt","select state.name as state_name, count(railways.gid) as num_railways |
|
from tl_2023_us_state as state cross join tl_2023_us_rails as railways |
|
where st_contains(state.geom, railways.geom) |
|
group by state.name |
|
order by num_railways desc |
|
limit 1;" |
|
Which is the longest railway in US?,07-railways.txt,"select fullname, sum(st_length(geom::geography))/1000 as length_km |
|
from tl_2023_us_rails as railways |
|
where fullname is not null |
|
group by fullname |
|
order by length_km desc |
|
limit 1;" |
|
Which is the longest railway in Florida?,"01-state.txt,07-railways.txt","with florida as ( |
|
select geoid, geom |
|
from tl_2023_us_state |
|
where name ilike '%florida%' |
|
limit 1 |
|
) |
|
select railways.fullname, sum(st_length(railways.geom::geography))/1000 as length_km |
|
from tl_2023_us_rails as railways, florida |
|
where fullname is not null and st_intersects(florida.geom, railways.geom) |
|
group by fullname |
|
order by length_km desc |
|
limit 1;" |
|
Which is the shortest railway in US?,07-railways.txt,"select fullname, sum(st_length(geom::geography))/1000 as length_km |
|
from tl_2023_us_rails as railways |
|
where fullname is not null |
|
group by fullname |
|
order by length_km asc |
|
limit 1;" |
|
"Are there any railways within 1000km radius of 8336 104th Ct, Vero Beach, FL 32967?",07-railways.txt,"with property as ( |
|
SELECT |
|
ST_X(geomout) as lon, |
|
ST_Y(geomout) as lat |
|
from geocode('8336 104th Ct, Vero Beach, FL 32967') |
|
limit 1 |
|
), |
|
near_railways as ( |
|
select railways.fullname, sum(railways.geom <-> st_transform(st_setsrid(st_point(property.lon, property.lat), 4326),4269)::geography)/1000 as dist_km |
|
from property, tl_2023_us_rails as railways |
|
group by railways.fullname |
|
order by dist_km asc |
|
) |
|
select fullname |
|
from near_railways |
|
where near_railways.dist_km < 1000;" |
|
What is the average length of a railway in United States?,07-railways.txt,"with total_lengths as ( |
|
select fullname, sum(st_length(geom::geography)/1000) as total_length |
|
from tl_2023_us_rails as railways |
|
where fullname is not null |
|
group by fullname |
|
) |
|
select avg(total_lengths.total_length) |
|
from total_lengths;" |
|
What is the length of Illinois Central railway?,07-railways.txt,"select sum(st_length(geom::geography))/1000 as length_km |
|
from tl_2023_us_rails |
|
where fullname ilike '%illinois central';" |
|
How many railways are there in Michigan?,"01-state.txt,07-railways.txt","with michigan as ( |
|
select geom |
|
from tl_2023_us_state |
|
where name ilike '%michigan%' |
|
limit 1 |
|
), |
|
michigan_railways as ( |
|
select railways.fullname |
|
from michigan, public.tl_2023_us_rails as railways |
|
where st_contains(michigan.geom, railways.geom) and railways.fullname is not null |
|
group by railways.fullname |
|
) |
|
select count(*) as num_railways |
|
from michigan_railways;" |
|
List 5 counties with most no of railways.,"02-county.txt,07-railways.txt","select county.name, count(railways.fullname) as num_railways |
|
from tl_2023_us_rails as railways cross join tl_2023_us_county as county |
|
where st_contains(county.geom, railways.geom) |
|
group by railways.fullname, county.name |
|
order by num_railways desc |
|
limit 5;" |
|
Which counties do At and Sf railway pass through?,"02-county.txt,07-railways.txt","select distinct county.name |
|
from tl_2023_us_county as county cross join tl_2023_us_rails as railways |
|
where st_contains(county.geom, railways.geom) and railways.fullname ilike '%at and sf%'" |
|
Give me list of counties and number of railways in state of Florida.,"01-state.txt,02-county.txt,07-railways.txt","with florida as ( |
|
select geoid, geom |
|
from tl_2023_us_state |
|
where name ilike '%florida%' |
|
limit 1 |
|
), |
|
florida_railways as ( |
|
select county.name as county_name, railways.fullname as railway |
|
from tl_2023_us_county as county cross join tl_2023_us_rails as railways, florida |
|
where st_contains(florida.geom, county.geom) and st_contains(county.geom, railways.geom) |
|
group by railways.fullname, county.name |
|
) |
|
select county_name, count(*) |
|
from florida_railways |
|
group by county_name;" |
|
Which is the shortest railway in California?,"01-state.txt,07-railways.txt","with california as ( |
|
select geom |
|
from tl_2023_us_state |
|
where name ilike '%california%' |
|
limit 1 |
|
) |
|
select railways.fullname, sum(st_length(railways.geom::geography))/1000 as length_km |
|
from california, tl_2023_us_rails as railways |
|
where railways.fullname is not null and st_contains(california.geom, railways.geom) |
|
group by railways.fullname |
|
order by length_km asc |
|
limit 1;" |
|
Which county has the highest no of railways?,"02-county.txt,07-railways.txt","with county_railways as ( |
|
select county.name as county_name, rails.fullname as railway_name |
|
from tl_2023_us_county as county cross join tl_2023_us_rails as rails |
|
where st_contains(county.geom, rails.geom) and rails.fullname is not null |
|
), |
|
railway_counts as ( |
|
select county_name, count(railway_name) as railway_count |
|
from county_railways |
|
group by county_name |
|
) |
|
select county_name |
|
from railway_counts |
|
order by railway_count desc |
|
limit 1;" |
|
Which metropolitan city has the highest no of railways?,"04-metropolitan.txt,07-railways.txt","with metro_railways as ( |
|
select metro.name as metro_name, rails.fullname as railway_name |
|
from public.tl_2023_us_cbsa as metro cross join tl_2023_us_rails as rails |
|
where st_contains(metro.geom, rails.geom) and rails.fullname is not null and metro.lsad = 'M1' |
|
), |
|
railway_counts as ( |
|
select metro_name, count(railway_name) as railway_count |
|
from metro_railways |
|
group by metro_name |
|
) |
|
select metro_name |
|
from railway_counts |
|
order by railway_count desc |
|
limit 1;" |
|
What is the average no of railways in a metropolitan area in US?,"04-metropolitan.txt,07-railways.txt","with metro_railways as ( |
|
select metro.name as metro_name, rails.fullname as railway_name |
|
from public.tl_2023_us_cbsa as metro cross join tl_2023_us_rails as rails |
|
where st_contains(metro.geom, rails.geom) and rails.fullname is not null and metro.lsad = 'M1' |
|
), |
|
railway_counts as ( |
|
select metro_name, count(railway_name) as railway_count |
|
from metro_railways |
|
group by metro_name |
|
) |
|
select avg(railway_count) as average_railway_count |
|
from railway_counts;" |
|
What is the average no of railways in a micropolitan area in US?,"04-metropolitan.txt,07-railways.txt","with micro_railways as ( |
|
select micro.name as micro_name, rails.fullname as railway_name |
|
from public.tl_2023_us_cbsa as micro cross join tl_2023_us_rails as rails |
|
where st_contains(micro.geom, rails.geom) and rails.fullname is not null and micro.lsad = 'M2' |
|
), |
|
railway_counts as ( |
|
select micro_name, count(railway_name) as railway_count |
|
from micro_railways |
|
group by micro_name |
|
) |
|
select avg(railway_count) as average_railway_count |
|
from railway_counts;" |
|
Which states do not have any railways?,"01-state.txt,07-railways.txt","with state_with_railways as ( |
|
select distinct state.name |
|
from tl_2023_us_state as state cross join tl_2023_us_rails as railways |
|
where st_contains(state.geom, railways.geom) |
|
group by state.name |
|
) |
|
select distinct state.name as states |
|
from state_with_railways, public.tl_2023_us_state as state |
|
where state.name not in (select name from state_with_railways);" |
|
How many counties in US do not have any railways?,"02-county.txt,07-railways.txt","with county_with_railways as ( |
|
select distinct county.name |
|
from tl_2023_us_county as county cross join tl_2023_us_rails as railways |
|
where st_contains(county.geom, railways.geom) |
|
group by county.name |
|
) |
|
select count(distinct county.name) as n_counties |
|
from county_with_railways, public.tl_2023_us_county as county |
|
where county.name not in (select name from county_with_railways); |
|
" |
|
What is the length of Missouri Pacific railway?,07-railways.txt,"select fullname, sum(st_length(geom::geography))/1000 as length_km |
|
from tl_2023_us_rails |
|
where fullname ilike '%missouri pacific%' and fullname is not null |
|
group by fullname |
|
limit 1;" |
|
Provide me a list of 5 longest railways in US.,07-railways.txt,"select fullname, sum(st_length(geom::geography))/1000 as length_km |
|
from tl_2023_us_rails |
|
where fullname is not null |
|
group by fullname |
|
order by length_km desc |
|
limit 5;" |