context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE providers (provider_id INT, name VARCHAR(50), zip_code VARCHAR(10));
Insert a new record into the "providers" table
INSERT INTO providers (provider_id, name, zip_code) VALUES (3, 'Dr. Garcia', '12345');
gretelai_synthetic_text_to_sql
CREATE TABLE warehouse (id INT, location VARCHAR(255)); INSERT INTO warehouse (id, location) VALUES (1, 'Seoul'), (2, 'Busan'); CREATE TABLE packages (id INT, warehouse_id INT, weight FLOAT, country VARCHAR(255)); INSERT INTO packages (id, warehouse_id, weight, country) VALUES (1, 1, 50.3, 'South Korea'), (2, 1, 30.1, ...
What is the total weight of packages shipped to South Korea, and how many were shipped?
SELECT country, SUM(weight) as total_weight, COUNT(*) as num_shipments FROM packages GROUP BY country HAVING country = 'South Korea';
gretelai_synthetic_text_to_sql
CREATE TABLE restorative_programs (program_id INT, state VARCHAR(20)); INSERT INTO restorative_programs (program_id, state) VALUES (1, 'New York'), (2, 'California');
What is the total number of restorative justice programs in the state of California?
SELECT COUNT(*) FROM restorative_programs WHERE state = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE materials (material_id INT, is_recycled BOOLEAN); INSERT INTO materials (material_id, is_recycled) VALUES (1, TRUE), (2, FALSE); CREATE TABLE production (production_id INT, material_id INT, quantity INT); INSERT INTO production (production_id, material_id, quantity) VALUES (1, 1, 100), (2, 2, 50);
Display the total quantity of materials used in production by recycled status
SELECT materials.is_recycled, SUM(production.quantity) FROM production INNER JOIN materials ON production.material_id = materials.material_id GROUP BY materials.is_recycled;
gretelai_synthetic_text_to_sql
CREATE TABLE Founders (id INT, name TEXT, gender TEXT); INSERT INTO Founders (id, name, gender) VALUES (1, 'Women Founders', 'Female'); CREATE TABLE Investments (company_id INT, investment_amount INT); INSERT INTO Investments (company_id, investment_amount) VALUES (1, 500000); INSERT INTO Investments (company_id, inves...
Show the total funding for companies founded by women, sorted by the most funding?
SELECT Companies.name, SUM(Investments.investment_amount) as total_funding FROM Companies JOIN Founders ON Companies.founder_id = Founders.id JOIN Investments ON Companies.id = Investments.company_id WHERE Founders.gender = 'Female' GROUP BY Companies.name ORDER BY total_funding DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Farm (id INT, name VARCHAR(50), country VARCHAR(50)); CREATE TABLE Species (id INT, name VARCHAR(50), scientific_name VARCHAR(50)); CREATE TABLE FarmSpecies (farm_id INT, species_id INT, biomass INT);
What is the total biomass of fish for each species in a specific aquaculture farm?
SELECT s.name, SUM(fs.biomass) FROM Species s JOIN FarmSpecies fs ON s.id = fs.species_id WHERE fs.farm_id = [some_farm_id] GROUP BY s.name;
gretelai_synthetic_text_to_sql
CREATE TABLE animal_population (id INT, animal_name VARCHAR(50), population INT);
What is the number of animals in 'animal_population' table that have a population of over 500?
SELECT animal_name FROM animal_population WHERE population > 500;
gretelai_synthetic_text_to_sql
CREATE TABLE mining_operations (id INT, mine_name TEXT, location TEXT, material TEXT, quantity INT, date DATE); INSERT INTO mining_operations (id, mine_name, location, material, quantity, date) VALUES (8, 'Nickel Nexus', 'China', 'nickel', 6000, '2018-01-01');
List all mines in China that mined nickel in 2018
SELECT DISTINCT mine_name FROM mining_operations WHERE material = 'nickel' AND location = 'China' AND date = '2018-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE policies (id INT, name TEXT, region TEXT, description TEXT); INSERT INTO policies (id, name, region, description) VALUES (1, 'Policy A', 'African Region', 'Improving healthcare access'); INSERT INTO policies (id, name, region, description) VALUES (2, 'Policy B', 'Asian Region', 'Reducing infectious disease...
What public health policies were implemented in the African region?
SELECT name, region, description FROM policies WHERE region = 'African Region';
gretelai_synthetic_text_to_sql
CREATE TABLE cases (case_id INT, attorney_name TEXT, case_outcome TEXT); INSERT INTO cases (case_id, attorney_name, case_outcome) VALUES (1, 'Alice Smith', 'won'), (2, 'Alice Smith', 'lost'), (3, 'Alice Smith', 'won');
How many cases did attorney 'Alice Smith' win?
SELECT COUNT(*) FROM cases WHERE attorney_name = 'Alice Smith' AND case_outcome = 'won';
gretelai_synthetic_text_to_sql
CREATE TABLE crimes (crime_id INT, year INT, age_group VARCHAR(255));
How many crimes were committed by age group in 2020?
SELECT age_group, COUNT(*) as total_crimes FROM crimes WHERE year = 2020 GROUP BY age_group;
gretelai_synthetic_text_to_sql
CREATE TABLE user_profiles (id INT, age INT, gender VARCHAR(10)); INSERT INTO user_profiles (id, age, gender) VALUES (1, 42, 'Female'), (2, 48, 'Male'), (3, 50, 'Non-binary'); CREATE TABLE daily_steps (id INT, user_id INT, steps INT, date DATE); INSERT INTO daily_steps (id, user_id, steps, date) VALUES (1, 1, 10000, '2...
What is the average number of steps taken per day for users aged 40-50, rounded to the nearest whole number?
SELECT ROUND(AVG(steps)) FROM daily_steps d JOIN user_profiles p ON d.user_id = p.id WHERE p.age BETWEEN 40 AND 50;
gretelai_synthetic_text_to_sql
CREATE TABLE military_spending (id INT, country VARCHAR(50), spending DECIMAL(10,2), year INT, gdp DECIMAL(10,2)); INSERT INTO military_spending (id, country, spending, year, gdp) VALUES (1, 'USA', 740000000.00, 2020, 21000000000.00); INSERT INTO military_spending (id, country, spending, year, gdp) VALUES (2, 'China', ...
What are the top 2 countries with the highest military spending as a percentage of their GDP in 2020?
SELECT country, (spending / gdp) * 100 as military_spending_percentage FROM military_spending WHERE year = 2020 ORDER BY military_spending_percentage DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (id INT, name TEXT, type TEXT);CREATE TABLE cargoes (id INT, vessel_id INT, tonnage INT, cargo_type TEXT); INSERT INTO vessels (id, name, type) VALUES (1, 'Tanker Master', 'Tanker'); INSERT INTO cargoes (id, vessel_id, tonnage, cargo_type) VALUES (1, 1, 10000, 'Hazardous'), (2, 1, 15000, 'Non-Hazar...
What is the total tonnage of hazardous cargo transported by vessels in the 'Tanker' category in the current year?
SELECT SUM(cargoes.tonnage) FROM cargoes JOIN vessels ON cargoes.vessel_id = vessels.id WHERE vessels.type = 'Tanker' AND cargo_type = 'Hazardous' AND YEAR(cargoes.id) = YEAR(CURRENT_DATE);
gretelai_synthetic_text_to_sql
CREATE SCHEMA gov_service;CREATE TABLE gov_service.library_data (region VARCHAR(20), year INT, libraries_built INT); INSERT INTO gov_service.library_data (region, year, libraries_built) VALUES ('North', 2019, 5), ('North', 2020, 7), ('South', 2019, 6), ('South', 2020, 8), ('East', 2019, 4), ('East', 2020, 9), ('West', ...
How many public libraries were built in each region in 2019 and 2020?
SELECT region, year, SUM(libraries_built) FROM gov_service.library_data GROUP BY region, year ORDER BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE Medals (Id INT, Event_Id INT, Athlete_Id INT, Medal VARCHAR(10)); INSERT INTO Medals (Id, Event_Id, Athlete_Id, Medal) VALUES (1, 1, 1, 'Gold'); INSERT INTO Medals (Id, Event_Id, Athlete_Id, Medal) VALUES (2, 2, 2, 'Silver'); INSERT INTO Medals (Id, Event_Id, Athlete_Id, Medal) VALUES (3, 3, 1, 'Silver');
Identify athletes who have won both gold and silver medals.
SELECT Athlete_Id FROM Medals WHERE Medal IN ('Gold', 'Silver') GROUP BY Athlete_Id HAVING COUNT(DISTINCT Medal) = 2
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels (Id INT, Name VARCHAR(50), Type VARCHAR(50), Flag VARCHAR(50)); INSERT INTO Vessels (Id, Name, Type, Flag) VALUES (1, 'Aurelia', 'Tanker', 'Panama'); INSERT INTO Vessels (Id, Name, Type, Flag) VALUES (2, 'Barracuda', 'Bulk Carrier', 'Marshall Islands'); CREATE TABLE Cargo (Id INT, VesselId INT, Car...
What is the number of vessels inspected and total quantity of cargo for vessels inspected in 2020?
SELECT COUNT(DISTINCT Inspections.VesselId) as NumberOfVesselsInpected, SUM(Cargo.Quantity) as TotalQuantityOfCargo FROM Inspections JOIN Cargo ON Inspections.VesselId = Cargo.VesselId WHERE YEAR(Inspections.InspectionDate) = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species_avg_depth (species TEXT, avg_depth FLOAT);
List all marine species with their average depth.
SELECT species, AVG(avg_depth) FROM marine_species_avg_depth GROUP BY species;
gretelai_synthetic_text_to_sql
CREATE TABLE shelter_assistance (id INT, organization TEXT, quantity INT, country TEXT, quarter INT, year INT); INSERT INTO shelter_assistance (id, organization, quantity, country, quarter, year) VALUES (1, 'UNHCR', 1200, 'Somalia', 3, 2021), (2, 'IRC', 1000, 'Somalia', 3, 2021), (3, 'Save the Children', 800, 'Somalia'...
Which organization provided the most shelter assistance in Somalia in Q3 2021?
SELECT organization, SUM(quantity) FROM shelter_assistance WHERE country = 'Somalia' AND quarter = 3 AND year = 2021 GROUP BY organization ORDER BY SUM(quantity) DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE soldiers (id INT PRIMARY KEY, name VARCHAR(50), rank VARCHAR(50), branch VARCHAR(50)); INSERT INTO soldiers (id, name, rank, branch) VALUES (101, 'John Doe', 'Captain', 'Army');
Show the rank and branch of a soldier with ID 101
SELECT rank, branch FROM soldiers WHERE id = 101;
gretelai_synthetic_text_to_sql
CREATE TABLE Funding (program_id INT, region VARCHAR(50), funding_amount DECIMAL(10,2), funding_date DATE); INSERT INTO Funding (program_id, region, funding_amount, funding_date) VALUES (4, 'Latin America', 8000.00, '2021-04-01'), (5, 'North America', 6000.00, '2021-05-01');
What was the total funding received by programs in 'Latin America'?
SELECT SUM(funding_amount) AS total_funding FROM Funding WHERE region = 'Latin America';
gretelai_synthetic_text_to_sql
CREATE TABLE port (port_id INT, port_name VARCHAR(50)); INSERT INTO port (port_id, port_name) VALUES (1, 'Port of Santos'); CREATE TABLE cargo (cargo_id INT, cargo_type VARCHAR(50)); CREATE TABLE transport (transport_id INT, cargo_id INT, port_id INT); INSERT INTO transport (transport_id, cargo_id, port_id) VALUES (1, ...
What are the unique cargo types transported by vessels to the Port of Santos?
SELECT DISTINCT cargo_type FROM cargo, transport WHERE cargo.cargo_id = transport.cargo_id AND port_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE smart_contracts (id INT, name VARCHAR(255), network VARCHAR(50));
Insert a new smart contract record with the name 'Contract4' on the 'Solana' network.
INSERT INTO smart_contracts (name, network) VALUES ('Contract4', 'Solana');
gretelai_synthetic_text_to_sql
CREATE TABLE menus (menu_id INT, item VARCHAR(255), category VARCHAR(255), price DECIMAL(10, 2), is_vegetarian BOOLEAN); INSERT INTO menus VALUES (1, 'Chicken Wings', 'Appetizers', 12.99, false); INSERT INTO menus VALUES (2, 'Veggie Burger', 'Entrees', 10.99, true); INSERT INTO menus VALUES (3, 'Tofu Stir Fry', 'Entree...
What are the least popular vegetarian menu items in the Asia-Pacific region?
SELECT m.item, SUM(s.quantity) as total_sold FROM menus m INNER JOIN sales s ON m.menu_id = s.menu_id WHERE m.is_vegetarian = true GROUP BY m.item ORDER BY total_sold ASC; SELECT region FROM sales GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE Aircraft (id INT, tail_number VARCHAR(20), model VARCHAR(100), airline VARCHAR(100), flight_hours DECIMAL(10,2)); INSERT INTO Aircraft (id, tail_number, model, airline, flight_hours) VALUES (1, 'N12345', '737-800', 'BlueSky', 12345.67); INSERT INTO Aircraft (id, tail_number, model, airline, flight_hours) V...
What is the difference in flight hours between the aircraft with the most and least flight hours for each airline?
SELECT airline, MAX(flight_hours) - MIN(flight_hours) OVER (PARTITION BY airline) as flight_hours_difference FROM Aircraft;
gretelai_synthetic_text_to_sql
CREATE TABLE project_timeline (project_id INT, start_date DATE, end_date DATE);
Update the project timeline for project ID 123456 to have a start date of 2022-06-01
UPDATE project_timeline SET start_date = '2022-06-01' WHERE project_id = 123456;
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tours (id INT, site_id INT, visitors INT, visit_date DATE); INSERT INTO virtual_tours (id, site_id, visitors, visit_date) VALUES (1, 1, 500, '2022-01-01'), (2, 2, 300, '2022-01-01');
Add a new virtual tour for the Great Wall of China with 1000 visitors on January 1, 2023
INSERT INTO virtual_tours (id, site_id, visitors, visit_date) VALUES (3, 3, 1000, '2023-01-01');
gretelai_synthetic_text_to_sql
CREATE TABLE Visitor_Demographics (visitor_id INT, city VARCHAR(50), year INT, age_group VARCHAR(20));
What is the most common age group for visitors who attended exhibitions in Berlin in 2018?
SELECT age_group, COUNT(*) AS frequency FROM Visitor_Demographics WHERE city = 'Berlin' AND year = 2018 GROUP BY age_group ORDER BY frequency DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_areas (area_id INT, name VARCHAR(50), region VARCHAR(50), num_marine_species INT); INSERT INTO marine_areas (area_id, name, region, num_marine_species) VALUES (1, 'Tubbataha Reefs Natural Park', 'Southeast Asia', 600), (2, 'Sundarbans National Park', 'Southeast Asia', 550), (3, 'Great Barrier Reef',...
What is the average number of marine species found in each protected marine area in Southeast Asia?
SELECT AVG(num_marine_species) FROM marine_areas WHERE region = 'Southeast Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE healthcare_facilities (id INT, name TEXT, location TEXT, patients_per_day INT); INSERT INTO healthcare_facilities (id, name, location, patients_per_day) VALUES (1, 'Facility A', 'suburban', 50), (2, 'Facility B', 'urban', 75), (3, 'Facility C', 'suburban', 60);
What is the average number of patients served per day by healthcare facilities in suburban areas?
SELECT AVG(patients_per_day) FROM healthcare_facilities WHERE location = 'suburban';
gretelai_synthetic_text_to_sql
CREATE TABLE Workshops (id INT, neighborhood VARCHAR(20), workshop_type VARCHAR(20), workshop_date DATE); INSERT INTO Workshops (id, neighborhood, workshop_type, workshop_date) VALUES (1, 'Westwood', 'Visual Art', '2022-04-10'), (2, 'Beverly Grove', 'Visual Art', '2022-06-05'), (3, 'Fairfax', 'Music', '2022-05-12');
How many visual art workshops were conducted in each neighborhood in Q2 2022?
SELECT neighborhood, workshop_type, COUNT(*) as workshop_count FROM Workshops WHERE workshop_date BETWEEN '2022-04-01' AND '2022-06-30' AND workshop_type = 'Visual Art' GROUP BY neighborhood, workshop_type;
gretelai_synthetic_text_to_sql
CREATE TABLE satellite_deployment (id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255), launch_date DATE); INSERT INTO satellite_deployment (id, name, country, launch_date) VALUES (1, 'Sentinel-1A', 'European Union', '2014-04-03'), (2, 'TechSat', 'United States', '2022-09-01'); CREATE VIEW eu_satellites AS SELE...
List all satellites and their launch dates
SELECT name, launch_date FROM satellite_deployment;
gretelai_synthetic_text_to_sql
CREATE TABLE RenewableEnergy.CityEnergy (city VARCHAR(50), energy_consumption FLOAT, num_buildings INT, continent VARCHAR(50)); INSERT INTO RenewableEnergy.CityEnergy (city, energy_consumption, num_buildings, continent) VALUES ('Sao Paulo', 123456.7, 2000, 'South America'), ('Mexico City', 150000.2, 3000, 'North Americ...
List all cities with their total energy consumption and the number of buildings in the 'RenewableEnergy' schema, grouped by continent.
SELECT continent, city, SUM(energy_consumption) AS total_energy, num_buildings FROM RenewableEnergy.CityEnergy GROUP BY continent, city;
gretelai_synthetic_text_to_sql
CREATE TABLE hotel_ota_revenue (hotel_name VARCHAR(20), ota_platform VARCHAR(20), revenue DECIMAL(10,2), revenue_date DATE); INSERT INTO hotel_ota_revenue (hotel_name, ota_platform, revenue, revenue_date) VALUES ('Hotel A', 'Expedia', 5000, '2022-04-01'), ('Hotel A', 'Booking.com', 6000, '2022-04-01'), ('Hotel A', 'Ago...
Which OTA platforms contributed to the highest revenue for a specific hotel in Q2 2022?
SELECT ota_platform, SUM(revenue) as total_revenue FROM hotel_ota_revenue WHERE hotel_name = 'Hotel A' AND revenue_date BETWEEN '2022-04-01' AND '2022-06-30' GROUP BY ota_platform ORDER BY total_revenue DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE energy_storage (id INT, state VARCHAR(255), name VARCHAR(255), capacity FLOAT); INSERT INTO energy_storage (id, state, name, capacity) VALUES (1, 'Texas', 'Storage A', 120.5); INSERT INTO energy_storage (id, state, name, capacity) VALUES (2, 'Texas', 'Storage B', 150.2); INSERT INTO energy_storage (id, sta...
Find the total installed energy storage capacity in Texas and Ontario.
SELECT SUM(capacity) FROM energy_storage WHERE state IN ('Texas', 'Ontario');
gretelai_synthetic_text_to_sql
CREATE TABLE worker_demographics (worker_id INT, gender VARCHAR(50), age INT); INSERT INTO worker_demographics (worker_id, gender, age) VALUES (1, 'Female', 35), (2, 'Male', 40), (3, 'Female', 45), (4, 'Non-binary', 50);
What is the minimum age of community health workers who have completed cultural competency training?
SELECT MIN(age) as min_age FROM community_health_workers chw INNER JOIN completed_training ct ON chw.worker_id = ct.worker_id;
gretelai_synthetic_text_to_sql
CREATE TABLE artifact_analysis (id INT, artifact_name VARCHAR(50), culture VARCHAR(50), weight INT); INSERT INTO artifact_analysis (id, artifact_name, culture, weight) VALUES (1, 'bronze_statue', 'Indus Valley', 100); CREATE TABLE ancient_tools (id INT, artifact_name VARCHAR(50), culture VARCHAR(50), age INT); INSERT I...
What is the total number of artifacts from the 'Indus Valley' culture in the 'artifact_analysis' and 'ancient_tools' tables?
SELECT COUNT(*) FROM (SELECT * FROM artifact_analysis WHERE culture = 'Indus Valley' UNION ALL SELECT * FROM ancient_tools WHERE culture = 'Indus Valley') t;
gretelai_synthetic_text_to_sql
CREATE TABLE fish_species (species_id INT PRIMARY KEY, species_name VARCHAR(255), scientific_name VARCHAR(255), conservation_status VARCHAR(50)); CREATE TABLE farm_locations (location_id INT PRIMARY KEY, location_name VARCHAR(255), country VARCHAR(255), ocean VARCHAR(255)); CREATE TABLE fish_production (production_id I...
Insert a record for the Atlantic Salmon production in Maine during 2020
INSERT INTO fish_production (production_id, species_id, location_id, year, quantity) VALUES (1, 1, 1, 2020, 150000);
gretelai_synthetic_text_to_sql
CREATE TABLE Users (id INT, user_name TEXT); INSERT INTO Users (id, user_name) VALUES (1, 'John Doe'); INSERT INTO Users (id, user_name) VALUES (2, 'Jane Smith'); INSERT INTO Users (id, user_name) VALUES (3, 'Pablo Garcia');
Delete the user with the id of 3.
DELETE FROM Users WHERE id = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Artifacts (id INT PRIMARY KEY, name VARCHAR(255), description TEXT, date_found DATE);
Create a table for storing information about artifacts
CREATE TABLE Artifacts (id INT PRIMARY KEY, name VARCHAR(255), description TEXT, date_found DATE);
gretelai_synthetic_text_to_sql
CREATE TABLE Green_Buildings (id INT, project_cost FLOAT, city VARCHAR(20)); INSERT INTO Green_Buildings (id, project_cost, city) VALUES (1, 5000000, 'Los Angeles');
What is the maximum project cost for green buildings in the city of Los Angeles?
SELECT MAX(project_cost) FROM Green_Buildings WHERE city = 'Los Angeles';
gretelai_synthetic_text_to_sql
CREATE TABLE AircraftManufacturing (id INT, manufacturer VARCHAR(255), country VARCHAR(255), cost FLOAT); INSERT INTO AircraftManufacturing VALUES (1, 'Boeing', 'USA', 120000000), (2, 'Airbus', 'Europe', 100000000), (3, 'Lockheed Martin', 'USA', 200000000);
What is the minimum manufacturing cost of aircrafts produced in Europe?
SELECT MIN(cost) FROM AircraftManufacturing WHERE country = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE international_visitors (country VARCHAR(50), year INT, num_visitors INT); INSERT INTO international_visitors (country, year, num_visitors) VALUES ('France', 2022, 15000000), ('Germany', 2022, 12000000), ('Spain', 2022, 16000000);
What is the maximum number of international visitors to any country in Europe in 2022?
SELECT MAX(num_visitors) FROM international_visitors WHERE country IN (SELECT name FROM countries WHERE region = 'Europe') AND year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE Programs (ProgramID INT, ProgramName VARCHAR(50), StartDate DATE); CREATE TABLE Volunteers (VolunteerID INT, ProgramID INT, SignUpDate DATE); INSERT INTO Programs (ProgramID, ProgramName, StartDate) VALUES (1, 'ProgramA', '2022-01-01'), (2, 'ProgramB', '2022-01-01'), (3, 'ProgramC', '2022-01-01'); INSERT I...
How many volunteers signed up for each program in 2022, ordered by program name?
SELECT p.ProgramName, COUNT(v.VolunteerID) AS SignUpCount FROM Programs p LEFT JOIN Volunteers v ON p.ProgramID = v.ProgramID WHERE YEAR(v.SignUpDate) = 2022 GROUP BY p.ProgramName ORDER BY p.ProgramName;
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (VolunteerID int, VolunteerName varchar(100), Country varchar(50), SignupDate date); INSERT INTO Volunteers (VolunteerID, VolunteerName, Country, SignupDate) VALUES (1, 'Jane Doe', 'Canada', '2022-01-01');
How many volunteers signed up in 'Canada' each month in the year 2022?
SELECT YEAR(SignupDate) AS Year, MONTH(SignupDate) AS Month, COUNT(*) AS NumberOfVolunteers FROM Volunteers WHERE Country = 'Canada' AND YEAR(SignupDate) = 2022 GROUP BY YEAR(SignupDate), MONTH(SignupDate);
gretelai_synthetic_text_to_sql
CREATE TABLE mines (id INT, name TEXT, type TEXT, state TEXT, production INT); INSERT INTO mines (id, name, type, state, production) VALUES (1, 'Golden Mine', 'Gold', 'Texas', 500), (2, 'Silver Mine', 'Silver', 'Texas', 250), (3, 'Bronze Mine', 'Bronze', 'California', 150), (4, 'Platinum Mine', 'Platinum', 'California'...
What is the production of each mine type per state?
SELECT type, state, SUM(production) as total_production FROM mines GROUP BY type, state;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, name VARCHAR(50), country VARCHAR(50), last_transaction_date DATE);
Determine the total number of customers in each country who have made at least one transaction in the past year.
SELECT country, COUNT(*) as num_customers FROM customers c WHERE last_transaction_date >= (CURRENT_DATE - INTERVAL '1 year') GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE energy_investments (customer_id INT, investment FLOAT, investment_type VARCHAR(10), region VARCHAR(10)); INSERT INTO energy_investments (customer_id, investment, investment_type, region) VALUES (1, 4000, 'renewable', 'west'), (2, 2000, 'non-renewable', 'east'), (3, 8000, 'healthcare', 'west'); CREATE TABLE...
What is the total investment in the healthcare sector for customers in the western region?
SELECT SUM(investment) FROM energy_investments INNER JOIN customer_data ON energy_investments.customer_id = customer_data.customer_id WHERE investment_type = 'healthcare' AND customer_data.region = 'west';
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_prices (quarter VARCHAR(6), region VARCHAR(255), price FLOAT); INSERT INTO carbon_prices (quarter, region, price) VALUES ('Q2 2022', 'Europe', 25.5), ('Q2 2022', 'North America', 15.3);
What was the carbon price in Europe in Q2 2022?
SELECT price FROM carbon_prices WHERE quarter = 'Q2 2022' AND region = 'Europe'
gretelai_synthetic_text_to_sql
CREATE TABLE ResearchProject (ProjectID INT, ProjectName VARCHAR(100), SiteID INT, StartDate DATE, EndDate DATE); INSERT INTO ResearchProject (ProjectID, ProjectName, SiteID, StartDate, EndDate) VALUES (6, 'Harappa Archaeological Project', 6, '2021-01-01', '2023-12-31'); CREATE TABLE PublicOutreach (OutreachID INT, Pro...
What are the public outreach types and their attendance for research projects in India?
SELECT p.ProjectName, po.OutreachType, po.Attendance FROM PublicOutreach po JOIN ResearchProject p ON po.ProjectID = p.ProjectID WHERE p.EndDate >= CURDATE() AND po.Attendance > 50;
gretelai_synthetic_text_to_sql
CREATE TABLE Claims_Type (id INT, policy_type VARCHAR(20), amount FLOAT); INSERT INTO Claims_Type (id, policy_type, amount) VALUES (1, 'Auto', 5000), (2, 'Home', 7000), (3, 'Life', 8000), (4, 'Health', 6000);
What is the total claim amount for each policy type?
SELECT policy_type, SUM(amount) as total_claim FROM Claims_Type GROUP BY policy_type;
gretelai_synthetic_text_to_sql
CREATE TABLE EV_Safety (Vehicle VARCHAR(255), SafetyRating FLOAT); INSERT INTO EV_Safety (Vehicle, SafetyRating) VALUES ('Tesla Model 3', 5.3), ('Chevrolet Bolt', 5.1), ('Nissan Leaf', 4.9), ('Ford Focus Electric', 4.5);
What is the minimum and maximum safety rating for electric vehicles?
SELECT MIN(SafetyRating), MAX(SafetyRating) FROM EV_Safety WHERE Vehicle LIKE '%electric%';
gretelai_synthetic_text_to_sql
CREATE TABLE community_health_statistics_v3 (id INT, community_type VARCHAR(20), statistic_value INT);
Delete a record with community health statistic for a specific community type
DELETE FROM community_health_statistics_v3 WHERE community_type = 'Remote';
gretelai_synthetic_text_to_sql
CREATE TABLE causes (id INT, name VARCHAR(255), type VARCHAR(255)); INSERT INTO causes (id, name, type) VALUES (1, 'Education', 'Social'), (2, 'Health', 'Social'), (3, 'Environment', 'Non-social'), (4, 'Animal Welfare', 'Non-social'); INSERT INTO donations (id, cause_id, amount) VALUES (1, 1, 500.00), (2, 1, 1000.00), ...
What is the total amount donated to environmental causes?
SELECT SUM(d.amount) FROM donations d JOIN causes c ON d.cause_id = c.id WHERE c.type = 'Non-social';
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (transaction_id INT, customer_id INT, amount DECIMAL(10, 2), transaction_date DATE); INSERT INTO transactions (transaction_id, customer_id, amount, transaction_date) VALUES (1, 1, 50.00, '2022-01-01'), (2, 1, 100.00, '2022-01-15'), (3, 2, 75.00, '2022-02-03'), (4, 3, 1200.00, '2022-03-01'); CR...
What is the total transaction value per month in the West region?
SELECT DATE_FORMAT(transaction_date, '%Y-%m') AS month, SUM(amount) FROM transactions t JOIN customers c ON t.customer_id = c.customer_id WHERE c.region = 'West' GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE Claims (PolicyID int, ClaimAmount int, Deductible int); INSERT INTO Claims (PolicyID, ClaimAmount, Deductible) VALUES (1, 500, 400), (2, 2000, 1000), (3, 800, 300);
What is the total claim amount for policies with a deductible less than $500?
SELECT SUM(ClaimAmount) OVER (PARTITION BY CASE WHEN Deductible < 500 THEN 1 ELSE 0 END) as TotalClaimAmount FROM Claims;
gretelai_synthetic_text_to_sql
CREATE TABLE Hospitals (HospitalID INT, Name TEXT, City TEXT, State TEXT, Emergency BOOLEAN); INSERT INTO Hospitals (HospitalID, Name, City, State, Emergency) VALUES (1, 'Mount Sinai Hospital', 'New York', 'New York', TRUE);
How many hospitals are there in the city of New York that offer emergency services?
SELECT COUNT(*) FROM Hospitals WHERE City = 'New York' AND Emergency = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE Suppliers(SupplierID INT, Name VARCHAR(50), Type VARCHAR(50));CREATE TABLE DairyProducts(ProductID INT, SupplierID INT, ProductName VARCHAR(50), Quantity INT, DeliveryDate DATE);INSERT INTO Suppliers VALUES (1, 'Dairy Direct', 'Dairy Supplier'), (2, 'Farm Fresh', 'Dairy Supplier'), (3, 'Fruitful', 'Fruit S...
Identify the total quantity of dairy products supplied by each supplier in the last month?
SELECT s.Name, SUM(dp.Quantity) FROM Suppliers s JOIN DairyProducts dp ON s.SupplierID = dp.SupplierID WHERE dp.DeliveryDate >= DATEADD(month, -1, GETDATE()) AND s.Type = 'Dairy Supplier' GROUP BY s.Name;
gretelai_synthetic_text_to_sql
CREATE TABLE Virtual_Tours (id INT, venue_id INT, tour_name VARCHAR(255), price DECIMAL(5,2), duration INT); INSERT INTO Virtual_Tours (id, venue_id, tour_name, price, duration) VALUES (1, 1, 'Online Tour of Museum', 20.00, 60); INSERT INTO Virtual_Tours (id, venue_id, tour_name, price, duration) VALUES (2, 2, 'Virtual...
What is the average duration of the longest virtual tours for each venue?
SELECT venue_id, AVG(duration) as 'Average Duration of Longest Tour' FROM Virtual_Tours t1 WHERE t1.duration = (SELECT MAX(duration) FROM Virtual_Tours t2 WHERE t1.venue_id = t2.venue_id) GROUP BY venue_id;
gretelai_synthetic_text_to_sql
CREATE TABLE deforestation (id INT, country VARCHAR(50), region VARCHAR(50), year INT, rate FLOAT);
Find the top five countries with the highest deforestation rate in African forests.
SELECT country, AVG(rate) AS avg_rate FROM deforestation WHERE region = 'Africa' GROUP BY country ORDER BY avg_rate DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE Satellites (id INT, name VARCHAR(50), launch_date DATE, status VARCHAR(50)); INSERT INTO Satellites (id, name, launch_date, status) VALUES (1, 'Sentinel-1A', '2014-04-03', 'Active'); INSERT INTO Satellites (id, name, launch_date, status) VALUES (2, 'Sentinel-1B', '2016-04-25', 'Active'); INSERT INTO Satell...
Get the number of satellites launched per year.
SELECT EXTRACT(YEAR FROM launch_date) AS year, COUNT(*) AS satellites_launched FROM Satellites GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE waste_generation (id INT, year INT, material VARCHAR(255), amount INT); INSERT INTO waste_generation (id, year, material, amount) VALUES (1, 2022, 'plastic', 5000);
What is the total waste generation by material type in 2022?
SELECT material, SUM(amount) as total_waste_generation FROM waste_generation WHERE year = 2022 GROUP BY material;
gretelai_synthetic_text_to_sql
CREATE TABLE health_equity_metrics (id INT PRIMARY KEY, zip_code VARCHAR(10), population INT, health_score INT); CREATE VIEW zip_health_avg AS SELECT zip_code, AVG(health_score) as avg_health_score FROM health_equity_metrics GROUP BY zip_code;
Identify zip codes with high health equity scores.
SELECT zip_code, AVG(health_score) as avg_health_score FROM health_equity_metrics GROUP BY zip_code HAVING AVG(health_score) > 80;
gretelai_synthetic_text_to_sql
CREATE TABLE Sports (SportID INT, Sport VARCHAR(255));CREATE TABLE Games (GameID INT, SportID INT, TicketPrice DECIMAL(5,2));
Determine the average ticket price for each sport, sorted in descending order.
SELECT AVG(TicketPrice) AS AvgPrice, Sport FROM Games JOIN Sports ON Games.SportID = Sports.SportID GROUP BY Sport ORDER BY AvgPrice DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE hospitals (id INT, rural BOOLEAN, beds INT); INSERT INTO hospitals (id, rural, beds) VALUES (1, true, 50), (2, false, 100), (3, true, 75);
Total number of hospital beds in rural hospitals?
SELECT SUM(beds) FROM hospitals WHERE rural = true;
gretelai_synthetic_text_to_sql
CREATE TABLE vessel_performance (id INT, name TEXT, speed DECIMAL(5,2), arrived_date DATE, country TEXT); INSERT INTO vessel_performance (id, name, speed, arrived_date, country) VALUES (1, 'Vessel A', 12.5, '2022-03-05', 'Australia'), (2, 'Vessel B', 16.8, '2022-03-10', 'Australia'), (3, 'Vessel C', 10.6, '2022-03-18',...
What is the minimum speed recorded for vessels that arrived in Australia in March 2022?
SELECT MIN(speed) FROM vessel_performance WHERE YEAR(arrived_date) = 2022 AND MONTH(arrived_date) = 3 AND country = 'Australia';
gretelai_synthetic_text_to_sql
CREATE TABLE CountyG (Location VARCHAR(50), Quantity INT, Date DATE); INSERT INTO CountyG (Location, Quantity, Date) VALUES ('Location1', 1000, '2021-01-01'), ('Location2', 2000, '2021-05-01');
What is the total waste generation in 'CountyG' as of the earliest date?
SELECT SUM(Quantity) FROM (SELECT Quantity, ROW_NUMBER() OVER (PARTITION BY Location ORDER BY Date ASC) as rn FROM CountyG) tmp WHERE rn = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE military_equipment (id INT, name VARCHAR(50), company VARCHAR(50), maintenance_frequency INT); INSERT INTO military_equipment (id, name, company, maintenance_frequency) VALUES (1, 'M1 Abrams', 'XYZ', 12); INSERT INTO military_equipment (id, name, company, maintenance_frequency) VALUES (2, 'F-35', 'ABC', 24...
What is the total number of military equipment maintained by XYZ company?
SELECT SUM(maintenance_frequency) FROM military_equipment WHERE company = 'XYZ';
gretelai_synthetic_text_to_sql
CREATE TABLE sustainable_tourism (business_id INT, region VARCHAR(255), economic_impact INT); CREATE TABLE regions (region_id INT, name VARCHAR(255));
What is the total economic impact of sustainable tourism in Africa and South America?
SELECT SUM(st.economic_impact) FROM sustainable_tourism st INNER JOIN regions r ON st.region IN (r.name, CONCAT(r.name, ' +')) WHERE r.name IN ('Africa', 'South America');
gretelai_synthetic_text_to_sql
CREATE TABLE music_albums (id INT, title VARCHAR(100), release_year INT); INSERT INTO music_albums (id, title, release_year) VALUES (1, 'Album1', 2016); INSERT INTO music_albums (id, title, release_year) VALUES (2, 'Album2', 2017); INSERT INTO music_albums (id, title, release_year) VALUES (3, 'Album3', 2018); INSERT IN...
How many music albums were released each year?
SELECT release_year, COUNT(*) FROM music_albums GROUP BY release_year;
gretelai_synthetic_text_to_sql
CREATE TABLE damages (id INT, incident_date DATE, reported_cost INT);
Delete records in the 'damages' table where the reported cost is greater than $10,000,000 and the incident occurred before 2010-01-01
DELETE FROM damages WHERE reported_cost > 10000000 AND incident_date < '2010-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE theater_attendance (id INT, program_type VARCHAR(255), num_attendees INT, attendance_year INT);
Which theater programs had the highest attendance in 2021?
SELECT program_type, num_attendees, RANK() OVER (ORDER BY num_attendees DESC) AS attendance_rank FROM theater_attendance WHERE attendance_year = 2021 AND num_attendees > 0 AND program_type LIKE '%theater%';
gretelai_synthetic_text_to_sql
CREATE TABLE menu_sales (item VARCHAR(255), sales INTEGER, sale_date DATE); INSERT INTO menu_sales (item, sales, sale_date) VALUES ('Burger', 150, '2022-02-01'), ('Pizza', 200, '2022-02-01'), ('Burger', 120, '2022-02-02');
Which menu item sold the most in February 2022?
SELECT item, MAX(sales) FROM menu_sales WHERE sale_date BETWEEN '2022-02-01' AND '2022-02-28' GROUP BY item;
gretelai_synthetic_text_to_sql
CREATE TABLE vulnerabilities(id INT, date DATE, severity VARCHAR(10), country VARCHAR(50), cve_id VARCHAR(50)); INSERT INTO vulnerabilities(id, date, severity, country, cve_id) VALUES (1, '2021-01-01', 'medium', 'Canada', 'CVE-2021-0123'), (2, '2021-01-02', 'high', 'USA', 'CVE-2021-0124');
What is the daily count and average severity of high vulnerabilities in North America?
SELECT date, COUNT(*) as total_vulnerabilities, AVG(severity = 'high'::int) as avg_high_severity FROM vulnerabilities WHERE country = 'North America' GROUP BY date ORDER BY date;
gretelai_synthetic_text_to_sql
CREATE TABLE patient_outcomes (patient_id INT, condition VARCHAR(255), received_treatment BOOLEAN, recovered BOOLEAN);
What is the total number of patients who have received treatment for depression or anxiety in the patient_outcomes table, and what is the percentage of patients who have recovered?
SELECT COUNT(*) AS total_patients, 100.0 * SUM(recovered AND received_treatment) / COUNT(*) AS recovery_percentage FROM patient_outcomes WHERE condition IN ('depression', 'anxiety');
gretelai_synthetic_text_to_sql
CREATE TABLE EquipmentSales (equipment_id INT, country VARCHAR(50), quantity INT, sale_date DATE); INSERT INTO EquipmentSales (equipment_id, country, quantity, sale_date) VALUES (1, 'USA', 15, '2021-04-15'); INSERT INTO EquipmentSales (equipment_id, country, quantity, sale_date) VALUES (2, 'Canada', 10, '2021-04-20');
What is the total quantity of military equipment sold by country in Q2 2021?
SELECT country, SUM(quantity) as total_quantity FROM EquipmentSales WHERE sale_date BETWEEN '2021-04-01' AND '2021-06-30' GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE ads (ad_id INT, user_id INT, platform VARCHAR(255), ad_revenue DECIMAL(10,2), post_count INT); INSERT INTO ads (ad_id, user_id, platform, ad_revenue, post_count) VALUES (1, 1, 'Facebook', 150.50, 20), (2, 2, 'Twitter', 80.00, 15), (3, 3, 'Instagram', 120.75, 25);
What is the maximum revenue generated from ads on Facebook in April 2021, for users in the 'brand' category who have posted more than 15 times?
SELECT MAX(ad_revenue) FROM ads WHERE platform = 'Facebook' AND MONTH(ad_date) = 4 AND YEAR(ad_date) = 2021 AND user_id IN (SELECT user_id FROM users WHERE category = 'brand' AND post_count > 15);
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (DonationID int, DonorID int, Cause varchar(50), DonationAmount decimal(10, 2)); INSERT INTO Donations (DonationID, DonorID, Cause, DonationAmount) VALUES (1, 1, 'Healthcare', 5000); INSERT INTO Donations (DonationID, DonorID, Cause, DonationAmount) VALUES (2, 2, 'Education', 1000); INSERT INTO D...
Show me the total donation amount by each cause in Africa.
SELECT Cause, SUM(DonationAmount) as TotalDonationAmount FROM Donations WHERE Cause IN ('Healthcare', 'Education', 'Environment') GROUP BY Cause;
gretelai_synthetic_text_to_sql
CREATE TABLE Iceberg (ID INT, Name TEXT, Location TEXT, Year INT, Count INT); INSERT INTO Iceberg (ID, Name, Location, Year, Count) VALUES (1, 'Iceberg1', 'Greenland', 2010, 50); INSERT INTO Iceberg (ID, Name, Location, Year, Count) VALUES (2, 'Iceberg2', 'Greenland', 2011, 75);
What is the maximum number of icebergs observed in a year in Greenland?
SELECT MAX(Year) as Max_Year, MAX(Count) as Max_Icebergs FROM Iceberg WHERE Location = 'Greenland';
gretelai_synthetic_text_to_sql
CREATE TABLE inventory (inventory_id INT, item_name VARCHAR(50), inventory_category VARCHAR(50), quantity INT, sales_volume INT); INSERT INTO inventory (inventory_id, item_name, inventory_category, quantity, sales_volume) VALUES (1, 'Tomato', 'Produce', 50, 100), (2, 'Chicken Breast', 'Meat', 100, 200), (3, 'Vanilla Ic...
What is the most popular item in each inventory category?
SELECT inventory_category, item_name, MAX(sales_volume) FROM inventory GROUP BY inventory_category;
gretelai_synthetic_text_to_sql
CREATE TABLE IntelligenceOperations (OperationID INT, OperationType VARCHAR(20), OperationLocation VARCHAR(30), OperationYear INT); INSERT INTO IntelligenceOperations (OperationID, OperationType, OperationLocation, OperationYear) VALUES (1, 'Surveillance', 'Vietnam', 2010), (2, 'Infiltration', 'Laos', 2012), (3, 'Surve...
What are the details of intelligence operations that involved surveillance and took place in Southeast Asia?
SELECT * FROM IntelligenceOperations WHERE OperationType = 'Surveillance' AND OperationLocation LIKE 'Southeast%';
gretelai_synthetic_text_to_sql
CREATE TABLE Dishes (id INT, cuisine VARCHAR(255), calories INT); INSERT INTO Dishes (id, cuisine, calories) VALUES (1, 'Fast Food', 1200), (2, 'Fast Food', 800), (3, 'Fast Food', 1500), (4, 'Chinese', 500);
What is the maximum and minimum calorie count for dishes in the 'Fast Food' cuisine category?
SELECT cuisine, MIN(calories) as min_calories, MAX(calories) as max_calories FROM Dishes WHERE cuisine = 'Fast Food' GROUP BY cuisine;
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name VARCHAR(255)); INSERT INTO companies (id, name) VALUES (1, 'ACME Minerals'), (2, 'BIG Extraction'); CREATE TABLE extraction (id INT, company_id INT, mineral VARCHAR(255), quantity INT); INSERT INTO extraction (id, company_id, mineral, quantity) VALUES (1, 1, 'gold', 500), (2, 1, 'si...
What is the total quantity of gold and silver extracted by each company, along with their respective environmental impact scores?
SELECT c.name, SUM(CASE WHEN e.mineral = 'gold' THEN e.quantity ELSE 0 END) as total_gold, SUM(CASE WHEN e.mineral = 'silver' THEN e.quantity ELSE 0 END) as total_silver, ms.environmental_impact_score FROM companies c INNER JOIN extraction e ON c.id = e.company_id INNER JOIN mining_sites ms ON c.id = ms.site_name GROUP...
gretelai_synthetic_text_to_sql
CREATE TABLE faculty (faculty_id INT, name VARCHAR(50), gender VARCHAR(10), department VARCHAR(50));
How many female and male faculty members are there in each department?
SELECT f.department, f.gender, COUNT(*) AS num_faculty FROM faculty f GROUP BY f.department, f.gender;
gretelai_synthetic_text_to_sql
CREATE TABLE fans (fan_id INT, state VARCHAR(255)); INSERT INTO fans (fan_id, state) VALUES (1, 'Texas'), (2, 'California'), (3, 'Texas'), (4, 'New York'); CREATE TABLE events (fan_id INT, event_id INT); INSERT INTO events (fan_id, event_id) VALUES (1, 101), (1, 102), (1, 103), (2, 101), (3, 102), (3, 103), (3, 104), (...
Which fans are from Texas and have attended more than 3 events?
SELECT f.state, COUNT(e.event_id) as event_count FROM fans f JOIN events e ON f.fan_id = e.fan_id WHERE f.state = 'Texas' GROUP BY f.fan_id HAVING event_count > 3;
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name TEXT, industry TEXT, founding_year INT, founder_identity TEXT); INSERT INTO companies (id, name, industry, founding_year, founder_identity) VALUES (1, 'EcomStore', 'E-commerce', 2018, 'BIPOC'); INSERT INTO companies (id, name, industry, founding_year, founder_identity) VALUES (2, 'S...
What is the maximum number of employees for companies founded by BIPOC (Black, Indigenous, and People of Color) in the e-commerce industry?
SELECT MAX(num_employees) FROM company_details INNER JOIN companies ON company_details.company_id = companies.id WHERE companies.founder_identity = 'BIPOC' AND companies.industry = 'E-commerce';
gretelai_synthetic_text_to_sql
CREATE TABLE autonomous_delivery_trucks (truck_id INT, distance FLOAT, city VARCHAR(50));
What is the maximum distance traveled by an autonomous delivery truck in Madrid, Spain?
SELECT MAX(distance) FROM autonomous_delivery_trucks WHERE city = 'Madrid';
gretelai_synthetic_text_to_sql
CREATE TABLE mine (id INT, name TEXT, location TEXT); CREATE TABLE employee (id INT, mine_id INT, name TEXT, diversity_group TEXT); INSERT INTO mine VALUES (1, 'Mine A', 'Country A'); INSERT INTO mine VALUES (2, 'Mine B', 'Country B'); INSERT INTO employee VALUES (1, 1, 'John', 'Underrepresented Group 1'); INSERT INTO ...
Count the number of employees from underrepresented communities in each mine by diversity group
SELECT mine.name, employee.diversity_group, COUNT(employee.id) AS employee_count FROM mine INNER JOIN employee ON mine.id = employee.mine_id WHERE employee.diversity_group IS NOT NULL GROUP BY mine.name, employee.diversity_group;
gretelai_synthetic_text_to_sql
CREATE TABLE MentalHealthParity (ViolationID INT, ViolationType VARCHAR(255), ViolationYear INT, Resolved BOOLEAN);
Update the 'MentalHealthParity' table to mark all financial violations from 2018 as resolved.
UPDATE MentalHealthParity SET Resolved = TRUE WHERE ViolationType = 'Financial' AND ViolationYear = 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (hotel_id INT, name VARCHAR(50), location VARCHAR(50), stars INT);
List all unique locations from the hotels table.
SELECT DISTINCT location FROM hotels;
gretelai_synthetic_text_to_sql
CREATE TABLE attorneys (attorney_id INT, name VARCHAR(50)); INSERT INTO attorneys (attorney_id, name) VALUES (1, 'John Doe'); CREATE TABLE cases (case_id INT, attorney_id INT, billing_amount DECIMAL(10,2)); INSERT INTO cases (case_id, attorney_id, billing_amount) VALUES (1, 1, 5000.00), (2, 1, 7000.00);
What is the total billing amount for cases handled by attorney John Doe?
SELECT SUM(billing_amount) FROM cases WHERE attorney_id IN (SELECT attorney_id FROM attorneys WHERE name = 'John Doe');
gretelai_synthetic_text_to_sql
CREATE TABLE sales_by_category_2 (product_category VARCHAR(255), revenue FLOAT); INSERT INTO sales_by_category_2 (product_category, revenue) VALUES ('Jackets', 7000), ('Sweaters', 8000), ('Pants', 9000), ('Skirts', 10000);
Get the total sales for each product category for the month of April 2022?
SELECT product_category, SUM(revenue) FROM sales_by_category_2 WHERE revenue IS NOT NULL AND product_category IS NOT NULL AND STR_TO_DATE(CONCAT('04-', MONTH(NOW())), '%d-%m-%Y') = STR_TO_DATE('04-2022', '%d-%m-%Y') GROUP BY product_category;
gretelai_synthetic_text_to_sql
CREATE TABLE SpaceMission (ID INT, SpacecraftName VARCHAR(50), MissionName VARCHAR(50), LaunchDate DATE, DurationInSpace INT); INSERT INTO SpaceMission VALUES (1, 'Spacecraft A', 'Mission 1A', '2011-03-15', 500), (2, 'Spacecraft A', 'Mission 2A', '2013-06-28', 700), (3, 'Spacecraft B', 'Mission 1B', '2014-08-22', 800),...
Delete space missions with a duration in space less than 500.
DELETE FROM SpaceMission WHERE DurationInSpace < 500;
gretelai_synthetic_text_to_sql
CREATE TABLE campaigns (campaign_id INT, condition TEXT, launch_date DATE, location TEXT); INSERT INTO campaigns (campaign_id, condition, launch_date, location) VALUES (1, 'Depression', '2019-05-01', 'New York'); INSERT INTO campaigns (campaign_id, condition, launch_date, location) VALUES (2, 'Anxiety', '2020-02-15', '...
How many public awareness campaigns were launched in the last 3 years, segmented by condition?
SELECT condition, COUNT(campaign_id) FROM campaigns WHERE launch_date >= DATEADD(year, -3, GETDATE()) GROUP BY condition;
gretelai_synthetic_text_to_sql
CREATE TABLE precinct (id INT, name VARCHAR(50)); INSERT INTO precinct (id, name) VALUES (1, 'Eastside'); CREATE TABLE community_program (id INT, precinct_id INT, program_name VARCHAR(50));
What is the total number of community policing programs in the 'Eastside' precinct?
SELECT COUNT(*) as total_programs FROM community_program WHERE precinct_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Inventory (inventory_id INT, product_id INT, name VARCHAR(255), quantity INT, price DECIMAL(5,2), type VARCHAR(255));
Delete all records of meat products from the inventory of LocalGroceryStore.
DELETE FROM Inventory WHERE type = 'meat';
gretelai_synthetic_text_to_sql
CREATE TABLE Funding (FundingID int, FundingAmount decimal(10,2), FundingDate date, FundingSource varchar(50)); INSERT INTO Funding (FundingID, FundingAmount, FundingDate, FundingSource) VALUES (1, 10000.00, '2019-01-01', 'Foundation'), (2, 20000.00, '2020-01-01', 'Foundation'), (3, 15000.00, '2021-01-01', 'Foundation'...
What is the total amount of funding received from foundation sources in the year 2019?
SELECT SUM(FundingAmount) FROM Funding WHERE FundingDate BETWEEN '2019-01-01' AND '2019-12-31' AND FundingSource = 'Foundation';
gretelai_synthetic_text_to_sql
CREATE TABLE smart_contracts (contract_id INT, contract_name VARCHAR(50), regulation_id INT); CREATE TABLE regulations (regulation_id INT, regulation_name VARCHAR(50)); INSERT INTO smart_contracts (contract_id, contract_name, regulation_id) VALUES (1, 'Uniswap', 1); INSERT INTO smart_contracts (contract_id, contract_na...
List the regulatory frameworks and the number of smart contracts associated with each of them.
SELECT regulations.regulation_name, COUNT(smart_contracts.contract_id) FROM regulations INNER JOIN smart_contracts ON regulations.regulation_id = smart_contracts.regulation_id GROUP BY regulations.regulation_name;
gretelai_synthetic_text_to_sql
CREATE TABLE Contractors (id INT, name VARCHAR(30), sales_value FLOAT); CREATE TABLE MilitaryEquipmentSales (id INT, contractor_id INT, equipment VARCHAR(30), price FLOAT);
Who are the top 3 defense contractors in terms of total sales value?
SELECT c.name, SUM(m.price) as total_sales FROM Contractors c INNER JOIN MilitaryEquipmentSales m ON c.id = m.contractor_id GROUP BY c.name ORDER BY total_sales DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE cities (city_id INT, city_name VARCHAR(50), state VARCHAR(50));CREATE TABLE regions (region_id INT, region_name VARCHAR(50), state VARCHAR(50));CREATE TABLE water_consumption (consumption_id INT, city_id INT, year INT, consumption FLOAT);CREATE TABLE wastewater_plants (plant_id INT, city_id INT, capacity I...
What is the total water consumption by each city in the California region, including their respective wastewater treatment plant capacities, for the year 2020?
SELECT c.city_name, SUM(w.consumption) AS total_consumption, ww.capacity AS plant_capacity FROM cities c INNER JOIN water_consumption w ON c.city_id = w.city_id AND w.year = 2020 INNER JOIN regions r ON c.region_id = r.region_id INNER JOIN wastewater_plants ww ON c.city_id = ww.city_id GROUP BY c.city_name;
gretelai_synthetic_text_to_sql