context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE Donors (DonorID INT, DonorName TEXT, DonationAmount INT, DonationYear INT); INSERT INTO Donors (DonorID, DonorName, DonationAmount, DonationYear) VALUES (1, 'Donor A', 4000, 2021), (2, 'Donor B', 6000, 2021), (1, 'Donor A', 3000, 2021), (2, 'Donor B', 5000, 2021); CREATE TABLE Organizations (OrganizationID...
Which organizations received donations from donors A and B in 2021?
SELECT OrganizationName FROM Organizations INNER JOIN Donations ON Organizations.OrganizationID = Donations.OrganizationID WHERE DonorID IN (1, 2) AND DonationYear = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE solar_panels (id INT, manufacturer VARCHAR(255), installed_year INT, capacity FLOAT);
Insert a new record into the 'solar_panels' table for a 300 W panel manufactured by 'SunCraft' in 2020
INSERT INTO solar_panels (id, manufacturer, installed_year, capacity) VALUES (1, 'SunCraft', 2020, 300);
gretelai_synthetic_text_to_sql
CREATE TABLE SustainableFish (date DATE, temperature FLOAT); INSERT INTO SustainableFish (date, temperature) VALUES ('2022-03-01', 21.0), ('2022-03-02', 22.0), ('2022-03-03', 23.0);
What is the minimum water temperature in the SustainableFish table for March 2022?
SELECT MIN(temperature) FROM SustainableFish WHERE MONTH(date) = 3 AND YEAR(date) = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (collection VARCHAR(20), revenue INT); INSERT INTO sales (collection, revenue) VALUES ('Spring 2021', 500000), ('Fall 2021', 600000), ('Winter 2021', 700000), ('Spring 2022', 800000);
What is the total revenue for each collection in the sales table?
SELECT collection, SUM(revenue) FROM sales GROUP BY collection;
gretelai_synthetic_text_to_sql
CREATE TABLE startups (id INT, name TEXT, country TEXT, funding FLOAT); INSERT INTO startups (id, name, country, funding) VALUES (1, 'Genetech', 'USA', 50000000); INSERT INTO startups (id, name, country, funding) VALUES (2, 'BioSteward', 'Canada', 75000000);
What is the maximum funding received by a biotech startup in each country?
SELECT country, MAX(funding) FROM startups GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE research_papers (paper_id INT, title VARCHAR(50), citations INT); INSERT INTO research_papers (paper_id, title, citations) VALUES (1, 'Autonomous Driving Algorithms', 120), (2, 'Deep Learning for Self-Driving Cars', 150), (3, 'LiDAR Sensor Technology in AVs', 85);
Show the top 3 autonomous driving research papers with the highest number of citations in the 'research_papers' table.
SELECT title, citations FROM (SELECT title, citations, RANK() OVER (ORDER BY citations DESC) rank FROM research_papers) sq WHERE rank <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE students (id INT, name TEXT, gender TEXT, enrollment_date DATE); INSERT INTO students (id, name, gender, enrollment_date) VALUES (1, 'Alice', 'Female', '2021-06-01'); INSERT INTO students (id, name, gender, enrollment_date) VALUES (2, 'Bob', 'Male', '2021-01-15'); INSERT INTO students (id, name, gender, en...
How many students have enrolled in online courses in the last 6 months?
SELECT COUNT(*) FROM students WHERE enrollment_date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) AND course_type = 'Online';
gretelai_synthetic_text_to_sql
CREATE TABLE auto_workers_union.auto_workers (id INT, name TEXT, union_member BOOLEAN);
How many members does 'auto_workers_union' have?
SELECT COUNT(*) FROM auto_workers_union.auto_workers WHERE union_member = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE events (event_id INT, event_name VARCHAR(50)); CREATE TABLE athlete_events (athlete_id INT, event_id INT);
How many athletes have participated in a specific event?
SELECT e.event_name, COUNT(*) as athlete_count FROM events e JOIN athlete_events ae ON e.event_id = ae.event_id GROUP BY e.event_name;
gretelai_synthetic_text_to_sql
CREATE TABLE menu_items (restaurant_id INT, is_sustainable BOOLEAN, number_of_items INT); INSERT INTO menu_items (restaurant_id, is_sustainable, number_of_items) VALUES (1, TRUE, 70), (1, FALSE, 30), (2, TRUE, 40), (2, FALSE, 60), (3, TRUE, 80), (3, FALSE, 20), (4, TRUE, 50), (4, FALSE, 50), (5, TRUE, 30), (5, FALSE, 7...
What percentage of menu items in each restaurant are sustainable, excluding restaurants with less than 50 menu items?
SELECT restaurant_id, (COUNT(*) FILTER (WHERE is_sustainable = TRUE) * 100.0 / COUNT(*)) AS percentage FROM menu_items WHERE number_of_items >= 50 GROUP BY restaurant_id;
gretelai_synthetic_text_to_sql
CREATE TABLE satellite_images (image_id INT PRIMARY KEY, image_url VARCHAR(255), cloud_coverage FLOAT, acquisition_date DATE);
Insert new records into the satellite_images table for images taken in the last week with cloud_coverage less than 30%
INSERT INTO satellite_images (image_url, cloud_coverage, acquisition_date) SELECT 'image_url_1', 0.25, DATE(CURRENT_DATE - INTERVAL '3 days') UNION ALL SELECT 'image_url_2', 0.15, DATE(CURRENT_DATE - INTERVAL '1 day') UNION ALL SELECT 'image_url_3', 0.20, DATE(CURRENT_DATE);
gretelai_synthetic_text_to_sql
CREATE TABLE financial_products (product_id INT, product_name TEXT, is_shariah_compliant BOOLEAN);
List all financial products with a Shariah-compliant status.
SELECT * FROM financial_products WHERE is_shariah_compliant = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE environmental_impact (id INT, disaster_name VARCHAR(50), year INT, environmental_impact_score INT); INSERT INTO environmental_impact (id, disaster_name, year, environmental_impact_score) VALUES (1, 'Australian Wildfires', 2020, 90), (2, 'Amazon Rainforest Fires', 2020, 80), (3, 'California Wildfires', 2020...
Which disasters in 2020 had the highest impact on the environment?
SELECT disaster_name FROM environmental_impact WHERE year = 2020 ORDER BY environmental_impact_score DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE VolunteerDonations (VolunteerID int, DonationAmount decimal(10,2)); INSERT INTO VolunteerDonations (VolunteerID, DonationAmount) VALUES (1, 600.00), (2, 250.00), (3, 800.00), (4, 300.00);
Find the names of volunteers who have donated more than $500 in total but never participated in the 'Animal Welfare' program category.
SELECT v.VolunteerName FROM Volunteers v JOIN VolunteerPrograms vp ON v.VolunteerID = vp.VolunteerID JOIN Programs p ON vp.ProgramID = p.ProgramID JOIN VolunteerDonations vd ON v.VolunteerID = vd.VolunteerID WHERE vd.DonationAmount > 500 AND p.Category NOT IN ('Animal Welfare') GROUP BY v.VolunteerID HAVING SUM(vd.Dona...
gretelai_synthetic_text_to_sql
CREATE TABLE Suppliers (SupplierID INT, CompanyName VARCHAR(50), Country VARCHAR(20)); INSERT INTO Suppliers VALUES (1, 'Supplier1', 'Asia'); INSERT INTO Suppliers VALUES (2, 'Supplier2', 'USA'); CREATE TABLE SupplierOrders (OrderID INT, SupplierID INT, OrderDate DATE); INSERT INTO SupplierOrders VALUES (1, 1); INSERT ...
Which of our suppliers in Asia have not supplied any products to us in the last year?
SELECT Suppliers.CompanyName FROM Suppliers LEFT JOIN SupplierOrders ON Suppliers.SupplierID = SupplierOrders.SupplierID WHERE Suppliers.Country = 'Asia' AND SupplierOrders.OrderDate < DATEADD(YEAR, -1, GETDATE()) AND SupplierOrders.OrderID IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE organizations (id INT PRIMARY KEY, name VARCHAR(50), type VARCHAR(50), location VARCHAR(50)); INSERT INTO organizations (id, name, type, location) VALUES (1, 'Greenpeace', 'Non-profit', 'Canada'); INSERT INTO organizations (id, name, type, location) VALUES (2, 'The Climate Group', 'Non-profit', 'UK'); INSE...
What are the names and types of organizations in 'Canada'?
SELECT organizations.name, organizations.type FROM organizations WHERE organizations.location = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE courses (course_id INT, course_name VARCHAR(50), creation_date DATE);
Delete all open pedagogy courses that were created before 2010 from the 'courses' table.
DELETE FROM courses WHERE course_name LIKE '%open pedagogy%' AND creation_date < '2010-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE restorative_completions (completion_id INT, program_id INT, state VARCHAR(20), completions INT); INSERT INTO restorative_completions (completion_id, program_id, state, completions) VALUES (1, 1, 'California', 35), (2, 2, 'California', 42), (3, 3, 'Texas', 21);
Which restorative program in California has the highest number of successful completions?
SELECT program_id, MAX(completions) FROM restorative_completions WHERE state = 'California' GROUP BY program_id;
gretelai_synthetic_text_to_sql
CREATE TABLE inventory (id INT, item VARCHAR(255), quantity INT); INSERT INTO inventory (id, item, quantity) VALUES (1, 'Organic Spinach', 50), (2, 'Tofu', 30), (3, 'Almond Milk', 20);
What is the inventory level of 'Organic Spinach'?
SELECT quantity FROM inventory WHERE item = 'Organic Spinach';
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_depths (id INT, name VARCHAR(255), location VARCHAR(255), depth FLOAT); INSERT INTO ocean_depths (id, name, location, depth) VALUES (1, 'Challenger Deep', 'Pacific Ocean', 10994); INSERT INTO ocean_depths (id, name, location, depth) VALUES (2, 'Southern Ocean Trench', 'Antarctic Ocean', 7235); INSERT...
What is the maximum depth of the deepest part of the Arctic, Atlantic, and Indian Oceans?
SELECT MAX(depth) FROM ocean_depths WHERE location IN ('Arctic Ocean', 'Atlantic Ocean', 'Indian Ocean');
gretelai_synthetic_text_to_sql
CREATE TABLE athletes (athlete_id INT, name VARCHAR(30), team VARCHAR(20)); INSERT INTO athletes VALUES (1, 'James', 'Lakers'); INSERT INTO athletes VALUES (2, 'Thomas', 'Celtics'); CREATE TABLE wellbeing_programs (program_id INT, athlete_id INT, program_name VARCHAR(30)); INSERT INTO wellbeing_programs VALUES (1, 1, '...
Who are the top 5 athletes with the highest participation in wellbeing programs?
SELECT athletes.name, COUNT(*) as program_count FROM athletes INNER JOIN wellbeing_programs ON athletes.athlete_id = wellbeing_programs.athlete_id GROUP BY athletes.name ORDER BY program_count DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE Athletes (athlete_id INT, name VARCHAR(255), participations INT); INSERT INTO Athletes (athlete_id, name, participations) VALUES (1, 'John Doe', 10), (2, 'Jane Smith', 12), (3, 'Mary Johnson', 8), (4, 'James Brown', 15);
Who are the top 3 athletes with the highest number of wellbeing program participations?
SELECT name, participations FROM Athletes ORDER BY participations DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists countries (id INT PRIMARY KEY, name VARCHAR(50), continent VARCHAR(50)); INSERT INTO countries (id, name, continent) VALUES (1, 'Haiti', 'North America'); INSERT INTO countries (id, name, continent) VALUES (2, 'Mexico', 'North America'); CREATE TABLE if not exists projects (id INT PRIMARY KEY...
Which volunteers are not assigned to any project in North America?
SELECT v.name FROM volunteers v LEFT JOIN projects p ON v.project_id = p.id WHERE p.id IS NULL AND c.continent = 'North America';
gretelai_synthetic_text_to_sql
CREATE TABLE Infrastructure_CA (ProjectID INT, Country VARCHAR(20), Type VARCHAR(20), Completion FLOAT); INSERT INTO Infrastructure_CA (ProjectID, Country, Type, Completion) VALUES (1, 'Guatemala', 'Transportation', 0.8), (2, 'Honduras', 'Energy', 0.7), (3, 'El Salvador', 'Irrigation', 0.6), (4, 'Nicaragua', 'Transport...
Which rural infrastructure projects in Central America have a completion rate higher than the overall completion rate for all projects, and what is the average completion rate for these projects?
SELECT AVG(Completion) as Avg_Completion_Rate FROM (SELECT Completion FROM Infrastructure_CA WHERE Country IN ('Guatemala', 'Honduras', 'El Salvador', 'Nicaragua', 'Costa Rica', 'Panama') HAVING Completion > (SELECT AVG(Completion) FROM Infrastructure_CA WHERE Country IN ('Guatemala', 'Honduras', 'El Salvador', 'Nicara...
gretelai_synthetic_text_to_sql
CREATE TABLE investment_rounds (id INT, company_name VARCHAR(100), round_type VARCHAR(50), raised_amount FLOAT, round_date DATE);
Insert a new investment round into the "investment_rounds" table for 'Charlie Startup' with $10M raised on 2022-01-01
INSERT INTO investment_rounds (id, company_name, round_type, raised_amount, round_date) VALUES (3, 'Charlie Startup', 'Series B', 10000000, '2022-01-01');
gretelai_synthetic_text_to_sql
CREATE TABLE GameDesignData (GameID INT PRIMARY KEY, GameName VARCHAR(50), Genre VARCHAR(20), Platform VARCHAR(20), ReleaseDate DATE, Developer VARCHAR(50));
Add a virtual reality game to the game design data
INSERT INTO GameDesignData (GameID, GameName, Genre, Platform, ReleaseDate, Developer) VALUES (1, 'VirtualReality Racer', 'Racing', 'VR', '2023-01-01', 'VR Game Studios');
gretelai_synthetic_text_to_sql
CREATE TABLE AssistiveTech (student_id INT, program_name VARCHAR(255), tech_type VARCHAR(255)); INSERT INTO AssistiveTech (student_id, program_name, tech_type) VALUES (1, 'Program A', 'Screen Reader'); INSERT INTO AssistiveTech (student_id, program_name, tech_type) VALUES (3, 'Program A', 'Text-to-Speech'); INSERT INTO...
What is the count of unique students who utilized assistive technology in each program?
SELECT program_name, COUNT(DISTINCT CASE WHEN tech_type = 'Assistive Technology' THEN student_id END) as unique_students FROM AssistiveTech GROUP BY program_name;
gretelai_synthetic_text_to_sql
CREATE TABLE solar_pv (id INT, country TEXT, year INT, capacity_mw FLOAT); INSERT INTO solar_pv (id, country, year, capacity_mw) VALUES (1, 'Japan', 2020, 60.5), (2, 'Japan', 2021, 65.6);
What is the total installed solar PV capacity (MW) in Japan as of 2021?
SELECT SUM(capacity_mw) FROM solar_pv WHERE country = 'Japan' AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE restaurant_revenue (restaurant_id INT, revenue_date DATE, total_revenue DECIMAL(10, 2));
Update the restaurant_revenue table to set the total_revenue to 0 for revenue_date '2022-07-01'
UPDATE restaurant_revenue SET total_revenue = 0 WHERE revenue_date = '2022-07-01';
gretelai_synthetic_text_to_sql
CREATE TABLE Programs (ProgramID INT, ProgramName TEXT, Budget FLOAT); CREATE TABLE VolunteerPrograms (VolunteerID INT, ProgramID INT, VolunteerDate DATE); INSERT INTO Programs (ProgramID, ProgramName, Budget) VALUES (1, 'Education', 10000.00), (2, 'Health', 15000.00); INSERT INTO VolunteerPrograms (VolunteerID, Progra...
List all programs and their corresponding volunteer engagement metrics for 2022, ordered by the highest number of volunteers?
SELECT Programs.ProgramName, COUNT(DISTINCT VolunteerPrograms.VolunteerID) as VolunteerCount FROM Programs INNER JOIN VolunteerPrograms ON Programs.ProgramID = VolunteerPrograms.ProgramID WHERE YEAR(VolunteerPrograms.VolunteerDate) = 2022 GROUP BY Programs.ProgramName ORDER BY VolunteerCount DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Habitat_Preservation (Id INT, Project_Name VARCHAR(50), Location VARCHAR(50), Budget DECIMAL(10, 2)); INSERT INTO Habitat_Preservation (Id, Project_Name, Location, Budget) VALUES (1, 'Amazon_Project_1', 'Amazon', 50000); INSERT INTO Habitat_Preservation (Id, Project_Name, Location, Budget) VALUES (2, 'Amaz...
What is the total budget for habitat preservation projects in the Amazon rainforest?
SELECT SUM(Budget) FROM Habitat_Preservation WHERE Location = 'Amazon';
gretelai_synthetic_text_to_sql
CREATE TABLE DisasterPreparedness (id INT, city VARCHAR(255), preparedness_score INT);
What is the minimum preparedness score for each city?
SELECT city, MIN(preparedness_score) FROM DisasterPreparedness GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers (id INT PRIMARY KEY, name VARCHAR(50), country VARCHAR(50), fair_trade BOOLEAN);
Which fair trade suppliers are based in South America?
SELECT name AS supplier_name FROM suppliers WHERE country IN ('Argentina', 'Bolivia', 'Brazil', 'Chile', 'Colombia', 'Ecuador', 'Guyana', 'Paraguay', 'Peru', 'Suriname', 'Uruguay', 'Venezuela') AND fair_trade = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE equipment_maintenance (equipment_id INT, branch VARCHAR(50), date DATE, status VARCHAR(50)); INSERT INTO equipment_maintenance (equipment_id, branch, date, status) VALUES (1002, 'Navy', '2020-07-18', 'Completed');
List all military equipment maintenance records for the Navy in Q3 2020
SELECT * FROM equipment_maintenance WHERE branch = 'Navy' AND QUARTER(date) = 3 AND YEAR(date) = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE donations_2 (id INT, donation_date DATE, donation_amount DECIMAL, donor_id INT);
What's the total number of donations and unique donors for each month in 2021?
SELECT EXTRACT(MONTH FROM donation_date) AS month, COUNT(id) AS total_donations, COUNT(DISTINCT donor_id) AS unique_donors FROM donations_2 WHERE donation_date >= '2021-01-01' GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE Sales (id INT, product_id INT, sale_date DATE, sale_price DECIMAL(5,2), country TEXT); CREATE TABLE Products (id INT, category TEXT, is_vegan BOOLEAN, price DECIMAL(5,2)); INSERT INTO Sales (id, product_id, sale_date, sale_price, country) VALUES (1, 1, '2022-02-01', 29.99, 'US'), (2, 2, '2022-03-05', 19.99...
What is the total revenue of vegan skincare products from the US?
SELECT SUM(sale_price) FROM Sales JOIN Products ON Sales.product_id = Products.id WHERE is_vegan = true AND category = 'Skincare' AND country = 'US';
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas(region VARCHAR(255), num_areas INT);INSERT INTO marine_protected_areas(region, num_areas) VALUES ('Africa', 120), ('Oceania', 200);
What is the total number of marine protected areas in Africa and Oceania?
SELECT SUM(num_areas) FROM marine_protected_areas WHERE region IN ('Africa', 'Oceania');
gretelai_synthetic_text_to_sql
CREATE TABLE peacekeeping(id INT, personnel_id INT, trained_in VARCHAR(255), training_year INT); INSERT INTO peacekeeping(id, personnel_id, trained_in, training_year) VALUES (1, 123, 'Humanitarian Assistance', 2017), (2, 456, 'Mediation', 2018), (3, 789, 'Humanitarian Assistance', 2019); CREATE TABLE nato_trainers(id I...
What is the total number of peacekeeping personnel who have received humanitarian assistance training from NATO since 2017?
SELECT COUNT(*) FROM peacekeeping p JOIN nato_trainers n ON p.trained_in = 'Humanitarian Assistance' AND trained_by = 'NATO';
gretelai_synthetic_text_to_sql
CREATE TABLE cities (id INT, name VARCHAR(30)); CREATE TABLE affordable_housing (id INT, city_id INT, units INT); INSERT INTO cities (id, name) VALUES (1, 'Seattle'), (2, 'Portland'), (3, 'Vancouver'); INSERT INTO affordable_housing (id, city_id, units) VALUES (101, 1, 200), (102, 1, 300), (103, 2, 150), (104, 3, 400);
Find the number of affordable housing units in each city.
SELECT cities.name, SUM(affordable_housing.units) FROM cities INNER JOIN affordable_housing ON cities.id = affordable_housing.city_id GROUP BY cities.name;
gretelai_synthetic_text_to_sql
CREATE TABLE PublicWorks (Service VARCHAR(255), District VARCHAR(255), Budget INT); INSERT INTO PublicWorks (Service, District, Budget) VALUES ('Road Maintenance', 'Downtown', 900000), ('Waste Management', 'Uptown', 1100000), ('Street Lighting', 'Suburbs', 700000);
What is the total budget allocated for the Public Works department's services in each city district?
SELECT SUM(Budget), District FROM PublicWorks GROUP BY District;
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (id INT, name VARCHAR(255), type VARCHAR(255)); CREATE TABLE safety_inspections (id INT, vessel_id INT, inspection_date DATE, result VARCHAR(255));
Delete all safety inspections prior to 2022-01-01 for the 'Ocean Titan' vessel.
DELETE FROM safety_inspections WHERE vessel_id IN (SELECT id FROM vessels WHERE name = 'Ocean Titan') AND inspection_date < '2022-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE artists (id INT, name VARCHAR(100)); INSERT INTO artists (id, name) VALUES (1, 'Taylor Swift');
Delete the artist 'Taylor Swift' from the artists table.
DELETE FROM artists WHERE name = 'Taylor Swift';
gretelai_synthetic_text_to_sql
CREATE TABLE policyholder_gender (policyholder_id INT, policyholder_gender VARCHAR(10)); CREATE TABLE policies (policy_id INT, policyholder_id INT); INSERT INTO policyholder_gender VALUES (1, 'Female'); INSERT INTO policies VALUES (1, 1);
What is the count of policies by policyholder gender?
SELECT policyholder_gender, COUNT(*) as policy_count FROM policies JOIN policyholder_gender ON policies.policyholder_id = policyholder_gender.policyholder_id GROUP BY policyholder_gender;
gretelai_synthetic_text_to_sql
CREATE TABLE threat_intelligence (report_id INT, report_date DATE, agency VARCHAR(100), report_text TEXT);
Identify the number of threat intelligence reports issued by each agency in the first quarter of 2022
SELECT agency, COUNT(*) FROM threat_intelligence WHERE report_date BETWEEN '2022-01-01' AND '2022-03-31' GROUP BY agency;
gretelai_synthetic_text_to_sql
CREATE TABLE States (State VARCHAR(50), Population INT, ObesityRate FLOAT); INSERT INTO States (State, Population, ObesityRate) VALUES ('California', 39512223, 25.1), ('Texas', 29528404, 32.4), ('Florida', 21647997, 27.8), ('New York', 19453561, 26.0), ('Pennsylvania', 12807060, 31.5), ('Illinois', 12671821, 30.3), ('O...
List the top 3 states in the US with the highest obesity rate?
SELECT State, ObesityRate FROM States ORDER BY ObesityRate DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE AgeData (PlayerID INT, Age INT, GameType VARCHAR(20)); INSERT INTO AgeData (PlayerID, Age, GameType) VALUES (1, 25, 'Action'), (2, 30, 'Adventure'), (3, 20, 'Simulation'), (4, 35, 'Simulation'), (5, 22, 'Action'), (6, 28, 'Simulation'), (7, 32, 'Action'), (8, 29, 'Action');
What is the maximum age of players who play action games?
SELECT GameType, MAX(Age) FROM AgeData WHERE GameType = 'Action';
gretelai_synthetic_text_to_sql
CREATE TABLE solar_plants (id INT, name TEXT, state TEXT, capacity_mw FLOAT); INSERT INTO solar_plants (id, name, state, capacity_mw) VALUES (1, 'Topaz Solar Farm', 'California', 550.0), (2, 'Solar Star', 'California', 579.0);
How many solar power plants are there in the state 'California' with a capacity greater than 100 MW?
SELECT COUNT(*) FROM solar_plants WHERE state = 'California' AND capacity_mw > 100.0;
gretelai_synthetic_text_to_sql
CREATE TABLE AISafety (id INT, concern VARCHAR(255), explainability_score DECIMAL(5,2)); INSERT INTO AISafety (id, concern, explainability_score) VALUES (1, 'Data Privacy', 78.91), (2, 'Unintended Consequences', 65.23), (3, 'Bias', 82.34);
What is the explainability score for each AI safety concern?
SELECT concern, AVG(explainability_score) as avg_explainability_score FROM AISafety GROUP BY concern;
gretelai_synthetic_text_to_sql
CREATE TABLE Feedback (Service VARCHAR(25), Score INT); INSERT INTO Feedback (Service, Score) VALUES ('Library', 8), ('Park', 7), ('Recreation Center', 9);
What is the average citizen feedback score for public libraries?
SELECT AVG(Score) FROM Feedback WHERE Service = 'Library';
gretelai_synthetic_text_to_sql
CREATE TABLE attraction_economic_impact (attraction_id INT, local_employment INT, annual_revenue FLOAT);
Update the local economic impact of an attraction
UPDATE attraction_economic_impact SET local_employment = 50, annual_revenue = 250000.00 WHERE attraction_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE otas (id INT, name TEXT, revenue FLOAT, q1_2022 FLOAT); INSERT INTO otas (id, name, revenue, q1_2022) VALUES (1, 'Expedia', 1000000, 350000), (2, 'Booking.com', 1200000, 420000), (3, 'Agoda', 800000, 380000);
Which 'online travel agency' has the highest revenue in 'Q1 2022'?
SELECT name FROM otas WHERE q1_2022 = (SELECT MAX(q1_2022) FROM otas);
gretelai_synthetic_text_to_sql
CREATE TABLE pollution_control (id INT, name TEXT, region TEXT); INSERT INTO pollution_control (id, name, region) VALUES (1, 'Initiative A', 'Indian Ocean'); INSERT INTO pollution_control (id, name, region) VALUES (2, 'Initiative B', 'Atlantic Ocean');
What are the names of all pollution control initiatives in the Indian Ocean?
SELECT name FROM pollution_control WHERE region = 'Indian Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE supply_chain_transparency (element VARCHAR(10), supplier VARCHAR(20), transparency INT); INSERT INTO supply_chain_transparency VALUES ('Dysprosium', 'Supplier A', 8), ('Dysprosium', 'Supplier B', 7), ('Dysprosium', 'Supplier C', 6), ('Terbium', 'Supplier A', 9), ('Terbium', 'Supplier B', 8), ('Terbium', 'S...
Identify the supplier with the lowest transparency score for Dysprosium and Terbium
SELECT element, MIN(transparency) AS min_transparency FROM supply_chain_transparency GROUP BY element;
gretelai_synthetic_text_to_sql
CREATE TABLE attorneys (attorney_id INT, name VARCHAR(50), state VARCHAR(50)); CREATE TABLE cases (case_id INT, attorney_id INT, state VARCHAR(50)); INSERT INTO attorneys (attorney_id, name, state) VALUES (1, 'Smith', 'California'), (2, 'Johnson', 'New York'), (3, 'Williams', 'California'), (4, 'Brown', 'Texas'); INSER...
How many cases were handled by each attorney in 'California'?
SELECT attorneys.name, COUNT(*) as cases_handled FROM attorneys INNER JOIN cases ON attorneys.attorney_id = cases.attorney_id WHERE attorneys.state = 'California' GROUP BY attorneys.name;
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_rates (city VARCHAR(50), population INT, continent VARCHAR(50), recycling_rate FLOAT); INSERT INTO recycling_rates (city, population, continent, recycling_rate) VALUES ('Tokyo', 9000000, 'Asia', 40), ('Delhi', 30000000, 'Asia', 35), ('Mumbai', 22000000, 'Asia', 28);
What is the average recycling rate in percentage for cities in Asia with a population greater than 2 million?
SELECT AVG(recycling_rate) FROM recycling_rates WHERE population > 2000000 AND continent = 'Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE Pizzeria (Date DATE, Revenue INT); INSERT INTO Pizzeria (Date, Revenue) VALUES ('2022-04-01', 600), ('2022-04-02', 700), ('2022-04-03', 800), ('2022-05-01', 600), ('2022-05-02', 700), ('2022-05-03', 800), ('2022-06-01', 600), ('2022-06-02', 700), ('2022-06-03', 800);
What was the total revenue for 'Crepe Cafe' in the second quarter of 2022?
SELECT SUM(Revenue) FROM Pizzeria WHERE Date BETWEEN '2022-04-01' AND '2022-06-30' AND Date LIKE '2022-04%' OR Date LIKE '2022-05%' OR Date LIKE '2022-06%' AND Restaurant = 'Crepe Cafe';
gretelai_synthetic_text_to_sql
CREATE TABLE subway_lines (line_id INT, line_name VARCHAR(255)); INSERT INTO subway_lines VALUES (1, 'Line 1'), (2, 'Line 2'), (3, 'Line 3'); CREATE TABLE fare_collection (collection_id INT, line_id INT, fare DECIMAL(5,2), collection_date DATE);
What is the total fare collected for each subway line in January 2022?
SELECT sl.line_name, SUM(fc.fare) as total_fare FROM subway_lines sl INNER JOIN fare_collection fc ON sl.line_id = fc.line_id WHERE fc.collection_date BETWEEN '2022-01-01' AND '2022-01-31' GROUP BY sl.line_name;
gretelai_synthetic_text_to_sql
CREATE TABLE industrial_water_usage (state VARCHAR(20), year INT, sector VARCHAR(30), usage FLOAT); INSERT INTO industrial_water_usage (state, year, sector, usage) VALUES ('New York', 2021, 'Agriculture', 12345.6), ('New York', 2021, 'Manufacturing', 23456.7), ('New York', 2021, 'Mining', 34567.8), ('New York', 2021, '...
List the top 3 water consuming industries in New York in 2021.
SELECT sector, usage FROM industrial_water_usage WHERE state = 'New York' AND year = 2021 ORDER BY usage DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE peacekeeping_operations (country VARCHAR(50), operation VARCHAR(100)); INSERT INTO peacekeeping_operations (country, operation) VALUES ('Indonesia', 'UNMIK'), ('Malaysia', 'UNAMID'), ('Philippines', 'MINUSTAH'), ('Singapore', 'UNMOGIP'), ('Thailand', 'UNFICYP');
Find the total number of peacekeeping operations conducted by ASEAN countries?
SELECT COUNT(*) FROM peacekeeping_operations WHERE country IN ('Indonesia', 'Malaysia', 'Philippines', 'Singapore', 'Thailand');
gretelai_synthetic_text_to_sql
CREATE TABLE ai_algorithms (algorithm_id INT, algorithm_name VARCHAR(255), region VARCHAR(255), usage_count INT); INSERT INTO ai_algorithms (algorithm_id, algorithm_name, region, usage_count) VALUES (1, 'Random Forest', 'France', 120), (2, 'SVM', 'Germany', 150), (3, 'Neural Network', 'UK', 200), (4, 'Decision Tree', '...
Display the top 3 AI algorithms with the highest average usage count in Europe.
SELECT algorithm_name, AVG(usage_count) as avg_usage_count FROM ai_algorithms WHERE region = 'Europe' GROUP BY algorithm_name ORDER BY avg_usage_count DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE attorneys (attorney_id INT, name TEXT); INSERT INTO attorneys (attorney_id, name) VALUES (1, 'Maria Lopez'); CREATE TABLE cases (case_id INT, attorney_id INT, outcome TEXT);
What is the success rate of cases in which attorney Maria Lopez was involved?
SELECT AVG(CASE WHEN cases.outcome = 'Success' THEN 1.0 ELSE 0.0 END) AS success_rate FROM cases INNER JOIN attorneys ON cases.attorney_id = attorneys.attorney_id WHERE attorneys.name = 'Maria Lopez';
gretelai_synthetic_text_to_sql
CREATE TABLE database_systems (id INT, name VARCHAR(255), severity VARCHAR(255)); INSERT INTO database_systems (id, name, severity) VALUES (1, 'Database1', 'critical'), (2, 'Database2', 'medium'), (3, 'Database3', 'low'), (4, 'Database4', 'medium');
How many 'critical' vulnerabilities exist in the 'database_systems' table?
SELECT COUNT(*) FROM database_systems WHERE severity = 'critical';
gretelai_synthetic_text_to_sql
CREATE TABLE clinical_trials (drug_name TEXT, phase TEXT); INSERT INTO clinical_trials (drug_name, phase) VALUES ('Drug1', 'phase 1'), ('Drug2', 'phase 2'), ('Drug3', 'phase 3'), ('Drug4', 'phase 3'), ('Drug5', 'phase 2'), ('Drug6', 'phase 1'); CREATE TABLE therapeutic_areas (drug_name TEXT, therapeutic_area TEXT); INS...
What are the names of drugs with phase 1 clinical trials in the rare diseases therapeutic area?
SELECT DISTINCT drug_name FROM clinical_trials INNER JOIN therapeutic_areas ON clinical_trials.drug_name = therapeutic_areas.drug_name WHERE phase = 'phase 1' AND therapeutic_area = 'rare diseases';
gretelai_synthetic_text_to_sql
CREATE TABLE states (id INT, name VARCHAR(255)); INSERT INTO states (id, name) VALUES (1, 'New York'); CREATE TABLE veteran_stats (id INT, state_id INT, employed INT, unemployed INT); INSERT INTO veteran_stats (id, state_id, employed, unemployed) VALUES (1, 1, 3000, 500);
List all veteran employment stats for New York state.
SELECT state_id, employed, unemployed FROM veteran_stats WHERE state_id = (SELECT id FROM states WHERE name = 'New York');
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (ArtistID int, ArtistName varchar(100), Gender varchar(50), Platform varchar(50)); CREATE TABLE Songs (SongID int, SongName varchar(100), ReleaseDate date, ArtistID int); INSERT INTO Artists VALUES (1, 'Artist E', 'Female', 'Classical Music'); INSERT INTO Artists VALUES (2, 'Artist F', 'Male', 'Cla...
How many songs have been released by female artists on the 'Classical Music' platform since 2010?
SELECT COUNT(*) as NumberOfSongs FROM Artists JOIN Songs ON Artists.ArtistID = Songs.ArtistID WHERE Gender = 'Female' AND Platform = 'Classical Music' AND ReleaseDate >= '2010-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE Factories (id INT, sector VARCHAR, lead_time INT);
What is the minimum lead time for factories in the fair labor sector?
SELECT MIN(lead_time) FROM Factories WHERE sector = 'fair labor';
gretelai_synthetic_text_to_sql
CREATE TABLE clients (client_id INT, account_balance DECIMAL(10,2), ethnicity VARCHAR(50)); INSERT INTO clients (client_id, account_balance, ethnicity) VALUES (1, 9000, 'Latinx'), (2, 7000, 'Hispanic'), (3, 6000, 'Asian'), (4, 5000, 'African American'), (5, 8000, 'Caucasian');
What is the average account balance for clients who identify as Latinx or Hispanic?
SELECT AVG(account_balance) FROM clients WHERE ethnicity IN ('Latinx', 'Hispanic');
gretelai_synthetic_text_to_sql
CREATE TABLE donations (donation_id INT, donor_id INT, organization_id INT, donation_amount FLOAT); INSERT INTO donations (donation_id, donor_id, organization_id, donation_amount) VALUES (1, 2, 101, 350.00), (2, 3, 102, 700.00), (3, 4, 103, 250.00);
Delete all records from the 'donations' table.
DELETE FROM donations;
gretelai_synthetic_text_to_sql
CREATE TABLE investments (client_id INT, investment_value DECIMAL(10,2), investment_type VARCHAR(50), investment_date DATE, country VARCHAR(50)); INSERT INTO investments (client_id, investment_value, investment_type, investment_date, country) VALUES (1, 15000.00, 'Sustainable Funds', '2022-02-10', 'Germany'), (2, 20000...
What is the total value of investments in sustainable funds by clients in the European Union in H1 2022?
SELECT SUM(investment_value) as total_investment_value FROM investments WHERE investment_type = 'Sustainable Funds' AND country IN ('Germany', 'France', 'Italy') AND investment_date BETWEEN '2022-01-01' AND '2022-06-30';
gretelai_synthetic_text_to_sql
CREATE TABLE threat_weekly (id INT, record_date DATE, source VARCHAR(10)); INSERT INTO threat_weekly (id, record_date, source) VALUES (1, '2022-01-03', 'TI1'), (2, '2022-01-03', 'TI2'), (3, '2022-01-10', 'TI3'), (4, '2022-01-17', 'TI4'), (5, '2022-01-24', 'TI1'), (6, '2022-01-31', 'TI2');
Display the number of threat intelligence records and their source by week
SELECT EXTRACT(WEEK FROM record_date) as week, source, COUNT(*) as records FROM threat_weekly GROUP BY week, source;
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_subscribers (subscriber_id INT, plan_type VARCHAR(10), region VARCHAR(20)); INSERT INTO mobile_subscribers (subscriber_id, plan_type, region) VALUES (1, 'postpaid', 'Urban'), (2, 'postpaid', 'Rural'), (3, 'prepaid', 'Rural'), (4, 'postpaid', 'Urban'), (5, 'prepaid', 'Urban');
How many mobile subscribers are there in each plan type?
SELECT plan_type, COUNT(*) FROM mobile_subscribers GROUP BY plan_type;
gretelai_synthetic_text_to_sql
CREATE TABLE BudgetAllocations (ID INT, Category TEXT, Quarter INT, Amount FLOAT); INSERT INTO BudgetAllocations (ID, Category, Quarter, Amount) VALUES (1, 'Disability Accommodations', 1, 20000.00), (2, 'Policy Advocacy', 2, 15000.00), (3, 'Disability Accommodations', 2, 5000.00), (4, 'Assistive Technology', 2, 8000.00...
Calculate the total budget allocated to 'Disability Accommodations' and 'Assistive Technology' combined in the second quarter.
SELECT SUM(Amount) FROM BudgetAllocations WHERE Category IN ('Disability Accommodations', 'Assistive Technology') AND Quarter = 2;
gretelai_synthetic_text_to_sql
CREATE SCHEMA Compliance;CREATE TABLE PollutionViolations (id INT, country TEXT, region TEXT, year INT, violations INT); INSERT INTO PollutionViolations (id, country, region, year, violations) VALUES (1, 'Argentina', 'Southern Ocean', 2019, 3), (2, 'Chile', 'Southern Ocean', 2020, 5), (3, 'South Africa', 'Southern Ocea...
Identify the number of pollution violations in the Southern Ocean region in the 'Compliance' schema.
SELECT region, SUM(violations) AS total_violations FROM Compliance.PollutionViolations WHERE region = 'Southern Ocean' GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE mining_operations (operation_id INT, operation_name VARCHAR(50), employee_id INT, first_name VARCHAR(50), last_name VARCHAR(50), position VARCHAR(50), gender VARCHAR(10)); INSERT INTO mining_operations (operation_id, operation_name, employee_id, first_name, last_name, position, gender) VALUES (1, 'Operatio...
Which mining operations have more than 50% of their workforce female?
SELECT operation_name FROM (SELECT operation_name, (COUNT(*) FILTER (WHERE gender = 'Female'))/COUNT(*) AS female_ratio FROM mining_operations GROUP BY operation_name) AS subquery WHERE female_ratio > 0.5;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (id INT, name VARCHAR(50), position VARCHAR(50), left_company BOOLEAN);
Update the position of an employee in the Employees table
UPDATE Employees SET position = 'Senior Software Engineer' WHERE name = 'Juan Garcia';
gretelai_synthetic_text_to_sql
CREATE TABLE ports (id INT, name TEXT, country TEXT); CREATE TABLE cargo_movements (id INT, port_id INT, cargo_type TEXT, weight INT, date DATE); INSERT INTO ports (id, name, country) VALUES (1, 'Port of Singapore', 'Singapore'), (2, 'Port of Shanghai', 'China'), (3, 'Port of Busan', 'South Korea'); INSERT INTO cargo_m...
What is the total cargo weight handled by each port during the second half of 2022?
SELECT p.name, SUM(cm.weight) FROM ports p JOIN cargo_movements cm ON p.id = cm.port_id WHERE MONTH(cm.date) > 6 GROUP BY p.name;
gretelai_synthetic_text_to_sql
CREATE TABLE geothermal_plants (name TEXT, capacity INTEGER, country TEXT); INSERT INTO geothermal_plants (name, capacity, country) VALUES ('Geothermal Plant 1', 600, 'Indonesia'), ('Geothermal Plant 2', 700, 'Indonesia');
What are the names and capacities of all geothermal power plants in Indonesia?
SELECT name, capacity FROM geothermal_plants WHERE country = 'Indonesia'
gretelai_synthetic_text_to_sql
CREATE TABLE Spacecraft (SpacecraftID INT, Name VARCHAR(50), Manufacturer VARCHAR(50), LaunchDate DATE, Mass FLOAT); INSERT INTO Spacecraft VALUES (1, 'Juno', 'NASA', '2011-08-05', 3625), (2, 'Curiosity', 'NASA', '2012-11-26', 1982), (3, 'Mangalyaan', 'ISRO', '2013-11-05', 1350);
What is the total mass of all spacecraft that have been launched since 2010?
SELECT SUM(Mass) FROM Spacecraft WHERE YEAR(LaunchDate) >= 2010;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (Employee_ID INT, First_Name VARCHAR(50), Last_Name VARCHAR(50), Department VARCHAR(50), Salary DECIMAL(10,2)); INSERT INTO Employees (Employee_ID, First_Name, Last_Name, Department, Salary) VALUES (1, 'Sana', 'Mir', 'Finance', 80000.00); INSERT INTO Employees (Employee_ID, First_Name, Last_Name,...
What is the average salary of employees in the 'Finance' department?
SELECT AVG(Salary) FROM Employees WHERE Department = 'Finance';
gretelai_synthetic_text_to_sql
CREATE TABLE EthicalAI (principle_id INT, principle_name VARCHAR(50)); INSERT INTO EthicalAI (principle_id, principle_name) VALUES (1, 'Fairness'), (2, 'Accountability'), (3, 'Transparency');
Which ethical AI principles are missing from the provided list?
SELECT 'Data Minimization' AS principle_name UNION ALL SELECT 'Explainability' UNION ALL SELECT 'Human Oversight';
gretelai_synthetic_text_to_sql
CREATE TABLE power_installations (id INT, location VARCHAR(50), year INT, power_type VARCHAR(50), size INT); INSERT INTO power_installations (id, location, year, power_type, size) VALUES (1, 'California', 2020, 'Solar', 1500); INSERT INTO power_installations (id, location, year, power_type, size) VALUES (2, 'California...
How many solar power installations were completed in California in 2020 and 2021?
SELECT SUM(size) FROM power_installations WHERE location = 'California' AND power_type = 'Solar' AND year IN (2020, 2021);
gretelai_synthetic_text_to_sql
CREATE TABLE CulturalEvents (id INT, year INT, visitors INT); INSERT INTO CulturalEvents (id, year, visitors) VALUES (1, 2017, 500), (2, 2018, 700), (3, 2019, 900), (4, 2020, 1100);
What is the average number of visitors to the events organized by the cultural center in the year 2020?
SELECT AVG(visitors) FROM CulturalEvents WHERE year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE funding_sources (id INT, program_type VARCHAR(255), funding_year INT, amount DECIMAL(10, 2));
What is the total funding by program type in 2022?
SELECT program_type, SUM(amount) OVER (PARTITION BY program_type) AS total_funding_by_program_type FROM funding_sources WHERE funding_year = 2022 ORDER BY program_type;
gretelai_synthetic_text_to_sql
CREATE TABLE businesses (id INT, business_name VARCHAR(255), business_owner_ethnicity VARCHAR(255), business_location VARCHAR(255)); CREATE TABLE incidents (id INT, incident_type VARCHAR(255), incident_date DATE, business_id INT); INSERT INTO businesses (id, business_name, business_owner_ethnicity, business_location) V...
How many cybersecurity incidents were reported by Asian-owned businesses in the past year?
SELECT COUNT(*) FROM incidents i JOIN businesses b ON i.business_id = b.id WHERE b.business_owner_ethnicity = 'Asian' AND i.incident_date >= DATEADD(year, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE green_buildings (id INT, name VARCHAR(50), construction_year INT, energy_consumption INT); INSERT INTO green_buildings (id, name, construction_year, energy_consumption) VALUES (1, 'GreenHub', 2015, 1200), (2, 'EcoTower', 2012, 1500), (3, 'SolarVista', 2008, 1800), (4, 'WindHaven', 2018, 1000);
What is the average energy consumption of all buildings constructed before 2010?
SELECT AVG(energy_consumption) FROM green_buildings WHERE construction_year < 2010;
gretelai_synthetic_text_to_sql
CREATE TABLE bay_of_bengal_farms (id INT, name TEXT, dissolved_oxygen FLOAT);
What is the maximum dissolved oxygen level (in mg/L) recorded in fish farms in the Bay of Bengal?
SELECT MAX(dissolved_oxygen) FROM bay_of_bengal_farms;
gretelai_synthetic_text_to_sql
CREATE TABLE sales_data(sale_id INT, garment_id INT, sale_date DATE, sustainable BOOLEAN, quantity INT, price FLOAT); INSERT INTO sales_data(sale_id, garment_id, sale_date, sustainable, quantity, price) VALUES (1, 1, '2022-07-01', true, 5, 25), (2, 3, '2022-08-15', true, 10, 40), (3, 2, '2022-09-05', false, 7, 35);
Which sustainable garments have the highest sales in the last 6 months?
SELECT garment_id, SUM(quantity * price) as total_sales FROM sales_data WHERE sale_date >= DATEADD(month, -6, CURRENT_DATE) AND sustainable = true GROUP BY garment_id ORDER BY total_sales DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_features (name TEXT, depth FLOAT); INSERT INTO ocean_features (name, depth) VALUES ('Mariana Trench', 10994.0), ('Puerto Rico Trench', 8605.0), ('Siberian Traps', 3000.0);
What is the average depth of all ocean features?
SELECT AVG(depth) FROM ocean_features;
gretelai_synthetic_text_to_sql
CREATE TABLE menu_item (item_id INT, item_name VARCHAR(50), category VARCHAR(20), price DECIMAL(5, 2));
Delete records in the menu_item table that have a price greater than 20
DELETE FROM menu_item WHERE price > 20;
gretelai_synthetic_text_to_sql
CREATE TABLE players (id INT, made_purchase BOOLEAN);
What is the percentage of players who have made a purchase in the last month?
SELECT 100.0 * COUNT(*) / (SELECT COUNT(*) FROM players) AS percentage FROM players WHERE made_purchase = TRUE AND purchase_date >= CURDATE() - INTERVAL 30 DAY;
gretelai_synthetic_text_to_sql
CREATE TABLE mines (id INT, name VARCHAR(50), location VARCHAR(50), size INT, operational_status VARCHAR(20)); INSERT INTO mines VALUES (1, 'Texas Mine', 'Texas', 500, 'operational'); INSERT INTO mines VALUES (2, 'Oklahoma Mine', 'Oklahoma', 300, 'operational'); INSERT INTO mines VALUES (3, 'Closed Mine', 'Texas', 400,...
List the number of mines in Texas and Oklahoma, grouped by state.
SELECT location, COUNT(*) as mine_count FROM mines WHERE location IN ('Texas', 'Oklahoma') GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE faculty (id INT, name VARCHAR(50), gender VARCHAR(50), publication_count INT); INSERT INTO faculty (id, name, gender, publication_count) VALUES (1, 'Alice Johnson', 'Female', 12), (2, 'Bob Brown', 'Male', 8), (3, 'Charlie Davis', 'Non-binary', 5);
Identify faculty members who are female and have published more than 10 papers.
SELECT * FROM faculty WHERE gender = 'Female' AND publication_count > 10;
gretelai_synthetic_text_to_sql
CREATE TABLE animal_population (species VARCHAR(50), endangered_status VARCHAR(50), animal_count INT);
Show the number of animals in the 'animal_population' table that belong to species that are not endangered.
SELECT species, animal_count FROM animal_population WHERE species NOT IN (SELECT species FROM animal_population WHERE endangered_status = 'endangered');
gretelai_synthetic_text_to_sql
CREATE TABLE regulations (country VARCHAR(2), regulation_name VARCHAR(100));
Insert a new record into the "regulations" table with "country" as "India", "regulation_name" as "Information Technology (Intermediaries Guidelines) Rules, 2011"
INSERT INTO regulations (country, regulation_name) VALUES ('IN', 'Information Technology (Intermediaries Guidelines) Rules, 2011');
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (ArtistID int, Name varchar(50), Nationality varchar(50)); INSERT INTO Artists (ArtistID, Name, Nationality) VALUES (1, 'Pablo Picasso', 'Spanish'), (2, 'Vincent van Gogh', 'Dutch'); CREATE TABLE Exhibitions (ExhibitionID int, Title varchar(50), Artists varchar(50), Museum varchar(50)); INSERT INTO...
Which artists have their works exhibited in the 'Modern Art Museum'?
SELECT Artists.Name FROM Artists INNER JOIN Exhibitions ON Artists.ArtistID = Cast(Split_Part(Exhibitions.Artists, ',', 1) AS int) WHERE Exhibitions.Museum = 'Modern Art Museum';
gretelai_synthetic_text_to_sql
CREATE TABLE crop_temperature (crop_type VARCHAR(20), record_date DATE, temperature INT); INSERT INTO crop_temperature (crop_type, record_date, temperature) VALUES ('Corn', '2022-05-01', 25), ('Soybean', '2022-05-01', 22), ('Wheat', '2022-05-01', 18); INSERT INTO crop_temperature (crop_type, record_date, temperature) V...
What is the average temperature recorded for each crop type in the past month?
SELECT crop_type, AVG(temperature) as avg_temperature FROM crop_temperature WHERE record_date >= DATEADD(month, -1, GETDATE()) GROUP BY crop_type;
gretelai_synthetic_text_to_sql
CREATE TABLE waste_generation_bangkok (year INT, total_waste INT); INSERT INTO waste_generation_bangkok (year, total_waste) VALUES (2018, 150000), (2019, 170000), (2020, 185000);
What was the waste generation in Bangkok in 2019?
SELECT total_waste FROM waste_generation_bangkok WHERE year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE mental_health_scores (score_id INT, district_id INT, grade_level INT, mental_health_score INT);
What is the average mental health score for students in each grade level, grouped by school district?
SELECT s.grade_level, sd.district_name, AVG(mhs.mental_health_score) FROM mental_health_scores mhs INNER JOIN students s ON mhs.student_id = s.student_id INNER JOIN school_districts sd ON s.district_id = sd.district_id GROUP BY s.grade_level, sd.district_name;
gretelai_synthetic_text_to_sql
CREATE TABLE brazil_energy_efficiency (state VARCHAR(50), building_type VARCHAR(50), energy_efficiency_rating FLOAT); INSERT INTO brazil_energy_efficiency (state, building_type, energy_efficiency_rating) VALUES ('São Paulo', 'Residential', 80.5), ('Rio de Janeiro', 'Residential', 75.3), ('Minas Gerais', 'Residential', ...
What is the average energy efficiency rating for residential buildings in Brazil?
SELECT AVG(energy_efficiency_rating) FROM brazil_energy_efficiency WHERE building_type = 'Residential';
gretelai_synthetic_text_to_sql
CREATE TABLE agri_patents (id INT, patent_number INT, title TEXT, applicant_country TEXT, grant_year INT); INSERT INTO agri_patents (id, patent_number, title, applicant_country, grant_year) VALUES (1, 12345, 'Smart Irrigation System', 'Kenya', 2017), (2, 67890, 'Vertical Farming Design', 'Nigeria', 2018), (3, 11121, 'O...
How many agricultural innovation patents were granted to applicants from African countries between 2017 and 2021?
SELECT COUNT(*) FROM agri_patents WHERE applicant_country LIKE 'Africa%' AND grant_year BETWEEN 2017 AND 2021;
gretelai_synthetic_text_to_sql