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