context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE budget (state VARCHAR(20), service VARCHAR(20), amount INT); INSERT INTO budget (state, service, amount) VALUES ('California', 'Education', 50000), ('California', 'Healthcare', 70000);
What is the total budget allocated for education and healthcare services in the state of 'California'?
SELECT SUM(amount) FROM budget WHERE state = 'California' AND service IN ('Education', 'Healthcare');
gretelai_synthetic_text_to_sql
CREATE TABLE factories (factory_id INT, name VARCHAR(100), location VARCHAR(100), production_output INT); CREATE TABLE employees (employee_id INT, factory_id INT, name VARCHAR(100), position VARCHAR(100), salary INT); INSERT INTO factories (factory_id, name, location, production_output) VALUES (1, 'ABC Factory', 'New Y...
What is the minimum salary of employees in factories with a production output above a certain threshold?
SELECT MIN(employees.salary) FROM factories INNER JOIN employees ON factories.factory_id = employees.factory_id WHERE factories.production_output > 5000;
gretelai_synthetic_text_to_sql
CREATE TABLE startups(id INT, name TEXT, industry TEXT, founder_ability TEXT, funding FLOAT); INSERT INTO startups (id, name, industry, founder_ability, funding) VALUES (1, 'FinanceAbility', 'Finance', 'Disabled', 2000000);
What is the minimum funding received by a startup founded by a person with a disability in the finance sector?
SELECT MIN(funding) FROM startups WHERE industry = 'Finance' AND founder_ability = 'Disabled';
gretelai_synthetic_text_to_sql
CREATE TABLE bike_rentals (location VARCHAR(20), day_of_week VARCHAR(10), bikes_rented INT); INSERT INTO bike_rentals (location, day_of_week, bikes_rented) VALUES ('park1', 'Saturday', 15), ('park1', 'Sunday', 20), ('park2', 'Friday', 10), ('park2', 'Saturday', 12), ('park2', 'Sunday', 18);
What is the maximum number of bikes rented in 'park1' and 'park2' on weekends?
SELECT MAX(bikes_rented) FROM bike_rentals WHERE location IN ('park1', 'park2') AND day_of_week IN ('Saturday', 'Sunday');
gretelai_synthetic_text_to_sql
CREATE TABLE community_policing (cp_id INT, did INT, meetings_this_year INT); INSERT INTO community_policing (cp_id, did, meetings_this_year) VALUES (1, 1, 5), (2, 2, 3), (3, 3, 7);
Delete records of community meetings that took place in 'Downtown' district
DELETE FROM community_policing WHERE did = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE countries (id INT, name TEXT); CREATE TABLE manufacturers (id INT, name TEXT, country_id INT, carbon_footprint INT); INSERT INTO countries (id, name) VALUES (1, 'Country 1'), (2, 'Country 2'), (3, 'Country 3'); INSERT INTO manufacturers (id, name, country_id, carbon_footprint) VALUES (1, 'Manufacturer 1', ...
What is the average carbon footprint of products manufactured in each country?
SELECT countries.name, AVG(manufacturers.carbon_footprint) FROM countries INNER JOIN manufacturers ON countries.id = manufacturers.country_id GROUP BY countries.name;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (product_type VARCHAR(20), region VARCHAR(10), revenue NUMERIC(10,2)); INSERT INTO sales (product_type, region, revenue) VALUES ('cleanser', 'West', 700), ('toner', 'East', 800), ('serum', 'West', 900), ('moisturizer', 'North', 600), ('sunscreen', 'South', 500), ('cleanser', 'South', 400), ('toner', ...
Calculate the revenue of organic skincare products sold in the West region
SELECT SUM(revenue) FROM sales INNER JOIN products ON sales.product_type = products.product_type WHERE products.organic = TRUE AND sales.region = 'West' AND sales.product_type = 'skincare';
gretelai_synthetic_text_to_sql
CREATE TABLE member_hr (member_id INT, resting_heart_rate INT); INSERT INTO member_hr (member_id, resting_heart_rate) VALUES (1, 75), (2, 58), (3, 65), (4, 59), (5, 72);
Which members have a resting heart rate below 60?
SELECT member_id FROM member_hr WHERE resting_heart_rate < 60;
gretelai_synthetic_text_to_sql
CREATE TABLE Satellites (Satellite_ID INT, Satellite_Name VARCHAR(50), Agency VARCHAR(50), Launch_Date DATETIME); INSERT INTO Satellites (Satellite_ID, Satellite_Name, Agency, Launch_Date) VALUES (1, 'Cartosat-1', 'ISRO', '2005-05-05'), (2, 'SPOT-5', 'CNES', '2002-05-03');
What are the names and launch dates of satellites launched by ISRO or CNES before 2010?
SELECT Satellite_Name, Launch_Date FROM Satellites WHERE Agency IN ('ISRO', 'CNES') AND Launch_Date < '2010-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE DefenseProjects (project_id INT, project_name VARCHAR(50), start_date DATE, end_date DATE, negotiation_status VARCHAR(50), geopolitical_risk_score INT); INSERT INTO DefenseProjects (project_id, project_name, start_date, end_date, negotiation_status, geopolitical_risk_score) VALUES (1, 'Project A', '2019-01...
List the defense projects and their respective start and end dates, along with the contract negotiation status, that have a geopolitical risk score above 7, ordered by the geopolitical risk score in descending order.
SELECT project_name, start_date, end_date, negotiation_status, geopolitical_risk_score FROM DefenseProjects WHERE geopolitical_risk_score > 7 ORDER BY geopolitical_risk_score DESC;
gretelai_synthetic_text_to_sql
CREATE SCHEMA RuralHealth; USE RuralHealth; CREATE TABLE States (StateName VARCHAR(50), StateAbbreviation VARCHAR(10)); CREATE TABLE Communities (CommunityID INT, CommunityName VARCHAR(50), StateAbbreviation VARCHAR(10), Rural BOOLEAN, AverageLifeExpectancy FLOAT); INSERT INTO States (StateName, StateAbbreviation) VALU...
What is the average life expectancy for residents in rural communities in each state, ordered from highest to lowest?
SELECT StateAbbreviation, AVG(AverageLifeExpectancy) as AvgLifeExpectancy FROM Communities WHERE Rural = TRUE GROUP BY StateAbbreviation ORDER BY AvgLifeExpectancy DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Vessel_Performance (Vessel_ID INT, Speed FLOAT, Region VARCHAR(255)); INSERT INTO Vessel_Performance (Vessel_ID, Speed, Region) VALUES (1, 14.5, 'Pacific'), (2, 10.2, 'Atlantic'), (3, 13.1, 'Pacific'), (4, 11.9, 'Atlantic'), (5, 9.8, 'Indian'), (6, 15.2, 'Pacific'), (7, 12.3, 'Arctic');
List regions with average vessel speed above 12 knots.
SELECT Region FROM Vessel_Performance WHERE Speed > 12 GROUP BY Region HAVING AVG(Speed) > 12;
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, name VARCHAR(50), favorite_genre VARCHAR(50)); INSERT INTO users (id, name, favorite_genre) VALUES (1, 'Alice', 'Pop'), (2, 'Bob', 'Rock'), (3, 'Charlie', 'Rock'), (4, 'David', 'Jazz'), (5, 'Eve', 'Pop'), (6, 'Frank', 'Country'), (7, 'Grace', 'Country'), (8, 'Harry', 'R&B'), (9, 'Ivy', 'Pop'...
What is the number of users who favor each genre?
SELECT favorite_genre, COUNT(*) as genre_count FROM users GROUP BY favorite_genre;
gretelai_synthetic_text_to_sql
CREATE TABLE Movies (id INT, title VARCHAR(100), rating FLOAT, production_country VARCHAR(50), release_year INT); INSERT INTO Movies (id, title, rating, production_country, release_year) VALUES (1, 'Movie1', 7.5, 'India', 2016), (2, 'Movie2', 8.2, 'India', 2018), (3, 'Movie3', 6.8, 'India', 2017), (4, 'Movie4', 5.0, 'I...
What is the minimum rating of movies produced in India and released after 2015?
SELECT MIN(rating) FROM Movies WHERE production_country = 'India' AND release_year > 2015;
gretelai_synthetic_text_to_sql
CREATE TABLE factories (factory_id INT, name TEXT, location TEXT); INSERT INTO factories (factory_id, name, location) VALUES (1, 'Factory A', 'New York'), (2, 'Factory B', 'Texas'), (3, 'Factory C', 'Florida'); CREATE TABLE productions (factory_id INT, chemical TEXT); INSERT INTO productions (factory_id, chemical) VALU...
What are the names and locations of factories that produce Chemical G?
SELECT f.name, f.location FROM factories f JOIN productions p ON f.factory_id = p.factory_id WHERE p.chemical = 'Chemical G';
gretelai_synthetic_text_to_sql
CREATE TABLE ghana_population (id INT, city VARCHAR(50), population INT, year INT); INSERT INTO ghana_population (id, city, population, year) VALUES (1, 'Accra', 2500000, 2019); INSERT INTO ghana_population (id, city, population, year) VALUES (2, 'Kumasi', 2000000, 2019); CREATE TABLE ghana_water_consumption (id INT, c...
What is the average water consumption per capita in the cities of Accra and Kumasi for the year 2019?
SELECT AVG(gwc.water_consumption / gp.population) FROM ghana_water_consumption gwc INNER JOIN ghana_population gp ON gwc.city = gp.city WHERE gwc.year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE trip_segments (segment_id INT, route_id INT, fare DECIMAL(5,2), passenger_count INT); INSERT INTO trip_segments (segment_id, route_id, fare, passenger_count) VALUES (1, 101, 2.50, 1000), (2, 101, 2.00, 1200), (3, 102, 3.00, 800), (4, 103, 1.50, 1500), (5, 104, 4.00, 600);
What is the average fare per trip segment for the top 10 most frequently traveled segments?
SELECT AVG(fare) FROM (SELECT fare, ROW_NUMBER() OVER (ORDER BY passenger_count DESC) rn FROM trip_segments) t WHERE rn <= 10;
gretelai_synthetic_text_to_sql
CREATE TABLE Cases (CaseID int, AttorneyID int, DurationDays int); INSERT INTO Cases (CaseID, AttorneyID, DurationDays) VALUES (1, 1, 45), (2, 2, 20), (3, 3, 32); CREATE TABLE CaseBilling (CaseID int, BillingAmount decimal(10,2)); INSERT INTO CaseBilling (CaseID, BillingAmount) VALUES (1, 4500.00), (2, 2000.00), (3, 32...
What is the total billing amount for cases with a duration of less than or equal to 30 days?
SELECT SUM(BillingAmount) AS TotalBillingAmount FROM CaseBilling JOIN Cases ON CaseBilling.CaseID = Cases.CaseID WHERE DurationDays <= 30;
gretelai_synthetic_text_to_sql
CREATE TABLE gold_mines (region VARCHAR(50), tons FLOAT, date DATE); INSERT INTO gold_mines (region, tons, date) VALUES ('North', 120, '2021-07-01'), ('South', 150, '2021-07-01'), ('East', 90, '2021-07-01'), ('West', 130, '2021-08-01'), ('Central', 160, '2021-08-01'), ('North', 100, '2021-08-01'), ('South', 140, '2021-...
What are the total tons of gold mined by region in Q3 2021?
SELECT region, SUM(tons) as total_tons FROM gold_mines WHERE YEAR(date) = 2021 AND QUARTER(date) = 3 GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE tourism_stats (id INT PRIMARY KEY, country VARCHAR(255), destination VARCHAR(255), duration INT); INSERT INTO tourism_stats (id, country, destination, duration) VALUES (1, 'Germany', 'Japan', 10);
What is the average trip duration in days for German tourists visiting Japan?
SELECT AVG(duration) FROM tourism_stats WHERE country = 'Germany' AND destination = 'Japan';
gretelai_synthetic_text_to_sql
CREATE TABLE WasteGenerators (GeneratorID INT, GeneratorType VARCHAR(50), WasteType VARCHAR(50), WasteQuantity FLOAT, Location VARCHAR(50)); INSERT INTO WasteGenerators (GeneratorID, GeneratorType, WasteType, WasteQuantity, Location) VALUES (2, 'Educational Institution', 'Paper Waste', 500, 'San Francisco');
What is the average waste quantity for paper generated by educational institutions?
SELECT GeneratorType, AVG(WasteQuantity) as AvgWasteQuantity FROM WasteGenerators WHERE WasteType = 'Paper Waste' AND GeneratorType = 'Educational Institution' GROUP BY GeneratorType;
gretelai_synthetic_text_to_sql
CREATE TABLE budgets (id INT, category VARCHAR(255), amount INT); INSERT INTO budgets (id, category, amount) VALUES (1, 'Habitat Restoration', 30000), (2, 'Habitat Maintenance', 20000), (3, 'Community Education', 25000);
Calculate the total budget for community education programs
SELECT SUM(amount) as total_budget FROM budgets WHERE category = 'Community Education';
gretelai_synthetic_text_to_sql
CREATE TABLE production_lines (line_id INT, line_name VARCHAR(50), country VARCHAR(50), environmental_impact_score DECIMAL(5,2)); INSERT INTO production_lines (line_id, line_name, country, environmental_impact_score) VALUES (1, 'Line A', 'Germany', 75.2), (2, 'Line B', 'Germany', 82.5), (3, 'Line C', 'USA', 60.0);
What is the average environmental impact score for production lines in Germany?
SELECT AVG(environmental_impact_score) FROM production_lines WHERE country = 'Germany';
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_subscribers (subscriber_id INT, subscriber_type VARCHAR(10), state VARCHAR(20)); INSERT INTO mobile_subscribers (subscriber_id, subscriber_type, state) VALUES (1, 'mobile', 'WA'), (2, 'mobile', 'NY'), (3, 'broadband', 'WA'), (4, 'mobile', 'CA'), (5, 'broadband', 'NY');
What is the total number of mobile and broadband subscribers in each state?
SELECT state, COUNT(*) as total_subscribers FROM mobile_subscribers GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_mitigation_projects (id INT PRIMARY KEY, project_type VARCHAR(50), country VARCHAR(50), year INT);
Calculate the total number of climate mitigation projects in Oceania, excluding Australia and New Zealand.
SELECT COUNT(*) AS total_projects FROM climate_mitigation_projects cmp WHERE country NOT IN ('Australia', 'New Zealand') AND country LIKE 'Oceania%';
gretelai_synthetic_text_to_sql
CREATE TABLE cases (case_id INT, case_outcome TEXT, total_billing FLOAT); INSERT INTO cases (case_id, case_outcome, total_billing) VALUES (1, 'settled', 2000.00), (2, 'won', 3000.00), (3, 'lost', 1500.00);
What is the total billing amount for cases with outcome 'settled'?
SELECT SUM(total_billing) FROM cases WHERE case_outcome = 'settled';
gretelai_synthetic_text_to_sql
CREATE TABLE accounts (customer_id INT, account_type VARCHAR(20), balance DECIMAL(10, 2));
What is the average monthly balance for each customer's account, partitioned by account type?
SELECT account_type, AVG(balance) OVER (PARTITION BY account_type) FROM accounts;
gretelai_synthetic_text_to_sql
CREATE TABLE water_consumption (city VARCHAR(50), consumption FLOAT, year INT); INSERT INTO water_consumption (city, consumption, year) VALUES ('Atlanta', 4500.5, 2020), ('Atlanta', 4700.2, 2021);
Determine the percentage change in water consumption for the city of Atlanta between the years 2020 and 2021.
SELECT (SUM(consumption) * 100.0 / (SELECT SUM(consumption) FROM water_consumption WHERE city = 'Atlanta' AND year = 2020) - 100.0) AS pct_change FROM water_consumption WHERE city = 'Atlanta' AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE regions (id INT, region_name VARCHAR(255)); INSERT INTO regions (id, region_name) VALUES (1, 'Asia'), (2, 'Africa'), (3, 'North America'); CREATE TABLE animal_location (id INT, animal_id INT, region_id INT); INSERT INTO animal_location (id, animal_id, region_id) VALUES (1, 1, 1), (2, 2, 2), (3, 3, 3); CREA...
Find the total number of animals in African and North American regions
SELECT r.region_name, COUNT(a.id) as animal_count FROM regions r INNER JOIN animal_location al ON r.id = al.region_id INNER JOIN animals a ON al.animal_id = a.id WHERE r.region_name IN ('Africa', 'North America') GROUP BY r.region_name;
gretelai_synthetic_text_to_sql
CREATE TABLE AircraftManufacturing (aircraft_id INT, manufacturer VARCHAR(50), country VARCHAR(50)); INSERT INTO AircraftManufacturing (aircraft_id, manufacturer, country) VALUES (1, 'Boeing', 'USA'), (2, 'Airbus', 'Europe');
Count the number of Boeing aircraft.
SELECT COUNT(*) FROM AircraftManufacturing WHERE manufacturer = 'Boeing';
gretelai_synthetic_text_to_sql
CREATE TABLE Programs (id INT, program_id INT, program_name VARCHAR(100), budget DECIMAL(10, 2), start_date DATE, end_date DATE); INSERT INTO Programs (id, program_id, program_name, budget, start_date, end_date) VALUES (1, 301, 'Elementary Education', 12000.00, '2023-01-01', '2023-03-31'); INSERT INTO Programs (id, pro...
What was the total budget for education programs in Q1 2023?
SELECT SUM(budget) FROM Programs WHERE program_id BETWEEN 301 AND 310 AND start_date <= '2023-03-31' AND end_date >= '2023-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE policies (policy_number INT, policyholder_name TEXT, issue_date DATE, state TEXT); INSERT INTO policies (policy_number, policyholder_name, issue_date, state) VALUES (12345, 'John Doe', '2021-06-01', 'California');
What is the policy number, policyholder name, and issue date for policies issued in California?
SELECT policy_number, policyholder_name, issue_date FROM policies WHERE state = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE coniferous_forests (id INT, carbon_sequestration FLOAT); INSERT INTO coniferous_forests VALUES (1, 45.67), (2, 56.78), (3, 67.89);
What is the average carbon sequestration in coniferous forests?
SELECT AVG(carbon_sequestration) FROM coniferous_forests;
gretelai_synthetic_text_to_sql
CREATE TABLE aquafarms (id INT, name TEXT, location TEXT); INSERT INTO aquafarms (id, name, location) VALUES (1, 'Farm A', 'Pacific'), (2, 'Farm B', 'Atlantic'), (5, 'Farm E', 'Arctic'); CREATE TABLE temperature_data (aquafarm_id INT, timestamp TIMESTAMP, temperature FLOAT);
What is the average water temperature change per hour for each aquafarm in the Arctic region?
SELECT aquafarm_id, AVG(temp_diff) AS avg_temp_change, EXTRACT(HOUR FROM timestamp) AS hour FROM (SELECT aquafarm_id, temperature, LAG(temperature) OVER (PARTITION BY aquafarm_id ORDER BY timestamp) AS prev_temperature, (temperature - COALESCE(prev_temperature, temperature)) AS temp_diff FROM temperature_data) temperat...
gretelai_synthetic_text_to_sql
CREATE TABLE Events (event_id INT, event_name VARCHAR(50), revenue INT); INSERT INTO Events (event_id, event_name, revenue) VALUES (2, 'Dance Recital', 12000);
What was the total revenue from the 'Dance Recital' event?
SELECT revenue FROM Events WHERE event_name = 'Dance Recital';
gretelai_synthetic_text_to_sql
CREATE TABLE OilProduction (ProductionID INT, Location VARCHAR(20), ProductionDate DATE, OilProduction INT); INSERT INTO OilProduction (ProductionID, Location, ProductionDate, OilProduction) VALUES (1, 'Alaska', '2022-01-01', 15000), (2, 'Alaska', '2022-01-02', 16000), (3, 'Alaska', '2022-01-03', 14000);
What is the average daily oil production in Alaska, in barrels, for the last 3 months?
SELECT AVG(OilProduction) FROM OilProduction WHERE Location = 'Alaska' AND ProductionDate >= DATEADD(month, -3, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE garment_manufacturing (garment_id INT, garment_type VARCHAR(50), region VARCHAR(50), manufacturing_time INT); CREATE TABLE garments (garment_id INT, garment_name VARCHAR(50));
What is the average manufacturing time for each garment type in East Asia?
SELECT garment_type, AVG(manufacturing_time) FROM garment_manufacturing JOIN garments ON garment_manufacturing.garment_id = garments.garment_id WHERE region = 'East Asia' GROUP BY garment_type;
gretelai_synthetic_text_to_sql
CREATE TABLE Hotels (id INT, name TEXT, country TEXT, type TEXT, co2_emission INT); INSERT INTO Hotels (id, name, country, type, co2_emission) VALUES (1, 'Eco Hotel', 'France', 'Eco', 50);
Find the top 5 hotels with the highest CO2 emission?
SELECT name, SUM(co2_emission) AS total_emission FROM Hotels GROUP BY name ORDER BY total_emission DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE concerts (event_id INT, event_name VARCHAR(50), location VARCHAR(50), date DATE, ticket_price DECIMAL(5,2), num_tickets INT);
What is the total revenue for each event in the 'concerts' table?
SELECT event_name, SUM(ticket_price * num_tickets) as total_revenue FROM concerts GROUP BY event_name;
gretelai_synthetic_text_to_sql
CREATE TABLE City (city_id INT, city_name VARCHAR(50), city_population INT); CREATE TABLE Initiative (initiative_id INT, initiative_name VARCHAR(50), city_id INT);
Which smart city initiatives have been implemented in the top 5 most populous cities?
SELECT City.city_name, Initiative.initiative_name FROM City JOIN Initiative ON City.city_id = Initiative.city_id WHERE City.city_population IN (SELECT city_population FROM City ORDER BY city_population DESC LIMIT 5);
gretelai_synthetic_text_to_sql
CREATE TABLE eco_hotels_extended (hotel_id INT, name TEXT, country TEXT); INSERT INTO eco_hotels_extended (hotel_id, name, country) VALUES (1, 'Le Hameau de la Vallée', 'France'), (2, 'Hotel Eco Vie', 'France'), (3, 'Eco Resort', 'Italy'), (4, 'Green Hotel', 'Spain');
Number of eco-friendly hotels in each country?
SELECT country, COUNT(*) FROM eco_hotels_extended GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE military_tech_patents (id INT, country VARCHAR(50), tech VARCHAR(50), year INT, patent_number INT); INSERT INTO military_tech_patents (id, country, tech, year, patent_number) VALUES (1, 'USA', 'Drones', 2017, 100), (2, 'USA', 'Cybersecurity', 2017, 101), (3, 'USA', 'Artificial Intelligence', 2017, 102), (4...
What is the total number of military technology patents filed by each country in the last 5 years, and what are the names of those technologies?
SELECT country, tech, SUM(patent_number) as total_patents FROM military_tech_patents WHERE year BETWEEN 2017 AND 2021 GROUP BY country, tech;
gretelai_synthetic_text_to_sql
CREATE TABLE environmental_impact (site_id INT, site_name TEXT, ei_score FLOAT); INSERT INTO environmental_impact (site_id, site_name, ei_score) VALUES (1, 'Site A', 75), (3, 'Site C', 60);
Delete the record for Site C from the environmental impact table.
DELETE FROM environmental_impact WHERE site_id = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE satellites (name TEXT, launch_date DATE, country TEXT, function TEXT);
Insert data into the "satellites" table for a satellite named "Hubble Space Telescope", launched on 1990-04-24, from USA, with function "Astronomy".
INSERT INTO satellites (name, launch_date, country, function) VALUES ('Hubble Space Telescope', '1990-04-24', 'USA', 'Astronomy');
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, rating FLOAT); INSERT INTO products (product_id, rating) VALUES (1, 4.5), (2, 4.8), (3, 3.2);
What is the rating of the product with the lowest product_id?
SELECT rating FROM products ORDER BY product_id LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE mental_health_parity (violation_id INT, violation_date DATE, region VARCHAR(255)); INSERT INTO mental_health_parity (violation_id, violation_date, region) VALUES (1, '2021-01-01', 'Northeast'), (2, '2021-02-01', 'Southeast'), (3, '2021-03-01', 'Northeast');
What is the maximum number of mental health parity violations in a single region?
SELECT region, MAX(violation_count) FROM (SELECT region, COUNT(violation_id) AS violation_count FROM mental_health_parity GROUP BY region) AS subquery GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE routes (route_id INT, name VARCHAR(255)); INSERT INTO routes (route_id, name) VALUES (505, 'Route 505'); CREATE TABLE vehicles (vehicle_id INT, route_id INT, model VARCHAR(255)); INSERT INTO vehicles (vehicle_id, route_id, model) VALUES (1001, 505, 'Bus A'), (1002, 505, 'Bus B');
How many vehicles are assigned to route 505?
SELECT COUNT(*) FROM vehicles WHERE route_id = 505;
gretelai_synthetic_text_to_sql
CREATE TABLE Workouts (Id INT, MemberId INT, Duration INT, Date DATE); INSERT INTO Workouts (Id, MemberId, Duration, Date) VALUES (1, 1, 60, '2022-01-01'), (2, 1, 45, '2022-01-02'), (3, 2, 90, '2022-01-01'), (4, 2, 75, '2022-01-03'), (5, 3, 120, '2022-01-01');
What is the maximum duration of a workout for each member?
SELECT MemberId, MAX(Duration) FROM Workouts GROUP BY MemberId;
gretelai_synthetic_text_to_sql
CREATE TABLE flower_prices (dispensary_id INT, sale_date DATE, price DECIMAL(10, 2)); INSERT INTO flower_prices (dispensary_id, sale_date, price) VALUES (1, '2022-01-01', 12), (1, '2022-01-15', 10), (1, '2022-02-05', 14), (2, '2022-01-03', 15), (2, '2022-01-31', 11), (2, '2022-02-20', 13);
What was the average price per gram of cannabis flower at each dispensary in Q1 2022?
SELECT d.name, AVG(fp.price / fs.weight) as avg_price_per_gram FROM flower_sales fs JOIN flower_prices fp ON fs.dispensary_id = fp.dispensary_id AND fs.sale_date = fp.sale_date JOIN dispensaries d ON fs.dispensary_id = d.id WHERE fs.sale_date BETWEEN '2022-01-01' AND '2022-03-31' GROUP BY d.name;
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_acidity (id INTEGER, location TEXT, acidity FLOAT, date DATE);
What is the average ocean acidity in the 'Southern Ocean' over the last 5 years?
SELECT AVG(acidity) FROM ocean_acidity WHERE location = 'Southern Ocean' AND date >= DATEADD(year, -5, CURRENT_DATE);
gretelai_synthetic_text_to_sql
CREATE TABLE antarctic_education_programs (organization VARCHAR(50), program_date DATE); INSERT INTO antarctic_education_programs (organization, program_date) VALUES ('Organization A', '2020-01-01'), ('Organization B', '2019-12-15'), ('Organization A', '2018-06-20');
What is the number of community education programs conducted by each organization in the Antarctic conservation programs?
SELECT organization, COUNT(*) FROM antarctic_education_programs GROUP BY organization;
gretelai_synthetic_text_to_sql
CREATE TABLE teachers (id INT, region TEXT, courses_completed INT);
What is the average number of professional development courses completed by teachers in each region?
SELECT region, AVG(courses_completed) FROM teachers GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT, product_type VARCHAR(20), color VARCHAR(20), revenue DECIMAL); INSERT INTO sales (id, product_type, color, revenue) VALUES (1, 'sustainable', 'green', 100.00), (2, 'regular', 'blue', 200.00), (3, 'sustainable', 'green', 300.00), (4, 'regular', 'red', 400.00), (5, 'sustainable', 'blue', 500.0...
What is the most popular color of sustainable fashion products?
SELECT color, COUNT(*) FROM sales WHERE product_type = 'sustainable' GROUP BY color ORDER BY COUNT(*) DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE daily_oil_production (platform_id INT, production_date DATE, oil_production FLOAT); INSERT INTO daily_oil_production (platform_id, production_date, oil_production) VALUES (1, '2020-04-01', 50), (1, '2020-04-02', 60), (1, '2020-04-03', 70), (1, '2020-05-01', 80), (1, '2020-05-02', 90), (1, '2020-05-03', 100...
Determine the daily oil production for a specific platform in Q2 2020
SELECT production_date, oil_production FROM daily_oil_production WHERE platform_id = 1 AND YEAR(production_date) = 2020 AND MONTH(production_date) BETWEEN 2 AND 5;
gretelai_synthetic_text_to_sql
CREATE TABLE students (student_id INT, program VARCHAR(20)); INSERT INTO students (student_id, program) VALUES (1, 'remote_learning'), (2, 'remote_learning'), (3, 'in_person'), (4, 'in_person');
What is the total number of students in each program?
SELECT program, COUNT(*) FROM students GROUP BY program;
gretelai_synthetic_text_to_sql
CREATE TABLE greenhouse_sensors ( id INT, sensor_type VARCHAR(20), temperature DECIMAL(5,2), humidity DECIMAL(5,2), light_level INT, timestamp TIMESTAMP); INSERT INTO greenhouse_sensors (id, sensor_type, temperature, humidity, light_level, timestamp) VALUES (1, 'temperature', 22.5, 60, 500, '2022-01-01 10:00:00'), (2, ...
What is the latest light_level reading from the greenhouse_sensors table?
SELECT MAX(timestamp), light_level FROM greenhouse_sensors WHERE sensor_type = 'light' AND light_level IS NOT NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE cosmetics (product_id INT, product_name VARCHAR(100), rating DECIMAL(2,1), is_eco_friendly BOOLEAN, product_type VARCHAR(50));
What is the average rating of eco-friendly skincare products?
SELECT AVG(rating) FROM cosmetics WHERE is_eco_friendly = TRUE AND product_type = 'skincare';
gretelai_synthetic_text_to_sql
CREATE TABLE citizen_feedback_records (state VARCHAR(20), response_time INT); INSERT INTO citizen_feedback_records (state, response_time) VALUES ('Florida', 48); INSERT INTO citizen_feedback_records (state, response_time) VALUES ('Florida', 52); INSERT INTO citizen_feedback_records (state, response_time) VALUES ('Texas...
What is the average response time for citizen feedback records in the state of Florida?
SELECT AVG(response_time) FROM citizen_feedback_records WHERE state = 'Florida';
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT PRIMARY KEY, PlayerName VARCHAR(100), Country VARCHAR(50), VRAdoption BOOLEAN); INSERT INTO Players VALUES (1, 'Lea', 'France', TRUE);
Get the number of players who have adopted VR technology from each country.
SELECT Country, COUNT(*) as NumPlayers FROM Players WHERE VRAdoption = TRUE GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE imports (id INT, country VARCHAR(20), material VARCHAR(30), quantity INT); CREATE TABLE exports (id INT, country VARCHAR(20), material VARCHAR(30), quantity INT); INSERT INTO imports (id, country, material, quantity) VALUES (1, 'USA', 'Steel', 5000), (2, 'USA', 'Aluminum', 7000), (3, 'China', 'Steel', 8000...
Show the total amount of raw materials imported and exported by each country in the manufacturing domain.
SELECT i.country, SUM(i.quantity) AS total_imported, SUM(e.quantity) AS total_exported FROM imports i INNER JOIN exports e ON i.country = e.country GROUP BY i.country;
gretelai_synthetic_text_to_sql
CREATE TABLE clinical_trials (id INT, drug_id INT, trial_name VARCHAR(50), outcome VARCHAR(50)); INSERT INTO clinical_trials (id, drug_id, trial_name, outcome) VALUES (1, 1, 'TrialA', 'Success'), (2, 1, 'TrialB', 'Failure'), (3, 2, 'TrialC', 'Success'), (4, 3, 'TrialD', 'Success');
What are the clinical trial outcomes for drugs in the neurology department?
SELECT ct.drug_id, ct.trial_name, ct.outcome FROM clinical_trials ct WHERE ct.drug_id IN (SELECT id FROM drugs WHERE department = 'Neurology');
gretelai_synthetic_text_to_sql
CREATE TABLE Cities (CityID int, CityName varchar(255), Country varchar(255), Population int); INSERT INTO Cities (CityID, CityName, Country, Population) VALUES (1, 'Pretoria', 'South Africa', 2000000);
What is the name of the capital city of South Africa and its population?
SELECT CityName, Population FROM Cities WHERE Country = 'South Africa' AND CityName = 'Pretoria';
gretelai_synthetic_text_to_sql
CREATE TABLE players (player_id INT, name TEXT, country TEXT); INSERT INTO players (player_id, name, country) VALUES (1, 'Messi', 'Argentina'), (2, 'Di Maria', 'Argentina'), (3, 'Kane', 'England'); CREATE TABLE fouls (foul_id INT, player_id INT, fouls INT); INSERT INTO fouls (foul_id, player_id, fouls) VALUES (1, 1, 2)...
What is the average number of fouls committed by players from Argentina in the 'World Cup'?
SELECT AVG(fouls) FROM fouls JOIN games ON fouls.player_id = games.player_id JOIN players ON fouls.player_id = players.player_id WHERE players.country = 'Argentina' AND games.tournament = 'World Cup';
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists financial_wellbeing (id INT, user_id INT, country VARCHAR(255), score INT); INSERT INTO financial_wellbeing (id, user_id, country, score) VALUES (1, 1, 'Canada', 70), (2, 2, 'USA', 80), (3, 3, 'Canada', 90);
What is the maximum financial wellbeing score in Canada?
SELECT MAX(score) FROM financial_wellbeing WHERE country = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE Facility_Materials (facility_id INT, source_date DATE, material_weight FLOAT);
What is the total weight of materials used in each production facility for the past year?
SELECT Facility_Materials.facility_id, SUM(Facility_Materials.material_weight) as total_weight FROM Facility_Materials WHERE source_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY Facility_Materials.facility_id;
gretelai_synthetic_text_to_sql
CREATE TABLE WastewaterTreatmentData (plant_location VARCHAR(20), water_consumption_per_day FLOAT); INSERT INTO WastewaterTreatmentData (plant_location, water_consumption_per_day) VALUES ('Miami', 5000000), ('Tampa', 4000000);
What is the maximum water consumption per day in the wastewater treatment plant located in Miami?
SELECT MAX(water_consumption_per_day) FROM WastewaterTreatmentData WHERE plant_location = 'Miami';
gretelai_synthetic_text_to_sql
CREATE TABLE Parks (ID INT, Area VARCHAR(50), Type VARCHAR(50)); INSERT INTO Parks VALUES (1, 'Urban', 'Public'), (2, 'Rural', 'Community'), (3, 'Urban', 'Private');
What is the total number of public parks in urban areas?
SELECT COUNT(*) FROM Parks WHERE Area = 'Urban' AND Type = 'Public';
gretelai_synthetic_text_to_sql
CREATE TABLE donors (id INT, age INT); INSERT INTO donors (id, age) VALUES (1, 32), (2, 45), (3, 28), (4, 52), (5, 18), (6, 23), (7, 48), (8, 37), (9, 57), (10, 21);
How many donors are there in each age group (5-year intervals)?
SELECT FLOOR(age/5)*5 as age_group, COUNT(*) as num_donors FROM donors GROUP BY age_group;
gretelai_synthetic_text_to_sql
CREATE TABLE PeacekeepingOperations (leader VARCHAR(255), operation VARCHAR(255), start_date DATE, end_date DATE, personnel INT); INSERT INTO PeacekeepingOperations (leader, operation, start_date, end_date, personnel) VALUES ('Indonesia', 'Aceh Monitoring Mission', '2005-12-15', '2006-12-15', 500); INSERT INTO Peacekee...
List all peacekeeping operations led by ASEAN member countries since 2000, with their start and end dates and the number of personnel involved, ordered by the most recent operations.
SELECT leader, operation, start_date, end_date, personnel, ROW_NUMBER() OVER (PARTITION BY leader ORDER BY start_date DESC) as operation_rank FROM PeacekeepingOperations WHERE leader LIKE 'ASEAN%' AND start_date >= '2000-01-01' ORDER BY start_date DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE circular_economy (country VARCHAR(50), year INT, initiatives INT); INSERT INTO circular_economy (country, year, initiatives) VALUES ('France', 2020, 12), ('Germany', 2020, 15), ('Italy', 2020, 18), ('Spain', 2020, 10), ('United Kingdom', 2020, 20);
What is the number of circular economy initiatives for each country in Europe in 2020?
SELECT country, initiatives FROM circular_economy WHERE year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE training_programs (id INT, department VARCHAR(20), program VARCHAR(50), date DATE, completed BOOLEAN); INSERT INTO training_programs (id, department, program, date, completed) VALUES (1, 'IT', 'Python', '2022-01-01', true);
Delete all records from the 'training_programs' table for the 'IT' department
DELETE FROM training_programs WHERE department = 'IT';
gretelai_synthetic_text_to_sql
CREATE TABLE Species ( id INT PRIMARY KEY, name VARCHAR(255), family VARCHAR(255), population INT);
What are the names of all marine species and their respective families with a population greater than 1000?
SELECT name, family FROM Species WHERE population > 1000;
gretelai_synthetic_text_to_sql
CREATE TABLE Accidents (MineID INT, MineType VARCHAR(15), AccidentDate DATE);
What is the total number of accidents in the diamond mines in the last 5 years?
SELECT COUNT(*) FROM Accidents WHERE MineType = 'Diamond' AND AccidentDate >= DATEADD(year, -5, GETDATE());
gretelai_synthetic_text_to_sql
CREATE SCHEMA green_buildings; CREATE TABLE certifications (certification_name VARCHAR(255), year_established INT); INSERT INTO certifications (certification_name, year_established) VALUES ('LEED', 2000), ('BREEAM', 1998), ('Green Star', 2008), ('WELL', 2014);
List the names of all Green Building certifications established between 2000 and 2010, in ascending order.
SELECT certification_name FROM green_buildings.certifications WHERE year_established >= 2000 AND year_established <= 2010 ORDER BY certification_name;
gretelai_synthetic_text_to_sql
CREATE TABLE energy_savings (id INT, building_id INT, technology VARCHAR(50), energy_savings_kwh FLOAT, saving_date DATE);
Calculate the average energy savings (in kWh) for each technology type, per year in the 'energy_savings' table
SELECT technology, EXTRACT(YEAR FROM saving_date) as year, AVG(energy_savings_kwh) as avg_savings FROM energy_savings GROUP BY technology, year;
gretelai_synthetic_text_to_sql
CREATE TABLE donor (id INT, name VARCHAR(255)); CREATE TABLE donation (id INT, donor_id INT, cause VARCHAR(255), amount DECIMAL(10, 2)); INSERT INTO donor (id, name) VALUES (1, 'Jane Doe'), (2, 'John Smith'), (3, 'Mary Johnson'); INSERT INTO donation (id, donor_id, cause, amount) VALUES (1, 1, 'animal_welfare', 500), (...
Who are the top 5 donors by total donation amount to the 'animal_welfare' cause?
SELECT donor_id, SUM(amount) as total_donations FROM donation WHERE cause = 'animal_welfare' GROUP BY donor_id ORDER BY total_donations DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE concerts (id INT, country VARCHAR(255), city VARCHAR(255), artist_name VARCHAR(255), tier VARCHAR(255), price DECIMAL(10,2), num_tickets INT); CREATE VIEW artist_countries AS SELECT artist_name, country FROM concerts;
Find the number of unique artists who have performed in each country, excluding artists who have performed in only one city.
SELECT country, COUNT(DISTINCT artist_name) AS num_artists FROM artist_countries GROUP BY country HAVING COUNT(DISTINCT city) > 1;
gretelai_synthetic_text_to_sql
CREATE TABLE plants (id INT, name TEXT, location TEXT, safety_score FLOAT); INSERT INTO plants (id, name, location, safety_score) VALUES (1, 'ABC Plant', 'California', 85.6), (2, 'XYZ Plant', 'California', 92.3);
What is the average safety score for chemical production plants located in California, ordered by the score in descending order?
SELECT AVG(safety_score) AS avg_safety_score FROM plants WHERE location = 'California' ORDER BY safety_score DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (transaction_id INT, activity_type TEXT, country TEXT); INSERT INTO transactions (transaction_id, activity_type, country) VALUES (1, 'Sustainable Transportation', 'Canada'), (2, 'Eco-Friendly Accommodation', 'Canada'), (3, 'Cultural Heritage Preservation', 'USA');
List all transactions involving sustainable tourism activities in Canada.
SELECT * FROM transactions WHERE activity_type LIKE '%sustainable%' AND country = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, sector VARCHAR(20), ESG_score FLOAT); INSERT INTO companies (id, sector, ESG_score) VALUES (1, 'technology', 78.3), (2, 'finance', 65.2), (3, 'technology', 74.5);
What is the minimum ESG score for companies in the 'technology' sector?
SELECT MIN(ESG_score) FROM companies WHERE sector = 'technology';
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, Country VARCHAR(20), VRPlatform VARCHAR(10), PrefersPC BOOLEAN);
Insert a new record for a player from 'Brazil' who uses Oculus and prefers PC gaming.
INSERT INTO Players (PlayerID, Country, VRPlatform, PrefersPC) VALUES (3, 'Brazil', 'Oculus', TRUE);
gretelai_synthetic_text_to_sql
CREATE TABLE donor (did INT, age INT, total_donation DECIMAL(10, 2)); INSERT INTO donor (did, age, total_donation) VALUES (1, 30, 1500), (2, 45, 1200), (3, 22, 800), (4, 50, 1700), (5, 28, 900);
What is the total donation amount by age group?
SELECT age_group, SUM(total_donation) as total_donation FROM (SELECT CASE WHEN age < 30 THEN '18-30' WHEN age < 50 THEN '31-50' ELSE '51+' END as age_group, total_donation FROM donor) t GROUP BY age_group;
gretelai_synthetic_text_to_sql
CREATE TABLE MiningCompanies (CompanyID INT, CompanyName VARCHAR(255)); INSERT INTO MiningCompanies (CompanyID, CompanyName) VALUES (1, 'ABC Mining'); INSERT INTO MiningCompanies (CompanyID, CompanyName) VALUES (2, 'XYZ Excavation'); CREATE TABLE Employees (EmployeeID INT, CompanyID INT, FirstName VARCHAR(255), LastNam...
What is the total number of employees for each mining company?
SELECT e.CompanyID, COUNT(e.EmployeeID) as TotalEmployees FROM Employees e GROUP BY e.CompanyID;
gretelai_synthetic_text_to_sql
CREATE TABLE athlete_wellbeing (athlete_id INT, wellbeing_program VARCHAR(20)); INSERT INTO athlete_wellbeing (athlete_id, wellbeing_program) VALUES (1, 'Yoga'), (2, 'Meditation'), (3, 'Stretching');
Delete all records from the 'athlete_wellbeing' table where the wellbeing_program is 'Meditation'
DELETE FROM athlete_wellbeing WHERE wellbeing_program = 'Meditation';
gretelai_synthetic_text_to_sql
CREATE TABLE patients (patient_id INT, name VARCHAR(50), age INT, state VARCHAR(50)); CREATE TABLE therapy_sessions (session_id INT, patient_id INT, therapist_id INT, session_date DATE, therapy_type VARCHAR(50)); INSERT INTO patients VALUES (1, 'John Doe', 35, 'California'); INSERT INTO patients VALUES (2, 'Jane Smith'...
List the names and treatment start dates of patients who have been treated with Cognitive Behavioral Therapy (CBT) or Dialectical Behavior Therapy (DBT)
SELECT patients.name, therapy_sessions.session_date FROM patients JOIN therapy_sessions ON patients.patient_id = therapy_sessions.patient_id WHERE therapy_sessions.therapy_type IN ('CBT', 'DBT');
gretelai_synthetic_text_to_sql
CREATE TABLE Trains (id INT, region VARCHAR(10), fare_collected DECIMAL(5,2)); INSERT INTO Trains (id, region, fare_collected) VALUES (1, 'west', 200.00), (2, 'west', 300.00), (3, 'east', 150.00);
What is the total fare collected for trains in the 'west' region in the last month?
SELECT SUM(Trains.fare_collected) FROM Trains WHERE Trains.region = 'west' AND Trains.fare_collected > 0 AND Trains.fare_collected IS NOT NULL AND Trains.fare_collected <> '';
gretelai_synthetic_text_to_sql
CREATE TABLE climate_investment (id INT, country VARCHAR(50), type VARCHAR(50), investment FLOAT); INSERT INTO climate_investment (id, country, type, investment) VALUES (1, 'China', 'climate adaptation', 500000.00), (2, 'India', 'climate mitigation', 750000.00), (3, 'Indonesia', 'climate adaptation', 600000.00);
What is the average investment in climate adaptation per project in Asia?
SELECT AVG(investment) FROM climate_investment WHERE country IN ('China', 'India', 'Indonesia', 'Japan', 'Vietnam') AND type = 'climate adaptation';
gretelai_synthetic_text_to_sql
CREATE TABLE WastewaterTreatmentPlants (PlantID INT, PlantName VARCHAR(50), Location VARCHAR(50), Capacity FLOAT); INSERT INTO WastewaterTreatmentPlants (PlantID, PlantName, Location, Capacity) VALUES (1, 'PlantA', 'LocationA', 500.5), (2, 'PlantB', 'LocationB', 600.2), (1001, 'PlantX', 'LocationX', 800.0);
Delete records of wastewater treatment plants with a "PlantID" greater than 1000.
DELETE FROM WastewaterTreatmentPlants WHERE PlantID > 1000;
gretelai_synthetic_text_to_sql
CREATE TABLE Site_Production (Site_ID INT, Production_Date DATE, Production_Quantity INT); INSERT INTO Site_Production (Site_ID, Production_Date, Production_Quantity) VALUES (1, '2022-01-01', 500), (1, '2022-02-01', 550), (1, '2022-03-01', 600), (2, '2022-01-01', 800), (2, '2022-02-01', 850), (2, '2022-03-01', 900);
Show the 3-month moving average of production for each site.
SELECT Site_ID, AVG(Production_Quantity) OVER (PARTITION BY Site_ID ORDER BY Production_Date ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) as Three_Month_Moving_Avg FROM Site_Production;
gretelai_synthetic_text_to_sql
CREATE TABLE DefenseDiplomacy (ID INT, EventName TEXT, EventDate DATE, Country TEXT, ParticipatingCountries TEXT); INSERT INTO DefenseDiplomacy VALUES (1, 'Event 1', '2016-01-01', 'USA', 'Canada, Mexico'); CREATE VIEW DiplomacyCountries AS SELECT Country FROM DefenseDiplomacy WHERE Country IN ('USA', 'Canada', 'Mexico'...
Which countries have been involved in the most defense diplomacy events in the last 7 years, along with the number of events?
SELECT dc.Country, COUNT(*) as DiplomacyCount FROM DefenseDiplomacy d JOIN DiplomacyCountries dc ON d.Country = dc.Country WHERE d.EventDate BETWEEN DATEADD(year, -7, GETDATE()) AND GETDATE() GROUP BY dc.Country ORDER BY DiplomacyCount DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE osha_fines (fine_id INT, region TEXT, amount INT); INSERT INTO osha_fines (fine_id, region, amount) VALUES (1, 'Northeast', 5000), (2, 'West Coast', 10000), (3, 'South', 7500);
What is the minimum workplace safety fine issued by OSHA in each region?
SELECT region, MIN(amount) OVER (PARTITION BY region) FROM osha_fines;
gretelai_synthetic_text_to_sql
CREATE TABLE HeritageSites (SiteID int, SiteName varchar(50), Country varchar(50)); INSERT INTO HeritageSites (SiteID, SiteName, Country) VALUES (1, 'Giza Pyramids', 'Egypt'), (2, 'African Renaissance Monument', 'Senegal'), (3, 'Taj Mahal', 'India'), (4, 'Angkor Wat', 'Cambodia'), (5, 'Machu Picchu', 'Peru'), (6, 'Petr...
Which countries have more than 3 heritage sites?
SELECT Country, COUNT(*) FROM HeritageSites GROUP BY Country HAVING COUNT(*) > 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (id INT, name TEXT, country TEXT, hours FLOAT, quarter TEXT, year INT); INSERT INTO Volunteers (id, name, country, hours, quarter, year) VALUES (1, 'Alice', 'USA', 5.0, 'Q3', 2021), (2, 'Bob', 'Canada', 7.5, 'Q3', 2021);
What is the total number of volunteer hours contributed by volunteers from the USA and Canada in Q3 2021?
SELECT SUM(hours) FROM Volunteers WHERE country IN ('USA', 'Canada') AND quarter = 'Q3' AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers (supplier_id INT, supplier_name VARCHAR(50)); INSERT INTO suppliers (supplier_id, supplier_name) VALUES (1, 'ABC Supplies'), (2, 'XYZ Components'), (3, 'Green Solutions'); CREATE TABLE deliveries (delivery_id INT, supplier_id INT, component_quantity INT, delivery_time INT); INSERT INTO deliveries...
List all suppliers and their average delivery time for components, arranged alphabetically by supplier name.
SELECT supplier_name, AVG(delivery_time) as avg_delivery_time FROM deliveries JOIN suppliers ON deliveries.supplier_id = suppliers.supplier_id GROUP BY supplier_name ORDER BY supplier_name;
gretelai_synthetic_text_to_sql
CREATE TABLE infrastructure_development (project_id INT, location VARCHAR(30), start_date DATE, end_date DATE, cost INT); INSERT INTO infrastructure_development (project_id, location, start_date, end_date, cost) VALUES (1, 'North Sea', '2017-01-01', '2021-12-31', 300000000); INSERT INTO infrastructure_development (proj...
Update the 'end_date' value for the record with 'project_id' = 2 in the 'infrastructure_development' table to '2023-12-31'
UPDATE infrastructure_development SET end_date = '2023-12-31' WHERE project_id = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE volunteer_program (id INT, name VARCHAR(50), age INT, location VARCHAR(30)); INSERT INTO volunteer_program (id, name, age, location) VALUES (1, 'John Doe', 25, 'New York'), (2, 'Jane Smith', 32, 'California'), (3, 'Alice Johnson', 22, 'Texas');
What is the total number of volunteers in the 'volunteer_program' table, grouped by age range (18-30, 31-40, 41-50)?
SELECT CASE WHEN age BETWEEN 18 AND 30 THEN '18-30' WHEN age BETWEEN 31 AND 40 THEN '31-40' WHEN age BETWEEN 41 AND 50 THEN '41-50' ELSE '50+' END AS age_range, COUNT(*) FROM volunteer_program GROUP BY age_range;
gretelai_synthetic_text_to_sql
CREATE TABLE tourism_stats (destination VARCHAR(255), year INT, visitors INT); INSERT INTO tourism_stats (destination, year, visitors) VALUES ('United States', 2019, 30000000);
Find the percentage of tourists who visited the United States in 2019
SELECT (visitors / (SELECT SUM(visitors) FROM tourism_stats) * 100) AS percentage FROM tourism_stats WHERE destination = 'United States' AND year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE Attorneys (AttorneyID INT, Gender VARCHAR(10), BillingAmount DECIMAL); INSERT INTO Attorneys (AttorneyID, Gender, BillingAmount) VALUES (1, 'Female', 2500.00), (2, 'Male', 1800.00), (3, 'Female', 3200.00);
What is the maximum billing amount for cases handled by attorneys who identify as female?
SELECT MAX(BillingAmount) FROM Attorneys WHERE Gender = 'Female';
gretelai_synthetic_text_to_sql
CREATE TABLE Films (film_id INT, title VARCHAR(255), release_date DATE, production_budget INT, director_gender VARCHAR(10)); INSERT INTO Films (film_id, title, release_date, production_budget, director_gender) VALUES (1, 'Movie1', '2000-01-01', 5000000, 'female'), (2, 'Movie2', '2005-01-01', 7000000, 'male'), (3, 'Movi...
What is the sum of all production budgets for films by female directors?
SELECT SUM(production_budget) FROM Films WHERE director_gender = 'female';
gretelai_synthetic_text_to_sql
CREATE TABLE malware_types (type_id INT, type_name VARCHAR(100));CREATE TABLE malware_instances (instance_id INT, type_id INT, instance_date DATE);
What are the top 5 most common types of malware, and how many instances of each type were detected in the last 90 days?
SELECT mt.type_name, COUNT(mi.instance_id) as total_instances FROM malware_types mt JOIN malware_instances mi ON mt.type_id = mi.type_id WHERE mi.instance_date >= NOW() - INTERVAL 90 DAY GROUP BY mt.type_name ORDER BY total_instances DESC LIMIT 5;
gretelai_synthetic_text_to_sql