context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE refugee_camps (id INT, camp_name TEXT, country TEXT, total_donations DECIMAL(10,2)); INSERT INTO refugee_camps (id, camp_name, country, total_donations) VALUES (1, 'Kakuma', 'Kenya', 5000000.00), (2, 'Dadaab', 'Kenya', 7000000.00), (3, 'Zaatari', 'Jordan', 12000000.00), (4, 'Azraq', 'Jordan', 8000000.00);
|
Update the total_donations value for the 'Kakuma' refugee camp by adding 10% to its current value.
|
UPDATE refugee_camps SET total_donations = total_donations * 1.10 WHERE camp_name = 'Kakuma';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donations (id INT, donation_amount DECIMAL(10,2), donation_date DATE, donor_program VARCHAR(50));
|
What is the total donation amount for the 'Green Earth' program in Q2 2022?
|
SELECT SUM(Donations.donation_amount) FROM Donations WHERE Donations.donation_date BETWEEN '2022-04-01' AND '2022-06-30' AND Donations.donor_program = 'Green Earth';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE storage (chemical_id INT); CREATE TABLE chemicals (id INT, chemical_name VARCHAR(255), safety_rating INT); INSERT INTO storage (chemical_id) VALUES (1), (3), (5); INSERT INTO chemicals (id, chemical_name, safety_rating) VALUES (1, 'H2O', 85), (2, 'CO2', 70), (3, 'N2', 60), (4, 'O2', 95), (5, 'F2', 80);
|
Update the 'safety_rating' in the 'chemicals' table to 95 for any chemical with an ID present in the 'storage' table and a safety rating below 90.
|
UPDATE chemicals SET safety_rating = 95 WHERE id IN (SELECT chemical_id FROM storage) AND safety_rating < 90;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE UserRegistrations (reg_id INT, reg_date DATE, user_id INT, user_info VARCHAR(255)); INSERT INTO UserRegistrations (reg_id, reg_date, user_id, user_info) VALUES (1, '2020-01-01', 1, 'John Doe'), (2, '2020-01-07', 2, 'Jane Doe'), (3, '2020-01-05', 3, 'Mike Johnson');
|
How many new users registered on the music platform per week?
|
SELECT DATE_FORMAT(reg_date, '%Y-%u') as registration_week, COUNT(DISTINCT user_id) as new_users_per_week FROM UserRegistrations GROUP BY registration_week;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Purchases (PurchaseID INT, PlayerID INT, GameID INT, PurchaseDate DATE, Price DECIMAL(5, 2)); INSERT INTO Purchases (PurchaseID, PlayerID, GameID, PurchaseDate, Price) VALUES (1, 1, 1, '2021-01-15', 29.99), (2, 2, 2, '2021-02-03', 19.99), (3, 3, 3, '2021-03-10', 39.99), (4, 1, 4, '2021-03-15', 49.99), (5, 2, 5, '2021-04-01', 59.99), (6, 3, 1, '2021-04-05', 29.99); CREATE TABLE GameGenres (GameID INT, Genre VARCHAR(20)); INSERT INTO GameGenres (GameID, Genre) VALUES (1, 'Role-playing'), (2, 'Action'), (3, 'Strategy'), (4, 'Adventure'), (5, 'Simulation'), (6, 'Virtual Reality');
|
What is the total revenue generated from the 'Adventure' genre in the last month?
|
SELECT SUM(Price) FROM Purchases INNER JOIN GameGenres ON Purchases.GameID = GameGenres.GameID WHERE PurchaseDate >= DATEADD(month, -1, GETDATE()) AND GameGenres.Genre = 'Adventure';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE revenue (restaurant_id INT, date DATE, revenue INT, sourcing_category VARCHAR(50)); INSERT INTO revenue (restaurant_id, date, revenue, sourcing_category) VALUES (1, '2022-02-01', 5000, 'Organic'), (1, '2022-02-02', 6000, 'Local'), (2, '2022-02-01', 4000, 'Fair Trade'), (2, '2022-02-02', 7000, 'Organic');
|
What is the total revenue per sustainable sourcing category in February 2022?
|
SELECT sourcing_category, SUM(revenue) as total_revenue FROM revenue WHERE MONTH(date) = 2 GROUP BY sourcing_category;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE dish (dish_id INT, dish_name TEXT, waste_percentage DECIMAL(5,2), calories INT); INSERT INTO dish (dish_id, dish_name, waste_percentage, calories) VALUES (1, 'Pizza Margherita', 0.12, 800), (2, 'Veggie Burger', 0.18, 600);
|
What is the average waste percentage for each dish and how many calories are there in each dish?
|
SELECT dish_name, AVG(waste_percentage) as avg_waste_percentage, AVG(calories) as avg_calories FROM dish GROUP BY dish_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SpaceShuttleAstronauts (AstronautName TEXT, Missions INTEGER);CREATE TABLE SoyuzAstronauts (AstronautName TEXT, Missions INTEGER);
|
What's the combined list of astronauts who have flown on both the Space Shuttle and Soyuz spacecraft?
|
SELECT AstronautName FROM SpaceShuttleAstronauts WHERE Missions > 1 INTERSECT SELECT AstronautName FROM SoyuzAstronauts WHERE Missions > 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Restaurants (RestaurantID int, Name varchar(50)); INSERT INTO Restaurants (RestaurantID, Name) VALUES (1, 'Paleteria Y Neveria'), (2, 'Thai Spice'), (3, 'Bombay Kitchen'), (4, 'Sushi Bar'); CREATE TABLE MenuItems (MenuItemID int, RestaurantID int, Name varchar(50), Revenue decimal(5,2)); INSERT INTO MenuItems (MenuItemID, RestaurantID, Name, Revenue) VALUES (1, 1, 'Mango Paleta', 3.00), (2, 1, 'Pineapple Paleta', 3.00), (3, 2, 'Pad Thai', 12.00), (4, 2, 'Tom Yum Soup', 6.00), (5, 3, 'Chicken Tikka Masala', 15.00), (6, 3, 'Naan Bread', 3.00), (7, 4, 'Spicy Tuna Roll', 8.00), (8, 4, 'Philadelphia Roll', 7.00);
|
Find the number of menu items offered by each restaurant, and rank them in order of highest to lowest number of menu items.
|
SELECT R.Name, COUNT(MI.MenuItemID) AS NumMenuItems, ROW_NUMBER() OVER (ORDER BY COUNT(MI.MenuItemID) DESC) AS Rank FROM Restaurants R LEFT JOIN MenuItems MI ON R.RestaurantID = MI.RestaurantID GROUP BY R.Name ORDER BY Rank;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donors (id INT, name TEXT, country TEXT, donation FLOAT); INSERT INTO donors (id, name, country, donation) VALUES (1, 'John Doe', 'USA', 500.00), (2, 'Jane Smith', 'Canada', 300.00);
|
What was the total amount donated by individual donors from the US in Q1 2021?
|
SELECT SUM(donation) FROM donors WHERE country = 'USA' AND donation_date BETWEEN '2021-01-01' AND '2021-03-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE garment_water_data (garment_id INT, garment_type VARCHAR(255), production_location VARCHAR(255), water_consumption INT, year INT);
|
What is the average water consumption per garment type in South America for 2021?
|
SELECT garment_type, AVG(water_consumption) AS avg_water_consumption FROM garment_water_data WHERE production_location LIKE 'South America%' AND year = 2021 GROUP BY garment_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE climate_mitigation_projects (year INT, project VARCHAR(20), budget FLOAT); INSERT INTO climate_mitigation_projects (year, project, budget) VALUES (2017, 'Project1', 6000000), (2018, 'Project2', 8000000), (2019, 'Project3', 1000000), (2020, 'Project4', 1200000), (2021, 'Project5', 1400000), (2022, 'Project6', 1600000);
|
Identify the number of mitigation projects per year between 2017 and 2022, and display the total budget for each year.
|
SELECT year, COUNT(DISTINCT project) AS num_projects, SUM(budget) AS total_budget FROM climate_mitigation_projects WHERE year BETWEEN 2017 AND 2022 GROUP BY year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE factories (factory_id INT, name VARCHAR(100), location VARCHAR(100), num_employees INT); CREATE TABLE employees (employee_id INT, factory_id INT, name VARCHAR(100), position VARCHAR(100)); INSERT INTO factories (factory_id, name, location, num_employees) VALUES (1, 'ABC Factory', 'North', 50), (2, 'XYZ Factory', 'South', 75), (3, 'LMN Factory', 'East', 100), (4, 'PQR Factory', 'West', 80); INSERT INTO employees (employee_id, factory_id, name, position) VALUES (1, 1, 'John Doe', 'Engineer'), (2, 1, 'Jane Smith', 'Manager'), (3, 2, 'Mike Johnson', 'Operator'), (4, 3, 'Sara Brown', 'Engineer'), (5, 3, 'David Williams', 'Manager'), (6, 4, 'Emily Davis', 'Engineer');
|
What is the maximum number of employees in factories located in a specific region?
|
SELECT MAX(factories.num_employees) FROM factories WHERE factories.location = 'East';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE AstrobiologyDiscoveries (id INT PRIMARY KEY, name VARCHAR(255), discovery_date DATE);
|
What is the latest astrobiology discovery?
|
SELECT name FROM AstrobiologyDiscoveries ORDER BY discovery_date DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_species (species_name TEXT, endangered BOOLEAN, ocean TEXT); INSERT INTO marine_species (species_name, endangered, ocean) VALUES ('Greenland Shark', FALSE, 'Atlantic'), ('Blue Whale', TRUE, 'Atlantic');
|
Find the number of endangered marine species in the Atlantic Ocean.
|
SELECT COUNT(*) FROM marine_species WHERE endangered = TRUE AND ocean = 'Atlantic';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE transportation (id INT, system_type VARCHAR(20), ridership INT, year INT); INSERT INTO transportation (id, system_type, ridership, year) VALUES (1, 'Subway', 5000000, 2022), (2, 'Bus', 3000000, 2022), (3, 'Light Rail', 1000000, 2022), (4, 'Ferry', 500000, 2022);
|
Which public transportation systems have the highest and lowest ridership in 'transportation' table for the year 2022?
|
SELECT system_type, ridership FROM (SELECT system_type, ridership, ROW_NUMBER() OVER (ORDER BY ridership DESC) AS rank FROM transportation WHERE system_type LIKE '%public%' AND year = 2022) AS subquery WHERE rank = 1 OR rank = 4;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE OceanFloorTrenches (id INT, ocean_id INT, trench VARCHAR(50), depth INT); INSERT INTO OceanFloorTrenches (id, ocean_id, trench, depth) VALUES (1, 1, 'Mariana Trench', 10994), (2, 2, 'Tonga Trench', 10820), (3, 3, 'Sunda Trench', 8045);
|
What is the maximum depth of the Mariana Trench?
|
SELECT MAX(OceanFloorTrenches.depth) FROM OceanFloorTrenches WHERE OceanFloorTrenches.trench = 'Mariana Trench';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE GameContinents (GameID INT, GameName VARCHAR(20), Continent VARCHAR(20), Genre VARCHAR(20)); INSERT INTO GameContinents (GameID, GameName, Continent, Genre) VALUES (1, 'GameE', 'Asia', 'Adventure'), (2, 'GameF', 'Europe', 'Simulation'), (3, 'GameG', 'North America', 'Strategy'), (4, 'GameH', 'Australia', 'Adventure');
|
What are the unique game genres played on each continent?
|
SELECT DISTINCT Continent, Genre FROM GameContinents WHERE Genre IS NOT NULL;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hospitals (name VARCHAR(255), province VARCHAR(255), icu_beds INT); INSERT INTO hospitals (name, province, icu_beds) VALUES ('Montreal General Hospital', 'Quebec', 50), ('Saint-Justine Hospital', 'Quebec', 75), ('McGill University Health Center', 'Quebec', 100);
|
How many hospitals are there in Quebec, and what is the total number of beds in their intensive care units?
|
SELECT COUNT(*) AS total_hospitals, SUM(icu_beds) AS total_icu_beds FROM hospitals WHERE province = 'Quebec';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE permit (permit_id INT, quarter VARCHAR(10), cost FLOAT); INSERT INTO permit VALUES (1, 'Q2', 5000); INSERT INTO permit VALUES (2, 'Q3', 6000);
|
Identify permit costs in Q2 2021 with a lead of the following quarter's costs.
|
SELECT permit_id, quarter, cost, LEAD(cost) OVER (ORDER BY quarter) as next_quarter_cost FROM permit WHERE quarter IN ('Q2', 'Q3');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE consumption (id INT, region VARCHAR(20), type VARCHAR(20), consumption INT); INSERT INTO consumption (id, region, type, consumption) VALUES (1, 'Southern', 'Green', 1000); INSERT INTO consumption (id, region, type, consumption) VALUES (2, 'Northern', 'Regular', 2000);
|
What is the total energy consumption of green buildings in the Southern region?
|
SELECT SUM(consumption) FROM consumption WHERE region = 'Southern' AND type = 'Green';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE PublicWorks(id INT, city VARCHAR(20), project VARCHAR(30), budget DECIMAL(10,2)); INSERT INTO PublicWorks(id, city, project, budget) VALUES (1, 'New York', 'Subway Expansion', 1500000.00), (2, 'Los Angeles', 'Highway Construction', 800000.00);
|
Which public works projects in 'New York' have a budget greater than $1,000,000?
|
SELECT city, project, budget FROM PublicWorks WHERE budget > 1000000.00 AND city = 'New York';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE fairness_assessments (assessment_id INT, assessment_date DATE, continent TEXT); INSERT INTO fairness_assessments (assessment_id, assessment_date, continent) VALUES (1, '2022-01-02', 'Africa'), (2, '2022-02-15', 'Africa'), (3, '2022-03-27', 'Africa');
|
What is the total number of algorithmic fairness assessments conducted in Africa in 2022?
|
SELECT COUNT(*) as num_assessments FROM fairness_assessments WHERE continent = 'Africa' AND assessment_date BETWEEN '2022-01-01' AND '2022-12-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Voyage (id INT, vessel VARCHAR(255), time_in_port INT, country VARCHAR(255), time DATETIME); INSERT INTO Voyage (id, vessel, time_in_port, country, time) VALUES (1, 'Arctic Explorer', 12, 'Canada', '2021-01-01 10:00:00'), (2, 'Sea Titan', 10, 'USA', '2021-02-15 15:30:00');
|
What is the average time spent in port by vessels that have transported containers to Canada in the year 2021?
|
SELECT AVG(time_in_port) FROM Voyage V WHERE country = 'Canada';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE IncomeLevel (IncomeLevelID INT PRIMARY KEY, IncomeLevel VARCHAR(50), DigitalDivideIndex DECIMAL(5,2)); INSERT INTO IncomeLevel (IncomeLevelID, IncomeLevel, DigitalDivideIndex) VALUES (1, 'Low Income', 0.65), (2, 'Middle Income', 0.45), (3, 'High Income', 0.25);
|
What is the maximum digital divide index for each income level?
|
SELECT IncomeLevel, MAX(DigitalDivideIndex) as MaxDigitalDivideIndex FROM IncomeLevel GROUP BY IncomeLevel;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE shipments(id INT, load_date DATE, unloaded_date DATE); INSERT INTO shipments VALUES(1, '2021-01-01', '2021-01-05');
|
Delete all shipments from January 2021
|
DELETE FROM shipments WHERE load_date >= '2021-01-01' AND load_date < '2021-02-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE artists (id INT, name TEXT, country TEXT, medium TEXT, works_count INT); INSERT INTO artists (id, name, country, medium, works_count) VALUES (1, 'John Doe', 'Nigeria', 'Sculpture', 12), (2, 'Jane Smith', 'Kenya', 'Painting', 25), (3, 'Mohamed Ahmed', 'Egypt', 'Sculpture', 8), (4, 'Aisha Mohamed', 'Senegal', 'Painting', 30), (5, 'Pedro Gonzales', 'South Africa', 'Drawing', 18);
|
Who are the top 3 artists with the most works in the 'Painting' medium?
|
SELECT name, medium, SUM(works_count) AS total_works FROM artists WHERE medium = 'Painting' GROUP BY name, medium ORDER BY total_works DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE network_towers (tower_id INT, state VARCHAR(20), investment_date DATE); INSERT INTO network_towers (tower_id, state, investment_date) VALUES (1, 'California', '2017-12-31'), (2, 'California', '2018-01-02'), (3, 'Texas', '2018-01-01');
|
List all network towers in the state of California that have a investment date on or after 2018-01-01.
|
SELECT tower_id, state, investment_date FROM network_towers WHERE state = 'California' AND investment_date >= '2018-01-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE virtual_tours_france (tour_id INT, tour_name TEXT, country TEXT, revenue FLOAT); INSERT INTO virtual_tours_france (tour_id, tour_name, country, revenue) VALUES (1, 'Eiffel Tower Virtual Tour', 'France', 30000), (2, 'Louvre Virtual Tour', 'France', 35000);
|
What is the maximum revenue generated by virtual tours in France?
|
SELECT MAX(revenue) FROM virtual_tours_france WHERE country = 'France';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE pilot_flight_time (pilot_name VARCHAR(20), flight_time INT, month VARCHAR(10)); INSERT INTO pilot_flight_time (pilot_name, flight_time, month) VALUES ('John', 50, 'January'), ('John', 45, 'February'), ('John', 55, 'March'), ('Jane', 60, 'January'), ('Jane', 65, 'February'), ('Jane', 70, 'March');
|
What are the average hours of flight time per month for each pilot in the air force?
|
SELECT pilot_name, AVG(flight_time) FROM pilot_flight_time GROUP BY pilot_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE carbon_offsets (id INT PRIMARY KEY, program_name VARCHAR(100), country VARCHAR(50), tons_offset INT);
|
Add a new record to the 'carbon_offsets' table with id 5001, program_name 'Renewable Forests', country 'Canada', and tons_offset 50000
|
INSERT INTO carbon_offsets (id, program_name, country, tons_offset) VALUES (5001, 'Renewable Forests', 'Canada', 50000);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE whale_species (id INT, species VARCHAR(255), median_length FLOAT); INSERT INTO whale_species (id, species, median_length) VALUES (1, 'Blue Whale', 25);
|
Which whale species has the largest median length?
|
SELECT species, MAX(median_length) FROM whale_species GROUP BY species ORDER BY MAX(median_length) DESC LIMIT 1
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE shared_bikes (bike_id int, city varchar(20), registration_date date); INSERT INTO shared_bikes (bike_id, city, registration_date) VALUES (1, 'Beijing', '2021-08-12'), (2, 'Beijing', '2022-02-24'), (3, 'Beijing', '2022-03-10');
|
How many shared bikes are available in Beijing as of 2022-03-15?
|
SELECT COUNT(*) FROM shared_bikes WHERE city = 'Beijing' AND registration_date <= '2022-03-15';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CommunityEvents (event_id INT, region VARCHAR(50), event_type VARCHAR(50)); INSERT INTO CommunityEvents (event_id, region, event_type) VALUES (1, 'North', 'Workshop'), (2, 'South', 'Concert'), (3, 'East', 'Lecture'), (4, 'West', 'Festival');
|
How many community engagement events were held in each region?
|
SELECT region, COUNT(*) as event_count FROM CommunityEvents GROUP BY region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE budget_allocations (allocation_id INT, borough TEXT, category TEXT, budget INT); INSERT INTO budget_allocations (allocation_id, borough, category, budget) VALUES (1, 'Manhattan', 'Parks', 5000000), (2, 'Brooklyn', 'Libraries', 3000000), (3, 'Bronx', 'Parks', 2000000);
|
What is the total budget allocated to parks in each borough?
|
SELECT borough, SUM(budget) FROM budget_allocations WHERE category = 'Parks' GROUP BY borough;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE company (id INT, name TEXT, founder_race TEXT); INSERT INTO company (id, name, founder_race) VALUES (1, 'Acme Inc', 'Black'), (2, 'Beta Corp', 'White'), (3, 'Gamma PLC', 'Asian'); CREATE TABLE investment (investor_id INT, company_id INT); INSERT INTO investment (investor_id, company_id) VALUES (1, 1), (2, 3);
|
Find companies founded by individuals who identify as Black or African American that have raised funds.
|
SELECT * FROM company WHERE founder_race = 'Black' AND id IN (SELECT company_id FROM investment)
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customer_usage (id INT, subscriber_id INT, service VARCHAR(20), usage INT); INSERT INTO customer_usage (id, subscriber_id, service, usage) VALUES (1, 1001, 'mobile', 500);
|
Show customer usage patterns for mobile and broadband subscribers in 'urban' regions.
|
SELECT subscriber_id, service, usage FROM customer_usage WHERE service IN ('mobile', 'broadband') AND (SELECT region FROM mobile_subscribers WHERE id = subscriber_id) = 'urban';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sustainable_vendors (id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255));
|
Delete records of Blue Harvest vendor from the sustainable_vendors table
|
DELETE FROM sustainable_vendors WHERE name = 'Blue Harvest';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ai_companies (id INT, name VARCHAR(100), employees INT, last_paper_year INT); CREATE TABLE explainable_papers (id INT, company_id INT, title VARCHAR(100), year INT);
|
Identify AI companies with more than 50 employees that have not published any explainable AI research papers in the last 2 years?
|
SELECT name FROM ai_companies WHERE employees > 50 AND last_paper_year < YEAR(CURRENT_DATE) - 2 AND id NOT IN (SELECT company_id FROM explainable_papers WHERE year BETWEEN YEAR(CURRENT_DATE) - 2 AND YEAR(CURRENT_DATE));
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Accommodations (Student VARCHAR(255), School VARCHAR(255), Accommodation VARCHAR(255)); INSERT INTO Accommodations (Student, School, Accommodation) VALUES ('Student1', 'SchoolA', 'Visual Aids'), ('Student2', 'SchoolA', 'Modified Curriculum'), ('Student3', 'SchoolB', 'Visual Aids');
|
What is the average number of accommodations provided per student with intellectual disabilities in each school?
|
SELECT School, AVG(CountOfAccommodations) as AverageAccommodationsPerStudent FROM (SELECT School, Student, COUNT(*) as CountOfAccommodations FROM Accommodations WHERE Accommodation LIKE '%Intellectual Disability%' GROUP BY School, Student) as Subquery GROUP BY School;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sea_level_rise (id INT, year INT, rise FLOAT); INSERT INTO sea_level_rise (id, year, rise) VALUES (1, 2000, 1.5); INSERT INTO sea_level_rise (id, year, rise) VALUES (2, 2005, 1.8); INSERT INTO sea_level_rise (id, year, rise) VALUES (3, 2010, 2.1);
|
What is the average sea level rise, grouped by year?
|
SELECT year, AVG(rise) FROM sea_level_rise GROUP BY year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE us_diversion_programs (id INT, community VARCHAR(255), num_programs INT); INSERT INTO us_diversion_programs (id, community, num_programs) VALUES (1, 'Navajo Nation', 10), (2, 'Cherokee Nation', 15), (3, 'Sioux Nation', 8);CREATE TABLE canada_diversion_programs (id INT, community VARCHAR(255), num_programs INT); INSERT INTO canada_diversion_programs (id, community, num_programs) VALUES (1, 'First Nations', 12), (2, 'Inuit', 6), (3, 'Métis', 9);
|
How many diversion programs exist in Native American communities in the US compared to those in Canada?
|
SELECT 'USA' AS country, community, SUM(num_programs) AS total_programs FROM us_diversion_programs GROUP BY community UNION ALL SELECT 'Canada' AS country, community, SUM(num_programs) AS total_programs FROM canada_diversion_programs GROUP BY community;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE safety_scores (id INT, vehicle VARCHAR(50), make VARCHAR(50), country VARCHAR(50), score INT); INSERT INTO safety_scores VALUES (1, 'Model S', 'Tesla', 'USA', 92); INSERT INTO safety_scores VALUES (2, 'Prius', 'Toyota', 'Japan', 89);
|
Show safety testing scores for vehicles manufactured in Japan
|
SELECT * FROM safety_scores WHERE country = 'Japan';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customers (id INT, name TEXT, region TEXT, savings REAL);
|
List the names of customers who have a savings balance greater than $7000.
|
SELECT customers.name FROM customers WHERE savings > 7000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Arctic_Mammals (ID INT, Name VARCHAR(50), Population INT, Status VARCHAR(50)); INSERT INTO Arctic_Mammals VALUES (1, 'Polar Bear', 1000, 'Least Concern'); INSERT INTO Arctic_Mammals VALUES (2, 'Walrus', 2000, 'Least Concern'); INSERT INTO Arctic_Mammals VALUES (3, 'Arctic Fox', 1500, 'Vulnerable'); CREATE TABLE Endangered_Species (ID INT, Name VARCHAR(50), Population INT, Status VARCHAR(50)); INSERT INTO Endangered_Species VALUES (1, 'Polar Bear', 1000, 'Vulnerable'); INSERT INTO Endangered_Species VALUES (2, 'Walrus', 2000, 'Near Threatened');
|
How many species of mammals are present in the 'Arctic_Mammals' table, but not in the 'Endangered_Species' table?
|
SELECT COUNT(*) FROM Arctic_Mammals EXCEPT SELECT * FROM Endangered_Species;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE student_demographics (student_id INT, age INT, mental_health_score INT);
|
What is the average mental health score of students per age group?
|
SELECT age, AVG(mental_health_score) FROM student_demographics GROUP BY age;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE menu (menu_id INT, menu_name VARCHAR(255), is_vegetarian BOOLEAN, quantity_sold INT); INSERT INTO menu (menu_id, menu_name, is_vegetarian, quantity_sold) VALUES (1, 'Quinoa Salad', TRUE, 25), (2, 'Margherita Pizza', FALSE, 30), (3, 'Vegetable Curry', TRUE, 40);
|
What is the total quantity of vegetarian menu items sold in the month of January 2022?
|
SELECT SUM(quantity_sold) FROM menu WHERE is_vegetarian = TRUE AND MONTH(order_date) = 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE national_security (id INT PRIMARY KEY, threat VARCHAR(50), level VARCHAR(50), region VARCHAR(50), year INT); INSERT INTO national_security (id, threat, level, region, year) VALUES (5, 'Cyber Warfare', 'High', 'North America', 2012); INSERT INTO national_security (id, threat, level, region, year) VALUES (6, 'Cyber Theft', 'Medium', 'Asia', 2017);
|
What is the earliest year in which a high level threat occurred in each region?
|
SELECT region, MIN(year) as first_threat_year FROM national_security WHERE level = 'High' GROUP BY region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ids_logs (id INT, timestamp TIMESTAMP, ip_address VARCHAR(255)); INSERT INTO ids_logs (id, timestamp, ip_address) VALUES (1, '2022-01-01 12:00:00', '172.16.0.1'), (2, '2022-01-02 10:30:00', '192.168.0.1');
|
How many times has a specific IP address appeared in the IDS logs in the last month?
|
SELECT COUNT(*) as num_occurrences FROM ids_logs WHERE ip_address = '192.168.0.1' AND timestamp >= NOW() - INTERVAL 1 MONTH;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE workforce_diversity (site_id INT, site_name TEXT, worker_id INT, worker_role TEXT, gender TEXT, age INT); INSERT INTO workforce_diversity (site_id, site_name, worker_id, worker_role, gender, age) VALUES (1, 'ABC Mine', 1001, 'Mining Engineer', 'Female', 28), (2, 'DEF Mine', 2001, 'Miner', 'Male', 45), (3, 'GHI Mine', 3001, 'Safety Manager', 'Male', 50), (1, 'ABC Mine', 1002, 'Geologist', 'Female', 32), (2, 'DEF Mine', 2002, 'Miner', 'Female', 38);
|
What is the percentage of female workers at each mine site?
|
SELECT site_name, (COUNT(*) FILTER (WHERE gender = 'Female')) * 100.0 / COUNT(*) as percentage_female FROM workforce_diversity GROUP BY site_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE waste_generation (id INT, city VARCHAR(20), amount INT); INSERT INTO waste_generation (id, city, amount) VALUES (1, 'Tokyo', 5000), (2, 'Osaka', 3000);
|
Calculate the total waste generated in 'Tokyo' and 'Osaka'
|
SELECT SUM(amount) FROM waste_generation WHERE city IN ('Tokyo', 'Osaka');
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA if not exists arts_culture;CREATE TABLE if not exists arts_culture.audiences (audience_id INT PRIMARY KEY, name VARCHAR(255));CREATE TABLE if not exists arts_culture.events (event_id INT PRIMARY KEY, name VARCHAR(255), audience_id INT, FOREIGN KEY (audience_id) REFERENCES arts_culture.audiences(audience_id));INSERT INTO arts_culture.audiences (audience_id, name) VALUES (1, 'John Doe'), (2, 'Jane Smith'), (3, 'Jim Brown');INSERT INTO arts_culture.events (event_id, name, audience_id) VALUES (1, 'Art Exhibition', 1), (2, 'Theater Performance', 1), (3, 'Music Concert', 2);
|
What is the number of events attended by each audience member, ordered by the number of events?
|
SELECT a.name as audience_name, COUNT(e.event_id) as attended_events FROM arts_culture.audiences a JOIN arts_culture.events e ON a.audience_id = e.audience_id GROUP BY a.name ORDER BY attended_events DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Rural_Patients (Patient_ID INT, Age INT, Gender VARCHAR(10), Diagnosis VARCHAR(20)); INSERT INTO Rural_Patients (Patient_ID, Age, Gender, Diagnosis) VALUES (1, 35, 'Male', 'Hypertension'); INSERT INTO Rural_Patients (Patient_ID, Age, Gender, Diagnosis) VALUES (2, 42, 'Female', 'Asthma'); CREATE TABLE Hypertension_Diagnosis (Diagnosis VARCHAR(20), Diagnosis_Date DATE); INSERT INTO Hypertension_Diagnosis (Diagnosis, Diagnosis_Date) VALUES ('Hypertension', '2020-01-01');
|
What is the maximum age of patients who were diagnosed with Hypertension?
|
SELECT MAX(Rural_Patients.Age) FROM Rural_Patients INNER JOIN Hypertension_Diagnosis ON Rural_Patients.Diagnosis = Hypertension_Diagnosis.Diagnosis;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE student_preference (student_id INT, district_id INT, preference VARCHAR(10)); INSERT INTO student_preference (student_id, district_id, preference) VALUES (1, 101, 'open'), (2, 101, 'traditional'), (3, 102, 'open'), (4, 102, 'open'), (5, 103, 'traditional');
|
What is the percentage of students who prefer open pedagogy in each school district?
|
SELECT district_id, 100.0 * SUM(CASE WHEN preference = 'open' THEN 1 ELSE 0 END) / COUNT(*) AS pct_open FROM student_preference GROUP BY district_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE artist_statements (statement_length INTEGER); INSERT INTO artist_statements (statement_length) VALUES (50), (100), (150);
|
What is the average length of all artist statements in the database?
|
SELECT AVG(statement_length) FROM artist_statements;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mediators (id INT, name VARCHAR(255), cases_mediated INT, year INT); INSERT INTO mediators (id, name, cases_mediated, year) VALUES (1, 'Alex', 22, 2020), (2, 'Taylor', 30, 2020), (3, 'Jamie', 40, 2020);
|
What is the maximum number of cases mediated by a single mediator in a year?
|
SELECT MAX(cases_mediated) FROM mediators WHERE year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE expeditions (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), focus VARCHAR(255)); INSERT INTO expeditions (id, name, location, focus) VALUES (1, 'Shark Exploration', 'Atlantic Ocean', 'Sharks');
|
What are the names and locations of all expeditions studying sharks?
|
SELECT expeditions.name, expeditions.location FROM expeditions WHERE expeditions.focus = 'Sharks';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE warehouse (id VARCHAR(5), name VARCHAR(10), location VARCHAR(15)); INSERT INTO warehouse (id, name, location) VALUES ('W01', 'BOS', 'Boston'), ('W02', 'NYC', 'New York'), ('W03', 'SEA', 'Seattle'); CREATE TABLE shipment (id INT, warehouse_id VARCHAR(5), destination VARCHAR(10), weight INT, shipped_date DATE); INSERT INTO shipment (id, warehouse_id, destination, weight, shipped_date) VALUES (1, 'SEA', 'NYC', 100, '2022-01-05'), (2, 'SEA', 'LAX', 200, '2022-01-10'), (3, 'SEA', 'CHI', 150, '2022-01-15');
|
List the destinations and total shipment weights for shipments originating from 'SEA' in January 2022.
|
SELECT s.destination, SUM(s.weight) FROM shipment s JOIN warehouse w ON s.warehouse_id = w.id WHERE w.name = 'SEA' AND s.shipped_date >= '2022-01-01' AND s.shipped_date < '2022-02-01' GROUP BY s.destination;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE company (id INT, name TEXT, industry TEXT); INSERT INTO company (id, name, industry) VALUES (1, 'RenewableEnergy', 'Renewable Energy'); INSERT INTO company (id, name, industry) VALUES (2, 'TechBoost', 'Technology'); CREATE TABLE funding_round (company_id INT, round_size INT); INSERT INTO funding_round (company_id, round_size) VALUES (1, 5000000); INSERT INTO funding_round (company_id, round_size) VALUES (2, 7000000); INSERT INTO funding_round (company_id, round_size) VALUES (1, 6000000); INSERT INTO funding_round (company_id, round_size) VALUES (1, 7000000);
|
What is the maximum number of funding rounds for startups in the renewable energy sector?
|
SELECT COUNT(*) FROM funding_round INNER JOIN company ON funding_round.company_id = company.id WHERE company.industry = 'Renewable Energy' GROUP BY company_id ORDER BY COUNT(*) DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE daily_ad_data (platform VARCHAR(20), date DATE, revenue NUMERIC(10,2));
|
What is the daily revenue by platform for the last 7 days?
|
SELECT platform, date, SUM(revenue) FROM daily_ad_data WHERE date >= (CURRENT_DATE - INTERVAL '7 days') GROUP BY platform, date ORDER BY date;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CarbonPrice (year INT, price FLOAT, market VARCHAR(50));
|
What is the minimum carbon price in the 'California' market in USD/tonne, for the years 2018 to 2022?
|
SELECT MIN(price) FROM CarbonPrice WHERE market = 'California' AND year BETWEEN 2018 AND 2022;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Claim (ClaimId INT, PolicyId INT, ClaimAmount DECIMAL(10,2)); CREATE TABLE Policy (PolicyId INT, PolicyType VARCHAR(50), IssueDate DATE, PolicyholderAge INT);
|
List all claims and their associated policy type, along with the total claim amount, for policyholders over 65 years old.
|
SELECT Policy.PolicyType, Claim.ClaimId, Claim.ClaimAmount, SUM(Claim.ClaimAmount) OVER (PARTITION BY Policy.PolicyType) as TotalClaimAmount FROM Policy INNER JOIN Claim ON Policy.PolicyId = Claim.PolicyId WHERE Policy.PolicyholderAge > 65;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vulnerabilities (id INT, country VARCHAR(255), report_date DATE); INSERT INTO vulnerabilities (id, country, report_date) VALUES (1, 'USA', '2022-01-01'); INSERT INTO vulnerabilities (id, country, report_date) VALUES (2, 'Canada', '2022-01-05'); INSERT INTO vulnerabilities (id, country, report_date) VALUES (3, 'Mexico', '2022-01-09');
|
What are the top 3 countries with the most reported vulnerabilities in the last month?
|
SELECT country, COUNT(*) as total_vulnerabilities FROM vulnerabilities WHERE report_date >= DATEADD(month, -1, GETDATE()) GROUP BY country ORDER BY total_vulnerabilities DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Research_Project (id INT, name VARCHAR(50), type VARCHAR(20), country VARCHAR(10), start_year INT, end_year INT); INSERT INTO Research_Project (id, name, type, country, start_year, end_year) VALUES (1, 'Project A', 'Autonomous Driving', 'USA', 2021, 2023), (2, 'Project B', 'Electric Vehicles', 'China', 2020, 2022), (3, 'Project C', 'Autonomous Driving', 'Germany', 2022, 2025);
|
Which autonomous driving research projects received funding from the US government in 2021 and 2022?
|
SELECT name FROM Research_Project WHERE type = 'Autonomous Driving' AND country = 'USA' AND start_year BETWEEN 2021 AND 2022;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE songs (id INT, title VARCHAR(255), artist_name VARCHAR(255), genre VARCHAR(255), streams INT); INSERT INTO songs (id, title, artist_name, genre, streams) VALUES (1, 'Shake it Off', 'Taylor Swift', 'Pop', 10000000), (2, 'Dynamite', 'BTS', 'Pop', 15000000), (3, 'Rolling in the Deep', 'Adele', 'Soul', 12000000), (4, 'Love Story', 'Taylor Swift', 'Country', 8000000), (5, 'Permission to Dance', 'BTS', 'Pop', 13000000), (6, 'Hello', 'Adele', 'Soul', 9000000), (7, 'Bad Guy', 'Billie Eilish', 'Pop', 11000000), (8, 'Old Town Road', 'Lil Nas X', 'Country', 14000000);
|
What is the total number of streams for each genre, ordered by the total number of streams?
|
SELECT genre, SUM(streams) as total_streams FROM songs GROUP BY genre ORDER BY total_streams DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE fish_data (id INT, species TEXT, ocean TEXT, biomass FLOAT); INSERT INTO fish_data (id, species, ocean, biomass) VALUES (1, 'Species A', 'Arctic', 1200), (2, 'Species B', 'Arctic', 1500), (3, 'Species C', 'Arctic', 1800);
|
What is the total biomass of fish in the Arctic ocean by species?
|
SELECT species, SUM(biomass) FROM fish_data WHERE ocean = 'Arctic' GROUP BY species;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE weather (city VARCHAR(255), wind_speed FLOAT, date DATE); INSERT INTO weather (city, wind_speed, date) VALUES ('Cape Town', 15, '2022-03-01'), ('Cape Town', 18, '2022-03-02'), ('Cape Town', 12, '2022-03-03');
|
What is the average wind speed in 'Cape Town' for March?
|
SELECT AVG(wind_speed) FROM weather WHERE city = 'Cape Town' AND date BETWEEN '2022-03-01' AND '2022-03-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE GovernmentDepartments (DepartmentID int, DepartmentName varchar(255), Country varchar(255)); INSERT INTO GovernmentDepartments (DepartmentID, DepartmentName, Country) VALUES (1, 'Indian Department of Defense', 'India'), (2, 'Indian Department of Health', 'India');
|
What is the total number of government departments in the country of India?
|
SELECT COUNT(*) FROM GovernmentDepartments WHERE Country = 'India';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_species (id INT, species_name VARCHAR(50), habitat_depth FLOAT); INSERT INTO marine_species (id, species_name, habitat_depth) VALUES (1, 'Orca', 200.0), (2, 'Blue Whale', 500.0);
|
Select the average depth of all marine species habitats.
|
SELECT AVG(habitat_depth) FROM marine_species;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE authors (id INT, name VARCHAR(50), gender VARCHAR(10)); INSERT INTO authors (id, name, gender) VALUES (1, 'Alice', 'Female'), (2, 'Bob', 'Male');
|
What is the most common gender of authors in the 'authors' table?
|
SELECT gender, COUNT(*) FROM authors GROUP BY gender ORDER BY COUNT(*) DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Members (Id INT PRIMARY KEY, FirstName VARCHAR(50), LastName VARCHAR(50), JoinDate DATETIME, LastLogin DATETIME);
|
Update the last login date of the user with Id = 10 to Jan 7, 2022 in the "Members" table
|
UPDATE Members SET LastLogin = '2022-01-07' WHERE Id = 10;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE GreenIncentive (id INT, city VARCHAR(255), program VARCHAR(255), start_date DATE, end_date DATE); INSERT INTO GreenIncentive (id, city, program, start_date, end_date) VALUES (1, 'Los Angeles', 'Solar Panel Rebate', '2010-01-01', '2015-12-31'), (2, 'San Francisco', 'Green Roof Subsidy', '2012-01-01', '2017-12-31');
|
What is the total number of green incentive programs in each city?
|
SELECT city, COUNT(*) as 'Total Programs' FROM GreenIncentive GROUP BY city;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE satellites (id INT, name VARCHAR(50), launch_date DATE, return_date DATE, orbit_type VARCHAR(50));
|
Delete all satellites that are no longer in orbit.
|
DELETE FROM satellites WHERE return_date IS NOT NULL;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Employees (id INT, name VARCHAR(50)); CREATE TABLE Articles (id INT, author_id INT, published_date DATE); INSERT INTO Employees (id, name) VALUES (1, 'John Doe'); INSERT INTO Employees (id, name) VALUES (2, 'Jane Smith'); INSERT INTO Articles (id, author_id, published_date) VALUES (1, 1, '2022-01-01'); INSERT INTO Articles (id, author_id, published_date) VALUES (2, 2, '2022-01-02');
|
list the names of employees who have never published an article
|
SELECT e.id, e.name FROM Employees e LEFT JOIN Articles a ON e.id = a.author_id WHERE a.id IS NULL;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sales (drug_name TEXT, qty_sold INTEGER, sale_date DATE); INSERT INTO sales (drug_name, qty_sold, sale_date) VALUES ('DrugA', 500, '2020-01-01'), ('DrugB', 750, '2020-01-02'), ('DrugC', 600, '2020-01-03');
|
What were the sales figures for the top 3 drugs by sales in Q1 2020?
|
SELECT drug_name, SUM(qty_sold) as qty_sold FROM sales WHERE sale_date BETWEEN '2020-01-01' AND '2020-03-31' GROUP BY drug_name ORDER BY SUM(qty_sold) DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Suppliers(supplier_id INT, supplier_name VARCHAR(50), country VARCHAR(50)); CREATE TABLE Orders(order_id INT, supplier_id INT, order_quantity INT); INSERT INTO Suppliers VALUES(1,'ABC Corp','Canada'),(2,'DEF Inc','USA'); INSERT INTO Orders VALUES(1,1,500),(2,1,300),(3,2,700);
|
List all suppliers from Canada with their respective total order quantities.
|
SELECT Suppliers.supplier_name, SUM(Orders.order_quantity) FROM Suppliers INNER JOIN Orders ON Suppliers.supplier_id = Orders.supplier_id WHERE Suppliers.country = 'Canada' GROUP BY Suppliers.supplier_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donors (donor_id INT, name TEXT);CREATE TABLE projects (project_id INT, name TEXT, sector TEXT);CREATE TABLE donations (donation_id INT, donor_id INT, project_id INT, amount FLOAT);INSERT INTO donors VALUES (1, 'Eva Green'), (2, 'Frank Red'), (3, 'Grace Blue'), (4, 'Harry Yellow');INSERT INTO projects VALUES (1, 'Library', 'education'), (2, 'Science Lab', 'education'), (3, 'Art Studio', 'arts'), (4, 'Music Room', 'arts');INSERT INTO donations VALUES (1, 1, 3, 1000.00), (2, 1, 4, 2000.00), (3, 2, 1, 3000.00), (4, 2, 2, 4000.00), (5, 3, 3, 5000.00), (6, 3, 4, 6000.00), (7, 4, 1, 7000.00), (8, 4, 2, 8000.00);
|
Which donors have not donated to any project in the education sector, in ascending order by donor_id?
|
SELECT donors.donor_id, donors.name FROM donors LEFT JOIN donations ON donors.donor_id = donations.donor_id LEFT JOIN projects ON donations.project_id = projects.project_id WHERE projects.sector IS NULL OR projects.sector != 'education' GROUP BY donors.donor_id ORDER BY donors.donor_id ASC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE fertilizer (fertilizer_type VARCHAR(255), nitrogen DECIMAL(5,2), phosphorus DECIMAL(5,2), potassium DECIMAL(5,2)); INSERT INTO fertilizer (fertilizer_type, nitrogen, phosphorus, potassium) VALUES ('urea', 46.0, 0.0, 0.0), ('ammonium nitrate', 34.0, 0.0, 0.0), ('monoammonium phosphate', 11.0, 23.0, 0.0), ('triple superphosphate', 0.0, 46.0, 0.0);
|
List all unique fertilizer types and their corresponding nutrient ratios (nitrogen, phosphorus, potassium) in ascending order of nitrogen content
|
SELECT DISTINCT fertilizer_type, nitrogen, phosphorus, potassium FROM fertilizer ORDER BY nitrogen ASC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE research_grants (id INT, year INT, faculty_name VARCHAR(50), faculty_department VARCHAR(50), faculty_gender VARCHAR(10), grant_amount INT); INSERT INTO research_grants (id, year, faculty_name, faculty_department, faculty_gender, grant_amount) VALUES (1, 2019, 'Jose Hernandez', 'School of Computer Science', 'Male', 10000), (2, 2020, 'Fatima Lopez', 'School of Computer Science', 'Female', 15000), (3, 2018, 'Hong Kim', 'School of Engineering', 'Male', 20000);
|
What is the total amount of research grants awarded to female faculty members in the School of Engineering in 2020?
|
SELECT SUM(grant_amount) FROM research_grants WHERE faculty_department LIKE '%Engineering%' AND year = 2020 AND faculty_gender = 'Female';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ports (port_id INT, port_name VARCHAR(100)); CREATE TABLE cargo (cargo_id INT, cargo_type VARCHAR(50), port_id INT); INSERT INTO ports VALUES (1, 'Port of Los Angeles'); INSERT INTO ports VALUES (2, 'Port of Long Beach'); INSERT INTO cargo VALUES (1, 'Container', 1); INSERT INTO cargo VALUES (2, 'Bulk', 2);
|
What is the total cargo weight handled by each port, including their corresponding cargo type?
|
SELECT ports.port_name, cargo.cargo_type, SUM(cargo.weight) as total_weight FROM cargo INNER JOIN ports ON cargo.port_id = ports.port_id GROUP BY ports.port_name, cargo.cargo_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE songs (id INT, title VARCHAR(255), artist VARCHAR(255)); INSERT INTO songs (id, title, artist) VALUES (1, 'Song 1', 'Artist A'), (2, 'Song 2', 'Artist B');
|
How many unique artists are in the songs table?
|
SELECT COUNT(DISTINCT artist) FROM songs;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE products (product_id INT, product_name VARCHAR(255), category VARCHAR(255), price DECIMAL(10,2), country VARCHAR(255)); INSERT INTO products (product_id, product_name, category, price, country) VALUES (1, 'Volumizing Mascara', 'Makeup', 12.5, 'US'), (2, 'Lengthening Mascara', 'Makeup', 14.99, 'France'), (3, 'Waterproof Mascara', 'Makeup', 9.99, 'Canada');
|
Which country has the highest average mascara price?
|
SELECT country, AVG(price) as avg_price FROM products WHERE category = 'Makeup' AND product_name LIKE '%Mascara%' GROUP BY country ORDER BY avg_price DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE agri_innovation (year INT, metric VARCHAR(255), score FLOAT, evaluations INT); INSERT INTO agri_innovation (year, metric, score, evaluations) VALUES (2019, 'Precision Agriculture', 8.2, 50), (2019, 'Drip Irrigation', 8.5, 75), (2019, 'Vertical Farming', 7.8, 60), (2019, 'Automated Harvesting', 8.0, 45);
|
List the top 3 agricultural innovation metrics by their average scores in 2019, along with the number of evaluations they received.
|
SELECT metric, AVG(score) as avg_score, COUNT(evaluations) as num_evals FROM agri_innovation WHERE year = 2019 GROUP BY metric ORDER BY avg_score DESC, num_evals DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE materials (material_id INT, material_name TEXT, is_eco_friendly BOOLEAN, price DECIMAL); INSERT INTO materials VALUES (1, 'organic cotton', TRUE, 2.5); INSERT INTO materials VALUES (2, 'recycled polyester', TRUE, 3.25);
|
What is the maximum price of eco-friendly materials in the materials table?
|
SELECT MAX(price) FROM materials WHERE is_eco_friendly = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE defense_contracts_by_country (id INT, contract_id VARCHAR(50), contract_amount DECIMAL(10,2), country VARCHAR(50));
|
What are the top 5 countries with the highest number of defense contracts awarded?
|
SELECT country, COUNT(DISTINCT contract_id) AS num_contracts FROM defense_contracts_by_country GROUP BY country ORDER BY num_contracts DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE fish_farms_fw (id INT, name TEXT, type TEXT, location TEXT, biomass FLOAT); INSERT INTO fish_farms_fw (id, name, type, location, biomass) VALUES (1, 'Farm Q', 'Fish', 'Brazil', 30000.0), (2, 'Farm R', 'Fish', 'Argentina', 20000.0);
|
What is the total biomass of fish in freshwater fish farms in the Southern Hemisphere?
|
SELECT SUM(biomass) FROM fish_farms_fw WHERE type = 'Fish' AND location IN (SELECT location FROM fish_farms_fw WHERE biomass IS NOT NULL GROUP BY location HAVING EXTRACT(HOUR FROM AVG(location)) > 12);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CountriesAmericas (id INT, name TEXT, region TEXT); INSERT INTO CountriesAmericas (id, name, region) VALUES (1, 'United States', 'Americas'), (2, 'Canada', 'Americas'); CREATE TABLE HeritageSitesAmericas (id INT, country_id INT, name TEXT); INSERT INTO HeritageSitesAmericas (id, country_id, name) VALUES (1, 1, 'Statue of Liberty'), (2, 1, 'Grand Canyon'), (3, 2, 'Niagara Falls'), (4, 2, 'CN Tower');
|
What is the average number of heritage sites per country in the Americas?
|
SELECT AVG(site_count) FROM (SELECT COUNT(HeritageSitesAmericas.id) AS site_count FROM HeritageSitesAmericas GROUP BY HeritageSitesAmericas.country_id) AS SiteCountPerCountry
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Players (PlayerID INT, Age INT, Gender VARCHAR(10), Location VARCHAR(20)); INSERT INTO Players (PlayerID, Age, Gender, Location) VALUES (1, 25, 'Male', 'Australia'); INSERT INTO Players (PlayerID, Age, Gender, Location) VALUES (2, 30, 'Female', 'Australia'); CREATE TABLE Games (GameID INT, GameName VARCHAR(20), VR BOOLEAN); INSERT INTO Games (GameID, GameName, VR) VALUES (1, 'Ocean Explorer', true);
|
What's the gender ratio of players who play VR games in Australia?
|
SELECT (COUNT(CASE WHEN Gender = 'Male' THEN 1 END) * 1.0 / COUNT(*)) AS Male_ratio, (COUNT(CASE WHEN Gender = 'Female' THEN 1 END) * 1.0 / COUNT(*)) AS Female_ratio FROM Players INNER JOIN Games ON Players.Location = Games.GameName WHERE Games.VR = true AND Players.Location = 'Australia';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vendors (vendor_id INT, vendor_name VARCHAR(50), state VARCHAR(50)); INSERT INTO vendors VALUES (1, 'VendorA', 'Oregon'); INSERT INTO vendors VALUES (2, 'VendorB', 'Texas'); CREATE TABLE products (product_id INT, product_name VARCHAR(50), vendor_id INT, price DECIMAL(5,2), upcycled BOOLEAN); INSERT INTO products VALUES (1, 'Product1', 1, 150, true); INSERT INTO products VALUES (2, 'Product2', 1, 75, true); INSERT INTO products VALUES (3, 'Product3', 2, 100, false); INSERT INTO products VALUES (4, 'Product4', 1, 200, true); CREATE TABLE sales (sale_id INT, product_id INT, vendor_id INT, sale_amount DECIMAL(5,2)); INSERT INTO sales VALUES (1, 1, 1, 50); INSERT INTO sales VALUES (2, 2, 1, 75); INSERT INTO sales VALUES (3, 3, 2, 30); INSERT INTO sales VALUES (4, 4, 1, 60);
|
What is the average price of upcycled products sold by vendors in Oregon?
|
SELECT AVG(products.price) FROM products JOIN vendors ON products.vendor_id = vendors.vendor_id WHERE products.upcycled = true AND vendors.state = 'Oregon';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mobile_usage (id INT, name VARCHAR(50), data_usage FLOAT); INSERT INTO mobile_usage (id, name, data_usage) VALUES (1, 'Jane Doe', 10.0);
|
What is the minimum monthly data usage for mobile subscribers?
|
SELECT MIN(data_usage) FROM mobile_usage;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mobile_speeds (region VARCHAR(255), speed FLOAT); INSERT INTO mobile_speeds (region, speed) VALUES ('North', 50), ('North', 51), ('South', 45), ('East', 55), ('East', 60), ('West', 48);
|
Identify the top 3 regions with the lowest average mobile speed, ordered from the lowest to the highest.
|
SELECT region, AVG(speed) as avg_speed, ROW_NUMBER() OVER (ORDER BY AVG(speed) ASC) as rank FROM mobile_speeds GROUP BY region HAVING rank <= 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CO2Emissions (Country VARCHAR(50), CO2 INT, CO2Date DATETIME);
|
Identify the top 3 countries with the highest CO2 emissions in the past month?
|
SELECT Country, SUM(CO2) OVER (PARTITION BY Country ORDER BY CO2Date ROWS BETWEEN 29 PRECEDING AND CURRENT ROW) AS TotalCO2, RANK() OVER (ORDER BY SUM(CO2) DESC) AS Rank FROM CO2Emissions WHERE CO2Date >= DATEADD(month, -1, CURRENT_TIMESTAMP) GROUP BY Country, CO2Date HAVING Rank <= 3
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MilitaryPersonnel (Country VARCHAR(50), MilitaryPersonnel INT); INSERT INTO MilitaryPersonnel (Country, MilitaryPersonnel) VALUES ('USA', 1400000), ('China', 2000000), ('Russia', 1000000);
|
What is the average number of military personnel by country, ordered from highest to lowest?
|
SELECT Country, AVG(MilitaryPersonnel) AS AvgMilitaryPersonnel FROM MilitaryPersonnel GROUP BY Country ORDER BY AvgMilitaryPersonnel DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ocean_acidity (region varchar(255), level decimal(10,2)); INSERT INTO ocean_acidity (region, level) VALUES ('Southern Ocean', 8.30), ('Arctic', 8.20), ('Indian', 8.15);
|
What is the maximum ocean acidity level in the Southern Ocean?
|
SELECT MAX(level) FROM ocean_acidity WHERE region = 'Southern Ocean';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE coral_reefs (id INT, species VARCHAR(255));
|
List all marine species that are found in both 'coral_reefs' and 'ocean_species'.
|
SELECT coral_reefs.species FROM coral_reefs INNER JOIN ocean_species ON coral_reefs.species = ocean_species.species;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MenuItems (menu_item_id INTEGER, menu_item_name TEXT, menu_type TEXT, calories INTEGER); INSERT INTO MenuItems (menu_item_id, menu_item_name, menu_type, calories) VALUES (1, 'Vegetarian Lasagna', 'Entree', 650);
|
Calculate the total calories provided by vegetarian menu options in European restaurants.
|
SELECT SUM(calories) FROM MenuItems WHERE menu_type = 'Entree' AND menu_item_name LIKE '%Vegetarian%' AND country = 'Europe';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE algorithmic_bias (algorithm_id INT, name TEXT, bias_score FLOAT); INSERT INTO algorithmic_bias (algorithm_id, name, bias_score) VALUES (1, 'AlgorithmI', 0.15), (2, 'AlgorithmJ', 0.22), (3, 'AlgorithmK', 0.18);
|
What is the name of the AI algorithm with the highest bias score in the 'algorithmic_bias' table?
|
SELECT name FROM algorithmic_bias ORDER BY bias_score DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE household_water_consumption (id INT, state VARCHAR(20), water_consumption FLOAT); INSERT INTO household_water_consumption (id, state, water_consumption) VALUES (1, 'California', 150), (2, 'California', 200), (3, 'Texas', 120);
|
What is the maximum water consumption per household in the state of California?
|
SELECT state, MAX(water_consumption) FROM household_water_consumption WHERE state = 'California';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE wind_turbines (id INT, installation_year INT, energy_production FLOAT); INSERT INTO wind_turbines (id, installation_year, energy_production) VALUES (1, 2005, 2.5), (2, 2008, 3.2), (3, 2012, 3.8), (4, 2015, 4.1);
|
What is the average energy production of wind turbines installed in the USA before 2010?
|
SELECT AVG(energy_production) FROM wind_turbines WHERE installation_year < 2010;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE stations (id INT, name TEXT, city TEXT, capacity INT);
|
Update the 'city' column in the 'stations' table for 'Station 1' to 'New York'
|
UPDATE stations SET city = 'New York' WHERE name = 'Station 1';
|
gretelai_synthetic_text_to_sql
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.