context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE SCHEMA indigenous_systems;CREATE TABLE farmers (id INT, name VARCHAR(50), region VARCHAR(50), area_ha FLOAT);INSERT INTO indigenous_systems.farmers (id, name, region, area_ha) VALUES (1, 'Farmer 1', 'Region A', 30.5), (2, 'Farmer 2', 'Region B', 45.8), (3, 'Farmer 3', 'Region A', 55.2), (4, 'Farmer 4', 'Region C', 65.9);
Identify the number of farmers in each region, along with the total area of farmland they manage, in the 'indigenous_systems' schema?
SELECT region, COUNT(*), SUM(area_ha) FROM indigenous_systems.farmers GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE biosensor_development (id INT, organization TEXT, year INT, quantity INT); INSERT INTO biosensor_development (id, organization, year, quantity) VALUES (1, 'BioSolutions', 2019, 50);
Which organizations developed biosensors in the US before 2020?
SELECT DISTINCT organization FROM biosensor_development WHERE year < 2020 AND country = 'US';
gretelai_synthetic_text_to_sql
CREATE TABLE mitigation_projects (id INT, country VARCHAR(255), sector VARCHAR(255), funding_source VARCHAR(255), amount FLOAT);
Delete records from the 'mitigation_projects' table where the 'country' is 'Brazil' and 'sector' is 'Energy' and the 'funding_source' is 'Government'
DELETE FROM mitigation_projects WHERE country = 'Brazil' AND sector = 'Energy' AND funding_source = 'Government';
gretelai_synthetic_text_to_sql
CREATE TABLE impact_investing (donor_id INT, donation_amount DECIMAL(10,2), donation_date DATE, country VARCHAR(50)); INSERT INTO impact_investing VALUES (1, 50000, '2020-01-01', 'United States'), (2, 75000, '2020-02-01', 'Canada'), (3, 35000, '2020-03-01', 'Mexico');
What are the top 3 countries with the most donations in the impact investing sector?
SELECT country, SUM(donation_amount) as total_donation FROM impact_investing GROUP BY country ORDER BY total_donation DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE drilling_operations (id INT, location VARCHAR(50), cost FLOAT); INSERT INTO drilling_operations (id, location, cost) VALUES (1, 'North Sea', 6000000), (2, 'North Sea', 3000000), (3, 'North Sea', 8000000);
Calculate the total number of drilling operations in the North Sea with a cost higher than $5M.
SELECT COUNT(*) FROM drilling_operations WHERE location = 'North Sea' AND cost > 5000000;
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_offset_programs (program_id INT, program_name TEXT, location TEXT);
Insert a new carbon offset program for 'Community Tree Planting' in 'Indigenous Territory Z'
INSERT INTO carbon_offset_programs (program_id, program_name, location) VALUES (5, 'Community Tree Planting', 'Indigenous Territory Z');
gretelai_synthetic_text_to_sql
CREATE TABLE model_fairness (model_id INT, fairness_score DECIMAL(3,2)); INSERT INTO model_fairness (model_id, fairness_score) VALUES (1, 0.85), (2, 0.70), (3, 0.92), (4, 0.68), (5, 0.89);
Display the names and fairness scores of models that have a higher fairness score than the average fairness score.
SELECT model_id, fairness_score FROM model_fairness WHERE fairness_score > (SELECT AVG(fairness_score) FROM model_fairness);
gretelai_synthetic_text_to_sql
CREATE TABLE civil_projects (id INT, project_name VARCHAR(50), location VARCHAR(50), start_date DATE, end_date DATE, total_cost FLOAT); INSERT INTO civil_projects (id, project_name, location, start_date, end_date, total_cost) VALUES (1, 'Dam Construction', 'Texas', '2018-05-01', '2020-01-15', 1500000.00), (2, 'Water Treatment Plant Upgrade', 'Florida', '2019-06-01', '2021-03-31', 800000.00);
Which infrastructure projects in 'civil_projects' were completed before 2020-01-01?
SELECT project_name FROM civil_projects WHERE end_date < '2020-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE checking (customer_id INT, account_type VARCHAR(20), balance DECIMAL(10, 2), check_date DATE); INSERT INTO checking (customer_id, account_type, balance, check_date) VALUES (1, 'Shariah', 5000.00, '2021-01-01'), (2, 'Checking', 7000.00, '2021-01-02'), (3, 'Shariah', 3000.00, '2021-07-01');
What is the difference in average daily balance between the first and second halves of the year for all customers with a Shariah-compliant checking account?
SELECT AVG(balance) FILTER (WHERE check_date <= '2021-06-30') - AVG(balance) FILTER (WHERE check_date > '2021-06-30') FROM checking WHERE account_type = 'Shariah';
gretelai_synthetic_text_to_sql
CREATE TABLE ResearchVessels (id INT, name VARCHAR(50), type VARCHAR(50), length INT, year INT); INSERT INTO ResearchVessels (id, name, type, length, year) VALUES (1, 'Ocean Explorer', 'Research', 100, 2010), (2, 'Marine Discoverer', 'Exploration', 120, 2015), (3, 'Sea Surveyor', 'Survey', 90, 2005), (4, 'Ocean Odyssey', 'Research', 110, 2018);
Update the 'ResearchVessels' table to correct the type for the vessel 'Ocean Odyssey' to 'Exploration'
UPDATE ResearchVessels SET type = 'Exploration' WHERE name = 'Ocean Odyssey';
gretelai_synthetic_text_to_sql
CREATE TABLE gulf_wells (well_type VARCHAR(10), location VARCHAR(50), num_wells INT); INSERT INTO gulf_wells (well_type, location, num_wells) VALUES ('Onshore', 'Gulf of Mexico', 150), ('Offshore', 'Gulf of Mexico', 750);
Show the number of offshore wells in the Gulf of Mexico
SELECT num_wells FROM gulf_wells WHERE well_type = 'Offshore';
gretelai_synthetic_text_to_sql
CREATE TABLE Teams (TeamID INT, TeamName VARCHAR(50)); CREATE TABLE TicketSales (TicketID INT, TeamID INT, SaleDate DATE); INSERT INTO Teams (TeamID, TeamName) VALUES (1, 'TeamA'), (2, 'TeamB'), (3, 'TeamC'); INSERT INTO TicketSales (TicketID, TeamID, SaleDate) VALUES (1, 1, '2023-01-01'), (2, 1, '2023-01-15'), (3, 2, '2023-01-02'), (4, 3, '2023-01-04');
Find the top 3 teams with the highest number of ticket sales in January 2023.
SELECT TeamName, COUNT(*) AS SaleCount FROM TicketSales JOIN Teams ON TicketSales.TeamID = Teams.TeamID WHERE SaleDate BETWEEN '2023-01-01' AND '2023-01-31' GROUP BY TeamName ORDER BY SaleCount DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_producers (id INT, name TEXT, capacity FLOAT, region TEXT); INSERT INTO renewable_producers (id, name, capacity, region) VALUES (1, 'ABC Energy', 2500, 'North'), (2, 'XYZ Solar', 3000, 'South'), (3, 'DEF Wind', 3500, 'West'), (4, 'JKL Energy', 1500, 'North'), (5, 'MNO Solar', 2000, 'South');
Find the renewable energy producers and their capacities by region, ordered by capacity.
SELECT region, name, capacity FROM renewable_producers ORDER BY region, capacity DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE solar ( id INT PRIMARY KEY, source VARCHAR(20), capacity FLOAT ); INSERT INTO solar (id, source, capacity) VALUES (1, 'PV', 400.5), (2, 'CSP', 600.3), (3, 'Hybrid', 700.1);
Delete records in the "solar" table where capacity is greater than 500
WITH cte AS (DELETE FROM solar WHERE capacity > 500) DELETE FROM cte;
gretelai_synthetic_text_to_sql
CREATE TABLE sales(product_id INT, sale_date DATE, revenue DECIMAL(10,2), country VARCHAR(50)); INSERT INTO sales VALUES (1, '2021-01-01', 50.00, 'US'); INSERT INTO sales VALUES (2, '2021-01-02', 75.00, 'US'); CREATE TABLE products(product_id INT, product_name VARCHAR(50), is_organic BOOLEAN); INSERT INTO products VALUES (1, 'Aloe Vera Moisturizer', TRUE); INSERT INTO products VALUES (2, 'Vitamin C Serum', FALSE);
What is the total revenue of organic skincare products sold in the US in Q1 2021?
SELECT SUM(sales.revenue) FROM sales INNER JOIN products ON sales.product_id = products.product_id WHERE products.is_organic = TRUE AND YEAR(sales.sale_date) = 2021 AND QUARTER(sales.sale_date) = 1 AND sales.country = 'US';
gretelai_synthetic_text_to_sql
CREATE TABLE Attorneys (attorney_id INT, name TEXT, join_date DATE); INSERT INTO Attorneys (attorney_id, name, join_date) VALUES (1, 'John Doe', '2019-01-01'), (2, 'Jane Smith', '2020-05-01'), (3, 'Mike Johnson', '2018-03-15'); CREATE TABLE Cases (case_id INT, attorney_id INT, won BOOLEAN); INSERT INTO Cases (case_id, attorney_id, won) VALUES (1, 1, TRUE), (2, 1, TRUE), (3, 2, FALSE), (4, 3, TRUE);
How many cases were won by attorneys who joined the firm in 2020 or later?
SELECT COUNT(Cases.case_id) FROM Cases INNER JOIN Attorneys ON Cases.attorney_id = Attorneys.attorney_id WHERE Attorneys.join_date >= '2020-01-01' AND Cases.won = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE satellite_params (satellite_id INT, orbital_param1 FLOAT, orbital_param2 FLOAT, orbital_param3 FLOAT, orbital_param4 FLOAT, orbital_param5 FLOAT); INSERT INTO satellite_params (satellite_id, orbital_param1, orbital_param2, orbital_param3, orbital_param4, orbital_param5) VALUES (1, 687.2, 1234.5, 456.0, 789.1, 345.6), (2, 555.8, 1001.2, 300.0, 888.9, 555.5), (3, 777.6, 1333.5, 555.0, 999.1, 777.7);
Update satellite information with the latest orbital parameters.
UPDATE satellite SET orbital_param1 = (SELECT orbital_param1 FROM satellite_params WHERE satellite.satellite_id = satellite_params.satellite_id), orbital_param2 = (SELECT orbital_param2 FROM satellite_params WHERE satellite.satellite_id = satellite_params.satellite_id), orbital_param3 = (SELECT orbital_param3 FROM satellite_params WHERE satellite.satellite_id = satellite_params.satellite_id), orbital_param4 = (SELECT orbital_param4 FROM satellite_params WHERE satellite.satellite_id = satellite_params.satellite_id), orbital_param5 = (SELECT orbital_param5 FROM satellite_params WHERE satellite.satellite_id = satellite_params.satellite_id);
gretelai_synthetic_text_to_sql
CREATE TABLE articles (id INT, author VARCHAR(255), title VARCHAR(255), section VARCHAR(255), date DATE);
Count the number of articles published by each author in the 'politics' section.
SELECT author, COUNT(*) FROM articles WHERE section='politics' GROUP BY author;
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (ArtistID INT, ArtistName VARCHAR(100), Genre VARCHAR(50), Age INT); INSERT INTO Artists (ArtistID, ArtistName, Genre, Age) VALUES (3, 'Madonna', 'Pop', 63); INSERT INTO Artists (ArtistID, ArtistName, Genre, Age) VALUES (4, 'Britney Spears', 'Pop', 40);
Who is the oldest pop artist?
SELECT ArtistName, Age FROM Artists WHERE Genre = 'Pop' AND Age = (SELECT MAX(Age) FROM Artists WHERE Genre = 'Pop');
gretelai_synthetic_text_to_sql
CREATE TABLE military_innovation (project_id INT, country_id INT, start_year INT, completion_year INT, FOREIGN KEY (country_id) REFERENCES country(id));
Which military innovation projects were started after 2017 and completed before 2020?
SELECT project_id, country_id, start_year, completion_year FROM military_innovation WHERE start_year > 2017 AND completion_year < 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE production (year INT, element VARCHAR(10), country VARCHAR(10), quantity INT); INSERT INTO production (year, element, country, quantity) VALUES (2017, 'Europium', 'China', 1200), (2018, 'Europium', 'China', 1400), (2019, 'Europium', 'China', 1600), (2020, 'Europium', 'China', 1800), (2021, 'Europium', 'China', 2000);
Find the change in Europium production in China from 2019 to 2020.
SELECT (subquery.qty2 - subquery.qty1) AS change FROM (SELECT production2020.quantity AS qty1, production2019.quantity AS qty2 FROM production AS production2019 INNER JOIN production AS production2020 ON production2019.element = production2020.element AND production2019.country = production2020.country WHERE production2019.element = 'Europium' AND production2019.country = 'China' AND production2019.year = 2019 AND production2020.year = 2020) AS subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE compliance_violations (id INT, dispensary_id INT, violation_date DATE, description TEXT); INSERT INTO compliance_violations (id, dispensary_id, violation_date, description) VALUES (1, 1, '2021-02-15', 'Inadequate labeling'), (2, 2, '2021-03-02', 'Improper storage'), (3, 3, '2021-06-28', 'Expired products'), (4, 4, '2021-07-14', 'Lack of inventory controls'), (5, 1, '2021-08-12', 'Inadequate labeling'), (6, 2, '2021-12-30', 'Improper storage');
How many compliance violations occurred in each month of 2021?
SELECT EXTRACT(MONTH FROM violation_date) AS month, COUNT(*) FROM compliance_violations WHERE violation_date BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE heritage_sites (site_id INT, site_name TEXT, country TEXT, rating INT); INSERT INTO heritage_sites (site_id, site_name, country, rating) VALUES (1, 'Roman Colosseum', 'Italy', 4), (2, 'Leaning Tower of Pisa', 'Italy', 5), (3, 'Spanish Steps', 'Italy', 3);
Which cultural heritage sites in Italy have the highest visitor ratings?
SELECT site_name, rating FROM heritage_sites WHERE country = 'Italy' ORDER BY rating DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Policy (PolicyNumber INT, PolicyholderName VARCHAR(50)); CREATE TABLE Claim (ClaimID INT, PolicyNumber INT, ClaimDate DATE); INSERT INTO Policy VALUES (1, 'Sophia Gupta'), (2, 'Mohammed Ahmed'); INSERT INTO Claim VALUES (1, 1, '2021-09-01'), (2, 1, '2021-09-15'), (3, 2, '2021-10-01'), (4, 2, '2021-11-01'), (5, 1, '2021-12-01');
Determine the number of unique claims per policyholder in the last 90 days?
SELECT PolicyNumber, COUNT(DISTINCT ClaimID) as UniqueClaims FROM Claim JOIN Policy ON Claim.PolicyNumber = Policy.PolicyNumber WHERE ClaimDate >= DATEADD(DAY, -90, GETDATE()) GROUP BY PolicyNumber;
gretelai_synthetic_text_to_sql
CREATE TABLE tourists (tourist_id INT, country_of_origin VARCHAR(50), destination VARCHAR(50));
What percentage of tourists visiting New Zealand are from Oceania?
SELECT 100.0 * COUNT(*) / (SELECT COUNT(*) FROM tourists) as percentage FROM tourists WHERE country_of_origin = 'Oceania' AND destination = 'New Zealand';
gretelai_synthetic_text_to_sql
CREATE TABLE marine_research_projects (id INT, name VARCHAR(255), location VARCHAR(255), budget DECIMAL(10,2), last_report_date DATE); INSERT INTO marine_research_projects (id, name, location, budget, last_report_date) VALUES (1, 'Coral Reef Study', 'Indian Ocean', 250000.00, '2020-01-01'), (2, 'Ocean Current Analysis', 'Atlantic Ocean', 350000.00, '2018-01-01');
Delete marine research projects that have not reported data in the last 3 years
DELETE FROM marine_research_projects WHERE last_report_date < NOW() - INTERVAL 3 YEAR;
gretelai_synthetic_text_to_sql
CREATE TABLE inventory (store_name TEXT, item_name TEXT, price INTEGER); INSERT INTO inventory (store_name, item_name, price) VALUES ('Organic Grocery 1', 'Quinoa', 8), ('Organic Grocery 2', 'Quinoa', 7), ('Organic Grocery 3', 'Quinoa', 6);
What is the name of the organic_grocery store with the lowest price for quinoa in the inventory table?
SELECT store_name, MIN(price) FROM inventory WHERE item_name = 'Quinoa';
gretelai_synthetic_text_to_sql
CREATE TABLE flight_safety (id INT, accident_date DATE, accident_type VARCHAR(255), country VARCHAR(255));
What is the number of flight accidents by accident type in the last 10 years?
SELECT accident_type, COUNT(*) as num_accidents FROM flight_safety WHERE accident_date >= DATE_SUB(CURRENT_DATE(), INTERVAL 10 YEAR) GROUP BY accident_type;
gretelai_synthetic_text_to_sql
CREATE TABLE programs (program TEXT); INSERT INTO programs (program) VALUES ('Program A'), ('Program B'), ('Program C');
dropdown_programs
SELECT program FROM programs;
gretelai_synthetic_text_to_sql
CREATE TABLE Teams (TeamID INT, TeamName VARCHAR(255));CREATE TABLE Games (GameID INT, HomeTeam VARCHAR(255), AwayTeam VARCHAR(255), GameDate DATE);
Determine the total number of games played per team, and rank them in descending order.
SELECT HomeTeam AS TeamName, COUNT(*) AS TotalGames, ROW_NUMBER() OVER (PARTITION BY HomeTeam ORDER BY COUNT(*) DESC) AS Rank FROM Games GROUP BY HomeTeam UNION ALL SELECT AwayTeam, COUNT(*), ROW_NUMBER() OVER (PARTITION BY AwayTeam ORDER BY COUNT(*) DESC) FROM Games GROUP BY AwayTeam;
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_energy_projects (project_name VARCHAR(50), country VARCHAR(20)); INSERT INTO renewable_energy_projects (project_name, country) VALUES ('Project A', 'France'), ('Project B', 'France'), ('Project C', 'Germany'), ('Project D', 'Germany');
How many renewable energy projects were completed in each country?
SELECT country, COUNT(*) FROM renewable_energy_projects rep GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE wells (well_id varchar(10), field varchar(10), datetime date); INSERT INTO wells (well_id, field, datetime) VALUES ('W001', 'FieldD', '2019-01-01'), ('W002', 'FieldD', '2020-01-01');
How many wells were drilled in 'FieldD' between 2018 and 2020?
SELECT COUNT(DISTINCT well_id) FROM wells WHERE field = 'FieldD' AND datetime BETWEEN '2018-01-01' AND '2020-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE SupportPrograms (ProgramID INT, DisabilityType VARCHAR(50), Region VARCHAR(50), ImplementationMonth INT, ImplementationYear INT); INSERT INTO SupportPrograms (ProgramID, DisabilityType, Region, ImplementationMonth, ImplementationYear) VALUES (1, 'Sign Language Interpretation', 'Atlantic', 1, 2022), (2, 'Hearing Aids', 'Atlantic', 2, 2022), (3, 'Assistive Listening Devices', 'Atlantic', 3, 2022);
What is the average number of support programs implemented per month for the deaf and hard of hearing community in the Atlantic region in 2022?
SELECT AVG(COUNT(ProgramID)) FROM SupportPrograms WHERE DisabilityType = 'Deaf' OR DisabilityType = 'Hard of Hearing' AND Region = 'Atlantic' GROUP BY ImplementationYear, ImplementationMonth;
gretelai_synthetic_text_to_sql
CREATE TABLE Spacecraft_Components (Component_ID INT, Spacecraft_ID INT, Name VARCHAR(50), Manufacturer VARCHAR(50), Quantity INT, Cost DECIMAL(5,2));
Create a table for storing spacecraft components and their quantities.
INSERT INTO Spacecraft_Components (Component_ID, Spacecraft_ID, Name, Manufacturer, Quantity, Cost) VALUES (1, 1, 'Propulsion System', 'Blue Origin', 1, 5000000.00);
gretelai_synthetic_text_to_sql
CREATE TABLE vehicle_registrations (registration_date DATE, is_autonomous BOOLEAN, PRIMARY KEY (registration_date, is_autonomous)); INSERT INTO vehicle_registrations (registration_date, is_autonomous) VALUES ('2022-03-20', true); INSERT INTO vehicle_registrations (registration_date, is_autonomous) VALUES ('2022-03-20', true);
What is the maximum number of autonomous vehicles registered in a single day in the 'vehicle_registrations' table?
SELECT MAX(autonomous_registrations_per_day) FROM (SELECT registration_date, COUNT(*) FILTER (WHERE is_autonomous = true) AS autonomous_registrations_per_day FROM vehicle_registrations GROUP BY registration_date) subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE factories (id INT, name VARCHAR(255), location VARCHAR(255), type VARCHAR(255), PRIMARY KEY(id)); INSERT INTO factories (id, name, location, type) VALUES (9, 'Organic Cotton Factories', 'India', 'Factory'); CREATE TABLE workers (id INT, name VARCHAR(255), position VARCHAR(255), factory_id INT, PRIMARY KEY(id), FOREIGN KEY (factory_id) REFERENCES factories(id)); INSERT INTO workers (id, name, position, factory_id) VALUES (10, 'Raj Patel', 'Seamstress', 9), (11, 'Priya Gupta', 'Quality Control', 9);
What is the total number of workers in organic cotton factories?
SELECT COUNT(*) FROM workers WHERE factory_id = (SELECT id FROM factories WHERE name = 'Organic Cotton Factories' AND type = 'Factory');
gretelai_synthetic_text_to_sql
CREATE TABLE ArtSales (id INT, title VARCHAR(255), price DECIMAL(10,2), sale_year INT, artist_gender VARCHAR(6), artist_country VARCHAR(255)); INSERT INTO ArtSales (id, title, price, sale_year, artist_gender, artist_country) VALUES (1, 'Installation1', 12000, 2001, 'Female', 'Brazil');
What is the total value of installations sold by female artists in Brazil since 2000?
SELECT SUM(price) FROM ArtSales WHERE artist_gender = 'Female' AND artist_country = 'Brazil' AND sale_year >= 2000 AND type = 'Installation';
gretelai_synthetic_text_to_sql
CREATE TABLE aircraft (id INT, manufacturer VARCHAR(255), model VARCHAR(255), engine_type VARCHAR(255)); INSERT INTO aircraft (id, manufacturer, model, engine_type) VALUES (1, 'Boeing', '737', 'CFM56');
How many aircraft have been manufactured by Boeing with engine type 'CFM56'?
SELECT COUNT(*) FROM aircraft WHERE manufacturer = 'Boeing' AND engine_type = 'CFM56';
gretelai_synthetic_text_to_sql
CREATE TABLE explainability_us (model_id INT, name VARCHAR(255), country VARCHAR(255), score FLOAT); INSERT INTO explainability_us (model_id, name, country, score) VALUES (1, 'Model1', 'USA', 0.85), (2, 'Model2', 'USA', 0.92), (3, 'Model3', 'USA', 0.78), (4, 'Model4', 'USA', 0.88), (5, 'Model5', 'USA', 0.90);
What is the minimum explainability score for models from the USA?
SELECT MIN(score) FROM explainability_us WHERE country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE Policyholder_State (ID INT, State VARCHAR(20), Insurance_Type VARCHAR(20)); INSERT INTO Policyholder_State (ID, State, Insurance_Type) VALUES (1, 'New York', 'Life'), (2, 'California', 'Health'), (3, 'Texas', 'Auto'), (4, 'Florida', 'Home'), (5, 'New York', 'Home'), (6, 'California', 'Home'), (7, 'Texas', 'Home'), (8, 'Florida', 'Auto'), (9, 'New York', 'Auto'), (10, 'California', 'Life');
Find the top 3 states with the most policyholders for home insurance.
SELECT State, COUNT(*) AS Policyholder_Count FROM Policyholder_State WHERE Insurance_Type = 'Home' GROUP BY State ORDER BY Policyholder_Count DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE AgriculturalWaterUsage (state VARCHAR(20), water_usage FLOAT);
Identify the top 5 states with the highest water usage in the agricultural sector.
SELECT state, water_usage FROM AgriculturalWaterUsage ORDER BY water_usage DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE local_businesses (business_id INT, name TEXT, city TEXT, daily_revenue FLOAT, benefited_from_sustainable_tourism BOOLEAN); INSERT INTO local_businesses (business_id, name, city, daily_revenue, benefited_from_sustainable_tourism) VALUES (1, 'La Boqueria Market Stall', 'Barcelona', 500, true), (2, 'Barcelona Gift Shop', 'Barcelona', 300, false);
What is the average daily revenue of local businesses in Barcelona that have not benefited from sustainable tourism?
SELECT AVG(daily_revenue) FROM local_businesses WHERE city = 'Barcelona' AND benefited_from_sustainable_tourism = false;
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_acidity_records (record_id INTEGER, ocean TEXT, acidity_level FLOAT);
What is the maximum ocean acidity level ever recorded in the Indian Ocean?
SELECT MAX(acidity_level) FROM ocean_acidity_records WHERE ocean = 'Indian Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers (id INT, name VARCHAR(255)); INSERT INTO suppliers (id, name) VALUES (1, 'Supplier A'); INSERT INTO suppliers (id, name) VALUES (2, 'Supplier B');CREATE TABLE ethical_practices (id INT, supplier_id INT, ethical_rating FLOAT); INSERT INTO ethical_practices (id, supplier_id, ethical_rating) VALUES (1, 1, 2.5); INSERT INTO ethical_practices (id, supplier_id, ethical_rating) VALUES (2, 2, 4.3);
Identify suppliers with unethical practices.
SELECT s.name FROM suppliers s JOIN ethical_practices ep ON s.id = ep.supplier_id WHERE ep.ethical_rating < 3.0;
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_offset_programs (id INT, name VARCHAR(50), start_date DATE, end_date DATE); INSERT INTO carbon_offset_programs (id, name, start_date, end_date) VALUES (1, 'Program 1', '2020-01-01', '2020-12-31'), (2, 'Program 2', '2021-01-01', '2021-12-31');
How many carbon offset programs were implemented in '2020' and '2021' in the 'carbon_offset' schema?
SELECT COUNT(*) FROM carbon_offset_programs WHERE YEAR(start_date) IN (2020, 2021);
gretelai_synthetic_text_to_sql
CREATE TABLE departments (id INT, name TEXT, budget INT); INSERT INTO departments (id, name, budget) VALUES (1, 'Computer Science', 1000000), (2, 'Mathematics', 750000); CREATE TABLE faculty (id INT, name TEXT, department TEXT, publications INT); INSERT INTO faculty (id, name, department, publications) VALUES (1, 'John Doe', 'Computer Science', 2), (2, 'Jane Smith', 'Mathematics', 3), (3, 'Alice Johnson', 'Computer Science', 1);
What is the total number of publications for each department?
SELECT d.name, SUM(f.publications) FROM departments d INNER JOIN faculty f ON d.name = f.department GROUP BY d.name;
gretelai_synthetic_text_to_sql
CREATE TABLE ArtSales (id INT, artwork_name VARCHAR(50), price FLOAT, sale_date DATE, artwork_type VARCHAR(20), artist_nationality VARCHAR(30)); INSERT INTO ArtSales (id, artwork_name, price, sale_date, artwork_type, artist_nationality) VALUES (1, 'Sculpture1', 12000, '2006-01-01', 'Sculpture', 'Japanese');
Number of sculptures made by Japanese artists sold after 2005?
SELECT COUNT(*) FROM ArtSales WHERE artwork_type = 'Sculpture' AND artist_nationality = 'Japanese' AND sale_date >= '2005-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE VolunteerHours (VolunteerHoursID INT PRIMARY KEY, VolunteerID INT, Hours DECIMAL(10, 2), VolunteerDate DATE);
Delete a record from the 'VolunteerHours' table
DELETE FROM VolunteerHours WHERE VolunteerHoursID = 401;
gretelai_synthetic_text_to_sql
CREATE TABLE sustainable_urbanism (size INT, city VARCHAR(20));
What is the average size of sustainable urbanism projects in Vancouver?
SELECT AVG(size) FROM sustainable_urbanism WHERE city = 'Vancouver';
gretelai_synthetic_text_to_sql
CREATE TABLE donors (donor_id INT, donation_amount DECIMAL(10,2), donation_date DATE); INSERT INTO donors (donor_id, donation_amount, donation_date) VALUES (1, 100, '2022-01-05'), (2, 250, '2022-03-20'), (3, 50, '2021-12-31'), (4, 75, '2022-11-28');
What is the maximum donation amount given by any individual in the first quarter of 2022?
SELECT MAX(donation_amount) FROM donors WHERE donation_date >= '2022-01-01' AND donation_date < '2022-04-01';
gretelai_synthetic_text_to_sql
CREATE TABLE departments (name VARCHAR(255), patient_count INT, total_salary NUMERIC(10, 2)); INSERT INTO departments (name, patient_count, total_salary) VALUES (1, 100, 300000), (2, 150, 400000);
What are the names and total salary expenditures of the rural health departments, with the departments ordered by total salary expenditure and including the patient count for each department?
SELECT name, patient_count, total_salary FROM departments ORDER BY total_salary DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE members (id INT, country VARCHAR(50)); INSERT INTO members (id, country) VALUES (1, 'UK'); CREATE TABLE workouts (id INT, member_id INT, date DATE, duration INT); INSERT INTO workouts (id, member_id, date, duration) VALUES (1, 1, '2021-01-01', 60);
What is the total workout duration per member from the UK in 2021?
SELECT members.id, SUM(duration) AS total_duration FROM members JOIN workouts ON members.id = workouts.member_id WHERE members.country = 'UK' AND YEAR(workouts.date) = 2021 GROUP BY members.id;
gretelai_synthetic_text_to_sql
CREATE TABLE sustainable_sourcing (menu_category VARCHAR(255), sustainable_ingredients DECIMAL(5,2)); INSERT INTO sustainable_sourcing (menu_category, sustainable_ingredients) VALUES ('Appetizers', 0.75), ('Entrees', 0.50), ('Desserts', 0.80);
What is the percentage of sustainable sourced ingredients by menu category?
SELECT menu_category, sustainable_ingredients * 100.00 as percentage_sustainable FROM sustainable_sourcing;
gretelai_synthetic_text_to_sql
CREATE TABLE Platforms (PlatformId INT, PlatformName VARCHAR(255), Genre VARCHAR(255), AvgRevenuePerStream DECIMAL(10,2)); INSERT INTO Platforms (PlatformId, PlatformName, Genre, AvgRevenuePerStream) VALUES (1, 'Spotify', 'Hip Hop', 0.005), (2, 'Apple Music', 'Hip Hop', 0.007), (3, 'Tidal', 'Hip Hop', 0.01), (4, 'Deezer', 'Hip Hop', 0.006), (5, 'Pandora', 'Hip Hop', 0.004);
Identify the top-5 streaming platforms with the highest average revenue per stream in the 'Hip Hop' genre.
SELECT PlatformName, AvgRevenuePerStream FROM Platforms WHERE Genre = 'Hip Hop' ORDER BY AvgRevenuePerStream DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE Protected_Habitats (id INT, animal_species VARCHAR(50), animal_count INT);
What is the minimum number of animals in a protected habitat for each animal species?
SELECT animal_species, MIN(animal_count) FROM Protected_Habitats GROUP BY animal_species;
gretelai_synthetic_text_to_sql
CREATE TABLE Digital_Assets (Asset_ID INT, Asset_Name VARCHAR(100), Max_Supply BIGINT); INSERT INTO Digital_Assets (Asset_ID, Asset_Name, Max_Supply) VALUES (1, 'Asset1', 1000000), (2, 'Asset2', 500000), (3, 'Asset3', 200000);
What is the maximum supply of each digital asset issued by companies based in the UK?
SELECT Asset_ID, Asset_Name, MAX(Max_Supply) FROM Digital_Assets WHERE Issuer_Country = 'UK' GROUP BY Asset_ID, Asset_Name;
gretelai_synthetic_text_to_sql
CREATE TABLE country_energy (country VARCHAR(255), total_energy_consumption FLOAT, renewable_energy_consumption FLOAT);
List the top 5 most energy-efficient countries in terms of renewable energy consumption as a percentage of total energy consumption.
SELECT country, renewable_energy_consumption/total_energy_consumption AS energy_efficiency FROM country_energy ORDER BY energy_efficiency DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE media_content (id INT, country VARCHAR(50), frequency INT); INSERT INTO media_content (id, country, frequency) VALUES (1, 'USA', 100), (2, 'Canada', 30), (3, 'Mexico', 40);
What is the average frequency of content for each country in the media_content table?
SELECT country, AVG(frequency) FROM media_content GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE Language (LanguageID INT, LanguageName VARCHAR(50), Continent VARCHAR(50), Population INT); INSERT INTO Language (LanguageID, LanguageName, Continent, Population) VALUES (1, 'Quechua', 'South America', 8000000), (2, 'Khmer', 'Asia', 16000000), (3, 'Berber', 'Africa', 25000000), (4, 'Maori', 'Australia', 500000);
How many languages are being preserved per capita in each continent?
SELECT r.Continent, AVG(l.Population) as AvgPopulation, COUNT(l.LanguageName) as LanguageCount, COUNT(l.LanguageName)/AVG(l.Population) as LangPerCapita FROM Language l JOIN (SELECT DISTINCT Continent FROM Language) r ON 1=1 GROUP BY r.Continent;
gretelai_synthetic_text_to_sql
CREATE TABLE athlete_stats (athlete_id INT, name VARCHAR(50), sport VARCHAR(20), country VARCHAR(50), gold_medals INT); INSERT INTO athlete_stats (athlete_id, name, sport, country, gold_medals) VALUES (1, 'Alex Morgan', 'Soccer', 'USA', 2); INSERT INTO athlete_stats (athlete_id, name, sport, country, gold_medals) VALUES (2, 'Simone Biles', 'Gymnastics', 'USA', 5);
List the number of athletes in each sport in the athlete_stats table who have won a gold medal in the Olympics.
SELECT sport, COUNT(*) FROM athlete_stats WHERE gold_medals > 0 GROUP BY sport;
gretelai_synthetic_text_to_sql
CREATE TABLE genetic_samples (id INT PRIMARY KEY, name VARCHAR(50), project_id INT, FOREIGN KEY (project_id) REFERENCES projects(id)); INSERT INTO genetic_samples (id, name, project_id) VALUES (1, 'DNA Sample 1', 1), (2, 'DNA Sample 2', 2), (3, 'DNA Sample 3', 3);
Delete genetic sample with ID 3 and related records.
WITH cte AS (DELETE FROM genetic_samples WHERE id = 3) DELETE FROM projects WHERE id IN (SELECT project_id FROM cte);
gretelai_synthetic_text_to_sql
CREATE TABLE cranes (crane_id VARCHAR(10), port_id VARCHAR(10)); INSERT INTO cranes (crane_id, port_id) VALUES ('crane_1', 'port_a'), ('crane_2', 'port_b'), ('crane_4', 'port_d'), ('crane_3', 'port_c');
Which cranes are located in port_d?
SELECT DISTINCT crane_id FROM cranes WHERE port_id = 'port_d';
gretelai_synthetic_text_to_sql
CREATE TABLE wildlife_habitat (habitat_id INT, habitat_type VARCHAR(50), wildlife_density FLOAT);
What is the wildlife density in each type of habitat in the wildlife_habitat table?
SELECT habitat_type, AVG(wildlife_density) FROM wildlife_habitat GROUP BY habitat_type;
gretelai_synthetic_text_to_sql
CREATE TABLE menu_items (menu_item_id INT, name VARCHAR(255), cuisine_type VARCHAR(255), price DECIMAL(10,2), sales INT); INSERT INTO menu_items (menu_item_id, name, cuisine_type, price, sales) VALUES (1, 'Pad Thai', 'Asian Fusion', 12.99, 50), (2, 'Sushi Roll', 'Asian Fusion', 14.99, 30), (3, 'Teriyaki Chicken', 'Asian Fusion', 13.99, 40);
List the top 3 menu items with the highest revenue in the "Asian Fusion" cuisine type.
SELECT name, SUM(price * sales) as total_revenue FROM menu_items WHERE cuisine_type = 'Asian Fusion' GROUP BY name ORDER BY total_revenue DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE VeteranEmploymentHistory (id INT, employment_date DATE, employment_status VARCHAR(50)); INSERT INTO VeteranEmploymentHistory (id, employment_date, employment_status) VALUES (1, '2021-01-01', 'Employed');
List the number of veterans who have found employment per month
SELECT DATE_FORMAT(employment_date, '%Y-%m'), COUNT(*) FROM VeteranEmploymentHistory WHERE employment_status = 'Employed' GROUP BY DATE_FORMAT(employment_date, '%Y-%m');
gretelai_synthetic_text_to_sql
CREATE TABLE cricket (id INT, player VARCHAR(50), team VARCHAR(50), league VARCHAR(50), runs INT); INSERT INTO cricket (id, player, team, league, runs) VALUES (1, 'Virat Kohli', 'Royal Challengers Bangalore', 'IPL', 46); INSERT INTO cricket (id, player, team, league, runs) VALUES (2, 'David Warner', 'Sunrisers Hyderabad', 'IPL', 34);
What is the minimum number of runs scored by cricket players in the IPL?
SELECT MIN(runs) FROM cricket WHERE league = 'IPL';
gretelai_synthetic_text_to_sql
CREATE TABLE donors (donor_id INT, first_name TEXT, last_name TEXT, donation_amount FLOAT); INSERT INTO donors (donor_id, first_name, last_name, donation_amount) VALUES (1, 'John', 'Doe', 500.00), (2, 'Jane', 'Smith', 350.00), (3, 'Mike', 'Johnson', 700.00); CREATE TABLE donations (donation_id INT, donor_id INT, organization_id INT, donation_amount FLOAT); INSERT INTO donations (donation_id, donor_id, organization_id, donation_amount) VALUES (1, 2, 101, 350.00), (2, 3, 102, 700.00); CREATE TABLE organizations (organization_id INT, organization_name TEXT); INSERT INTO organizations (organization_id, organization_name) VALUES (101, 'Effective Altruism'), (102, 'Impact Investing');
Which organizations have received donations from donors with the last name 'Smith'?
SELECT organizations.organization_name FROM organizations INNER JOIN donations ON organizations.organization_id = donations.organization_id INNER JOIN donors ON donations.donor_id = donors.donor_id WHERE donors.last_name = 'Smith';
gretelai_synthetic_text_to_sql
CREATE TABLE departments (id INT, name TEXT, manager TEXT); INSERT INTO departments (id, name, manager) VALUES (1, 'chemicals', 'Alice'), (2, 'textiles', 'Bob'), (3, 'electronics', 'Jane'), (4, 'metals', 'John'); CREATE TABLE workers (id INT, department_id INT, salary FLOAT); INSERT INTO workers (id, department_id, salary) VALUES (1, 1, 70000), (2, 1, 75000), (3, 2, 60000), (4, 2, 65000), (5, 1, 80000);
Determine the number of workers in the 'chemicals' department who earn more than the average salary.
SELECT COUNT(*) FROM workers INNER JOIN departments ON workers.department_id = departments.id WHERE departments.name = 'chemicals' AND salary > (SELECT AVG(salary) FROM workers INNER JOIN departments ON workers.department_id = departments.id WHERE departments.name = 'chemicals');
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, Department VARCHAR(30), CompletedDiversityTraining BOOLEAN, EmploymentDate DATE); INSERT INTO Employees (EmployeeID, Department, CompletedDiversityTraining, EmploymentDate) VALUES (1, 'HR', TRUE, '2021-07-01'), (2, 'IT', FALSE, '2021-01-01'), (3, 'Finance', TRUE, '2021-06-01'), (4, 'Marketing', TRUE, '2021-12-01');
Calculate the percentage of employees who have completed diversity and inclusion training, by department, in the last 6 months.
SELECT Department, COUNT(CASE WHEN CompletedDiversityTraining THEN 1 ELSE NULL END) * 100.0 / COUNT(*) AS Percentage_Completed_DiversityTraining FROM Employees WHERE EmploymentDate >= CURDATE() - INTERVAL 6 MONTH GROUP BY Department;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (sale_id INT, product_category VARCHAR(50), sale_date DATE, revenue DECIMAL(10,2));
What is the total revenue for each product category in 2021?
SELECT product_category, SUM(revenue) AS total_revenue FROM sales WHERE sale_date BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY product_category;
gretelai_synthetic_text_to_sql
CREATE TABLE sectors (id INT, sector_name VARCHAR(255)); INSERT INTO sectors (id, sector_name) VALUES (1, 'Healthcare'), (2, 'Education'); CREATE TABLE unions (id INT, union_name VARCHAR(255), sector VARCHAR(255)); INSERT INTO unions (id, union_name, sector) VALUES (1, 'National Nurses United', 'Healthcare'), (2, 'American Federation of Teachers', 'Education'); CREATE TABLE members (id INT, union_id INT, member_count INT); INSERT INTO members (id, union_id, member_count) VALUES (1, 1, 50000), (2, 1, 25000);
What is the total number of union members in the healthcare sector?
SELECT SUM(m.member_count) FROM members m JOIN unions u ON m.union_id = u.id WHERE u.sector = 'Healthcare';
gretelai_synthetic_text_to_sql
CREATE TABLE circular_economy_initiatives (id INT, initiative_name TEXT, city TEXT, recycling_rate DECIMAL(5,2)); INSERT INTO circular_economy_initiatives (id, initiative_name, city, recycling_rate) VALUES (1, 'Initiative A', 'Accra', 0.75), (2, 'Initiative B', 'Accra', 0.85);
What is the average recycling rate for circular economy initiatives in the city of Accra, Ghana?
SELECT AVG(recycling_rate) FROM circular_economy_initiatives WHERE city = 'Accra';
gretelai_synthetic_text_to_sql
CREATE TABLE journeys (vessel VARCHAR(20), speed INT, distance INT); INSERT INTO journeys (vessel, speed, distance) VALUES ('Aurelia', 20, 100), ('Aurelia', 22, 120), ('Belfast', 25, 150), ('Belfast', 24, 140), ('Belfast', 26, 160), ('Caledonia', 21, 110), ('Caledonia', 23, 130);
What is the maximum speed reached during the journeys of all vessels?
SELECT MAX(speed) FROM journeys;
gretelai_synthetic_text_to_sql
CREATE TABLE species (id INT PRIMARY KEY, name VARCHAR(50), population INT);
Update the population of the Beluga Whale by 200.
WITH updated_population AS (UPDATE species SET population = population + 200 WHERE name = 'Beluga Whale') SELECT * FROM species WHERE name = 'Beluga Whale';
gretelai_synthetic_text_to_sql
CREATE TABLE astronauts (astronaut_id INT, name TEXT, medical_condition TEXT); INSERT INTO astronauts (astronaut_id, name, medical_condition) VALUES (1, 'Neil Armstrong', NULL), (2, 'Buzz Aldrin', NULL), (3, 'Pete Conrad', 'Diabetes'), (4, 'Alan Shepard', NULL); CREATE TABLE astronaut_missions (astronaut_id INT, mission_id INT); INSERT INTO astronaut_missions (astronaut_id, mission_id) VALUES (1, 1), (1, 2), (2, 1), (3, 3), (4, 2); CREATE TABLE space_missions (mission_id INT, name TEXT, destination TEXT); INSERT INTO space_missions (mission_id, name, destination) VALUES (1, 'Apollo 11', 'Moon'), (2, 'Apollo 12', 'Moon'), (3, 'Apollo 13', 'Moon'), (4, 'Apollo 14', 'Moon');
List the astronauts and their medical conditions who have flown to the Moon.
SELECT a.name AS astronaut_name, a.medical_condition FROM astronauts a JOIN astronaut_missions am ON a.astronaut_id = am.astronaut_id JOIN space_missions s ON am.mission_id = s.mission_id WHERE s.destination = 'Moon';
gretelai_synthetic_text_to_sql
CREATE TABLE micro_mobility_berlin (id INT, vehicle_type VARCHAR(20), speed FLOAT, date DATE, city VARCHAR(20)); INSERT INTO micro_mobility_berlin (id, vehicle_type, speed, date, city) VALUES (1, 'ElectricScooter', 75.3, '2022-05-01', 'Berlin'); INSERT INTO micro_mobility_berlin (id, vehicle_type, speed, date, city) VALUES (2, 'ElectricScooter', 28.1, '2022-05-02', 'Berlin'); INSERT INTO micro_mobility_berlin (id, vehicle_type, speed, date, city) VALUES (3, 'ElectricScooter', 42.7, '2022-05-03', 'Berlin');
What is the average speed of electric scooters per day for the last 7 days in the 'micro_mobility' table in Berlin?
SELECT DATE(date) as trip_date, AVG(speed) as avg_speed FROM micro_mobility_berlin WHERE vehicle_type = 'ElectricScooter' AND city = 'Berlin' AND date BETWEEN DATE_SUB(CURDATE(), INTERVAL 7 DAY) AND CURDATE() GROUP BY trip_date ORDER BY trip_date;
gretelai_synthetic_text_to_sql
CREATE TABLE Projects (ProjectID int, Region varchar(20), Cost decimal(10,2)); INSERT INTO Projects (ProjectID, Region, Cost) VALUES (1, 'Midwest', 50000.00), (2, 'Northeast', 75000.00), (3, 'Midwest', 60000.00);
What is the average cost of sustainable building materials per project in the Midwest region, sorted by the highest average cost?
SELECT AVG(Cost) as Avg_Cost, Region FROM Projects WHERE Region = 'Midwest' GROUP BY Region ORDER BY Avg_Cost DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Glaciers (glacier_name VARCHAR(50), country VARCHAR(50)); INSERT INTO Glaciers (glacier_name, country) VALUES ('Vatnajökull', 'Iceland'), ('Langjökull', 'Iceland'), ('Hofsjökull', 'Iceland');
What is the number of glaciers in Iceland?
SELECT country, COUNT(*) FROM Glaciers GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE office (office_id INT, office_name VARCHAR(20)); INSERT INTO office (office_id, office_name) VALUES (1, 'boston'), (2, 'new_york'); CREATE TABLE attorney (attorney_id INT, attorney_name VARCHAR(30), office_id INT, billing_rate DECIMAL(5,2));
List the names and billing rates of all attorneys who have a higher billing rate than the average billing rate for the 'boston' office.
SELECT attorney_name, billing_rate FROM attorney WHERE billing_rate > (SELECT AVG(billing_rate) FROM attorney JOIN office ON attorney.office_id = office.office_id WHERE office.office_name = 'boston');
gretelai_synthetic_text_to_sql
CREATE TABLE HourlyWaterUsage (id INT, location VARCHAR(50), usage_hour INT, usage_amount INT); INSERT INTO HourlyWaterUsage (id, location, usage_hour, usage_amount) VALUES (1, 'City A', 1, 500); INSERT INTO HourlyWaterUsage (id, location, usage_hour, usage_amount) VALUES (2, 'City B', 2, 700);
How does water usage vary by hour of the day for a given location?
SELECT location, usage_hour, AVG(usage_amount) AS avg_usage FROM HourlyWaterUsage GROUP BY location, usage_hour;
gretelai_synthetic_text_to_sql
CREATE TABLE OceanCurrents (CurrentID INT, CurrentName VARCHAR(255), Location VARCHAR(255), AverageSpeed FLOAT);
Update the 'AverageSpeed' of the 'Agulhas Current' in the 'OceanCurrents' table
UPDATE OceanCurrents SET AverageSpeed = 2.0 WHERE CurrentName = 'Agulhas Current';
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_services (subscriber_id INT, service_type VARCHAR(10), start_date DATE, end_date DATE, price DECIMAL(5,2)); INSERT INTO mobile_services (subscriber_id, service_type, start_date, end_date, price) VALUES (1, 'postpaid', '2022-01-01', '2022-03-31', 50.00), (2, 'postpaid', '2022-01-01', '2022-03-31', 60.00);
What is the total revenue for postpaid mobile services in Q1 2022?
SELECT SUM(price) FROM mobile_services WHERE service_type = 'postpaid' AND start_date >= '2022-01-01' AND end_date <= '2022-03-31';
gretelai_synthetic_text_to_sql
CREATE TABLE wind_turbines (id INT, name TEXT, year INT, location TEXT);
Number of wind turbines installed in Latin America between 2010-2015?
SELECT COUNT(*) FROM wind_turbines WHERE location LIKE '%Latin America%' AND year BETWEEN 2010 AND 2015;
gretelai_synthetic_text_to_sql
CREATE TABLE GameDesign (GameID INT, Name VARCHAR(50), Genre VARCHAR(20), Multiplayer BOOLEAN, NumLevels INT); INSERT INTO GameDesign (GameID, Name, Genre, Multiplayer, NumLevels) VALUES (1, 'VR Racer', 'Racing', TRUE, 10), (2, 'Solar System', 'Simulation', FALSE, 1), (3, 'VR Puzzler', 'Puzzle', TRUE, 15), (4, 'Space Shooter', 'Shooter', FALSE, 5);
List the VR game design elements, including their unique IDs, names, genres, and the number of levels, for games that support multiplayer mode and have at least 10 levels.
SELECT GameID, Name, Genre, NumLevels FROM GameDesign WHERE Multiplayer = TRUE AND NumLevels >= 10;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name VARCHAR(30), product_type VARCHAR(20), sell_by_date DATE); INSERT INTO products (product_id, product_name, product_type, sell_by_date) VALUES (1, 'Ice Cream', 'frozen', '2023-01-01'), (2, 'Pizza', 'frozen', '2023-01-07');
What is the average sell-by date for frozen products?
SELECT AVG(DATEDIFF('2023-01-01', sell_by_date)) FROM products WHERE product_type = 'frozen';
gretelai_synthetic_text_to_sql
CREATE TABLE museums (id INT, name TEXT, city TEXT, virtual_tour_price FLOAT); INSERT INTO museums (id, name, city, virtual_tour_price) VALUES (1, 'Tokyo National Museum', 'Tokyo', 20);
Update the virtual tour price for the Tokyo museum to 15 USD.
UPDATE museums SET virtual_tour_price = 15 WHERE name = 'Tokyo National Museum' AND city = 'Tokyo';
gretelai_synthetic_text_to_sql
CREATE TABLE mpas (id INT, name VARCHAR(255), ocean VARCHAR(255));
Add a new marine protected area to the mpas table
INSERT INTO mpas (id, name, ocean) VALUES (6, 'Revillagigedo Archipelago National Park', 'Pacific');
gretelai_synthetic_text_to_sql
CREATE TABLE community_education (program_id INT, program_name VARCHAR(100), description TEXT);
List all the education programs in the 'community_education' table
SELECT program_name FROM community_education;
gretelai_synthetic_text_to_sql
CREATE TABLE companies (company_id INT, company_name TEXT, country TEXT); INSERT INTO companies VALUES (1, 'South Atlantic Shipping', 'Brazil'), (2, 'Amazonian Marine Services', 'Peru'), (3, 'Caribbean Cruises', 'Colombia'); CREATE TABLE vessels (vessel_id INT, company_id INT, vessel_type TEXT, crew_size INT); INSERT INTO vessels VALUES (1, 1, 'Container Ship', 25), (2, 1, 'Tanker', 40), (3, 2, 'Bulk Carrier', 35), (4, 3, 'Passenger Ship', 120), (5, 3, 'Cruise Ship', 200);
What is the total number of crew members on vessels owned by companies from South America, grouped by the vessel type?
SELECT SUM(vessels.crew_size) FROM vessels JOIN companies ON vessels.company_id = companies.company_id WHERE companies.country = 'South America' GROUP BY vessels.vessel_type;
gretelai_synthetic_text_to_sql
CREATE TABLE military_equipment (id INT PRIMARY KEY, equipment_number VARCHAR(255), equipment_type VARCHAR(255), current_location VARCHAR(255), last_maintenance_date DATE, next_maintenance_date DATE);
List all military equipment that was maintained in California in 2018
SELECT * FROM military_equipment WHERE current_location = 'CA' AND YEAR(last_maintenance_date) = 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE sales_data_2 (sale_id INT, product_category VARCHAR(255), region VARCHAR(255), sale_quantity INT, sale_amount DECIMAL(10,2), sale_year INT);
What is the sales growth of each product category compared to the previous year?
SELECT a.product_category, ((b.sale_quantity - a.sale_quantity) * 100.0 / a.sale_quantity) AS sales_growth_percentage FROM sales_data_2 a JOIN sales_data_2 b ON a.product_category = b.product_category AND a.sale_year = b.sale_year - 1 GROUP BY a.product_category, b.sale_quantity, a.sale_quantity;
gretelai_synthetic_text_to_sql
CREATE TABLE regions (region VARCHAR(20)); INSERT INTO regions (region) VALUES ('North'), ('South'), ('East'), ('West'); CREATE TABLE teachers (teacher_id INT, region VARCHAR(20)); INSERT INTO teachers (teacher_id, region) VALUES (16, 'East'), (17, 'East'), (18, 'West'), (19, 'West'), (20, 'North'); CREATE TABLE courses (course_id INT, teacher_id INT, completion_date DATE); INSERT INTO courses (course_id, teacher_id, completion_date) VALUES (25, 16, '2023-01-01'), (26, 17, '2023-03-15'), (27, 18, '2023-12-31'), (28, 19, '2023-06-01'), (29, 20, '2023-07-01');
How many professional development courses were completed by teachers in the 'East' region in 2023?
SELECT COUNT(*) FROM courses JOIN teachers ON courses.teacher_id = teachers.teacher_id JOIN regions ON teachers.region = regions.region WHERE regions.region = 'East' AND YEAR(completion_date) = 2023 AND course_id NOT IN (SELECT course_id FROM courses WHERE teacher_id NOT IN (SELECT teacher_id FROM teachers));
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_rates (id INT, region VARCHAR(50), year INT, recycling_rate DECIMAL(5,2)); INSERT INTO recycling_rates (id, region, year, recycling_rate) VALUES (1, 'North', 2020, 0.63), (2, 'South', 2020, 0.59), (3, 'East', 2020, 0.46), (4, 'West', 2020, 0.71), (5, 'Southeast Asia', 2020, 0.68), (6, 'North', 2019, 0.60), (7, 'South', 2019, 0.57), (8, 'East', 2019, 0.44), (9, 'West', 2019, 0.69);
What is the recycling rate per region and year for Southeast Asia?
SELECT region, year, AVG(recycling_rate) FROM recycling_rates WHERE region = 'Southeast Asia' GROUP BY region, year;
gretelai_synthetic_text_to_sql
CREATE TABLE energy_consumption (id INT, country VARCHAR(255), consumption FLOAT, source VARCHAR(255)); INSERT INTO energy_consumption (id, country, consumption, source) VALUES (1, 'Egypt', 50.0, 'renewable'), (2, 'South Africa', 60.0, 'non-renewable'), (3, 'Morocco', 70.0, 'renewable');
Which country has the highest renewable energy consumption in Africa?
SELECT country FROM energy_consumption WHERE consumption = (SELECT MAX(consumption) FROM energy_consumption WHERE source = 'renewable' AND country IN ('Africa')) AND source = 'renewable';
gretelai_synthetic_text_to_sql
CREATE TABLE city_water_conservation (city VARCHAR(50), year INT, conservation_volume INT); INSERT INTO city_water_conservation (city, year, conservation_volume) VALUES ('CityA', 2019, 100), ('CityA', 2020, 200), ('CityA', 2021, 300), ('CityB', 2019, 150), ('CityB', 2020, 250), ('CityB', 2021, 350);
What is the total water conservation effort (in cubic meters) by each city in 2021?
SELECT city, SUM(conservation_volume) AS total_conservation_volume FROM city_water_conservation WHERE year = 2021 GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE species (id INT, species_name VARCHAR, conservation_status VARCHAR); INSERT INTO species VALUES (1, 'Polar Bear', 'Vulnerable');
List the species and their conservation status in Greenland.
SELECT species_name, conservation_status FROM species WHERE country = 'Greenland';
gretelai_synthetic_text_to_sql
CREATE TABLE veteran_employment (state TEXT, veteran_unemployment FLOAT); INSERT INTO veteran_employment (state, veteran_unemployment) VALUES ('California', 3.2), ('Texas', 2.8), ('Florida', 4.1);
What is the unemployment rate among veterans in California?
SELECT veteran_unemployment FROM veteran_employment WHERE state = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE missions (id INT, service VARCHAR(10), year INT, country VARCHAR(50)); INSERT INTO missions (id, service, year, country) VALUES (1, 'Navy', 2019, 'Colombia'); INSERT INTO missions (id, service, year, country) VALUES (2, 'Navy', 2020, 'Indonesia');
Identify the number of humanitarian assistance missions carried out by the Navy in 2019 and 2020.
SELECT COUNT(*) FROM missions WHERE service = 'Navy' AND year BETWEEN 2019 AND 2020 AND country LIKE '%assistance%';
gretelai_synthetic_text_to_sql
CREATE TABLE Album (Artist VARCHAR(30), Country VARCHAR(20), Genre VARCHAR(10), ReleaseYear INT); INSERT INTO Album (Artist, Country, Genre, ReleaseYear) VALUES ('Band1', 'USA', 'Rock', 2010), ('Band2', 'Canada', 'Rock', 2012), ('Band3', 'USA', 'Rock', 2014), ('Band4', 'Mexico', 'Rock', 2011), ('Band5', 'USA', 'Rock', 2015), ('Band6', 'Brazil', 'Rock', 2010);
How many artists from the USA released an album in the rock genre between 2010 and 2015?
SELECT COUNT(*) FROM Album WHERE Country = 'USA' AND Genre = 'Rock' AND ReleaseYear BETWEEN 2010 AND 2015;
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers (name TEXT, component_type TEXT); INSERT INTO suppliers (name, component_type) VALUES ('Alpha Supplies', 'Automation Software'), ('Beta Components', 'Manufacturing Robots'), ('Charlie Parts', 'Legacy Equipment');
Delete records of suppliers that do not supply components for Industry 4.0 technologies.
DELETE FROM suppliers WHERE component_type NOT IN ('Automation Software', 'Manufacturing Robots');
gretelai_synthetic_text_to_sql