context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE Graduate_Students (id INT, name VARCHAR(50), department VARCHAR(50)); INSERT INTO Graduate_Students (id, name, department) VALUES (1, 'Brian', 'Mathematics'); CREATE TABLE Publications (id INT, student_id INT, year INT, title VARCHAR(100)); INSERT INTO Publications (id, student_id, year, title) VALUES (1, ...
What is the number of publications by graduate students in the Mathematics department each year?
SELECT year, COUNT(*) FROM Publications JOIN Graduate_Students ON Publications.student_id = Graduate_Students.id WHERE Graduate_Students.department = 'Mathematics' GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE FinancialCapability (id INT, org_name VARCHAR(50), location VARCHAR(50), training_hours INT, start_date DATE, end_date DATE);
What is the total financial capability training hours provided by each organization in Latin America between 2017 and 2019, ordered by total hours?
SELECT org_name, SUM(training_hours) as total_hours FROM FinancialCapability WHERE location LIKE '%Latin America%' AND start_date BETWEEN '2017-01-01' AND '2019-12-31' GROUP BY org_name ORDER BY total_hours DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE AircraftManufacturing (aircraft_id INT, model VARCHAR(255), manufacturer VARCHAR(255), manufacturing_date DATE, country VARCHAR(255));
List all aircraft models manufactured by AviaCorp in Canada before 2000-01-01.
SELECT model FROM AircraftManufacturing WHERE manufacturer = 'AviaCorp' AND manufacturing_date < '2000-01-01' AND country = 'Canada';
gretelai_synthetic_text_to_sql
create table incidents (id int, date date, sector varchar(255)); insert into incidents values (1, '2021-01-01', 'retail'); insert into incidents values (2, '2021-01-05', 'retail'); insert into incidents values (3, '2021-01-10', 'financial services'); insert into incidents values (4, '2021-04-15', 'financial services');...
What is the total number of security incidents for each sector in the last quarter?
SELECT sector, COUNT(*) FROM incidents WHERE date >= '2021-01-01' AND date < '2021-04-01' GROUP BY sector; SELECT sector, COUNT(*) FROM incidents WHERE date >= '2021-04-01' AND date < '2021-07-01' GROUP BY sector; SELECT sector, COUNT(*) FROM incidents WHERE date >= '2021-07-01' AND date < '2021-10-01' GROUP BY sector;...
gretelai_synthetic_text_to_sql
CREATE TABLE hospitals (id INT, name TEXT, state TEXT, hospital_type TEXT, num_beds INT); INSERT INTO hospitals (id, name, state, hospital_type, num_beds) VALUES (1, 'General Hospital', 'California', 'Acute Care', 300), (2, 'Specialty Hospital', 'California', 'Rehabilitation', 150), (3, 'Teaching Hospital', 'California...
What is the total number of hospitals in the state of California, grouped by hospital type?
SELECT hospital_type, COUNT(*) as total FROM hospitals WHERE state = 'California' GROUP BY hospital_type;
gretelai_synthetic_text_to_sql
CREATE TABLE rd_expenditure (drug_name TEXT, disease_area TEXT, rd_cost INTEGER); INSERT INTO rd_expenditure (drug_name, disease_area, rd_cost) VALUES ('DrugA', 'Oncology', 20000000), ('DrugB', 'Cardiovascular', 15000000), ('DrugC', 'Oncology', 30000000), ('DrugD', 'Neurology', 25000000);
What is the average R&D expenditure for drugs in each disease area?
SELECT disease_area, AVG(rd_cost) FROM rd_expenditure GROUP BY disease_area;
gretelai_synthetic_text_to_sql
CREATE TABLE Events (EventID INT, Category VARCHAR(50)); INSERT INTO Events (EventID, Category) VALUES (1, 'Music'), (2, 'Theater'), (3, 'Dance');
Delete the event 'Dance Recital' from the Events table
DELETE FROM Events WHERE Category = 'Dance';
gretelai_synthetic_text_to_sql
CREATE TABLE olympic_medals (id INT, athlete VARCHAR(50), country VARCHAR(50), medal VARCHAR(50)); INSERT INTO olympic_medals (id, athlete, country, medal) VALUES (1, 'Neeraj Chopra', 'India', 'Gold'); INSERT INTO olympic_medals (id, athlete, country, medal) VALUES (2, 'PV Sindhu', 'India', 'Bronze');
What is the total number of medals won by Indian athletes in the 'olympic_medals' table?
SELECT COUNT(*) FROM olympic_medals WHERE country = 'India';
gretelai_synthetic_text_to_sql
CREATE TABLE genres (genre_id INTEGER, genre VARCHAR(255)); INSERT INTO genres (genre_id, genre) VALUES (1, 'Pop'), (2, 'Rock'), (3, 'Jazz'), (4, 'Classical');
Update the genre table to add a new genre 'Folk' with a genre_id of 5.
INSERT INTO genres (genre_id, genre) VALUES (5, 'Folk');
gretelai_synthetic_text_to_sql
CREATE TABLE co_ownership(id INT, city TEXT, cost FLOAT); INSERT INTO co_ownership(id, city, cost) VALUES (1, 'Seattle', 500000.00);
What is the average co-ownership cost in Seattle?
SELECT AVG(cost) FROM co_ownership WHERE city = 'Seattle';
gretelai_synthetic_text_to_sql
CREATE TABLE exomoons (id INT, name VARCHAR(255), planet_type VARCHAR(255), orbital_period FLOAT); CREATE VIEW gas_giant_exomoons AS SELECT * FROM exomoons WHERE planet_type = 'gas giant';
What is the maximum orbital period for exomoons orbiting gas giants?
SELECT MAX(orbital_period) FROM gas_giant_exomoons;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_projects (country VARCHAR(50), project_type VARCHAR(50), year INT); INSERT INTO climate_projects (country, project_type, year) VALUES ('Saudi Arabia', 'climate mitigation', 2015), ('Iran', 'climate mitigation', 2016), ('Turkey', 'climate mitigation', 2015);
What is the average number of climate mitigation projects per year for each country in the Middle East?
SELECT country, AVG(year) FROM climate_projects WHERE project_type = 'climate mitigation' GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE FluData (Year INT, Region VARCHAR(20), Cases INT); INSERT INTO FluData (Year, Region, Cases) VALUES (2018, 'North America', 5000); INSERT INTO FluData (Year, Region, Cases) VALUES (2020, 'South America', 3000);
Find the number of Influenza cases reported in South America in 2020.
SELECT SUM(Cases) FROM FluData WHERE Region = 'South America' AND Year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE military_sales (id INT, year INT, customer VARCHAR(20), equipment_type VARCHAR(20), value FLOAT); INSERT INTO military_sales (id, year, customer, equipment_type, value) VALUES (1, 2018, 'European Union', 'Naval Vessels', 12000000); INSERT INTO military_sales (id, year, customer, equipment_type, value) VALU...
What was the total value of naval vessel sales to the European Union in 2018?
SELECT SUM(value) FROM military_sales WHERE year = 2018 AND customer = 'European Union' AND equipment_type = 'Naval Vessels';
gretelai_synthetic_text_to_sql
CREATE TABLE streams (song VARCHAR(255), location VARCHAR(255), streams INT); INSERT INTO streams (song, location, streams) VALUES ('Take Me Home, Country Roads', 'Texas', 1200), ('Hotel California', 'California', 1800), ('Hotel California', 'New York', 1500);
How many streams did 'Hotel California' get in total?
SELECT SUM(streams) FROM streams WHERE song = 'Hotel California';
gretelai_synthetic_text_to_sql
CREATE TABLE Textiles (brand VARCHAR(20), fabric_type VARCHAR(20), quantity INT); INSERT INTO Textiles (brand, fabric_type, quantity) VALUES ('Eco-friendly Fashions', 'Organic Cotton', 1500), ('Eco-friendly Fashions', 'Recycled Polyester', 2000), ('Fab Fashions', 'Recycled Polyester', 1000), ('Fab Fashions', 'Hemp', 80...
Show the total quantity of all sustainable fabrics used in the 'Textiles' table, grouped by brand.
SELECT brand, SUM(quantity) FROM Textiles WHERE fabric_type IN ('Organic Cotton', 'Recycled Polyester', 'Hemp') GROUP BY brand;
gretelai_synthetic_text_to_sql
CREATE TABLE FairnessResearchers (id INT, name VARCHAR(255), age INT, project VARCHAR(255));
What is the minimum age of any AI researcher working on projects related to algorithmic fairness?
SELECT MIN(age) FROM FairnessResearchers WHERE project LIKE '%algorithmic fairness%';
gretelai_synthetic_text_to_sql
CREATE TABLE garments (id INT, name VARCHAR(255), category VARCHAR(255), country VARCHAR(255)); INSERT INTO garments (id, name, category, country) VALUES (1, 'Eco-friendly T-shirt', 'Tops', 'Germany');
What is the average quantity of 'Eco-friendly T-shirts' sold per order in Germany?
SELECT AVG(quantity) FROM orders INNER JOIN garments ON orders.garment_id = garments.id WHERE garments.name = 'Eco-friendly T-shirt' AND garments.country = 'Germany';
gretelai_synthetic_text_to_sql
CREATE TABLE tourism_revenue (id INT, destination VARCHAR, region VARCHAR, revenue FLOAT, year INT); INSERT INTO tourism_revenue (id, destination, region, revenue, year) VALUES (1, 'Machu Picchu', 'South America', 12000000, 2020);
What is the total tourism revenue for South America in 2020?
SELECT SUM(revenue) FROM tourism_revenue WHERE region = 'South America' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE LandfillCapacity (country VARCHAR(255), landfill_capacity_cubic_meters DECIMAL(15,2), region VARCHAR(255)); INSERT INTO LandfillCapacity (country, landfill_capacity_cubic_meters, region) VALUES ('France', 15000000.0, 'Europe'), ('Germany', 21000000.0, 'Europe'), ('Italy', 12000000.0, 'Europe');
What is the total landfill capacity in the European region in cubic meters?
SELECT SUM(landfill_capacity_cubic_meters) FROM LandfillCapacity WHERE region = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE hotel_segment_ratings (hotel_id INT, segment VARCHAR(20), guest_rating FLOAT);
Which hotels in the 'eco' segment have the lowest guest satisfaction ratings?
SELECT hotel_id, segment, AVG(guest_rating) as avg_rating FROM hotel_segment_ratings WHERE segment = 'eco' GROUP BY hotel_id ORDER BY avg_rating ASC;
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers(id INT PRIMARY KEY, name VARCHAR(50), certified_date DATE, certification_expiration_date DATE); INSERT INTO suppliers(id, name, certified_date, certification_expiration_date) VALUES (1, 'Supplier A', '2020-01-01', '2022-12-31'), (2, 'Supplier B', '2019-06-15', '2021-06-14'), (3, 'Supplier C', '20...
Determine the number of days between the certification expiration date and the current date for each supplier.
SELECT name, certification_expiration_date, CURRENT_DATE, certification_expiration_date - CURRENT_DATE AS days_left FROM suppliers;
gretelai_synthetic_text_to_sql
CREATE TABLE Cases (CaseID int, Outcome varchar(10)); INSERT INTO Cases VALUES (1, 'Won'), (2, 'Lost'), (3, 'Won'); CREATE TABLE Billing (BillingID int, CaseID int, Amount decimal(10,2)); INSERT INTO Billing VALUES (1, 1, 5000.00), (2, 1, 7000.00), (3, 2, 3000.00), (4, 3, 4000.00);
What is the average billing amount for cases with a specific outcome?
SELECT AVG(B.Amount) as AvgBilling FROM Billing B INNER JOIN Cases C ON B.CaseID = C.CaseID WHERE C.Outcome = 'Won';
gretelai_synthetic_text_to_sql
CREATE TABLE Budget (Program varchar(50), Allocation numeric(10,2)); INSERT INTO Budget (Program, Allocation) VALUES ('ProgramA', 5000.00), ('ProgramB', 3000.00), ('ProgramC', 2000.00);
What is the total budget allocated to ProgramC, and what percentage of the total budget does it represent?
SELECT Program, Allocation, (Allocation / SUM(Allocation) OVER ()) * 100 AS BudgetPercentage FROM Budget WHERE Program = 'ProgramC';
gretelai_synthetic_text_to_sql
CREATE SCHEMA sa_schema;CREATE TABLE sa_schema.waste_management_budget (year INT, service VARCHAR(20), amount INT);INSERT INTO sa_schema.waste_management_budget (year, service, amount) VALUES (2020, 'Waste Management', 10000000);
What is the total budget allocated for waste management services in South Africa in 2020?
SELECT amount FROM sa_schema.waste_management_budget WHERE year = 2020 AND service = 'Waste Management';
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists biosensor_types;CREATE TABLE if not exists biosensor_types.sensors (id INT, name VARCHAR(100), continent VARCHAR(50));INSERT INTO biosensor_types.sensors (id, name, continent) VALUES (1, 'TypeA', 'Africa'), (2, 'TypeB', 'South America'), (3, 'TypeA', 'Africa'), (4, 'TypeC', 'South America');
What are the most common types of biosensors used in Africa and South America?
SELECT continent, name, COUNT(*) as count FROM biosensor_types.sensors GROUP BY continent, name ORDER BY continent, count DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE policyholders (id INT, name TEXT, state TEXT); CREATE TABLE policies (id INT, policyholder_id INT, issue_date DATE, claim_amount FLOAT); INSERT INTO policyholders (id, name, state) VALUES (1, 'Emily Wong', 'NY'); INSERT INTO policies (id, policyholder_id, issue_date, claim_amount) VALUES (1, 1, '2017-12-31...
Find the maximum claim amount for policyholders living in 'New York' who have policies issued before '2018-01-01'.
SELECT MAX(claim_amount) FROM policies INNER JOIN policyholders ON policies.policyholder_id = policyholders.id WHERE issue_date < '2018-01-01' AND policyholders.state = 'NY';
gretelai_synthetic_text_to_sql
CREATE TABLE wildlife (species VARCHAR(255), population INT, year INT); INSERT INTO wildlife (species, population, year) VALUES ('Tiger', 500, 2019), ('Tiger', 550, 2020), ('Tiger', 600, 2021), ('Elephant', 3000, 2019), ('Elephant', 3200, 2020), ('Elephant', 3400, 2021), ('Lemur', 100, 2019), ('Lemur', 110, 2020), ('Le...
What is the wildlife population trend for each species between 2019 and 2021?
SELECT species, (population_2021 - population_2019) as population_change FROM (SELECT species, MAX(CASE WHEN year = 2021 THEN population END) as population_2021, MAX(CASE WHEN year = 2019 THEN population END) as population_2019 FROM wildlife GROUP BY species) as population_changes;
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name TEXT, region TEXT, founder_race TEXT); INSERT INTO companies (id, name, region, founder_race) VALUES (1, 'Startup A', 'west_coast', 'asian'), (2, 'Startup B', 'east_coast', 'white'), (3, 'Startup C', 'west_coast', 'latinx'), (4, 'Startup D', 'east_coast', 'black'), (5, 'Startup E', ...
Find the number of startups founded by underrepresented racial or ethnic groups in each region
SELECT region, COUNT(*) FROM companies WHERE founder_race IN ('asian', 'black', 'latinx', 'native_american') GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE investments (id INT, category VARCHAR(255), amount FLOAT); INSERT INTO investments (id, category, amount) VALUES (1, 'environmental sustainability', 50000), (2, 'social equity', 35000), (3, 'environmental sustainability', 75000);
What is the maximum investment amount made in the environmental sustainability category?
SELECT MAX(amount) FROM investments WHERE category = 'environmental sustainability';
gretelai_synthetic_text_to_sql
CREATE TABLE sales_africa (sale_id INT, garment_type VARCHAR(50), sale_date DATE, total_sales DECIMAL(10, 2), region VARCHAR(50));
What is the average price of each garment type in the Africa region in Q2 2022?
SELECT garment_type, AVG(total_sales / (SELECT SUM(total_quantity) FROM sales_africa sa WHERE sa.garment_type = s.garment_type AND sa.sale_date = s.sale_date)) FROM sales_africa s WHERE sale_date BETWEEN '2022-04-01' AND '2022-06-30' AND region = 'Africa' GROUP BY garment_type;
gretelai_synthetic_text_to_sql
CREATE TABLE hospitals (id INT, name VARCHAR(50), state VARCHAR(25), num_beds INT); INSERT INTO hospitals (id, name, state, num_beds) VALUES (1, 'Hospital A', 'Texas', 60), (2, 'Hospital B', 'Texas', 30), (3, 'Hospital C', 'California', 75);
What is the maximum number of beds in a hospital in California?
SELECT MAX(num_beds) FROM hospitals WHERE state = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE military_equipment_sales (company VARCHAR(255), region VARCHAR(255), year INT, cost INT); INSERT INTO military_equipment_sales (company, region, year, cost) VALUES ('General Dynamics', 'Americas', 2020, 2000000);
What is the minimum cost of military equipment sold by General Dynamics to the Americas in 2020?
SELECT MIN(cost) FROM military_equipment_sales WHERE company = 'General Dynamics' AND region = 'Americas' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE patient (patient_id INT, age INT, gender VARCHAR(50), state VARCHAR(50), condition VARCHAR(50)); INSERT INTO patient (patient_id, age, gender, state, condition) VALUES (1, 35, 'Female', 'Texas', 'Depression'); INSERT INTO patient (patient_id, age, gender, state, condition) VALUES (2, 42, 'Male', 'Californi...
What is the total duration of therapy received by patients with depression?
SELECT SUM(treatment.duration) FROM patient INNER JOIN treatment ON patient.patient_id = treatment.patient_id WHERE patient.condition = 'Depression';
gretelai_synthetic_text_to_sql
CREATE TABLE FarmStock (farm_id INT, date DATE, action VARCHAR(10), quantity INT); INSERT INTO FarmStock (farm_id, date, action, quantity) VALUES (3, '2022-01-01', 'added', 300), (3, '2022-01-05', 'removed', 50);
Find the total number of fish added and removed from the Shrimp farm each month in 2022
SELECT EXTRACT(MONTH FROM date) month, SUM(CASE WHEN action = 'added' THEN quantity ELSE -quantity END) quantity FROM FarmStock WHERE farm_id = 3 AND YEAR(date) = 2022 GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE Emissions (chemical VARCHAR(20), emission_rate INT, location VARCHAR(20)); INSERT INTO Emissions (chemical, emission_rate, location) VALUES ('ChemicalA', 100, 'Southeast'), ('ChemicalB', 120, 'Southeast');
Which chemical has the highest emission rate in the Southeast region?
SELECT chemical, emission_rate FROM Emissions WHERE location = 'Southeast' ORDER BY emission_rate DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Request (RequestID INT, RequestDate DATE, City VARCHAR(50), RequestType VARCHAR(50)); INSERT INTO Request (RequestID, RequestDate, City, RequestType) VALUES (1, '2021-01-01', 'San Francisco', 'Disability Support'); INSERT INTO Request (RequestID, RequestDate, City, RequestType) VALUES (2, '2021-02-15', 'Ne...
List the top 5 cities with the highest number of disability support requests in the past year.
SELECT City, COUNT(*) AS Requests FROM Request WHERE RequestType = 'Disability Support' AND RequestDate >= DATEADD(YEAR, -1, GETDATE()) GROUP BY City ORDER BY Requests DESC FETCH FIRST 5 ROWS ONLY;
gretelai_synthetic_text_to_sql
CREATE TABLE ArtifactsByCountry (Country TEXT, ArtifactType TEXT, Quantity INT); INSERT INTO ArtifactsByCountry (Country, ArtifactType, Quantity) VALUES ('France', 'Pottery', 50), ('France', 'Bronze Tools', 30), ('Germany', 'Pottery', 75), ('Germany', 'Iron Weapons', 60);
What are the top 3 most common artifact types found in France and Germany?
SELECT Country, ArtifactType, Quantity FROM ArtifactsByCountry WHERE Country IN ('France', 'Germany') GROUP BY ArtifactType ORDER BY SUM(Quantity) DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name VARCHAR(255), sector VARCHAR(255), ESG_score FLOAT); INSERT INTO companies (id, name, sector, ESG_score) VALUES (1, 'Pfizer', 'Healthcare', 72.5); INSERT INTO companies (id, name, sector, ESG_score) VALUES (2, 'Johnson & Johnson', 'Healthcare', 76.8); INSERT INTO companies (id, name...
Which companies in the healthcare sector have an ESG score below 70?
SELECT name FROM companies c JOIN sectors s ON c.sector = s.sector WHERE s.sector = 'Healthcare' AND c.ESG_score < 70;
gretelai_synthetic_text_to_sql
CREATE TABLE sales_data (sale_id INT, product_category VARCHAR(255), region VARCHAR(255), sale_quantity INT, sale_amount DECIMAL(10,2), sale_date DATE);
What are the total sales and quantity of each product category sold in the NY region for the year 2021?
SELECT region, product_category, SUM(sale_quantity) AS quantity_sold, SUM(sale_amount) AS sales_amount FROM sales_data WHERE region = 'NY' AND YEAR(sale_date) = 2021 GROUP BY region, product_category;
gretelai_synthetic_text_to_sql
CREATE TABLE songs (song_id INT, title VARCHAR(100), release_year INT, rating FLOAT); INSERT INTO songs (song_id, title, release_year, rating) VALUES (1, 'Gangnam Style', 2012, 4.5), (2, 'Boy With Luv', 2019, 4.7), (3, 'Dynamite', 2020, 4.6);
Insert a new K-pop song 'Butter' with a rating of 4.8 and a 2021 release.
INSERT INTO songs (title, release_year, rating) VALUES ('Butter', 2021, 4.8);
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (id INT, species_name VARCHAR(50), habitat_depth FLOAT); INSERT INTO marine_species (id, species_name, habitat_depth) VALUES (1, 'Green Sea Turtle', 50.0), (2, 'Clownfish', 20.0), (3, 'Bottlenose Dolphin', 100.0), (4, 'Blue Whale', 300.0);
Display the average maximum depth of all marine species habitats in the 'marine_species' table.
SELECT AVG(habitat_depth) AS avg_max_depth FROM marine_species;
gretelai_synthetic_text_to_sql
CREATE TABLE ports (port_id INT, port_name TEXT, country TEXT);CREATE TABLE visits (visit_id INT, vessel_id INT, port_id INT, visit_date DATE);
How many vessels visited each port in the US in the last 3 months?
SELECT ports.port_name, COUNT(visits.vessel_id) as num_visits FROM ports JOIN visits ON ports.port_id = visits.port_id WHERE ports.country = 'US' AND visits.visit_date BETWEEN DATEADD(month, -3, CURRENT_DATE) AND CURRENT_DATE GROUP BY ports.port_name;
gretelai_synthetic_text_to_sql
CREATE TABLE green_buildings (id INT, name VARCHAR(255), state VARCHAR(255), energy_efficiency_rating FLOAT, construction_date DATE);
What is the average energy efficiency rating of green buildings in the state of Texas, for buildings constructed after 2015?
SELECT AVG(energy_efficiency_rating) AS avg_rating FROM green_buildings WHERE state = 'Texas' AND YEAR(construction_date) > 2015;
gretelai_synthetic_text_to_sql
CREATE TABLE public_transport (id INT, vehicle_type VARCHAR(255), passenger_capacity INT); INSERT INTO public_transport (id, vehicle_type, passenger_capacity) VALUES (1, 'Tram', 300);
What is the maximum passenger capacity of public transport in the "public_transport" table?
SELECT MAX(passenger_capacity) FROM public_transport WHERE vehicle_type = 'Tram';
gretelai_synthetic_text_to_sql
CREATE TABLE players (player_id INT, age INT, country VARCHAR(50), vr_owner BOOLEAN); CREATE TABLE esports_participants (participant_id INT, player_id INT); CREATE TABLE esports_events (event_id INT, location VARCHAR(50));
What is the maximum age of players who own a VR headset and have participated in esports events in North America?
SELECT MAX(players.age) FROM players INNER JOIN esports_participants ON players.player_id = esports_participants.player_id INNER JOIN (SELECT event_id FROM esports_events WHERE location = 'North America') AS north_america_events ON esports_participants.player_id = north_america_events.event_id WHERE players.vr_owner = ...
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, name VARCHAR(100), is_organic BOOLEAN, sustainability_rating FLOAT); INSERT INTO products (product_id, name, is_organic, sustainability_rating) VALUES (1, 'Nourishing Face Cream', true, 4.2), (2, 'Hydrating Body Lotion', false, 3.5);
What is the average sustainability rating for organic products?
SELECT AVG(sustainability_rating) FROM products WHERE is_organic = true;
gretelai_synthetic_text_to_sql
CREATE TABLE VirtualTourRevenue(id INT, country TEXT, revenue FLOAT); INSERT INTO VirtualTourRevenue(id, country, revenue) VALUES (1, 'United States', 5000.0), (2, 'Canada', 3000.0), (3, 'Mexico', 2000.0);
What is the revenue generated from virtual tours in each country?
SELECT country, SUM(revenue) FROM VirtualTourRevenue GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE diagnoses (patient_id INT, diagnosis VARCHAR(20)); INSERT INTO diagnoses (patient_id, diagnosis) VALUES (1, 'PTSD'), (2, 'Anxiety'), (3, 'Depression');
What is the total number of patients who have been diagnosed with a mental health condition?
SELECT COUNT(*) FROM diagnoses;
gretelai_synthetic_text_to_sql
CREATE TABLE donors (donor_id INT PRIMARY KEY, first_name VARCHAR(50), last_name VARCHAR(50), email VARCHAR(100), donation_amount DECIMAL(10, 2), donation_date DATE);
Update the donation amount for donor_id 2001
UPDATE donors SET donation_amount = 550.00 WHERE donor_id = 2001;
gretelai_synthetic_text_to_sql
CREATE TABLE State.agencies (name VARCHAR(50), budget INT); INSERT INTO State.agencies (name, budget) VALUES ('Department of Transportation', 2000000), ('Department of Education', 1500000), ('Department of Health', 3000000), ('Department of Public Safety', 1200000), ('Department of Human Services', 2500000);
Find the names of all government agencies that have a budget higher than the average budget for all agencies in the 'State' schema.
SELECT name FROM State.agencies WHERE budget > (SELECT AVG(budget) FROM State.agencies);
gretelai_synthetic_text_to_sql
CREATE TABLE Archaeological_Tools (id INT PRIMARY KEY, name VARCHAR(255), type TEXT, age INT); INSERT INTO Archaeological_Tools (id, name, type, age) VALUES (1, 'Metal Trowel', 'Digging', 5), (2, 'Brush', 'Cleaning', 2), (3, 'Total Station', 'Measurement', 8);
List all archaeological tools of a specific type
SELECT * FROM Archaeological_Tools WHERE type = 'Digging';
gretelai_synthetic_text_to_sql
CREATE TABLE budget_allocation (city VARCHAR(255), service VARCHAR(255), fiscal_year INT, initial_budget DECIMAL(10,2), revised_budget DECIMAL(10,2)); INSERT INTO budget_allocation (city, service, fiscal_year, initial_budget, revised_budget) VALUES ('Los Angeles', 'Education', 2022, 5000000.00, 5500000.00), ('Los Angel...
What is the total budget allocated for education and healthcare services in the city of Los Angeles, for the fiscal year 2022, considering both initial and revised budgets?
SELECT city, service, initial_budget + revised_budget as total_budget FROM budget_allocation WHERE city = 'Los Angeles' AND fiscal_year = 2022 AND service IN ('Education', 'Healthcare')
gretelai_synthetic_text_to_sql
CREATE TABLE cybersecurity_strategies (id INT, strategy_name VARCHAR(255), implementation_date DATE, region VARCHAR(255)); INSERT INTO cybersecurity_strategies (id, strategy_name, implementation_date, region) VALUES (1, 'Strategy 1', '2017-01-01', 'Africa'), (2, 'Strategy 2', '2018-05-15', 'Africa');
List all cybersecurity strategies and their corresponding implementation dates in Africa, sorted by implementation date in ascending order.
SELECT * FROM cybersecurity_strategies WHERE region = 'Africa' ORDER BY implementation_date ASC;
gretelai_synthetic_text_to_sql
CREATE TABLE spacecraft(id INT, name VARCHAR(255), propulsion_type VARCHAR(255)); INSERT INTO spacecraft(id, name, propulsion_type) VALUES (1, 'Starship', 'Raptor'), (2, 'Falcon Heavy', 'Merlin');
What is the most common type of propulsion system used in SpaceX spacecraft?
SELECT propulsion_type, COUNT(*) as count FROM spacecraft GROUP BY propulsion_type ORDER BY count DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE fish_farms (id INT, name TEXT, location TEXT, water_type TEXT); INSERT INTO fish_farms (id, name, location, water_type) VALUES (1, 'Farm S', 'Jakarta', 'Saltwater'); INSERT INTO fish_farms (id, name, location, water_type) VALUES (2, 'Farm T', 'Bangkok', 'Freshwater'); CREATE TABLE fish_species (id INT, nam...
What is the average dissolved oxygen level for each fish species in our farms located in Southeast Asia?
SELECT fs.name AS species_name, AVG(wq.dissolved_oxygen) AS avg_dissolved_oxygen FROM fish_farms ff JOIN fish_species fs ON TRUE JOIN water_quality wq ON ff.id = wq.fish_farm_id AND fs.id = wq.fish_species_id WHERE ff.location LIKE '%%Southeast Asia%%' GROUP BY fs.name;
gretelai_synthetic_text_to_sql
CREATE TABLE circular_economy_initiatives (region VARCHAR(20), year INT, spending INT); INSERT INTO circular_economy_initiatives (region, year, spending) VALUES ('North', 2020, 875000), ('North', 2021, 925000), ('South', 2020, 725000), ('South', 2021, 775000);
What was the circular economy initiative spending in the 'North' region in 2021?
SELECT spending FROM circular_economy_initiatives WHERE region = 'North' AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE rural_infrastructure (id INT, state VARCHAR(50), cost FLOAT, project_type VARCHAR(50), start_date DATE); INSERT INTO rural_infrastructure (id, state, cost, project_type, start_date) VALUES (1, 'Odisha', 75000.00, 'Bridge Construction', '2019-01-01');
What was the maximum cost of a rural infrastructure project in the state of Odisha in 2019?
SELECT MAX(cost) FROM rural_infrastructure WHERE state = 'Odisha' AND start_date >= '2019-01-01' AND start_date < '2020-01-01' AND project_type = 'Bridge Construction';
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_energy_projects (id INT PRIMARY KEY, project_type VARCHAR(50), status VARCHAR(20));
Update the 'status' column to 'completed' for all wind energy projects in the 'renewable_energy_projects' table
UPDATE renewable_energy_projects SET status = 'completed' WHERE project_type = 'wind energy';
gretelai_synthetic_text_to_sql
CREATE TABLE Customers (CustomerID INT, Name TEXT, Country TEXT, IsVegetarian BOOLEAN); CREATE TABLE Orders (OrderID INT, MenuItemID INT, CustomerID INT, Quantity INT); CREATE TABLE MenuItems (MenuItemID INT, Name TEXT, IsVegetarian BOOLEAN, Country TEXT);
Identify the top 3 most ordered vegetarian dishes in each country.
SELECT Country, Name, SUM(Quantity) AS TotalOrdered FROM Customers INNER JOIN Orders ON Customers.CustomerID = Orders.CustomerID INNER JOIN MenuItems ON Orders.MenuItemID = MenuItems.MenuItemID WHERE IsVegetarian = TRUE GROUP BY Country, Name ORDER BY Country, TotalOrdered DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE cities (id INT, city VARCHAR(50), population INT); INSERT INTO cities VALUES (1, 'CityX', 600000); INSERT INTO cities VALUES (2, 'CityY', 400000); INSERT INTO cities VALUES (3, 'CityZ', 550000); CREATE TABLE properties (id INT, city VARCHAR(50), coowners INT); INSERT INTO properties VALUES (1, 'CityX', 2);...
List all cities with a population over 500,000 that have co-owned properties
SELECT a.city FROM cities a INNER JOIN properties b ON a.city = b.city WHERE a.population > 500000 AND b.coowners > 1 GROUP BY a.city, b.city;
gretelai_synthetic_text_to_sql
CREATE TABLE revenue (restaurant_id INT, cuisine VARCHAR(255), revenue FLOAT); INSERT INTO revenue VALUES (1, 'Italian', 5000), (1, 'Mexican', 7000), (2, 'Italian', 6000), (2, 'Chinese', 8000);
What is the total revenue by cuisine type and restaurant?
SELECT cuisine, restaurant_id, SUM(revenue) as total_revenue FROM revenue GROUP BY cuisine, restaurant_id;
gretelai_synthetic_text_to_sql
CREATE TABLE community_development (community_development_id INT PRIMARY KEY, community_development_name VARCHAR(100), sector VARCHAR(50), country VARCHAR(50), region VARCHAR(50), start_date DATE, end_date DATE);
Insert new records for community development initiatives in 'Oceania' in the 'rural_development' database's 'community_development' table
INSERT INTO community_development (community_development_id, community_development_name, sector, country, region, start_date, end_date) VALUES (1, 'Oceania Community Empowerment Program', 'Community Development', 'Australia', 'Oceania', '2022-01-01', '2025-12-31'), (2, 'Pacific Islands Community Development Initiative'...
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (vessel_id INT, vessel_name VARCHAR(50), flag_state VARCHAR(50), vessel_type VARCHAR(50)); CREATE TABLE voyages (id INT, vessel_id INT, start_port_id INT, end_port_id INT, distance FLOAT, travel_time FLOAT, voyage_date DATE);
Find the average travel speed for each vessel, grouped by vessel type and month.
SELECT v.vessel_type, DATE_FORMAT(voyages.voyage_date, '%Y-%m') as time_period, AVG(voyages.distance/voyages.travel_time*24) as avg_speed FROM vessels JOIN voyages ON vessels.vessel_id = voyages.vessel_id GROUP BY v.vessel_type, time_period;
gretelai_synthetic_text_to_sql
CREATE TABLE Algorithms (AlgorithmId INT, Name TEXT, FairnessScore FLOAT, Country TEXT); INSERT INTO Algorithms (AlgorithmId, Name, FairnessScore, Country) VALUES (1, 'AlgorithmA', 0.8, 'Brazil'), (2, 'AlgorithmB', 0.9, 'Argentina'), (3, 'AlgorithmC', 0.7, 'Colombia');
Determine the average fairness score of algorithms in South America
SELECT AVG(FairnessScore) FROM Algorithms WHERE Country = 'South America';
gretelai_synthetic_text_to_sql
CREATE TABLE artists (artist_id INT, artist VARCHAR(100), genre VARCHAR(50)); CREATE TABLE concerts (concert_id INT, artist_id INT, date DATE);
What is the total number of concerts for each artist in the Rock genre, in the last 6 months?
SELECT a.artist, COUNT(c.concert_id) AS concert_count FROM artists a JOIN concerts c ON a.artist_id = c.artist_id WHERE a.genre = 'Rock' AND c.date >= DATEADD(month, -6, GETDATE()) GROUP BY a.artist;
gretelai_synthetic_text_to_sql
CREATE TABLE community_policing (id INT, district VARCHAR(20), event_type VARCHAR(20), date DATE); INSERT INTO community_policing (id, district, event_type, date) VALUES (1, 'East', 'Neighborhood Watch', '2022-02-01'); INSERT INTO community_policing (id, district, event_type, date) VALUES (2, 'West', 'Coffee with a Cop...
What is the total number of community policing events in the East district?
SELECT COUNT(*) FROM community_policing WHERE district = 'East';
gretelai_synthetic_text_to_sql
CREATE TABLE mental_health_parity (violation_id INT, date DATE, location VARCHAR(50), description VARCHAR(100)); INSERT INTO mental_health_parity (violation_id, date, location, description) VALUES (1, '2023-01-01', 'NY', 'Description 1'), (2, '2023-02-01', 'CA', 'Description 2'), (3, '2023-03-01', 'TX', 'Description 3'...
List all mental health parity violations that occurred in the last 6 months.
SELECT * FROM mental_health_parity WHERE date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE startups (id INT, name TEXT, location TEXT, founder_disability BOOLEAN, funding_amount INT); INSERT INTO startups (id, name, location, founder_disability, funding_amount) VALUES (1, 'Startup A', 'USA', true, 3000000); INSERT INTO startups (id, name, location, founder_disability, funding_amount) VALUES (2, ...
What is the average funding amount for startups founded by people with disabilities in the USA?
SELECT AVG(funding_amount) FROM startups WHERE location = 'USA' AND founder_disability = true;
gretelai_synthetic_text_to_sql
CREATE TABLE health_equity_metrics (state VARCHAR(50), score INT); INSERT INTO health_equity_metrics (state, score) VALUES ('California', 85), ('Texas', 75), ('New York', 90), ('Florida', 80), ('Illinois', 70);
Add a new health equity metric score of 82 for Florida?
INSERT INTO health_equity_metrics (state, score) VALUES ('Florida', 82);
gretelai_synthetic_text_to_sql
CREATE TABLE cases (case_id INT, open_date DATE); INSERT INTO cases (case_id, open_date) VALUES (1, '2020-01-01'); INSERT INTO cases (case_id, open_date) VALUES (2, '2020-02-15'); INSERT INTO cases (case_id, open_date) VALUES (3, '2019-12-31');
How many cases were opened in each month in 2020?
SELECT DATE_FORMAT(open_date, '%Y-%m') as month, COUNT(case_id) as cases_opened FROM cases WHERE YEAR(open_date) = 2020 GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE ticket_sales (id INT, game_date DATE, game_type VARCHAR(10), quantity INT);
What is the total number of tickets sold for all games in the last year, and what is the percentage that was sold for hockey games?
SELECT SUM(CASE WHEN game_type = 'hockey' THEN quantity ELSE 0 END) / SUM(quantity) * 100 as hockey_percentage FROM ticket_sales WHERE game_date >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE SpaceMissions (id INT, mission VARCHAR(255), year INT, altitude INT);
What is the maximum and minimum altitude reached by space missions in the last 10 years?
SELECT MAX(altitude) AS max_altitude, MIN(altitude) AS min_altitude FROM SpaceMissions WHERE year >= EXTRACT(YEAR FROM CURRENT_DATE) - 10;
gretelai_synthetic_text_to_sql
CREATE TABLE hourly_production (production_hour TIME, chemical VARCHAR(20), quantity INT); INSERT INTO hourly_production (production_hour, chemical, quantity) VALUES ('00:00:00', 'chemical E', 100); INSERT INTO hourly_production (production_hour, chemical, quantity) VALUES ('01:00:00', 'chemical E', 120);
What is the average quantity of chemical E produced per day?
SELECT date_format(production_hour, '%H') as hour, avg(quantity) as avg_quantity FROM hourly_production WHERE chemical = 'chemical E' GROUP BY hour;
gretelai_synthetic_text_to_sql
CREATE TABLE Cosmetics (id INT, brand VARCHAR(255), product VARCHAR(255), cruelty_free BOOLEAN, rating INT); INSERT INTO Cosmetics (id, brand, product, cruelty_free, rating) VALUES (1, 'Lush', 'Soak Stimulant Bath Bomb', true, 5), (2, 'The Body Shop', 'Born Lippy Strawberry Lip Balm', true, 4), (3, 'Estee Lauder', 'Adv...
What is the average cruelty-free rating for products in the cosmetics database?
SELECT AVG(rating) as average_rating FROM Cosmetics WHERE cruelty_free = true;
gretelai_synthetic_text_to_sql
CREATE TABLE patient (patient_id INT, patient_name TEXT, age INT, gender TEXT, diagnosis TEXT, location TEXT); INSERT INTO patient (patient_id, patient_name, age, gender, diagnosis, location) VALUES (1, 'John Doe', 55, 'Male', 'Heart Disease', 'Montana');
What is the minimum age of male patients who have been diagnosed with heart disease in the rural area of "Montana"?
SELECT MIN(age) FROM patient WHERE diagnosis = 'Heart Disease' AND gender = 'Male' AND location = 'Montana';
gretelai_synthetic_text_to_sql
CREATE TABLE rural_clinics (clinic_id INT, patients_per_day INT, year INT);
What is the maximum number of patients per day in rural_clinics in 2021?
SELECT MAX(patients_per_day) FROM rural_clinics WHERE year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE military_bases (base_name VARCHAR(255), country VARCHAR(255), personnel INT); INSERT INTO military_bases (base_name, country, personnel) VALUES ('Al Udeid Air Base', 'Qatar', 5000), ('Incirlik Air Base', 'Turkey', 4000), ('Ali Al Salem Air Base', 'Kuwait', 3500), ('Camp Arifjan', 'Kuwait', 2500);
Which military bases in the Middle East have more than 3000 personnel?
SELECT * FROM military_bases WHERE country LIKE 'Middle%' AND personnel > 3000;
gretelai_synthetic_text_to_sql
CREATE TABLE mining_operations (id INT, name VARCHAR(50), job_title VARCHAR(50), department VARCHAR(50), experience INT); INSERT INTO mining_operations (id, name, job_title, department, experience) VALUES (1, 'John Doe', 'Mining Engineer', 'Operations', 7); INSERT INTO mining_operations (id, name, job_title, department...
What is the total number of employees in the 'mining_operations' table, grouped by their job titles?
SELECT job_title, COUNT(*) as total_employees FROM mining_operations GROUP BY job_title;
gretelai_synthetic_text_to_sql
CREATE TABLE policyholders (policy_number INT, policyholder_name VARCHAR(50), policyholder_dob DATE);CREATE TABLE cars (policy_number INT, car_make VARCHAR(20));
Find the policy numbers, policyholder names, and birth dates for policyholders over 60 years old with a car make of 'Toyota'
SELECT p.policy_number, p.policyholder_name, p.policyholder_dob FROM policyholders p INNER JOIN cars c ON p.policy_number = c.policy_number WHERE DATEDIFF(year, p.policyholder_dob, GETDATE()) > 60 AND c.car_make = 'Toyota';
gretelai_synthetic_text_to_sql
CREATE TABLE ethical_ai (id INT, country VARCHAR(255), year INT, projects INT); INSERT INTO ethical_ai (id, country, year, projects) VALUES (1, 'USA', 2021, 50); INSERT INTO ethical_ai (id, country, year, projects) VALUES (2, 'Canada', 2021, 40); INSERT INTO ethical_ai (id, country, year, projects) VALUES (3, 'Mexico',...
What are the top 3 countries with the most ethical AI projects in 2021?
SELECT country, projects FROM ethical_ai WHERE year = 2021 ORDER BY projects DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE vip_ticket_prices (ticket_id INT, game_id INT, price DECIMAL(5,2));
Show the total revenue from VIP ticket sales for football games.
SELECT SUM(price * quantity) FROM vip_ticket_prices JOIN ticket_sales ON vip_ticket_prices.ticket_id = ticket_sales.ticket_id WHERE vip_ticket_prices.price > 100 AND (SELECT game_type FROM games WHERE games.game_id = ticket_sales.game_id) = 'Football';
gretelai_synthetic_text_to_sql
CREATE TABLE Infrastructure (id INT, project VARCHAR(255), location VARCHAR(255), year INT, cost INT); INSERT INTO Infrastructure (id, project, location, year, cost) VALUES (1, 'Bridge', 'Rural East', 2015, 1500000), (2, 'Road', 'Urban North', 2017, 5000000), (3, 'Water Supply', 'Rural South', 2016, 3000000), (4, 'Elec...
Calculate the average budget of rural infrastructure projects in the 'Infrastructure' table that started in 2017?
SELECT AVG(cost) as avg_cost FROM Infrastructure WHERE year = 2017;
gretelai_synthetic_text_to_sql
CREATE TABLE population (person_id INT, state VARCHAR(255), vaccinated BOOLEAN); INSERT INTO population (person_id, state, vaccinated) VALUES (1, 'FL', TRUE), (2, 'FL', FALSE), (3, 'NY', TRUE); CREATE TABLE census (state VARCHAR(255), population INT); INSERT INTO census (state, population) VALUES ('FL', 20000000), ('NY...
What is the percentage of the population in Florida that has been vaccinated against influenza?
SELECT (COUNT(*) * 100.0 / (SELECT population FROM census WHERE state = 'FL')) AS pct_vaccinated FROM population WHERE state = 'FL' AND vaccinated = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE Budget (Region VARCHAR(255), ServiceType VARCHAR(255), Budget DECIMAL(10,2)); INSERT INTO Budget (Region, ServiceType, Budget) VALUES ('North', 'Hospital', 30000), ('South', 'Hospital', 40000), ('East', 'Clinic', 25000), ('West', 'Hospital', 50000), ('North', 'Clinic', 20000);
What is the total budget allocated to each service type (hospital, clinic) in the North region?
SELECT ServiceType, SUM(Budget) AS TotalBudget FROM Budget WHERE Region = 'North' GROUP BY ServiceType;
gretelai_synthetic_text_to_sql
CREATE TABLE NBA_Matches (MatchID INT, HomeTeam VARCHAR(50), AwayTeam VARCHAR(50), HomeTeamScore INT, AwayTeamScore INT); INSERT INTO NBA_Matches (MatchID, HomeTeam, AwayTeam, HomeTeamScore, AwayTeamScore) VALUES (1, 'Chicago Bulls', 'Golden State Warriors', 142, 128);
Find the maximum number of points scored in a single game in NBA history?
SELECT MAX(HomeTeamScore + AwayTeamScore) FROM NBA_Matches;
gretelai_synthetic_text_to_sql
CREATE TABLE Sustainable_Projects (project_id INT, project_name VARCHAR(50), location VARCHAR(50), cost FLOAT); INSERT INTO Sustainable_Projects VALUES (3456, 'Wind Farm', 'California', 18000000);
List the names and costs of all sustainable building projects in California, ordered by cost in descending order.
SELECT project_name, cost FROM Sustainable_Projects WHERE location = 'California' ORDER BY cost DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE oceans (ocean_id INT, name VARCHAR(50), avg_depth DECIMAL(5,2)); INSERT INTO oceans VALUES (1, 'Atlantic', 3332), (2, 'Pacific', 4028);
What is the average depth of the Atlantic and Pacific oceans, grouped by ocean?
SELECT name, avg_depth FROM oceans WHERE name IN ('Atlantic', 'Pacific') GROUP BY name;
gretelai_synthetic_text_to_sql
CREATE TABLE CountrySite (SiteID INT, Country TEXT); INSERT INTO CountrySite (SiteID, Country) VALUES (1, 'Italy'), (2, 'France'), (3, 'Germany');
Which artifacts have been analyzed by researchers from the same country as the excavation site?
SELECT Artifacts.ArtifactID, Artifacts.AnalyzedBy FROM Artifacts INNER JOIN CountrySite ON Artifacts.Location = CountrySite.Country;
gretelai_synthetic_text_to_sql
CREATE TABLE StudentCounseling (StudentID INT, State VARCHAR(10), Counseling VARCHAR(50)); INSERT INTO StudentCounseling (StudentID, State, Counseling) VALUES (1, 'CO', 'Incomplete');
Delete all student records with incomplete mental health counseling information from 'Colorado'
DELETE FROM StudentCounseling WHERE State = 'Colorado' AND Counseling = 'Incomplete';
gretelai_synthetic_text_to_sql
CREATE TABLE savings (account_number INT, interest_rate DECIMAL(3, 2), customer_name VARCHAR(50), created_at TIMESTAMP);
Add a new row to the savings table with the following data: (301, 0.02, 'Aisha')
INSERT INTO savings (account_number, interest_rate, customer_name) VALUES (301, 0.02, 'Aisha');
gretelai_synthetic_text_to_sql
CREATE TABLE farm_locations (location VARCHAR, country VARCHAR, fish_id INT); CREATE TABLE fish_stock (fish_id INT, species VARCHAR, biomass FLOAT); INSERT INTO farm_locations (location, country, fish_id) VALUES ('Location A', 'USA', 1), ('Location B', 'Canada', 2), ('Location A', 'USA', 3), ('Location C', 'Mexico', 4)...
What is the total biomass of fish for each farming location, grouped by country?
SELECT fs.country, f.location, SUM(fs.biomass) FROM fish_stock fs JOIN farm_locations f ON fs.fish_id = f.fish_id GROUP BY fs.country, f.location;
gretelai_synthetic_text_to_sql
CREATE TABLE Inspections (Id INT, VesselId INT, InspectionDate DATETIME, Result VARCHAR(10)); INSERT INTO Inspections (Id, VesselId, InspectionDate, Result) VALUES (1, 1, '2021-01-01', 'Passed'); CREATE TABLE Cargo (Id INT, VoyageId INT, Type VARCHAR(50), Weight DECIMAL(10,2)); INSERT INTO Cargo (Id, VoyageId, Type, We...
What is the average cargo weight for vessels that have passed all inspections and loaded a specific type of cargo?
SELECT AVG(C.Weight) AS AverageWeight FROM Cargo C INNER JOIN (SELECT V.Id, COUNT(*) AS InspectionCount FROM Vessels V LEFT JOIN Inspections I ON V.Id = I.VesselId WHERE I.Result = 'Passed' GROUP BY V.Id) VE ON C.VoyageId = VE.Id WHERE C.Type = 'Liquefied Natural Gas' AND VE.InspectionCount = (SELECT MAX(InspectionCoun...
gretelai_synthetic_text_to_sql
CREATE TABLE community_education (id INT, animal_name VARCHAR(255), age INT, participated_in_education BOOLEAN);
What is the maximum age of the animals in the community_education table that have participated in educational programs?
SELECT MAX(age) FROM community_education WHERE participated_in_education = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_offset_programs (id INT, name VARCHAR(100), country VARCHAR(50)); INSERT INTO carbon_offset_programs (id, name, country) VALUES (1, 'Program 1', 'USA'), (2, 'Program 2', 'USA'), (3, 'Program 3', 'Canada');
Show the number of Carbon Offset Programs in the United States
SELECT COUNT(*) FROM carbon_offset_programs WHERE country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE gameactivity (player_id INT, game_id INT, game_region VARCHAR(50), joined_at TIMESTAMP); INSERT INTO gameactivity (player_id, game_id, game_region, joined_at) VALUES (1, 1001, 'APAC', '2022-01-01 10:00:00');
Find the top 3 games with the highest number of matches played
SELECT game_id, COUNT(DISTINCT player_id) as num_players, RANK() OVER (ORDER BY COUNT(DISTINCT player_id) DESC) as rank FROM gameactivity GROUP BY game_id
gretelai_synthetic_text_to_sql
CREATE TABLE construction_workers (id INT, name VARCHAR(50), age INT, state VARCHAR(50)); INSERT INTO construction_workers (id, name, age, state) VALUES (1, 'John Doe', 35, 'California'); INSERT INTO construction_workers (id, name, age, state) VALUES (2, 'Jane Smith', 40, 'California');
What is the average age of construction workers in California?
SELECT AVG(age) FROM construction_workers WHERE state = 'California'
gretelai_synthetic_text_to_sql
CREATE TABLE brand_sales (brand VARCHAR(255), sales FLOAT); INSERT INTO brand_sales (brand, sales) VALUES ('Brand A', 30000), ('Brand B', 25000), ('Brand C', 20000), ('Brand D', 15000), ('Brand E', 10000);
What is the market share of each brand in the ethical fashion industry?
SELECT brand, sales/SUM(sales) OVER() as market_share FROM brand_sales;
gretelai_synthetic_text_to_sql
CREATE TABLE campaigns (campaign_id INT, name VARCHAR(50), condition VARCHAR(50), budget INT); INSERT INTO campaigns (campaign_id, name, condition, budget) VALUES (1, 'Hope Rising', 'Depression', 50000); INSERT INTO campaigns (campaign_id, name, condition, budget) VALUES (2, 'Mind Matters', 'Anxiety', 75000);
List the names of campaigns and their corresponding budgets that are related to depression awareness.
SELECT campaigns.name, campaigns.budget FROM campaigns WHERE campaigns.condition = 'Depression';
gretelai_synthetic_text_to_sql
CREATE TABLE ports (id VARCHAR(20), name VARCHAR(20)); CREATE TABLE safety_incidents (id INT, port_id VARCHAR(20), incident_type VARCHAR(50), incident_date DATE); INSERT INTO ports (id, name) VALUES ('POR001', 'PORT001'), ('POR003', 'PORT003'), ('POR004', 'PORT004'); INSERT INTO safety_incidents (id, port_id, incident_...
List ports with safety incidents in 2019
SELECT ports.name FROM ports JOIN safety_incidents ON ports.id = safety_incidents.port_id WHERE YEAR(incident_date) = 2019;
gretelai_synthetic_text_to_sql