1sf/bird-sql-train-with-schema huggingface dataset:
Database: shipping
Tables: city, customer, driver, truck, shipment
Columns (table index, column name): -1, *, 0, city_id, 0, city_name, 0, state, 0, population, 0, area, 1, cust_id, 1, cust_name, 1, annual_revenue, 1, cust_type, 1, address, 1, city, 1, state, 1, zip, 1, phone, 2, driver_id, 2, first_name, 2, last_name, 2, address, 2, city, 2, state, 2, zip_code, 2, phone, 3, truck_id, 3, make, 3, model_year, 4, ship_id, 4, cust_id, 4, weight, 4, truck_id, 4, driver_id, 4, city_id, 4, ship_date
Question: Give the name of the driver of shipment no.1021.
Evidence: shipment no. 1021 refers to ship_id = 1021; name refers to first_name, last_name
SQL: SELECT T2.first_name, T2.last_name FROM shipment AS T1 INNER JOIN driver AS T2 ON T1.driver_id = T2.driver_id WHERE T1.ship_id = '1021'
Database: shipping
Tables: city, customer, driver, truck, shipment
Columns (table index, column name): -1, *, 0, city_id, 0, city_name, 0, state, 0, population, 0, area, 1, cust_id, 1, cust_name, 1, annual_revenue, 1, cust_type, 1, address, 1, city, 1, state, 1, zip, 1, phone, 2, driver_id, 2, first_name, 2, last_name, 2, address, 2, city, 2, state, 2, zip_code, 2, phone, 3, truck_id, 3, make, 3, model_year, 4, ship_id, 4, cust_id, 4, weight, 4, truck_id, 4, driver_id, 4, city_id, 4, ship_date
Question: Tell the name of the driver who received the shipment on 2017/11/5.
Evidence: shipment on 2017/11/5 refers to ship_date = '2017-11/05'; name refers to first_name, last_name
SQL: SELECT T2.first_name, T2.last_name FROM shipment AS T1 INNER JOIN driver AS T2 ON T1.driver_id = T2.driver_id WHERE T1.ship_date = '2017-11-05'
Database: shipping
Tables: city, customer, driver, truck, shipment
Columns (table index, column name): -1, *, 0, city_id, 0, city_name, 0, state, 0, population, 0, area, 1, cust_id, 1, cust_name, 1, annual_revenue, 1, cust_type, 1, address, 1, city, 1, state, 1, zip, 1, phone, 2, driver_id, 2, first_name, 2, last_name, 2, address, 2, city, 2, state, 2, zip_code, 2, phone, 3, truck_id, 3, make, 3, model_year, 4, ship_id, 4, cust_id, 4, weight, 4, truck_id, 4, driver_id, 4, city_id, 4, ship_date
Question: Show the population of the city which was the destination of shipment no.1398.
Evidence: shipment no. 1398 refers to ship_id = 1398
SQL: SELECT T2.population FROM shipment AS T1 INNER JOIN city AS T2 ON T1.city_id = T2.city_id WHERE T1.ship_id = '1398'
Database: shipping
Tables: city, customer, driver, truck, shipment
Columns (table index, column name): -1, *, 0, city_id, 0, city_name, 0, state, 0, population, 0, area, 1, cust_id, 1, cust_name, 1, annual_revenue, 1, cust_type, 1, address, 1, city, 1, state, 1, zip, 1, phone, 2, driver_id, 2, first_name, 2, last_name, 2, address, 2, city, 2, state, 2, zip_code, 2, phone, 3, truck_id, 3, make, 3, model_year, 4, ship_id, 4, cust_id, 4, weight, 4, truck_id, 4, driver_id, 4, city_id, 4, ship_date
Question: Provide the ship date of the first shipment to customers in South Carolina.
Evidence: "South Carolina" refers to state = 'SC'; first shipment refers to Min(ship_date)
SQL: SELECT MIN(T1.ship_date) FROM shipment AS T1 INNER JOIN customer AS T2 ON T1.cust_id = T2.cust_id WHERE T2.state = 'SC'
Database: shipping
Tables: city, customer, driver, truck, shipment
Columns (table index, column name): -1, *, 0, city_id, 0, city_name, 0, state, 0, population, 0, area, 1, cust_id, 1, cust_name, 1, annual_revenue, 1, cust_type, 1, address, 1, city, 1, state, 1, zip, 1, phone, 2, driver_id, 2, first_name, 2, last_name, 2, address, 2, city, 2, state, 2, zip_code, 2, phone, 3, truck_id, 3, make, 3, model_year, 4, ship_id, 4, cust_id, 4, weight, 4, truck_id, 4, driver_id, 4, city_id, 4, ship_date
Question: For the shipment received by Leszek Kieltyka on 2017/9/25, what was its weight?
Evidence: on 2017/9/25 refers to ship_date = '2017-09-25'
SQL: SELECT T1.weight FROM shipment AS T1 INNER JOIN driver AS T2 ON T1.driver_id = T2.driver_id WHERE T2.first_name = 'Leszek' AND T2.last_name = 'Kieltyka' AND T1.ship_date = '2017-09-25'
Database: shipping
Tables: city, customer, driver, truck, shipment
Columns (table index, column name): -1, *, 0, city_id, 0, city_name, 0, state, 0, population, 0, area, 1, cust_id, 1, cust_name, 1, annual_revenue, 1, cust_type, 1, address, 1, city, 1, state, 1, zip, 1, phone, 2, driver_id, 2, first_name, 2, last_name, 2, address, 2, city, 2, state, 2, zip_code, 2, phone, 3, truck_id, 3, make, 3, model_year, 4, ship_id, 4, cust_id, 4, weight, 4, truck_id, 4, driver_id, 4, city_id, 4, ship_date
Question: What is the area of the destination city of shipment No.1346?
Evidence: shipment no. 1346 refers to ship_id = 1346
SQL: SELECT T2.area FROM shipment AS T1 INNER JOIN city AS T2 ON T1.city_id = T2.city_id WHERE T1.ship_id = '1346'
Database: shipping
Tables: city, customer, driver, truck, shipment
Columns (table index, column name): -1, *, 0, city_id, 0, city_name, 0, state, 0, population, 0, area, 1, cust_id, 1, cust_name, 1, annual_revenue, 1, cust_type, 1, address, 1, city, 1, state, 1, zip, 1, phone, 2, driver_id, 2, first_name, 2, last_name, 2, address, 2, city, 2, state, 2, zip_code, 2, phone, 3, truck_id, 3, make, 3, model_year, 4, ship_id, 4, cust_id, 4, weight, 4, truck_id, 4, driver_id, 4, city_id, 4, ship_date
Question: Provide the weight of the shipment to U-haul Center Of N Syracuse on 2016/9/21.
Evidence: "U-haul Center Of N Syracuse" is the cust_name; on 2016/9/21 refers to ship_date = '2016/09/21'
SQL: SELECT T1.weight FROM shipment AS T1 INNER JOIN customer AS T2 ON T1.cust_id = T2.cust_id WHERE T2.cust_name = 'U-haul Center Of N Syracuse' AND T1.ship_date = '2016-09-21'
Database: shipping
Tables: city, customer, driver, truck, shipment
Columns (table index, column name): -1, *, 0, city_id, 0, city_name, 0, state, 0, population, 0, area, 1, cust_id, 1, cust_name, 1, annual_revenue, 1, cust_type, 1, address, 1, city, 1, state, 1, zip, 1, phone, 2, driver_id, 2, first_name, 2, last_name, 2, address, 2, city, 2, state, 2, zip_code, 2, phone, 3, truck_id, 3, make, 3, model_year, 4, ship_id, 4, cust_id, 4, weight, 4, truck_id, 4, driver_id, 4, city_id, 4, ship_date
Question: Who was the driver of truck no.3 on 2016/9/19? Tell the full name.
Evidence: truck no. 3 refers to truck_id = 3; on 2016/9/19 refers to ship_date = '2016-09-19'; full name refers to first_name, last_name
SQL: SELECT T3.first_name, T3.last_name FROM truck AS T1 INNER JOIN shipment AS T2 ON T1.truck_id = T2.truck_id INNER JOIN driver AS T3 ON T3.driver_id = T2.driver_id WHERE T1.truck_id = '3' AND T2.ship_date = '2016-09-19'
Database: shipping
Tables: city, customer, driver, truck, shipment
Columns (table index, column name): -1, *, 0, city_id, 0, city_name, 0, state, 0, population, 0, area, 1, cust_id, 1, cust_name, 1, annual_revenue, 1, cust_type, 1, address, 1, city, 1, state, 1, zip, 1, phone, 2, driver_id, 2, first_name, 2, last_name, 2, address, 2, city, 2, state, 2, zip_code, 2, phone, 3, truck_id, 3, make, 3, model_year, 4, ship_id, 4, cust_id, 4, weight, 4, truck_id, 4, driver_id, 4, city_id, 4, ship_date
Question: Calculate the population density of the city as the destination of shipment no.1369.
Evidence: shipment no. 1369 refers to ship_id = 1369; population density refers to Divide (area, population)
SQL: SELECT T2.area / T2.population FROM shipment AS T1 INNER JOIN city AS T2 ON T1.city_id = T2.city_id WHERE T1.ship_id = '1369'
Database: shipping
Tables: city, customer, driver, truck, shipment
Columns (table index, column name): -1, *, 0, city_id, 0, city_name, 0, state, 0, population, 0, area, 1, cust_id, 1, cust_name, 1, annual_revenue, 1, cust_type, 1, address, 1, city, 1, state, 1, zip, 1, phone, 2, driver_id, 2, first_name, 2, last_name, 2, address, 2, city, 2, state, 2, zip_code, 2, phone, 3, truck_id, 3, make, 3, model_year, 4, ship_id, 4, cust_id, 4, weight, 4, truck_id, 4, driver_id, 4, city_id, 4, ship_date
Question: What is the average number of shipments done by the Kenworth trucks?
Evidence: "Kenworth" is the make of truck; average = Divide (Count(ship_id where make = 'Kenworth'), Count(truck_id where make = 'Kenworth))
SQL: SELECT CAST(COUNT(T2.ship_id) AS REAL) / COUNT(DISTINCT T1.truck_id) FROM truck AS T1 INNER JOIN shipment AS T2 ON T1.truck_id = T2.truck_id WHERE T1.make = 'Kenworth'
Database: shipping
Tables: city, customer, driver, truck, shipment
Columns (table index, column name): -1, *, 0, city_id, 0, city_name, 0, state, 0, population, 0, area, 1, cust_id, 1, cust_name, 1, annual_revenue, 1, cust_type, 1, address, 1, city, 1, state, 1, zip, 1, phone, 2, driver_id, 2, first_name, 2, last_name, 2, address, 2, city, 2, state, 2, zip_code, 2, phone, 3, truck_id, 3, make, 3, model_year, 4, ship_id, 4, cust_id, 4, weight, 4, truck_id, 4, driver_id, 4, city_id, 4, ship_date
Question: How many pounds did Sue Newell transport during her first shipment?
Evidence: first shipment refers to Min(ship_date); pounds refers to weight
SQL: SELECT T1.weight FROM shipment AS T1 INNER JOIN driver AS T2 ON T1.driver_id = T2.driver_id WHERE T2.first_name = 'Sue' AND T2.last_name = 'Newell' ORDER BY T1.ship_date ASC LIMIT 1
Database: shipping
Tables: city, customer, driver, truck, shipment
Columns (table index, column name): -1, *, 0, city_id, 0, city_name, 0, state, 0, population, 0, area, 1, cust_id, 1, cust_name, 1, annual_revenue, 1, cust_type, 1, address, 1, city, 1, state, 1, zip, 1, phone, 2, driver_id, 2, first_name, 2, last_name, 2, address, 2, city, 2, state, 2, zip_code, 2, phone, 3, truck_id, 3, make, 3, model_year, 4, ship_id, 4, cust_id, 4, weight, 4, truck_id, 4, driver_id, 4, city_id, 4, ship_date
Question: To whom did the company transport its heaviest shipment?
Evidence: heaviest shipment refers to Max(weight)
SQL: SELECT T2.cust_name FROM shipment AS T1 INNER JOIN customer AS T2 ON T1.cust_id = T2.cust_id ORDER BY T1.weight DESC LIMIT 1
Database: shipping
Tables: city, customer, driver, truck, shipment
Columns (table index, column name): -1, *, 0, city_id, 0, city_name, 0, state, 0, population, 0, area, 1, cust_id, 1, cust_name, 1, annual_revenue, 1, cust_type, 1, address, 1, city, 1, state, 1, zip, 1, phone, 2, driver_id, 2, first_name, 2, last_name, 2, address, 2, city, 2, state, 2, zip_code, 2, phone, 3, truck_id, 3, make, 3, model_year, 4, ship_id, 4, cust_id, 4, weight, 4, truck_id, 4, driver_id, 4, city_id, 4, ship_date
Question: What is the full name of the driver who transported the first shipment of the company?
Evidence: first shipment of the company refers to Min(ship_date); full name refers to first_name, last_name
SQL: SELECT T2.first_name, T2.last_name FROM shipment AS T1 INNER JOIN driver AS T2 ON T1.driver_id = T2.driver_id ORDER BY T1.ship_date ASC LIMIT 1
Database: shipping
Tables: city, customer, driver, truck, shipment
Columns (table index, column name): -1, *, 0, city_id, 0, city_name, 0, state, 0, population, 0, area, 1, cust_id, 1, cust_name, 1, annual_revenue, 1, cust_type, 1, address, 1, city, 1, state, 1, zip, 1, phone, 2, driver_id, 2, first_name, 2, last_name, 2, address, 2, city, 2, state, 2, zip_code, 2, phone, 3, truck_id, 3, make, 3, model_year, 4, ship_id, 4, cust_id, 4, weight, 4, truck_id, 4, driver_id, 4, city_id, 4, ship_date
Question: In total, how many shipments were transported to Olympic Camper Sales Inc?
Evidence: "Olympic Camper Sales Inc" is the cust_name
SQL: SELECT COUNT(T2.ship_id) FROM customer AS T1 INNER JOIN shipment AS T2 ON T1.cust_id = T2.cust_id WHERE T1.cust_name = 'Olympic Camper Sales Inc'
Database: shipping
Tables: city, customer, driver, truck, shipment
Columns (table index, column name): -1, *, 0, city_id, 0, city_name, 0, state, 0, population, 0, area, 1, cust_id, 1, cust_name, 1, annual_revenue, 1, cust_type, 1, address, 1, city, 1, state, 1, zip, 1, phone, 2, driver_id, 2, first_name, 2, last_name, 2, address, 2, city, 2, state, 2, zip_code, 2, phone, 3, truck_id, 3, make, 3, model_year, 4, ship_id, 4, cust_id, 4, weight, 4, truck_id, 4, driver_id, 4, city_id, 4, ship_date
Question: How many of the shipments bound for New York City were shipped to Harry's Hot Rod Auto and Truck Accessories?
Evidence: "New York" is the city_name; 'Harry's Hot Rod Auto & Truck Accessories' is the cust_name
SQL: SELECT COUNT(*) FROM customer AS T1 INNER JOIN shipment AS T2 ON T1.cust_id = T2.cust_id INNER JOIN city AS T3 ON T3.city_id = T2.city_id WHERE T3.city_name = 'New York' AND T1.cust_name = 'Harry''s Hot Rod Auto & Truck Accessories'
Database: shipping
Tables: city, customer, driver, truck, shipment
Columns (table index, column name): -1, *, 0, city_id, 0, city_name, 0, state, 0, population, 0, area, 1, cust_id, 1, cust_name, 1, annual_revenue, 1, cust_type, 1, address, 1, city, 1, state, 1, zip, 1, phone, 2, driver_id, 2, first_name, 2, last_name, 2, address, 2, city, 2, state, 2, zip_code, 2, phone, 3, truck_id, 3, make, 3, model_year, 4, ship_id, 4, cust_id, 4, weight, 4, truck_id, 4, driver_id, 4, city_id, 4, ship_date
Question: Among the top 5 heaviest shipments, how many shipments were transported via Mack?
Evidence: heaviest shipment refers to Max(weight); via Mack refers to make = 'Mack'
SQL: SELECT COUNT(T2.ship_id) FROM truck AS T1 INNER JOIN shipment AS T2 ON T1.truck_id = T2.truck_id WHERE T1.make = 'Mack' ORDER BY T2.weight DESC LIMIT 1
Database: shipping
Tables: city, customer, driver, truck, shipment
Columns (table index, column name): -1, *, 0, city_id, 0, city_name, 0, state, 0, population, 0, area, 1, cust_id, 1, cust_name, 1, annual_revenue, 1, cust_type, 1, address, 1, city, 1, state, 1, zip, 1, phone, 2, driver_id, 2, first_name, 2, last_name, 2, address, 2, city, 2, state, 2, zip_code, 2, phone, 3, truck_id, 3, make, 3, model_year, 4, ship_id, 4, cust_id, 4, weight, 4, truck_id, 4, driver_id, 4, city_id, 4, ship_date
Question: What is the full name of the driver who delivered the most shipments to the least populated city?
Evidence: least populated city refers to Min(population); fullname refers to first_name, last_name; most shipment refers to driver_id where Max(Count (ship_id))
SQL: SELECT T1.first_name, T1.last_name FROM driver AS T1 INNER JOIN shipment AS T2 ON T1.driver_id = T2.driver_id INNER JOIN city AS T3 ON T3.city_id = T2.city_id GROUP BY T1.first_name, T1.last_name, T3.population HAVING T3.population = MAX(T3.population) ORDER BY COUNT(*) DESC LIMIT 1
Database: shipping
Tables: city, customer, driver, truck, shipment
Columns (table index, column name): -1, *, 0, city_id, 0, city_name, 0, state, 0, population, 0, area, 1, cust_id, 1, cust_name, 1, annual_revenue, 1, cust_type, 1, address, 1, city, 1, state, 1, zip, 1, phone, 2, driver_id, 2, first_name, 2, last_name, 2, address, 2, city, 2, state, 2, zip_code, 2, phone, 3, truck_id, 3, make, 3, model_year, 4, ship_id, 4, cust_id, 4, weight, 4, truck_id, 4, driver_id, 4, city_id, 4, ship_date
Question: How many shipments with weight of no more than 1,000 pounds were shipped by the oldest truck?
Evidence: weight of no more than 1000 pounds refers to weight < 1000; oldest truck refers to Min (model_year)
SQL: SELECT COUNT(*) FROM truck AS T1 INNER JOIN shipment AS T2 ON T1.truck_id = T2.truck_id WHERE T2.weight < 1000 ORDER BY T1.model_year ASC LIMIT 1
Database: shipping
Tables: city, customer, driver, truck, shipment
Columns (table index, column name): -1, *, 0, city_id, 0, city_name, 0, state, 0, population, 0, area, 1, cust_id, 1, cust_name, 1, annual_revenue, 1, cust_type, 1, address, 1, city, 1, state, 1, zip, 1, phone, 2, driver_id, 2, first_name, 2, last_name, 2, address, 2, city, 2, state, 2, zip_code, 2, phone, 3, truck_id, 3, make, 3, model_year, 4, ship_id, 4, cust_id, 4, weight, 4, truck_id, 4, driver_id, 4, city_id, 4, ship_date
Question: How much is the annual revenue of the customer with the most number of shipments?
Evidence: customer with the most number of shipment refers to cust_id where Max(Count(ship_id))
SQL: SELECT T2.annual_revenue FROM shipment AS T1 INNER JOIN customer AS T2 ON T1.cust_id = T2.cust_id GROUP BY T1.cust_id ORDER BY COUNT(T1.cust_id) DESC LIMIT 1
Database: shipping
Tables: city, customer, driver, truck, shipment
Columns (table index, column name): -1, *, 0, city_id, 0, city_name, 0, state, 0, population, 0, area, 1, cust_id, 1, cust_name, 1, annual_revenue, 1, cust_type, 1, address, 1, city, 1, state, 1, zip, 1, phone, 2, driver_id, 2, first_name, 2, last_name, 2, address, 2, city, 2, state, 2, zip_code, 2, phone, 3, truck_id, 3, make, 3, model_year, 4, ship_id, 4, cust_id, 4, weight, 4, truck_id, 4, driver_id, 4, city_id, 4, ship_date
Question: Among the shipments for Downey, how many shipments were shipped to California in 2016?
Evidence: "Downey" is the city_name; 'California' is the state, whose abbreviation is CA; in 2016 refers to year(ship_date) = 2016,
SQL: SELECT COUNT(*) FROM shipment AS T1 INNER JOIN city AS T2 ON T1.city_id = T2.city_id INNER JOIN customer AS T3 ON T3.cust_id = T1.cust_id WHERE T2.city_name = 'Downey' AND STRFTIME('%Y', T1.ship_date) = '2016' AND T3.state = 'CA'
Database: shipping
Tables: city, customer, driver, truck, shipment
Columns (table index, column name): -1, *, 0, city_id, 0, city_name, 0, state, 0, population, 0, area, 1, cust_id, 1, cust_name, 1, annual_revenue, 1, cust_type, 1, address, 1, city, 1, state, 1, zip, 1, phone, 2, driver_id, 2, first_name, 2, last_name, 2, address, 2, city, 2, state, 2, zip_code, 2, phone, 3, truck_id, 3, make, 3, model_year, 4, ship_id, 4, cust_id, 4, weight, 4, truck_id, 4, driver_id, 4, city_id, 4, ship_date
Question: How many shipments did Holger Nohr transport to North Las Vegas overall?
Evidence: "North Las Vegas" is the city_name
SQL: SELECT COUNT(*) FROM driver AS T1 INNER JOIN shipment AS T2 ON T1.driver_id = T2.driver_id INNER JOIN city AS T3 ON T3.city_id = T2.city_id WHERE T1.first_name = 'Holger' AND T1.last_name = 'Nohr' AND T3.city_name = 'North Las Vegas'
Database: shipping
Tables: city, customer, driver, truck, shipment
Columns (table index, column name): -1, *, 0, city_id, 0, city_name, 0, state, 0, population, 0, area, 1, cust_id, 1, cust_name, 1, annual_revenue, 1, cust_type, 1, address, 1, city, 1, state, 1, zip, 1, phone, 2, driver_id, 2, first_name, 2, last_name, 2, address, 2, city, 2, state, 2, zip_code, 2, phone, 3, truck_id, 3, make, 3, model_year, 4, ship_id, 4, cust_id, 4, weight, 4, truck_id, 4, driver_id, 4, city_id, 4, ship_date
Question: How many shipments were shipped to the most densely populated city?
Evidence: most densely populated city refers to Max(Divide(area, population))
SQL: SELECT COUNT(*) FROM shipment AS T1 INNER JOIN city AS T2 ON T1.city_id = T2.city_id ORDER BY T2.area / T2.population DESC LIMIT 1
Database: shipping
Tables: city, customer, driver, truck, shipment
Columns (table index, column name): -1, *, 0, city_id, 0, city_name, 0, state, 0, population, 0, area, 1, cust_id, 1, cust_name, 1, annual_revenue, 1, cust_type, 1, address, 1, city, 1, state, 1, zip, 1, phone, 2, driver_id, 2, first_name, 2, last_name, 2, address, 2, city, 2, state, 2, zip_code, 2, phone, 3, truck_id, 3, make, 3, model_year, 4, ship_id, 4, cust_id, 4, weight, 4, truck_id, 4, driver_id, 4, city_id, 4, ship_date
Question: Determine the percentage of manufacturers who are from Texas among all of Lorenzo's customers.
Evidence: "Texas" refers to state = 'TX'; 'manufacturer' is the cust_type; percentage = Divide (Count(cust_id where state = 'TX'), Count(cust_id)) * 100
SQL: SELECT CAST(SUM(CASE WHEN cust_type = 'manufacturer' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM customer WHERE state = 'TX'
Database: shipping
Tables: city, customer, driver, truck, shipment
Columns (table index, column name): -1, *, 0, city_id, 0, city_name, 0, state, 0, population, 0, area, 1, cust_id, 1, cust_name, 1, annual_revenue, 1, cust_type, 1, address, 1, city, 1, state, 1, zip, 1, phone, 2, driver_id, 2, first_name, 2, last_name, 2, address, 2, city, 2, state, 2, zip_code, 2, phone, 3, truck_id, 3, make, 3, model_year, 4, ship_id, 4, cust_id, 4, weight, 4, truck_id, 4, driver_id, 4, city_id, 4, ship_date
Question: Identify the total weight of shipments transported to San Mateo, California, in 2016.
Evidence: "San Mateo" is the city_name; in 2016 refers to Cast(ship_date as DATE) = 2016
SQL: SELECT SUM(T1.weight) FROM shipment AS T1 INNER JOIN city AS T2 ON T1.city_id = T2.city_id WHERE T2.city_name = 'San Mateo' AND STRFTIME('%Y', T1.ship_date) = '2016'
Database: shipping
Tables: city, customer, driver, truck, shipment
Columns (table index, column name): -1, *, 0, city_id, 0, city_name, 0, state, 0, population, 0, area, 1, cust_id, 1, cust_name, 1, annual_revenue, 1, cust_type, 1, address, 1, city, 1, state, 1, zip, 1, phone, 2, driver_id, 2, first_name, 2, last_name, 2, address, 2, city, 2, state, 2, zip_code, 2, phone, 3, truck_id, 3, make, 3, model_year, 4, ship_id, 4, cust_id, 4, weight, 4, truck_id, 4, driver_id, 4, city_id, 4, ship_date
Question: Identify the total weight of shipments transported in 2016 by the newest Peterbilt.
Evidence: transported in 2016 refers to CAST(ship_date as DATE) = 2016; 'Peterbilt' is the make; newest refers to Max(model_year)
SQL: SELECT SUM(T2.weight) FROM truck AS T1 INNER JOIN shipment AS T2 ON T1.truck_id = T2.truck_id WHERE T1.make = 'Peterbilt' AND STRFTIME('%Y', T2.ship_date) = '2016' ORDER BY T1.model_year DESC LIMIT 1
Database: shipping
Tables: city, customer, driver, truck, shipment
Columns (table index, column name): -1, *, 0, city_id, 0, city_name, 0, state, 0, population, 0, area, 1, cust_id, 1, cust_name, 1, annual_revenue, 1, cust_type, 1, address, 1, city, 1, state, 1, zip, 1, phone, 2, driver_id, 2, first_name, 2, last_name, 2, address, 2, city, 2, state, 2, zip_code, 2, phone, 3, truck_id, 3, make, 3, model_year, 4, ship_id, 4, cust_id, 4, weight, 4, truck_id, 4, driver_id, 4, city_id, 4, ship_date
Question: What was the maximum weight of the shipment carried to Boston? Name the customer of that shipment.
Evidence: "Boston" is the city_name; maximum weight refers to Max(weight); customer refers to cust_name
SQL: SELECT T1.weight, T2.cust_name FROM shipment AS T1 INNER JOIN customer AS T2 ON T1.cust_id = T2.cust_id INNER JOIN city AS T3 ON T3.city_id = T1.city_id WHERE T3.city_name = 'Boston' ORDER BY T1.weight DESC LIMIT 1
Database: shipping
Tables: city, customer, driver, truck, shipment
Columns (table index, column name): -1, *, 0, city_id, 0, city_name, 0, state, 0, population, 0, area, 1, cust_id, 1, cust_name, 1, annual_revenue, 1, cust_type, 1, address, 1, city, 1, state, 1, zip, 1, phone, 2, driver_id, 2, first_name, 2, last_name, 2, address, 2, city, 2, state, 2, zip_code, 2, phone, 3, truck_id, 3, make, 3, model_year, 4, ship_id, 4, cust_id, 4, weight, 4, truck_id, 4, driver_id, 4, city_id, 4, ship_date
Question: Where was shipment no. 1002 headed?
Evidence: shipment no. 1002 refers to ship_id = 1002; where shipment was headed refers to city_name
SQL: SELECT T2.city_name FROM shipment AS T1 INNER JOIN city AS T2 ON T1.city_id = T2.city_id WHERE T1.ship_id = '1002'
Database: shipping
Tables: city, customer, driver, truck, shipment
Columns (table index, column name): -1, *, 0, city_id, 0, city_name, 0, state, 0, population, 0, area, 1, cust_id, 1, cust_name, 1, annual_revenue, 1, cust_type, 1, address, 1, city, 1, state, 1, zip, 1, phone, 2, driver_id, 2, first_name, 2, last_name, 2, address, 2, city, 2, state, 2, zip_code, 2, phone, 3, truck_id, 3, make, 3, model_year, 4, ship_id, 4, cust_id, 4, weight, 4, truck_id, 4, driver_id, 4, city_id, 4, ship_date
Question: What is the average shipment weight carried by the oldest Mack?
Evidence: "Mack" is the make; oldest refers to Min(model_year); average shipment weight refers to AVG(weight)
SQL: SELECT AVG(T2.weight) FROM truck AS T1 INNER JOIN shipment AS T2 ON T1.truck_id = T2.truck_id WHERE T1.make = 'Mack'