context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE Articles (id INT, title VARCHAR(255), content TEXT, word_count INT); INSERT INTO Articles (id, title, content, word_count) VALUES (1, 'Racial Equity in Education', 'Racial equity is important in education...', 500), (2, 'Economic Impact', 'The economy is a significant...', 300), (3, 'Racial Equity in Healthcare', 'Racial equity is necessary in healthcare...', 600);
What is the average word count of articles that mention 'racial equity'?
SELECT AVG(word_count) as avg_word_count FROM Articles WHERE title LIKE '%racial equity%' OR content LIKE '%racial equity%';
gretelai_synthetic_text_to_sql
CREATE TABLE energy_efficiency (id INT PRIMARY KEY, building_id INT, energy_rating INT); CREATE TABLE buildings (id INT PRIMARY KEY, name VARCHAR(50), location VARCHAR(50)); CREATE TABLE energy_transactions (id INT PRIMARY KEY, building_id INT, source VARCHAR(50), energy_type VARCHAR(50), quantity INT, transaction_date DATE);
What is the average energy rating for each building in a specific location?
SELECT buildings.location, AVG(energy_efficiency.energy_rating) FROM energy_efficiency INNER JOIN buildings ON energy_efficiency.building_id = buildings.id GROUP BY buildings.location;
gretelai_synthetic_text_to_sql
CREATE TABLE Countries(id INT, name TEXT); INSERT INTO Countries (id, name) VALUES (1, 'Country A'); INSERT INTO Countries (id, name) VALUES (2, 'Country B'); CREATE TABLE ExcavationSites(id INT, country_id INT, name TEXT, date DATE); INSERT INTO ExcavationSites (id, country_id, name, date) VALUES (1, 1, 'Site A', '2000-01-01'); INSERT INTO ExcavationSites (id, country_id, name, date) VALUES (2, 1, 'Site B', '1995-05-15'); CREATE TABLE Artifacts(id INT, excavation_site_id INT, name TEXT, type TEXT); INSERT INTO Artifacts (id, excavation_site_id, name, type) VALUES (1, 1, 'Pottery 1', 'Pottery'); INSERT INTO Artifacts (id, excavation_site_id, name, type) VALUES (2, 2, 'Pottery 2', 'Pottery');
What is the total number of excavation sites and associated artifacts for each country?
SELECT Countries.name, COUNT(ExcavationSites.id) AS site_count, COUNT(Artifacts.id) AS artifact_count FROM Countries LEFT JOIN ExcavationSites ON Countries.id = ExcavationSites.country_id LEFT JOIN Artifacts ON ExcavationSites.id = Artifacts.excavation_site_id GROUP BY Countries.name;
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tours (hotel_id INT, location VARCHAR(20), views INT, clicks INT);
Compare virtual tour engagement metrics between Asia and Europe.
SELECT location, AVG(views) as avg_views, AVG(clicks) as avg_clicks FROM virtual_tours WHERE location IN ('Asia', 'Europe') GROUP BY location
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tours (tour_id INT, location VARCHAR(50), tour_date DATE); INSERT INTO virtual_tours (tour_id, location, tour_date) VALUES (1, 'Paris', '2022-01-01'), (2, 'Rome', '2022-06-15'), (3, 'London', '2021-12-31'), (4, 'Berlin', '2022-07-01');
Delete all virtual tours that took place before January 1, 2022.
DELETE FROM virtual_tours WHERE tour_date < '2022-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE tropical_rainforests (id INT, name VARCHAR(255), country VARCHAR(255), sequestration INT); INSERT INTO tropical_rainforests (id, name, country, sequestration) VALUES (1, 'Tropical Rainforest 1', 'Brazil', 9000), (2, 'Tropical Rainforest 2', 'Brazil', 12000), (3, 'Tropical Rainforest 3', 'Brazil', 15000);
What is the minimum carbon sequestration achieved in a single year in tropical rainforests, and which forest was it?
SELECT name, MIN(sequestration) FROM tropical_rainforests WHERE country = 'Brazil';
gretelai_synthetic_text_to_sql
CREATE TABLE Students (StudentID INT, DisabilityType TEXT, Region TEXT); INSERT INTO Students (StudentID, DisabilityType, Region) VALUES (1, 'VisualImpairment', 'North'), (2, 'HearingImpairment', 'South'), (3, 'MentalHealth', 'East'); CREATE TABLE Accommodations (StudentID INT, AccommodationID INT); INSERT INTO Accommodations (StudentID, AccommodationID) VALUES (1, 1001), (2, 1002), (3, 1003);
How many students with mental health disabilities received accommodations in each region of Texas?
SELECT Region, COUNT(*) as NumStudents FROM Students JOIN Accommodations ON Students.StudentID = Accommodations.StudentID WHERE DisabilityType = 'MentalHealth' AND State = 'Texas' GROUP BY Region;
gretelai_synthetic_text_to_sql
CREATE TABLE donations (donation_id INT, donor_id INT, amount_donated DECIMAL(10, 2)); INSERT INTO donations VALUES (1, 1, 500.00), (2, 2, 350.00), (3, 1, 200.00); CREATE TABLE donors (donor_id INT, name TEXT); INSERT INTO donors VALUES (1, 'John Doe'), (2, 'Jane Smith');
Calculate the total amount donated by each donor, sorted by the highest donation amount.
SELECT donors.name, SUM(donations.amount_donated) AS total_donated FROM donors INNER JOIN donations ON donors.donor_id = donations.donor_id GROUP BY donors.donor_id ORDER BY total_donated DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE SpaceRadar (id INT, country VARCHAR(50), year INT, satellites INT); INSERT INTO SpaceRadar (id, country, year, satellites) VALUES (1, 'USA', 2000, 10), (2, 'China', 2005, 8), (3, 'Russia', 1995, 12), (4, 'Russia', 1996, 14);
What is the average number of satellites launched per year by Russia in the SpaceRadar table?
SELECT AVG(satellites) AS avg_satellites_per_year FROM SpaceRadar WHERE country = 'Russia';
gretelai_synthetic_text_to_sql
CREATE TABLE financial_capability_data_2 (customer_id INT, score INT, region VARCHAR(20)); INSERT INTO financial_capability_data_2 (customer_id, score, region) VALUES (1, 70, 'Middle East'), (2, 80, 'Western Europe'), (3, 60, 'East Asia'), (4, 90, 'North America'), (5, 75, 'Oceania'), (6, 65, 'South America'), (7, 85, 'Eastern Europe'); CREATE VIEW financial_capability_view_2 AS SELECT region, AVG(score) as avg_score FROM financial_capability_data_2 GROUP BY region;
What is the average financial capability score for customers in each region?
SELECT region, avg_score FROM financial_capability_view_2;
gretelai_synthetic_text_to_sql
CREATE TABLE forests (id INT, region VARCHAR(255), volume FLOAT, year INT); INSERT INTO forests (id, region, volume, year) VALUES (1, 'North', 1200, 2020), (2, 'South', 1500, 2020), (3, 'East', 1800, 2020), (4, 'West', 1000, 2020);
Find the top 2 regions with the highest total timber volume in 2020.
SELECT region, SUM(volume) as total_volume FROM forests WHERE year = 2020 GROUP BY region ORDER BY total_volume DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE Defense_Project_Timelines (project_id INT, project_name VARCHAR(50), start_date DATE, end_date DATE); INSERT INTO Defense_Project_Timelines (project_id, project_name, start_date, end_date) VALUES (1, 'Project X', '2019-01-01', '2021-12-31'); INSERT INTO Defense_Project_Timelines (project_id, project_name, start_date, end_date) VALUES (2, 'Project Y', '2020-01-01', '2022-12-31'); INSERT INTO Defense_Project_Timelines (project_id, project_name, start_date, end_date) VALUES (3, 'Project Z', '2021-01-01', '2023-12-31');
Which defense projects have a duration longer than the 75th percentile of all defense project durations?
SELECT project_id, project_name, DATEDIFF('day', start_date, end_date) AS project_duration FROM Defense_Project_Timelines WHERE DATEDIFF('day', start_date, end_date) > PERCENTILE_CONT(0.75) WITHIN GROUP (ORDER BY DATEDIFF('day', start_date, end_date));
gretelai_synthetic_text_to_sql
CREATE TABLE creative_ai (model_id INT, model_name VARCHAR(50), model_type VARCHAR(20), dataset_name VARCHAR(50)); INSERT INTO creative_ai (model_id, model_name, model_type, dataset_name) VALUES (1, 'GAN', 'generative', 'creative_ai'), (2, 'VAE', 'generative', 'creative_ai'), (3, 'CNN', 'discriminative', 'creative_ai');
What is the total number of models, categorized by their type, that have been trained on the 'creative_ai' dataset?
SELECT model_type, COUNT(*) as total FROM creative_ai WHERE dataset_name = 'creative_ai' GROUP BY model_type;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists rnd;CREATE TABLE if not exists rnd.investment (id INT, technology VARCHAR(50), country VARCHAR(50), amount DECIMAL(10, 2)); INSERT INTO rnd.investment (id, technology, country, amount) VALUES (1, 'BioSensor1', 'USA', 1000000.00), (2, 'BioSensor2', 'USA', 1500000.00), (3, 'BioSensor3', 'Canada', 500000.00), (4, 'BioSensor4', 'Canada', 750000.00);
Calculate the total R&D investment in biosensors for each country.
SELECT country, SUM(amount) FROM rnd.investment GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE Farmers (id INT PRIMARY KEY, name VARCHAR(50), age INT, location VARCHAR(50)); CREATE TABLE Irrigation (id INT PRIMARY KEY, system VARCHAR(50), cost FLOAT, installation_date DATE, farm_id INT, FOREIGN KEY (farm_id) REFERENCES Farmers(id)); INSERT INTO Farmers (id, name, age, location) VALUES (1, 'Juan Garcia', 45, 'Texas'); INSERT INTO Farmers (id, name, age, location) VALUES (2, 'Maria Rodriguez', 50, 'California'); INSERT INTO Irrigation (id, system, cost, installation_date, farm_id) VALUES (1, 'Drip', 5000.00, '2021-06-01', 1); INSERT INTO Irrigation (id, system, cost, installation_date, farm_id) VALUES (2, 'Sprinkler', 7000.00, '2022-02-15', 2);
What are the names of farmers who have irrigation systems?
SELECT Farmers.name FROM Farmers INNER JOIN Irrigation ON Farmers.id = Irrigation.farm_id;
gretelai_synthetic_text_to_sql
CREATE TABLE water_wells (id INT, project_id INT, location VARCHAR(255), construction_date DATE); INSERT INTO water_wells (id, project_id, location, construction_date) VALUES (1, 4001, 'Colombia', '2019-05-01'); INSERT INTO water_wells (id, project_id, location, construction_date) VALUES (2, 4002, 'Peru', '2018-02-01');
What is the total number of water wells dug in "Latin America" since 2018?
SELECT COUNT(*) FROM water_wells WHERE location = 'Latin America' AND YEAR(construction_date) >= 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE research_grants (grant_id INT, student_id INT, grant_amount DECIMAL(10,2), grant_start_date DATE, grant_end_date DATE, student_community VARCHAR(255)); CREATE TABLE students (student_id INT, student_name VARCHAR(255), student_community VARCHAR(255));
What is the number of research grants awarded to Latinx and Indigenous graduate students in the last 3 years?
SELECT COUNT(*) FROM research_grants rg INNER JOIN students s ON rg.student_id = s.student_id WHERE rg.grant_start_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 YEAR) AND s.student_community IN ('Latinx', 'Indigenous');
gretelai_synthetic_text_to_sql
CREATE TABLE Suppliers (SupplierID int, SupplierName varchar(50)); CREATE TABLE Products (ProductID int, ProductName varchar(50), SupplierID int); CREATE TABLE Orders (OrderID int, ProductID int, OrderDate date, Units int); INSERT INTO Suppliers VALUES (1, 'SupplierA'), (2, 'SupplierB'); INSERT INTO Products VALUES (1, 'Organic Apples', 1), (2, 'Bananas', 2); INSERT INTO Orders VALUES (1, 1, '2022-01-01', 500), (2, 2, '2022-01-03', 700);
Which suppliers have delivered more than 1000 units of a product in the last week?
SELECT SupplierName, ProductName, SUM(Units) as TotalUnits FROM Orders o JOIN Products p ON o.ProductID = p.ProductID JOIN Suppliers sp ON p.SupplierID = sp.SupplierID WHERE OrderDate >= DATEADD(week, -1, GETDATE()) GROUP BY SupplierName, ProductName HAVING SUM(Units) > 1000;
gretelai_synthetic_text_to_sql
CREATE TABLE HIVData (Year INT, Region VARCHAR(20), Cases INT); INSERT INTO HIVData (Year, Region, Cases) VALUES (2016, 'South America', 5000); INSERT INTO HIVData (Year, Region, Cases) VALUES (2018, 'Central America', 3000);
Find the number of HIV cases in Central America in 2018.
SELECT SUM(Cases) FROM HIVData WHERE Region = 'Central America' AND Year = 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE AIModels (model_id INT, model_name VARCHAR(50), fairness_score DECIMAL(3,2)); INSERT INTO AIModels (model_id, model_name, fairness_score) VALUES (1, 'ModelA', 85.00), (2, 'ModelB', 78.50), (3, 'ModelC', 92.75), (4, 'ModelD', 83.00);
Show AI models with fairness scores below 80.
SELECT model_name, fairness_score FROM AIModels WHERE fairness_score < 80;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name TEXT, is_cruelty_free BOOLEAN, is_vegan BOOLEAN, consumer_rating DECIMAL(3,1));
What is the average consumer rating for products that are both cruelty-free and vegan?
SELECT AVG(products.consumer_rating) as avg_rating FROM products WHERE products.is_cruelty_free = TRUE AND products.is_vegan = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE wells (well_id INT, well_name VARCHAR(50), region VARCHAR(20), production FLOAT, year INT); INSERT INTO wells (well_id, well_name, region, production, year) VALUES (1, 'Well A', 'onshore', 100.0, 2023); INSERT INTO wells (well_id, well_name, region, production, year) VALUES (2, 'Well B', 'offshore', 200.0, 2022); INSERT INTO wells (well_id, well_name, region, production, year) VALUES (3, 'Well C', 'amazon', 120.0, 2023);
What is the minimum production for wells in the 'amazon' region in 2023?
SELECT MIN(production) FROM wells WHERE region = 'amazon' AND year = 2023;
gretelai_synthetic_text_to_sql
CREATE TABLE orders (id INT PRIMARY KEY, product_id INT, quantity INT, order_date DATE, price DECIMAL(5,2)); INSERT INTO orders (id, product_id, quantity, order_date, price) VALUES (1, 1, 2, '2021-06-01', 29.99), (2, 3, 1, '2021-06-03', 14.99), (3, 2, 3, '2021-06-05', 39.99);
Find the order details for orders placed on June 3, 2021?
SELECT * FROM orders WHERE order_date = '2021-06-03';
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists program (id INT, name VARCHAR(50), category VARCHAR(50)); CREATE TABLE if not exists funding (id INT, program_id INT, year INT, amount DECIMAL(10, 2), source VARCHAR(50)); INSERT INTO program (id, name, category) VALUES (1, 'Ballet', 'Dance'), (2, 'Contemporary', 'Dance'), (3, 'Hip Hop', 'Dance'); INSERT INTO funding (id, program_id, year, amount, source) VALUES (1, 1, 2021, 15000, 'City Grant'), (2, 1, 2022, 18000, 'Private Donor'), (3, 2, 2021, 12000, 'Corporate Sponsor'), (4, 2, 2022, 14000, 'Government Grant'), (5, 3, 2021, 16000, 'Private Donor'), (6, 3, 2022, 20000, 'City Grant');
What is the total amount of funding for 'Dance' programs in 2022?
SELECT SUM(amount) FROM funding f JOIN program p ON f.program_id = p.id WHERE p.category = 'Dance' AND f.year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE conservation_efforts (effort_id INT, effort_name VARCHAR(50));CREATE TABLE conservation_projects (project_id INT, project_name VARCHAR(50));CREATE TABLE project_species (project_id INT, species_id INT); INSERT INTO conservation_efforts (effort_id, effort_name) VALUES (1, 'Habitat Restoration'), (2, 'Community Education'), (3, 'Animal Monitoring'); INSERT INTO conservation_projects (project_id, project_name) VALUES (101, 'Project A'), (102, 'Project B'), (103, 'Project C'); INSERT INTO project_species (project_id, species_id) VALUES (101, 1), (101, 2), (102, 2), (103, 3);
Which animal species were involved in the highest number of conservation efforts?
SELECT s.species_name, COUNT(ps.project_id) AS total_projects FROM animal_species s JOIN project_species ps ON s.species_id = ps.species_id GROUP BY s.species_name ORDER BY total_projects DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Department (id INT, name VARCHAR(255)); INSERT INTO Department (id, name) VALUES (1, 'Computer Science'), (2, 'Physics'), (3, 'English'), (4, 'History'); CREATE TABLE Student (id INT, department_id INT, gender VARCHAR(10)); INSERT INTO Student (id, department_id, gender) VALUES (1, 1, 'Female'), (2, 2, 'Male'), (3, 1, 'Non-binary'), (4, 3, 'Female'), (5, 4, 'Male'), (6, 3, 'Male');
List the number of male and female graduate students in the English department
SELECT s.gender, COUNT(*) as num_students FROM Student s JOIN Department d ON s.department_id = d.id WHERE d.name = 'English' GROUP BY s.gender;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, name VARCHAR(255), state VARCHAR(255), financial_capability_score INT);
What is the distribution of financial capability scores for customers in New York?
SELECT state, COUNT(*) as count, MIN(financial_capability_score) as min_score, AVG(financial_capability_score) as avg_score, MAX(financial_capability_score) as max_score FROM customers WHERE state = 'New York' GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE AlbumRevenue (AlbumID INT, GenreID INT, Revenue DECIMAL(10,2)); INSERT INTO AlbumRevenue (AlbumID, GenreID, Revenue) VALUES (1, 1, 150000.00), (2, 1, 125000.00), (3, 2, 150000.00), (4, 2, 100000.00), (5, 3, 100000.00);
What is the difference in revenue between the top and bottom album for each genre?
SELECT GenreID, MAX(Revenue) - MIN(Revenue) AS RevenueDifference FROM AlbumRevenue GROUP BY GenreID;
gretelai_synthetic_text_to_sql
CREATE TABLE Completions (CompletionID INT, StudentID INT, CourseID INT, CompletionDate DATE); INSERT INTO Completions (CompletionID, StudentID, CourseID, CompletionDate) VALUES (1, 1, 1, '2023-01-01'), (2, 2, 2, '2023-01-02'), (3, 3, 1, '2023-01-03'), (4, 5, 2, '2023-01-04'); CREATE TABLE Courses (CourseID INT, CourseName VARCHAR(50), Cost INT, CertificationYear INT, TargetAudience VARCHAR(20)); INSERT INTO Courses (CourseID, CourseName, Cost, CertificationYear, TargetAudience) VALUES (1, 'Critical Pedagogy', 250, 2023, 'Teachers'), (2, 'Data Analysis for Educators', 250, 2023, 'Teachers');
How many teachers have completed the 'Critical Pedagogy' course in 2023?
SELECT COUNT(*) FROM Completions INNER JOIN Courses ON Completions.CourseID = Courses.CourseID WHERE Courses.CourseName = 'Critical Pedagogy' AND CertificationYear = 2023 AND TargetAudience = 'Teachers';
gretelai_synthetic_text_to_sql
CREATE TABLE destinations (id INT, country TEXT); INSERT INTO destinations (id, country) VALUES (1, 'New Zealand'); CREATE TABLE visits (id INT, visit_date DATE, destination_id INT); INSERT INTO visits (id, visit_date, destination_id) VALUES (1, '2015-01-01', 1), (2, '2015-07-01', 1), (3, '2016-01-01', 1);
How many tourists visited New Zealand from '2015-01-01' to '2016-12-31', broken down by quarter?
SELECT DATE_TRUNC('quarter', v.visit_date) AS quarter, COUNT(*) as num_visitors FROM visits v JOIN destinations d ON v.destination_id = d.id WHERE d.country = 'New Zealand' AND v.visit_date BETWEEN '2015-01-01' AND '2016-12-31' GROUP BY quarter;
gretelai_synthetic_text_to_sql
CREATE TABLE Campaigns (CampaignID INT, Year INT, Budget INT); CREATE TABLE MentalHealthCampaigns (CampaignID INT, CampaignName VARCHAR(50));
Which mental health campaigns were launched in a specific year and their respective budgets?
SELECT Campaigns.Year, MentalHealthCampaigns.CampaignName, Campaigns.Budget FROM Campaigns INNER JOIN MentalHealthCampaigns ON Campaigns.CampaignID = MentalHealthCampaigns.CampaignID WHERE Campaigns.Year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE Spacecraft_Manufacturing (Facility VARCHAR(50), Country VARCHAR(50)); INSERT INTO Spacecraft_Manufacturing (Facility, Country) VALUES ('Facility1', 'USA'), ('Facility2', 'USA'), ('Facility3', 'USA'), ('Facility4', 'Germany'), ('Facility5', 'France'), ('Facility6', 'France'), ('Facility7', 'Japan'), ('Facility8', 'Japan'), ('Facility9', 'India'), ('Facility10', 'India');
Determine the top 2 spacecraft manufacturing countries with the highest average facility count, displaying country names and average facility counts.
SELECT Country, AVG(1.0*COUNT(*)) as Avg_Facility_Count FROM Spacecraft_Manufacturing GROUP BY Country HAVING COUNT(*) >= ALL (SELECT COUNT(*) as Facility_Count FROM Spacecraft_Manufacturing GROUP BY Country ORDER BY Facility_Count DESC LIMIT 1 OFFSET 1) LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE chemical_production (id INT PRIMARY KEY, chemical_id VARCHAR(10), quantity INT, country VARCHAR(50)); INSERT INTO chemical_production (id, chemical_id, quantity, country) VALUES (1, 'XY987', 700, 'Brazil'), (2, 'GH247', 600, 'India'), (3, 'XY987', 300, 'Australia'), (4, 'GH247', 500, 'India'), (5, 'GH247', 800, 'Brazil'), (6, 'XY987', 200, 'Chile'), (7, 'LM345', 150, 'Argentina');
Find the chemical_id with the lowest production quantity
SELECT chemical_id FROM chemical_production GROUP BY chemical_id ORDER BY SUM(quantity) ASC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE healthcare_specialties (name TEXT, location TEXT, specialty TEXT); INSERT INTO healthcare_specialties (name, location, specialty) VALUES ('Provider A', 'Rural South Africa', 'Infectious Diseases'), ('Provider B', 'Rural Kenya', 'Cardiology');
Find the number of rural healthcare providers who are specialized in infectious diseases in South Africa and Kenya.
SELECT location, COUNT(*) as provider_count FROM healthcare_specialties WHERE location LIKE 'Rural%' AND specialty LIKE '%Infectious%' GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE oil_production (well_id INT, year INT, oil_volume FLOAT);
List all the unique well identifiers from the 'oil_production' table where the oil production for the year 2020 is greater than 10000
SELECT DISTINCT well_id FROM oil_production WHERE year = 2020 AND oil_volume > 10000;
gretelai_synthetic_text_to_sql
CREATE TABLE natural_disasters (id INT, state VARCHAR(255), year INT, number_of_disasters INT); INSERT INTO natural_disasters (id, state, year, number_of_disasters) VALUES (1, 'Florida', 2019, 50), (2, 'California', 2019, 75);
How many natural disasters were reported in the state of Florida in 2019?
SELECT SUM(number_of_disasters) FROM natural_disasters WHERE state = 'Florida' AND year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE sustainable_inventory (id INT, item_name VARCHAR(50), item_size VARCHAR(10), is_sustainable BOOLEAN); INSERT INTO sustainable_inventory (id, item_name, item_size, is_sustainable) VALUES (1, 'T-Shirt', 'XS', TRUE); INSERT INTO sustainable_inventory (id, item_name, item_size, is_sustainable) VALUES (2, 'Jeans', 'M', TRUE); INSERT INTO sustainable_inventory (id, item_name, item_size, is_sustainable) VALUES (3, 'Sweater', 'S', FALSE);
How many unique sustainable clothing items are available in sizes XS, S, and M?
SELECT COUNT(DISTINCT item_name) FROM sustainable_inventory WHERE item_size IN ('XS', 'S', 'M') AND is_sustainable = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE GameMatches (GameID int, GameName varchar(50), MatchesPlayed int); INSERT INTO GameMatches (GameID, GameName, MatchesPlayed) VALUES (1, 'GameA', 6000), (2, 'GameB', 4000), (3, 'GameC', 3000);
What is the maximum number of matches played for each game?
SELECT GameName, MAX(MatchesPlayed) FROM GameMatches GROUP BY GameName;
gretelai_synthetic_text_to_sql
CREATE TABLE Diplomacy (event VARCHAR(255), location VARCHAR(255), speaker VARCHAR(255), topic VARCHAR(255), date DATE); INSERT INTO Diplomacy (event, location, speaker, topic, date) VALUES ('Security Cooperation', 'Tokyo', 'John Smith', 'US-Japan Military Cooperation', '2019-04-15');
List the defense diplomacy events where a representative from the USA spoke about military cooperation with a country in the Asia-Pacific region?
SELECT DISTINCT event, location, speaker, topic, date FROM Diplomacy WHERE speaker LIKE '%USA%' AND location LIKE '%Asia-Pacific%' AND topic LIKE '%military cooperation%';
gretelai_synthetic_text_to_sql
CREATE TABLE games (id INT PRIMARY KEY, player_id INT, game_name VARCHAR(100), last_played TIMESTAMP, playtime INTERVAL); INSERT INTO games VALUES (1, 1, 'GameA', '2021-01-01 12:00:00', '02:00:00'), (2, 1, 'GameB', '2021-02-15 14:30:00', '01:30:00'), (3, 3, 'GameA', '2021-06-20 09:15:00', '03:00:00'), (4, 2, 'GameA', '2021-07-01 10:30:00', '01:00:00'), (5, 3, 'GameB', '2021-07-05 11:45:00', '02:30:00');
Calculate the average playtime for each game
SELECT game_name, AVG(playtime) AS avg_playtime FROM games GROUP BY game_name;
gretelai_synthetic_text_to_sql
CREATE TABLE extraction (id INT PRIMARY KEY, site_id INT, mineral VARCHAR(50), quantity INT, year INT);
Get total mineral extraction in 2021
SELECT SUM(quantity) FROM extraction WHERE year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE GameSessions (GameSessionID INT, PlayerID INT, GameDate DATE); INSERT INTO GameSessions (GameSessionID, PlayerID, GameDate) VALUES (1, 1, '2022-01-01'), (2, 2, '2022-01-02'), (3, 3, '2022-01-03'), (4, 4, '2022-01-04'), (5, 5, '2022-01-05'), (6, 1, '2022-01-06'), (7, 2, '2022-01-06'), (8, 3, '2022-01-06');
How many games have been played each day in the last week?
SELECT GameDate, COUNT(*) as NumGames FROM GameSessions WHERE GameDate >= CURDATE() - INTERVAL 7 DAY GROUP BY GameDate;
gretelai_synthetic_text_to_sql
CREATE TABLE EnergyCosts (energy_cost DECIMAL(10,2), renewable_energy BOOLEAN);
What was the total cost savings from using renewable energy sources in the UK in Q3 2021?
SELECT SUM(energy_cost) FROM EnergyCosts WHERE DATE_FORMAT(energy_cost_date, '%Y-%m-%d') BETWEEN '2021-07-01' AND '2021-09-30' AND renewable_energy = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE Research_Papers (year INT, country VARCHAR(50), topic VARCHAR(50), quantity INT); INSERT INTO Research_Papers (year, country, topic, quantity) VALUES (2020, 'UK', 'Autonomous Driving', 150); INSERT INTO Research_Papers (year, country, topic, quantity) VALUES (2020, 'UK', 'Autonomous Driving', 160);
What is the average number of autonomous driving research papers published in the UK?
SELECT AVG(quantity) FROM Research_Papers WHERE year = 2020 AND country = 'UK' AND topic = 'Autonomous Driving';
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (id INT, name VARCHAR(255), contact_info VARCHAR(255)); CREATE TABLE Volunteer_Hours (id INT, volunteer_id INT, program VARCHAR(255), hours INT); INSERT INTO Volunteers (id, name, contact_info) VALUES (1, 'Alice Johnson', 'alicejohnson@example.com'), (2, 'Brian Lee', 'brianlee@example.com'); INSERT INTO Volunteer_Hours (id, volunteer_id, program, hours) VALUES (1, 1, 'Sports', 20), (2, 1, 'Sports', 15), (3, 2, 'Education', 30);
What is the total number of volunteer hours for the sports program?
SELECT SUM(hours) FROM Volunteer_Hours WHERE program = 'Sports';
gretelai_synthetic_text_to_sql
CREATE TABLE LandfillCapacities (country VARCHAR(50), capacity INT); INSERT INTO LandfillCapacities (country, capacity) VALUES ('Germany', 120000), ('France', 90000), ('UK', 80000);
What is the total landfill capacity for European countries?
SELECT SUM(capacity) FROM LandfillCapacities WHERE country IN ('Germany', 'France', 'UK', 'Italy', 'Spain');
gretelai_synthetic_text_to_sql
CREATE TABLE wildlife_sightings (id INT, community VARCHAR(255), num_sightings INT); CREATE TABLE indigenous_communities (id INT, name VARCHAR(255), location VARCHAR(255));
Which indigenous communities have the highest number of reported wildlife sightings?
SELECT i.name, w.num_sightings FROM indigenous_communities i JOIN wildlife_sightings w ON i.location = w.community ORDER BY w.num_sightings DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Concerts (id INT, artist VARCHAR(100), location VARCHAR(100), price DECIMAL(5,2)); INSERT INTO Concerts (id, artist, location, price) VALUES (1, 'Shakira', 'Brazil', 75.00), (2, 'Pitbull', 'Brazil', 85.00);
What is the minimum ticket price for concerts in Brazil?
SELECT MIN(price) FROM Concerts WHERE location = 'Brazil'
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels (id INT, name VARCHAR(50), country VARCHAR(50)); CREATE TABLE SafetyIncidents (id INT, vessel_id INT, incident_type VARCHAR(50), time TIMESTAMP, latitude DECIMAL(9,6), longitude DECIMAL(9,6));
Find the number of safety incidents for each vessel operating in the Gulf of Mexico in the last 3 years.
SELECT V.name, COUNT(SI.id) FROM Vessels V JOIN SafetyIncidents SI ON V.id = SI.vessel_id WHERE SI.time > NOW() - INTERVAL '3 years' AND SI.latitude BETWEEN 15 AND 30 AND SI.longitude BETWEEN -100 AND -85 GROUP BY V.name;
gretelai_synthetic_text_to_sql
CREATE TABLE SpacecraftManufacturing(ID INT, SpacecraftName VARCHAR(50), ManufacturingCost FLOAT);
What was the total cost of Spacecraft X manufacturing?
SELECT ManufacturingCost FROM SpacecraftManufacturing WHERE SpacecraftName = 'Spacecraft X';
gretelai_synthetic_text_to_sql
CREATE TABLE PatientTreatmentInfo (PatientID INT, Age INT, Condition VARCHAR(50), TreatmentDate DATE, City VARCHAR(50), State VARCHAR(20));
What is the average age of patients with a mental health condition who have been treated in the past year in New York?
SELECT AVG(Age) FROM PatientTreatmentInfo WHERE TreatmentDate >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR) AND State = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE waste_generation (city VARCHAR(255), quarter INT, material_type VARCHAR(255), generation_grams INT); INSERT INTO waste_generation (city, quarter, material_type, generation_grams) VALUES ('Chicago', 2, 'Plastic', 1800);
Update the waste generation for plastic in the city of Chicago to 2000 grams in the second quarter of 2021.
UPDATE waste_generation SET generation_grams = 2000 WHERE city = 'Chicago' AND quarter = 2 AND material_type = 'Plastic';
gretelai_synthetic_text_to_sql
CREATE TABLE DissolvedOxygenData (id INT, country VARCHAR(50), year INT, min_oxygen FLOAT, max_oxygen FLOAT); INSERT INTO DissolvedOxygenData (id, country, year, min_oxygen, max_oxygen) VALUES (1, 'Brazil', 2017, 6.5, 8.2), (2, 'Brazil', 2018, 6.3, 8.4), (3, 'Brazil', 2019, 6.8, 8.1), (4, 'Brazil', 2020, 6.6, 8.3), (5, 'Brazil', 2021, 6.7, 8.2);
What is the minimum and maximum dissolved oxygen levels (in mg/L) for aquaculture farms in Brazil, for each year between 2017 and 2022?
SELECT year, MIN(min_oxygen), MAX(max_oxygen) FROM DissolvedOxygenData WHERE country = 'Brazil' GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE clinics (clinic_id INT, clinic_name VARCHAR(50), city VARCHAR(50), state VARCHAR(50)); INSERT INTO clinics (clinic_id, clinic_name, city, state) VALUES (1, 'ClinicC', 'Houston', 'TX'), (2, 'ClinicD', 'Austin', 'TX'); CREATE TABLE patients (patient_id INT, patient_name VARCHAR(50), age INT, clinic_id INT, condition_id INT); INSERT INTO patients (patient_id, patient_name, age, clinic_id, condition_id) VALUES (1, 'James Doe', 35, 1, 1), (2, 'Jasmine Smith', 28, 1, 2), (3, 'Alice Johnson', 42, 2, 3); CREATE TABLE conditions (condition_id INT, condition_name VARCHAR(50)); INSERT INTO conditions (condition_id, condition_name) VALUES (1, 'Depression'), (2, 'Anxiety Disorder'), (3, 'Bipolar Disorder'); CREATE TABLE therapies (therapy_id INT, therapy_name VARCHAR(50), patient_id INT, therapy_type VARCHAR(50)); INSERT INTO therapies (therapy_id, therapy_name, patient_id, therapy_type) VALUES (1, 'Group Therapy', 1, 'Group Therapy'), (2, 'Individual Therapy', 2, 'Individual Therapy');
What is the number of patients who received group therapy for depression in clinics located in Texas?
SELECT COUNT(*) FROM patients p JOIN clinics c ON p.clinic_id = c.clinic_id JOIN therapies t ON p.patient_id = t.patient_id JOIN conditions cond ON p.condition_id = cond.condition_id WHERE c.state = 'TX' AND cond.condition_name = 'Depression' AND t.therapy_type = 'Group Therapy';
gretelai_synthetic_text_to_sql
CREATE TABLE equipment_maintenance (request_id INT, priority INT, equipment_type VARCHAR(50), request_date DATE); INSERT INTO equipment_maintenance (request_id, priority, equipment_type, request_date) VALUES (1, 4, 'M1 Abrams', '2022-01-01'), (2, 5, 'C-130 Hercules', '2022-02-15'), (3, 3, 'CH-47 Chinook', '2022-03-05');
Show military equipment maintenance requests categorized by priority level, for equipment types starting with the letter 'C', in the last 3 months.
SELECT priority, equipment_type, COUNT(*) as num_requests FROM equipment_maintenance WHERE equipment_type LIKE 'C%' AND request_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH) GROUP BY priority, equipment_type;
gretelai_synthetic_text_to_sql
CREATE TABLE community_development (id INT, initiative_name TEXT, location TEXT, start_date DATE); INSERT INTO community_development (id, initiative_name, location, start_date) VALUES (1, 'Youth Center', 'North', '2021-05-01'), (2, 'Community Garden', 'South', '2020-01-15'), (3, 'Senior Center', 'West', '2022-06-15'), (4, 'Makerspace', 'East', '2021-12-20');
How many community development initiatives in the 'community_development' table, started in the second half of 2021?
SELECT COUNT(*) FROM community_development WHERE start_date >= '2021-07-01' AND start_date < '2022-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE VirtualTours (hotel_id INT, city TEXT, engagement_percentage FLOAT); INSERT INTO VirtualTours (hotel_id, city, engagement_percentage) VALUES (1, 'Tokyo', 25), (2, 'Tokyo', 30), (3, 'Tokyo', 20);
What is the engagement percentage of virtual tours for hotels in 'Tokyo'?
SELECT AVG(engagement_percentage) FROM VirtualTours WHERE city = 'Tokyo';
gretelai_synthetic_text_to_sql
CREATE TABLE department (id INT, name VARCHAR(255)); CREATE TABLE department_vulnerabilities (department_id INT, vulnerability_count INT); INSERT INTO department (id, name) VALUES (1, 'Finance'), (2, 'IT'); INSERT INTO department_vulnerabilities (department_id, vulnerability_count) VALUES (1, 2), (2, 0);
What are the names of all the departments that have no recorded vulnerabilities?
SELECT name FROM department WHERE id NOT IN (SELECT department_id FROM department_vulnerabilities WHERE vulnerability_count > 0);
gretelai_synthetic_text_to_sql
CREATE TABLE production_data (element VARCHAR(20), year INT, quantity FLOAT); INSERT INTO production_data (element, year, quantity) VALUES ('gadolinium', 2015, 150), ('gadolinium', 2016, 170), ('gadolinium', 2017, 190), ('gadolinium', 2018, 210), ('gadolinium', 2019, 230), ('gadolinium', 2020, 250), ('promethium', 2015, 50), ('promethium', 2016, 55), ('promethium', 2017, 60), ('promethium', 2018, 65), ('promethium', 2019, 70), ('promethium', 2020, 75), ('ytterbium', 2015, 30), ('ytterbium', 2016, 33), ('ytterbium', 2017, 36), ('ytterbium', 2018, 39), ('ytterbium', 2019, 42), ('ytterbium', 2020, 45);
What is the minimum production quantity (in metric tons) for gadolinium, promethium, and ytterbium in the production_data table?
SELECT MIN(quantity) FROM production_data WHERE element IN ('gadolinium', 'promethium', 'ytterbium');
gretelai_synthetic_text_to_sql
CREATE TABLE Military_Aid (id INT, country VARCHAR(50), year INT, military_aid INT); CREATE TABLE Humanitarian_Aid (id INT, country VARCHAR(50), year INT, humanitarian_aid INT);
Which countries have provided the most military and humanitarian aid in the last 5 years?
SELECT m.country, SUM(m.military_aid + h.humanitarian_aid) as total_aid FROM Military_Aid m JOIN Humanitarian_Aid h ON m.country = h.country WHERE m.year BETWEEN (YEAR(CURRENT_DATE) - 5) AND YEAR(CURRENT_DATE) GROUP BY m.country;
gretelai_synthetic_text_to_sql
CREATE TABLE students (student_id INT, dept_id INT, year INT, graduated BOOLEAN);CREATE TABLE departments (dept_id INT, dept_name VARCHAR(255));
Find the number of students who graduated per year, partitioned by department, in ascending order of graduation year.
SELECT dept_name, year, COUNT(student_id) AS num_graduates FROM students s JOIN departments d ON s.dept_id = d.dept_id WHERE graduated = TRUE GROUP BY dept_name, year ORDER BY year ASC;
gretelai_synthetic_text_to_sql
CREATE TABLE movies (id INT PRIMARY KEY, title TEXT, duration INT, director TEXT); INSERT INTO movies (id, title, duration, director) VALUES (1, 'Movie1', 120, 'John Doe'), (2, 'Movie2', 150, 'Jane Doe'), (3, 'Movie3', 240, 'Alex Smith');
Delete all movies with a duration of over 180 minutes directed by men.
DELETE FROM movies WHERE director IN ('John Doe', 'Alex Smith') AND duration > 180;
gretelai_synthetic_text_to_sql
CREATE SCHEMA defense_diplomacy;CREATE TABLE african_union_budget (country VARCHAR(50), budget INT, year INT);INSERT INTO defense_diplomacy.african_union_budget (country, budget, year) VALUES ('Nigeria', 5000000, 2022), ('South Africa', 6000000, 2022), ('Egypt', 7000000, 2022), ('Algeria', 4000000, 2022), ('Morocco', 8000000, 2022);
What is the maximum budget allocated for defense diplomacy by African Union countries in 2022?
SELECT MAX(budget) FROM defense_diplomacy.african_union_budget WHERE year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (region TEXT, year INT, registered BOOLEAN); INSERT INTO vessels (region, year, registered) VALUES ('Atlantic Ocean', 2019, TRUE), ('Atlantic Ocean', 2020, TRUE);
How many vessels were registered in the Atlantic Ocean in the year 2019?
SELECT COUNT(*) FROM vessels WHERE region = 'Atlantic Ocean' AND year = 2019 AND registered = TRUE;
gretelai_synthetic_text_to_sql
CREATE SCHEMA activity;CREATE TABLE activity.user_activity (user_id INT, activity_hour TIME);
What is the distribution of user activity by hour in the 'activity' schema?
SELECT activity_hour, COUNT(user_id) FROM activity.user_activity GROUP BY activity_hour;
gretelai_synthetic_text_to_sql
CREATE TABLE customers_usa (customer_id INT, name VARCHAR(255), state VARCHAR(255)); INSERT INTO customers_usa (customer_id, name, state) VALUES (1, 'John Doe', 'California'), (2, 'Jane Smith', 'New York'); CREATE TABLE data_usage_usa (customer_id INT, monthly_data_usage DECIMAL(10,2)); INSERT INTO data_usage_usa (customer_id, monthly_data_usage) VALUES (1, 10.5), (2, 15.6);
What is the maximum data usage in gigabytes per month for customers in the state of California?
SELECT MAX(monthly_data_usage) FROM data_usage_usa INNER JOIN customers_usa ON data_usage_usa.customer_id = customers_usa.customer_id WHERE state = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE articles (id INT PRIMARY KEY, title TEXT, category TEXT, publication_date DATE, author_id INT);
What is the total number of articles published in the "articles" table for the 'investigative' category?
SELECT COUNT(*) FROM articles WHERE category = 'investigative';
gretelai_synthetic_text_to_sql
CREATE TABLE EmergencyResponse (id INT, incidentType VARCHAR(20), region VARCHAR(10), responseTime INT, year INT);
Identify the top 5 emergency response times for 'Medical' incidents in 'West' region, for the last 3 years, from 'EmergencyResponse' table.
SELECT incidentType, region, MIN(responseTime) FROM EmergencyResponse WHERE incidentType = 'Medical' AND region = 'West' AND year BETWEEN (YEAR(CURRENT_DATE) - 3) AND YEAR(CURRENT_DATE) GROUP BY incidentType, region ORDER BY responseTime LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE housing_subsidies (id INT, policy_name TEXT, start_date DATE, end_date DATE);
Insert records for 3 new subsidies into the 'housing_subsidies' table.
INSERT INTO housing_subsidies (id, policy_name, start_date, end_date) VALUES (1, 'Policy 1', '2022-01-01', '2023-12-31'), (2, 'Policy 2', '2022-01-01', '2025-12-31'), (3, 'Policy 3', '2024-01-01', '2026-12-31');
gretelai_synthetic_text_to_sql
CREATE TABLE Streaming_Users (user_id INT, country VARCHAR(50), subscription_date DATE, cancelled_date DATE);
Monthly active users of streaming service in Germany?
SELECT COUNT(DISTINCT user_id) as monthly_active_users FROM Streaming_Users WHERE country = 'Germany' AND cancelled_date > DATE_ADD(subscription_date, INTERVAL 30 DAY);
gretelai_synthetic_text_to_sql
CREATE TABLE peacekeeping (id INT, operation VARCHAR(50), service1 VARCHAR(10), service2 VARCHAR(10), year INT); INSERT INTO peacekeeping (id, operation, service1, service2, year) VALUES (1, 'Op1', 'Marine Corps', 'Army', 2015); INSERT INTO peacekeeping (id, operation, service1, service2, year) VALUES (2, 'Op2', 'Army', 'Marine Corps', 2017);
Find the number of peacekeeping operations where the Marine Corps and Army participated together from 2015 to 2017.
SELECT COUNT(*) FROM peacekeeping WHERE (service1 = 'Marine Corps' AND service2 = 'Army') OR (service1 = 'Army' AND service2 = 'Marine Corps') AND year BETWEEN 2015 AND 2017;
gretelai_synthetic_text_to_sql
CREATE TABLE campaigns (id INT, name TEXT); CREATE TABLE donations (id INT, donor_id INT, campaign_id INT, donation_amount DECIMAL(10,2)); INSERT INTO campaigns (id, name) VALUES (1, 'Campaign A'), (2, 'Campaign B'); INSERT INTO donations (id, donor_id, campaign_id, donation_amount) VALUES (1, 1, 1, 50.00), (2, 2, 1, 100.00);
How many donors have made a donation to a specific campaign?
SELECT COUNT(DISTINCT donor_id) FROM donations JOIN campaigns ON donations.campaign_id = campaigns.id WHERE campaigns.name = 'Campaign A';
gretelai_synthetic_text_to_sql
CREATE TABLE Companies (id INT, name VARCHAR(50), industry VARCHAR(50), country VARCHAR(50), founding_year INT, founder_gender VARCHAR(10)); CREATE TABLE Funding (id INT, company_name VARCHAR(50), funding_amount INT); INSERT INTO Companies (id, name, industry, country, founding_year, founder_gender) VALUES (1, 'EduMale', 'EdTech', 'USA', 2016, 'Male'); INSERT INTO Funding (id, company_name, funding_amount) VALUES (1, 'EduMale', 3000000);
What is the total number of funding records for companies with male founders in the EdTech industry?
SELECT COUNT(*) as funding_records_count FROM Funding INNER JOIN Companies ON Funding.company_name = Companies.name WHERE Companies.industry = 'EdTech' AND Companies.founder_gender = 'Male';
gretelai_synthetic_text_to_sql
CREATE TABLE shipments (id INT, source_country VARCHAR(20), destination_state VARCHAR(20), weight FLOAT, shipping_date DATE); INSERT INTO shipments (id, source_country, destination_state, weight, shipping_date) VALUES (1, 'China', 'Texas', 25.3, '2022-01-03'), (2, 'China', 'Texas', 34.8, '2022-01-07');
What is the average weight of packages shipped to Texas from China in the last month?
SELECT AVG(weight) FROM shipments WHERE source_country = 'China' AND destination_state = 'Texas' AND shipping_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, name VARCHAR(50), email VARCHAR(50), subscribed_to_newsletter BOOLEAN);
Delete records of users who have unsubscribed from the newsletter in the last month from the users table
DELETE FROM users WHERE subscribed_to_newsletter = false AND signup_date < DATE_SUB(CURDATE(), INTERVAL 1 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE OrganicProducts (productID int, productName varchar(255), price decimal(10,2), country varchar(255), date datetime); INSERT INTO OrganicProducts VALUES (1, 'Apples', 1.99, 'USA', '2022-01-01'); CREATE TABLE Sales (saleID int, productID int, quantity int, date datetime); INSERT INTO Sales VALUES (1, 1, 50, '2022-01-02');
What is the total revenue of organic products sold in the USA in Q1 2022?
SELECT SUM(Op.price * S.quantity) as total_revenue FROM OrganicProducts Op INNER JOIN Sales S ON Op.productID = S.productID WHERE Op.country = 'USA' AND YEAR(S.date) = 2022 AND QUARTER(S.date) = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE customer_sizes (customer_id INT, customer_size TEXT, customer_country TEXT);
What is the distribution of customer sizes in France?
SELECT customer_size, COUNT(*) AS customer_count FROM customer_sizes WHERE customer_country = 'France' GROUP BY customer_size
gretelai_synthetic_text_to_sql
CREATE TABLE Grants (GrantID int, GrantSize decimal(10,2)); INSERT INTO Grants (GrantID, GrantSize) VALUES (1, 5000.00), (2, 10000.00), (3, 15000.00);
What is the distribution of grants by size?
SELECT GrantSize, COUNT(GrantID) AS GrantCount FROM Grants GROUP BY GrantSize;
gretelai_synthetic_text_to_sql
CREATE TABLE co2_emissions (id INT, transportation_mode VARCHAR(255), co2_emission_g_km INT); INSERT INTO co2_emissions (id, transportation_mode, co2_emission_g_km) VALUES (1, 'Car', 120), (2, 'Bus', 80), (3, 'Train', 40), (4, 'Plane', 150), (5, 'Bicycle', 0), (6, 'Foot', 0);
What is the average CO2 emission for each mode of transportation in the EU?
SELECT transportation_mode, AVG(co2_emission_g_km) as avg_co2_emission FROM co2_emissions GROUP BY transportation_mode;
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (VolunteerID INT, VolunteerName TEXT, Country TEXT); INSERT INTO Volunteers (VolunteerID, VolunteerName, Country) VALUES (1, 'Marcos Santos', 'Brazil'), (2, 'Sophie Dupont', 'Canada'); CREATE TABLE VolunteerPrograms (ProgramID INT, ProgramName TEXT); INSERT INTO VolunteerPrograms (ProgramID, ProgramName) VALUES (1, 'Education'), (2, 'Environment'); CREATE TABLE VolunteerAssignments (AssignmentID INT, VolunteerID INT, ProgramID INT, Hours DECIMAL); INSERT INTO VolunteerAssignments (AssignmentID, VolunteerID, ProgramID, Hours) VALUES (1, 1, 1, 10.00), (2, 1, 2, 8.00);
How many volunteers from Brazil participated in each program, and what was the total number of volunteer hours for each program?
SELECT VolunteerPrograms.ProgramName, COUNT(DISTINCT Volunteers.VolunteerID) AS VolunteerCount, SUM(VolunteerAssignments.Hours) AS TotalHours FROM Volunteers INNER JOIN VolunteerAssignments ON Volunteers.VolunteerID = VolunteerAssignments.VolunteerID INNER JOIN VolunteerPrograms ON VolunteerAssignments.ProgramID = VolunteerPrograms.ProgramID WHERE Volunteers.Country = 'Brazil' GROUP BY VolunteerPrograms.ProgramName;
gretelai_synthetic_text_to_sql
CREATE TABLE calls (call_id INT, customer_id INT, call_duration INT, call_date DATE); INSERT INTO calls VALUES (1, 1, 200, '2022-01-01'); INSERT INTO calls VALUES (2, 1, 150, '2022-01-02'); INSERT INTO calls VALUES (3, 2, 250, '2022-01-03');
What is the average call duration per day for each customer?
SELECT customer_id, DATE(call_date) as call_date, AVG(call_duration) as avg_call_duration FROM calls GROUP BY customer_id, call_date;
gretelai_synthetic_text_to_sql
CREATE SCHEMA renewables;CREATE TABLE hydro_power (name VARCHAR(50), capacity INT);INSERT INTO renewables.hydro_power (name, capacity) VALUES ('PowerPlant1', 300);CREATE TABLE wind_farms (name VARCHAR(50), capacity INT);INSERT INTO renewables.wind_farms (name, capacity) VALUES ('Farm1', 100), ('Farm2', 200);
Find the difference between the sum of capacities for hydro and wind power in the 'renewables' schema?
SELECT (SELECT SUM(capacity) FROM renewables.hydro_power) - (SELECT SUM(capacity) FROM renewables.wind_farms);
gretelai_synthetic_text_to_sql
CREATE TABLE Festivals (FestivalID INT, Name VARCHAR(255), Genre VARCHAR(255), Location VARCHAR(255), Country VARCHAR(255), Year INT, Revenue INT); INSERT INTO Festivals VALUES (4, 'Montreal Jazz Festival', 'Jazz', 'Montreal', 'Canada', 2022, 12000000); INSERT INTO Festivals VALUES (5, 'Newport Jazz Festival', 'Jazz', 'Newport', 'USA', 2022, 5000000);
What is the total revenue of jazz festivals in North America?
SELECT SUM(Revenue) FROM Festivals WHERE Genre = 'Jazz' AND Country = 'North America';
gretelai_synthetic_text_to_sql
CREATE TABLE employees (employee_id INT, name TEXT, hire_date DATE);
How many employees were hired in each month of 2020?
SELECT EXTRACT(MONTH FROM hire_date) AS month, COUNT(*) AS num_hired FROM employees WHERE hire_date BETWEEN '2020-01-01' AND '2020-12-31' GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE national_parks (country VARCHAR(20), park VARCHAR(50), visitors INT, year INT); INSERT INTO national_parks (country, park, visitors, year) VALUES ('Canada', 'Banff National Park', 800000, 2019), ('Canada', 'Jasper National Park', 600000, 2019), ('Canada', 'Banff National Park', 700000, 2020), ('Canada', 'Jasper National Park', 500000, 2020);
What is the total number of tourists who visited Canadian national parks in 2019 and 2020?
SELECT year, SUM(visitors) as total_visitors FROM national_parks WHERE country = 'Canada' GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE models_explainability (model_id INT, org_id INT, explainability_score FLOAT); INSERT INTO models_explainability (model_id, org_id, explainability_score) VALUES (101, 1, 0.85), (102, 1, 0.92), (103, 2, 0.88), (104, 2, 0.9), (105, 3, 0.95);
What is the minimum, maximum, and average explainability score of the models developed by different organizations?
SELECT org_id, MIN(explainability_score) as min_score, MAX(explainability_score) as max_score, AVG(explainability_score) as avg_score FROM models_explainability GROUP BY org_id;
gretelai_synthetic_text_to_sql
CREATE TABLE movies (id INT, title VARCHAR(255), genre VARCHAR(50), rating DECIMAL(3,2)); INSERT INTO movies (id, title, genre, rating) VALUES (1, 'MovieA', 'Horror', 7.2); INSERT INTO movies (id, title, genre, rating) VALUES (2, 'MovieB', 'Comedy', 8.5); INSERT INTO movies (id, title, genre, rating) VALUES (3, 'MovieC', 'Horror', 6.8);
What's the average rating for horror movies?
SELECT AVG(rating) FROM movies WHERE genre = 'Horror';
gretelai_synthetic_text_to_sql
CREATE TABLE broadband_revenue (revenue_id INT, revenue_date DATE, revenue_amount FLOAT); INSERT INTO broadband_revenue (revenue_id, revenue_date, revenue_amount) VALUES (1, '2021-01-01', 25000); INSERT INTO broadband_revenue (revenue_id, revenue_date, revenue_amount) VALUES (2, '2021-02-15', 30000);
Display the total revenue generated from broadband services for each quarter in the year 2021.
SELECT DATE_TRUNC('quarter', revenue_date) AS quarter, SUM(revenue_amount) AS total_revenue FROM broadband_revenue WHERE revenue_date >= '2021-01-01' AND revenue_date < '2022-01-01' GROUP BY quarter;
gretelai_synthetic_text_to_sql
CREATE TABLE security_incidents (id INT, city VARCHAR(255), timestamp TIMESTAMP);
How many security incidents were recorded in each city in the last 6 months?
SELECT city, COUNT(*) FROM security_incidents WHERE timestamp >= NOW() - INTERVAL 6 MONTH GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE landfill_capacity (state VARCHAR(20), capacity_remaining FLOAT); INSERT INTO landfill_capacity (state, capacity_remaining) VALUES ('New York', 75.0), ('Pennsylvania', 70.0), ('New Jersey', 65.0);
Which state has the least landfill capacity remaining?
SELECT state, MIN(capacity_remaining) FROM landfill_capacity;
gretelai_synthetic_text_to_sql
CREATE TABLE military_equipment (id INT, equipment_name VARCHAR(50), equipment_type VARCHAR(30), price DECIMAL(10,2), sale_date DATE);
What is the average price of military equipment sold to European countries in the last quarter?
SELECT AVG(price) as avg_price FROM military_equipment WHERE sale_date >= DATEADD(quarter, -1, GETDATE()) AND country IN ('France', 'Germany', 'Italy', 'Spain', 'United Kingdom');
gretelai_synthetic_text_to_sql
CREATE TABLE space_debris (id INT, size DECIMAL(3,1), source VARCHAR(50));
Calculate the percentage of space debris that is larger than 10 cm?
SELECT 100.0 * COUNT(CASE WHEN size > 10 THEN 1 END) / COUNT(*) AS pct_large_debris FROM space_debris;
gretelai_synthetic_text_to_sql
CREATE TABLE user_data (user_id INT, followers INT, category VARCHAR(50), platform VARCHAR(20)); INSERT INTO user_data (user_id, followers, category, platform) VALUES (1, 1000, 'cooking', 'Facebook'), (2, 2000, 'technology', 'Facebook'), (3, 500, 'cooking', 'Facebook');
What is the average number of followers for users who posted in the 'cooking' category on Facebook?
SELECT AVG(followers) FROM user_data WHERE category = 'cooking' AND platform = 'Facebook';
gretelai_synthetic_text_to_sql
CREATE TABLE wildlife_habitat (id INT, name VARCHAR(50), area FLOAT); INSERT INTO wildlife_habitat (id, name, area) VALUES (1, 'Habitat1', 50.23); INSERT INTO wildlife_habitat (id, name, area) VALUES (2, 'Habitat2', 75.64); INSERT INTO wildlife_habitat (id, name, area) VALUES (3, 'Habitat3', 85.34);
List all wildlife habitats that have an area greater than 60
SELECT * FROM wildlife_habitat WHERE area > 60;
gretelai_synthetic_text_to_sql
CREATE TABLE rural_diseases (id INT, name VARCHAR(50), prevalence DECIMAL(3,2), location VARCHAR(50));
Update the prevalence to 0.12 for the record with the name 'Influenza' in the 'rural_diseases' table
UPDATE rural_diseases SET prevalence = 0.12 WHERE name = 'Influenza';
gretelai_synthetic_text_to_sql
CREATE TABLE Disasters (DisasterID INT, DisasterName VARCHAR(100), DisasterType VARCHAR(100)); INSERT INTO Disasters (DisasterID, DisasterName, DisasterType) VALUES (1, 'Disaster1', 'Flood'), (2, 'Disaster2', 'Earthquake'), (3, 'Disaster3', 'Flood'); CREATE TABLE Aid (AidID INT, AidType VARCHAR(100), DisasterID INT, Cost DECIMAL(10,2)); INSERT INTO Aid (AidID, AidType, DisasterID, Cost) VALUES (1, 'Food', 1, 10000), (2, 'Medical', 1, 15000), (3, 'Shelter', 2, 20000);
What is the most common type of aid provided for each disaster, and the total cost of that type of aid?
SELECT DisasterType, AidType, COUNT(*) as Count, SUM(Cost) as TotalCost FROM Aid JOIN Disasters ON Aid.DisasterID = Disasters.DisasterID GROUP BY DisasterType, AidType ORDER BY Count DESC, TotalCost DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE cuisine (cuisine_id INT, cuisine_name VARCHAR(255)); INSERT INTO cuisine VALUES (1, 'Italian'); INSERT INTO cuisine VALUES (2, 'Indian'); CREATE TABLE dishes (dish_id INT, dish_name VARCHAR(255), cuisine_id INT, is_vegetarian BOOLEAN); INSERT INTO dishes VALUES (1, 'Pizza Margherita', 1, true); INSERT INTO dishes VALUES (2, 'Chole Bhature', 2, false);
What is the total number of vegetarian dishes offered by each cuisine?
SELECT cuisine_name, COUNT(*) as total_veg_dishes FROM cuisine JOIN dishes ON cuisine.cuisine_id = dishes.cuisine_id WHERE is_vegetarian = true GROUP BY cuisine_name;
gretelai_synthetic_text_to_sql
CREATE TABLE Flight_Safety_Record (id INT, airline VARCHAR(255), incidents INT, fatalities INT); INSERT INTO Flight_Safety_Record (id, airline, incidents, fatalities) VALUES (1, 'Delta Airlines', 5, 0), (2, 'American Airlines', 3, 1);
What is the total number of flight safety incidents and fatalities for each airline?
SELECT airline, SUM(incidents + fatalities) as total_safety_issues FROM Flight_Safety_Record GROUP BY airline;
gretelai_synthetic_text_to_sql
CREATE TABLE accidents (id INT, date DATE, description VARCHAR(50), severity INT);
Get the total number of accidents in the past 12 months?
SELECT COUNT(*) FROM accidents WHERE date >= DATE_SUB(CURRENT_DATE, INTERVAL 12 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE artists (id INT, name VARCHAR(50), continent VARCHAR(50)); INSERT INTO artists (id, name, continent) VALUES (1, 'Frida Kahlo', 'North America'); CREATE TABLE paintings (id INT, artist_id INT, year INT); INSERT INTO paintings (id, artist_id, year) VALUES (1, 1, 2000); INSERT INTO paintings (id, artist_id, year) VALUES (2, 2, 2010); INSERT INTO paintings (id, artist_id, year) VALUES (3, 1, 2015);
What is the total number of paintings created by artists from different continents in the last 50 years?
SELECT a.continent, COUNT(p.id) as total_paintings FROM paintings p JOIN artists a ON p.artist_id = a.id WHERE p.year BETWEEN YEAR(GETDATE()) - 50 AND YEAR(GETDATE()) GROUP BY a.continent;
gretelai_synthetic_text_to_sql