cnatale/presto-athena-txt-2-sql huggingface dataset:
Give the names of characteristics that are in two or more products?
Additional table information: table: products_gen_characteristics
SQL: SELECT t3.characteristic_name FROM products AS t1 JOIN product_characteristics AS t2 ON t1.product_id = t2.product_id JOIN CHARACTERISTICS AS t3 ON t2.characteristic_id = t3.characteristic_id GROUP BY t3.characteristic_name HAVING COUNT(*) >= 2
How many colors are never used by any product?
Additional table information: table: products_gen_characteristics
SQL: SELECT COUNT(*) FROM Ref_colors WHERE NOT color_code IN (SELECT color_code FROM products)
Count the number of colors that are not used in any products.
Additional table information: table: products_gen_characteristics
SQL: SELECT COUNT(*) FROM Ref_colors WHERE NOT color_code IN (SELECT color_code FROM products)
How many events are there?
Additional table information: table: swimming
SQL: SELECT COUNT(*) FROM event
List all the event names by year from the most recent to the oldest.
Additional table information: table: swimming
SQL: SELECT name FROM event ORDER BY YEAR DESC
What is the name of the event that happened in the most recent year?
Additional table information: table: swimming
SQL: SELECT name FROM event ORDER BY YEAR DESC LIMIT 1
How many stadiums are there?
Additional table information: table: swimming
SQL: SELECT COUNT(*) FROM stadium
Find the name of the stadium that has the maximum capacity.
Additional table information: table: swimming
SQL: SELECT name FROM stadium ORDER BY capacity DESC LIMIT 1
Find the names of stadiums whose capacity is smaller than the average capacity.
Additional table information: table: swimming
SQL: SELECT name FROM stadium WHERE capacity < (SELECT AVG(capacity) FROM stadium)
Find the country that has the most stadiums.
Additional table information: table: swimming
SQL: SELECT country FROM stadium GROUP BY country ORDER BY COUNT(*) DESC LIMIT 1
Which country has at most 3 stadiums listed?
Additional table information: table: swimming
SQL: SELECT country FROM stadium GROUP BY country HAVING COUNT(*) <= 3
Which country has both stadiums with capacity greater than 60000 and stadiums with capacity less than 50000?
Additional table information: table: swimming
SQL: SELECT country FROM stadium WHERE capacity > 60000 INTERSECT SELECT country FROM stadium WHERE capacity < 50000
How many cities have a stadium that was opened before the year of 2006?
Additional table information: table: swimming
SQL: SELECT COUNT(DISTINCT city) FROM stadium WHERE opening_year < 2006
How many stadiums does each country have?
Additional table information: table: swimming
SQL: SELECT country, COUNT(*) FROM stadium GROUP BY country
Which countries do not have a stadium that was opened after 2006?
Additional table information: table: swimming
SQL: SELECT country FROM stadium EXCEPT SELECT country FROM stadium WHERE opening_year > 2006
How many stadiums are not in country 'Russia'?
Additional table information: table: swimming
SQL: SELECT COUNT(*) FROM stadium WHERE country <> 'Russia'
Find the names of all swimmers, sorted by their 100 meter scores in ascending order.
Additional table information: table: swimming
SQL: SELECT name FROM swimmer ORDER BY meter_100 NULLS FIRST
How many different countries are all the swimmers from?
Additional table information: table: swimming
SQL: SELECT COUNT(DISTINCT nationality) FROM swimmer
List countries that have more than one swimmer.
Additional table information: table: swimming
SQL: SELECT nationality, COUNT(*) FROM swimmer GROUP BY nationality HAVING COUNT(*) > 1
Find all 200 meter and 300 meter results of swimmers with nationality 'Australia'.
Additional table information: table: swimming
SQL: SELECT meter_200, meter_300 FROM swimmer WHERE nationality = 'Australia'
Find the names of swimmers who has a result of 'win'.
Additional table information: table: swimming
SQL: SELECT t1.name FROM swimmer AS t1 JOIN record AS t2 ON t1.id = t2.swimmer_id WHERE RESULT = 'Win'
What is the name of the stadium which held the most events?
Additional table information: table: swimming
SQL: SELECT t1.name FROM stadium AS t1 JOIN event AS t2 ON t1.id = t2.stadium_id GROUP BY t2.stadium_id ORDER BY COUNT(*) DESC LIMIT 1
Find the name and capacity of the stadium where the event named 'World Junior' happened.
Additional table information: table: swimming
SQL: SELECT t1.name, t1.capacity FROM stadium AS t1 JOIN event AS t2 ON t1.id = t2.stadium_id WHERE t2.name = 'World Junior'
Find the names of stadiums which have never had any event.
Additional table information: table: swimming
SQL: SELECT name FROM stadium WHERE NOT id IN (SELECT stadium_id FROM event)
Find the name of the swimmer who has the most records.
Additional table information: table: swimming
SQL: SELECT t1.name FROM swimmer AS t1 JOIN record AS t2 ON t1.id = t2.swimmer_id GROUP BY t2.swimmer_id ORDER BY COUNT(*) DESC LIMIT 1
Find the name of the swimmer who has at least 2 records.
Additional table information: table: swimming
SQL: SELECT t1.name FROM swimmer AS t1 JOIN record AS t2 ON t1.id = t2.swimmer_id GROUP BY t2.swimmer_id HAVING COUNT(*) >= 2
Find the name and nationality of the swimmer who has won (i.e., has a result of 'win') more than 1 time.
Additional table information: table: swimming
SQL: SELECT t1.name, t1.nationality FROM swimmer AS t1 JOIN record AS t2 ON t1.id = t2.swimmer_id WHERE RESULT = 'Win' GROUP BY t2.swimmer_id HAVING COUNT(*) > 1
Find the names of the swimmers who have no record.
Additional table information: table: swimming
SQL: SELECT name FROM swimmer WHERE NOT id IN (SELECT swimmer_id FROM record)
Find the names of the swimmers who have both 'win' and 'loss' results in the record.
Additional table information: table: swimming
SQL: SELECT t1.name FROM swimmer AS t1 JOIN record AS t2 ON t1.id = t2.swimmer_id WHERE RESULT = 'Win' INTERSECT SELECT t1.name FROM swimmer AS t1 JOIN record AS t2 ON t1.id = t2.swimmer_id WHERE RESULT = 'Loss'
Find the names of stadiums that some Australian swimmers have been to.
Additional table information: table: swimming
SQL: SELECT t4.name FROM swimmer AS t1 JOIN record AS t2 ON t1.id = t2.swimmer_id JOIN event AS t3 ON t2.event_id = t3.id JOIN stadium AS t4 ON t4.id = t3.stadium_id WHERE t1.nationality = 'Australia'
Find the names of stadiums that the most swimmers have been to.
Additional table information: table: swimming
SQL: SELECT t3.name FROM record AS t1 JOIN event AS t2 ON t1.event_id = t2.id JOIN stadium AS t3 ON t3.id = t2.stadium_id GROUP BY t2.stadium_id ORDER BY COUNT(*) DESC LIMIT 1
Find all details for each swimmer.
Additional table information: table: swimming
SQL: SELECT * FROM swimmer
What is the average capacity of the stadiums that were opened in year 2005?
Additional table information: table: swimming
SQL: SELECT AVG(capacity) FROM stadium WHERE opening_year = 2005
How many railways are there?
Additional table information: table: railway
SQL: SELECT COUNT(*) FROM railway
List the builders of railways in ascending alphabetical order.
Additional table information: table: railway
SQL: SELECT Builder FROM railway ORDER BY Builder ASC NULLS FIRST
List the wheels and locations of the railways.
Additional table information: table: railway
SQL: SELECT Wheels, LOCATION FROM railway
What is the maximum level of managers in countries that are not 'Australia'?
Additional table information: table: railway
SQL: SELECT MAX(LEVEL) FROM manager WHERE Country <> 'Australia	'
What is the average age for all managers?
Additional table information: table: railway
SQL: SELECT AVG(Age) FROM manager
What are the names of managers in ascending order of level?
Additional table information: table: railway
SQL: SELECT Name FROM manager ORDER BY LEVEL ASC NULLS FIRST
What are the names and arrival times of trains?
Additional table information: table: railway
SQL: SELECT Name, Arrival FROM train
What is the name of the oldest manager?
Additional table information: table: railway
SQL: SELECT Name FROM manager ORDER BY Age DESC LIMIT 1
Show the names of trains and locations of railways they are in.
Additional table information: table: railway
SQL: SELECT T2.Name, T1.Location FROM railway AS T1 JOIN train AS T2 ON T1.Railway_ID = T2.Railway_ID
Show the builder of railways associated with the trains named 'Andaman Exp'.
Additional table information: table: railway
SQL: SELECT T1.Builder FROM railway AS T1 JOIN train AS T2 ON T1.Railway_ID = T2.Railway_ID WHERE T2.Name = 'Andaman Exp'
Show id and location of railways that are associated with more than one train.
Additional table information: table: railway
SQL: SELECT T2.Railway_ID, T1.Location FROM railway AS T1 JOIN train AS T2 ON T1.Railway_ID = T2.Railway_ID GROUP BY T2.Railway_ID HAVING COUNT(*) > 1
Show the id and builder of the railway that are associated with the most trains.
Additional table information: table: railway
SQL: SELECT T2.Railway_ID, T1.Builder FROM railway AS T1 JOIN train AS T2 ON T1.Railway_ID = T2.Railway_ID GROUP BY T2.Railway_ID ORDER BY COUNT(*) DESC LIMIT 1
Show different builders of railways, along with the corresponding number of railways using each builder.
Additional table information: table: railway
SQL: SELECT Builder, COUNT(*) FROM railway GROUP BY Builder
Show the most common builder of railways.
Additional table information: table: railway
SQL: SELECT Builder FROM railway GROUP BY Builder ORDER BY COUNT(*) DESC LIMIT 1
Show different locations of railways along with the corresponding number of railways at each location.
Additional table information: table: railway
SQL: SELECT LOCATION, COUNT(*) FROM railway GROUP BY LOCATION
Show the locations that have more than one railways.
Additional table information: table: railway
SQL: SELECT LOCATION FROM railway GROUP BY LOCATION HAVING COUNT(*) > 1
List the object number of railways that do not have any trains.
Additional table information: table: railway
SQL: SELECT ObjectNumber FROM railway WHERE NOT Railway_ID IN (SELECT Railway_ID FROM train)
Show the countries that have both managers of age above 50 and managers of age below 46.
Additional table information: table: railway
SQL: SELECT Country FROM manager WHERE Age > 50 INTERSECT SELECT Country FROM manager WHERE Age < 46
Show the distinct countries of managers.
Additional table information: table: railway
SQL: SELECT DISTINCT Country FROM manager
Show the working years of managers in descending order of their level.
Additional table information: table: railway
SQL: SELECT Working_year_starts FROM manager ORDER BY LEVEL DESC
Show the countries that have managers of age above 50 or below 46.
Additional table information: table: railway
SQL: SELECT Country FROM manager WHERE Age > 50 OR Age < 46
How many addresses are there in country USA?
Additional table information: table: customers_and_products_contacts
SQL: SELECT COUNT(*) FROM addresses WHERE country = 'USA'
Show all distinct cities in the address record.
Additional table information: table: customers_and_products_contacts
SQL: SELECT DISTINCT city FROM addresses
Show each state and the number of addresses in each state.
Additional table information: table: customers_and_products_contacts
SQL: SELECT state_province_county, COUNT(*) FROM addresses GROUP BY state_province_county
Show names and phones of customers who do not have address information.
Additional table information: table: customers_and_products_contacts
SQL: SELECT customer_name, customer_phone FROM customers WHERE NOT customer_id IN (SELECT customer_id FROM customer_address_history)
Show the name of the customer who has the most orders.
Additional table information: table: customers_and_products_contacts
SQL: SELECT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY COUNT(*) DESC LIMIT 1
Show the product type codes which have at least two products.
Additional table information: table: customers_and_products_contacts
SQL: SELECT product_type_code FROM products GROUP BY product_type_code HAVING COUNT(*) >= 2
Show the names of customers who have both an order in completed status and an order in part status.
Additional table information: table: customers_and_products_contacts
SQL: SELECT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status_code = 'Completed' INTERSECT SELECT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status_code = 'Part'
Show the name, phone, and payment method code for all customers in descending order of customer number.
Additional table information: table: customers_and_products_contacts
SQL: SELECT customer_name, customer_phone, payment_method_code FROM customers ORDER BY customer_number DESC
Show the product name and total order quantity for each product.
Additional table information: table: customers_and_products_contacts
SQL: SELECT T1.product_name, SUM(T2.order_quantity) FROM products AS T1 JOIN order_items AS T2 ON T1.product_id = T2.product_id GROUP BY T1.product_id
Show the minimum, maximum, average price for all products.
Additional table information: table: customers_and_products_contacts
SQL: SELECT MIN(product_price), MAX(product_price), AVG(product_price) FROM products
How many products have a price higher than the average?
Additional table information: table: customers_and_products_contacts
SQL: SELECT COUNT(*) FROM products WHERE product_price > (SELECT AVG(product_price) FROM products)
Show the customer name, customer address city, date from, and date to for each customer address history.
Additional table information: table: customers_and_products_contacts
SQL: SELECT T2.customer_name, T3.city, T1.date_from, T1.date_to FROM customer_address_history AS T1 JOIN customers AS T2 ON T1.customer_id = T2.customer_id JOIN addresses AS T3 ON T1.address_id = T3.address_id
Show the names of customers who use Credit Card payment method and have more than 2 orders.
Additional table information: table: customers_and_products_contacts
SQL: SELECT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id WHERE T1.payment_method_code = 'Credit Card' GROUP BY T1.customer_id HAVING COUNT(*) > 2
What are the name and phone of the customer with the most ordered product quantity?
Additional table information: table: customers_and_products_contacts
SQL: SELECT T1.customer_name, T1.customer_phone FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id JOIN order_items AS T3 ON T3.order_id = T2.order_id GROUP BY T1.customer_id ORDER BY SUM(T3.order_quantity) DESC LIMIT 1
Show the product type and name for the products with price higher than 1000 or lower than 500.
Additional table information: table: customers_and_products_contacts
SQL: SELECT product_type_code, product_name FROM products WHERE product_price > 1000 OR product_price < 500
Find the name of dorms only for female (F gender).
Additional table information: table: dorm_1
SQL: SELECT dorm_name FROM dorm WHERE gender = 'F'
What are the names of the all-female dorms?
Additional table information: table: dorm_1
SQL: SELECT dorm_name FROM dorm WHERE gender = 'F'
Find the name of dorms that can accommodate more than 300 students.
Additional table information: table: dorm_1
SQL: SELECT dorm_name FROM dorm WHERE student_capacity > 300
What are the names of all the dorms that can accomdate more than 300 students?
Additional table information: table: dorm_1
SQL: SELECT dorm_name FROM dorm WHERE student_capacity > 300
How many female students (sex is F) whose age is below 25?
Additional table information: table: dorm_1
SQL: SELECT COUNT(*) FROM student WHERE sex = 'F' AND age < 25
How many girl students who are younger than 25?
Additional table information: table: dorm_1
SQL: SELECT COUNT(*) FROM student WHERE sex = 'F' AND age < 25
Find the first name of students who is older than 20.
Additional table information: table: dorm_1
SQL: SELECT fname FROM student WHERE age > 20
What are the first names of all students who are older than 20?
Additional table information: table: dorm_1
SQL: SELECT fname FROM student WHERE age > 20
Find the first name of students living in city PHL whose age is between 20 and 25.
Additional table information: table: dorm_1
SQL: SELECT fname FROM student WHERE city_code = 'PHL' AND age BETWEEN 20 AND 25
What is the first name of the students who are in age 20 to 25 and living in PHL city?
Additional table information: table: dorm_1
SQL: SELECT fname FROM student WHERE city_code = 'PHL' AND age BETWEEN 20 AND 25
How many dorms are there?
Additional table information: table: dorm_1
SQL: SELECT COUNT(*) FROM dorm
How many dorms are in the database?
Additional table information: table: dorm_1
SQL: SELECT COUNT(*) FROM dorm
Find the number of distinct amenities.
Additional table information: table: dorm_1
SQL: SELECT COUNT(*) FROM dorm_amenity
How many diffrent dorm amenities are there?
Additional table information: table: dorm_1
SQL: SELECT COUNT(*) FROM dorm_amenity
Find the total capacity of all dorms.
Additional table information: table: dorm_1
SQL: SELECT SUM(student_capacity) FROM dorm
What is the total student capacity of all dorms?
Additional table information: table: dorm_1
SQL: SELECT SUM(student_capacity) FROM dorm
How many students are there?
Additional table information: table: dorm_1
SQL: SELECT COUNT(*) FROM student
How many students exist?
Additional table information: table: dorm_1
SQL: SELECT COUNT(*) FROM student
Find the average age of all students living in the each city.
Additional table information: table: dorm_1
SQL: SELECT AVG(age), city_code FROM student GROUP BY city_code
What is the average age for each city and what are those cities?
Additional table information: table: dorm_1
SQL: SELECT AVG(age), city_code FROM student GROUP BY city_code
Find the average and total capacity of dorms for the students with gender X.
Additional table information: table: dorm_1
SQL: SELECT AVG(student_capacity), SUM(student_capacity) FROM dorm WHERE gender = 'X'
What is the average and total capacity for all dorms who are of gender X?
Additional table information: table: dorm_1
SQL: SELECT AVG(student_capacity), SUM(student_capacity) FROM dorm WHERE gender = 'X'
Find the number of dorms that have some amenity.
Additional table information: table: dorm_1
SQL: SELECT COUNT(DISTINCT dormid) FROM has_amenity
How many dorms have amenities?
Additional table information: table: dorm_1
SQL: SELECT COUNT(DISTINCT dormid) FROM has_amenity
Find the name of dorms that do not have any amenity
Additional table information: table: dorm_1
SQL: SELECT dorm_name FROM dorm WHERE NOT dormid IN (SELECT dormid FROM has_amenity)
What are the names of all the dorms that don't have any amenities?
Additional table information: table: dorm_1
SQL: SELECT dorm_name FROM dorm WHERE NOT dormid IN (SELECT dormid FROM has_amenity)
Find the number of distinct gender for dorms.
Additional table information: table: dorm_1
SQL: SELECT COUNT(DISTINCT gender) FROM dorm
How many different genders are there in the dorms?
Additional table information: table: dorm_1
SQL: SELECT COUNT(DISTINCT gender) FROM dorm
Find the capacity and gender type of the dorm whose name has substring ‘Donor’.
Additional table information: table: dorm_1
SQL: SELECT student_capacity, gender FROM dorm WHERE dorm_name LIKE '%Donor%'
What is the student capacity and type of gender for the dorm whose name as the phrase Donor in it?
Additional table information: table: dorm_1
SQL: SELECT student_capacity, gender FROM dorm WHERE dorm_name LIKE '%Donor%'
Find the name and gender type of the dorms whose capacity is greater than 300 or less than 100.
Additional table information: table: dorm_1
SQL: SELECT dorm_name, gender FROM dorm WHERE student_capacity > 300 OR student_capacity < 100
What are the names and types of the dorms that have a capacity greater than 300 or less than 100?
Additional table information: table: dorm_1
SQL: SELECT dorm_name, gender FROM dorm WHERE student_capacity > 300 OR student_capacity < 100
Find the numbers of different majors and cities.
Additional table information: table: dorm_1
SQL: SELECT COUNT(DISTINCT major), COUNT(DISTINCT city_code) FROM student
How many different majors are there and how many different city codes are there for each student?
Additional table information: table: dorm_1
SQL: SELECT COUNT(DISTINCT major), COUNT(DISTINCT city_code) FROM student
Find the name of dorms which have both TV Lounge and Study Room as amenities.
Additional table information: table: dorm_1
SQL: SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid WHERE T3.amenity_name = 'TV Lounge' INTERSECT SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid WHERE T3.amenity_name = 'Study Room'
What is the name of the dorm with both a TV Lounge and Study Room listed as amenities?
Additional table information: table: dorm_1
SQL: SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid WHERE T3.amenity_name = 'TV Lounge' INTERSECT SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid WHERE T3.amenity_name = 'Study Room'
Find the name of dorms which have TV Lounge but no Study Room as amenity.
Additional table information: table: dorm_1
SQL: SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid WHERE T3.amenity_name = 'TV Lounge' EXCEPT SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid WHERE T3.amenity_name = 'Study Room'
What is the name of each dorm that has a TV Lounge but no study rooms?
Additional table information: table: dorm_1
SQL: SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid WHERE T3.amenity_name = 'TV Lounge' EXCEPT SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid WHERE T3.amenity_name = 'Study Room'
Find the last name of students who is either female (sex is F) and living in the city of code BAL or male (sex is M) and in age of below 20.
Additional table information: table: dorm_1
SQL: SELECT lname FROM student WHERE sex = 'F' AND city_code = 'BAL' UNION SELECT lname FROM student WHERE sex = 'M' AND age < 20
What is the last name of every student who is either female or living in a city with the code BAL or male and under 20?
Additional table information: table: dorm_1
SQL: SELECT lname FROM student WHERE sex = 'F' AND city_code = 'BAL' UNION SELECT lname FROM student WHERE sex = 'M' AND age < 20
Find the name of the dorm with the largest capacity.
Additional table information: table: dorm_1
SQL: SELECT dorm_name FROM dorm ORDER BY student_capacity DESC LIMIT 1
What are the names of the dorm with the largest capacity?
Additional table information: table: dorm_1
SQL: SELECT dorm_name FROM dorm ORDER BY student_capacity DESC LIMIT 1
List in alphabetic order all different amenities.
Additional table information: table: dorm_1
SQL: SELECT amenity_name FROM dorm_amenity ORDER BY amenity_name NULLS FIRST
What are the different dorm amenity names in alphabetical order?
Additional table information: table: dorm_1
SQL: SELECT amenity_name FROM dorm_amenity ORDER BY amenity_name NULLS FIRST
Find the code of city where most of students are living in.
Additional table information: table: dorm_1
SQL: SELECT city_code FROM student GROUP BY city_code ORDER BY COUNT(*) DESC LIMIT 1
What is the code of the city with the most students?
Additional table information: table: dorm_1
SQL: SELECT city_code FROM student GROUP BY city_code ORDER BY COUNT(*) DESC LIMIT 1
Find the first and last name of students whose age is younger than the average age.
Additional table information: table: dorm_1
SQL: SELECT fname, lname FROM student WHERE age < (SELECT AVG(age) FROM student)
What is the first and last name of all students who are younger than average?
Additional table information: table: dorm_1
SQL: SELECT fname, lname FROM student WHERE age < (SELECT AVG(age) FROM student)
List the first and last name of students who are not living in the city with code HKG, and sorted the results by their ages.
Additional table information: table: dorm_1
SQL: SELECT fname, lname FROM student WHERE city_code <> 'HKG' ORDER BY age NULLS FIRST
What are the first and last names of all students who are not living in the city HKG and order the results by age?
Additional table information: table: dorm_1
SQL: SELECT fname, lname FROM student WHERE city_code <> 'HKG' ORDER BY age NULLS FIRST
List name of all amenities which Anonymous Donor Hall has, and sort the results in alphabetic order.
Additional table information: table: dorm_1
SQL: SELECT T1.amenity_name FROM dorm_amenity AS T1 JOIN has_amenity AS T2 ON T2.amenid = T1.amenid JOIN dorm AS T3 ON T2.dormid = T3.dormid WHERE T3.dorm_name = 'Anonymous Donor Hall' ORDER BY T1.amenity_name NULLS FIRST
What are the amenities in alphabetical order that Anonymous Donor Hall has?
Additional table information: table: dorm_1
SQL: SELECT T1.amenity_name FROM dorm_amenity AS T1 JOIN has_amenity AS T2 ON T2.amenid = T1.amenid JOIN dorm AS T3 ON T2.dormid = T3.dormid WHERE T3.dorm_name = 'Anonymous Donor Hall' ORDER BY T1.amenity_name NULLS FIRST
Find the number of dorms and total capacity for each gender.
Additional table information: table: dorm_1
SQL: SELECT COUNT(*), SUM(student_capacity), gender FROM dorm GROUP BY gender
How many dorms are there and what is the total capacity for each gender?
Additional table information: table: dorm_1
SQL: SELECT COUNT(*), SUM(student_capacity), gender FROM dorm GROUP BY gender
Find the average and oldest age for students with different sex.
Additional table information: table: dorm_1
SQL: SELECT AVG(age), MAX(age), sex FROM student GROUP BY sex
What is the average and oldest age for each gender of student?
Additional table information: table: dorm_1
SQL: SELECT AVG(age), MAX(age), sex FROM student GROUP BY sex
Find the number of students in each major.
Additional table information: table: dorm_1
SQL: SELECT COUNT(*), major FROM student GROUP BY major
How many students are there in each major?
Additional table information: table: dorm_1
SQL: SELECT COUNT(*), major FROM student GROUP BY major
Find the number and average age of students living in each city.
Additional table information: table: dorm_1
SQL: SELECT COUNT(*), AVG(age), city_code FROM student GROUP BY city_code
How many students live in each city and what are their average ages?
Additional table information: table: dorm_1
SQL: SELECT COUNT(*), AVG(age), city_code FROM student GROUP BY city_code
Find the average age and number of male students (with sex M) from each city.
Additional table information: table: dorm_1
SQL: SELECT COUNT(*), AVG(age), city_code FROM student WHERE sex = 'M' GROUP BY city_code
What is the average age and how many male students are there in each city?
Additional table information: table: dorm_1
SQL: SELECT COUNT(*), AVG(age), city_code FROM student WHERE sex = 'M' GROUP BY city_code
Find the number of students for the cities where have more than one student.
Additional table information: table: dorm_1
SQL: SELECT COUNT(*), city_code FROM student GROUP BY city_code HAVING COUNT(*) > 1
How many students are from each city, and which cities have more than one cities?
Additional table information: table: dorm_1
SQL: SELECT COUNT(*), city_code FROM student GROUP BY city_code HAVING COUNT(*) > 1
Find the first and last name of students who are not in the largest major.
Additional table information: table: dorm_1
SQL: SELECT fname, lname FROM student WHERE major <> (SELECT major FROM student GROUP BY major ORDER BY COUNT(*) DESC LIMIT 1)
What is the first and last name of the students who are not in the largest major?
Additional table information: table: dorm_1
SQL: SELECT fname, lname FROM student WHERE major <> (SELECT major FROM student GROUP BY major ORDER BY COUNT(*) DESC LIMIT 1)
Find the number of students whose age is older than the average age for each gender.
Additional table information: table: dorm_1
SQL: SELECT COUNT(*), sex FROM student WHERE age > (SELECT AVG(age) FROM student) GROUP BY sex
How many students are older than average for each gender?
Additional table information: table: dorm_1
SQL: SELECT COUNT(*), sex FROM student WHERE age > (SELECT AVG(age) FROM student) GROUP BY sex
Find the average age of students living in each dorm and the name of dorm.
Additional table information: table: dorm_1
SQL: SELECT AVG(T1.age), T3.dorm_name FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid JOIN dorm AS T3 ON T3.dormid = T2.dormid GROUP BY T3.dorm_name
What is the average age for each dorm and what are the names of each dorm?
Additional table information: table: dorm_1
SQL: SELECT AVG(T1.age), T3.dorm_name FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid JOIN dorm AS T3 ON T3.dormid = T2.dormid GROUP BY T3.dorm_name
Find the number of amenities for each of the dorms that can accommodate more than 100 students.
Additional table information: table: dorm_1
SQL: SELECT COUNT(*), T1.dormid FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid WHERE T1.student_capacity > 100 GROUP BY T1.dormid
For each dorm, how many amenities does it have?
Additional table information: table: dorm_1
SQL: SELECT COUNT(*), T1.dormid FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid WHERE T1.student_capacity > 100 GROUP BY T1.dormid
Find the number of students who is older than 20 in each dorm.
Additional table information: table: dorm_1
SQL: SELECT COUNT(*), T3.dorm_name FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid JOIN dorm AS T3 ON T3.dormid = T2.dormid WHERE T1.age > 20 GROUP BY T3.dorm_name
How many students are older than 20 in each dorm?
Additional table information: table: dorm_1
SQL: SELECT COUNT(*), T3.dorm_name FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid JOIN dorm AS T3 ON T3.dormid = T2.dormid WHERE T1.age > 20 GROUP BY T3.dorm_name
Find the first name of students who are living in the Smith Hall.
Additional table information: table: dorm_1
SQL: SELECT T1.fname FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid JOIN dorm AS T3 ON T3.dormid = T2.dormid WHERE T3.dorm_name = 'Smith Hall'
What are the first names of all students in Smith Hall?
Additional table information: table: dorm_1
SQL: SELECT T1.fname FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid JOIN dorm AS T3 ON T3.dormid = T2.dormid WHERE T3.dorm_name = 'Smith Hall'
Find the average age of students who are living in the dorm with the largest capacity.
Additional table information: table: dorm_1
SQL: SELECT AVG(T1.age) FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid JOIN dorm AS T3 ON T3.dormid = T2.dormid WHERE T3.student_capacity = (SELECT MAX(student_capacity) FROM dorm)
What is the average age of students who are living in the dorm with the largest capacity?
Additional table information: table: dorm_1
SQL: SELECT AVG(T1.age) FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid JOIN dorm AS T3 ON T3.dormid = T2.dormid WHERE T3.student_capacity = (SELECT MAX(student_capacity) FROM dorm)
Find the total number of students living in the male dorm (with gender M).
Additional table information: table: dorm_1
SQL: SELECT COUNT(*) FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid JOIN dorm AS T3 ON T3.dormid = T2.dormid WHERE T3.gender = 'M'
What are the total number of students who are living in a male dorm?
Additional table information: table: dorm_1
SQL: SELECT COUNT(*) FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid JOIN dorm AS T3 ON T3.dormid = T2.dormid WHERE T3.gender = 'M'
Find the number of female students (with F sex) living in Smith Hall
Additional table information: table: dorm_1
SQL: SELECT COUNT(*) FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid JOIN dorm AS T3 ON T3.dormid = T2.dormid WHERE T3.dorm_name = 'Smith Hall' AND T1.sex = 'F'
How many female students live in Smith Hall?
Additional table information: table: dorm_1
SQL: SELECT COUNT(*) FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid JOIN dorm AS T3 ON T3.dormid = T2.dormid WHERE T3.dorm_name = 'Smith Hall' AND T1.sex = 'F'
Find the name of amenities Smith Hall dorm have.
Additional table information: table: dorm_1
SQL: SELECT T3.amenity_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid WHERE T1.dorm_name = 'Smith Hall'
What are the names of the amenities that Smith Hall has?
Additional table information: table: dorm_1
SQL: SELECT T3.amenity_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid WHERE T1.dorm_name = 'Smith Hall'
Find the name of amenities Smith Hall dorm have. ordered the results by amenity names.
Additional table information: table: dorm_1
SQL: SELECT T3.amenity_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid WHERE T1.dorm_name = 'Smith Hall' ORDER BY T3.amenity_name NULLS FIRST
What amenities does Smith Hall have in alphabetical order?
Additional table information: table: dorm_1
SQL: SELECT T3.amenity_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid WHERE T1.dorm_name = 'Smith Hall' ORDER BY T3.amenity_name NULLS FIRST
Find the name of amenity that is most common in all dorms.
Additional table information: table: dorm_1
SQL: SELECT T1.amenity_name FROM dorm_amenity AS T1 JOIN has_amenity AS T2 ON T1.amenid = T2.amenid GROUP BY T2.amenid ORDER BY COUNT(*) DESC LIMIT 1
What is the most common amenity in the dorms?
Additional table information: table: dorm_1
SQL: SELECT T1.amenity_name FROM dorm_amenity AS T1 JOIN has_amenity AS T2 ON T1.amenid = T2.amenid GROUP BY T2.amenid ORDER BY COUNT(*) DESC LIMIT 1
Find the first name of students who are living in the dorm that has most number of amenities.
Additional table information: table: dorm_1
SQL: SELECT T1.fname FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid WHERE T2.dormid IN (SELECT T2.dormid FROM dorm AS T3 JOIN has_amenity AS T4 ON T3.dormid = T4.dormid JOIN dorm_amenity AS T5 ON T4.amenid = T5.amenid GROUP BY T3.dormid ORDER BY COUNT(*) DESC LIMIT 1)
What are the first names of all students who live in the dorm with the most amenities?
Additional table information: table: dorm_1
SQL: SELECT T1.fname FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid WHERE T2.dormid IN (SELECT T2.dormid FROM dorm AS T3 JOIN has_amenity AS T4 ON T3.dormid = T4.dormid JOIN dorm_amenity AS T5 ON T4.amenid = T5.amenid GROUP BY T3.dormid ORDER BY COUNT(*) DESC LIMIT 1)
Find the name and capacity of the dorm with least number of amenities.
Additional table information: table: dorm_1
SQL: SELECT T1.dorm_name, T1.student_capacity FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid GROUP BY T2.dormid ORDER BY COUNT(*) NULLS FIRST LIMIT 1
What is the name and capacity of the dorm with the fewest amount of amenities?
Additional table information: table: dorm_1
SQL: SELECT T1.dorm_name, T1.student_capacity FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid GROUP BY T2.dormid ORDER BY COUNT(*) NULLS FIRST LIMIT 1
Find the name of dorms that do not have amenity TV Lounge.
Additional table information: table: dorm_1
SQL: SELECT dorm_name FROM dorm EXCEPT SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid WHERE T3.amenity_name = 'TV Lounge'
What are the names of the dorm that does not have a TV Lounge?
Additional table information: table: dorm_1
SQL: SELECT dorm_name FROM dorm EXCEPT SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid WHERE T3.amenity_name = 'TV Lounge'
Find the first and last name of students who are living in the dorms that have amenity TV Lounge.
Additional table information: table: dorm_1
SQL: SELECT T1.fname, T1.lname FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid WHERE T2.dormid IN (SELECT T3.dormid FROM has_amenity AS T3 JOIN dorm_amenity AS T4 ON T3.amenid = T4.amenid WHERE T4.amenity_name = 'TV Lounge')
What are the first and last names of all students who are living in a dorm with a TV Lounge?
Additional table information: table: dorm_1
SQL: SELECT T1.fname, T1.lname FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid WHERE T2.dormid IN (SELECT T3.dormid FROM has_amenity AS T3 JOIN dorm_amenity AS T4 ON T3.amenid = T4.amenid WHERE T4.amenity_name = 'TV Lounge')
Find the first name and age of students who are living in the dorms that do not have amenity TV Lounge.
Additional table information: table: dorm_1
SQL: SELECT T1.fname, T1.age FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid WHERE NOT T2.dormid IN (SELECT T3.dormid FROM has_amenity AS T3 JOIN dorm_amenity AS T4 ON T3.amenid = T4.amenid WHERE T4.amenity_name = 'TV Lounge')
What is the first name and age of every student who lives in a dorm with a TV Lounge?
Additional table information: table: dorm_1
SQL: SELECT T1.fname, T1.age FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid WHERE NOT T2.dormid IN (SELECT T3.dormid FROM has_amenity AS T3 JOIN dorm_amenity AS T4 ON T3.amenid = T4.amenid WHERE T4.amenity_name = 'TV Lounge')
Find the name of amenities of the dorm where the student with last name Smith is living in.
Additional table information: table: dorm_1
SQL: SELECT T3.amenity_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid JOIN lives_in AS T4 ON T4.dormid = T1.dormid JOIN student AS T5 ON T5.stuid = T4.stuid WHERE T5.lname = 'Smith'
What are the amenities in the dorm that a student who has the last name of Smith lives in?
Additional table information: table: dorm_1
SQL: SELECT T3.amenity_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid JOIN lives_in AS T4 ON T4.dormid = T1.dormid JOIN student AS T5 ON T5.stuid = T4.stuid WHERE T5.lname = 'Smith'
How many customers are there?
Additional table information: table: customer_complaints
SQL: SELECT COUNT(*) FROM customers
Count the number of customers.
Additional table information: table: customer_complaints
SQL: SELECT COUNT(*) FROM customers
Find the emails and phone numbers of all the customers, ordered by email address and phone number.
Additional table information: table: customer_complaints
SQL: SELECT email_address, phone_number FROM customers ORDER BY email_address NULLS FIRST, phone_number NULLS FIRST
What are the emails and phone numbers of all customers, sorted by email address and phone number?
Additional table information: table: customer_complaints
SQL: SELECT email_address, phone_number FROM customers ORDER BY email_address NULLS FIRST, phone_number NULLS FIRST
Which city has the least number of customers whose type code is 'Good Credit Rating'?
Additional table information: table: customer_complaints
SQL: SELECT town_city FROM customers WHERE customer_type_code = 'Good Credit Rating' GROUP BY town_city ORDER BY COUNT(*) NULLS FIRST LIMIT 1
Return the city with the customer type code 'Good Credit Rating' that had the fewest customers.
Additional table information: table: customer_complaints
SQL: SELECT town_city FROM customers WHERE customer_type_code = 'Good Credit Rating' GROUP BY town_city ORDER BY COUNT(*) NULLS FIRST LIMIT 1
List the name of all products along with the number of complaints that they have received.
Additional table information: table: customer_complaints
SQL: SELECT t1.product_name, COUNT(*) FROM products AS t1 JOIN complaints AS t2 ON t1.product_id = t2.product_id GROUP BY t1.product_name
What are all the different product names, and how many complains has each received?
Additional table information: table: customer_complaints
SQL: SELECT t1.product_name, COUNT(*) FROM products AS t1 JOIN complaints AS t2 ON t1.product_id = t2.product_id GROUP BY t1.product_name
Find the emails of customers who has filed a complaints of the product with the most complaints.
Additional table information: table: customer_complaints
SQL: SELECT t1.email_address FROM customers AS t1 JOIN complaints AS t2 ON t1.customer_id = t2.customer_id GROUP BY t1.customer_id ORDER BY COUNT(*) NULLS FIRST LIMIT 1
What are the emails of customers who have filed complaints on the product which has had the greatest number of complaints?
Additional table information: table: customer_complaints
SQL: SELECT t1.email_address FROM customers AS t1 JOIN complaints AS t2 ON t1.customer_id = t2.customer_id GROUP BY t1.customer_id ORDER BY COUNT(*) NULLS FIRST LIMIT 1
Which products has been complained by the customer who has filed least amount of complaints?
Additional table information: table: customer_complaints
SQL: SELECT DISTINCT t1.product_name FROM products AS t1 JOIN complaints AS t2 ON t1.product_id = t2.product_id, customers AS t3 GROUP BY t3.customer_id ORDER BY COUNT(*) NULLS FIRST LIMIT 1
Return the names of products that have had complaints filed by the customer who has filed the fewest complaints.
Additional table information: table: customer_complaints
SQL: SELECT DISTINCT t1.product_name FROM products AS t1 JOIN complaints AS t2 ON t1.product_id = t2.product_id, customers AS t3 GROUP BY t3.customer_id ORDER BY COUNT(*) NULLS FIRST LIMIT 1
What is the phone number of the customer who has filed the most recent complaint?
Additional table information: table: customer_complaints
SQL: SELECT t1.phone_number FROM customers AS t1 JOIN complaints AS t2 ON t1.customer_id = t2.customer_id ORDER BY t2.date_complaint_raised DESC LIMIT 1
Return the phone number of the customer who filed the complaint that was raised most recently.
Additional table information: table: customer_complaints
SQL: SELECT t1.phone_number FROM customers AS t1 JOIN complaints AS t2 ON t1.customer_id = t2.customer_id ORDER BY t2.date_complaint_raised DESC LIMIT 1
Find the email and phone number of the customers who have never filed a complaint before.
Additional table information: table: customer_complaints
SQL: SELECT email_address, phone_number FROM customers WHERE NOT customer_id IN (SELECT customer_id FROM complaints)
What are the emails and phone numbers of custoemrs who have never filed a complaint?
Additional table information: table: customer_complaints
SQL: SELECT email_address, phone_number FROM customers WHERE NOT customer_id IN (SELECT customer_id FROM complaints)
Find the phone number of all the customers and staff.
Additional table information: table: customer_complaints
SQL: SELECT phone_number FROM customers UNION SELECT phone_number FROM staff
What are the phone numbers of all customers and all staff members?
Additional table information: table: customer_complaints
SQL: SELECT phone_number FROM customers UNION SELECT phone_number FROM staff
What is the description of the product named 'Chocolate'?
Additional table information: table: customer_complaints
SQL: SELECT product_description FROM products WHERE product_name = 'Chocolate'
Return the description of the product called 'Chocolate'.
Additional table information: table: customer_complaints
SQL: SELECT product_description FROM products WHERE product_name = 'Chocolate'
Find the name and category of the most expensive product.
Additional table information: table: customer_complaints
SQL: SELECT product_name, product_category_code FROM products ORDER BY product_price DESC LIMIT 1
What is the name and category code of the product with the highest price?
Additional table information: table: customer_complaints
SQL: SELECT product_name, product_category_code FROM products ORDER BY product_price DESC LIMIT 1
Find the prices of products which has never received a single complaint.
Additional table information: table: customer_complaints
SQL: SELECT product_price FROM products WHERE NOT product_id IN (SELECT product_id FROM complaints)
What are the prices of products that have never gotten a complaint?
Additional table information: table: customer_complaints
SQL: SELECT product_price FROM products WHERE NOT product_id IN (SELECT product_id FROM complaints)
What is the average price of the products for each category?
Additional table information: table: customer_complaints
SQL: SELECT AVG(product_price), product_category_code FROM products GROUP BY product_category_code
Return the average price of products that have each category code.
Additional table information: table: customer_complaints
SQL: SELECT AVG(product_price), product_category_code FROM products GROUP BY product_category_code
Find the last name of the staff member who processed the complaint of the cheapest product.
Additional table information: table: customer_complaints
SQL: SELECT t1.last_name FROM staff AS t1 JOIN complaints AS t2 ON t1.staff_id = t2.staff_id JOIN products AS t3 ON t2.product_id = t3.product_id ORDER BY t3.product_price NULLS FIRST LIMIT 1
What is the last name of the staff member in charge of the complaint on the product with the lowest price?
Additional table information: table: customer_complaints
SQL: SELECT t1.last_name FROM staff AS t1 JOIN complaints AS t2 ON t1.staff_id = t2.staff_id JOIN products AS t3 ON t2.product_id = t3.product_id ORDER BY t3.product_price NULLS FIRST LIMIT 1
Which complaint status has more than 3 records on file?
Additional table information: table: customer_complaints
SQL: SELECT complaint_status_code FROM complaints GROUP BY complaint_status_code HAVING COUNT(*) > 3
Return complaint status codes have more than 3 corresponding complaints?
Additional table information: table: customer_complaints
SQL: SELECT complaint_status_code FROM complaints GROUP BY complaint_status_code HAVING COUNT(*) > 3
Find the last name of the staff whose email address contains 'wrau'.
Additional table information: table: customer_complaints
SQL: SELECT last_name FROM staff WHERE email_address LIKE '%wrau%'
What are the last names of staff with email addressed containing the substring 'wrau'?
Additional table information: table: customer_complaints
SQL: SELECT last_name FROM staff WHERE email_address LIKE '%wrau%'
How many customers are there in the customer type with the most customers?
Additional table information: table: customer_complaints
SQL: SELECT COUNT(*) FROM customers GROUP BY customer_type_code ORDER BY COUNT(*) DESC LIMIT 1
Count the number of customers that have the customer type that is most common.
Additional table information: table: customer_complaints
SQL: SELECT COUNT(*) FROM customers GROUP BY customer_type_code ORDER BY COUNT(*) DESC LIMIT 1
What is the last name of the staff who has handled the first ever complaint?
Additional table information: table: customer_complaints
SQL: SELECT t1.last_name FROM staff AS t1 JOIN complaints AS t2 ON t1.staff_id = t2.staff_id ORDER BY t2.date_complaint_raised NULLS FIRST LIMIT 1
Return the last name of the staff member who handled the complaint with the earliest date raised.
Additional table information: table: customer_complaints
SQL: SELECT t1.last_name FROM staff AS t1 JOIN complaints AS t2 ON t1.staff_id = t2.staff_id ORDER BY t2.date_complaint_raised NULLS FIRST LIMIT 1
How many distinct complaint type codes are there in the database?
Additional table information: table: customer_complaints
SQL: SELECT COUNT(DISTINCT complaint_type_code) FROM complaints
Count the number of different complaint type codes.
Additional table information: table: customer_complaints
SQL: SELECT COUNT(DISTINCT complaint_type_code) FROM complaints
Find the address line 1 and 2 of the customer with email 'vbogisich@example.org'.
Additional table information: table: customer_complaints
SQL: SELECT address_line_1, address_line_2 FROM customers WHERE email_address = 'vbogisich@example.org'
What are lines 1 and 2 of the addressed of the customer with the email 'vbogisich@example.org'?
Additional table information: table: customer_complaints
SQL: SELECT address_line_1, address_line_2 FROM customers WHERE email_address = 'vbogisich@example.org'