context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE Artwork (ArtworkID INT, ArtistID INT, CreationDate DATE); INSERT INTO Artwork (ArtworkID, ArtistID, CreationDate) VALUES (1, 2, '1905-01-01'), (2, 2, '1910-05-15');
Which artist has created the most artwork entries in Africa in each decade since 1900?
SELECT ArtistID, EXTRACT(YEAR FROM CreationDate) AS Decade, COUNT(*) as ArtworkCount FROM Artwork WHERE Continent = 'Africa' GROUP BY ArtistID, Decade ORDER BY Decade, ArtworkCount DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE TotalSales (SaleID INT, SupplierName TEXT, Quantity INT); INSERT INTO TotalSales (SaleID, SupplierName, Quantity) VALUES (601, 'GreenFabrics', 100), (602, 'GreenFabrics', 200), (603, 'EcoWeave', 150), (604, 'EcoWeave', 50), (605, 'StandardTextiles', 60), (606, 'StandardTextiles', 30);
What is the percentage of sales by 'GreenFabrics' out of total sales?
SELECT (SUM(s1.Quantity) / (SELECT SUM(Quantity) FROM TotalSales)) * 100 FROM TotalSales s1 WHERE SupplierName = 'GreenFabrics';
gretelai_synthetic_text_to_sql
CREATE TABLE veteran_employment (state VARCHAR(255), year INT, employment_rate FLOAT); INSERT INTO veteran_employment (state, year, employment_rate) VALUES ('CA', 2019, 0.75); INSERT INTO veteran_employment (state, year, employment_rate) VALUES ('NY', 2018, 0.65);
Show veteran employment statistics by state for the year 2019
SELECT state, employment_rate FROM veteran_employment WHERE year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE iot_sensors (id INT, installation_date DATE, sensor_type VARCHAR(255)); INSERT INTO iot_sensors (id, installation_date, sensor_type) VALUES (5, '2022-03-01', 'temperature'), (6, '2022-03-05', 'humidity'), (7, '2022-04-10', 'moisture'), (8, '2022-04-15', 'light');
Find the difference in the number of IoT sensors installed in March and April.
SELECT COUNT(*) - (SELECT COUNT(*) FROM iot_sensors WHERE MONTH(installation_date) = 4) AS mar_apr_sensor_count_diff FROM iot_sensors WHERE MONTH(installation_date) = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE GreenBuildings (id INT, name VARCHAR(50), location VARCHAR(50), energyConsumption DECIMAL(5,2)); CREATE TABLE Averages (location VARCHAR(50), avg_consumption DECIMAL(5,2)); INSERT INTO Averages (location, avg_consumption) SELECT location, AVG(energyConsumption) FROM GreenBuildings GROUP BY location;
Find the number of buildings in each location that have energy consumption below the average energy consumption in the 'GreenBuildings' table.
SELECT location, COUNT(*) as num_buildings FROM GreenBuildings JOIN Averages ON GreenBuildings.location = Averages.location WHERE GreenBuildings.energyConsumption < Averages.avg_consumption GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE factories (factory_id INT, name TEXT, location TEXT, waste_produced FLOAT, circular_economy BOOLEAN);
Show the total waste produced by each factory in the past year, and whether or not they have implemented a circular economy strategy.
SELECT factory_id, name, SUM(waste_produced) as total_waste, circular_economy FROM factories WHERE date(last_updated) >= date('now','-1 year') GROUP BY factory_id;
gretelai_synthetic_text_to_sql
CREATE TABLE store_sales (sale_date DATE, store_id INT, sale_quantity INT);
Show stores with no sales in the past month
SELECT store_id FROM store_sales WHERE sale_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY store_id HAVING COUNT(*) = 0;
gretelai_synthetic_text_to_sql
CREATE TABLE round_data (company_id INT, round TEXT); INSERT INTO round_data (company_id, round) VALUES (1, 'series A'), (1, 'series B'), (2, 'series C'), (3, 'series D'), (3, 'series A'), (4, 'series C');
How many series D rounds were there for companies founded by immigrants in the "cybersecurity" sector?
SELECT COUNT(*) FROM round_data JOIN company ON round_data.company_id = company.id JOIN founders ON company.id = founders.company_id WHERE company.industry = 'cybersecurity' AND founders.nationality = 'immigrant' AND round_data.round = 'series D';
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, GameDuration FLOAT, Country VARCHAR(50), Platform VARCHAR(50)); INSERT INTO Players (PlayerID, GameDuration, Country, Platform) VALUES (1, 567.8, 'Japan', 'PC'), (2, 678.9, 'India', 'Console'), (3, 345.1, 'Brazil', 'Mobile');
What is the average gameplay duration for players from Japan, India, and Brazil, partitioned by platform?
SELECT AVG(GameDuration) AS AvgGameDuration, Platform FROM Players WHERE Country IN ('Japan', 'India', 'Brazil') GROUP BY Platform, Country WITH ROLLUP;
gretelai_synthetic_text_to_sql
CREATE TABLE PlayerData (PlayerID INT, Name VARCHAR(50), Age INT, Country VARCHAR(50));
Insert data into the 'PlayerData' table with the following records: ('1', 'John Doe', '25', 'USA'), ('2', 'Jane Smith', '30', 'Canada')
INSERT INTO PlayerData (PlayerID, Name, Age, Country) VALUES ('1', 'John Doe', '25', 'USA'), ('2', 'Jane Smith', '30', 'Canada');
gretelai_synthetic_text_to_sql
CREATE TABLE savings (savings_id INT, customer_id INT, savings_amount INT, account_open_date DATE);CREATE TABLE customers (customer_id INT, region TEXT);
What is the total amount of Shariah-compliant savings held by customers in the Middle East region as of 2021-01-01?
SELECT SUM(savings_amount) FROM savings JOIN customers ON savings.customer_id = customers.customer_id WHERE region = 'Middle East' AND account_open_date <= '2021-01-01' AND savings_amount >= 0;
gretelai_synthetic_text_to_sql
CREATE TABLE fabrics (id INT, material VARCHAR(50), color VARCHAR(50), country_of_origin VARCHAR(50));
Update the color column to 'Red' in the fabrics table for all records with material='Cotton'
UPDATE fabrics SET color = 'Red' WHERE material = 'Cotton';
gretelai_synthetic_text_to_sql
CREATE TABLE videos (id INT, title TEXT, release_year INT, watch_time INT, culture TEXT); INSERT INTO videos (id, title, release_year, watch_time, culture) VALUES (1, 'Video1', 2020, 15000, 'Indigenous'); INSERT INTO videos (id, title, release_year, watch_time, culture) VALUES (2, 'Video2', 2021, 12000, 'Indigenous');
What is the total watch time for videos about indigenous culture produced in the last 3 years?
SELECT SUM(watch_time) FROM videos WHERE release_year >= YEAR(CURRENT_DATE) - 3 AND culture = 'Indigenous';
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists engineering;CREATE TABLE engineering.patents (id INT, patent_name VARCHAR(50), country VARCHAR(50));INSERT INTO engineering.patents (id, patent_name, country) VALUES (1, 'Patent1', 'USA'), (2, 'Patent2', 'USA'), (3, 'Patent3', 'Germany'), (4, 'Patent4', 'Japan'), (5, 'Patent5', 'USA'), (6, 'Patent6', 'France');
What are the top 3 countries with the most bioprocess engineering patents?
SELECT country, COUNT(*) as patent_count FROM engineering.patents GROUP BY country ORDER BY patent_count DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE CountryData (country VARCHAR(50), num_spacecraft INT); INSERT INTO CountryData (country, num_spacecraft) VALUES ('USA', 10), ('Russia', 8), ('China', 7), ('India', 5), ('Germany', 3);
What are the top 3 countries with the most spacecraft manufactured?
SELECT country, num_spacecraft FROM CountryData ORDER BY num_spacecraft DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE members_2020 (id INT, name VARCHAR(50), country VARCHAR(50), joined DATE); INSERT INTO members_2020 (id, name, country, joined) VALUES (6, 'Charlie Davis', 'Canada', '2020-05-10'); CREATE TABLE member_workout (member_id INT, activity VARCHAR(50)); INSERT INTO member_workout (member_id, activity) VALUES (1, 'Running'); INSERT INTO member_workout (member_id, activity) VALUES (1, 'Cycling'); INSERT INTO member_workout (member_id, activity) VALUES (6, 'Swimming'); INSERT INTO member_workout (member_id, activity) VALUES (6, 'Yoga');
Find the number of unique workout activities for members who joined in 2020.
SELECT member_id, COUNT(DISTINCT activity) as unique_activities FROM member_workout GROUP BY member_id HAVING joined >= '2020-01-01' AND joined < '2021-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE norwegian_farms (farmer_id INT, fish_species TEXT, farming_method TEXT, biomass FLOAT); INSERT INTO norwegian_farms (farmer_id, fish_species, farming_method, biomass) VALUES (1, 'Salmon', 'Offshore cages', 500.2), (2, 'Cod', 'Ponds', 300.0), (3, 'Salmon', 'Recirculating aquaculture systems', 400.3);
What is the total biomass of Salmon farmed in Norwegian offshore cages?
SELECT SUM(biomass) FROM norwegian_farms WHERE fish_species = 'Salmon' AND farming_method = 'Offshore cages';
gretelai_synthetic_text_to_sql
CREATE TABLE Wages (Id INT, Employee_Id INT, Position VARCHAR(50), Hourly_Rate DECIMAL(5,2), Overtime_Rate DECIMAL(5,2), Date DATE); INSERT INTO Wages (Id, Employee_Id, Position, Hourly_Rate, Overtime_Rate, Date) VALUES (1, 1, 'Operator', 20.50, 30.75, '2020-01-01'); INSERT INTO Wages (Id, Employee_Id, Position, Hourly_Rate, Overtime_Rate, Date) VALUES (2, 2, 'Engineer', 25.50, 35.25, '2020-01-02');
How many employees were paid overtime at each position in the first week of 2020, if any position had over 10 employees with overtime, exclude it from the results?
SELECT Position, COUNT(*) as Overtime_Employees FROM Wages WHERE Date >= '2020-01-01' AND Date < '2020-01-08' AND Overtime_Rate > 0 GROUP BY Position HAVING Overtime_Employees < 10;
gretelai_synthetic_text_to_sql
CREATE TABLE customer (customer_id INT PRIMARY KEY, first_name VARCHAR(50), last_name VARCHAR(50), email VARCHAR(100), credit_limit INT);
Delete the 'credit_limit' column from the 'customer' table
ALTER TABLE customer DROP COLUMN credit_limit;
gretelai_synthetic_text_to_sql
CREATE TABLE Carbon_Offset_Programs (program_id INT, program_name VARCHAR(100), co2_reduction_tonnes FLOAT);
Which carbon offset programs have achieved the greatest reduction in CO2 emissions?
SELECT program_name, co2_reduction_tonnes FROM Carbon_Offset_Programs ORDER BY co2_reduction_tonnes DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Films (film_id INT, title VARCHAR(255), release_date DATE, rating FLOAT, production_country VARCHAR(50)); INSERT INTO Films (film_id, title, release_date, rating, production_country) VALUES (1, 'Movie1', '2000-01-01', 7.5, 'Spain'), (2, 'Movie2', '2005-01-01', 8.2, 'Italy'), (3, 'Movie3', '2010-01-01', 6.8, 'France');
What is the average rating of films produced in Spain and Italy?
SELECT AVG(rating) FROM Films WHERE production_country IN ('Spain', 'Italy');
gretelai_synthetic_text_to_sql
CREATE TABLE projects (id INT, name VARCHAR(255), investment_amount DECIMAL(10,2), sector VARCHAR(255), country VARCHAR(255), project_start_date DATE);
What is the average investment amount in renewable energy projects for each country?
SELECT country, AVG(investment_amount) FROM projects WHERE sector = 'Renewable Energy' GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE sf_crime_stats (id INT, crime_type TEXT, crime_date DATE); INSERT INTO sf_crime_stats (id, crime_type, crime_date) VALUES (1, 'Theft', '2022-01-01'), (2, 'Vandalism', '2022-02-01'), (3, 'Assault', '2022-03-01');
What is the total number of thefts in San Francisco in 2022?
SELECT COUNT(*) FROM sf_crime_stats WHERE crime_type = 'Theft' AND YEAR(crime_date) = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE Manufacturers (id INT, industry VARCHAR(255), name VARCHAR(255), waste_produced INT); INSERT INTO Manufacturers (id, industry, name, waste_produced) VALUES (1, 'Electronics', 'ACME Electronics', 500), (2, 'Electronics', 'DEF Electronics', 750), (3, 'Aerospace', 'GHI Aerospace', 250);
What is the total waste produced by each manufacturer in the electronics industry?
SELECT name, waste_produced FROM Manufacturers WHERE industry = 'Electronics';
gretelai_synthetic_text_to_sql
CREATE TABLE ArtistDemographics (artist VARCHAR(255), age INT, festival VARCHAR(255));
What is the average age of artists who performed at festival 'Z'?
SELECT AVG(age) FROM ArtistDemographics WHERE festival = 'Z';
gretelai_synthetic_text_to_sql
CREATE TABLE incident_resolution_time (id INT, incident_id INT, resolution_time INT, incident_date DATE); INSERT INTO incident_resolution_time (id, incident_id, resolution_time, incident_date) VALUES (1, 1, 2, '2022-03-01'), (2, 2, 5, '2022-03-02'), (3, 3, 10, '2022-03-03');
What is the maximum and minimum resolution time for security incidents in the last month?
SELECT MIN(resolution_time) as min_resolution_time, MAX(resolution_time) as max_resolution_time FROM incident_resolution_time WHERE incident_date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE tv_shows (id INT, title TEXT, country TEXT, year INT); INSERT INTO tv_shows (id, title, country, year) VALUES (1, 'ShowA', 'Japan', 2010), (2, 'ShowB', 'Japan', 2011), (3, 'ShowC', 'USA', 2012);
How many TV shows were produced in Japan each year?
SELECT year, COUNT(*) FROM tv_shows WHERE country = 'Japan' GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE DApps (DApp_ID INT, DApp_Name VARCHAR(100), Developer_Location VARCHAR(50)); INSERT INTO DApps (DApp_ID, DApp_Name, Developer_Location) VALUES (1, 'DApp1', 'USA'), (2, 'DApp2', 'Nigeria'), (3, 'DApp3', 'USA');
What is the total number of decentralized applications created by developers in the US and Africa?
SELECT COUNT(*) FROM DApps WHERE Developer_Location IN ('USA', 'Africa');
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name TEXT, founding_year INT, executive_diversity TEXT); INSERT INTO companies (id, name, founding_year, executive_diversity) VALUES (1, 'GreenTech', 2020, 'Diverse'); INSERT INTO companies (id, name, founding_year, executive_diversity) VALUES (2, 'CleanEnergy', 2018, 'Not Diverse');
How many companies were founded in 2020 with a diverse executive team?
SELECT COUNT(*) FROM companies WHERE founding_year = 2020 AND executive_diversity = 'Diverse';
gretelai_synthetic_text_to_sql
CREATE TABLE company (id INT, name TEXT, industry TEXT, founding_date DATE, founder_ethnicity TEXT); INSERT INTO company (id, name, industry, founding_date, founder_ethnicity) VALUES (1, 'GreenQ', 'Sustainability', '2020-12-15', 'AAPI');
List all companies founded by AAPI individuals in the sustainability sector.
SELECT company.name FROM company WHERE company.founder_ethnicity = 'AAPI' AND company.industry = 'Sustainability';
gretelai_synthetic_text_to_sql
CREATE TABLE space_missions (mission_id INT, mission_name VARCHAR(100), country VARCHAR(50), start_date DATE, end_date DATE); INSERT INTO space_missions (mission_id, mission_name, country, start_date, end_date) VALUES (1, 'Kepler', 'United States', '2009-03-07', '2018-10-30'); INSERT INTO space_missions (mission_id, mission_name, country, start_date, end_date) VALUES (2, 'TESS', 'United States', '2018-04-18', 'ONGOING'); CREATE TABLE discoveries (discovery_id INT, discovery_name VARCHAR(100), discovery_date DATE, mission_id INT); INSERT INTO discoveries (discovery_id, discovery_name, discovery_date, mission_id) VALUES (1, 'Kepler-22b', '2011-12-05', 1); INSERT INTO discoveries (discovery_id, discovery_name, discovery_date, mission_id) VALUES (2, 'Pi Mensae c', '2018-09-15', 2);
List all space missions that have discovered exoplanets.
SELECT mission_name FROM space_missions sm JOIN discoveries d ON sm.mission_id = d.mission_id WHERE d.discovery_name IS NOT NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT PRIMARY KEY, Name VARCHAR(100), Age INT, Sport VARCHAR(50), Country VARCHAR(50)); CREATE TABLE Players_Matches (PlayerID INT, MatchID INT, Points INT, FOREIGN KEY (PlayerID) REFERENCES Players(PlayerID)); INSERT INTO Players_Matches (PlayerID, MatchID, Points) VALUES (1, 1, 25); INSERT INTO Players_Matches (PlayerID, MatchID, Points) VALUES (2, 2, 30);
What is the minimum number of points scored by a cricket player from India in a single match?
SELECT MIN(Points) as MinPoints FROM Players_Matches JOIN Players ON Players.PlayerID = Players_Matches.PlayerID WHERE Players.Country = 'India';
gretelai_synthetic_text_to_sql
CREATE TABLE cases (case_id INT, case_type VARCHAR(255)); INSERT INTO cases (case_id, case_type) VALUES (1, 'Criminal'), (2, 'Family'), (3, 'Personal Injury'), (4, 'Criminal'), (5, 'Family'); CREATE TABLE billing (bill_id INT, case_id INT, amount DECIMAL(10,2)); INSERT INTO billing (bill_id, case_id, amount) VALUES (1, 1, 500.00), (2, 1, 750.00), (3, 2, 600.00), (4, 3, 800.00), (5, 3, 900.00), (6, 4, 1000.00), (7, 4, 1200.00), (8, 5, 1500.00);
What is the minimum billing amount for each case in the 'billing' table, grouped by case type?
SELECT cases.case_type, MIN(billing.amount) FROM billing JOIN cases ON billing.case_id = cases.case_id GROUP BY cases.case_type;
gretelai_synthetic_text_to_sql
CREATE TABLE hourly_trips (city VARCHAR(50), hour INT, trips INT); INSERT INTO hourly_trips (city, hour, trips) VALUES ('New York', 1, 25000), ('New York', 2, 26000), ('New York', 3, 24000), ('Los Angeles', 1, 15000), ('Los Angeles', 2, 16000), ('Los Angeles', 3, 14000), ('Chicago', 1, 22000), ('Chicago', 2, 23000), ('Chicago', 3, 21000);
Show the number of public transportation trips per hour for each city
SELECT city, hour, COUNT(*) as trips_per_hour FROM hourly_trips GROUP BY city, hour;
gretelai_synthetic_text_to_sql
CREATE TABLE ConservationInitiatives (id INT, state TEXT, initiative_id INT);
Determine the number of water conservation initiatives in 'ConservationInitiatives' table for each state.
SELECT state, COUNT(initiative_id) FROM ConservationInitiatives GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE la_school_budget (school_id INT, school_name TEXT, school_city TEXT, budget FLOAT); INSERT INTO la_school_budget (school_id, school_name, school_city, budget) VALUES (1, 'King', 'Los Angeles', 600000), (2, 'Lincoln', 'Los Angeles', 700000), (3, 'Garfield', 'Los Angeles', 550000);
What is the minimum amount of budget allocated per school in the city of Los Angeles?
SELECT MIN(budget) FROM la_school_budget WHERE school_city = 'Los Angeles';
gretelai_synthetic_text_to_sql
CREATE TABLE farms (region VARCHAR(20), practice VARCHAR(20), land_area INT); INSERT INTO farms VALUES ('Africa', 'Agroecology', 1000), ('South America', 'Permaculture', 2000), ('Africa', 'Biodynamics', 1500);
How many small-scale farms in Africa and South America use agroecological practices, and what is the total land area used by these farms?
SELECT f.region, COUNT(f.region) as num_farms, SUM(f.land_area) as total_land_area FROM farms f WHERE f.region IN ('Africa', 'South America') AND f.practice = 'Agroecology' GROUP BY f.region;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas (area_name VARCHAR(255), min_depth DECIMAL(5,2)); INSERT INTO marine_protected_areas (area_name, min_depth) VALUES ('Galapagos Islands', 100.5), ('Great Barrier Reef', 50.0), ('Palau National Marine Sanctuary', 150.0);
Find the minimum depth of any marine protected area
SELECT MIN(min_depth) FROM marine_protected_areas;
gretelai_synthetic_text_to_sql
CREATE TABLE products (id INT, name TEXT, price DECIMAL, is_vegan BOOLEAN, country_of_origin TEXT); INSERT INTO products (id, name, price, is_vegan, country_of_origin) VALUES (1, 'Mascara', 15.99, true, 'France');
What's the average price of vegan makeup products from France?
SELECT AVG(price) FROM products WHERE is_vegan = true AND country_of_origin = 'France';
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, Name VARCHAR(50), Department VARCHAR(50), Salary FLOAT); INSERT INTO Employees (EmployeeID, Name, Department, Salary) VALUES (1, 'John Doe', 'Ethical Manufacturing', 50000.00); INSERT INTO Employees (EmployeeID, Name, Department, Salary) VALUES (2, 'Jane Smith', 'Ethical Manufacturing', 55000.00); INSERT INTO Employees (EmployeeID, Name, Department, Salary) VALUES (3, 'Jim Brown', 'Circular Economy', 45000.00); INSERT INTO Employees (EmployeeID, Name, Department, Salary) VALUES (4, 'Jake White', 'Circular Economy', 40000.00);
What is the name of the employee with the lowest salary in each department?
SELECT Name, Department FROM (SELECT Name, Department, Salary, RANK() OVER (PARTITION BY Department ORDER BY Salary ASC) AS Rank FROM Employees) AS EmployeesRanked WHERE Rank = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE smart_contract_vulnerabilities (id INT, discovered_date DATE, found_in_contract VARCHAR(255)); INSERT INTO smart_contract_vulnerabilities (id, discovered_date, found_in_contract) VALUES (1, '2021-03-01', 'Contract1'), (2, '2022-01-15', 'Contract2'), (3, '2021-12-30', 'Contract3');
Identify the number of smart contract vulnerabilities found in the past year?
SELECT COUNT(*) FROM smart_contract_vulnerabilities WHERE discovered_date >= '2021-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE departments (id INT, name VARCHAR(255)); INSERT INTO departments (id, name) VALUES (1, 'research_and_development'); CREATE TABLE workers (id INT, salary DECIMAL(10,2), department_id INT); INSERT INTO workers (id, salary, department_id) VALUES (1, 60000.00, 1), (2, 65000.00, 1), (3, 70000.00, 1);
What is the maximum salary of workers in the 'research_and_development' department?
SELECT MAX(salary) FROM workers WHERE department_id = (SELECT id FROM departments WHERE name = 'research_and_development');
gretelai_synthetic_text_to_sql
CREATE TABLE vaccine_doses (patient_id INT, vaccine_name VARCHAR(255), administered_date DATE, borough VARCHAR(255)); INSERT INTO vaccine_doses VALUES (1, 'Pfizer-BioNTech', '2021-01-01', 'Queens'); INSERT INTO vaccine_doses VALUES (2, 'Moderna', '2021-01-15', 'Brooklyn');
What is the number of individuals who have received the COVID-19 vaccine in each borough of New York City?
SELECT borough, COUNT(DISTINCT patient_id) FROM vaccine_doses GROUP BY borough;
gretelai_synthetic_text_to_sql
CREATE TABLE productions (id INT, garment VARCHAR(50), material VARCHAR(50), country VARCHAR(50), production_date DATE); INSERT INTO productions (id, garment, material, country, production_date) VALUES (1, 'T-Shirt', 'Recycled Polyester', 'Turkey', '2021-01-15'), (2, 'Hoodie', 'Organic Cotton', 'Turkey', '2021-02-20'), (3, 'Jacket', 'Recycled Polyester', 'Turkey', '2021-03-10');
How many garments made of recycled polyester are produced per month in Turkey?
SELECT material, COUNT(*) as monthly_production FROM productions WHERE country = 'Turkey' AND material = 'Recycled Polyester' GROUP BY EXTRACT(MONTH FROM production_date);
gretelai_synthetic_text_to_sql
CREATE TABLE Space_Missions (Mission_ID INT, Mission_Name VARCHAR(50), Budget INT, Year INT, PRIMARY KEY (Mission_ID)); INSERT INTO Space_Missions (Mission_ID, Mission_Name, Budget, Year) VALUES (1, 'Artemis I', 240000000, 2020), (2, 'Mars 2020', 2800000000, 2020), (3, 'Hubble Space Telescope', 10000000000, 1990);
What was the total budget for space missions in 2020?
SELECT SUM(Budget) FROM Space_Missions WHERE Year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE VolunteerHours (VolunteerHoursID INT, VolunteerDate DATE, ProgramType TEXT, VolunteerHours DECIMAL); INSERT INTO VolunteerHours (VolunteerHoursID, VolunteerDate, ProgramType, VolunteerHours) VALUES (1, '2022-01-01', 'Food Security', 50), (2, '2022-01-05', 'Education', 75), (3, '2022-02-10', 'Healthcare', 80);
What are the total volunteer hours per month and per program type?
SELECT DATE_TRUNC('month', VolunteerDate) as Month, ProgramType, SUM(VolunteerHours) as TotalHours FROM VolunteerHours GROUP BY Month, ProgramType;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, DonorName TEXT, DonorCountry TEXT); INSERT INTO Donors (DonorID, DonorName, DonorCountry) VALUES (1, 'John Doe', 'USA'), (2, 'Jane Smith', 'Canada'); CREATE TABLE Donations (DonationID INT, DonorID INT, DonationAmount DECIMAL); INSERT INTO Donations (DonationID, DonorID, DonationAmount) VALUES (1, 1, 50.00), (2, 1, 100.00), (3, 2, 75.00);
What's the average donation amount per donor from the US?
SELECT AVG(Donations.DonationAmount) FROM Donors INNER JOIN Donations ON Donors.DonorID = Donations.DonorID WHERE Donors.DonorCountry = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_pollution (id INT, location VARCHAR(255), pollution_level INT, measurement_date DATE); INSERT INTO ocean_pollution (id, location, pollution_level, measurement_date) VALUES (1, 'Pacific Ocean', 50, '2021-01-01'), (2, 'Pacific Ocean', 45, '2021-02-01'), (3, 'Pacific Ocean', 40, '2021-03-01'), (4, 'Atlantic Ocean', 70, '2021-01-01'), (5, 'Atlantic Ocean', 75, '2021-02-01'), (6, 'Atlantic Ocean', 80, '2021-03-01');
Calculate the average pollution level for the last 6 months in the Pacific Ocean and the Atlantic Ocean
SELECT location, AVG(pollution_level) average_pollution FROM ocean_pollution WHERE measurement_date >= NOW() - INTERVAL 6 MONTH GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE wells (well_id INT, well_name VARCHAR(255), region VARCHAR(255), production FLOAT);
Insert a new record into the 'wells' table for well 'A-02' in the 'North Sea' region with a production value of 1200
INSERT INTO wells (well_id, well_name, region, production) VALUES (NULL, 'A-02', 'North Sea', 1200);
gretelai_synthetic_text_to_sql
CREATE TABLE SpaceMissionRecords (mission_name VARCHAR(30), astronaut_name VARCHAR(30), country VARCHAR(20), mission_duration INT); INSERT INTO SpaceMissionRecords (mission_name, astronaut_name, country, mission_duration) VALUES ('Moon Landing', 'Neil Armstrong', 'USA', 196), ('Mars Exploration', 'Amy Johnson', 'USA', 250);
What is the maximum duration of space missions led by US astronauts?
SELECT MAX(mission_duration) FROM SpaceMissionRecords WHERE country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE sustainable_practices (practice_id INT, description TEXT, category VARCHAR(20)); INSERT INTO sustainable_practices (practice_id, description, category) VALUES (3, 'Using energy-efficient lighting', 'Waste');
Update the record in the "sustainable_practices" table with an ID of 3 to have a category of 'Energy'
UPDATE sustainable_practices SET category = 'Energy' WHERE practice_id = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE investments (investment_id INT, investor_id INT, sector VARCHAR(20), investment_value DECIMAL(10,2)); INSERT INTO investments (investment_id, investor_id, sector, investment_value) VALUES (1, 1, 'technology', 5000.00), (2, 2, 'finance', 3000.00);
What is the total value of investments in the technology sector?
SELECT SUM(investment_value) FROM investments WHERE sector = 'technology';
gretelai_synthetic_text_to_sql
CREATE TABLE GameDesign (GameID INT, GameName VARCHAR(50), Developer VARCHAR(50), ReleaseYear INT);
Insert sample data into the 'GameDesign' table
INSERT INTO GameDesign (GameID, GameName, Developer, ReleaseYear) VALUES ('1', 'Fortnite', 'Epic Games', '2017'), ('2', 'Among Us', 'InnerSloth', '2018');
gretelai_synthetic_text_to_sql
CREATE TABLE therapy_sessions (patient_id INT, session_type VARCHAR(20), state VARCHAR(20), quarter INT, year INT); INSERT INTO therapy_sessions VALUES (1, 'Group', 'California', 1, 2022), (2, 'Individual', 'California', 1, 2022), (3, 'Group', 'California', 1, 2022);
What is the number of unique patients who received group therapy sessions in California in Q1 2022?
SELECT COUNT(DISTINCT patient_id) FROM therapy_sessions WHERE session_type = 'Group' AND state = 'California' AND quarter = 1 AND year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE dispensaries (id INT, name TEXT, state TEXT); INSERT INTO dispensaries (id, name, state) VALUES (1, 'Eaze', 'CA'), (2, 'MedMen', 'NY'), (3, 'Harborside', 'CA'), (4, 'LivWell', 'CO');
How many dispensaries are there in the state of California?
SELECT COUNT(*) FROM dispensaries WHERE state = 'CA';
gretelai_synthetic_text_to_sql
CREATE TABLE marine_farms (farm_id INT, location VARCHAR(20), sea_temperature FLOAT); INSERT INTO marine_farms (farm_id, location, sea_temperature) VALUES (1, 'Bay Area', 15.2), (2, 'Seattle', 12.1), (3, 'Miami', 27.3);
Which marine farms have a higher sea temperature than the average?
SELECT farm_id, location, sea_temperature FROM (SELECT farm_id, location, sea_temperature, AVG(sea_temperature) OVER () avg_temp FROM marine_farms) t WHERE sea_temperature > avg_temp;
gretelai_synthetic_text_to_sql
CREATE TABLE contractor_maintenance(contractor_id INT, request_date DATE, request_type VARCHAR(20)); INSERT INTO contractor_maintenance(contractor_id, request_date, request_type) VALUES (1, '2021-01-01', 'equipment_inspection'), (2, '2021-01-05', 'parts_replacement'), (1, '2021-01-10', 'equipment_repair');
What is the total number of military equipment maintenance requests by contractor, ordered by total count in descending order?
SELECT contractor_id, COUNT(*) as total_requests FROM contractor_maintenance GROUP BY contractor_id ORDER BY total_requests DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE category_emissions (product_id INT, category VARCHAR(255), co2_emissions DECIMAL(10,2)); INSERT INTO category_emissions (product_id, category, co2_emissions) VALUES (1, 'Category A', 1.25), (2, 'Category B', 3.00), (3, 'Category A', 1.50);
What is the average CO2 emission for products in each category?
SELECT category, AVG(co2_emissions) as avg_co2_emissions FROM category_emissions GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE Satellites (satellite_id INT, manufacturer VARCHAR(255), delivery_time FLOAT); INSERT INTO Satellites (satellite_id, manufacturer, delivery_time) VALUES (1, 'SpaceTech Inc.', 340.5), (2, 'Galactic Systems', 285.6), (3, 'SpaceTech Inc.', 362.9);
What is the average delivery time for satellites manufactured by SpaceTech Inc.?
SELECT AVG(delivery_time) FROM Satellites WHERE manufacturer = 'SpaceTech Inc.';
gretelai_synthetic_text_to_sql
CREATE TABLE social_good (project_id INT, budget FLOAT, region TEXT); INSERT INTO social_good (project_id, budget, region) VALUES (1, 35000, 'Middle East'), (2, 50000, 'Europe'), (3, 70000, 'Middle East');
What is the average budget for technology for social good projects in the Middle East?
SELECT AVG(budget) FROM social_good WHERE region = 'Middle East';
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists rural_development; use rural_development; CREATE TABLE IF NOT EXISTS rural_infrastructure (id INT, name VARCHAR(255), cost FLOAT, PRIMARY KEY (id)); INSERT INTO rural_infrastructure (id, name, cost) VALUES (1, 'Rural Electrification', 150000.00), (2, 'Irrigation System', 75000.00), (3, 'Rural Telecommunications', 200000.00);
Delete all records with a cost less than 100000 from the 'rural_infrastructure' table.
DELETE FROM rural_infrastructure WHERE cost < 100000.00;
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_energy (name TEXT, location TEXT, type TEXT); INSERT INTO renewable_energy (name, location, type) VALUES ('Project 1', 'Country K', 'Wind'), ('Project 2', 'Country L', 'Solar'), ('Project 3', 'Country K', 'Geothermal');
How many renewable energy projects are in Country K?
SELECT COUNT(*) FROM renewable_energy WHERE location = 'Country K';
gretelai_synthetic_text_to_sql
CREATE TABLE Missions (id INT, name VARCHAR(50), company VARCHAR(50), mission_type VARCHAR(50), duration INT); INSERT INTO Missions (id, name, company, mission_type, duration) VALUES (1, 'Magellan 1', 'Interplanetary Inc.', 'Venus', 365), (2, 'Magellan 2', 'Interplanetary Inc.', 'Venus', 420), (3, 'Magellan 3', 'Interplanetary Inc.', 'Venus', 390);
What is the maximum duration of Venus missions conducted by 'Interplanetary Inc.'?
SELECT MAX(duration) FROM Missions WHERE company = 'Interplanetary Inc.' AND mission_type = 'Venus';
gretelai_synthetic_text_to_sql
CREATE TABLE entries (id INT PRIMARY KEY, station_name VARCHAR(255), line VARCHAR(255), entries INT); INSERT INTO entries (id, station_name, line, entries) VALUES (1, '14 St - Union Sq', 'N', 500), (2, 'Bedford Ave', 'L', 400);
Determine the number of unique subway lines in New York City.
SELECT COUNT(DISTINCT line) AS num_lines FROM entries;
gretelai_synthetic_text_to_sql
CREATE TABLE WaterTreatmentPlants (plant_id INT, location VARCHAR(50), treatment_type VARCHAR(20));
Count the number of water treatment plants in 'WaterTreatmentPlants' table where the treatment type is 'Filtration'
SELECT COUNT(*) FROM WaterTreatmentPlants WHERE treatment_type = 'Filtration';
gretelai_synthetic_text_to_sql
CREATE TABLE citizen_feedback (id INT PRIMARY KEY, city VARCHAR(255), age INT, feedback TEXT); CREATE TABLE public_services (id INT PRIMARY KEY, service VARCHAR(255), location VARCHAR(255), budget DECIMAL(10, 2), provider VARCHAR(255));
Calculate the average age of citizens giving feedback for each public service.
SELECT p.service, AVG(f.age) FROM public_services p INNER JOIN citizen_feedback f ON p.location = f.city GROUP BY p.service;
gretelai_synthetic_text_to_sql
CREATE TABLE arctic_research_stations (id INT, name TEXT, location TEXT); INSERT INTO arctic_research_stations (id, name, location) VALUES (1, 'Toolik Field Station', 'Alaska'); INSERT INTO arctic_research_stations (id, name, location) VALUES (2, 'Zackenberg Research Station', 'Greenland'); INSERT INTO arctic_research_stations (id, name, location) VALUES (3, 'Koldeway Station', 'Norway'); CREATE TABLE species_observations (station_id INT, species_name TEXT); INSERT INTO species_observations (station_id, species_name) VALUES (1, 'Species A'); INSERT INTO species_observations (station_id, species_name) VALUES (1, 'Species B'); INSERT INTO species_observations (station_id, species_name) VALUES (2, 'Species A'); INSERT INTO species_observations (station_id, species_name) VALUES (2, 'Species C'); INSERT INTO species_observations (station_id, species_name) VALUES (3, 'Species A'); INSERT INTO species_observations (station_id, species_name) VALUES (3, 'Species B'); INSERT INTO species_observations (station_id, species_name) VALUES (3, 'Species C'); INSERT INTO species_observations (station_id, species_name) VALUES (3, 'Species D');
Which arctic research stations have observed more than 50 unique species?
SELECT station_id, COUNT(DISTINCT species_name) as species_count FROM species_observations GROUP BY station_id HAVING species_count > 50;
gretelai_synthetic_text_to_sql
CREATE TABLE AnimalPopulation (animal_id INT, common_name VARCHAR(50), status VARCHAR(50)); INSERT INTO AnimalPopulation (animal_id, common_name, status) VALUES (1, 'Cheetah', 'Vulnerable'), (2, 'Tiger', 'Endangered'), (3, 'GiantPanda', 'Endangered'), (4, 'MountainGorilla', 'Critically Endangered'), (5, 'BlackRhino', 'Critically Endangered'), (6, 'PassengerPigeon', 'Extinct'), (7, 'Elephant', 'Vulnerable'), (8, 'Giraffe', 'Vulnerable');
What is the total number of animals in the "AnimalPopulation" table that are either vulnerable or endangered?
SELECT COUNT(*) FROM AnimalPopulation WHERE status IN ('Vulnerable', 'Endangered');
gretelai_synthetic_text_to_sql
CREATE TABLE teams (team_name VARCHAR(255), season_start_year INT, season_end_year INT); INSERT INTO teams (team_name, season_start_year, season_end_year) VALUES ('Suns', 2020, 2021); CREATE TABLE games (team_name VARCHAR(255), location VARCHAR(255), won BOOLEAN);
How many games did the Suns win at home in the 2020-2021 season?
SELECT COUNT(*) FROM games WHERE team_name = 'Suns' AND location = 'home' AND won = TRUE AND season_start_year = 2020 AND season_end_year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE sustainable_building (id INT, project_id INT, city VARCHAR(255), timeline FLOAT, cost FLOAT, renewable_energy BOOLEAN);
What is the average cost of sustainable building projects in the city of Seattle, comparing projects that use renewable energy with those that don't?
SELECT AVG(cost), renewable_energy FROM sustainable_building WHERE city = 'Seattle' GROUP BY renewable_energy;
gretelai_synthetic_text_to_sql
CREATE TABLE smart_city_projects (vendor VARCHAR(255), city VARCHAR(255));
Identify smart city technology vendors that have implemented projects in both New York and Tokyo.
SELECT vendor FROM smart_city_projects WHERE city IN ('New York', 'Tokyo') GROUP BY vendor HAVING COUNT(DISTINCT city) = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE building_permits (permit_number VARCHAR(10), issue_date DATE, contractor_name VARCHAR(50), project_type VARCHAR(20));
Insert a new building permit for a residential project in Austin, Texas, with permit number '2022-101', issued on '2022-03-15', and assigned to 'ABC Construction Inc.'
INSERT INTO building_permits (permit_number, issue_date, contractor_name, project_type) VALUES ('2022-101', '2022-03-15', 'ABC Construction Inc.', 'Residential');
gretelai_synthetic_text_to_sql
CREATE TABLE user (user_id INT, name VARCHAR(50)); INSERT INTO user (user_id, name) VALUES (8, 'Nina White');
Update the name for user with ID 8 to 'Nia White'
WITH updated_user AS (UPDATE user SET name = 'Nia White' WHERE user_id = 8 RETURNING *) SELECT * FROM updated_user;
gretelai_synthetic_text_to_sql
CREATE TABLE rural_clinic_2 (procedure_id INT, cost DECIMAL(5,2)); INSERT INTO rural_clinic_2 (procedure_id, cost) VALUES (1, 100.50), (2, 150.25), (3, 75.00);
What is the total cost of procedures in the 'rural_clinic_2' table?
SELECT SUM(cost) FROM rural_clinic_2;
gretelai_synthetic_text_to_sql
CREATE TABLE clinics (id INT, name TEXT, service TEXT, location TEXT, state TEXT);
Insert records of new clinics in New Mexico offering primary care, pediatrics, and dental services.
INSERT INTO clinics (id, name, service, location, state) VALUES (1, 'Southwest Care', 'Primary Care', 'New Mexico', 'New Mexico'); INSERT INTO clinics (id, name, service, location, state) VALUES (2, 'Desert Sun Pediatrics', 'Pediatrics', 'New Mexico', 'New Mexico'); INSERT INTO clinics (id, name, service, location, state) VALUES (3, 'Mountain Dental', 'Dental', 'New Mexico', 'New Mexico')
gretelai_synthetic_text_to_sql
CREATE TABLE space_missions (id INT, name VARCHAR(50), company VARCHAR(50), launch_date DATE);
What is the number of space missions launched by private companies between 2010 and 2020?
SELECT COUNT(*) as number_of_missions FROM space_missions JOIN company ON space_missions.company = company.name WHERE company.type = 'private' AND space_missions.launch_date BETWEEN '2010-01-01' AND '2020-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE products(product_id VARCHAR(20), launch_date DATE); INSERT INTO products (product_id, launch_date) VALUES ('Product B', '2021-09-01'); CREATE TABLE sales(product_id VARCHAR(20), store_location VARCHAR(20), sale_date DATE, quantity INTEGER); INSERT INTO sales (product_id, store_location, sale_date, quantity) VALUES ('Product B', 'California Store 1', '2021-09-05', 12), ('Product B', 'California Store 2', '2021-09-07', 30);
Which stores in California have sold more than 20 units of product B since its launch?
SELECT store_location, SUM(quantity) FROM sales JOIN products ON sales.product_id = products.product_id WHERE sales.product_id = 'Product B' AND sale_date >= products.launch_date AND store_location LIKE 'California%' GROUP BY store_location HAVING SUM(quantity) > 20;
gretelai_synthetic_text_to_sql
CREATE TABLE rural_infrastructure (id INT, project_name VARCHAR(255), start_date DATE, end_date DATE); INSERT INTO rural_infrastructure (id, project_name, start_date, end_date) VALUES (1, 'Road Construction', '2021-01-01', '2023-01-01'), (2, 'Bridge Building', '2020-06-15', '2022-06-15');
List the names of rural infrastructure projects and their respective end dates.
SELECT project_name, end_date FROM rural_infrastructure;
gretelai_synthetic_text_to_sql
CREATE TABLE labor_statistics (id INT, added_date DATE, category VARCHAR(255), title VARCHAR(255), hourly_wage DECIMAL(5,2));
How many labor statistics records were added per month in 2019?
SELECT DATE_FORMAT(added_date, '%Y-%m') as month, COUNT(*) as records_added FROM labor_statistics WHERE YEAR(added_date) = 2019 GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE digital_assets (asset_id INT, name VARCHAR(100), market_cap DECIMAL(20,2)); INSERT INTO digital_assets (asset_id, name, market_cap) VALUES (1, 'Asset1', 2000000000), (2, 'Asset2', 1200000000), (3, 'Asset3', 3000000000), (4, 'Asset4', 500000000), (5, 'Asset5', 1000000000); CREATE TABLE smart_contracts (contract_id INT, name VARCHAR(100), network VARCHAR(100)); INSERT INTO smart_contracts (contract_id, name, network) VALUES (1, 'Contract1', 'Ethereum'), (2, 'Contract2', 'Ethereum'), (3, 'Contract3', 'Ethereum'), (4, 'Contract4', 'Binance Smart Chain'), (5, 'Contract5', 'Polygon');
What are the digital assets with a market capitalization greater than $1,000,000,000 and their respective smart contracts on the Ethereum network?
SELECT da.name, sc.name FROM digital_assets da INNER JOIN smart_contracts sc ON da.name = sc.name WHERE da.market_cap > 1000000000 AND sc.network = 'Ethereum';
gretelai_synthetic_text_to_sql
CREATE TABLE agroecology (crop_type VARCHAR(255), temperature FLOAT);
What is the average temperature for each crop type in the agroecology dataset?
SELECT crop_type, AVG(temperature) as avg_temperature FROM agroecology GROUP BY crop_type;
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_subscribers(id INT, name VARCHAR(50), has_made_international_calls BOOLEAN, date DATE); CREATE TABLE broadband_subscribers(id INT, name VARCHAR(50), has_made_international_calls BOOLEAN, date DATE);
What is the total number of mobile and broadband subscribers who have made international calls in the last month?
SELECT 'mobile' as type, COUNT(*) as total_subscribers FROM mobile_subscribers WHERE has_made_international_calls = TRUE AND date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH) UNION ALL SELECT 'broadband' as type, COUNT(*) as total_subscribers FROM broadband_subscribers WHERE has_made_international_calls = TRUE AND date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE mine_stats (mine_name VARCHAR(255), country VARCHAR(255), mineral VARCHAR(255), quantity INT, year INT); INSERT INTO mine_stats (mine_name, country, mineral, quantity, year) VALUES ('Driefontein', 'South Africa', 'Gold', 1500, 2018), ('Kloof', 'South Africa', 'Gold', 1200, 2018), ('Mponeng', 'South Africa', 'Gold', 1000, 2018);
What is the average gold production per mine located in South Africa for the year 2018?
SELECT country, AVG(quantity) as avg_gold_production FROM mine_stats WHERE country = 'South Africa' AND mineral = 'Gold' GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE clinic_7 (patient_id INT, therapy_received BOOLEAN); INSERT INTO clinic_7 (patient_id, therapy_received) VALUES (1, true), (2, false), (3, true), (14, false); CREATE TABLE clinic_8 (patient_id INT, therapy_received BOOLEAN); INSERT INTO clinic_8 (patient_id, therapy_received) VALUES (4, false), (5, true), (6, false), (15, false);
Determine the number of patients who received therapy in 'clinic_7' and did not receive therapy in 'clinic_8'
SELECT 'clinic_7' AS clinic, COUNT(*) FROM clinic_7 WHERE therapy_received = true INTERSECT SELECT 'clinic_8' AS clinic, COUNT(*) FROM clinic_8 WHERE therapy_received = false;
gretelai_synthetic_text_to_sql
CREATE TABLE vulnerabilities (id INT, sector VARCHAR(255), vulnerability VARCHAR(255)); INSERT INTO vulnerabilities (id, sector, vulnerability) VALUES (1, 'healthcare', 'SQL injection'), (2, 'finance', 'Cross-site scripting');
What are the total number of vulnerabilities found in the healthcare sector?
SELECT COUNT(*) FROM vulnerabilities WHERE sector = 'healthcare';
gretelai_synthetic_text_to_sql
CREATE TABLE cars (make text, model text, year integer, efficiency decimal);
What was the energy efficiency rating of the top 10 most efficient cars in the US and Canada, by make and model, in 2019?
SELECT make, model, MAX(efficiency) as top_efficiency FROM cars WHERE year = 2019 AND country IN ('US', 'Canada') GROUP BY make, model ORDER BY top_efficiency DESC LIMIT 10;
gretelai_synthetic_text_to_sql
CREATE TABLE prepaid_plans (id INT, plan_name VARCHAR(20), region VARCHAR(10), monthly_bill INT); INSERT INTO prepaid_plans (id, plan_name, region, monthly_bill) VALUES (1, 'Basic', 'oceanic', 30), (2, 'Plus', 'oceanic', 40), (3, 'Premium', 'oceanic', 50); CREATE TABLE subscribers (id INT, type VARCHAR(10), region VARCHAR(10), unlimited BOOLEAN); INSERT INTO subscribers (id, type, region, unlimited) VALUES (1, 'postpaid', 'oceanic', FALSE), (2, 'postpaid', 'oceanic', TRUE);
What is the minimum monthly bill for postpaid mobile customers in the "oceanic" region, excluding those with unlimited plans?
SELECT MIN(monthly_bill) FROM prepaid_plans JOIN subscribers ON prepaid_plans.region = subscribers.region WHERE subscribers.type = 'postpaid' AND subscribers.region = 'oceanic' AND subscribers.unlimited = FALSE;
gretelai_synthetic_text_to_sql
CREATE TABLE stellar_transactions (transaction_id INT, fee DECIMAL(10, 2), value DECIMAL(20, 2)); INSERT INTO stellar_transactions (transaction_id, fee, value) VALUES (1, 0.01, 500), (2, 0.02, 1200), (3, 0.03, 800), (4, 0.04, 1500), (5, 0.05, 200);
What is the average transaction fee on the Stellar blockchain, and what is the minimum fee for transactions with a value greater than 1000?
SELECT AVG(fee), MIN(fee) FROM stellar_transactions WHERE value > 1000;
gretelai_synthetic_text_to_sql
CREATE TABLE infections (id INT, patient_id INT, infection VARCHAR(50), date DATE, city VARCHAR(50)); INSERT INTO infections (id, patient_id, infection, date, city) VALUES (3, 3, 'Covid-19', '2022-02-01', 'Tokyo'); INSERT INTO infections (id, patient_id, infection, date, city) VALUES (4, 4, 'Flu', '2022-03-01', 'Tokyo');
Which infectious diseases have been reported in Tokyo this year?
SELECT DISTINCT infection FROM infections WHERE city = 'Tokyo' AND date >= '2022-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE articles (id INT, title VARCHAR(100), content TEXT, publish_date DATE); INSERT INTO articles (id, title, content, publish_date) VALUES (1, 'Article 1', 'Content 1', '2019-12-31'), (2, 'Article 2', 'Content 2', '2020-01-01'), (3, 'Article 3', 'Content 3', '2020-01-02');
Which articles were published before 2020-01-01?
SELECT * FROM articles WHERE publish_date < '2020-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE songs (song_id INT, title TEXT, release_year INT, artist_id INT, revenue FLOAT); CREATE TABLE artists (artist_id INT, name TEXT);
What is the total revenue generated by each artist in the last 5 years?
SELECT a.name, SUM(s.revenue) FROM songs s JOIN artists a ON s.artist_id = a.artist_id WHERE s.release_year >= 2016 GROUP BY a.name;
gretelai_synthetic_text_to_sql
CREATE TABLE member_workouts_2021 (member_id INT, workout_date DATE); CREATE TABLE member_workouts_2022 (member_id INT, workout_date DATE);
Which members have a workout record in both 2021 and 2022?
SELECT mw21.member_id FROM member_workouts_2021 mw21 INNER JOIN member_workouts_2022 mw22 ON mw21.member_id = mw22.member_id;
gretelai_synthetic_text_to_sql
CREATE TABLE broadband_speeds (speed_test_id INT, technology VARCHAR(10), median_speed INT);
What is the average broadband speed for each technology?
SELECT technology, AVG(median_speed) AS avg_median_speed FROM broadband_speeds GROUP BY technology;
gretelai_synthetic_text_to_sql
CREATE TABLE Facilities (Year INT, FacilityType TEXT); INSERT INTO Facilities (Year, FacilityType) VALUES (2018, 'PublicLibrary'), (2019, 'PublicLibrary'), (2020, 'PublicLibrary'), (2021, 'PublicLibrary');
How many public libraries were opened in each year from 2018 to 2021?
SELECT Year, COUNT(*) FROM Facilities WHERE FacilityType = 'PublicLibrary' GROUP BY Year;
gretelai_synthetic_text_to_sql
CREATE TABLE artworks (id INT, artist_id INT, art_type VARCHAR(255), year INT); INSERT INTO artworks (id, artist_id, art_type, year) VALUES (1, 1, 'visual', 2005), (2, 1, 'visual', 2010), (3, 2, 'visual', 2015), (4, 3, 'sculpture', 2000), (5, 3, 'visual', 2008), (6, 4, 'visual', 2012), (7, 4, 'sculpture', 2018), (8, 5, 'visual', 2003); INSERT INTO artists (id, name, nationality) VALUES (1, 'Rufino Tamayo', 'Mexico'), (2, 'Francisco Toledo', 'Mexico'), (3, 'Diego Rivera', 'Mexico'), (4, 'José Clemente Orozco', 'Mexico'), (5, 'David Alfaro Siqueiros', 'Mexico');
How many visual artworks have been created by Indigenous artists in Mexico since 2000?
SELECT COUNT(*) FROM artworks a JOIN artists ar ON a.artist_id = ar.id WHERE ar.nationality = 'Mexico' AND a.art_type = 'visual' AND a.year >= 2000;
gretelai_synthetic_text_to_sql
CREATE TABLE SafetyRecords (ID INT PRIMARY KEY, VesselID INT, Category TEXT); INSERT INTO SafetyRecords (ID, VesselID, Category) VALUES (1, 1, 'excellent'), (2, 2, 'excellent'), (3, 3, 'excellent');
Update the safety record category to 'good' for vessel with ID 2 in the 'SafetyRecords' table.
UPDATE SafetyRecords SET Category = 'good' WHERE VesselID = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE students_mental_health (student_id INT, school_id INT, mental_health_score INT);
What is the average mental health score of students per school, with a mental health score above 80, from the "students_mental_health" table?
SELECT school_id, AVG(mental_health_score) as avg_mental_health_score FROM students_mental_health WHERE mental_health_score > 80 GROUP BY school_id;
gretelai_synthetic_text_to_sql
CREATE TABLE WasteGeneration (Site VARCHAR(50), Chemical VARCHAR(50), WasteScore INT, WasteDate DATETIME);
Find the chemical with the highest waste generation score in the past month, per manufacturing site?
SELECT Site, MAX(WasteScore) OVER (PARTITION BY Site ORDER BY WasteDate ROWS BETWEEN 29 PRECEDING AND CURRENT ROW) AS MaxWasteScore, Chemical FROM WasteGeneration
gretelai_synthetic_text_to_sql
CREATE TABLE spacecraft (id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255), launch_date DATE, discovered_exoplanets BOOLEAN);
What is the earliest launch date for a spacecraft that has discovered exoplanets?
SELECT name, MIN(launch_date) FROM spacecraft WHERE discovered_exoplanets = TRUE GROUP BY name;
gretelai_synthetic_text_to_sql
CREATE TABLE ships (ship_id INT, ship_name VARCHAR(255), registration_date DATE, fleet_id INT); INSERT INTO ships VALUES (1, 'Sea Giant', '2010-03-23', 1), (2, 'Poseidon', '2012-09-08', 1); CREATE TABLE fleets (fleet_id INT, fleet_name VARCHAR(255)); INSERT INTO fleets VALUES (1, 'Sea Fleet');
Insert a new ship 'Titan' with registration date '2020-05-15' and add it to the fleet
INSERT INTO ships (ship_id, ship_name, registration_date, fleet_id) VALUES (3, 'Titan', '2020-05-15', 1);
gretelai_synthetic_text_to_sql