Chinastark/bird_dataset huggingface dataset:
Database: bike_share_1
Note: started at refers to start_station_name; start_station_name = 'Steuart at Market'; ended at refers to end_station_name; end_station_name = 'Embarcadero at Sansome'; rides in July 2004 refers to start_date = '7/1/2014 0:00'AND end_date = '7/31/2014 12:59';average ride time = DIVidE(SUM(duration), COUNT(id));
Question: Find the average ride time of the bikes that started at Steuart at Market station and ended at Embarcadero at Sansome station in July 2014.
SQL: SELECT avg(duration) FROM trip WHERE start_date = '7/1/2014%' AND end_date = '7/31/2014%' AND start_station_name = 'Steuart at Market' AND end_station_name = 'Embarcadero at Sansome'
Database: bike_share_1
Note: average maximum temperature = DIVidE(SUM(max_temperature_f), COUNT(date)); average minimum temperature = DIVidE(SUM(min_temperature_f), COUNT(date)); May 2015 refers to date BETWEEN '5/1/2015'AND '5/31/2015';
Question: What are the average maximum and minimum temperatures in May 2015 when the mean humidity is between 65 and 75?
SQL: SELECT avg(max_temperature_f), avg(min_temperature_f) FROM weather WHERE date LIKE '5/%/2015' AND mean_humidity BETWEEN 65 AND 75
Database: bike_share_1
Note: customer refers to subscription_type = 'Customer'; subscribers refers to subscription_type = 'Subscriber'; difference = SUBTRACT(SUM(subscription_type = 'Subscriber' t), SUM(subscription_type = 'Customer')); trip in June 2013 refers to start_date BETWEEN '6/1/2013 0:00'AND '6/31/2013 12:59';
Question: Calculate the difference between the number of customers and the number of subscribers who did the trip in June 2013.
SQL: SELECT sum(iif(subscription_type = 'Subscriber', 1, 0)) - sum(iif(subscription_type = 'Customer', 1, 0)) FROM trip WHERE start_date LIKE '6/%/2013%'
Database: bike_share_1
Note: in 2013 refers to year(date) = 2013; rain and fog ocurred together refers to events = 'Fog-Rain'; id of bikes refers to biked_id;
Question: List the days in 2013 when rain and fog occurred together and find the id of bikes borrowed on these days.
SQL: SELECT weather.date, trip.bike_id FROM trip INNER JOIN weather ON weather.zip_code = trip.zip_code WHERE substr(cast(weather.date AS TEXT), -4) = '2013' AND weather.events = 'Fog-Rain'
Database: bike_share_1
Note: foggy day refers to events = 'fog'; longest ride on a foggy day refers to MAX(duration) where events = 'fog'; mean visibility refers to mean_visibility_miles; mean wind speed refers to mean_wind_speed_mph; weather event refers to events; coordinates refers to (lat, long); start station refers to start_station_id; end station refers to end_station_id;
Question: Find the longest ride on foggy day. What were the mean visibility, mean wind speed, and weather event during that ride? Also, list the coordinates and names of the start and end stations.
SQL: SELECT weather.mean_visibility_miles, weather.mean_wind_speed_mph, weather.events, station.lat, station.long , trip.start_station_name, trip.end_station_name FROM station INNER JOIN trip ON trip.start_station_name = station.name INNER JOIN weather ON weather.zip_code = trip.zip_code WHERE weather.events = 'Fog' ORDER BY trip.duration DESC LIMIT 1
Database: bike_share_1
Note: started at refers to start_station_name; start_station_name = 'Market at 10th'; ended at refers to end_station_name; end_station_name = 'South Van Ness at Market'; in August of 2013 refers to start_date BETWEEN '8/1/2013 0:00' AND '8/31/2013 12:59'; day that had the coldest temperature refers to MIN(min_temperature_f);
Question: For the rides that started at Market at 10th station and ended at South Van Ness at Market station in August of 2013, which day had the coldest temperature?
SQL: SELECT trip.start_date FROM trip INNER JOIN weather ON weather.zip_code = trip.zip_code AND weather.date = substr(cast(trip.start_date AS TEXT), 1, instr(trip.start_date, ' ') - 1) WHERE weather.date LIKE '8/%/2013' AND trip.start_station_name = 'Market at 10th' AND trip.end_station_name = 'South Van Ness at Market' AND weather.min_temperature_f = ( SELECT min(weather.min_temperature_f) FROM trip INNER JOIN weather ON weather.zip_code = trip.zip_code AND weather.date = substr(cast(trip.start_date AS TEXT), 1, instr(trip.start_date, ' ') - 1) WHERE weather.date LIKE '8/%/2013' AND trip.start_station_name = 'Market at 10th' AND trip.end_station_name = 'South Van Ness at Market' )
Database: bike_share_1
Note: rainy days refers to events = 'rain'; longest ride refers to MAX(duration); start station refers to start_station_name; end station refers to end_station_name; duration of the ride refers to duration;
Question: Among the rides during the rainy days, which ride was the longest? List the start station, end station, and duration of this ride.
SQL: SELECT trip.start_station_name, trip.end_station_name, trip.duration FROM trip INNER JOIN weather ON weather.zip_code = trip.zip_code WHERE weather.events = 'Rain' OR weather.events = 'rain' ORDER BY trip.duration DESC LIMIT 1
Database: bike_share_1
Note: rain of more than 0.8 inches refers to events = rain where precipitation_inches>0.8; average ride duration = DIVidE(SUM(duration), COUNT(duration));
Question: Find the average ride duration during the rain of more than 0.8 inches.
SQL: SELECT avg(trip.duration) FROM trip INNER JOIN weather ON weather.zip_code = trip.zip_code WHERE (weather.events = 'Rain' AND weather.precipitation_inches > 0.8) OR (weather.events = 'rain' AND weather.precipitation_inches > 0.8)
Database: bike_share_1
Note: starting stations refers to start_station_name; above average duration trips = DIVidE(SUM(duration), COUNT(main_trip.id))<duration;
Question: List the name and city of starting stations which has an above-average duration trips.
SQL: SELECT DISTINCT trip.start_station_name, station.city FROM trip INNER JOIN station ON station.name = trip.start_station_name WHERE trip.duration > ( SELECT avg(trip.duration) FROM trip LEFT JOIN station ON station.name = trip.start_station_name )
Database: bike_share_1
Note: stations refers to name; San Francisco refers to city = 'San Francisco'; installed in 2004 refers to installation_date like'%2014';
Question: How many stations in San Francisco are installed in 2014?
SQL: SELECT sum(CASE WHEN city = 'San Francisco' AND substr(installation_date, -4) = '2014' THEN 1 ELSE 0 END) FROM station
Database: bike_share_1
Note: in 2006 refers to start_date LIKE'%2006%'; ended at station refers to end_station_name; Mountain View refers to city = 'Mountain View';
Question: In 2006, how many trips ended at stations in Mountain View?
SQL: SELECT count(station.city) FROM trip INNER JOIN station ON station.name = trip.end_station_name WHERE station.city = 'Mountain View' AND trip.start_date LIKE '%2006%'
Database: bike_share_1
Note: longest duration refers to MAX(duration); start station refers to start_station_name;
Question: Which trip id had the longest duration and the start station is in Redwood City?
SQL: SELECT trip.id FROM trip LEFT JOIN station ON station.name = trip.start_station_name WHERE station.city = 'Redwood City' AND trip.duration = ( SELECT max(trip.duration) FROM trip LEFT JOIN station ON station.name = trip.start_station_name WHERE station.city = 'Redwood City' )
Database: bike_share_1
Note: start station refers to start_station_name; installed in 2013 refers to installation_date LIKE '%2013';
Question: Please list bikes id were used in trips which start station were installed in 2013.
SQL: SELECT DISTINCT trip.bike_id FROM trip INNER JOIN station ON station.name = trip.start_station_name WHERE station.installation_date LIKE '%2013'
Database: bike_share_1
Note: ended in refers to end_station_name;
Question: How many trips which subscription types were Subscriber and ended in San Jose city?
SQL: SELECT count(trip.subscription_type) FROM trip INNER JOIN station ON station.name = trip.end_station_name WHERE trip.subscription_type = 'Subscriber' AND station.city = 'San Jose'
Database: bike_share_1
Note: shortest duration refers to MIN(duration); started at the station refers to start_station_name; can hold 15 bikes refers to dock_count = 15;
Question: Which trip had the shortest duration and started at the station that can hold 15 bikes?
SQL: SELECT trip.id FROM trip INNER JOIN station ON station.name = trip.start_station_name WHERE station.dock_count = 15 AND trip.duration = ( SELECT min(trip.duration) FROM trip LEFT JOIN station ON station.name = trip.start_station_name WHERE station.dock_count = 15 )
Database: bike_share_1
Note: started at station refers to start_station_name; San Francisco refers to city = 'San Francisco'; year that had the most number of trips refers to MAX(year(start_date));
Question: Which year had the most number of trips that started at stations in San Francisco?
SQL: SELECT substr(cast(trip.start_date AS TEXT), instr(trip.start_date, ' '), -4) FROM trip INNER JOIN station ON station.name = trip.start_station_name WHERE station.city = 'San Francisco' GROUP BY trip.start_station_name ORDER BY count(trip.id) DESC LIMIT 1
Database: bike_share_1
Note: percentage of trips = DIVidE(COUNT(duration>800), COUNT(duration)) as percentage; San Jose refers to city = 'San Jose'; duration>800;
Question: What is the percentage of trips that started in San Jose and durations were longer than 800 seconds?
SQL: SELECT cast(sum(CASE WHEN trip.duration > 800 THEN 1 ELSE 0 END) AS REAL) * 100 / count(trip.id) FROM trip INNER JOIN station ON station.name = trip.start_station_name WHERE station.city = 'San Jose'
Database: bike_share_1
Note: trips in 2013 refers to start_date like'%2013%'; duration>1000;
Question: How many trips in 2013 had durations longer than 1000 seconds?
SQL: SELECT count(duration) FROM trip WHERE start_date LIKE '%/%/2013%' AND duration > 1000
Database: bike_share_1
Note: started at refers to start_station_name; start_station_name = 'South Van Ness at Market'; average duration = DIVidE(SUM(duration), COUNT(duration));
Question: Please calculate the average duration of trips started at South Van Ness at Market in 2015.
SQL: SELECT avg(duration) FROM trip WHERE start_date LIKE '%2015%' AND start_station_name = 'South Van Ness at Market'
Database: bike_share_1
Note: start station refers to start_station_id; end station refers to end_station_id; start station and end station are the same refers to start_station_id = end_station_id;
Question: How many trips which start station and end station are the same?
SQL: SELECT sum(iif(start_station_id = end_station_id, 1, 0)) FROM trip
Database: bike_share_1
Note: started refers to start_date; the hottest day refers to max_temperature_f;
Question: Please list trips id started on the hottest day.
SQL: SELECT trip.id FROM trip INNER JOIN weather ON weather.zip_code = trip.zip_code ORDER BY weather.max_temperature_f DESC LIMIT 1
Database: bike_share_1
Note: started at refers to start_station_name; start_station_name = 'Mountain View city Hall'; ended on a rainy day refers to end_date where events = 'rain';
Question: Which were the trips that started at Mountain View City Hall and ended on a rainy day?
SQL: SELECT trip.id FROM trip INNER JOIN weather WHERE weather.events = 'Rain' AND trip.start_station_name = 'Mountain View City Hall'
Database: bike_share_1
Note: ended on a foggy day refers to end_date where events = 'fog'; average duration = DIVidE(SUM(duration), COUNT(duration));
Question: What is the average duration of trips that ended on a foggy day?
SQL: SELECT avg(trip.duration) FROM trip INNER JOIN weather ON weather.zip_code = trip.zip_code WHERE weather.events = 'Fog'
Database: bike_share_1
Note: longest trip refers to MAX(duration); started on the day refers to start_date; maximum wind speed refers to max_wind_speed_mph; max_wind_speed_mph = 30;
Question: What was duration of the longest trip started on the day that has a maximum wind speed of 30 mph?
SQL: SELECT trip.duration FROM trip INNER JOIN weather ON weather.zip_code = trip.zip_code WHERE weather.max_wind_speed_mph = 30 ORDER BY trip.duration DESC LIMIT 1
Database: bike_share_1
Note: started at refers to start_station_name; start station_name = 'Market at 4th'; in 2013 refers to start_date like '%2013%'; temperature refers to mean_temperature_f; average temperature = DIVidE(SUM(mean_temperature_f), COUNT(mean_temperature_f));
Question: Please calculate the average temperature of those trips that started at Market at 4th in 2013.
SQL: SELECT avg(weather.mean_temperature_f) FROM trip INNER JOIN weather ON weather.zip_code = trip.zip_code WHERE substr(cast(weather.date AS TEXT), -4) = '2013' AND trip.start_station_name = 'Market at 4th'
Database: bike_share_1
Note: mean humidity refers to mean_humidity;
Question: What was the mean humidity of a trip with id 4275?
SQL: SELECT weather.mean_humidity FROM trip INNER JOIN weather ON weather.zip_code = trip.zip_code WHERE trip.id = 4275
Database: bike_share_1
Note: in 2015 refers to end_date like '%2015%'; percentage = DIVidE(COUNT(events = 'Rain'), COUNT(events));
Question: In 2015, what percentage of trips that had the subscription type was Customer and ended on a rainy day?
SQL: SELECT cast(sum(CASE WHEN weather.events = 'Rain' THEN 1 ELSE 0 END) AS REAL) * 100 / count(trip.id) FROM trip INNER JOIN weather ON weather.zip_code = trip.zip_code WHERE substr(cast(weather.date AS TEXT), -4) = '2015' AND trip.subscription_type = 'Customer'
Database: bike_share_1
Note: installed after August, 2013 refers to year(installation_date)>2013; in San Jose refers to city = 'San Jose';
Question: How many bike stations are installed after August, 2013 in San Jose?
SQL: SELECT count(installation_date) FROM station WHERE city = 'San Jose' AND (substr(cast(installation_date AS TEXT), 1, instr(installation_date, '/') - 1) IN ('8', '9', '10', '11', '12') AND substr(cast(installation_date AS TEXT), -4) = '2013') OR substr(cast(installation_date AS TEXT), -4) > '2013'
Database: bike_share_1
Note: mean temperature in Fahrenheit refers to mean_temperature_f; on 8/29/2013 refers to date = '8/29/2013';
Question: What is the mean temperature in Fahrenheit on 8/29/2013 for the area where the zip code is 94107?
SQL: SELECT sum(iif(zip_code = 94107 AND date = '8/29/2013', mean_temperature_f, 0)) FROM weather
Database: bike_share_1
Note: hottest temperature refers to max_temperatutre_f; coldest temperature refers to min_temperature_f; difference = SUBTRACT(max_temperature_f, min_temperature_f); date = '8/29/2013';
Question: What is the difference between the hottest temperature and the coldest temperature in in Fahrenheit on 8/29/2013 for the area where the zip code is 94107?
SQL: SELECT sum(iif(zip_code = 94107 AND date = '8/29/2013', max_temperature_f - min_temperature_f, 0)) FROM weather
Database: bike_share_1
Note: number of bikes that can be borrowed refers to bikes_available; San Jose Diridon Caltrain station refers to name = 'San Jose Diridon Caltrain station'; time = '2013/8/29 12:06:01';
Question: How many bikes can be borrowed in San Jose Diridon Caltrain Station at 12:06:01 on 2013/8/29?
SQL: SELECT status.bikes_available FROM station INNER JOIN status ON station.id = status.station_id WHERE station.name = 'San Jose Diridon Caltrain Station' AND status.time = '2013/08/29 12:06:01'
Database: bike_share_1
Note: bike is borrowed from refers to start_station_id;
Question: In which city's station is a bike borrowed on trip ID4069?
SQL: SELECT station.city FROM trip INNER JOIN station ON station.name = trip.start_station_name WHERE trip.id = 4069
Database: bike_share_1
Note: started on the days in September, 2013 refers to date LIKE'9%'AND date LIKE'%2013' hottest temperature over 70 degrees Fahrenheit refers to max_temperature_f>70;
Question: How many bike trips started on the days in September, 2013 with the hottest temperature over 70 degrees Fahrenheit in the area where the zip code is 94107?
SQL: SELECT count(trip.id) FROM trip INNER JOIN weather ON weather.zip_code = trip.zip_code WHERE weather.date LIKE '9/%/2013' AND weather.zip_code = 94107 AND weather.max_temperature_f > 70
Database: bike_share_1
Note: starting stations refers to start_station_name; day with a max humidity over 80 refers to max_humidity>80; in 2013 refers to date LIKE'%2013';
Question: Please list the starting stations of the bike trips made on a day with a max humidity over 80 in 2013 in the area where the zip code is 94107.
SQL: SELECT DISTINCT trip.start_station_name FROM trip INNER JOIN weather ON weather.zip_code = trip.zip_code WHERE substr(cast(weather.date AS TEXT), -4) = '2013' AND weather.zip_code = 94107 AND weather.max_temperature_f > 80
Database: bike_share_1
Note: subscriber refers to subscription_type = 'Subscriber'; in August 2013 refers to start_date LIKE'8%' AND start_date LIKE'%2013%'; station that can hold more than 20 bikes refers to dock_count>20;
Question: How many trips made by a subscriber started in August, 2013 from a station that can hold more than 20 bikes?
SQL: SELECT count(trip.id) FROM station INNER JOIN trip ON station.id = trip.start_station_id WHERE trip.subscription_type = 'Subscriber' AND trip.start_date LIKE '8/%/2013%' AND station.dock_count > 20
Database: bike_share_1
Note: location coordinates refers to (lat, long); bike that was borrowed the longest refers to MAX(duration);
Question: What is the location coordinates of the bike station from which the bike for the trip that last the longest was borrowed?
SQL: SELECT station.lat, station.long FROM trip INNER JOIN station ON station.name = trip.start_station_name WHERE trip.duration = ( SELECT max(trip.duration) FROM trip INNER JOIN station ON station.name = trip.start_station_name )
Database: bike_share_1
Note: end station refers to end_station_id; docks that were left refers to docks_available;
Question: How many docks were left at the end station for trip ID4069?
SQL: SELECT sum(status.docks_available) FROM trip INNER JOIN status ON status.station_id = trip.end_station_id WHERE trip.id = 4069
Database: bike_share_1
Note: started on the days with a fog refers to start_date where events = 'fog'; in 2013 refers to date LIKE '%2013'; started from station refers to start_station_name; start_station_name = '2nd at Townsend';
Question: Among the bike trips started on the days with a fog in 2013, how many of those trips started from the station "2nd at Townsend"?
SQL: SELECT count(trip.start_station_name) FROM trip INNER JOIN weather ON weather.zip_code = trip.zip_code WHERE weather.date LIKE '%2013%' AND weather.events = 'Fog' AND trip.start_station_name = '2nd at Townsend' AND weather.zip_code = 94107
Database: bike_share_1
Note: longest duration refers to MAX(duration); starting on a day with a fog refers to start_date where events = 'fog'; in 2013 refers to date LIKE '%2013';
Question: What is the longest duration for a bike trip starting on a day with a fog in 2013?
SQL: SELECT max(trip.duration) FROM trip INNER JOIN weather ON weather.zip_code = trip.zip_code WHERE weather.date LIKE '%2013%' AND weather.events = 'Fog' AND weather.zip_code = 94107
Database: bike_share_1
Note: bike was borrowed from refers to start_station_id; when the bike station was installed refers to installation_date;
Question: When was the bike station from which the bike was borrowed on trip ID4069 installed?
SQL: SELECT station.installation_date FROM trip INNER JOIN station ON station.name = trip.start_station_name WHERE trip.id = 4069
Database: bike_share_1
Note: bike was borrowed from refers to start_station_id; San Francisco refers to city = 'San Francisco'; subscriber refers to subscription_type = 'Subscriber';
Question: How many trips with a bike borrowed from the stations in San Francisco were made by a subscriber?
SQL: SELECT count(trip.id) FROM trip INNER JOIN station ON station.id = trip.start_station_id WHERE station.city = 'San Francisco' AND trip.subscription_type = 'Subscriber'
Database: bike_share_1
Note: hottest temperature refers to max_temperatutre_f; in 2014 refers to date LIKE '%2014'; started from station refers to start_station_name; start_station_name = '2nd at Folsom';
Question: On the day with the hottest temperature ever in 2014, how many bike trips started from the station 2nd at Folsom?
SQL: SELECT count(trip.start_station_name) FROM trip INNER JOIN weather ON weather.zip_code = trip.zip_code WHERE weather.date LIKE '%2014%' AND weather.zip_code = 94107 AND trip.start_station_name = '2nd at Folsom' ORDER BY weather.max_temperature_f DESC LIMIT 1
Database: bike_share_1
Note: average duration = DIVidE(SUM(duration), COUNT(id)); hottest temperature refers to max_temperature_f; in 2014 refers to date LIKE '%2014';
Question: What is the average duration of a bike trip made on the day with the hottest temperature ever in 2014?
SQL: SELECT avg(trip.duration) FROM trip INNER JOIN weather ON weather.zip_code = trip.zip_code WHERE weather.date LIKE '%2014%' AND trip.start_station_name = '2nd at Folsom' AND weather.max_temperature_f = ( SELECT max_temperature_f FROM weather ORDER BY max_temperature_f DESC LIMIT 1 )
Database: bike_share_1
Note: end station refers to end_station_name; starting from refers to start_station_name; start_station_name = '2nd at South Park';
Question: List out all end stations for a bicycle that were making a trip starting from 2nd at South Park station? Only retain the unique value.
SQL: SELECT DISTINCT end_station_name FROM trip WHERE start_station_name = '2nd at South Park'
Database: bike_share_1
Note: rainy days refers to events = 'rain'; Mountain View refers to zip_code = 94041;
Question: How many rainy days were recorded in Mountain View?
SQL: SELECT sum(iif(zip_code = 94041 AND EVENTS = 'Rain', 1, 0)) FROM weather
Database: bike_share_1
Note: total number of bikes that can be hold = MAX(dock_count); before 2014 refers to year(installation_date)<2014;
Question: What is the total number of bikes that can be hold in Redwood City before 2014.
SQL: SELECT sum(CASE WHEN city = 'Redwood City' AND substr(installation_date, -4) < '2014' THEN dock_count ELSE 0 END) num FROM station
Database: bike_share_1
Note: longest trip duration refers to MAX(duration); days conversion = DIVidE(duration, 86400);
Question: What is the longest trip duration according? Convert the it to number of days.
SQL: SELECT max(duration), cast(max(duration) AS REAL) / 86400 FROM trip
Database: bike_share_1
Note: temperature refers to max_temperature_f; March 2013 refers to date like '3/%/2013'; conversion to Celcius = DIVidE(SUBTRACT(max_temperature_f, 32), 1.800) as Celsius1; DIVidE(SUBTRACT(mean_temperature_f, 32), 1.800) as Celsius2; DIVidE(SUBTRACT(min_temperature_f, 32), 1.800) as Celcius3;
Question: Convert all temperature recorded at San Francisco city during August 2013 into degree Celsius.
SQL: SELECT (max_temperature_f - 32) / 1.8000 , (mean_temperature_f - 32) / 1.8000 , (min_temperature_f - 32) / 1.8000 FROM weather WHERE substr(cast(date AS TEXT), 1, instr(date, '/') - 1) = '8' AND substr(cast(date AS TEXT), -4) = '2013' AND zip_code = 94107
Database: bike_share_1
Note: subscriber refers to subscription_type = 'Subscriber'; customer refers to subscription_type = 'customer';starting station refers to start_station_name; ending station refers to end_statio_name; start_station_name = '2nd at South Park' AND end_station_name = '2nd at South Park';
Question: What is the ratio for subscriber to customer given that the starting and the ending stations is 2nd at South Park?
SQL: SELECT cast(sum(iif(subscription_type = 'Subscriber', 1, 0)) AS REAL) / sum(iif(subscription_type = 'Customer', 1, 0)) FROM trip WHERE start_station_name = '2nd at South Park' AND end_station_name = '2nd at South Park'
Database: bike_share_1
Note: station refers to name;
Question: Are all stations with zip code 94107 located in San Francisco city?
SQL: SELECT DISTINCT station.city FROM trip INNER JOIN station ON station.name = trip.start_station_name WHERE trip.zip_code = 94107
Database: bike_share_1
Note: mean temperature refers to mean_temperature_f; mean temperature of 20 degree Celsius refers to DIVidE(SUBTRACT(mean_temperature_f, 32), 1.8) = 20; in 2014 refers to date LIKE'%2015%';
Question: List out all stations name that having a mean temperature 20 degree Celsius in year 2014.
SQL: SELECT DISTINCT trip.start_station_name, trip.end_station_name FROM weather INNER JOIN trip ON weather.zip_code = trip.zip_code WHERE weather.date LIKE '%2014' AND weather.mean_temperature_f = 20 * 1.8 + 32