db_id
stringclasses
68 values
question
stringlengths
24
325
evidence
stringlengths
0
580
SQL
stringlengths
23
728
human_resources
What is the average salary of all employees with a 2 year degree position?
2 year degree refers to educationrequired = '2 year degree'; calculation = DIVIDE(SUM(salary), COUNT(positiontitle))
SELECT AVG(CAST(REPLACE(SUBSTR(T1.salary, 4), ',', '') AS REAL)) FROM employee AS T1 INNER JOIN position AS T2 ON T1.positionID = T2.positionID WHERE T2.educationrequired = '2 year degree'
human_resources
How many male Regional Managers are there?
male refers to gender = 'M'; Regional Managers is a position title
SELECT COUNT(*) FROM employee AS T1 INNER JOIN position AS T2 ON T1.positionID = T2.positionID WHERE T2.positiontitle = 'Regional Manager' AND T1.gender = 'M'
human_resources
Which position has the highest amount of poor performing employees?
poor performing employees refers to performance = 'Poor'; the highest amount of employees refers to MAX(positiontitle)
SELECT T2.positiontitle FROM employee AS T1 INNER JOIN position AS T2 ON T1.positionID = T2.positionID WHERE T1.performance = 'Poor' GROUP BY T2.positiontitle ORDER BY COUNT(T2.positiontitle) DESC LIMIT 1
human_resources
Which position has the highest number of female employees with a 2 year degree?
2 year degree refers to educationrequired = '2 year degree'; female refers to gender = 'F'; the highest number of employees refers to MAX(positionID)
SELECT T2.positiontitle FROM employee AS T1 INNER JOIN position AS T2 ON T1.positionID = T2.positionID WHERE T2.educationrequired = '2 year degree' AND T1.gender = 'F' GROUP BY T2.positiontitle ORDER BY COUNT(T2.positiontitle) DESC LIMIT 1
human_resources
How many Account Representatives are there in Illinois with satisfying performance?
Account Representatives is a position title; satisfying performance mostly refers togood performance
SELECT COUNT(*) FROM employee AS T1 INNER JOIN location AS T2 ON T1.locationID = T2.locationID INNER JOIN position AS T3 ON T3.positionID = T1.positionID WHERE T3.positiontitle = 'Account Representative' AND T1.performance = 'Good' AND T2.state = 'IL'
human_resources
What is the average salary of the worst performing managers?
the worst performing refers to performance = 'Poor'; manager is a positiontitle; average salary refers to AVG(salary)
SELECT AVG(CAST(REPLACE(SUBSTR(T1.salary, 4), ',', '') AS REAL)) FROM employee AS T1 INNER JOIN position AS T2 ON T1.positionID = T2.positionID WHERE T1.performance = 'Poor' AND T2.positiontitle = 'Manager'
human_resources
In which state can you find the highest amount of good performing Account Representatives?
good performing refers to performance = 'Good'; Account Representatives is a positiontitle; highest amount of employee refers to MAX(positionID);
SELECT T2.state FROM employee AS T1 INNER JOIN location AS T2 ON T1.locationID = T2.locationID INNER JOIN position AS T3 ON T3.positionID = T1.positionID WHERE T3.positiontitle = 'Account Representative' AND T1.performance = 'Good' GROUP BY T2.state ORDER BY COUNT(T2.state) DESC LIMIT 1
human_resources
Mention the employee's full name and performance status who got the lowest in salary per year.
full name = firstname, lastname; the lowest salary refers to MIN(salary)
SELECT firstname, lastname, performance FROM employee ORDER BY salary ASC LIMIT 1
human_resources
List the location cities in the Western states.
Western states refers to state = 'CO' OR state = 'UT' OR state = 'CA'; location cities refers to locationcity
SELECT locationcity FROM location WHERE state IN ('CO', 'UT', 'CA')
human_resources
Which city and address has zip code of above 90000?
zip code of above 90000 refers to zipcode > 90000; city refers to locationcity
SELECT locationcity, address FROM location WHERE zipcode > 90000
human_resources
Which positions are suitable with 4 years degree education?
4 years degree education refers to educationrequired = '4 year degree'; positions refers to positiontitle
SELECT positiontitle FROM position WHERE educationrequired = '4 year degree'
human_resources
What is the maximum salary of position "Trainer"?
maximum salary refers to maxsalary; Trainee is a positiontitle
SELECT maxsalary FROM position WHERE positiontitle = 'Trainee'
human_resources
List the full name and social security number of the account representative with average performance.
full name = firstname, lastname; social security number refers to ssn; account representative is a position title; average performance refers to performance = 'Average'
SELECT T1.firstname, T1.lastname, T1.ssn FROM employee AS T1 INNER JOIN position AS T2 ON T1.positionID = T2.positionID WHERE T1.performance = 'Average'
human_resources
When was Emily Wood hired? Mention her position and salary.
Emily Wood is the full name of an employee; full name = firstname, lastname; when was she hired refers to hiredate
SELECT T1.hiredate, T2.positiontitle, T1.salary FROM employee AS T1 INNER JOIN position AS T2 ON T1.positionID = T2.positionID WHERE T1.firstname = 'Emily' AND T1.lastname = 'Wood'
human_resources
What are the maximum and minimum salary range and position title of Bill Marlin?
Bill Marlin is the full name of an employee; full name = firstname, lastname; maximum salary refers to maxsalary; minimum salary refers to minsalary
SELECT T2.maxsalary, T2.minsalary, T2.positiontitle FROM employee AS T1 INNER JOIN position AS T2 ON T1.positionID = T2.positionID WHERE T1.firstname = 'Bill' AND T1.lastname = 'Marlin'
human_resources
List the full names, gender and positions who's location is in New York city.
full name = firstname, lastname; New York city refers to locationcity = 'New York City'
SELECT T1.firstname, T1.lastname, T1.gender, T3.positiontitle FROM employee AS T1 INNER JOIN location AS T2 ON T1.locationID = T2.locationID INNER JOIN position AS T3 ON T3.positionID = T1.positionID WHERE T2.locationcity = 'New York City'
human_resources
Mention the full name, hired date and performance status of the employee whose location is in Utah state.
full name = firstname, lastname; Utah refers to state = 'UT'
SELECT T1.firstname, T1.lastname, T1.hiredate, T1.performance FROM employee AS T1 INNER JOIN location AS T2 ON T1.locationID = T2.locationID WHERE T2.state = 'UT'
human_resources
Among the employees with poor performance, provide the managers' full names, location city, address and its zip code.
poor performance refers to performance = 'Poor'; full name = firstname, lastname; managers is a position title
SELECT T1.firstname, T1.lastname, T2.locationcity, T2.address, T2.zipcode FROM employee AS T1 INNER JOIN location AS T2 ON T1.locationID = T2.locationID INNER JOIN position AS T3 ON T3.positionID = T1.positionID WHERE T3.positiontitle = 'Manager' AND T1.performance = 'Poor'
human_resources
What is the education required to be account representative? Mention account representative full name and salary who got poor in performance status.
account representative is a position title; full name = firstname, lastname; poor performance refers to performance = 'Poor'
SELECT T2.educationrequired, T1.firstname, T1.lastname, T1.salary FROM employee AS T1 INNER JOIN position AS T2 ON T1.positionID = T2.positionID WHERE T1.performance = 'Poor' AND T2.positiontitle = 'Account Representative'
human_resources
Write down the full name, performance status and located city of the employee who's social security number is "767-74-7373".
full name = firstname, lastname; ssn = '767-74-7373'
SELECT T1.firstname, T1.lastname, T2.state, T2.locationcity FROM employee AS T1 INNER JOIN location AS T2 ON T1.locationID = T2.locationID WHERE T1.ssn = '767-74-7373'
human_resources
Describe the employees' full name, positions, located city and office phone number within Colorado state.
full name = firstname, lastname; Colorado state refers to state = 'CO'; positions refers to positiontitle; located city refers to locationcity; office phone number refers to officephone;
SELECT T1.firstname, T1.lastname, T3.positiontitle, T2.locationcity, T2.officephone FROM employee AS T1 INNER JOIN location AS T2 ON T1.locationID = T2.locationID INNER JOIN position AS T3 ON T3.positionID = T1.positionID WHERE T2.state = 'CO'
bike_share_1
Which trip had the longest duration? State the start and end station.
start station refers to start_station_name; end station refers to end_station_name;
SELECT start_station_name, end_station_name FROM trip WHERE duration = ( SELECT MAX(duration) FROM trip )
bike_share_1
What is the percentage of the trip were done by a subscriber?
subscription_type = 'Subscriber'; DIVIDE(COUNT(id where subscription_type = 'Subscriber'), COUNT(id)) as percentage;
SELECT CAST(COUNT(subscription_type) AS REAL) * 100 / ( SELECT COUNT(subscription_type) FROM trip ) FROM trip WHERE subscription_type = 'Subscriber'
bike_share_1
State the final station of bike id 13. Which city was it at?
final station refers to end_station_name where MAX(end_date);
SELECT T2.end_station_id, T1.city FROM station AS T1 INNER JOIN trip AS T2 ON T1.name = T2.end_station_name WHERE T2.bike_id = 13 ORDER BY T2.end_date DESC LIMIT 1
bike_share_1
Which is the station where no bike could not be borrowed form on the 2013/11/03 02:01:01? State the location of the station.
Latitude and longitude coordinates can be used to indicate a location, where latitude refers to lat longtitude refer to long; bikes_available = 0 means no bike can be borrowed; 3/11/2013 02:01:01 refers to time;
SELECT T1.name, T1.long FROM station AS T1 INNER JOIN status AS T2 ON T2.station_id = T1.id WHERE T2.time = '2013/11/03 02:01:01' AND T2.bikes_available = 0
bike_share_1
At what date and time did San Jose Diridon Caltrain Station have most bikes available.
San Jose Diridon Caltrain Station is the name of the station; most bikes available refers to MAX(bikes_available);
SELECT T2.time FROM station AS T1 INNER JOIN status AS T2 ON T2.station_id = T1.id WHERE T1.name = 'San Jose Diridon Caltrain Station' AND T2.bikes_available = ( SELECT MAX(T2.bikes_available) FROM station AS T1 INNER JOIN status AS T2 ON T2.station_id = T1.id WHERE T1.name = 'San Jose Diridon Caltrain Station' )
bike_share_1
Among the trips in August 2013, how many bikes were borrowed from Redwood City.
Redwood City is the name of the city; trips in August 2013 refers to start_date like '8%2013%';
SELECT COUNT(T2.start_date) FROM station AS T1 INNER JOIN trip AS T2 ON T2.start_station_name = T1.name WHERE T2.start_date LIKE '8/%/2013%' AND T1.city = 'Redwood City'
bike_share_1
What is the longest trip duration that started and ended August 29, 2013?
started and ended August 29, 2013 refers to start_date = '8/29/2013' and end_date = '8/29/2013';
SELECT MAX(duration) FROM trip WHERE start_date LIKE '8/29/2013%' AND end_date LIKE '8/29/2013%'
bike_share_1
How long did it take for bike id 426 to reach 2nd at South Park from Market at 4th on 8/29/2013? Indicate the duration in minutes.
duration in minutes refers to DIVIDE(duration, 60 seconds); 2nd at South Park refers to end_station_name; Market at 4th refers to start_station_name; start_date = '8/29/2013'; end_date = '8/29/2013';
SELECT CAST(duration AS REAL) / 60 FROM trip WHERE bike_id = 426 AND end_station_name = '2nd at South Park' AND start_station_name = 'Market at 4th' AND start_date LIKE '8/29/2013%' AND end_date LIKE '8/29/2013%'
bike_share_1
On 8/29/2013, who took the longest to arrive in California Ave Caltrain Station from University and Emerson? Indicate the bike id.
start_date = '8/29/2013'; end_date = '8/29/2013'; end_station_name = 'California Ave Caltrain Station'; start_station_name = 'University and Emerson'; who took the longest to arrive refers to MAX(duration);
SELECT bike_id FROM trip WHERE start_date LIKE '8/29/2013%' AND end_date LIKE '8/29/2013%' AND end_station_name = 'California Ave Caltrain Station' AND start_station_name = 'University and Emerson' AND duration = ( SELECT MAX(duration) FROM trip WHERE start_date LIKE '8/29/2013%' AND end_date LIKE '8/29/2013%' AND end_station_name = 'California Ave Caltrain Station' AND start_station_name = 'University and Emerson' )
bike_share_1
How many stations in San Francico can hold more than 20 bikes?
San Francico is the name of the city; can hold more than 20 bikes implies dock's capacity and refers to dock_count≥20;
SELECT SUM(CASE WHEN city = 'San Francisco' AND dock_count > 20 THEN 1 ELSE 0 END) FROM station
bike_share_1
Which year experienced the most rain?
events = 'Rain'; year refers to YEAR(date);
SELECT SUBSTR(CAST(date AS TEXT), -4) FROM weather GROUP BY SUBSTR(CAST(date AS TEXT), -4) ORDER BY SUM(CASE WHEN events LIKE '%Rain%' OR events LIKE '%rain%' THEN 1 ELSE 0 END) DESC LIMIT 1
bike_share_1
On 11/3/2013, which stations are often empty? Indicate the names of the stations.
time = '11/3/2013'; which stations are empty refers to bikes_available = '0';
SELECT DISTINCT T1.name FROM station AS T1 INNER JOIN status AS T2 ON T2.station_id = T1.id WHERE T2.bikes_available = 0 AND T2.time LIKE '2013/11/03%'
bike_share_1
What is the average duration of bike trips in the city of Palo Alto?
DIVIDE(SUM(duration where city = 'Palo Alto'), COUNT(start_station_id));
SELECT AVG(T1.duration) FROM trip AS T1 LEFT JOIN station AS T2 ON T2.name = T1.start_station_name WHERE T2.city = 'Palo Alto'
bike_share_1
What is the route that has the longest duration? Indicate the city of where the stations are located.
route implies a course taken in getting from start_station_name to end_station_name; the longest duration refers to MAX(duration);
SELECT T1.start_station_name, T1.end_station_name, T2.city FROM trip AS T1 LEFT JOIN station AS T2 ON T2.name = T1.start_station_name WHERE T1.duration = ( SELECT MAX(T1.duration) FROM trip AS T1 LEFT JOIN station AS T2 ON T2.name = T1.start_station_name )
bike_share_1
What is the average duration of trips which are started at Adobe on Almaden station to Ryland Park?
trips refer to id; DIVIDE(SUM(duration where start_station_name = 'Adobe on Almaden', end_station_name = 'Ryland Park'), COUNT(id));
SELECT AVG(duration) FROM trip WHERE start_station_name = 'Adobe on Almaden' AND end_station_name = 'Ryland Park'
bike_share_1
Write down the times when there is no available bike to borrow in a station. List down the stations name and location coordinate.
no available bike to borrow refers to bikes_available = 0; latitude and longitude coordinates can be used to indicate a location;
SELECT T2.time, T1.name, T1.lat, T1.long FROM station AS T1 INNER JOIN status AS T2 ON T2.station_id = T1.id WHERE T2.bikes_available = 0
bike_share_1
List down the trips in which their start and end station are similar. Give me their trip IDs and location coordinates.
start and end station are similar refers to start_station_name = end_station_name; latitude and longitude coordinates can be used to indicate a location;
SELECT T1.id, T2.lat, T2.long FROM trip AS T1 LEFT JOIN station AS T2 ON T2.name = T1.start_station_name WHERE T1.start_station_name = T1.end_station_name
bike_share_1
What are the average maximum and minimum temperatures in May 2015 when the mean humidity is between 65 and 75?
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';
SELECT AVG(max_temperature_f), AVG(min_temperature_f) FROM weather WHERE date LIKE '5/%/2015' AND mean_humidity BETWEEN 65 AND 75
bike_share_1
List the name and city of starting stations which has an above-average duration trips.
starting stations refers to start_station_name; above average duration trips = DIVIDE(SUM(duration), COUNT(main_trip.id))<duration;
SELECT DISTINCT T1.start_station_name, T2.city FROM trip AS T1 INNER JOIN station AS T2 ON T2.name = T1.start_station_name WHERE T1.duration > ( SELECT AVG(T1.duration) FROM trip AS T1 LEFT JOIN station AS T2 ON T2.name = T1.start_station_name )
bike_share_1
How many stations in San Francisco are installed in 2014?
stations refers to name; San Francisco refers to city = 'San Francisco'; installed in 2004 refers to installation_date like'%2014';
SELECT SUM(CASE WHEN city = 'San Francisco' AND SUBSTR(installation_date, -4) = '2014' THEN 1 ELSE 0 END) FROM station
bike_share_1
In 2006, how many trips ended at stations in Mountain View?
in 2006 refers to start_date LIKE'%2006%'; ended at station refers to end_station_name; Mountain View refers to city = 'Mountain View';
SELECT COUNT(T2.city) FROM trip AS T1 INNER JOIN station AS T2 ON T2.name = T1.end_station_name WHERE T2.city = 'Mountain View' AND T1.start_date LIKE '%2006%'
bike_share_1
Which trip id had the longest duration and the start station is in Redwood City?
longest duration refers to MAX(duration); start station refers to start_station_name;
SELECT T1.id FROM trip AS T1 LEFT JOIN station AS T2 ON T2.name = T1.start_station_name WHERE T2.city = 'Redwood City' AND T1.duration = ( SELECT MAX(T1.duration) FROM trip AS T1 LEFT JOIN station AS T2 ON T2.name = T1.start_station_name WHERE T2.city = 'Redwood City' )
bike_share_1
Please list bikes id were used in trips which start station were installed in 2013.
start station refers to start_station_name; installed in 2013 refers to installation_date LIKE '%2013';
SELECT DISTINCT T1.bike_id FROM trip AS T1 INNER JOIN station AS T2 ON T2.name = T1.start_station_name WHERE T2.installation_date LIKE '%2013'
bike_share_1
How many trips which subscription types were Subscriber and ended in San Jose city?
ended in refers to end_station_name;
SELECT COUNT(T1.subscription_type) FROM trip AS T1 INNER JOIN station AS T2 ON T2.name = T1.end_station_name WHERE T1.subscription_type = 'Subscriber' AND T2.city = 'San Jose'
bike_share_1
Which trip had the shortest duration and started at the station that can hold 15 bikes?
shortest duration refers to MIN(duration); started at the station refers to start_station_name; can hold 15 bikes refers to dock_count = 15;
SELECT T1.id FROM trip AS T1 INNER JOIN station AS T2 ON T2.name = T1.start_station_name WHERE T2.dock_count = 15 AND T1.duration = ( SELECT MIN(T1.duration) FROM trip AS T1 LEFT JOIN station AS T2 ON T2.name = T1.start_station_name WHERE T2.dock_count = 15 )
bike_share_1
What is the percentage of trips that started in San Jose and durations were longer than 800 seconds?
percentage of trips = DIVIDE(COUNT(duration>800), COUNT(duration)) as percentage; San Jose refers to city = 'San Jose'; duration>800;
SELECT CAST(SUM(CASE WHEN T1.duration > 800 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.id) FROM trip AS T1 INNER JOIN station AS T2 ON T2.name = T1.start_station_name WHERE T2.city = 'San Jose'
bike_share_1
How many trips in 2013 had durations longer than 1000 seconds?
trips in 2013 refers to start_date like'%2013%'; duration>1000;
SELECT COUNT(duration) FROM trip WHERE start_date LIKE '%/%/2013%' AND duration > 1000
bike_share_1
Please calculate the average duration of trips started at South Van Ness at Market in 2015.
started at refers to start_station_name; start_station_name = 'South Van Ness at Market'; average duration = DIVIDE(SUM(duration), COUNT(duration));
SELECT AVG(duration) FROM trip WHERE start_date LIKE '%2015%' AND start_station_name = 'South Van Ness at Market'
bike_share_1
How many bikes can be borrowed in San Jose Diridon Caltrain Station at 12:06:01 on 2013/8/29?
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'
SELECT T2.bikes_available FROM station AS T1 INNER JOIN status AS T2 ON T1.id = T2.station_id WHERE T1.name = 'San Jose Diridon Caltrain Station' AND T2.time = '2013/08/29 12:06:01'
bike_share_1
In which city's station is a bike borrowed on trip ID4069?
bike is borrowed from refers to start_station_id;
SELECT T2.city FROM trip AS T1 INNER JOIN station AS T2 ON T2.name = T1.start_station_name WHERE T1.id = 4069
bike_share_1
How many trips made by a subscriber started in August, 2013 from a station that can hold more than 20 bikes?
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;
SELECT COUNT(T2.id) FROM station AS T1 INNER JOIN trip AS T2 ON T1.id = T2.start_station_id WHERE T2.subscription_type = 'Subscriber' AND T2.start_date LIKE '8/%/2013%' AND T1.dock_count > 20
bike_share_1
What is the location coordinates of the bike station from which the bike for the trip that last the longest was borrowed?
location coordinates refers to (lat, long); bike that was borrowed the longest refers to MAX(duration);
SELECT T2.lat, T2.long FROM trip AS T1 INNER JOIN station AS T2 ON T2.name = T1.start_station_name WHERE T1.duration = ( SELECT MAX(T1.duration) FROM trip AS T1 INNER JOIN station AS T2 ON T2.name = T1.start_station_name )
bike_share_1
How many docks were left at the end station for trip ID4069?
end station refers to end_station_id; docks that were left refers to docks_available;
SELECT SUM(T2.docks_available) FROM trip AS T1 INNER JOIN status AS T2 ON T2.station_id = T1.end_station_id WHERE T1.ID = 4069
bike_share_1
When was the bike station from which the bike was borrowed on trip ID4069 installed?
bike was borrowed from refers to start_station_id; when the bike station was installed refers to installation_date;
SELECT T2.installation_date FROM trip AS T1 INNER JOIN station AS T2 ON T2.name = T1.start_station_name WHERE T1.id = 4069
bike_share_1
How many trips with a bike borrowed from the stations in San Francisco were made by a subscriber?
bike was borrowed from refers to start_station_id; San Francisco refers to city = 'San Francisco'; subscriber refers to subscription_type = 'Subscriber';
SELECT COUNT(T1.id) FROM trip AS T1 INNER JOIN station AS T2 ON T2.ID = T1.start_station_id WHERE T2.city = 'San Francisco' AND T1.subscription_type = 'Subscriber'
bike_share_1
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.
end station refers to end_station_name; starting from refers to start_station_name; start_station_name = '2nd at South Park';
SELECT DISTINCT end_station_name FROM trip WHERE start_station_name = '2nd at South Park'
bike_share_1
What is the total number of bikes that can be hold in Redwood City before 2014.
total number of bikes that can be hold = MAX(dock_count); before 2014 refers to year(installation_date)<2014;
SELECT SUM(CASE WHEN city = 'Redwood City' AND SUBSTR(installation_date, -4) < '2014' THEN dock_count ELSE 0 END) NUM FROM station
bike_share_1
What is the longest trip duration according? Convert the it to number of days.
longest trip duration refers to MAX(duration); days conversion = DIVIDE(duration, 86400);
SELECT MAX(duration), CAST(MAX(duration) AS REAL) / 86400 FROM trip
bike_share_1
Are all stations with zip code 94107 located in San Francisco city?
station refers to name;
SELECT DISTINCT T2.city FROM trip AS T1 INNER JOIN station AS T2 ON T2.name = T1.start_station_name WHERE T1.zip_code = 94107
bike_share_1
How many bicycle trip were made within San Jose city during August 2013?
during August 2013 refers to start_date like '8/%/2013%';
SELECT COUNT(T2.id) FROM station AS T1 INNER JOIN trip AS T2 ON T2.start_station_name = T1.name WHERE T1.city = 'San Jose' AND T2.start_date LIKE '8/%/2013%' AND T2.start_station_name LIKE 'San Jose%' AND T2.end_station_name LIKE 'San Jose%'
bike_share_1
Is there any intercity trip were made during 2014? If yes, list out the city name for the start and end station.
intercity trip refers to start_station_name! = end_station_name; during 2014 refers to start_date like '%2014%'; start station refers to start_station_name; end station refers to end_station_name;
SELECT T1.start_station_name, T1.end_station_name FROM trip AS T1 LEFT JOIN station AS T2 ON T2.name = T1.start_station_name WHERE T1.start_date LIKE '%/%/2014%' AND T1.start_station_name != T1.end_station_name
bike_share_1
What is the ratio of customer to subscriber that making a trip inside Mountain View city?
customer refers to subscription_type = 'customer'; subscriber refers to subscription_type = 'subscriber'; ratio = MULTIPLY(DIVIDE(COUNT(subscription_type = 'Customer'), COUNT(subscription_type = 'Subscriber'). 1.0)) AS ratio;
SELECT CAST(SUM(CASE WHEN T1.subscription_type = 'Customer' THEN 1 ELSE 0 END) AS REAL) * 100 / SUM(CASE WHEN T1.subscription_type = 'Subscriber' THEN 1 ELSE 0 END) FROM trip AS T1 LEFT JOIN station AS T2 ON T2.name = T1.start_station_name WHERE T2.city = 'Mountain View'
bike_share_1
What is the total trip duration made within Palo Alto city? Convert the duration to hour.
total trip duration to hour = DIVIDE(SUM(duration), 3600);
SELECT CAST(SUM(T1.duration) AS REAL) / 3600 FROM trip AS T1 LEFT JOIN station AS T2 ON T2.name = T1.start_station_name WHERE T2.city = 'Palo Alto'
bike_share_1
Count the number of subscribers who started their trips in Market at 4th.
subsscriber refers to subscription_type = subscriber; started their trips in refers to start_station_name; start_station_name = 'Market at 4th';
SELECT COUNT(CASE WHEN subscription_type = 'Subscriber' AND start_station_name = 'Market at 4th' THEN id END) FROM trip
bike_share_1
List the names of the stations within Mountain View that were installed on 12/31/2013.
Mountain View refers to city = 'Mountain View'; installed on 12/31/2013 refers to installation_date = '12/31/2013';
SELECT name FROM station WHERE installation_date = '12/31/2013' AND city = 'Mountain View'
bike_share_1
How many bikes could Evelyn Park and Ride hold and how many users who started on that station are subscribers?
number of bikes a station can hold refers to SUM(dock_count); Evelyn Park and Ride refers to name = 'Evelyn Park and Ride'; started on the station refers to start_station_name; subscribers refers to subscription_type = 'subscriber';
SELECT SUM(T2.dock_count), COUNT(T1.subscription_type) FROM trip AS T1 INNER JOIN station AS T2 ON T2.name = T1.start_station_name WHERE T2.name = 'Evelyn Park and Ride' AND T1.start_station_name = T2.name AND T1.subscription_type = 'Subscriber'
bike_share_1
What is the percentage ration of customers to subscribers that started their trips within the city of San Francisco?
customer refers to subscription_type = 'customer'; subscriber refers to subscription_type = 'subscriber'; started their trips within refers to start_station_id; percentage ratio = DIVIDE(SUM(subscription_type = 'Customer'), SUM(subscription_type = 'Subscriber')) as percentage;
SELECT CAST(SUM(CASE WHEN T1.subscription_type = 'Customer' THEN 1 ELSE 0 END) AS REAL) * 100 / SUM(CASE WHEN T1.subscription_type = 'Subscriber' THEN 1 ELSE 0 END) FROM trip AS T1 LEFT JOIN station AS T2 ON T2.name = T1.start_station_name WHERE T2.city = 'San Francisco'
bike_share_1
Name the city of the station that trip ID 585842 borrowed a bike and indicate when that station was first installed.
when the station was first installed refers to installation_date;
SELECT T2.city, T2.installation_date FROM trip AS T1 INNER JOIN station AS T2 ON T2.name = T1.start_station_name WHERE T1.id = 585842
bike_share_1
How many stations were installed on the date of 8/16/2013 and how many users on those stations are classified as a customer?
installed on refers to installation_date; installation_date = '8/16/2013'; customers refers to subscription_type = customers;
SELECT COUNT(T1.name) , SUM(CASE WHEN T2.subscription_type = 'Customer' THEN 1 ELSE 0 END) FROM station AS T1 INNER JOIN trip AS T2 ON T2.start_station_name = T1.name WHERE T1.installation_date = '8/16/2013' AND T2.subscription_type = 'Customer'
bike_share_1
Which station did the user who started at Market at 4th station ended their trip at the time of 12:45:00 PM and the date of 8/29/2013 and what is the location coordinates of the ending station?
started at refers to start_station_name; start_station_name = 'Market at 4th'; location coordinates refers to (lat, long);
SELECT T1.name, T1.lat, T1.long FROM station AS T1 INNER JOIN trip AS T2 ON T2.end_station_name = T1.name WHERE T2.start_station_name = 'Market at 4th' AND T2.end_date = '8/29/2013 12:45'
movie_3
What is the description of the film ACADEMY DINOSAUR?
"ACADEMY DINOSAUR" is the title of film
SELECT description FROM film WHERE title = 'ACADEMY DINOSAUR'
movie_3
How many films have a rental duration of over 6 days?
rental duration of over 6 days refers to rental_duration > 6
SELECT COUNT(film_id) FROM film WHERE rental_duration > 6
movie_3
Which film has the longest duration of film screening? Please give its title.
longest duration of film refers to Max(length)
SELECT title FROM film ORDER BY length DESC LIMIT 1
movie_3
Which film has a higher replacement cost, ACE GOLDFINGER or ACADEMY DINOSAUR?
higher replacement cost refers to Max(replacement_cost); 'ACE GOLDFIINGER' and 'ACADEMY DINOSAUR' are both the title of film
SELECT title FROM film WHERE title IN ('ACE GOLDFINGER', 'ACADEMY DINOSAUR') ORDER BY replacement_cost DESC LIMIT 1
movie_3
How many films with the rental rate of $2.99 have the special feature of "Deleted Scenes"?
rental rate of $2.99 refers to rental_rate = 2.99; film refers to title
SELECT COUNT(film_id) FROM film WHERE rental_rate = 2.99 AND special_features = 'Deleted Scenes'
movie_3
Please list the titles of all the films that have more than 2 special features.
more than 2 special features refers to Count(special_features) > 2
SELECT title FROM ( SELECT title, COUNT(special_features) AS num FROM film GROUP BY title ) AS T ORDER BY T.num > 2
movie_3
What is the email address of the staff Jon Stephens?
SELECT email FROM staff WHERE first_name = 'Jon' AND last_name = 'Stephens'
movie_3
Please give the full names of all the active staff.
full name refers to first_name, last_name; active staff refers to active = 1
SELECT first_name, last_name FROM staff WHERE active = 1
movie_3
In which year was the film with the highest replacement cost released?
highest replacement_cost refers to Max (replacement_cost); year refers to release_year
SELECT DISTINCT release_year FROM film WHERE replacement_cost = ( SELECT MAX(replacement_cost) FROM film )
movie_3
Please list the titles of the top 3 films with the highest replacement cost.
highest replacement_cost refers to Max (replacement_cost); film refers to title
SELECT title FROM film WHERE replacement_cost = ( SELECT MAX(replacement_cost) FROM film ) LIMIT 3
movie_3
What is the language of the film ACADEMY DINOSAUR?
"ACADEMY DINOSAUR" is the title of film; language refers to language.name
SELECT T2.name FROM film AS T1 INNER JOIN language AS T2 ON T1.language_id = T2.language_id WHERE T1.title = 'ACADEMY DINOSAUR'
movie_3
How many films are in English?
"English" is the name of language
SELECT COUNT(T1.film_id) FROM film AS T1 INNER JOIN language AS T2 ON T1.language_id = T2.language_id WHERE T2.name = 'English'
movie_3
Please list the titles of all the films starring the actor PENELOPE GUINESS.
SELECT T2.title FROM film_actor AS T1 INNER JOIN film AS T2 ON T1.film_id = T2.film_id INNER JOIN actor AS T3 ON T1.actor_id = T3.actor_id WHERE T3.first_name = 'PENELOPE' AND T3.last_name = 'GUINESS'
movie_3
How many actors have starred in the film ACADEMY DINOSAUR?
"ACADEMY DINOSAUR" is the title of film
SELECT COUNT(T1.actor_id) FROM film_actor AS T1 INNER JOIN film AS T2 ON T1.film_id = T2.film_id WHERE T2.title = 'ACADEMY DINOSAUR'
movie_3
Please list the full names of all the actors that have starred in the film ACADEMY DINOSAUR.
full name refers to first_name, last_name; "ACADEMY DINOSAUR" is the title of film
SELECT T1.first_name, T1.last_name FROM actor AS T1 INNER JOIN film_actor AS T2 ON T1.actor_id = T2.actor_id INNER JOIN film AS T3 ON T2.film_id = T3.film_id WHERE T3.title = 'ACADEMY DINOSAUR'
movie_3
Please give the title of the film starring PENELOPE GUINESS and has the highest replacement cost.
highest replacement cost refers to Max (replacement_cost)
SELECT T3.title FROM actor AS T1 INNER JOIN film_actor AS T2 ON T1.actor_id = T2.actor_id INNER JOIN film AS T3 ON T2.film_id = T3.film_id WHERE T1.first_name = 'PENELOPE' AND T1.last_name = 'GUINESS' ORDER BY T3.replacement_cost DESC LIMIT 1
movie_3
Please list the full names of all the actors that have starred in the film with the highest replacement cost.
highest replacement cost refers to Max (replacement_cost); full name refers to first_name, last_name
SELECT first_name, last_name FROM actor AS T1 INNER JOIN film_actor AS T2 ON T1.actor_id = T2.actor_id INNER JOIN film AS T3 ON T2.film_id = T3.film_id ORDER BY T3.replacement_cost DESC LIMIT 1
movie_3
Among the films starring PENELOPE GUINESS, how many of them are in English?
"English" is the name of language
SELECT COUNT(T3.film_id) FROM actor AS T1 INNER JOIN film_actor AS T2 ON T1.actor_id = T2.actor_id INNER JOIN film AS T3 ON T2.film_id = T3.film_id INNER JOIN language AS T4 ON T3.language_id = T4.language_id WHERE T4.name = 'English' AND T1.first_name = 'PENELOPE' AND T1.last_name = 'GUINESS'
movie_3
What is the title of the film with the longest duration time and stars PENELOPE GUINESS?
longest duration of film refers to Max(length)
SELECT T3.title FROM actor AS T1 INNER JOIN film_actor AS T2 ON T1.actor_id = T2.actor_id INNER JOIN film AS T3 ON T2.film_id = T3.film_id WHERE T1.first_name = 'PENELOPE' AND T1.last_name = 'GUINESS' ORDER BY T3.length DESC LIMIT 1
movie_3
Please list the titles of all the films in the category of "Horror".
"Horror" is the name of category
SELECT T1.title FROM film AS T1 INNER JOIN film_category AS T2 ON T1.film_id = T2.film_id INNER JOIN category AS T3 ON T2.category_id = T3.category_id WHERE T3.name = 'Horror'
movie_3
How many films are there under the category of "Horror"?
"Horror" is the name of category
SELECT COUNT(T1.film_id) FROM film_category AS T1 INNER JOIN category AS T2 ON T1.category_id = T2.category_id WHERE T2.name = 'Horror'
movie_3
For how many times has the customer RUTH MARTINEZ rented a film?
times of rented refers to Count(rental_id)
SELECT COUNT(T2.rental_id) FROM customer AS T1 INNER JOIN rental AS T2 ON T1.customer_id = T2.customer_id WHERE T1.first_name = 'RUTH' AND T1.last_name = 'MARTINEZ'
movie_3
Please list the titles of all the films that the customer RUTH MARTINEZ has rented.
SELECT T4.title FROM customer AS T1 INNER JOIN rental AS T2 ON T1.customer_id = T2.customer_id INNER JOIN inventory AS T3 ON T2.inventory_id = T3.inventory_id INNER JOIN film AS T4 ON T3.film_id = T4.film_id WHERE T1.first_name = 'RUTH' AND T1.last_name = 'MARTINEZ'
movie_3
Among the films that the customer RUTH MARTINEZ has rented, what is the title of the one with the highest replacement cost?
highest replacement cost refers to Max(replacement_cost)
SELECT T4.title FROM customer AS T1 INNER JOIN rental AS T2 ON T1.customer_id = T2.customer_id INNER JOIN inventory AS T3 ON T2.inventory_id = T3.inventory_id INNER JOIN film AS T4 ON T3.film_id = T4.film_id WHERE T1.first_name = 'RUTH' AND T1.last_name = 'MARTINEZ' ORDER BY T4.replacement_cost DESC LIMIT 1
movie_3
Please list the full names of all the customers who have rented the film with the highest replacement cost.
full name refers to first_name, last_name; highest replacement cost refers to Max(replacement_cost)
SELECT T1.first_name, T1.last_name FROM customer AS T1 INNER JOIN rental AS T2 ON T1.customer_id = T2.customer_id INNER JOIN inventory AS T3 ON T2.inventory_id = T3.inventory_id INNER JOIN film AS T4 ON T3.film_id = T4.film_id ORDER BY T4.replacement_cost DESC LIMIT 1
movie_3
Please give the full name of the customer that have rented the most films.
full name refers to first_name, last_name; customer who rented the most film refers to Max(count(rental_id))
SELECT T.first_name, T.last_name FROM ( SELECT T1.first_name, T1.last_name, COUNT(T2.rental_id) AS num FROM customer AS T1 INNER JOIN rental AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.first_name, T1.last_name ) AS T ORDER BY T.num DESC LIMIT 1
movie_3
Among the customers who have rented the film ACADEMY DINOSAUR, how many of them are active?
"ACADEMY DINOSAUR" is the title of film; customer refers to customer_id; active refers to active = 1
SELECT COUNT(T1.customer_id) FROM customer AS T1 INNER JOIN rental AS T2 ON T1.customer_id = T2.customer_id INNER JOIN inventory AS T3 ON T2.inventory_id = T3.inventory_id INNER JOIN film AS T4 ON T3.film_id = T4.film_id WHERE T1.active = 1 AND T4.title = 'ACADEMY DINOSAUR'
movie_3
Which film is rented for the most times by the customers? Please give its title.
film refers to title; film rented the most times refers to title where Max(Count(rental_id))
SELECT T.title FROM ( SELECT T1.title, COUNT(T3.rental_id) AS num FROM film AS T1 INNER JOIN inventory AS T2 ON T1.film_id = T2.film_id INNER JOIN rental AS T3 ON T2.inventory_id = T3.inventory_id GROUP BY T1.title ) AS T ORDER BY T.num DESC LIMIT 1
movie_3
Which customer has rented more movies, RUTH MARTINEZ or LINDA WILLIAMS?
rented more movie Max(Count(customer_id)); "RUTH MARTINEZ" and "LINDA WILLIAMS" are both full name of customer
SELECT T.first_name, T.last_name FROM ( SELECT T1.first_name, T1.last_name, COUNT(T1.customer_id) AS num FROM customer AS T1 INNER JOIN rental AS T2 ON T1.customer_id = T2.customer_id WHERE (T1.first_name = 'RUTH' AND T1.last_name = 'MARTINEZ') OR (T1.first_name = 'LINDA' AND T1.last_name = 'WILLIAMS') GROUP BY T1.first_name, T1.last_name ) AS T ORDER BY T.num DESC LIMIT 1