context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE Players (PlayerID INT PRIMARY KEY, Name VARCHAR(100), Age INT, Sport VARCHAR(50), Country VARCHAR(50)); INSERT INTO Players (PlayerID, Name, Age, Sport, Country) VALUES (1, 'John Doe', 25, 'Soccer', 'USA'); INSERT INTO Players (PlayerID, Name, Age, Sport, Country) VALUES (2, 'Jane Smith', 30, 'Basketball',...
How many basketball assists were made by players from Canada?
SELECT SUM(Value) as TotalAssists FROM Players_Stats JOIN Players ON Players.PlayerID = Players_Stats.PlayerID WHERE Players.Sport = 'Basketball' AND Players.Country = 'Canada' AND Stat = 'Assists';
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (transaction_id INT, account_number INT, amount DECIMAL(10,2), transaction_date DATE, account_region VARCHAR(50)); INSERT INTO transactions (transaction_id, account_number, amount, transaction_date, account_region) VALUES (1, 333333333, 150.00, '2022-07-01', 'Middle East'), (2, 444444444, 250....
What is the earliest transaction date for any account in the Middle East region?
SELECT MIN(transaction_date) FROM transactions WHERE account_region = 'Middle East';
gretelai_synthetic_text_to_sql
CREATE TABLE facilities (id INT, country VARCHAR(50), num_facilities INT); INSERT INTO facilities (id, country, num_facilities) VALUES (1, 'China', 5000), (2, 'USA', 3000), (3, 'India', 2500), (4, 'Germany', 2000), (5, 'Mexico', 1500);
What are the top 3 countries with the most manufacturing facilities, and how many facilities do they have?
SELECT country, num_facilities FROM facilities ORDER BY num_facilities DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (id INT, volunteer_name VARCHAR(255), program VARCHAR(255), volunteer_hours INT, volunteer_date DATE); INSERT INTO Volunteers (id, volunteer_name, program, volunteer_hours, volunteer_date) VALUES (1, 'Marta Silva', 'Education', 10, '2021-08-05'), (2, 'Pedro Ferreira', 'Education', 15, '2021-10-2...
How many volunteers contributed to educational programs in Brazil in H2 2021?
SELECT COUNT(*) FROM Volunteers WHERE program = 'Education' AND volunteer_date BETWEEN '2021-07-01' AND '2021-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE IntelligenceOperations (Id INT, Name VARCHAR(50), ImplementationDate DATE); INSERT INTO IntelligenceOperations VALUES (1, 'SIGINT', '1960-01-01'); INSERT INTO IntelligenceOperations VALUES (2, 'HUMINT', '1945-05-07'); INSERT INTO IntelligenceOperations VALUES (3, 'GEOINT', '2001-09-11');
What is the earliest implementation date for military intelligence operations?
SELECT MIN(ImplementationDate) FROM IntelligenceOperations;
gretelai_synthetic_text_to_sql
CREATE TABLE thulium_smelting (country VARCHAR(20), num_smelting INT); INSERT INTO thulium_smelting (country, num_smelting) VALUES ('Canada', 3), ('China', 7), ('Russia', 5);
How many thulium smelting facilities are there in Canada?
SELECT num_smelting FROM thulium_smelting WHERE country = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers (supplier_id INT, name TEXT);CREATE TABLE materials (material_id INT, name TEXT);CREATE TABLE factory_supplies (factory_id INT, supplier_id INT, material_id INT);
Who are the suppliers that provide materials to more than one factory, and what are the materials they supply?
SELECT s.name, m.name FROM suppliers s INNER JOIN factory_supplies fs ON s.supplier_id = fs.supplier_id INNER JOIN materials m ON fs.material_id = m.material_id GROUP BY s.name, m.name HAVING COUNT(DISTINCT fs.factory_id) > 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Spacecraft (spacecraft_model VARCHAR(50), flight_hours INT, last_maintenance_date DATE); INSERT INTO Spacecraft (spacecraft_model, flight_hours, last_maintenance_date) VALUES ('SC-1', 5000, '2016-05-12'), ('SC-2', 7000, '2018-03-21'), ('SC-3', 3500, '2015-08-04');
What is the total number of flight hours for each spacecraft model in the last 5 years?
SELECT spacecraft_model, SUM(flight_hours) as total_flight_hours FROM Spacecraft WHERE last_maintenance_date >= DATEADD(year, -5, GETDATE()) GROUP BY spacecraft_model;
gretelai_synthetic_text_to_sql
CREATE TABLE donations (donor_id INT, donation_amount DECIMAL, donation_date DATE); INSERT INTO donations (donor_id, donation_amount, donation_date) VALUES (1, 100, '2021-05-01'); INSERT INTO donations (donor_id, donation_amount, donation_date) VALUES (1, 150, '2022-05-01');
List all donors who have increased their donation amounts in the last 12 months compared to the previous year.
SELECT d1.donor_id, d1.donation_amount, d2.donation_amount FROM donations d1 INNER JOIN donations d2 ON d1.donor_id = d2.donor_id WHERE YEAR(d1.donation_date) = YEAR(CURRENT_DATE()) - 1 AND YEAR(d2.donation_date) = YEAR(CURRENT_DATE()) AND d1.donation_amount > d2.donation_amount;
gretelai_synthetic_text_to_sql
CREATE TABLE Programs (ProgramID INT, ProgramName TEXT, Budget DECIMAL); INSERT INTO Programs (ProgramID, ProgramName, Budget) VALUES (1, 'Education', 15000.00), (2, 'Healthcare', 20000.00), (3, 'Environment', 10000.00);
List all the programs and their respective budgets?
SELECT ProgramName, Budget FROM Programs;
gretelai_synthetic_text_to_sql
CREATE TABLE SafetyRecords (ID INT PRIMARY KEY, VesselID INT, Category TEXT); INSERT INTO SafetyRecords (ID, VesselID, Category) VALUES (1, 1, 'excellent'), (2, 2, 'good'), (3, 3, 'excellent');
How many vessels have a safety record in the 'excellent' category?
SELECT COUNT(*) FROM SafetyRecords WHERE Category = 'excellent';
gretelai_synthetic_text_to_sql
CREATE TABLE Fish_Farms (id INT, region VARCHAR(255), year INT, biomass INT); INSERT INTO Fish_Farms (id, region, year, biomass) VALUES (1, 'Europe', 2017, 180), (2, 'Europe', 2018, 220), (3, 'Asia', 2017, 250), (4, 'Europe', 2019, 230);
What is the average biomass of fish in European aquaculture farms in 2018?
SELECT AVG(Fish_Farms.biomass) FROM Fish_Farms WHERE Fish_Farms.region = 'Europe' AND Fish_Farms.year = 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_rates (id INT, material VARCHAR(20), year INT, recycling_rate DECIMAL(5,2)); INSERT INTO recycling_rates (id, material, year, recycling_rate) VALUES (1, 'plastic', 2017, 0.25), (2, 'plastic', 2018, 0.28), (3, 'plastic', 2019, 0.31), (4, 'paper', 2017, 0.60), (5, 'paper', 2018, 0.63), (6, 'paper',...
What was the plastic recycling rate in 2019 compared to 2017?
SELECT (recycling_rate - (SELECT recycling_rate FROM recycling_rates r2 WHERE r2.material = 'plastic' AND r2.year = 2017)) FROM recycling_rates WHERE material = 'plastic' AND year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE Hospitals (Name VARCHAR(255), State VARCHAR(255), Specialized BOOLEAN); INSERT INTO Hospitals (Name, State, Specialized) VALUES ('Hospital A', 'State A', TRUE), ('Hospital B', 'State A', FALSE), ('Hospital C', 'State B', TRUE), ('Hospital D', 'State B', FALSE); CREATE TABLE StateData (State VARCHAR(255), T...
What is the number of hospitals in each state, and how many of them are specialized in mental health?
SELECT h.State, COUNT(*) AS TotalHospitals, SUM(CASE WHEN h.Specialized THEN 1 ELSE 0 END) AS SpecializedMentalHealthHospitals FROM Hospitals h INNER JOIN StateData sd ON h.State = sd.State GROUP BY h.State;
gretelai_synthetic_text_to_sql
CREATE TABLE policy_types (id INT, policy_type TEXT); INSERT INTO policy_types (id, policy_type) VALUES (1, 'Auto'); INSERT INTO policy_types (id, policy_type) VALUES (2, 'Home'); INSERT INTO policy_types (id, policy_type) VALUES (3, 'Life'); CREATE TABLE policies (id INT, policyholder_id INT, policy_type_id INT, issue...
Display the policy types with the lowest claim frequency in Texas.
SELECT policy_types.policy_type, COUNT(DISTINCT policies.id) AS num_policies, COUNT(DISTINCT claims.id) AS num_claims, COUNT(DISTINCT claims.id) / COUNT(DISTINCT policies.id) * 100 AS claim_frequency FROM policies JOIN policy_types ON policies.policy_type_id = policy_types.id LEFT JOIN claims ON policies.id = claims.po...
gretelai_synthetic_text_to_sql
CREATE TABLE EquipmentSales (id INT PRIMARY KEY, country VARCHAR(50), equipment_type VARCHAR(50), sale_price DECIMAL(10, 2));
What is the average sale price for military equipment in Germany?
SELECT AVG(sale_price) FROM EquipmentSales WHERE country = 'Germany';
gretelai_synthetic_text_to_sql
CREATE TABLE socially_responsible_loans (loan_id INT, borrower_country TEXT, daily_balance DECIMAL(10, 2), loan_date DATE); INSERT INTO socially_responsible_loans VALUES (1, 'Indonesia', 5000, '2021-01-15'), (2, 'Brazil', 7000, '2021-03-20'), (3, 'Indonesia', 3000, '2021-06-05'), (4, 'Nigeria', 8000, '2021-09-10');
What is the average daily balance for socially responsible loans, partitioned by borrower's country and ordered by average balance?
SELECT borrower_country, AVG(daily_balance) as avg_balance, ROW_NUMBER() OVER (ORDER BY AVG(daily_balance) DESC, borrower_country) as rank FROM socially_responsible_loans GROUP BY borrower_country ORDER BY avg_balance DESC, borrower_country;
gretelai_synthetic_text_to_sql
CREATE TABLE antarctica_therapy (patient_id INT, therapy VARCHAR(20)); INSERT INTO antarctica_therapy (patient_id, therapy) VALUES (1, 'Psychodynamic Therapy'), (2, 'CBT'), (3, 'Psychodynamic Therapy'), (4, 'NA'), (5, 'Psychodynamic Therapy'), (6, 'NA'), (7, 'NA'), (8, 'NA'), (9, 'NA');
What is the total number of patients who received any therapy in Antarctica?
SELECT COUNT(*) FROM antarctica_therapy WHERE therapy IS NOT NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE tv_show (id INT, title VARCHAR(50), viewers INT); INSERT INTO tv_show (id, title, viewers) VALUES (1, 'TVShow1', 250000), (2, 'TVShow2', 180000), (3, 'TVShow3', 300000), (4, 'TVShow4', 220000), (5, 'TVShow5', 150000), (6, 'TVShow6', 190000);
What are the top 5 most viewed TV shows in descending order?
SELECT title FROM tv_show ORDER BY viewers DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE player_demographics (player_id INT PRIMARY KEY, age INT, gender VARCHAR(10), location VARCHAR(50), birthdate DATE);
Display players who share the same birthdate
SELECT p1.player_id, p1.gender, p1.location, p2.player_id, p2.gender, p2.location FROM player_demographics p1 INNER JOIN player_demographics p2 ON p1.birthdate = p2.birthdate WHERE p1.player_id <> p2.player_id;
gretelai_synthetic_text_to_sql
CREATE TABLE tourism_impact (city VARCHAR(100), year INT, local_economic_impact INT); INSERT INTO tourism_impact (city, year, local_economic_impact) VALUES ('Paris', 2020, 12000000); INSERT INTO tourism_impact (city, year, local_economic_impact) VALUES ('London', 2020, 11000000);
What is the local economic impact of tourism in Paris in 2020?
SELECT local_economic_impact FROM tourism_impact WHERE city = 'Paris' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE grants (id serial, researcher_id integer, title text, amount real, year integer);
Delete all research grants before 2005
DELETE FROM grants WHERE year < 2005;
gretelai_synthetic_text_to_sql
CREATE TABLE mental_health_parity (id INT PRIMARY KEY, state VARCHAR(255), mental_health_parity_law TEXT); INSERT INTO mental_health_parity (id, state, mental_health_parity_law) VALUES (1, 'Alabama', 'Partial Parity'), (2, 'Alaska', 'Full Parity'), (3, 'Arizona', 'No Parity'), (4, 'Arkansas', 'Partial Parity');
Show the number of mental health parity laws for each state
SELECT state, COUNT(*) as num_laws FROM mental_health_parity GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE workers (id INT, name VARCHAR(50), industry VARCHAR(50), salary FLOAT, state VARCHAR(50)); INSERT INTO workers (id, name, industry, salary, state) VALUES (1, 'John Doe', 'oil', 60000, 'Texas'); INSERT INTO workers (id, name, industry, salary, state) VALUES (2, 'Jane Smith', 'oil', 65000, 'California'); INS...
What is the minimum salary of workers in the 'oil' industry in each state in the USA?
SELECT state, MIN(salary) FROM workers WHERE industry = 'oil' GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE HairCareSales (sale_id INT, product_id INT, sale_price DECIMAL(5,2), sale_date DATE, is_natural BOOLEAN, country TEXT); INSERT INTO HairCareSales (sale_id, product_id, sale_price, sale_date, is_natural, country) VALUES (1, 801, 32.99, '2022-05-13', true, 'Canada');
Which natural hair care products had the highest sales in Canada in 2022?
SELECT product_id, MAX(sale_price) FROM HairCareSales WHERE is_natural = true AND country = 'Canada' AND sale_date BETWEEN '2022-01-01' AND '2022-12-31' GROUP BY product_id;
gretelai_synthetic_text_to_sql
CREATE TABLE public.programs (name text); INSERT INTO public.programs (name) VALUES ('Open Data Program'), ('Public Participation Program'), ('Transparency in Government Program'), ('Evidence-Based Policy Making Program');
List all unique names of government programs in the public schema that contain the word "transparency"?
SELECT DISTINCT name FROM public.programs WHERE name LIKE '%transparency%';
gretelai_synthetic_text_to_sql
CREATE TABLE CountryProductivity (country VARCHAR(50), mine_name VARCHAR(50), year INT, productivity INT); INSERT INTO CountryProductivity (country, mine_name, year, productivity) VALUES ('Canada', 'Golden Mine', 2019, 115), ('Mexico', 'Silver Mine', 2019, 135), ('Brazil', 'Iron Mine', 2019, 165);
What is the average labor productivity for each mine, by country, in 2019?
SELECT context.country, AVG(context.productivity) as avg_productivity FROM context WHERE context.year = 2019 GROUP BY context.country;
gretelai_synthetic_text_to_sql
CREATE TABLE Restaurants (name text, type text); INSERT INTO Restaurants (name, type) VALUES ('Organic Bites', 'Vegetarian'); CREATE TABLE Menu (name text, restaurant text, food text, calories integer); INSERT INTO Menu (name, restaurant, food, calories) VALUES ('Lunch', 'Organic Bites', 'Vegetable Lasagna', 550), ('Lu...
What is the average calorie count for vegetarian dishes served in 'Organic Bites'?
SELECT AVG(calories) FROM Menu WHERE restaurant = 'Organic Bites' AND food LIKE '%vegetarian%';
gretelai_synthetic_text_to_sql
CREATE TABLE departments (id INT, department_name VARCHAR(255)); CREATE TABLE research_grants (id INT, grant_name VARCHAR(255), grant_amount INT, department_id INT, PRIMARY KEY (id), FOREIGN KEY (department_id) REFERENCES departments(id)); INSERT INTO departments (id, department_name) VALUES (1, 'Computer Science'), (2...
What is the average grant amount awarded to each department?
SELECT d.department_name, AVG(rg.grant_amount) as avg_grant_amount FROM departments d JOIN research_grants rg ON d.id = rg.department_id GROUP BY d.department_name;
gretelai_synthetic_text_to_sql
CREATE TABLE hospitals (id INT, name TEXT, state TEXT, capacity INT); INSERT INTO hospitals (id, name, state, capacity) VALUES (1, 'Hospital A', 'TX', 200), (2, 'Hospital B', 'TX', 300), (3, 'Hospital C', 'FL', 250), (4, 'Hospital D', 'FL', 350);
What is the total capacity of hospitals in Texas and Florida?
SELECT SUM(capacity) FROM hospitals WHERE state IN ('TX', 'FL');
gretelai_synthetic_text_to_sql
CREATE TABLE union_membership (id INT, name VARCHAR(50), department VARCHAR(50), tenure INT); INSERT INTO union_membership (id, name, department, tenure) VALUES (1, 'Alice', 'technology', 5); INSERT INTO union_membership (id, name, department, tenure) VALUES (2, 'Bob', 'technology', 3); INSERT INTO union_membership (id...
What is the average tenure of members in the 'technology' department?
SELECT AVG(tenure) FROM union_membership WHERE department = 'technology';
gretelai_synthetic_text_to_sql
CREATE TABLE Concerts (city VARCHAR(20), genre VARCHAR(20), price DECIMAL(5,2)); INSERT INTO Concerts (city, genre, price) VALUES ('New York', 'Jazz', 35.99), ('Chicago', 'Blues', 24.99), ('New York', 'Rock', 15.00);
What is the average ticket price for jazz concerts in New York?
SELECT AVG(price) FROM Concerts WHERE city = 'New York' AND genre = 'Jazz';
gretelai_synthetic_text_to_sql
CREATE TABLE Claims (PolicyID INT, PolicyType VARCHAR(255), ClaimAmount DECIMAL(10, 2), ClaimDate DATE); INSERT INTO Claims VALUES (1, 'Auto', 500, '2022-01-05'), (2, 'Home', 1000, '2022-02-10'), (3, 'Auto', 750, '2022-03-15'), (4, 'Home', 1200, '2022-01-25'), (5, 'Auto', 300, '2022-02-01'), (6, 'Home', 1500, '2022-03-...
What is the average claim amount by policy type and month?
SELECT PolicyType, EXTRACT(MONTH FROM ClaimDate) AS Month, AVG(ClaimAmount) AS AvgClaimAmount FROM Claims GROUP BY PolicyType, Month;
gretelai_synthetic_text_to_sql
CREATE TABLE community_health_workers (county VARCHAR(20), region VARCHAR(10), workers INT); INSERT INTO community_health_workers (county, region, workers) VALUES ('Cook', 'Midwest', 500), ('Ramsey', 'Midwest', 300), ('Shelby', 'Midwest', 400);
What is the total number of community health workers by county in the Midwest region?
SELECT county, SUM(workers) FROM community_health_workers WHERE region = 'Midwest' GROUP BY county;
gretelai_synthetic_text_to_sql
CREATE TABLE CommunityPolicing (id INT, district VARCHAR(20), event_date DATE);
How many community policing events were held in each district in the last year, ordered by the highest number of events?
SELECT district, COUNT(*) as num_events FROM CommunityPolicing WHERE event_date >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR) GROUP BY district ORDER BY num_events DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Events (id INT PRIMARY KEY, name VARCHAR(30), year INT, artistic_genre VARCHAR(30), attendees INT); INSERT INTO Events (id, name, year, artistic_genre, attendees) VALUES (1, 'Dance Performance', 2022, 'Dance', 100); INSERT INTO Events (id, name, year, artistic_genre, attendees) VALUES (2, 'Music Concert', ...
Which artistic_genre had the highest number of attendees in 2022?
SELECT artistic_genre, MAX(attendees) FROM Events WHERE year = 2022 GROUP BY artistic_genre;
gretelai_synthetic_text_to_sql
CREATE TABLE research_grants (grant_id INT, student_id INT, dept_name VARCHAR(50), funding_source VARCHAR(50), grant_amount INT, grant_date DATE);
What is the distribution of research grants by funding source, and what is the total amount of funding received from each source in the past year, broken down by department?
SELECT funding_source, dept_name, COUNT(*) as num_grants, SUM(grant_amount) as total_funding FROM research_grants WHERE grant_date >= DATE_SUB(CURRENT_DATE(), INTERVAL 1 YEAR) GROUP BY funding_source, dept_name;
gretelai_synthetic_text_to_sql
CREATE TABLE emissions (year INT, co2_emission FLOAT);
What is the total CO2 emission per year in the 'emissions' table?
SELECT year, SUM(co2_emission) FROM emissions GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE age_groups (age_group VARCHAR(50), total_donations DECIMAL(10,2)); INSERT INTO age_groups (age_group, total_donations) VALUES ('18-24', 15000.00), ('25-34', 30000.00), ('35-44', 25000.00), ('45-54', 20000.00), ('55-65', 10000.00);
What is the percentage of total donations made by donors in each age group in the effective altruism movement?
SELECT age_group, (total_donations / SUM(total_donations) OVER()) * 100 AS percentage FROM age_groups;
gretelai_synthetic_text_to_sql
CREATE TABLE Menu (id INT PRIMARY KEY, dish VARCHAR(255), diet VARCHAR(255)); INSERT INTO Menu (id, dish, diet) VALUES (1, 'Quinoa Salad', 'Vegan'), (2, 'Tofu Stir Fry', 'Vegan'), (3, 'Chicken Caesar Salad', 'None'), (4, 'Vegetable Curry', 'Vegan');
Determine the number of 'Vegan' dishes in the 'Menu' table
SELECT COUNT(*) FROM Menu WHERE diet = 'Vegan';
gretelai_synthetic_text_to_sql
CREATE TABLE Unions (UnionID INT, UnionName TEXT); CREATE TABLE Agreements (AgreementID INT, UnionID INT, AgreementDate DATE);
What is the maximum number of collective bargaining agreements signed by a single union in a year?
SELECT u.UnionName, YEAR(a.AgreementDate) AS AgreementYear, MAX(COUNT(a.AgreementID)) AS MaxAgreementsPerYear FROM Unions u INNER JOIN Agreements a ON u.UnionID = a.UnionID GROUP BY u.UnionName, AgreementYear;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_adaptation_eo (project_name VARCHAR(50), location VARCHAR(50), status VARCHAR(50), funding_source VARCHAR(50)); INSERT INTO climate_adaptation_eo (project_name, location, status, funding_source) VALUES ('Resilient Cities', 'Europe', 'Successful', 'GCF'), ('Green Infrastructure', 'Europe', 'Successf...
Find the number of climate adaptation projects in Europe and Oceania that have been successful and their respective funding sources.
SELECT location, status, funding_source FROM climate_adaptation_eo WHERE location IN ('Europe', 'Oceania') AND status = 'Successful';
gretelai_synthetic_text_to_sql
CREATE SCHEMA Research; CREATE TABLE Projects (id INT, name TEXT, start_date DATE, end_date DATE, budget FLOAT);
Identify the number of marine life research projects and their respective budgets in the last 3 years.
SELECT COUNT(*), SUM(budget) FROM Research.Projects WHERE start_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE HospitalBeds (HealthCenterID INT, State VARCHAR(20), Beds INT); INSERT INTO HospitalBeds (HealthCenterID, State, Beds) VALUES (1, 'Illinois', 50); INSERT INTO HospitalBeds (HealthCenterID, State, Beds) VALUES (2, 'Illinois', 75);
What is the minimum number of hospital beds in health centers in Illinois?
SELECT MIN(Beds) FROM HospitalBeds WHERE State = 'Illinois';
gretelai_synthetic_text_to_sql
CREATE TABLE KenyanAthletes (AthleteID INT, Name VARCHAR(50), Age INT, Sport VARCHAR(20), Country VARCHAR(50)); INSERT INTO KenyanAthletes (AthleteID, Name, Age, Sport, Country) VALUES (1, 'Faith Kipyegon', 28, 'Athletics', 'Kenya'); INSERT INTO KenyanAthletes (AthleteID, Name, Age, Sport, Country) VALUES (2, 'Eliud Ki...
What is the age and sport ranking of athletes from Kenya?
SELECT AthleteID, Name, Age, Sport, ROW_NUMBER() OVER (PARTITION BY Country ORDER BY Age, Sport) AS AgeSportRank FROM KenyanAthletes;
gretelai_synthetic_text_to_sql
CREATE TABLE habitats (id INT, name VARCHAR(255));CREATE TABLE animals (id INT, species_id INT, habitat_id INT);CREATE TABLE species (id INT, name VARCHAR(255)); INSERT INTO habitats (id, name) VALUES (1, 'Forest'), (2, 'Savannah'); INSERT INTO animals (id, species_id, habitat_id) VALUES (1, 1, 2), (2, 2, 1), (3, 3, 2)...
Identify habitats with more than 50 animals and the number of species in each
SELECT h.name AS habitat_name, COUNT(DISTINCT a.species_id) AS species_count FROM animals a INNER JOIN habitats h ON a.habitat_id = h.id GROUP BY h.name HAVING COUNT(a.id) > 50;
gretelai_synthetic_text_to_sql
CREATE TABLE Projects (id INT, name TEXT, location TEXT, capacity FLOAT, type TEXT, PRIMARY KEY (id)); INSERT INTO Projects (id, name, location, capacity, type) VALUES (1, 'Solar Farm A', 'California', 50.0, 'Solar'), (2, 'Wind Farm B', 'Texas', 100.0, 'Wind'); CREATE TABLE Funding (id INT, project_id INT, source TEXT,...
Find projects without funding sources.
SELECT Projects.name FROM Projects LEFT JOIN Funding ON Projects.id = Funding.project_id WHERE Funding.source IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE city_complaints (complaint_id INT, city_name VARCHAR(50), complaint_date DATE); INSERT INTO city_complaints VALUES (1, 'CityA', '2021-01-05'), (2, 'CityB', '2021-01-10'), (3, 'CityA', '2021-01-20'), (4, 'CityC', '2021-01-25'), (5, 'CityB', '2021-01-30');
How many complaints were submitted in each city in January 2021?
SELECT city_name, COUNT(*) as num_complaints FROM city_complaints WHERE complaint_date >= '2021-01-01' AND complaint_date < '2021-02-01' GROUP BY city_name;
gretelai_synthetic_text_to_sql
CREATE TABLE Policy (PolicyNumber INT, CoverageType VARCHAR(50)); CREATE TABLE Claim (ClaimNumber INT, PolicyNumber INT, ClaimAmount INT); INSERT INTO Policy (PolicyNumber, CoverageType) VALUES (1, 'Home'); INSERT INTO Policy (PolicyNumber, CoverageType) VALUES (2, 'Auto'); INSERT INTO Claim (ClaimNumber, PolicyNumber,...
What is the average claim amount for policies in the 'Home' coverage type?
SELECT AVG(ClaimAmount) FROM Claim JOIN Policy ON Claim.PolicyNumber = Policy.PolicyNumber WHERE Policy.CoverageType = 'Home';
gretelai_synthetic_text_to_sql
CREATE TABLE production_figure (well_name VARCHAR(255), daily_production_rate INT);
Show the highest daily production rate in the 'production_figure' table
SELECT MAX(daily_production_rate) FROM production_figure;
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, donor_id INT, donation_amount DECIMAL(10,2), donation_state TEXT, donation_date DATE);
What is the average donation amount in 'donations' table for the state of New York?
SELECT AVG(donation_amount) FROM donations WHERE donation_state = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE researchers ( id INT PRIMARY KEY, name VARCHAR(255), title VARCHAR(255)); INSERT INTO researchers (id, name, title) VALUES (1, 'Alice', 'Professor'); INSERT INTO researchers (id, name, title) VALUES (2, 'Bob', 'Dr.'); CREATE TABLE expeditions ( id INT PRIMARY KEY, name VARCHAR(255), year INT, location VARC...
What is the maximum number of expeditions led by a researcher in a single year?
SELECT year, COUNT(DISTINCT name) as num_expeditions FROM expeditions JOIN researchers ON expeditions.leader_id = researchers.id GROUP BY year HAVING num_expeditions > 1 ORDER BY num_expeditions DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Orders (order_id INT, product_id INT, revenue FLOAT); INSERT INTO Orders (order_id, product_id, revenue) VALUES (1, 1, 50.0), (2, 2, 30.0), (3, 3, 20.0), (4, 1, 45.0), (5, 3, 25.0); CREATE TABLE Products (product_id INT, name VARCHAR(255), category VARCHAR(255), material_id INT); INSERT INTO Products (prod...
What percentage of the total revenue comes from accessories made of recycled materials?
SELECT (SUM(CASE WHEN Materials.is_recycled THEN Orders.revenue ELSE 0 END) / SUM(Orders.revenue)) * 100 AS percentage FROM Orders INNER JOIN Products ON Orders.product_id = Products.product_id INNER JOIN Materials ON Products.material_id = Materials.material_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Trams (tram_id INT, region VARCHAR(20), maintenance_frequency INT); INSERT INTO Trams (tram_id, region, maintenance_frequency) VALUES (501, 'Harborside', 45), (502, 'Harborside', 60), (503, 'Harborside', 30);
What is the minimum maintenance frequency for trams in the 'Harborside' region?
SELECT MIN(maintenance_frequency) FROM Trams WHERE region = 'Harborside';
gretelai_synthetic_text_to_sql
CREATE TABLE ResourceExtraction(id INT, country VARCHAR(50), extraction_date DATE, amount INT);
What is the average amount of resources extracted per day in Canada and Australia?
SELECT country, AVG(amount) AS Avg_Amount FROM ResourceExtraction WHERE country IN ('Canada', 'Australia') AND extraction_date >= DATEADD(day, -365, CURRENT_DATE) GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE game_design (game_id INT, game_name VARCHAR(50), genre VARCHAR(20), revenue FLOAT, vr_compatible BOOLEAN); INSERT INTO game_design (game_id, game_name, genre, revenue, vr_compatible) VALUES (1, 'Elite Dangerous', 'Space Sim', 50.0, true), (2, 'Witcher 3', 'RPG', 120.0, false), (3, 'Half-Life: Alyx', 'Actio...
Show the total revenue of games designed for VR.
SELECT SUM(revenue) FROM game_design WHERE vr_compatible = true;
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (transaction_id INT, customer_id INT, product_id INT, category_id INT, transaction_date DATE, amount DECIMAL(10,2), payment_method VARCHAR(50)); CREATE TABLE customers (customer_id INT, age INT, gender VARCHAR(10), location VARCHAR(255));
What is the average daily transaction value for the last week, split by customer location and payment method?
SELECT c.location, t.payment_method, AVG(t.amount) as avg_daily_transaction_value FROM transactions t INNER JOIN customers c ON t.customer_id = c.customer_id WHERE t.transaction_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK) GROUP BY c.location, t.payment_method;
gretelai_synthetic_text_to_sql
CREATE TABLE MiningSites (site_id INT, site_name VARCHAR(50), location VARCHAR(50), water_consumed DECIMAL(10, 2));
Insert a new mining site 'Site C' located in 'Colorado' with an initial water consumption of 2000.
INSERT INTO MiningSites (site_name, location, water_consumed) VALUES ('Site C', 'Colorado', 2000);
gretelai_synthetic_text_to_sql
CREATE TABLE financial_wellbeing_canada (id INT, gender VARCHAR(10), score INT); INSERT INTO financial_wellbeing_canada (id, gender, score) VALUES (1, 'Female', 65), (2, 'Male', 75), (3, 'Male', 80);
What is the maximum financial wellbeing score for men in Canada?
SELECT MAX(score) FROM financial_wellbeing_canada WHERE gender = 'Male';
gretelai_synthetic_text_to_sql
CREATE TABLE faculty (id INT, name VARCHAR(50), department VARCHAR(50)); CREATE TABLE grants (id INT, title VARCHAR(100), faculty_id INT);
List the names of faculty members who have not received any research grants.
SELECT faculty.name FROM faculty LEFT JOIN grants ON faculty.id = grants.faculty_id WHERE grants.faculty_id IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE first_practiced (id INT, art VARCHAR(255), year INT, country VARCHAR(255)); INSERT INTO first_practiced (id, art, year, country) VALUES (1, 'Adinkra', 1600, 'Ghana'), (2, 'Udu', 1500, 'Nigeria');
What is the minimum year when a traditional art was first practiced in Africa?
SELECT MIN(year) FROM first_practiced WHERE country LIKE 'Africa%';
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_type TEXT, production_country TEXT); INSERT INTO products (product_id, product_type, production_country) VALUES (1, 'Lipstick', 'USA'), (2, 'Eyeshadow', 'China'), (3, 'Lipstick', 'France');
What is the percentage of lipsticks that are made in the USA?
SELECT (COUNT(*) FILTER (WHERE production_country = 'USA')) * 100.0 / COUNT(*) FROM products WHERE product_type = 'Lipstick';
gretelai_synthetic_text_to_sql
CREATE TABLE RenewableEnergy (id INT, project_name VARCHAR(20), energy_source VARCHAR(20), capacity INT); INSERT INTO RenewableEnergy (id, project_name, energy_source, capacity) VALUES (1, 'SolarFarm1', 'solar', 5000), (2, 'WindFarm1', 'wind', 6000), (3, 'GeothermalPlant1', 'geothermal', 4000);
Delete all records in the "RenewableEnergy" table where the "energy_source" is "solar"
DELETE FROM RenewableEnergy WHERE energy_source = 'solar';
gretelai_synthetic_text_to_sql
CREATE TABLE ProgramCategories (CategoryID INT, Category VARCHAR(20)); INSERT INTO ProgramCategories (CategoryID, Category) VALUES (1, 'Education'), (2, 'Health'), (3, 'Environment'); CREATE TABLE Budget (ProgramID INT, CategoryID INT, Amount DECIMAL(10,2)); INSERT INTO Budget (ProgramID, CategoryID, Amount) VALUES (10...
What's the total budget allocated to each program category?
SELECT pc.Category, SUM(b.Amount) AS TotalBudget FROM ProgramCategories pc JOIN Budget b ON pc.CategoryID = b.CategoryID GROUP BY pc.Category;
gretelai_synthetic_text_to_sql
CREATE TABLE alternative_dispute_resolution (id INT, case_number INT, participant_name VARCHAR(255), service_type VARCHAR(255)); INSERT INTO alternative_dispute_resolution (id, case_number, participant_name, service_type) VALUES (1, 1234, 'Amy Lee', 'Mediation');
Who received 'Mediation' services in the 'alternative_dispute_resolution' table?
SELECT participant_name FROM alternative_dispute_resolution WHERE service_type = 'Mediation';
gretelai_synthetic_text_to_sql
CREATE TABLE otas (id INT PRIMARY KEY, hotel_id INT, bookings INT, booking_date DATE, ota_name VARCHAR(255));
Which OTA had the highest number of bookings in 'Brazil' in Q2 2021?
SELECT ota_name, MAX(bookings) FROM otas WHERE country = 'Brazil' AND EXTRACT(QUARTER FROM booking_date) = 2 AND EXTRACT(YEAR FROM booking_date) = 2021 GROUP BY ota_name;
gretelai_synthetic_text_to_sql
CREATE TABLE menu (menu_id INT, menu_name VARCHAR(255), is_vegan BOOLEAN, cost_ingredients DECIMAL(5,2)); INSERT INTO menu (menu_id, menu_name, is_vegan, cost_ingredients) VALUES (1, 'Vegan Tacos', TRUE, 7.50), (2, 'Chickpea Curry', TRUE, 6.25), (3, 'Beef Burger', FALSE, 8.75), (4, 'Fish and Chips', FALSE, 9.25); CREAT...
Show the total cost of ingredients for vegan menu items in the North region.
SELECT SUM(cost_ingredients * inventory_quantity) as total_cost FROM menu JOIN inventory ON menu.menu_id = inventory.menu_id WHERE is_vegan = TRUE AND region = 'North';
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, name TEXT, email TEXT); INSERT INTO customers (customer_id, name, email) VALUES (1, 'John Doe', '[john.doe@gmail.com](mailto:john.doe@gmail.com)'), (2, 'Jane Smith', '[jane.smith@yahoo.com](mailto:jane.smith@yahoo.com)'); CREATE TABLE orders (order_id INT, customer_id INT, suppl...
Determine the number of unique customers who have purchased organic products from 'Farm Fresh Organics' in Sydney, Australia.
SELECT COUNT(DISTINCT customers.customer_id) FROM customers JOIN orders ON customers.customer_id = orders.customer_id JOIN organic_products ON orders.supplier_id = organic_products.supplier_id JOIN suppliers ON orders.supplier_id = suppliers.supplier_id WHERE suppliers.name = 'Farm Fresh Organics' AND organic_products....
gretelai_synthetic_text_to_sql
CREATE TABLE flights(flight_id INT, origin TEXT, destination TEXT, year INT, distance INT, CO2_emissions INT);INSERT INTO flights (flight_id, origin, destination, year, distance, CO2_emissions) VALUES (1, 'New York', 'Delhi', 2019, 7487, 374350), (2, 'Los Angeles', 'Mumbai', 2019, 8078, 403900), (3, 'Chicago', 'Bangalo...
What is the total CO2 emissions for flights between the United States and India in 2019?
SELECT SUM(CO2_emissions) FROM flights WHERE origin IN ('New York', 'Los Angeles', 'Chicago', 'San Francisco') AND destination IN ('Delhi', 'Mumbai', 'Bangalore', 'Hyderabad') AND year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE mining_operations (id INT, equipment_type VARCHAR(20), operation_date DATE, quantity INT); INSERT INTO mining_operations (id, equipment_type, operation_date, quantity) VALUES (1, 'Modern Drill', '2021-01-01', 100), (2, 'Archaic Drill', '2020-12-31', 25), (3, 'Modern Drill', '2020-12-30', 150);
Delete records from the 'mining_operations' table where the 'equipment_type' is 'Archaic Drill'
DELETE FROM mining_operations WHERE equipment_type = 'Archaic Drill';
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (vessel_id VARCHAR(10), port_id VARCHAR(10)); INSERT INTO vessels (vessel_id, port_id) VALUES ('vessel_z', 'port_a'), ('vessel_x', 'port_b'), ('vessel_y', 'port_c');
Which ports does vessel_z travel to?
SELECT DISTINCT port_id FROM vessels WHERE vessel_id = 'vessel_z';
gretelai_synthetic_text_to_sql
CREATE TABLE CommunityHealthWorkers (WorkerID INT, Name VARCHAR(50), Specialty VARCHAR(50)); CREATE TABLE Cases (WorkerID INT, CaseID INT, CaseType VARCHAR(20)); INSERT INTO CommunityHealthWorkers (WorkerID, Name, Specialty) VALUES (1, 'John Doe', 'Mental Health'); INSERT INTO CommunityHealthWorkers (WorkerID, Name, Sp...
Show the number of mental health and physical health cases managed by community health workers.
SELECT Specialty, COUNT(*) FROM Cases GROUP BY Specialty;
gretelai_synthetic_text_to_sql
CREATE TABLE funds (company_id INT, funding_amount DECIMAL(10, 2), funding_date DATE); INSERT INTO funds VALUES (1, 500000, '2022-01-01'); INSERT INTO funds VALUES (2, 300000, '2021-06-15');
Find the total funding received by companies with female founders in the last 5 years
SELECT SUM(funding_amount) FROM funds INNER JOIN companies ON funds.company_id = companies.company_id WHERE companies.founder_gender = 'Female' AND funds.funding_date BETWEEN DATEADD(year, -5, GETDATE()) AND GETDATE();
gretelai_synthetic_text_to_sql
CREATE TABLE teams (team_id INT, team_name VARCHAR(100)); CREATE TABLE innings (inning_id INT, team_id INT, runs INT);
What is the average number of runs scored per inning by each team in the IPL?
SELECT teams.team_name, AVG(innings.runs) as avg_runs_per_inning FROM teams INNER JOIN innings ON teams.team_id = innings.team_id GROUP BY teams.team_name;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (id INT, name VARCHAR(255), location VARCHAR(255), population INT); INSERT INTO marine_species (id, name, location, population) VALUES (1, 'Species A', 'Coral Triangle', 1000); INSERT INTO marine_species (id, name, location, population) VALUES (2, 'Species B', 'Great Barrier Reef', 2000); IN...
What is the total number of marine species in the Coral Triangle and the Great Barrier Reef?
SELECT SUM(population) FROM marine_species WHERE location IN ('Coral Triangle', 'Great Barrier Reef');
gretelai_synthetic_text_to_sql
CREATE TABLE programs (id INT, name VARCHAR(255)); INSERT INTO programs (id, name) VALUES (1, 'Education'), (2, 'Health'), (3, 'Environment'); CREATE TABLE volunteer_hours (id INT, program_id INT, volunteer_date DATE, hours INT); INSERT INTO volunteer_hours (id, program_id, volunteer_date, hours) VALUES (1, 1, '2022-01...
What is the total number of volunteer hours for each program, by quarter?
SELECT program_id, DATE_TRUNC('quarter', volunteer_date) AS quarter, SUM(hours) OVER (PARTITION BY program_id, quarter) AS total_volunteer_hours FROM volunteer_hours;
gretelai_synthetic_text_to_sql
CREATE TABLE salaries (id INT, salary DECIMAL(10, 2), training VARCHAR(255)); INSERT INTO salaries (id, salary, training) VALUES (1, 50000, 'completed'), (2, 55000, 'in progress'), (3, 60000, 'not started');
Calculate the average salary of employees who have completed diversity and inclusion training.
SELECT AVG(salary) FROM salaries WHERE training = 'completed';
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (volunteer_id INT, cause VARCHAR(20)); INSERT INTO volunteers (volunteer_id, cause) VALUES (1, 'education'), (2, 'environment'), (3, 'health'), (4, 'education');
Find the total number of volunteers who have worked on the 'education' and 'health' causes.
SELECT COUNT(*) FROM volunteers WHERE cause IN ('education', 'health');
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, age INT, gender TEXT); INSERT INTO users (id, age, gender) VALUES (1, 25, 'male'), (2, 35, 'non-binary'), (3, 30, 'female'), (4, 45, 'male'), (5, 50, 'non-binary');
What is the percentage of male users?
SELECT (COUNT(CASE WHEN gender = 'male' THEN 1 END) * 100.0 / COUNT(*)) as male_percentage FROM users;
gretelai_synthetic_text_to_sql
CREATE TABLE union_members (id INT, name VARCHAR(50), occupation VARCHAR(50), union_member BOOLEAN, salary FLOAT); INSERT INTO union_members (id, name, occupation, union_member, salary) VALUES (1, 'John Doe', 'Engineer', true, 85000.00), (2, 'Jane Smith', 'Engineer', false, 72000.00), (3, 'Mike Johnson', 'Clerk', true,...
Delete all records with a salary above 80000 from the 'union_members' table
DELETE FROM union_members WHERE salary > 80000;
gretelai_synthetic_text_to_sql
CREATE TABLE community_development (id INT, region VARCHAR(50), initiative_type VARCHAR(50), start_date DATE, end_date DATE); INSERT INTO community_development (id, region, initiative_type, start_date, end_date) VALUES (1, 'Patagonia', 'Library', '2015-01-01', '2016-12-31');
How many community development initiatives were completed in the region of Patagonia between 2015 and 2017?
SELECT COUNT(*) FROM community_development WHERE region = 'Patagonia' AND start_date <= '2017-12-31' AND end_date >= '2015-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE revenue_sustainable_materials (id INT, garment_type VARCHAR(50), revenue DECIMAL(5, 2), sustainable_material BOOLEAN); INSERT INTO revenue_sustainable_materials (id, garment_type, revenue, sustainable_material) VALUES (1, 'Pants', 25000, true); INSERT INTO revenue_sustainable_materials (id, garment_type, r...
What is the total revenue of men's garments made of sustainable materials?
SELECT SUM(revenue) FROM revenue_sustainable_materials WHERE garment_type LIKE '%Men%' AND sustainable_material = true;
gretelai_synthetic_text_to_sql
CREATE TABLE Aircraft (id INT, name VARCHAR(50), engines INT, manufacturer VARCHAR(50)); INSERT INTO Aircraft (id, name, engines, manufacturer) VALUES (1, 'Boeing 747', 4); INSERT INTO Aircraft (id, name, engines, manufacturer) VALUES (2, 'Airbus A320', 2); INSERT INTO Aircraft (id, name, engines, manufacturer) VALUES ...
List all aircraft in the Aircraft table with more than 2 engines.
SELECT * FROM Aircraft WHERE engines > 2;
gretelai_synthetic_text_to_sql
CREATE TABLE cybersecurity_incidents (id INT, title VARCHAR(255), description TEXT, region VARCHAR(255), countermeasure TEXT);INSERT INTO cybersecurity_incidents (id, title, description, region, countermeasure) VALUES (1, 'Incident A', 'Details about Incident A', 'Asia-Pacific', 'Countermeasure A'), (2, 'Incident B', '...
List all cybersecurity incidents that occurred in the Asia-Pacific region, including their details and the countermeasures taken.
SELECT * FROM cybersecurity_incidents WHERE region = 'Asia-Pacific';
gretelai_synthetic_text_to_sql
CREATE TABLE member_registration (member_id INT, registration_date DATE); INSERT INTO member_registration VALUES (8,'2022-02-20'); INSERT INTO member_registration VALUES (9,'2022-02-21'); CREATE TABLE workouts (workout_id INT, member_id INT, date DATE);
Insert new records for members who joined in the last day and have not yet attended a workout.
INSERT INTO workouts (workout_id, member_id, date) SELECT seq.member_id, seq.member_id, GETDATE() FROM (SELECT member_registration.member_id, ROW_NUMBER() OVER (ORDER BY member_registration.registration_date DESC) AS row_num FROM member_registration WHERE member_registration.registration_date >= DATEADD(day, -1, GETDAT...
gretelai_synthetic_text_to_sql
CREATE TABLE diversity (id INT PRIMARY KEY AUTO_INCREMENT, company_id INT, metric VARCHAR(255), value FLOAT, diversity_date DATE);
Update the diversity metric "Women in Executive Roles" to 0.40 for "GreenTech Solutions"
UPDATE diversity SET value = 0.40 WHERE metric = 'Women in Executive Roles' AND company_id IN (SELECT id FROM company WHERE name = 'GreenTech Solutions');
gretelai_synthetic_text_to_sql
CREATE TABLE delivery (delivery_id INT, organization VARCHAR(100), delivery_date DATE); INSERT INTO delivery (delivery_id, organization, delivery_date) VALUES (1, 'Org A', '2022-01-01'), (2, 'Org B', '2022-01-05'), (3, 'Org A', '2022-01-10');
What is the average number of days between delivery dates for each organization?
SELECT organization, AVG(DATEDIFF(d2.delivery_date, d1.delivery_date)) FROM delivery d1 JOIN delivery d2 ON d1.organization = d2.organization AND d1.delivery_date < d2.delivery_date GROUP BY organization;
gretelai_synthetic_text_to_sql
CREATE TABLE landfill_capacity (country TEXT, capacity INTEGER, year INTEGER);
What is the total landfill capacity in the US and Canada, as of 2022?
SELECT SUM(capacity) FROM landfill_capacity WHERE country IN ('USA', 'Canada') AND year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE physician_practices (id INT PRIMARY KEY, name TEXT, state TEXT, total_doctors INT); INSERT INTO physician_practices (id, name, state, total_doctors) VALUES (1, 'Practice 1', 'TX', 10), (2, 'Practice 2', 'NY', 15), (3, 'Practice 3', 'FL', 20);
Update the "physician_practices" table to reflect the correct "total_doctors" for the practice with id 2
UPDATE physician_practices SET total_doctors = 20 WHERE id = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE Attorneys (AttorneyID INT PRIMARY KEY, LawSchool VARCHAR(255), Wins INT, Losses INT); INSERT INTO Attorneys (AttorneyID, LawSchool, Wins, Losses) VALUES (1, 'Harvard', 5, 2), (2, 'Yale', 4, 1), (3, 'Harvard', 6, 1);
What is the success rate for attorneys from a specific law school?
SELECT LawSchool, (SUM(Wins) / (SUM(Wins) + SUM(Losses))) AS SuccessRate FROM Attorneys GROUP BY LawSchool HAVING LawSchool = 'Harvard';
gretelai_synthetic_text_to_sql
CREATE TABLE organic_farms (id INT, crop VARCHAR(255), is_organic BOOLEAN, acres DECIMAL(10,2), yield DECIMAL(10,2));
What is the total number of acres and average yield for organic crops in the 'organic_farms' table?
SELECT SUM(acres) as total_acres, AVG(yield) as avg_yield FROM organic_farms WHERE is_organic = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE Farm (id INT, species TEXT, weight FLOAT, age INT); INSERT INTO Farm (id, species, weight, age) VALUES (1, 'Tilapia', 500.3, 2), (2, 'Salmon', 300.1, 1), (3, 'Tilapia', 600.5, 3), (4, 'Salmon', 700.2, 4), (5, 'Salmon', 800.1, 5);
What is the maximum age of the fish in the 'Salmon' species?
SELECT MAX(age) FROM Farm WHERE species = 'Salmon';
gretelai_synthetic_text_to_sql
CREATE TABLE astronaut_medical (id INT, astronaut_name TEXT, last_check TEXT); INSERT INTO astronaut_medical (id, astronaut_name, last_check) VALUES (1, 'Maria', 'unsuccessful'), (2, 'James', 'successful');
Update the medical records of astronaut Maria to show her last medical check as successful.
UPDATE astronaut_medical SET last_check = 'successful' WHERE astronaut_name = 'Maria';
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (donation_id INT, org_id INT, donation_amount DECIMAL(10,2));
What is the average donation amount for each organization in the 'Donations' and 'Organizations' tables?
SELECT O.name, AVG(D.donation_amount) FROM Donations D INNER JOIN Organizations O ON D.org_id = O.org_id GROUP BY O.name;
gretelai_synthetic_text_to_sql
CREATE TABLE Languages (language_id INT, language_name TEXT);CREATE TABLE CommunityHealthWorkers (worker_id INT, worker_language INT, worker_age INT);
What is the average age of community health workers who speak a language other than English?
SELECT AVG(worker_age) FROM CommunityHealthWorkers cwh WHERE worker_language IN (SELECT language_id FROM Languages WHERE language_name != 'English');
gretelai_synthetic_text_to_sql
CREATE TABLE teachers (teacher_id INT, teacher_name VARCHAR(50), gender VARCHAR(50)); CREATE TABLE professional_development (pd_id INT, teacher_id INT, program_name VARCHAR(50), topic VARCHAR(50)); INSERT INTO teachers (teacher_id, teacher_name, gender) VALUES (1, 'John Doe', 'Male'), (2, 'Jane Smith', 'Female'), (3, '...
What is the number of teachers who have participated in open pedagogy workshops by gender?
SELECT gender, COUNT(DISTINCT teachers.teacher_id) as num_teachers FROM teachers INNER JOIN professional_development ON teachers.teacher_id = professional_development.teacher_id WHERE professional_development.topic = 'Open Pedagogy' GROUP BY gender;
gretelai_synthetic_text_to_sql
CREATE TABLE multilateral_development_banks(project_id INT, project_name TEXT, sector TEXT, amount_funded FLOAT);
What's the difference in funding between climate mitigation and climate adaptation projects by multilateral development banks?
SELECT SUM(CASE WHEN sector = 'climate mitigation' THEN amount_funded ELSE 0 END) - SUM(CASE WHEN sector = 'climate adaptation' THEN amount_funded ELSE 0 END) FROM multilateral_development_banks WHERE sector IN ('climate mitigation', 'climate adaptation');
gretelai_synthetic_text_to_sql
CREATE TABLE family_cases (case_id INT, case_type VARCHAR(20), billing_amount FLOAT, case_date DATE); INSERT INTO family_cases (case_id, case_type, billing_amount, case_date) VALUES (1, 'Family', 4000.0, '2021-01-01'), (2, 'Family', 6000.0, '2021-02-01'), (3, 'Family', 5000.0, '2021-03-01');
What is the total billing amount for family cases in the last 6 months?
SELECT SUM(billing_amount) FROM family_cases WHERE case_type = 'Family' AND case_date >= DATE_SUB(CURDATE(), INTERVAL 6 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE game_stats (game_id INT, name VARCHAR(50), genre VARCHAR(20), release_date DATE, total_sales INT, avg_playtime DECIMAL(5,2));
What is the average playtime of sports games released in 2021?
SELECT AVG(avg_playtime) FROM game_stats WHERE genre = 'Sports' AND YEAR(release_date) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE indigenous_farming (farmer_id INT, practice VARCHAR(50), region VARCHAR(50)); INSERT INTO indigenous_farming (farmer_id, practice, region) VALUES (1, 'Monoculture', 'Amazon'), (2, 'Permaculture', 'Andes'), (3, 'Permaculture', 'Andes'), (4, 'Monoculture', 'Amazon');
How many indigenous farmers practice 'Permaculture' in each region in the 'indigenous_farming' table?
SELECT region, COUNT(farmer_id) as num_permaculture_farmers FROM indigenous_farming WHERE practice = 'Permaculture' GROUP BY region;
gretelai_synthetic_text_to_sql