context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE explainable_ai (model_name TEXT, dataset TEXT, fairness_score INTEGER); INSERT INTO explainable_ai (model_name, dataset, fairness_score) VALUES ('model1', 'explainable_ai', 85), ('model2', 'explainable_ai', 92), ('model3', 'explainable_ai', 88);
What is the minimum fairness score for models trained on the 'explainable_ai' dataset?
SELECT MIN(fairness_score) FROM explainable_ai WHERE dataset = 'explainable_ai';
gretelai_synthetic_text_to_sql
CREATE TABLE menus (menu_id INT, restaurant_id INT, meal_time VARCHAR(255), item VARCHAR(255), price DECIMAL(5,2));
What is the average price of 'Pasta' dishes in the 'Dinner Menu' of Restaurant Z?
SELECT AVG(price) as average_price FROM menus WHERE restaurant_id = (SELECT restaurant_id FROM restaurants WHERE name = 'Restaurant Z') AND meal_time = 'Dinner' AND item LIKE '%Pasta%';
gretelai_synthetic_text_to_sql
CREATE TABLE Countries (Country VARCHAR(255), AvgScore FLOAT); INSERT INTO Countries (Country, AvgScore) VALUES ('United States', 85.6), ('Japan', 82.3), ('Brazil', 78.9), ('Canada', 75.2), ('Germany', 74.5);
Which countries have the highest average player scores in the game "Galactic Guardians"?
SELECT Country FROM Countries ORDER BY AvgScore DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE landfill_capacity (country VARCHAR(50), capacity INT);
Insert records for landfill_capacity table, with data for 'Argentina', 'China', 'Indonesia' and capacity values 9000, 16000, 21000 respectively
INSERT INTO landfill_capacity (country, capacity) VALUES ('Argentina', 9000), ('China', 16000), ('Indonesia', 21000);
gretelai_synthetic_text_to_sql
CREATE SCHEMA IF NOT EXISTS environment; CREATE TABLE environment.projects (id INT, name VARCHAR(100), co2_emissions FLOAT); INSERT INTO environment.projects (id, name, co2_emissions) VALUES (1, 'Solar Farm', 50), (2, 'Wind Turbine Park', 25), (3, 'Hydroelectric Plant', 10);
Calculate the average CO2 emissions for projects in the 'environment' schema
SELECT AVG(co2_emissions) FROM environment.projects;
gretelai_synthetic_text_to_sql
CREATE TABLE southern_hemisphere (region TEXT, species_number INTEGER); INSERT INTO southern_hemisphere (region, species_number) VALUES ('Southern Atlantic', 5000), ('Southern Pacific', 8000), ('Southern Indian', 6000);
What is the total number of marine species in the Southern Hemisphere?
SELECT SUM(species_number) FROM southern_hemisphere;
gretelai_synthetic_text_to_sql
CREATE TABLE tourism (id INT PRIMARY KEY, country VARCHAR(50), destination VARCHAR(50), age INT, certified_sustainable BOOLEAN); INSERT INTO tourism (id, country, destination, age, certified_sustainable) VALUES (1, 'Mexico', 'Germany', 22, TRUE); INSERT INTO tourism (id, country, destination, age, certified_sustainable) VALUES (2, 'Mexico', 'Germany', 28, FALSE);
What is the minimum age of tourists visiting Germany from Mexico?
SELECT MIN(age) FROM tourism WHERE country = 'Mexico' AND destination = 'Germany';
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists arts_culture;CREATE TABLE if not exists arts_culture.donors (donor_id INT PRIMARY KEY, name VARCHAR(255), type VARCHAR(255), donation DECIMAL(10,2));INSERT INTO arts_culture.donors (donor_id, name, type, donation) VALUES (1, 'John Doe', 'Individual', 50.00), (2, 'Jane Smith', 'Individual', 100.00), (3, 'Google Inc.', 'Corporation', 5000.00);
Update the donation amount of 'Google Inc.' to $6000 in the 'donors' table.
UPDATE arts_culture.donors SET donation = 6000 WHERE name = 'Google Inc.';
gretelai_synthetic_text_to_sql
CREATE TABLE tourism_activities (id INT, country VARCHAR(50), activity_type VARCHAR(50), num_tourists INT); INSERT INTO tourism_activities (id, country, activity_type, num_tourists) VALUES (1, 'Japan', 'Eco-tourism', 30000); CREATE TABLE international_visitors (id INT, country VARCHAR(50), year INT, num_visitors INT); INSERT INTO international_visitors (id, country, year, num_visitors) VALUES (1, 'Japan', 2020, 8000000);
What is the total number of tourists who visited Japan in 2020 and engaged in eco-tourism activities?
SELECT SUM(tourism_activities.num_tourists) FROM tourism_activities JOIN international_visitors ON tourism_activities.country = international_visitors.country WHERE tourism_activities.activity_type = 'Eco-tourism' AND international_visitors.year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE Regions (id INT, name VARCHAR(255)); INSERT INTO Regions (id, name) VALUES (1, 'North'), (2, 'South'), (3, 'East'), (4, 'West'); CREATE TABLE CarbonSeq (id INT, region_id INT, year INT, rate FLOAT); INSERT INTO CarbonSeq (id, region_id, year, rate) VALUES (1, 1, 2004, 2.5), (2, 1, 2005, 3.0), (3, 2, 2004, 4.0), (4, 2, 2005, 4.5), (5, 3, 2004, 3.5), (6, 3, 2005, 4.0), (7, 4, 2004, 4.5), (8, 4, 2005, 5.0);
Calculate the total carbon sequestration per region in 2004.
SELECT r.name, SUM(cs.rate) AS total_carbon_sequestration FROM Regions r JOIN CarbonSeq cs ON r.id = cs.region_id WHERE cs.year = 2004 GROUP BY r.id;
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tour_engagement (hotel_id INT, hotel_name TEXT, country TEXT, engagement_time FLOAT); INSERT INTO virtual_tour_engagement (hotel_id, hotel_name, country, engagement_time) VALUES (1, 'Hotel K', 'Japan', 15.5), (2, 'Hotel L', 'Australia', 12.3), (3, 'Hotel M', 'China', 18.7), (4, 'Hotel N', 'India', 10.2), (5, 'Hotel O', 'South Korea', 14.8); CREATE VIEW apac_hotels AS SELECT * FROM virtual_tour_engagement WHERE country IN ('Japan', 'Australia', 'China', 'India', 'South Korea');
What is the average engagement time with virtual tours for hotels in the APAC region?
SELECT AVG(engagement_time) FROM apac_hotels;
gretelai_synthetic_text_to_sql
CREATE TABLE schools (school_id INT, school_name VARCHAR(255)); CREATE TABLE teachers (teacher_id INT, school_id INT); CREATE TABLE courses (course_id INT, course_name VARCHAR(255), completion_date DATE); CREATE TABLE teacher_courses (teacher_id INT, course_id INT);
How many teachers have completed a professional development course in each school?
SELECT s.school_name, COUNT(tc.teacher_id) FROM schools s JOIN teachers t ON s.school_id = t.school_id JOIN teacher_courses tc ON t.teacher_id = tc.teacher_id JOIN courses c ON tc.course_id = c.course_id WHERE c.completion_date >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR) GROUP BY s.school_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Schools (year INT, region VARCHAR(255), count INT); INSERT INTO Schools (year, region, count) VALUES (2022, 'North', 100), (2022, 'North', 105), (2022, 'North', 110), (2022, 'North', 115);
What was the minimum number of public schools in the North region in 2022?
SELECT MIN(count) FROM Schools WHERE year = 2022 AND region = 'North';
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_subscribers (subscriber_id INT, last_data_usage_date DATE, data_usage FLOAT, plan_type VARCHAR(10), region VARCHAR(20)); INSERT INTO mobile_subscribers (subscriber_id, last_data_usage_date, data_usage, plan_type, region) VALUES (1, '2022-03-20', 3.5, 'postpaid', 'Urban'), (2, '2022-04-05', 6.2, 'postpaid', 'Rural'), (3, '2022-04-10', 0, 'prepaid', 'Rural');
List all mobile subscribers who have not used any data in the past month.
SELECT subscriber_id FROM mobile_subscribers WHERE last_data_usage_date < DATEADD(month, -1, CURRENT_DATE);
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, Department VARCHAR(20), Gender VARCHAR(20), IdentifiesAsLGBTQ BOOLEAN); INSERT INTO Employees (EmployeeID, Department, Gender, IdentifiesAsLGBTQ) VALUES (1, 'Sales', 'Male', true), (2, 'IT', 'Female', false), (3, 'Sales', 'Non-binary', true);
How many employees in the Sales department identify as LGBTQ+?
SELECT COUNT(*) FROM Employees WHERE Department = 'Sales' AND IdentifiesAsLGBTQ = true;
gretelai_synthetic_text_to_sql
CREATE TABLE menus (menu_id INT, dish_name VARCHAR(50), dish_type VARCHAR(50), price DECIMAL(5,2), sales INT);
What is the total revenue for 'Italian' and 'Chinese' dishes?
SELECT SUM(price * sales) FROM menus WHERE dish_type IN ('Italian', 'Chinese');
gretelai_synthetic_text_to_sql
CREATE TABLE Electric_Buses (id INT, route_number INT, manufacturer VARCHAR(50), year INT, daily_passengers INT, daily_miles FLOAT); INSERT INTO Electric_Buses (id, route_number, manufacturer, year, daily_passengers, daily_miles) VALUES (1, 201, 'Proterra', 2019, 1200, 110.0), (2, 202, 'BYD', 2022, 1300, 100.0);
Which electric buses have a daily passenger count greater than 1200 or were manufactured in 2022?
SELECT id, route_number, manufacturer, year, daily_passengers, daily_miles FROM Electric_Buses WHERE daily_passengers > 1200 OR year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE oil_production (well_id INT, year INT, oil_volume FLOAT);
List the unique well identifiers from the 'oil_production' table for the year 2021 where the oil production is less than 5000
SELECT DISTINCT well_id FROM oil_production WHERE year = 2021 AND oil_volume < 5000;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas (name TEXT, location TEXT, avg_depth FLOAT); CREATE TABLE ocean_regions (name TEXT, area FLOAT);
What is the average depth of all marine protected areas in the Pacific Ocean?
SELECT AVG(avg_depth) FROM marine_protected_areas WHERE location = (SELECT name FROM ocean_regions WHERE area = 'Pacific Ocean');
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (DonationID INT, DonorID INT, Category TEXT, Amount DECIMAL); INSERT INTO Donations (DonationID, DonorID, Category, Amount) VALUES (1, 1, 'Arts', 50), (2, 1, 'Education', 100), (3, 2, 'Arts', 75);
What is the average donation amount in the 'Arts' category?
SELECT AVG(Amount) FROM Donations WHERE Category = 'Arts';
gretelai_synthetic_text_to_sql
CREATE TABLE landfill_capacity (country VARCHAR(255), capacity FLOAT); INSERT INTO landfill_capacity (country, capacity) VALUES ('United States', 13.5), ('Canada', 4.1), ('Mexico', 1.5);
What is the total landfill capacity in North America?
SELECT SUM(capacity) FROM landfill_capacity WHERE country IN ('United States', 'Canada', 'Mexico');
gretelai_synthetic_text_to_sql
CREATE TABLE Infrastructure (id INT, category VARCHAR(20), completed DATE); INSERT INTO Infrastructure (id, category, completed) VALUES (1, 'Transportation', '2020-01-01'), (2, 'WaterSupply', '2019-01-01'), (3, 'Bridges', '2022-03-01'), (4, 'Roads', '2021-05-01');
What is the latest completion date for projects in 'Bridges' and 'Roads' categories?
SELECT category, MAX(completed) FROM Infrastructure WHERE category IN ('Bridges', 'Roads') GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE toronto_buildings (certification VARCHAR(20), sqft INT); INSERT INTO toronto_buildings (certification, sqft) VALUES ('LEED', 120000); INSERT INTO toronto_buildings (certification, sqft) VALUES ('GreenGlobes', 100000);
What is the maximum square footage of a green-certified building in Toronto?
SELECT MAX(sqft) FROM toronto_buildings WHERE certification = 'LEED';
gretelai_synthetic_text_to_sql
CREATE TABLE shipments (shipment_id INT, customer_id INT, shipped_date TIMESTAMP, shipped_time TIME, delivered_date TIMESTAMP, delivered_time TIME, status TEXT, delay DECIMAL(3,2));
What is the average delivery time for shipments to Texas from the 'shipments' table?
SELECT AVG(TIMESTAMPDIFF(MINUTE, shipped_date, delivered_date)) as avg_delivery_time FROM shipments WHERE destination_state = 'Texas';
gretelai_synthetic_text_to_sql
CREATE TABLE MilitaryBases (BaseID INT, BaseCountry VARCHAR(30)); INSERT INTO MilitaryBases (BaseID, BaseCountry) VALUES (1, 'USA'), (2, 'Germany'), (3, 'France'), (4, 'Brazil'), (5, 'Canada');
What is the number of military bases in each country, sorted by the total number of bases in descending order?
SELECT BaseCountry, COUNT(*) as Total FROM MilitaryBases GROUP BY BaseCountry ORDER BY Total DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE donors (id INT, name TEXT, country TEXT, donation_amount DECIMAL); INSERT INTO donors (id, name, country, donation_amount) VALUES (1, 'John Doe', 'USA', 50.00), (2, 'Jane Smith', 'Canada', 100.00), (3, 'Maria Garcia', 'USA', 25.00);
What is the average amount of donations made by individual donors from the USA?
SELECT AVG(donation_amount) FROM donors WHERE country = 'USA' GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE state_recycling_rates (state VARCHAR(20), year INT, recycling_rate FLOAT); INSERT INTO state_recycling_rates (state, year, recycling_rate) VALUES ('Texas', 2020, 0.25);
What is the recycling rate for the state of Texas for the year 2020?'
SELECT recycling_rate FROM state_recycling_rates WHERE state = 'Texas' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE arctic_stations (id INT, name VARCHAR(50), location VARCHAR(50), year INT); INSERT INTO arctic_stations (id, name, location, year) VALUES (1, 'Station A', 'Greenland', 2000), (2, 'Station B', 'Svalbard', 2010);
Insert a new record for a research station in the arctic_stations table.
INSERT INTO arctic_stations (id, name, location, year) VALUES (3, 'Station C', 'Nunavut', 2015);
gretelai_synthetic_text_to_sql
CREATE TABLE digital_assets (asset_id INT, name VARCHAR(50), exchange VARCHAR(50), quantity DECIMAL(10,2)); INSERT INTO digital_assets (asset_id, name, exchange, quantity) VALUES (1, 'BTC', 'Binance', 1000), (2, 'ETH', 'Binance', 2000), (3, 'BTC', 'Coinbase', 1500), (4, 'ETH', 'Coinbase', 2500);
What is the total value of digital assets held by each exchange on the blockchain?
SELECT exchange, SUM(quantity) as total_value FROM digital_assets GROUP BY exchange;
gretelai_synthetic_text_to_sql
CREATE TABLE ThreatActors (ActorID int, ActorName varchar(100), LastAttackDate date); INSERT INTO ThreatActors (ActorID, ActorName, LastAttackDate) VALUES (1, 'APT28', '2022-01-15'), (2, 'APT33', '2022-02-03'), (3, 'Lazarus', '2022-03-01'), (4, 'CozyBear', '2022-03-17'), (5, 'FancyBear', '2022-04-09');
Identify the top 5 threat actors by the number of attacks they have launched in the last month.
SELECT ActorName, COUNT(*) as AttackCount FROM ThreatActors WHERE LastAttackDate >= DATEADD(month, -1, GETDATE()) GROUP BY ActorName ORDER BY AttackCount DESC FETCH NEXT 5 ROWS ONLY;
gretelai_synthetic_text_to_sql
CREATE TABLE infectious_disease_tracking (id INT, location TEXT, cases_per_month INT, month TEXT); INSERT INTO infectious_disease_tracking (id, location, cases_per_month, month) VALUES (1, 'Rural A', 10, 'January'), (2, 'Rural B', 15, 'February'), (3, 'Rural A', 20, 'March');
What is the maximum number of infectious disease cases reported in a month in rural areas?
SELECT MAX(cases_per_month) FROM infectious_disease_tracking WHERE location = 'rural';
gretelai_synthetic_text_to_sql
CREATE TABLE Infrastructure_Projects (Project_ID INT, Project_Name VARCHAR(50), Project_Type VARCHAR(50), Cost FLOAT, Start_Date DATE); INSERT INTO Infrastructure_Projects (Project_ID, Project_Name, Project_Type, Cost, Start_Date) VALUES (1, 'Seawall', 'Resilience', 5000000.00, '2018-01-01'), (2, 'Floodgate', 'Resilience', 3000000.00, '2019-01-01'), (3, 'Bridge_Replacement', 'Transportation', 8000000.00, '2018-07-01');
What is the total cost of all projects in the infrastructure database that started before 2019?
SELECT SUM(Cost) FROM Infrastructure_Projects WHERE Start_Date < '2019-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE disasters (disaster_id INT, disaster_name TEXT, disaster_type TEXT, response_time INT, year INT, region TEXT); INSERT INTO disasters (disaster_id, disaster_name, disaster_type, response_time, year, region) VALUES (1, 'Floods', 'natural disaster', 48, 2019, 'Europe');
What is the average response time for disaster relief in Europe in 2019?
SELECT AVG(response_time) as avg_response_time FROM disasters WHERE disaster_type = 'natural disaster' AND year = 2019 AND region = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE players (id INT, name VARCHAR(50)); CREATE TABLE games (id INT, player_id INT, kills INT, deaths INT, assists INT); INSERT INTO players VALUES (1, 'Aarav Singh'); INSERT INTO players VALUES (2, 'Bella Rodriguez'); INSERT INTO players VALUES (3, 'Chloe Lee'); INSERT INTO games VALUES (1, 1, 12, 6, 8); INSERT INTO games VALUES (2, 1, 18, 4, 12); INSERT INTO games VALUES (3, 2, 7, 3, 2); INSERT INTO games VALUES (4, 2, 10, 5, 6); INSERT INTO games VALUES (5, 3, 5, 2, 1); INSERT INTO games VALUES (6, 3, 8, 4, 2); INSERT INTO games VALUES (7, 1, 20, 10, 5);
Which players have participated in more than 15 games in the 'games' table?
SELECT players.name FROM players INNER JOIN games ON players.id = games.player_id GROUP BY players.name HAVING COUNT(*) > 15;
gretelai_synthetic_text_to_sql
CREATE TABLE employees (id INT, name VARCHAR(50), salary DECIMAL(10, 2)); INSERT INTO employees (id, name, salary) VALUES (1, 'John Doe', 60000.00), (2, 'Jane Smith', 45000.00), (3, 'Alice Johnson', 52000.00);
Get the names and salaries of all employees earning more than $50,000
SELECT name, salary FROM employees WHERE salary > 50000.00;
gretelai_synthetic_text_to_sql
CREATE TABLE Attractions_Africa (id INT, name VARCHAR(50), continent VARCHAR(50), rating DECIMAL(3,1), reviews INT); INSERT INTO Attractions_Africa (id, name, continent, rating, reviews) VALUES (1, 'Pyramids of Giza', 'Africa', 4.8, 50000), (2, 'Victoria Falls', 'Africa', 4.6, 35000), (3, 'Mount Kilimanjaro', 'Africa', 4.9, 20000), (4, 'Masai Mara National Reserve', 'Africa', 4.5, 40000), (5, 'Serengeti National Park', 'Africa', 4.7, 45000);
What are the names and ratings of the top 5 most popular tourist attractions in Africa?
SELECT name, rating FROM Attractions_Africa ORDER BY rating DESC, reviews DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE Factory_Products(id INT, factory_id INT, product_id INT, is_fair_trade_certified BOOLEAN); INSERT INTO Factory_Products(id, factory_id, product_id, is_fair_trade_certified) VALUES (1, 1, 1, true), (2, 1, 2, true), (3, 2, 3, false); CREATE TABLE Factories(id INT, name TEXT); INSERT INTO Factories(id, name) VALUES (1, 'Factory A'), (2, 'Factory B');
What is the name of the factory with the highest number of fair trade certified products?
SELECT Factories.name FROM Factories INNER JOIN (SELECT factory_id, COUNT(*) as product_count FROM Factory_Products WHERE is_fair_trade_certified = true GROUP BY factory_id) AS Subquery ON Factories.id = Subquery.factory_id ORDER BY Subquery.product_count DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE cargo (id INT, vessel_id INT, cargo TEXT, delivery_date DATE);
Delete records from the "cargo" table where the cargo is "chemicals" and the delivery_date is before 2020-01-01
DELETE FROM cargo WHERE cargo = 'chemicals' AND delivery_date < '2020-01-01';
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists ai_projects; CREATE TABLE if not exists ai_projects.projects (id INT PRIMARY KEY, project_name VARCHAR(255), location VARCHAR(255), open_source BOOLEAN); INSERT INTO ai_projects.projects (id, project_name, location, open_source) VALUES (1, 'AI Project 1', 'USA', true), (2, 'AI Project 2', 'USA', false), (3, 'AI Project 3', 'Canada', true), (4, 'AI Project 4', 'Canada', false), (5, 'AI Project 5', 'EU', true), (6, 'AI Project 6', 'EU', true);
What is the total number of AI projects in the US, Canada, and the EU, and how many of them are open source?
SELECT SUM(open_source) as total_open_source, COUNT(*) as total_projects FROM ai_projects.projects WHERE location IN ('USA', 'Canada', 'EU');
gretelai_synthetic_text_to_sql
CREATE TABLE well_locations (well_name TEXT, region TEXT); INSERT INTO well_locations (well_name, region) VALUES ('Well A', 'north'), ('Well B', 'south'), ('Well C', 'north');
Which wells are located in the 'south' region?
SELECT well_name FROM well_locations WHERE region = 'south';
gretelai_synthetic_text_to_sql
CREATE TABLE esports_event (event_id INT, event_name VARCHAR(50), game_title VARCHAR(50), prize_pool INT, region VARCHAR(20)); INSERT INTO esports_event (event_id, event_name, game_title, prize_pool, region) VALUES (1, 'Worlds', 'League of Legends', 2500000, 'Asia'); INSERT INTO esports_event (event_id, event_name, game_title, prize_pool, region) VALUES (2, 'The International', 'Dota 2', 40000000, 'Europe'); INSERT INTO esports_event (event_id, event_name, game_title, prize_pool, region) VALUES (3, 'Major', 'CS:GO', 1000000, 'Asia');
What is the maximum prize pool for esports events in Asia?
SELECT MAX(prize_pool) FROM esports_event WHERE region = 'Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE accidents (employee_id INT, gender VARCHAR(50), accident_date DATE); INSERT INTO accidents (employee_id, gender, accident_date) VALUES (1, 'Male', '2020-01-01'), (2, 'Female', '2020-02-01'), (3, 'Non-binary', '2020-03-01'), (4, 'Male', '2020-04-01'), (5, 'Female', '2020-05-01');
How many mining accidents were reported by gender in the given dataset?
SELECT gender, COUNT(*) as total_accidents FROM accidents GROUP BY gender;
gretelai_synthetic_text_to_sql
CREATE TABLE Astronauts (ID INT PRIMARY KEY, Name TEXT); CREATE TABLE Missions (ID INT PRIMARY KEY, Astronaut_ID INT, Name TEXT, Status TEXT);
Which astronauts have never been on a successful mission?
SELECT a.Name FROM Astronauts a LEFT JOIN Missions m ON a.ID = m.Astronaut_ID WHERE m.Status != 'Success';
gretelai_synthetic_text_to_sql
CREATE TABLE algorithmic_fairness (id INT, incident_count INT, developer VARCHAR(50)); INSERT INTO algorithmic_fairness (id, incident_count, developer) VALUES (1, 7, 'Jane Doe'), (2, 3, 'John Smith');
What is the total number of algorithmic fairness incidents for each developer?
SELECT developer, SUM(incident_count) FROM algorithmic_fairness GROUP BY developer;
gretelai_synthetic_text_to_sql
CREATE TABLE Countries (CountryID INT, CountryName VARCHAR(50)); CREATE TABLE Members (MemberID INT, MemberName VARCHAR(50), CountryID INT); CREATE TABLE Workouts (WorkoutID INT, WorkoutName VARCHAR(50), WorkoutType VARCHAR(50), Participants INT, WorkoutDate DATE, MemberID INT);
List the top 2 most popular workout types in India based on the number of unique participants in the last month.
SELECT w.WorkoutType, COUNT(DISTINCT m.MemberID) AS UniqueParticipants FROM Countries c INNER JOIN Members m ON c.CountryID = m.CountryID INNER JOIN Workouts w ON m.MemberID = w.MemberID WHERE c.CountryName = 'India' AND w.WorkoutDate >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY w.WorkoutType ORDER BY UniqueParticipants DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE Bridge (id INT, name VARCHAR(255), location VARCHAR(255), build_date DATE); INSERT INTO Bridge (id, name, location, build_date) VALUES (1, 'Bridge A', 'California', '2011-01-01'), (2, 'Bridge B', 'Texas', '2008-05-15'), (3, 'Bridge C', 'California', '2015-03-25');
List all bridges that were built in California after 2010
SELECT * FROM Bridge WHERE location = 'California' AND build_date > '2010-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE manufacturers (manufacturer_id INT, name VARCHAR(50)); INSERT INTO manufacturers (manufacturer_id, name) VALUES (1, 'ManufacturerA'), (2, 'ManufacturerB'), (3, 'ManufacturerC'); CREATE TABLE products (product_id INT, manufacturer_id INT, material VARCHAR(50)); INSERT INTO products (product_id, manufacturer_id, material) VALUES (1, 1, 'organic cotton'), (2, 1, 'hemp'), (3, 2, 'organic cotton'), (4, 2, 'recycled polyester'), (5, 3, 'recycled polyester'), (6, 3, 'hemp');
How many unique materials does each manufacturer use in their products?
SELECT manufacturers.name, COUNT(DISTINCT products.material) AS unique_materials_count FROM manufacturers JOIN products ON manufacturers.manufacturer_id = products.manufacturer_id GROUP BY manufacturers.name;
gretelai_synthetic_text_to_sql
CREATE TABLE Inclusion(inclusion_id INT, disability TEXT, budget DECIMAL(5,2));
What is the total budget allocated for inclusion efforts for students with physical disabilities?
SELECT SUM(budget) FROM Inclusion WHERE disability LIKE '%physical%';
gretelai_synthetic_text_to_sql
CREATE TABLE hospitals (id INT, state CHAR(2), num_beds INT, rural BOOLEAN); INSERT INTO hospitals (id, state, num_beds, rural) VALUES (1, 'IL', 50, true), (2, 'CA', 100, false);
What is the total number of hospital beds in rural areas in the Midwest?
SELECT SUM(num_beds) FROM hospitals WHERE rural = true AND state IN ('IL', 'IN', 'MI', 'MN', 'IA', 'MO', 'NE', 'ND', 'OH', 'OK', 'SD', 'WI');
gretelai_synthetic_text_to_sql
CREATE TABLE graduate_students (student_id INT, name TEXT, gpa DECIMAL(3,2), department TEXT); CREATE TABLE research_grants (grant_id INT, student_id INT, amount DECIMAL(10,2), date DATE);
What is the average GPA of graduate students who have received a research grant in the past year?
SELECT AVG(gs.gpa) FROM graduate_students gs INNER JOIN research_grants rg ON gs.student_id = rg.student_id WHERE rg.date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, Department VARCHAR(20), HireDate DATE); INSERT INTO Employees (EmployeeID, Department, HireDate) VALUES (1, 'Marketing', '2022-01-15'); INSERT INTO Employees (EmployeeID, Department, HireDate) VALUES (2, 'IT', '2021-12-01');
How many new hires were there in the Marketing department in Q1 2022?
SELECT COUNT(*) FROM Employees WHERE Department = 'Marketing' AND HireDate BETWEEN '2022-01-01' AND '2022-03-31';
gretelai_synthetic_text_to_sql
CREATE TABLE Security_Incidents (id INT PRIMARY KEY, incident_type VARCHAR(255), incident_date DATE, affected_system_id INT, FOREIGN KEY (affected_system_id) REFERENCES Systems(id)); INSERT INTO Security_Incidents (id, incident_type, incident_date, affected_system_id) VALUES (2, 'Phishing', '2021-06-05', 1);
How many security incidents of type 'Phishing' occurred per month in 2021?
SELECT COUNT(*) AS phishing_incidents, EXTRACT(MONTH FROM incident_date) AS month, EXTRACT(YEAR FROM incident_date) AS year FROM Security_Incidents WHERE incident_type = 'Phishing' AND EXTRACT(YEAR FROM incident_date) = 2021 GROUP BY month, year;
gretelai_synthetic_text_to_sql
CREATE TABLE citizens (citizen_id INT PRIMARY KEY, state TEXT, feedback TEXT);CREATE TABLE feedback_categories (feedback_id INT PRIMARY KEY, category TEXT);
List the number of citizens who provided feedback on environmental policies in each state
SELECT c.state, COUNT(c.citizen_id) FROM citizens c INNER JOIN feedback_categories fc ON c.feedback = fc.feedback_id WHERE fc.category = 'Environment' GROUP BY c.state;
gretelai_synthetic_text_to_sql
CREATE TABLE legal_aid (id INT, defendant_id INT, lawyer_id INT, is_pro_bono BOOLEAN); INSERT INTO legal_aid (id, defendant_id, lawyer_id, is_pro_bono) VALUES (1, 101, 201, TRUE), (2, 102, 202, FALSE), (3, 103, 203, TRUE), (4, 104, 204, FALSE);
What is the total number of pro bono cases in the 'legal_aid' table?
SELECT COUNT(*) FROM legal_aid WHERE is_pro_bono = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE wells (well_id INT, well_name VARCHAR(50), country VARCHAR(50), production FLOAT); INSERT INTO wells (well_id, well_name, country, production) VALUES (1, 'Well A', 'UK', 10000), (2, 'Well B', 'Norway', 15000), (3, 'Well C', 'UK', 20000); CREATE TABLE countries (country_id INT, country_name VARCHAR(50), region VARCHAR(50)); INSERT INTO countries (country_id, country_name, region) VALUES (1, 'UK', 'Europe'), (2, 'Norway', 'Europe');
What are the total production figures for each country in the 'Europe' region?
SELECT countries.country_name, SUM(wells.production) FROM wells INNER JOIN countries ON wells.country = countries.country_name WHERE countries.region = 'Europe' GROUP BY countries.country_name;
gretelai_synthetic_text_to_sql
CREATE TABLE trains (id INT, region VARCHAR(20), fare DECIMAL(5,2)); INSERT INTO trains (id, region, fare) VALUES (1, 'Seattle', 6.00), (2, 'Seattle', 4.50), (3, 'Portland', 3.50);
Delete all records of trains in the 'Seattle' region with a fare greater than $5.00.
DELETE FROM trains WHERE region = 'Seattle' AND fare > 5.00;
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name TEXT, industry TEXT, founder_gender TEXT); INSERT INTO companies (id, name, industry, founder_gender) VALUES (1, 'LatAmFood', 'Food', 'Female'); INSERT INTO companies (id, name, industry, founder_gender) VALUES (2, 'CleanEnergyMale', 'CleanEnergy', 'Male'); CREATE TABLE founders (id INT, name TEXT, gender TEXT); INSERT INTO founders (id, name, gender) VALUES (1, 'Alex', 'Female'); INSERT INTO founders (id, name, gender) VALUES (2, 'Jordan', 'Male');
How many startups were founded by women in the food sector?
SELECT COUNT(*) FROM companies INNER JOIN founders ON companies.founder_gender = founders.gender WHERE companies.industry = 'Food';
gretelai_synthetic_text_to_sql
CREATE TABLE Distance (user_id INT, distance DECIMAL(5,2), activity_date DATE); INSERT INTO Distance (user_id, distance, activity_date) VALUES (1, 5.5, '2021-04-01'), (2, 6.2, '2021-05-15'), (3, 7.3, '2021-06-30');
What is the total distance covered by users in Q2 2021?
SELECT SUM(distance) FROM Distance WHERE activity_date BETWEEN '2021-04-01' AND '2021-06-30';
gretelai_synthetic_text_to_sql
CREATE TABLE accommodations (id INT, student_id INT, accommodation_type VARCHAR(50), cost FLOAT, accommodation_date DATE); INSERT INTO accommodations (id, student_id, accommodation_type, cost, accommodation_date) VALUES (1, 2, 'Sign Language Interpreter', 50.00, '2021-01-01'), (2, 3, 'Assistive Listening Devices', 300.00, '2021-04-01');
Update the accommodation date for student 3 to '2021-03-15'
UPDATE accommodations SET accommodation_date = '2021-03-15' WHERE student_id = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE vaccinations (vaccine_type VARCHAR(50), age INTEGER, state VARCHAR(50), year INTEGER, quantity INTEGER); INSERT INTO vaccinations (vaccine_type, age, state, year, quantity) VALUES ('Flu', 3, 'California', 2020, 12000), ('Flu', 4, 'California', 2020, 15000), ('Flu', 2, 'Texas', 2020, 10000), ('Flu', 5, 'Texas', 2020, 18000), ('Flu', 3, 'New York', 2020, 14000), ('Flu', 4, 'New York', 2020, 16000);
Find the total number of flu vaccinations administered to children under 5 years old, grouped by state, for the year 2020.
SELECT state, SUM(quantity) as total_vaccinations FROM vaccinations WHERE vaccine_type = 'Flu' AND age < 5 AND year = 2020 GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE dysprosium_production (id INT, year INT, producer VARCHAR(255), dysprosium_prod FLOAT); INSERT INTO dysprosium_production (id, year, producer, dysprosium_prod) VALUES (1, 2018, 'China', 123.4), (2, 2018, 'USA', 234.5), (3, 2018, 'Australia', 345.6), (4, 2019, 'China', 456.7), (5, 2019, 'USA', 567.8), (6, 2019, 'Australia', 678.9);
What is the average Dysprosium production for the top 3 producers in 2018 and 2019?
SELECT AVG(dysprosium_prod) FROM (SELECT * FROM dysprosium_production WHERE year IN (2018, 2019) AND producer IN ('China', 'USA', 'Australia') ORDER BY dysprosium_prod DESC) WHERE rownum <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE schools (name VARCHAR(255), state VARCHAR(255)); INSERT INTO schools (name, state) VALUES ('School1', 'Texas'), ('School2', 'Texas'), ('School3', 'Florida');
Find the difference in the number of public schools between Texas and Florida.
SELECT (SELECT COUNT(*) FROM schools WHERE state = 'Texas') - (SELECT COUNT(*) FROM schools WHERE state = 'Florida');
gretelai_synthetic_text_to_sql
CREATE TABLE underwriting (id INT, group VARCHAR(10), name VARCHAR(20)); INSERT INTO underwriting (id, group, name) VALUES (1, 'High Risk', 'John Doe'), (2, 'Low Risk', 'Jane Smith'), (3, 'High Risk', 'Mike Johnson'), (4, 'Low Risk', 'Emma White');
What is the total number of policyholders in each underwriting group?
SELECT group, COUNT(*) FROM underwriting GROUP BY group;
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name TEXT, industry TEXT); CREATE TABLE funding (company_id INT, amount INT); INSERT INTO companies (id, name, industry) VALUES (1, 'HealFast', 'Healthcare'); INSERT INTO funding (company_id, amount) VALUES (1, 500000);
Calculate the average funding amount for companies in the healthcare sector, and list their names and funding amounts.
SELECT companies.name, AVG(funding.amount) AS avg_funding FROM companies INNER JOIN funding ON companies.id = funding.company_id WHERE companies.industry = 'Healthcare' GROUP BY companies.name;
gretelai_synthetic_text_to_sql
CREATE TABLE spacecraft (id INT, name VARCHAR(255), launch_country VARCHAR(255), launch_date DATE, max_speed FLOAT);
What is the average speed of spacecraft launched by country?
SELECT launch_country, AVG(max_speed) as avg_speed FROM spacecraft GROUP BY launch_country;
gretelai_synthetic_text_to_sql
CREATE TABLE data_breaches (id INT, sector TEXT, country TEXT, affected_users INT); INSERT INTO data_breaches (id, sector, country, affected_users) VALUES (1, 'Education', 'Germany', 1000); INSERT INTO data_breaches (id, sector, country, affected_users) VALUES (2, 'Education', 'USA', 500); INSERT INTO data_breaches (id, sector, country, affected_users) VALUES (3, 'Healthcare', 'Germany', 2000);
What is the average number of affected users for data breaches in the education sector in Germany?
SELECT AVG(affected_users) FROM data_breaches WHERE sector = 'Education' AND country = 'Germany';
gretelai_synthetic_text_to_sql
CREATE TABLE events (id INT, category VARCHAR(10), price DECIMAL(5,2), attendance INT); INSERT INTO events (id, category, price, attendance) VALUES (1, 'music', 20.00, 600), (2, 'dance', 15.00, 400), (3, 'music', 55.00, 800), (4, 'theater', 30.00, 700);
Delete events with a ticket price greater than $50.
DELETE FROM events WHERE price > 50.00;
gretelai_synthetic_text_to_sql
CREATE TABLE binance_smart_chain (contract_address VARCHAR(42), tx_count INT);
List the top 5 most frequently used smart contracts on the Binance Smart Chain?
SELECT contract_address, tx_count FROM binance_smart_chain ORDER BY tx_count DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE spending (district VARCHAR(20), amount FLOAT); INSERT INTO spending (district, amount) VALUES ('North', 30000.0), ('East', 40000.0), ('West', 20000.0), ('South', 50000.0);
What is the total spending on transparency measures for the "West" and "North" districts?
SELECT SUM(amount) FROM spending WHERE district IN ('West', 'North');
gretelai_synthetic_text_to_sql
CREATE TABLE sustainable_tourism (initiative_id INT, name TEXT, continent TEXT); INSERT INTO sustainable_tourism (initiative_id, name, continent) VALUES (1, 'Green Coast Project', 'Europe'), (2, 'EcoVillage Borneo', 'Asia'), (3, 'Sustainable Safari Tours', 'Africa');
Identify the number of sustainable tourism initiatives in each continent.
SELECT continent, COUNT(*) as initiative_count FROM sustainable_tourism GROUP BY continent;
gretelai_synthetic_text_to_sql
CREATE TABLE menu_items (id INT, name TEXT, cuisine TEXT, vegetarian BOOLEAN, price INT); INSERT INTO menu_items (id, name, cuisine, vegetarian, price) VALUES (1, 'Tofu Curry', 'asian', 1, 15), (2, 'Chicken Fried Rice', 'asian', 0, 12), (3, 'Vegetable Stir Fry', 'asian', 1, 10), (4, 'Beef and Broccoli', 'asian', 0, 18);
What is the maximum and minimum price of vegetarian menu items in the 'asian' cuisine category?
SELECT MAX(price) as max_price, MIN(price) as min_price FROM menu_items WHERE cuisine = 'asian' AND vegetarian = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Drilling (WellID INT, Country VARCHAR(20), StartDate DATE, EndDate DATE);
Delete all records from the 'Drilling' table where 'Country' is 'Brazil'
DELETE FROM Drilling WHERE Country = 'Brazil';
gretelai_synthetic_text_to_sql
CREATE TABLE countries (id INT, name TEXT, ocean_health_score FLOAT); INSERT INTO countries (id, name, ocean_health_score) VALUES (1, 'Country A', 78.2), (2, 'Country B', 82.6), (3, 'Country C', 71.5), (4, 'Country D', 80.9), (5, 'Country E', 79.4);
List the top 3 countries with the highest ocean health metric scores.
SELECT name, ocean_health_score FROM (SELECT name, ocean_health_score, ROW_NUMBER() OVER (ORDER BY ocean_health_score DESC) as rank FROM countries) subquery WHERE rank <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (id INT, donation_date DATE, amount FLOAT);
What is the number of donations received each day in January 2022?
SELECT DATE(donation_date) as donation_date, COUNT(*) as number_of_donations FROM Donations WHERE YEAR(donation_date) = 2022 AND MONTH(donation_date) = 1 GROUP BY donation_date;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas (id INT, name VARCHAR(255), area_size FLOAT); INSERT INTO marine_protected_areas (id, name, area_size) VALUES (1, 'Galapagos', 14000), (2, 'Maldives', 5000);
What is the smallest marine protected area by area size?
SELECT name, MIN(area_size) FROM marine_protected_areas
gretelai_synthetic_text_to_sql
CREATE TABLE TV_Views (viewer_id INT, age INT, tv_show VARCHAR(255), view_date DATE);
Views by age group for TV Show "Stranger Things"?
SELECT age, COUNT(*) as views FROM TV_Views WHERE tv_show = 'Stranger Things' GROUP BY age;
gretelai_synthetic_text_to_sql
CREATE TABLE news_stories (id INT, published_date DATE); INSERT INTO news_stories (id, published_date) VALUES (1, '2022-01-01'), (2, '2022-01-02'), (3, '2021-12-31'), (4, '2022-01-03')
How many news stories were published in 2022?
SELECT COUNT(*) FROM news_stories WHERE YEAR(published_date) = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE test_drives (id INT PRIMARY KEY, vehicle_make VARCHAR(255), test_driver VARCHAR(255), test_date DATE);
Delete all records from the 'test_drives' table where the 'vehicle_make' is 'Tesla'
DELETE FROM test_drives WHERE vehicle_make = 'Tesla';
gretelai_synthetic_text_to_sql
CREATE TABLE customer (id INT, size FLOAT, gender TEXT, date DATE);
What is the average customer size by gender for the past 12 months?
SELECT gender, AVG(size) FROM customer WHERE date >= DATE_SUB(CURDATE(), INTERVAL 12 MONTH) GROUP BY gender;
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_programs_africa (id INT, name VARCHAR(100), country VARCHAR(50), start_date DATE); INSERT INTO carbon_programs_africa (id, name, country, start_date) VALUES (1, 'Program 1', 'South Africa', '2020-01-01'), (2, 'Program 2', 'Kenya', '2019-05-15'), (3, 'Program 3', 'Nigeria', '2021-03-20');
List all Carbon Offset Programs in Africa along with their start dates
SELECT name, start_date FROM carbon_programs_africa WHERE country = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE ElectricVehicleSales (id INT, name VARCHAR(50), horsepower INT, sale_year INT); INSERT INTO ElectricVehicleSales (id, name, horsepower, sale_year) VALUES (1, 'Tesla Model 3', 258, 2022); INSERT INTO ElectricVehicleSales (id, name, horsepower, sale_year) VALUES (2, 'Chevrolet Bolt', 200, 2022);
What is the minimum horsepower of electric vehicles sold in 2022?
SELECT MIN(horsepower) FROM ElectricVehicleSales WHERE sale_year = 2022 AND horsepower IS NOT NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE sustainable_tourism (initiative_id INT, name TEXT, country TEXT); INSERT INTO sustainable_tourism VALUES (1, 'Sustainable Islands Tour', 'Greece'), (2, 'Eco-friendly Cruises', 'Greece'), (3, 'Green National Parks', 'Croatia');
How many sustainable tourism initiatives are there in total in Greece and Croatia?
SELECT COUNT(*) FROM sustainable_tourism WHERE country IN ('Greece', 'Croatia');
gretelai_synthetic_text_to_sql
CREATE TABLE fabric_source ( id INT PRIMARY KEY, fabric_type VARCHAR(255), country VARCHAR(255), certified_sustainable BOOLEAN, quantity INT );
What is the total quantity of sustainable fabrics by type?
SELECT fabric_type, SUM(CASE WHEN certified_sustainable THEN quantity ELSE 0 END) as sustainable_fabrics_quantity FROM fabric_source GROUP BY fabric_type;
gretelai_synthetic_text_to_sql
CREATE TABLE streams (song VARCHAR(50), country VARCHAR(50), streams INT); INSERT INTO streams (song, country, streams) VALUES ('Hey Jude', 'France', 400000), ('Let It Be', 'France', 300000);
What is the total number of streams in France?
SELECT SUM(streams) FROM streams WHERE country = 'France';
gretelai_synthetic_text_to_sql
CREATE TABLE province (province_id INT, province VARCHAR(50)); INSERT INTO province (province_id, province) VALUES (1, 'Alberta'), (2, 'British Columbia'), (3, 'Manitoba'), (4, 'New Brunswick'), (5, 'Newfoundland and Labrador'), (6, 'Nova Scotia'), (7, 'Ontario'), (8, 'Prince Edward Island'), (9, 'Quebec'), (10, 'Saskatchewan'); CREATE TABLE landfill_capacity (landfill_id INT, province_id INT, capacity_m3 INT); INSERT INTO landfill_capacity (landfill_id, province_id, capacity_m3) VALUES (1, 1, 12000000), (2, 2, 9000000), (3, 3, 7000000), (4, 4, 5000000), (5, 5, 4000000), (6, 6, 6000000), (7, 7, 15000000), (8, 8, 2000000), (9, 9, 11000000), (10, 10, 8000000);
List the landfill capacity by province in Canada in descending order.
SELECT p.province, l.capacity_m3 FROM province p JOIN landfill_capacity l ON p.province_id = l.province_id ORDER BY l.capacity_m3 DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Astronauts (AstronautID INT, TotalTimeInSpace FLOAT);
Who are the astronauts who have spent the most time in space, and what is their total time spent in space?
SELECT AstronautID, TotalTimeInSpace FROM (SELECT AstronautID, SUM(Duration) AS TotalTimeInSpace FROM SpaceMissions GROUP BY AstronautID) subquery ORDER BY TotalTimeInSpace DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE art_forms (name VARCHAR(255), region VARCHAR(255), practitioners INTEGER); INSERT INTO art_forms (name, region, practitioners) VALUES ('Art A', 'Africa', 7000); INSERT INTO art_forms (name, region, practitioners) VALUES ('Art B', 'Africa', 3000);
Identify the traditional art forms that are primarily practiced in Africa and have more than 5000 active practitioners.
SELECT name FROM art_forms WHERE region = 'Africa' AND practitioners > 5000
gretelai_synthetic_text_to_sql
CREATE TABLE movies (id INT, title VARCHAR(255), release_year INT, director_gender VARCHAR(10), budget INT); INSERT INTO movies (id, title, release_year, director_gender, budget) VALUES (1, 'Movie1', 2020, 'Female', 20000000), (2, 'Movie2', 2019, 'Male', 30000000);
Find the average budget of movies released in 2020 directed by female directors.
SELECT AVG(budget) FROM movies WHERE release_year = 2020 AND director_gender = 'Female';
gretelai_synthetic_text_to_sql
CREATE TABLE energy_consumption (id INT, sector TEXT, year INT, consumption_twh FLOAT); INSERT INTO energy_consumption (id, sector, year, consumption_twh) VALUES (1, 'Residential', 2019, 250.5), (2, 'Residential', 2020, 270.6);
What was the total energy consumption (TWh) of the residential sector in Brazil in 2020?
SELECT SUM(consumption_twh) FROM energy_consumption WHERE sector = 'Residential' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE clients (client_id INT, name VARCHAR(50), investment FLOAT); CREATE TABLE fund_investments (client_id INT, fund_name VARCHAR(50), investment FLOAT);
What is the total investment of clients with the first name "John" in any fund?
SELECT SUM(investment) FROM clients INNER JOIN fund_investments ON clients.client_id = fund_investments.client_id WHERE clients.name LIKE 'John%';
gretelai_synthetic_text_to_sql
CREATE TABLE digital_assets (asset_id INT, asset_name VARCHAR(50), value DECIMAL(10,2)); INSERT INTO digital_assets (asset_id, asset_name, value) VALUES (1, 'Asset1', 50.5), (2, 'Asset2', 100.2), (3, 'Asset3', 75.0); CREATE TABLE smart_contracts (contract_id INT, asset_id INT, contract_name VARCHAR(50)); INSERT INTO smart_contracts (contract_id, asset_id, contract_name) VALUES (101, 1, 'ContractProtocol1'), (102, 2, 'Contract2'), (103, 3, 'ContractProtocol3');
What is the maximum value of digital assets associated with smart contracts containing the word 'protocol'?
SELECT MAX(digital_assets.value) FROM digital_assets INNER JOIN smart_contracts ON digital_assets.asset_id = smart_contracts.asset_id WHERE smart_contracts.contract_name LIKE '%protocol%';
gretelai_synthetic_text_to_sql
CREATE TABLE fl_spending (quarter VARCHAR(5), state VARCHAR(10), spending FLOAT); INSERT INTO fl_spending (quarter, state, spending) VALUES ('Q1 2022', 'Florida', 6000000), ('Q2 2022', 'Florida', 6500000), ('Q3 2022', 'Florida', 7000000), ('Q4 2022', 'Florida', 7500000);
What was the total construction spending in Florida in Q1 2022?
SELECT spending FROM fl_spending WHERE quarter = 'Q1 2022' AND state = 'Florida';
gretelai_synthetic_text_to_sql
CREATE TABLE track_plays (play_id INT, track_id INT, country VARCHAR(255), plays INT, play_date DATE); CREATE VIEW daily_track_plays AS SELECT track_id, country, play_date, SUM(plays) as total_plays FROM track_plays GROUP BY track_id, country, play_date;
What is the number of plays per day, by country, for the last 30 days, for the track "Eye of the Tiger"?
SELECT track_id, country, play_date, total_plays, ROW_NUMBER() OVER (PARTITION BY country ORDER BY total_plays DESC) as rank FROM daily_track_plays WHERE track_id = (SELECT track_id FROM tracks WHERE name = 'Eye of the Tiger') AND play_date >= DATEADD(day, -30, CURRENT_DATE) ORDER BY country, rank;
gretelai_synthetic_text_to_sql
CREATE TABLE reo_production (id INT PRIMARY KEY, reo_type VARCHAR(50), production_quantity INT, production_year INT);
Get the REO types and their total production quantities in 2023 from the reo_production table, sorted in descending order by production quantity
SELECT reo_type, SUM(production_quantity) as total_production FROM reo_production WHERE production_year = 2023 GROUP BY reo_type ORDER BY total_production DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE donations (donation_id INT, donor_id INT, donation_date DATE, amount DECIMAL(10,2)); INSERT INTO donations VALUES (1, 1, '2022-01-01', 50.00), (2, 1, '2022-03-15', 100.00), (3, 2, '2022-02-01', 200.00), (4, 2, '2022-04-15', 150.00);
What is the average donation amount for each donor in 2022?
SELECT donor_id, AVG(amount) as avg_donation FROM donations WHERE donation_date BETWEEN '2022-01-01' AND '2022-12-31' GROUP BY donor_id;
gretelai_synthetic_text_to_sql
CREATE SCHEMA nyc_schema;CREATE TABLE nyc_schema.transportation (trip_year INT, mode VARCHAR(20), num_trips INT);CREATE TABLE nyc_schema.parking_violations (violation_year INT, violation_type VARCHAR(20), num_violations INT);INSERT INTO nyc_schema.transportation (trip_year, mode, num_trips) VALUES (2019, 'Public Transportation', 5000000);INSERT INTO nyc_schema.parking_violations (violation_year, violation_type, num_violations) VALUES (2019, 'Parking', 1000000);
Find the number of public transportation trips and parking violations issued in New York City in 2019.
SELECT SUM(num_trips) FROM nyc_schema.transportation WHERE trip_year = 2019 AND mode = 'Public Transportation';SELECT SUM(num_violations) FROM nyc_schema.parking_violations WHERE violation_year = 2019 AND violation_type = 'Parking';
gretelai_synthetic_text_to_sql
CREATE TABLE grants (grant_id INT, recipient_name VARCHAR(255), region VARCHAR(255), grant_amount FLOAT); INSERT INTO grants (grant_id, recipient_name, region, grant_amount) VALUES (1, 'Organization A', 'North', 20000), (2, 'Organization B', 'South', 15000), (3, 'Organization C', 'East', 25000), (4, 'Organization A', 'North', 18000), (5, 'Organization D', 'West', 12000), (6, 'Organization E', 'East', 19000);
Find the top 2 regions with the highest total grant amount in the 'grants' table, and display the region and total grant amount for each region.
SELECT region, SUM(grant_amount) as total_grant FROM grants GROUP BY region ORDER BY total_grant DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE vendors (id INT, vendor_name VARCHAR(255), vendor_location VARCHAR(255)); CREATE TABLE contracts (id INT, vendor_id INT, equipment_type VARCHAR(255), quantity INT, contract_value FLOAT, state VARCHAR(255)); INSERT INTO vendors (id, vendor_name, vendor_location) VALUES (1, 'General Dynamics', 'Florida'); INSERT INTO vendors (id, vendor_name, vendor_location) VALUES (2, 'Bell', 'Texas'); INSERT INTO vendors (id, vendor_name, vendor_location) VALUES (3, 'Boeing', 'Washington'); INSERT INTO contracts (id, vendor_id, equipment_type, quantity, contract_value, state) VALUES (1, 1, 'Tank', 50, 10000000, 'Texas'); INSERT INTO contracts (id, vendor_id, equipment_type, quantity, contract_value, state) VALUES (2, 2, 'Helicopter', 25, 5000000, 'Texas'); INSERT INTO contracts (id, vendor_id, equipment_type, quantity, contract_value, state) VALUES (3, 3, 'Aircraft', 10, 20000000, 'California');
Which vendors have provided military equipment worth more than $10 million in Texas?
SELECT v.vendor_name, SUM(c.contract_value) as total_contract_value FROM contracts c JOIN vendors v ON c.vendor_id = v.id WHERE c.state = 'Texas' GROUP BY v.vendor_name HAVING total_contract_value > 10000000;
gretelai_synthetic_text_to_sql
CREATE TABLE SeaLevelRise (location varchar(50), year int, rise float);
What is the average sea level rise in the Arctic region by year?
SELECT year, AVG(rise) AS avg_rise FROM SeaLevelRise WHERE location LIKE 'Arctic%' GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID int, DonorName varchar(50), TotalDonations numeric(18,2));
What is the total amount donated by each donor in the 'Donors' table, sorted by the total amount in descending order?
SELECT DonorName, SUM(TotalDonations) as TotalDonated FROM Donors GROUP BY DonorName ORDER BY TotalDonated DESC;
gretelai_synthetic_text_to_sql