text
stringlengths 182
1.07k
|
---|
convert the question into postgresql query using the context values
### Question:
List each donator name and the amount of endowment in descending order of the amount of endowment.
### Context:
CREATE TABLE endowment (donator_name VARCHAR, amount INTEGER)
###Answer:
SELECT donator_name, SUM(amount) FROM endowment GROUP BY donator_name ORDER BY SUM(amount) DESC |
convert the question into postgresql query using the context values
### Question:
List the names of the schools without any endowment.
### Context:
CREATE TABLE endowment (school_name VARCHAR, school_id VARCHAR); CREATE TABLE school (school_name VARCHAR, school_id VARCHAR)
###Answer:
SELECT school_name FROM school WHERE NOT school_id IN (SELECT school_id FROM endowment) |
convert the question into postgresql query using the context values
### Question:
List all the names of schools with an endowment amount smaller than or equal to 10.
### Context:
CREATE TABLE school (school_name VARCHAR, school_id VARCHAR); CREATE TABLE endowment (school_id VARCHAR, amount INTEGER)
###Answer:
SELECT T2.school_name FROM endowment AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id GROUP BY T1.school_id HAVING SUM(T1.amount) <= 10 |
convert the question into postgresql query using the context values
### Question:
Show the names of donors who donated to both school "Glenn" and "Triton."
### Context:
CREATE TABLE school (school_id VARCHAR, school_name VARCHAR); CREATE TABLE endowment (donator_name VARCHAR, school_id VARCHAR)
###Answer:
SELECT T1.donator_name FROM endowment AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id WHERE T2.school_name = 'Glenn' INTERSECT SELECT T1.donator_name FROM endowment AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id WHERE T2.school_name = 'Triton' |
convert the question into postgresql query using the context values
### Question:
Show the names of all the donors except those whose donation amount less than 9.
### Context:
CREATE TABLE endowment (donator_name VARCHAR, amount INTEGER)
###Answer:
SELECT donator_name FROM endowment EXCEPT SELECT donator_name FROM endowment WHERE amount < 9 |
convert the question into postgresql query using the context values
### Question:
List the amount and donor name for the largest amount of donation.
### Context:
CREATE TABLE endowment (amount VARCHAR, donator_name VARCHAR)
###Answer:
SELECT amount, donator_name FROM endowment ORDER BY amount DESC LIMIT 1 |
convert the question into postgresql query using the context values
### Question:
How many budgets are above 3000 in year 2001 or before?
### Context:
CREATE TABLE budget (budgeted VARCHAR, YEAR VARCHAR)
###Answer:
SELECT COUNT(*) FROM budget WHERE budgeted > 3000 AND YEAR <= 2001 |
convert the question into postgresql query using the context values
### Question:
Show each school name, its budgeted amount, and invested amount in year 2002 or after.
### Context:
CREATE TABLE budget (budgeted VARCHAR, invested VARCHAR, school_id VARCHAR, year VARCHAR); CREATE TABLE school (school_name VARCHAR, school_id VARCHAR)
###Answer:
SELECT T2.school_name, T1.budgeted, T1.invested FROM budget AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id WHERE T1.year >= 2002 |
convert the question into postgresql query using the context values
### Question:
Show all donor names.
### Context:
CREATE TABLE endowment (donator_name VARCHAR)
###Answer:
SELECT DISTINCT donator_name FROM endowment |
convert the question into postgresql query using the context values
### Question:
How many budget record has a budget amount smaller than the invested amount?
### Context:
CREATE TABLE budget (budgeted INTEGER, invested VARCHAR)
###Answer:
SELECT COUNT(*) FROM budget WHERE budgeted < invested |
convert the question into postgresql query using the context values
### Question:
What is the total budget amount for school "Glenn" in all years?
### Context:
CREATE TABLE budget (budgeted INTEGER, school_id VARCHAR); CREATE TABLE school (school_id VARCHAR, school_name VARCHAR)
###Answer:
SELECT SUM(T1.budgeted) FROM budget AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id WHERE T2.school_name = 'Glenn' |
convert the question into postgresql query using the context values
### Question:
Show the names of schools with a total budget amount greater than 100 or a total endowment greater than 10.
### Context:
CREATE TABLE endowment (school_id VARCHAR, amount INTEGER); CREATE TABLE budget (school_id VARCHAR, budgeted INTEGER); CREATE TABLE school (school_name VARCHAR, school_id VARCHAR)
###Answer:
SELECT T2.school_name FROM budget AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id JOIN endowment AS T3 ON T2.school_id = T3.school_id GROUP BY T2.school_name HAVING SUM(T1.budgeted) > 100 OR SUM(T3.amount) > 10 |
convert the question into postgresql query using the context values
### Question:
Find the names of schools that have more than one donator with donation amount above 8.5.
### Context:
CREATE TABLE school (School_name VARCHAR, school_id VARCHAR); CREATE TABLE endowment (school_id VARCHAR, amount INTEGER)
###Answer:
SELECT T2.School_name FROM endowment AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id WHERE T1.amount > 8.5 GROUP BY T1.school_id HAVING COUNT(*) > 1 |
convert the question into postgresql query using the context values
### Question:
Find the number of schools that have more than one donator whose donation amount is less than 8.5.
### Context:
CREATE TABLE endowment (school_id VARCHAR, amount INTEGER)
###Answer:
SELECT COUNT(*) FROM (SELECT * FROM endowment WHERE amount > 8.5 GROUP BY school_id HAVING COUNT(*) > 1) |
convert the question into postgresql query using the context values
### Question:
List the name, IHSAA Football Class, and Mascot of the schools that have more than 6000 of budgeted amount or were founded before 2003, in the order of percent of total invested budget and total budgeted budget.
### Context:
CREATE TABLE school (School_name VARCHAR, Mascot VARCHAR, IHSAA_Football_Class VARCHAR, school_id VARCHAR); CREATE TABLE budget (school_id VARCHAR, total_budget_percent_invested VARCHAR, total_budget_percent_budgeted VARCHAR)
###Answer:
SELECT T1.School_name, T1.Mascot, T1.IHSAA_Football_Class FROM school AS T1 JOIN budget AS T2 ON T1.school_id = T2.school_id WHERE Budgeted > 6000 OR YEAR < 2003 ORDER BY T2.total_budget_percent_invested, T2.total_budget_percent_budgeted |
convert the question into postgresql query using the context values
### Question:
How many buildings are there?
### Context:
CREATE TABLE building (Id VARCHAR)
###Answer:
SELECT COUNT(*) FROM building |
convert the question into postgresql query using the context values
### Question:
Show the name, street address, and number of floors for all buildings ordered by the number of floors.
### Context:
CREATE TABLE building (name VARCHAR, street_address VARCHAR, floors VARCHAR)
###Answer:
SELECT name, street_address, floors FROM building ORDER BY floors |
convert the question into postgresql query using the context values
### Question:
What is the name of the tallest building?
### Context:
CREATE TABLE building (name VARCHAR, height_feet VARCHAR)
###Answer:
SELECT name FROM building ORDER BY height_feet DESC LIMIT 1 |
convert the question into postgresql query using the context values
### Question:
What are the average, maximum, and minimum number of floors for all buildings?
### Context:
CREATE TABLE building (floors INTEGER)
###Answer:
SELECT AVG(floors), MAX(floors), MIN(floors) FROM building |
convert the question into postgresql query using the context values
### Question:
Show the number of buildings with a height above the average or a number of floors above the average.
### Context:
CREATE TABLE building (height_feet INTEGER, floors INTEGER)
###Answer:
SELECT COUNT(*) FROM building WHERE height_feet > (SELECT AVG(height_feet) FROM building) OR floors > (SELECT AVG(floors) FROM building) |
convert the question into postgresql query using the context values
### Question:
List the names of buildings with at least 200 feet of height and with at least 20 floors.
### Context:
CREATE TABLE building (name VARCHAR, height_feet VARCHAR, floors VARCHAR)
###Answer:
SELECT name FROM building WHERE height_feet >= 200 AND floors >= 20 |
convert the question into postgresql query using the context values
### Question:
Show the names and locations of institutions that are founded after 1990 and have the type "Private".
### Context:
CREATE TABLE institution (institution VARCHAR, LOCATION VARCHAR, founded VARCHAR, TYPE VARCHAR)
###Answer:
SELECT institution, LOCATION FROM institution WHERE founded > 1990 AND TYPE = 'Private' |
convert the question into postgresql query using the context values
### Question:
Show institution types, along with the number of institutions and total enrollment for each type.
### Context:
CREATE TABLE institution (TYPE VARCHAR, enrollment INTEGER)
###Answer:
SELECT TYPE, COUNT(*), SUM(enrollment) FROM institution GROUP BY TYPE |
convert the question into postgresql query using the context values
### Question:
Show the institution type with the largest number of institutions.
### Context:
CREATE TABLE institution (TYPE VARCHAR)
###Answer:
SELECT TYPE FROM institution GROUP BY TYPE ORDER BY COUNT(*) DESC LIMIT 1 |
convert the question into postgresql query using the context values
### Question:
Show the institution type with an institution founded after 1990 and an institution with at least 1000 enrollment.
### Context:
CREATE TABLE institution (TYPE VARCHAR, founded VARCHAR, enrollment VARCHAR)
###Answer:
SELECT TYPE FROM institution WHERE founded > 1990 AND enrollment >= 1000 |
convert the question into postgresql query using the context values
### Question:
Show the name of buildings that do not have any institution.
### Context:
CREATE TABLE building (name VARCHAR, building_id VARCHAR); CREATE TABLE institution (name VARCHAR, building_id VARCHAR)
###Answer:
SELECT name FROM building WHERE NOT building_id IN (SELECT building_id FROM institution) |
convert the question into postgresql query using the context values
### Question:
Show the names of buildings except for those having an institution founded in 2003.
### Context:
CREATE TABLE building (name VARCHAR, building_id VARCHAR); CREATE TABLE building (name VARCHAR); CREATE TABLE institution (building_id VARCHAR, founded VARCHAR)
###Answer:
SELECT name FROM building EXCEPT SELECT T1.name FROM building AS T1 JOIN institution AS T2 ON T1.building_id = T2.building_id WHERE T2.founded = 2003 |
convert the question into postgresql query using the context values
### Question:
For each building, show the name of the building and the number of institutions in it.
### Context:
CREATE TABLE building (name VARCHAR, building_id VARCHAR); CREATE TABLE institution (building_id VARCHAR)
###Answer:
SELECT T1.name, COUNT(*) FROM building AS T1 JOIN institution AS T2 ON T1.building_id = T2.building_id GROUP BY T1.building_id |
convert the question into postgresql query using the context values
### Question:
Show the names and heights of buildings with at least two institutions founded after 1880.
### Context:
CREATE TABLE building (name VARCHAR, height_feet VARCHAR, building_id VARCHAR); CREATE TABLE institution (building_id VARCHAR, founded INTEGER)
###Answer:
SELECT T1.name, T1.height_feet FROM building AS T1 JOIN institution AS T2 ON T1.building_id = T2.building_id WHERE T2.founded > 1880 GROUP BY T1.building_id HAVING COUNT(*) >= 2 |
convert the question into postgresql query using the context values
### Question:
Show all the distinct institution types.
### Context:
CREATE TABLE institution (TYPE VARCHAR)
###Answer:
SELECT DISTINCT TYPE FROM institution |
convert the question into postgresql query using the context values
### Question:
Show institution names along with the number of proteins for each institution.
### Context:
CREATE TABLE institution (institution VARCHAR, institution_id VARCHAR); CREATE TABLE protein (institution_id VARCHAR)
###Answer:
SELECT T1.institution, COUNT(*) FROM institution AS T1 JOIN protein AS T2 ON T1.institution_id = T2.institution_id GROUP BY T1.institution_id |
convert the question into postgresql query using the context values
### Question:
How many proteins are associated with an institution founded after 1880 or an institution with type "Private"?
### Context:
CREATE TABLE institution (institution_id VARCHAR, founded VARCHAR, type VARCHAR); CREATE TABLE protein (institution_id VARCHAR)
###Answer:
SELECT COUNT(*) FROM institution AS T1 JOIN protein AS T2 ON T1.institution_id = T2.institution_id WHERE T1.founded > 1880 OR T1.type = 'Private' |
convert the question into postgresql query using the context values
### Question:
Show the protein name and the institution name.
### Context:
CREATE TABLE institution (institution VARCHAR, institution_id VARCHAR); CREATE TABLE protein (protein_name VARCHAR, institution_id VARCHAR)
###Answer:
SELECT T2.protein_name, T1.institution FROM institution AS T1 JOIN protein AS T2 ON T1.institution_id = T2.institution_id |
convert the question into postgresql query using the context values
### Question:
How many proteins are associated with an institution in a building with at least 20 floors?
### Context:
CREATE TABLE institution (institution_id VARCHAR, building_id VARCHAR); CREATE TABLE building (building_id VARCHAR, floors VARCHAR); CREATE TABLE protein (institution_id VARCHAR)
###Answer:
SELECT COUNT(*) FROM institution AS T1 JOIN protein AS T2 ON T1.institution_id = T2.institution_id JOIN building AS T3 ON T3.building_id = T1.building_id WHERE T3.floors >= 20 |
convert the question into postgresql query using the context values
### Question:
How many institutions do not have an associated protein in our record?
### Context:
CREATE TABLE protein (institution_id VARCHAR); CREATE TABLE institution (institution_id VARCHAR)
###Answer:
SELECT COUNT(*) FROM institution WHERE NOT institution_id IN (SELECT institution_id FROM protein) |
convert the question into postgresql query using the context values
### Question:
Show all the locations where no cinema has capacity over 800.
### Context:
CREATE TABLE cinema (LOCATION VARCHAR, capacity INTEGER)
###Answer:
SELECT LOCATION FROM cinema EXCEPT SELECT LOCATION FROM cinema WHERE capacity > 800 |
convert the question into postgresql query using the context values
### Question:
Show all the locations where some cinemas were opened in both year 2010 and year 2011.
### Context:
CREATE TABLE cinema (LOCATION VARCHAR, openning_year VARCHAR)
###Answer:
SELECT LOCATION FROM cinema WHERE openning_year = 2010 INTERSECT SELECT LOCATION FROM cinema WHERE openning_year = 2011 |
convert the question into postgresql query using the context values
### Question:
How many cinema do we have?
### Context:
CREATE TABLE cinema (Id VARCHAR)
###Answer:
SELECT COUNT(*) FROM cinema |
convert the question into postgresql query using the context values
### Question:
Show name, opening year, and capacity for each cinema.
### Context:
CREATE TABLE cinema (name VARCHAR, openning_year VARCHAR, capacity VARCHAR)
###Answer:
SELECT name, openning_year, capacity FROM cinema |
convert the question into postgresql query using the context values
### Question:
Show the cinema name and location for cinemas with capacity above average.
### Context:
CREATE TABLE cinema (name VARCHAR, LOCATION VARCHAR, capacity INTEGER)
###Answer:
SELECT name, LOCATION FROM cinema WHERE capacity > (SELECT AVG(capacity) FROM cinema) |
convert the question into postgresql query using the context values
### Question:
What are all the locations with a cinema?
### Context:
CREATE TABLE cinema (LOCATION VARCHAR)
###Answer:
SELECT DISTINCT LOCATION FROM cinema |
convert the question into postgresql query using the context values
### Question:
Show all the cinema names and opening years in descending order of opening year.
### Context:
CREATE TABLE cinema (name VARCHAR, openning_year VARCHAR)
###Answer:
SELECT name, openning_year FROM cinema ORDER BY openning_year DESC |
convert the question into postgresql query using the context values
### Question:
What are the name and location of the cinema with the largest capacity?
### Context:
CREATE TABLE cinema (name VARCHAR, LOCATION VARCHAR, capacity VARCHAR)
###Answer:
SELECT name, LOCATION FROM cinema ORDER BY capacity DESC LIMIT 1 |
convert the question into postgresql query using the context values
### Question:
Show the average, minimum, and maximum capacity for all the cinemas opened in year 2011 or later.
### Context:
CREATE TABLE cinema (capacity INTEGER, openning_year VARCHAR)
###Answer:
SELECT AVG(capacity), MIN(capacity), MAX(capacity) FROM cinema WHERE openning_year >= 2011 |
convert the question into postgresql query using the context values
### Question:
Show each location and the number of cinemas there.
### Context:
CREATE TABLE cinema (LOCATION VARCHAR)
###Answer:
SELECT LOCATION, COUNT(*) FROM cinema GROUP BY LOCATION |
convert the question into postgresql query using the context values
### Question:
What is the location with the most cinemas opened in year 2010 or later?
### Context:
CREATE TABLE cinema (LOCATION VARCHAR, openning_year VARCHAR)
###Answer:
SELECT LOCATION FROM cinema WHERE openning_year >= 2010 GROUP BY LOCATION ORDER BY COUNT(*) DESC LIMIT 1 |
convert the question into postgresql query using the context values
### Question:
Show all the locations with at least two cinemas with capacity above 300.
### Context:
CREATE TABLE cinema (LOCATION VARCHAR, capacity INTEGER)
###Answer:
SELECT LOCATION FROM cinema WHERE capacity > 300 GROUP BY LOCATION HAVING COUNT(*) >= 2 |
convert the question into postgresql query using the context values
### Question:
Show the title and director for all films.
### Context:
CREATE TABLE film (title VARCHAR, directed_by VARCHAR)
###Answer:
SELECT title, directed_by FROM film |
convert the question into postgresql query using the context values
### Question:
Show all directors.
### Context:
CREATE TABLE film (directed_by VARCHAR)
###Answer:
SELECT DISTINCT directed_by FROM film |
convert the question into postgresql query using the context values
### Question:
List all directors along with the number of films directed by each director.
### Context:
CREATE TABLE film (directed_by VARCHAR)
###Answer:
SELECT directed_by, COUNT(*) FROM film GROUP BY directed_by |
convert the question into postgresql query using the context values
### Question:
What is total number of show times per dat for each cinema?
### Context:
CREATE TABLE schedule (show_times_per_day INTEGER, cinema_id VARCHAR); CREATE TABLE cinema (name VARCHAR, cinema_id VARCHAR)
###Answer:
SELECT T2.name, SUM(T1.show_times_per_day) FROM schedule AS T1 JOIN cinema AS T2 ON T1.cinema_id = T2.cinema_id GROUP BY T1.cinema_id |
convert the question into postgresql query using the context values
### Question:
What are the title and maximum price of each film?
### Context:
CREATE TABLE film (title VARCHAR, film_id VARCHAR); CREATE TABLE schedule (price INTEGER, film_id VARCHAR)
###Answer:
SELECT T2.title, MAX(T1.price) FROM schedule AS T1 JOIN film AS T2 ON T1.film_id = T2.film_id GROUP BY T1.film_id |
convert the question into postgresql query using the context values
### Question:
Show cinema name, film title, date, and price for each record in schedule.
### Context:
CREATE TABLE schedule (date VARCHAR, price VARCHAR, film_id VARCHAR, cinema_id VARCHAR); CREATE TABLE cinema (name VARCHAR, cinema_id VARCHAR); CREATE TABLE film (title VARCHAR, film_id VARCHAR)
###Answer:
SELECT T3.name, T2.title, T1.date, T1.price FROM schedule AS T1 JOIN film AS T2 ON T1.film_id = T2.film_id JOIN cinema AS T3 ON T1.cinema_id = T3.cinema_id |
convert the question into postgresql query using the context values
### Question:
What are the title and director of the films without any schedule?
### Context:
CREATE TABLE schedule (title VARCHAR, directed_by VARCHAR, film_id VARCHAR); CREATE TABLE film (title VARCHAR, directed_by VARCHAR, film_id VARCHAR)
###Answer:
SELECT title, directed_by FROM film WHERE NOT film_id IN (SELECT film_id FROM schedule) |
convert the question into postgresql query using the context values
### Question:
Show director with the largest number of show times in total.
### Context:
CREATE TABLE schedule (film_id VARCHAR, show_times_per_day INTEGER); CREATE TABLE film (directed_by VARCHAR, film_id VARCHAR)
###Answer:
SELECT T2.directed_by FROM schedule AS T1 JOIN film AS T2 ON T1.film_id = T2.film_id GROUP BY T2.directed_by ORDER BY SUM(T1.show_times_per_day) DESC LIMIT 1 |
convert the question into postgresql query using the context values
### Question:
Find the locations that have more than one movie theater with capacity above 300.
### Context:
CREATE TABLE cinema (LOCATION VARCHAR, capacity INTEGER)
###Answer:
SELECT LOCATION FROM cinema WHERE capacity > 300 GROUP BY LOCATION HAVING COUNT(*) > 1 |
convert the question into postgresql query using the context values
### Question:
How many films have the word 'Dummy' in their titles?
### Context:
CREATE TABLE film (title VARCHAR)
###Answer:
SELECT COUNT(*) FROM film WHERE title LIKE "%Dummy%" |
convert the question into postgresql query using the context values
### Question:
Are the customers holding coupons with amount 500 bad or good?
### Context:
CREATE TABLE discount_coupons (coupon_id VARCHAR, coupon_amount VARCHAR); CREATE TABLE customers (good_or_bad_customer VARCHAR, coupon_id VARCHAR)
###Answer:
SELECT T1.good_or_bad_customer FROM customers AS T1 JOIN discount_coupons AS T2 ON T1.coupon_id = T2.coupon_id WHERE T2.coupon_amount = 500 |
convert the question into postgresql query using the context values
### Question:
How many bookings did each customer make? List the customer id, first name, and the count.
### Context:
CREATE TABLE bookings (customer_id VARCHAR); CREATE TABLE Customers (customer_id VARCHAR, first_name VARCHAR)
###Answer:
SELECT T1.customer_id, T1.first_name, COUNT(*) FROM Customers AS T1 JOIN bookings AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id |
convert the question into postgresql query using the context values
### Question:
What is the maximum total amount paid by a customer? List the customer id and amount.
### Context:
CREATE TABLE Payments (customer_id VARCHAR, amount_paid INTEGER)
###Answer:
SELECT customer_id, SUM(amount_paid) FROM Payments GROUP BY customer_id ORDER BY SUM(amount_paid) DESC LIMIT 1 |
convert the question into postgresql query using the context values
### Question:
What are the id and the amount of refund of the booking that incurred the most times of payments?
### Context:
CREATE TABLE Payments (booking_id VARCHAR); CREATE TABLE Bookings (booking_id VARCHAR, amount_of_refund VARCHAR)
###Answer:
SELECT T1.booking_id, T1.amount_of_refund FROM Bookings AS T1 JOIN Payments AS T2 ON T1.booking_id = T2.booking_id GROUP BY T1.booking_id ORDER BY COUNT(*) DESC LIMIT 1 |
convert the question into postgresql query using the context values
### Question:
What is the id of the product that is booked for 3 times?
### Context:
CREATE TABLE products_booked (product_id VARCHAR)
###Answer:
SELECT product_id FROM products_booked GROUP BY product_id HAVING COUNT(*) = 3 |
convert the question into postgresql query using the context values
### Question:
What is the product description of the product booked with an amount of 102.76?
### Context:
CREATE TABLE products_for_hire (product_description VARCHAR, product_id VARCHAR); CREATE TABLE products_booked (product_id VARCHAR, booked_amount VARCHAR)
###Answer:
SELECT T2.product_description FROM products_booked AS T1 JOIN products_for_hire AS T2 ON T1.product_id = T2.product_id WHERE T1.booked_amount = 102.76 |
convert the question into postgresql query using the context values
### Question:
What are the start date and end date of the booking that has booked the product named 'Book collection A'?
### Context:
CREATE TABLE bookings (booking_start_date VARCHAR, booking_end_date VARCHAR, booking_id VARCHAR); CREATE TABLE products_booked (product_id VARCHAR, booking_id VARCHAR); CREATE TABLE Products_for_hire (product_id VARCHAR, product_name VARCHAR)
###Answer:
SELECT T3.booking_start_date, T3.booking_end_date FROM Products_for_hire AS T1 JOIN products_booked AS T2 ON T1.product_id = T2.product_id JOIN bookings AS T3 ON T2.booking_id = T3.booking_id WHERE T1.product_name = 'Book collection A' |
convert the question into postgresql query using the context values
### Question:
What are the names of products whose availability equals to 1?
### Context:
CREATE TABLE view_product_availability (product_id VARCHAR, available_yn VARCHAR); CREATE TABLE products_for_hire (product_name VARCHAR, product_id VARCHAR)
###Answer:
SELECT T2.product_name FROM view_product_availability AS T1 JOIN products_for_hire AS T2 ON T1.product_id = T2.product_id WHERE T1.available_yn = 1 |
convert the question into postgresql query using the context values
### Question:
How many different product types are there?
### Context:
CREATE TABLE products_for_hire (product_type_code VARCHAR)
###Answer:
SELECT COUNT(DISTINCT product_type_code) FROM products_for_hire |
convert the question into postgresql query using the context values
### Question:
What are the first name, last name, and gender of all the good customers? Order by their last name.
### Context:
CREATE TABLE customers (first_name VARCHAR, last_name VARCHAR, gender_mf VARCHAR, good_or_bad_customer VARCHAR)
###Answer:
SELECT first_name, last_name, gender_mf FROM customers WHERE good_or_bad_customer = 'good' ORDER BY last_name |
convert the question into postgresql query using the context values
### Question:
What is the average amount due for all the payments?
### Context:
CREATE TABLE payments (amount_due INTEGER)
###Answer:
SELECT AVG(amount_due) FROM payments |
convert the question into postgresql query using the context values
### Question:
What are the maximum, minimum, and average booked count for the products booked?
### Context:
CREATE TABLE products_booked (booked_count INTEGER)
###Answer:
SELECT MAX(booked_count), MIN(booked_count), AVG(booked_count) FROM products_booked |
convert the question into postgresql query using the context values
### Question:
What are all the distinct payment types?
### Context:
CREATE TABLE payments (payment_type_code VARCHAR)
###Answer:
SELECT DISTINCT payment_type_code FROM payments |
convert the question into postgresql query using the context values
### Question:
What are the daily hire costs for the products with substring 'Book' in its name?
### Context:
CREATE TABLE Products_for_hire (daily_hire_cost VARCHAR, product_name VARCHAR)
###Answer:
SELECT daily_hire_cost FROM Products_for_hire WHERE product_name LIKE '%Book%' |
convert the question into postgresql query using the context values
### Question:
How many products are never booked with amount higher than 200?
### Context:
CREATE TABLE products_booked (product_id VARCHAR, booked_amount INTEGER); CREATE TABLE Products_for_hire (product_id VARCHAR, booked_amount INTEGER)
###Answer:
SELECT COUNT(*) FROM Products_for_hire WHERE NOT product_id IN (SELECT product_id FROM products_booked WHERE booked_amount > 200) |
convert the question into postgresql query using the context values
### Question:
What are the coupon amount of the coupons owned by both good and bad customers?
### Context:
CREATE TABLE Discount_Coupons (coupon_amount VARCHAR, coupon_id VARCHAR); CREATE TABLE customers (coupon_id VARCHAR, good_or_bad_customer VARCHAR)
###Answer:
SELECT T1.coupon_amount FROM Discount_Coupons AS T1 JOIN customers AS T2 ON T1.coupon_id = T2.coupon_id WHERE T2.good_or_bad_customer = 'good' INTERSECT SELECT T1.coupon_amount FROM Discount_Coupons AS T1 JOIN customers AS T2 ON T1.coupon_id = T2.coupon_id WHERE T2.good_or_bad_customer = 'bad' |
convert the question into postgresql query using the context values
### Question:
What are the payment date of the payment with amount paid higher than 300 or with payment type is 'Check'
### Context:
CREATE TABLE payments (payment_date VARCHAR, amount_paid VARCHAR, payment_type_code VARCHAR)
###Answer:
SELECT payment_date FROM payments WHERE amount_paid > 300 OR payment_type_code = 'Check' |
convert the question into postgresql query using the context values
### Question:
What are the names and descriptions of the products that are of 'Cutlery' type and have daily hire cost lower than 20?
### Context:
CREATE TABLE products_for_hire (product_name VARCHAR, product_description VARCHAR, product_type_code VARCHAR, daily_hire_cost VARCHAR)
###Answer:
SELECT product_name, product_description FROM products_for_hire WHERE product_type_code = 'Cutlery' AND daily_hire_cost < 20 |
convert the question into postgresql query using the context values
### Question:
How many phones are there?
### Context:
CREATE TABLE phone (Id VARCHAR)
###Answer:
SELECT COUNT(*) FROM phone |
convert the question into postgresql query using the context values
### Question:
List the names of phones in ascending order of price.
### Context:
CREATE TABLE phone (Name VARCHAR, Price VARCHAR)
###Answer:
SELECT Name FROM phone ORDER BY Price |
convert the question into postgresql query using the context values
### Question:
What are the memories and carriers of phones?
### Context:
CREATE TABLE phone (Memory_in_G VARCHAR, Carrier VARCHAR)
###Answer:
SELECT Memory_in_G, Carrier FROM phone |
convert the question into postgresql query using the context values
### Question:
List the distinct carriers of phones with memories bigger than 32.
### Context:
CREATE TABLE phone (Carrier VARCHAR, Memory_in_G INTEGER)
###Answer:
SELECT DISTINCT Carrier FROM phone WHERE Memory_in_G > 32 |
convert the question into postgresql query using the context values
### Question:
Show the names of phones with carrier either "Sprint" or "TMobile".
### Context:
CREATE TABLE phone (Name VARCHAR, Carrier VARCHAR)
###Answer:
SELECT Name FROM phone WHERE Carrier = "Sprint" OR Carrier = "TMobile" |
convert the question into postgresql query using the context values
### Question:
What is the carrier of the most expensive phone?
### Context:
CREATE TABLE phone (Carrier VARCHAR, Price VARCHAR)
###Answer:
SELECT Carrier FROM phone ORDER BY Price DESC LIMIT 1 |
convert the question into postgresql query using the context values
### Question:
Show different carriers of phones together with the number of phones with each carrier.
### Context:
CREATE TABLE phone (Carrier VARCHAR)
###Answer:
SELECT Carrier, COUNT(*) FROM phone GROUP BY Carrier |
convert the question into postgresql query using the context values
### Question:
Show the most frequently used carrier of the phones.
### Context:
CREATE TABLE phone (Carrier VARCHAR)
###Answer:
SELECT Carrier FROM phone GROUP BY Carrier ORDER BY COUNT(*) DESC LIMIT 1 |
convert the question into postgresql query using the context values
### Question:
Show the carriers that have both phones with memory smaller than 32 and phones with memory bigger than 64.
### Context:
CREATE TABLE phone (Carrier VARCHAR, Memory_in_G INTEGER)
###Answer:
SELECT Carrier FROM phone WHERE Memory_in_G < 32 INTERSECT SELECT Carrier FROM phone WHERE Memory_in_G > 64 |
convert the question into postgresql query using the context values
### Question:
Show the names of phones and the districts of markets they are on.
### Context:
CREATE TABLE phone (Name VARCHAR, Phone_ID VARCHAR); CREATE TABLE market (District VARCHAR, Market_ID VARCHAR); CREATE TABLE phone_market (Market_ID VARCHAR, Phone_ID VARCHAR)
###Answer:
SELECT T3.Name, T2.District FROM phone_market AS T1 JOIN market AS T2 ON T1.Market_ID = T2.Market_ID JOIN phone AS T3 ON T1.Phone_ID = T3.Phone_ID |
convert the question into postgresql query using the context values
### Question:
Show the names of phones and the districts of markets they are on, in ascending order of the ranking of the market.
### Context:
CREATE TABLE market (District VARCHAR, Market_ID VARCHAR, Ranking VARCHAR); CREATE TABLE phone (Name VARCHAR, Phone_ID VARCHAR); CREATE TABLE phone_market (Market_ID VARCHAR, Phone_ID VARCHAR)
###Answer:
SELECT T3.Name, T2.District FROM phone_market AS T1 JOIN market AS T2 ON T1.Market_ID = T2.Market_ID JOIN phone AS T3 ON T1.Phone_ID = T3.Phone_ID ORDER BY T2.Ranking |
convert the question into postgresql query using the context values
### Question:
Show the names of phones that are on market with number of shops greater than 50.
### Context:
CREATE TABLE market (Market_ID VARCHAR, Num_of_shops INTEGER); CREATE TABLE phone (Name VARCHAR, Phone_ID VARCHAR); CREATE TABLE phone_market (Market_ID VARCHAR, Phone_ID VARCHAR)
###Answer:
SELECT T3.Name FROM phone_market AS T1 JOIN market AS T2 ON T1.Market_ID = T2.Market_ID JOIN phone AS T3 ON T1.Phone_ID = T3.Phone_ID WHERE T2.Num_of_shops > 50 |
convert the question into postgresql query using the context values
### Question:
For each phone, show its names and total number of stocks.
### Context:
CREATE TABLE phone_market (Num_of_stock INTEGER, Phone_ID VARCHAR); CREATE TABLE phone (Name VARCHAR, Phone_ID VARCHAR)
###Answer:
SELECT T2.Name, SUM(T1.Num_of_stock) FROM phone_market AS T1 JOIN phone AS T2 ON T1.Phone_ID = T2.Phone_ID GROUP BY T2.Name |
convert the question into postgresql query using the context values
### Question:
Show the names of phones that have total number of stocks bigger than 2000, in descending order of the total number of stocks.
### Context:
CREATE TABLE phone_market (Phone_ID VARCHAR, Num_of_stock INTEGER); CREATE TABLE phone (Name VARCHAR, Phone_ID VARCHAR)
###Answer:
SELECT T2.Name FROM phone_market AS T1 JOIN phone AS T2 ON T1.Phone_ID = T2.Phone_ID GROUP BY T2.Name HAVING SUM(T1.Num_of_stock) >= 2000 ORDER BY SUM(T1.Num_of_stock) DESC |
convert the question into postgresql query using the context values
### Question:
List the names of phones that are not on any market.
### Context:
CREATE TABLE phone (Name VARCHAR, Phone_id VARCHAR, Phone_ID VARCHAR); CREATE TABLE phone_market (Name VARCHAR, Phone_id VARCHAR, Phone_ID VARCHAR)
###Answer:
SELECT Name FROM phone WHERE NOT Phone_id IN (SELECT Phone_ID FROM phone_market) |
convert the question into postgresql query using the context values
### Question:
How many gas companies are there?
### Context:
CREATE TABLE company (Id VARCHAR)
###Answer:
SELECT COUNT(*) FROM company |
convert the question into postgresql query using the context values
### Question:
List the company name and rank for all companies in the decreasing order of their sales.
### Context:
CREATE TABLE company (company VARCHAR, rank VARCHAR, Sales_billion VARCHAR)
###Answer:
SELECT company, rank FROM company ORDER BY Sales_billion DESC |
convert the question into postgresql query using the context values
### Question:
Show the company name and the main industry for all companies whose headquarters are not from USA.
### Context:
CREATE TABLE company (company VARCHAR, main_industry VARCHAR, headquarters VARCHAR)
###Answer:
SELECT company, main_industry FROM company WHERE headquarters <> 'USA' |
convert the question into postgresql query using the context values
### Question:
Show all company names and headquarters in the descending order of market value.
### Context:
CREATE TABLE company (company VARCHAR, headquarters VARCHAR, market_value VARCHAR)
###Answer:
SELECT company, headquarters FROM company ORDER BY market_value DESC |
convert the question into postgresql query using the context values
### Question:
Show minimum, maximum, and average market value for all companies.
### Context:
CREATE TABLE company (market_value INTEGER)
###Answer:
SELECT MIN(market_value), MAX(market_value), AVG(market_value) FROM company |
convert the question into postgresql query using the context values
### Question:
Show all main industry for all companies.
### Context:
CREATE TABLE company (main_industry VARCHAR)
###Answer:
SELECT DISTINCT main_industry FROM company |
convert the question into postgresql query using the context values
### Question:
List all headquarters and the number of companies in each headquarter.
### Context:
CREATE TABLE company (headquarters VARCHAR)
###Answer:
SELECT headquarters, COUNT(*) FROM company GROUP BY headquarters |
convert the question into postgresql query using the context values
### Question:
Show all main industry and total market value in each industry.
### Context:
CREATE TABLE company (main_industry VARCHAR, market_value INTEGER)
###Answer:
SELECT main_industry, SUM(market_value) FROM company GROUP BY main_industry |
convert the question into postgresql query using the context values
### Question:
List the main industry with highest total market value and its number of companies.
### Context:
CREATE TABLE company (main_industry VARCHAR, market_value INTEGER)
###Answer:
SELECT main_industry, COUNT(*) FROM company GROUP BY main_industry ORDER BY SUM(market_value) DESC LIMIT 1 |
convert the question into postgresql query using the context values
### Question:
Show headquarters with at least two companies in the banking industry.
### Context:
CREATE TABLE company (headquarters VARCHAR, main_industry VARCHAR)
###Answer:
SELECT headquarters FROM company WHERE main_industry = 'Banking' GROUP BY headquarters HAVING COUNT(*) >= 2 |