context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE Attendees (attendee_id INT, attendee_community VARCHAR(50), attendance_date DATE); INSERT INTO Attendees (attendee_id, attendee_community, attendance_date) VALUES (1, 'Hispanic', '2020-01-01'), (2, 'African American', '2020-02-01'), (3, 'Asian', '2020-03-01'), (4, 'Native American', '2020-04-01'), (5, 'Cau...
How many attendees were from underrepresented communities in 2020?
SELECT COUNT(*) AS total_attendees FROM Attendees WHERE attendance_date BETWEEN '2020-01-01' AND '2020-12-31' AND attendee_community IN ('Hispanic', 'African American', 'Asian', 'Native American', 'LGBTQ+', 'Disabled', 'Women', 'Senior', 'Youth', 'Veteran', 'Refugee');
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists projects (id INT, name VARCHAR(100), category VARCHAR(50), total_cost FLOAT); INSERT INTO projects (id, name, category, total_cost) VALUES (1, 'Water Treatment Plant', 'water_infrastructure', 5000000);
What was the total cost of projects in the 'water_infrastructure' category?
SELECT SUM(total_cost) FROM projects WHERE category = 'water_infrastructure';
gretelai_synthetic_text_to_sql
CREATE TABLE esports_events (id INT, event_name VARCHAR(50), date DATE, venue_id INT); CREATE TABLE venues (id INT, name VARCHAR(50), capacity INT); INSERT INTO esports_events (id, event_name, date, venue_id) VALUES (1, 'GameX', '2023-06-01', 101); INSERT INTO venues (id, name, capacity) VALUES (101, 'Staples Center', ...
What are the names of all venues that have hosted esports events?
SELECT venues.name FROM venues INNER JOIN esports_events ON venues.id = esports_events.venue_id;
gretelai_synthetic_text_to_sql
CREATE TABLE students (student_id INT, major VARCHAR(255)); INSERT INTO students (student_id, major) VALUES (1, 'Computer Science'), (2, 'Mathematics'), (3, 'Psychology'), (4, 'Biology'), (5, 'Computer Science');
List all the unique majors offered in the 'Students' table.
SELECT DISTINCT major FROM students;
gretelai_synthetic_text_to_sql
CREATE TABLE Spacecraft (id INT, name VARCHAR(255), manufacturer VARCHAR(255), budget DECIMAL(10, 2)); INSERT INTO Spacecraft (id, name, manufacturer, budget) VALUES (1, 'Voyager I', 'AeroSpace Inc.', 800000000.00), (2, 'Voyager II', 'AeroSpace Inc.', 850000000.00);
What was the total budget for spacecraft manufactured by 'AeroSpace Inc.'?
SELECT SUM(budget) FROM Spacecraft WHERE manufacturer = 'AeroSpace Inc.';
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_offset_initiatives (id INT, name VARCHAR(50), location VARCHAR(50), offset_amount INT);
Insert a new record into the carbon offset initiatives table
INSERT INTO carbon_offset_initiatives (id, name, location, offset_amount) VALUES (5, 'Tree Planting', 'City M', 1000);
gretelai_synthetic_text_to_sql
CREATE TABLE oceanic_animal_profiles (id INT, animal_name VARCHAR(50), age INT, species_id INT); INSERT INTO oceanic_animal_profiles (id, animal_name, age, species_id) VALUES (1, 'Blue Whale', 30, 1001), (2, 'Dolphin', 8, 1002), (3, 'Sea Turtle', 25, 1003);
What is the minimum age of all animals in the 'oceanic_animal_profiles' table?
SELECT MIN(age) FROM oceanic_animal_profiles;
gretelai_synthetic_text_to_sql
CREATE TABLE south_american_countries (country VARCHAR(255), population INT, water_consumption INT); INSERT INTO south_american_countries (country, population, water_consumption) VALUES ('Brazil', 210000000, 4200000000), ('Colombia', 50000000, 1000000000);
What is the average water consumption per person in South American countries?
SELECT country, water_consumption / population AS avg_water_consumption FROM south_american_countries;
gretelai_synthetic_text_to_sql
CREATE TABLE crew_members ( full_name VARCHAR(255), gender VARCHAR(10), position VARCHAR(255), hire_date DATE, vessel_name VARCHAR(255));
Insert records in the crew_members table for vessel "Pacific Voyager" with the following data: ('John Doe', 'Male', 'Captain', '2022-04-01')
INSERT INTO crew_members (full_name, gender, position, hire_date, vessel_name) VALUES ('John Doe', 'Male', 'Captain', '2022-04-01', 'Pacific Voyager');
gretelai_synthetic_text_to_sql
CREATE TABLE CityB_Issues (ID INT, Year INT, Issue VARCHAR(50)); INSERT INTO CityB_Issues (ID, Year, Issue) VALUES (1, 2021, 'Potholes'), (2, 2021, 'Street Lighting'); CREATE TABLE CityC_Issues (ID INT, Year INT, Issue VARCHAR(50)); INSERT INTO CityC_Issues (ID, Year, Issue) VALUES (3, 2021, 'Potholes'), (4, 2021, 'Gar...
Identify the number of unique policy issues reported by citizens in 'CityB' and 'CityC' in 2021, excluding duplicates.
SELECT COUNT(DISTINCT Issue) FROM (SELECT Issue FROM CityB_Issues WHERE Year = 2021 UNION SELECT Issue FROM CityC_Issues WHERE Year = 2021) AS CombinedIssues;
gretelai_synthetic_text_to_sql
CREATE TABLE Arts (id INT, name TEXT, origin TEXT); INSERT INTO Arts (id, name, origin) VALUES (1, 'Kabuki', 'Japan'); CREATE TABLE Locations (id INT, art_id INT, continent TEXT); INSERT INTO Locations (id, art_id, continent) VALUES (1, 1, 'Asia');
How many traditional art forms are there in Asia, and what are their names and origins?
SELECT A.name, A.origin, COUNT(*) FROM Arts A INNER JOIN Locations L ON A.id = L.art_id WHERE L.continent = 'Asia' GROUP BY A.name, A.origin;
gretelai_synthetic_text_to_sql
CREATE TABLE AutoShow (id INT, name VARCHAR(100), year INT, location VARCHAR(50));
How many auto shows have been held in Canada since the year 2000?
SELECT COUNT(*) FROM AutoShow WHERE year >= 2000 AND location = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE expeditions (id INT PRIMARY KEY, name VARCHAR(50), location VARCHAR(50), start_date DATE, end_date DATE); CREATE TABLE researchers (id INT PRIMARY KEY, name VARCHAR(50), affiliation VARCHAR(50)); CREATE TABLE expedition_researchers AS SELECT NULL id, e.name AS expedition, r.name AS researcher FROM expediti...
Delete the records in the expedition_researchers table for the expedition 'Expedition2'.
DELETE FROM expedition_researchers WHERE expedition = 'Expedition2';
gretelai_synthetic_text_to_sql
CREATE TABLE student_demographics (id INT PRIMARY KEY, name VARCHAR(255), age INT, gender VARCHAR(50), ethnicity VARCHAR(50));
Retrieve all records from the student_demographics table
SELECT * FROM student_demographics;
gretelai_synthetic_text_to_sql
CREATE TABLE ResilienceProjects (ProjectID int, Sector varchar(10), Budget int); INSERT INTO ResilienceProjects (ProjectID, Sector, Budget) VALUES (1, 'Water', 500000), (2, 'Transport', 800000), (3, 'Energy', 600000);
What is the maximum budget for a resilience project in the 'Transport' sector?
SELECT MAX(Budget) AS MaxBudget FROM ResilienceProjects WHERE Sector = 'Transport';
gretelai_synthetic_text_to_sql
CREATE TABLE Building_Permits (Permit_ID INT, Permit_Date DATE, Location TEXT, Type TEXT); INSERT INTO Building_Permits (Permit_ID, Permit_Date, Location, Type) VALUES (1, '2020-01-01', 'Texas', 'Residential'), (2, '2020-02-15', 'California', 'Commercial'), (3, '2020-04-20', 'Texas', 'Residential'), (4, '2020-06-30', '...
How many building permits were issued in Texas between January 2020 and June 2020?
SELECT COUNT(*) FROM Building_Permits WHERE Location = 'Texas' AND Permit_Date BETWEEN '2020-01-01' AND '2020-06-30';
gretelai_synthetic_text_to_sql
CREATE TABLE client_demographics (client_id INT PRIMARY KEY, gender VARCHAR(10), income DECIMAL(10,2));
Create a table named 'client_demographics'
CREATE TABLE client_demographics (client_id INT PRIMARY KEY, gender VARCHAR(10), income DECIMAL(10,2));
gretelai_synthetic_text_to_sql
CREATE TABLE Extraction (ExtractionID INT, MineID INT, Year INT, Material VARCHAR(255), Amount INT); INSERT INTO Extraction (ExtractionID, MineID, Year, Material, Amount) VALUES (1, 1, 2019, 'Gold', 100); INSERT INTO Extraction (ExtractionID, MineID, Year, Material, Amount) VALUES (2, 1, 2018, 'Gold', 110); INSERT INTO...
What is the average amount of gold extracted annually from each mine in Australia?
SELECT AVG(e.Amount) as AvgAnnualGoldExtraction FROM Extraction e INNER JOIN Mines m ON e.MineID = m.MineID WHERE m.Country = 'Australia' AND e.Material = 'Gold' GROUP BY e.MineID;
gretelai_synthetic_text_to_sql
CREATE TABLE policyholders (id INT, name VARCHAR(100), city VARCHAR(50), state VARCHAR(20)); CREATE TABLE claims (id INT, policyholder_id INT, amount DECIMAL(10, 2)); INSERT INTO policyholders (id, name, city, state) VALUES (1, 'Sarah Lee', 'New York', 'NY'), (2, 'Tom Chen', 'Buffalo', 'NY'); INSERT INTO claims (id, po...
What is the maximum claim amount for policyholders in the state of New York?
SELECT MAX(claims.amount) FROM claims JOIN policyholders ON claims.policyholder_id = policyholders.id WHERE policyholders.state = 'NY';
gretelai_synthetic_text_to_sql
CREATE TABLE incidents(id INT, vessel_id INT, incident_date DATE); INSERT INTO incidents VALUES (1, 2, '2021-09-15'), (2, 2, '2022-02-03');
How many incidents were reported for VesselB in the last year?
SELECT COUNT(*) FROM incidents WHERE vessel_id = 2 AND incident_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) AND CURRENT_DATE;
gretelai_synthetic_text_to_sql
CREATE TABLE advertisers (advertiser_id INT, advertiser_name VARCHAR(50), spend DECIMAL(10, 2), spend_date DATE); INSERT INTO advertisers VALUES (304, 'Advertiser G', 4000, '2022-07-01'), (305, 'Advertiser H', 6000, '2022-07-05'), (306, 'Advertiser I', 8000, '2022-07-10');
What is the total ad spend per advertiser for the month of July 2022?
SELECT advertiser_name, SUM(spend) as total_spend FROM advertisers WHERE MONTH(spend_date) = 7 AND YEAR(spend_date) = 2022 GROUP BY advertiser_name;
gretelai_synthetic_text_to_sql
CREATE TABLE Wholesale_Prices (Wholesale_Price_ID INT, Strain TEXT, Wholesale_Price DECIMAL); INSERT INTO Wholesale_Prices (Wholesale_Price_ID, Strain, Wholesale_Price) VALUES (1, 'Sour Diesel', 4.00);
Determine the difference between the average wholesale price and average retail price per gram for each strain of cannabis flower.
SELECT Wholesale_Prices.Strain, AVG(Wholesale_Price) as Avg_Wholesale_Price, AVG(Retail_Price) as Avg_Retail_Price, AVG(Retail_Price) - AVG(Wholesale_Price) as Price_Difference FROM Wholesale_Prices JOIN Sales ON Wholesale_Prices.Strain = Sales.Strain GROUP BY Wholesale_Prices.Strain;
gretelai_synthetic_text_to_sql
CREATE TABLE education_programs (program_date DATE, program_type VARCHAR(50));
Display the number of community education programs for each month in the year 2020.
SELECT EXTRACT(MONTH FROM program_date) as month, COUNT(*) as num_programs FROM education_programs WHERE EXTRACT(YEAR FROM program_date) = 2020 GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE startups (id INT, name VARCHAR(50), location VARCHAR(50), funding FLOAT); INSERT INTO startups (id, name, location, funding) VALUES (1, 'Genetech', 'San Francisco', 12000000); INSERT INTO startups (id, name, location, funding) VALUES (2, 'Zymergen', 'Emeryville', 25000000);
What is the average funding amount for biotech startups in the Bay Area?
SELECT AVG(funding) FROM startups WHERE location = 'Bay Area';
gretelai_synthetic_text_to_sql
CREATE TABLE community_development (id INT, region VARCHAR(50), initiative_type VARCHAR(50), cost FLOAT, start_date DATE, end_date DATE); INSERT INTO community_development (id, region, initiative_type, cost, start_date, end_date) VALUES (1, 'Lombardy', 'Community Center', 30000.00, '2015-01-01', '2015-12-31');
How many community development initiatives were completed in the region of Lombardy between 2015 and 2017?
SELECT COUNT(*) FROM community_development WHERE region = 'Lombardy' AND start_date <= '2017-12-31' AND end_date >= '2015-01-01' AND initiative_type = 'Community Center';
gretelai_synthetic_text_to_sql
CREATE TABLE local_impact (city TEXT, sustainability_score INT, economic_impact INT); INSERT INTO local_impact (city, sustainability_score, economic_impact) VALUES ('Rome', 8, 5000000), ('Rome', 9, 6000000);
What is the local economic impact of sustainable tourism in Rome?
SELECT economic_impact FROM local_impact WHERE city = 'Rome';
gretelai_synthetic_text_to_sql
CREATE SCHEMA GreenEnergy; CREATE TABLE RenewableProjects (project_id INT, name VARCHAR(50), location VARCHAR(50), installed_capacity FLOAT); INSERT INTO RenewableProjects (project_id, name, location, installed_capacity) VALUES (1, 'Solar Farm A', 'City A', 5000.0), (2, 'Wind Farm B', 'City B', 7500.0);
What is the total installed capacity of renewable energy projects in the 'GreenEnergy' schema?
SELECT SUM(installed_capacity) FROM GreenEnergy.RenewableProjects;
gretelai_synthetic_text_to_sql
CREATE TABLE workforce (id INT, mining_operation_id INT, gender VARCHAR(50), role VARCHAR(50)); INSERT INTO workforce (id, mining_operation_id, gender, role) VALUES (1, 1, 'Female', 'Engineer'); INSERT INTO workforce (id, mining_operation_id, gender, role) VALUES (2, 1, 'Male', 'Manager'); INSERT INTO workforce (id, mi...
What is the percentage of women in the workforce of each mining operation?
SELECT mining_operation_id, ROUND(100.0 * SUM(CASE WHEN gender = 'Female' THEN 1 ELSE 0 END) / COUNT(*), 2) as percentage FROM workforce GROUP BY mining_operation_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Members (id INT, gender VARCHAR(10), membershipLength INT, joinDate DATE); CREATE TABLE BodyMetrics (id INT, memberId INT, bodyFatPercentage DECIMAL(3,2), weight DECIMAL(5,2)); INSERT INTO Members (id, gender, membershipLength, joinDate) VALUES (1, 'Female', 12, '2020-01-01'), (2, 'Male', 6, '2019-07-15'),...
How many users have a body fat percentage less than 15% and weigh more than 200 pounds?
SELECT COUNT(*) FROM BodyMetrics JOIN Members ON BodyMetrics.memberId = Members.id WHERE bodyFatPercentage < 0.15 AND weight > 200.0;
gretelai_synthetic_text_to_sql
CREATE TABLE network_investments (investment_id INT, investment_date DATE, region VARCHAR(50), amount DECIMAL(5,2)); INSERT INTO network_investments (investment_id, investment_date, region, amount) VALUES (1, '2022-02-01', 'North', 50000.00), (2, '2022-03-14', 'South', 40000.00), (3, '2022-01-22', 'East', 35000.00), (4...
What is the total network investment for each region in the past year?
SELECT region, SUM(amount) as total_investment FROM network_investments WHERE investment_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE SCHEMA labor_rights; CREATE TABLE employees (id INT, name VARCHAR, sector VARCHAR, union_member BOOLEAN); INSERT INTO employees VALUES (1, 'Jane Smith', 'Tech', TRUE); CREATE TABLE unions (id INT, name VARCHAR, sector VARCHAR); INSERT INTO unions VALUES (1, 'Union X', 'Tech');
What is the percentage of employees in each sector who are members of a union in the 'labor_rights' schema?
SELECT sector, 100.0 * AVG(CASE WHEN union_member THEN 1 ELSE 0 END) AS union_membership_percentage FROM labor_rights.employees JOIN labor_rights.unions ON employees.sector = unions.sector GROUP BY sector;
gretelai_synthetic_text_to_sql
CREATE TABLE visits (visit_id INT, destination TEXT, visit_date DATE); INSERT INTO visits (visit_id, destination, visit_date) VALUES (1, 'New York', '2022-01-01'), (2, 'New York', '2022-02-01'), (3, 'Vancouver', '2022-03-01');
Find the 2nd most visited destination for each year in the 'visits' table.
SELECT destination, EXTRACT(YEAR FROM visit_date) AS visit_year, RANK() OVER (PARTITION BY EXTRACT(YEAR FROM visit_date) ORDER BY COUNT(*) DESC) AS visit_rank FROM visits GROUP BY destination, EXTRACT(YEAR FROM visit_date) HAVING visit_rank = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE Action_Players (Player_ID INT, Name VARCHAR(20)); INSERT INTO Action_Players (Player_ID, Name) VALUES (1, 'John'), (2, 'Sarah'), (3, 'Mike'), (4, 'David'); CREATE TABLE Adventure_Players (Player_ID INT, Name VARCHAR(20)); INSERT INTO Adventure_Players (Player_ID, Name) VALUES (2, 'Sarah'), (3, 'Mike'), (4,...
What is the total number of players who have played action or adventure games?
SELECT COUNT(*) FROM Action_Players UNION SELECT COUNT(*) FROM Adventure_Players;
gretelai_synthetic_text_to_sql
CREATE TABLE digital_assets_partial (asset_name TEXT, regulatory_status TEXT, country TEXT);
What is the total number of unique digital assets with a regulatory status of "partially regulated" in each country?
SELECT country, COUNT(DISTINCT asset_name) FROM digital_assets_partial WHERE regulatory_status = 'partially regulated' GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE field_temperatures (field_id VARCHAR(10), temperature INT, reading_date DATE); INSERT INTO field_temperatures (field_id, temperature, reading_date) VALUES ('A', 10, '2021-12-01'), ('B', 15, '2021-12-02'), ('C', 12, '2021-12-03');
List all fields that had a maximum temperature above the minimum temperature for field A in December 2021.
SELECT field_id FROM field_temperatures WHERE temperature > (SELECT MIN(temperature) FROM field_temperatures WHERE field_id = 'A') AND reading_date BETWEEN '2021-12-01' AND '2021-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE wind_turbines (id INT, farm_id INT, name VARCHAR(255), installed_capacity INT); INSERT INTO wind_turbines (id, farm_id, name, installed_capacity) VALUES (1, 1, 'Turbine A', 50), (2, 2, 'Turbine B', 60);
What is the maximum installed capacity of a single wind turbine in the wind farm with the highest installed capacity?
SELECT MAX(installed_capacity) FROM wind_turbines WHERE farm_id IN (SELECT id FROM (SELECT MAX(id) AS id FROM wind_farms) AS max_farm_id);
gretelai_synthetic_text_to_sql
CREATE TABLE wells (well_id INT, location VARCHAR(255), production_figures FLOAT); INSERT INTO wells (well_id, location, production_figures) VALUES (1, 'Permian Basin', 15000); INSERT INTO wells (well_id, location, production_figures) VALUES (2, 'Eagle Ford', 12000);
What are the production figures for wells in the Permian Basin, sorted by production?
SELECT location, production_figures FROM wells WHERE location = 'Permian Basin' ORDER BY production_figures DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Exhibitions (id INT, name VARCHAR(20)); INSERT INTO Exhibitions (id, name) VALUES (1, 'Modern Art'), (2, 'Photography');
What is the total number of visitors for the modern art and photography exhibitions?
SELECT COUNT(*) FROM Visitors JOIN Exhibitions ON Visitors.exhibition_id = Exhibitions.id WHERE Exhibitions.name IN ('Modern Art', 'Photography');
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels (ID INT, Name VARCHAR(255), SafetyScore INT, LastSafetyCheck DATETIME); INSERT INTO Vessels (ID, Name, SafetyScore, LastSafetyCheck) VALUES (7, 'Indian Titan', 88, '2022-01-05'), (8, 'Asian Ace', 96, '2022-02-23');
Update the safety score of the vessel 'Indian Titan' to 93 if its last safety check was more than a month ago.
UPDATE Vessels SET SafetyScore = 93 WHERE Name = 'Indian Titan' AND LastSafetyCheck < DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE health_insurance (id INT, insured BOOLEAN, state TEXT); INSERT INTO health_insurance (id, insured, state) VALUES (1, true, 'California'); INSERT INTO health_insurance (id, insured, state) VALUES (2, false, 'Florida');
What is the percentage of uninsured individuals in Florida?
SELECT (SUM(NOT insured) * 100.0 / COUNT(*)) FROM health_insurance WHERE state = 'Florida';
gretelai_synthetic_text_to_sql
CREATE TABLE naval_vessels (id INT, country TEXT, vessel_type TEXT, in_service DATE); INSERT INTO naval_vessels (id, country, vessel_type, in_service) VALUES (1, 'Algeria', 'Frigate', '2016-05-12'), (2, 'Nigeria', 'Corvette', '2018-06-20'), (3, 'South Africa', 'Submarine', '2020-04-05');
What is the total number of naval vessels owned by African countries?
SELECT COUNT(*) FROM naval_vessels WHERE country IN (SELECT DISTINCT country FROM naval_vessels WHERE country LIKE 'Africa%');
gretelai_synthetic_text_to_sql
CREATE TABLE players (id INT, name VARCHAR(255), age INT, country VARCHAR(255)); CREATE TABLE players_to_delete (id INT); INSERT INTO players (id, name, age, country) VALUES (1, 'John Doe', 25, 'USA'), (2, 'Jane Doe', 30, 'Canada'); INSERT INTO players_to_delete (id) VALUES (1), (3);
Delete all player records from the 'Players to Delete' list.
DELETE FROM players WHERE id IN (SELECT id FROM players_to_delete);
gretelai_synthetic_text_to_sql
CREATE TABLE team_game_data (id INT, team VARCHAR(50), season INT, games INT); INSERT INTO team_game_data (id, team, season, games) VALUES (1, 'Celtics', 2022, 82), (2, 'Bruins', 2022, 82);
How many games did each team play in the last season?
SELECT team, SUM(games) as total_games FROM team_game_data WHERE season = 2022 GROUP BY team;
gretelai_synthetic_text_to_sql
CREATE TABLE production (id INT, country VARCHAR(255), element VARCHAR(255), quantity INT); INSERT INTO production (id, country, element, quantity) VALUES (1, 'China', 'Neodymium', 12000), (2, 'China', 'Dysprosium', 1000), (3, 'USA', 'Neodymium', 4000), (4, 'USA', 'Dysprosium', 800), (5, 'Australia', 'Neodymium', 3000)...
Find the element with the highest production quantity for each country.
SELECT country, element, quantity FROM (SELECT country, element, quantity, RANK() OVER (PARTITION BY country ORDER BY quantity DESC) as rnk FROM production) as ranked WHERE rnk = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists EvSpeed(state CHAR(2), avg_speed FLOAT); INSERT INTO EvSpeed(state, avg_speed) VALUES ('NY', 65.3), ('NY', 63.8), ('CA', 68.9), ('CA', 70.1);
What is the average speed of electric vehicles in New York and California?
SELECT AVG(avg_speed) FROM EvSpeed WHERE state IN ('NY', 'CA') GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_rates_population (country VARCHAR(255), year INT, plastic_rate FLOAT, metal_rate FLOAT); INSERT INTO recycling_rates_population (country, year, plastic_rate, metal_rate) VALUES ('India', 2020, 0.5, 0.4), ('China', 2020, 0.6, 0.5), ('Indonesia', 2020, 0.4, 0.3);
What is the recycling rate for plastic and metal combined in 2020 for countries with a population over 100 million?
SELECT r.country, (r.plastic_rate + r.metal_rate) as recycling_rate FROM recycling_rates_population r WHERE r.year = 2020 AND r.population > 100000000;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (sale_id INT, product_id INT, sale_date DATE, region VARCHAR(50), sale_price FLOAT); INSERT INTO sales VALUES (1, 1, '2022-01-05', 'Europe', 15.99), (2, 2, '2022-02-10', 'Asia', 19.99), (3, 1, '2022-03-20', 'Europe', 15.99), (4, 3, '2022-03-25', 'Europe', 12.99);
What is the total sales revenue for a given region in a given year?
SELECT SUM(sale_price) FROM sales WHERE sale_date BETWEEN '2022-01-01' AND '2022-12-31' AND region = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE Schools (name VARCHAR(50), state VARCHAR(20), rating INT); INSERT INTO Schools (name, state, rating) VALUES ('SchoolA', 'New Jersey', 8), ('SchoolB', 'New Jersey', 7), ('SchoolC', 'Georgia', 6);
Find the number of public schools in the state of New Jersey and Georgia, excluding any schools with a rating below 7.
SELECT COUNT(*) FROM Schools WHERE state IN ('New Jersey', 'Georgia') AND rating >= 7;
gretelai_synthetic_text_to_sql
CREATE TABLE incidents (id INT, date DATE, severity VARCHAR(10), attack_vector VARCHAR(20), country VARCHAR(20)); INSERT INTO incidents (id, date, severity, attack_vector, country) VALUES (1, '2021-01-01', 'medium', 'web', 'USA'); INSERT INTO incidents (id, date, severity, attack_vector, country) VALUES (2, '2021-01-02...
What is the total number of incidents and vulnerabilities, by attack vector and country?
SELECT 'incidents' as type, attack_vector, country, COUNT(*) as total FROM incidents GROUP BY attack_vector, country UNION ALL SELECT 'vulnerabilities' as type, system as attack_vector, country, COUNT(*) as total FROM vulnerabilities GROUP BY system, country;
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name VARCHAR(255)); INSERT INTO companies (id, name) VALUES (1, 'ACME Minerals'), (2, 'BIG Extraction'); CREATE TABLE production (id INT, company_id INT, extracted_minerals INT, extraction_hours DECIMAL(10,2)); INSERT INTO production (id, company_id, extracted_minerals, extraction_hours)...
What is the total labor productivity in terms of extracted minerals per hour for each company?
SELECT c.name, SUM(p.extracted_minerals) / SUM(p.extraction_hours) as labor_productivity FROM companies c INNER JOIN production p ON c.id = p.company_id GROUP BY c.name;
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (VolunteerID int, Name varchar(50)); INSERT INTO Volunteers (VolunteerID, Name) VALUES (1, 'John Doe'), (2, 'Jane Smith'), (3, 'Mike Johnson'); CREATE TABLE VolunteerPrograms (VolunteerID int, ProgramID int); INSERT INTO VolunteerPrograms (VolunteerID, ProgramID) VALUES (1, 1), (2, 1), (3, 2);
Which volunteers have not donated to a program?
SELECT V.Name FROM Volunteers V LEFT JOIN VolunteerPrograms VP ON V.VolunteerID = VP.VolunteerID WHERE VP.ProgramID IS NULL
gretelai_synthetic_text_to_sql
CREATE TABLE feed_inventory (feed_id INT PRIMARY KEY, feed_type VARCHAR(50), nutrients INT, quantity INT); INSERT INTO feed_inventory (feed_id, feed_type, nutrients, quantity) VALUES (1, 'Pellets', 350, 1000), (2, 'Flakes', 280, 750), (3, 'Gel', 400, 1200);
Show the total nutrient content for each feed type
SELECT feed_type, SUM(nutrients * quantity) as total_nutrients FROM feed_inventory GROUP BY feed_type;
gretelai_synthetic_text_to_sql
CREATE TABLE warehouse (id INT, location VARCHAR(255)); INSERT INTO warehouse (id, location) VALUES (1, 'Chicago'), (2, 'Houston'); CREATE TABLE packages (id INT, warehouse_id INT, weight FLOAT); INSERT INTO packages (id, warehouse_id, weight) VALUES (1, 1, 50.3), (2, 1, 30.1), (3, 2, 70.0), (4, 2, 10.0);
What is the average package weight shipped from each warehouse, excluding shipments under 20 kg?
SELECT warehouse_id, AVG(weight) as avg_weight FROM packages WHERE weight >= 20 GROUP BY warehouse_id;
gretelai_synthetic_text_to_sql
CREATE TABLE energy_storage (country VARCHAR(255), energy_type VARCHAR(255), project_count INT); INSERT INTO energy_storage (country, energy_type, project_count) VALUES ('South Korea', 'Batteries', 200), ('Brazil', 'Batteries', 350), ('South Korea', 'Pumped Hydro', 50), ('Brazil', 'Pumped Hydro', 600);
Find the number of energy storage projects in South Korea and Brazil for each energy type.
SELECT country, energy_type, SUM(project_count) FROM energy_storage WHERE country IN ('South Korea', 'Brazil') GROUP BY country, energy_type;
gretelai_synthetic_text_to_sql
CREATE TABLE routes (route_name VARCHAR(20), fare FLOAT); INSERT INTO routes (route_name, fare) VALUES ('Red Line', 2.50), ('Blue Line', 3.25), ('Green Line', 1.75);
What was the total fare collected from the 'Blue Line' on February 14, 2021?
SELECT SUM(fare) FROM routes WHERE route_name = 'Blue Line' AND fare_date = '2021-02-14';
gretelai_synthetic_text_to_sql
CREATE TABLE construction_labor (laborer_id INT, laborer_name VARCHAR(50), project_id INT, material VARCHAR(50), cost DECIMAL(10,2));
List the materials with the highest labor cost in the 'construction_labor' table.
SELECT material, MAX(cost) AS max_cost FROM construction_labor GROUP BY material ORDER BY max_cost DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE vendors(vendor_id INT, vendor_name TEXT, ethical_practices BOOLEAN); INSERT INTO vendors(vendor_id, vendor_name, ethical_practices) VALUES (1, 'VendorA', TRUE), (2, 'VendorB', FALSE), (3, 'VendorC', TRUE);
How many products have been sold by vendors with ethical labor practices?
SELECT COUNT(DISTINCT product_id) FROM transactions JOIN vendors ON transactions.vendor_id = vendors.vendor_id WHERE vendors.ethical_practices = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE Languages (language_id INT, language_name TEXT);CREATE TABLE ParityViolations (violation_id INT, violation_language INT);
What is the number of mental health parity violations per language?
SELECT l.language_name, COUNT(*) as num_violations FROM ParityViolations pv JOIN Languages l ON pv.violation_language = l.language_id GROUP BY l.language_name;
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_customers (customer_id INT, international_calls BOOLEAN, state VARCHAR(20), call_date DATE); INSERT INTO mobile_customers (customer_id, international_calls, state, call_date) VALUES (1, true, 'California', '2021-01-05'), (2, false, 'California', '2021-02-10'), (3, true, 'California', '2021-03-15');
What is the total number of mobile customers who have made international calls from the state of California in the first quarter of 2021?
SELECT COUNT(*) FROM mobile_customers WHERE international_calls = true AND state = 'California' AND call_date >= '2021-01-01' AND call_date <= '2021-03-31';
gretelai_synthetic_text_to_sql
CREATE TABLE LandfillCapacity (region VARCHAR(255), landfill_capacity FLOAT); INSERT INTO LandfillCapacity (region, landfill_capacity) VALUES ('North', 1000000), ('South', 800000), ('East', 1200000), ('West', 900000);
What is the maximum landfill capacity in cubic meters for each region?
SELECT region, MAX(landfill_capacity) FROM LandfillCapacity GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE therapy (therapy_id INT, patient_id INT, therapist_id INT, therapy_date DATE, city TEXT); INSERT INTO therapy (therapy_id, patient_id, therapist_id, therapy_date, city) VALUES (1, 1, 101, '2018-01-02', 'Sydney');
How many patients started therapy in Sydney each quarter of 2020?
SELECT DATE_TRUNC('quarter', therapy_date) as quarter, COUNT(DISTINCT patient_id) as num_patients FROM therapy WHERE city = 'Sydney' AND EXTRACT(YEAR FROM therapy_date) = 2020 GROUP BY quarter ORDER BY quarter;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, DonorName TEXT, Country TEXT); INSERT INTO Donors (DonorID, DonorName, Country) VALUES (1, 'John Doe', 'Canada'); INSERT INTO Donors (DonorID, DonorName, Country) VALUES (2, 'Jane Smith', 'USA'); CREATE TABLE Donations (DonationID INT, DonorID INT, DonationAmount DECIMAL, DonationDate ...
What is the total amount donated by individual donors from Canada in the year 2020?
SELECT SUM(Donations.DonationAmount) FROM Donors INNER JOIN Donations ON Donors.DonorID = Donations.DonorID WHERE Donors.Country = 'Canada' AND YEAR(Donations.DonationDate) = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE faculty (faculty_id INT, faculty_name VARCHAR(50), dept_name VARCHAR(50), salary INT, gender VARCHAR(10));
How many female and male faculty members are there in the College of Engineering, and what is their average salary?
SELECT dept_name, SUM(CASE WHEN gender = 'Female' THEN 1 ELSE 0 END) as num_female, SUM(CASE WHEN gender = 'Male' THEN 1 ELSE 0 END) as num_male, AVG(salary) as avg_salary FROM faculty WHERE dept_name = 'College of Engineering' GROUP BY dept_name;
gretelai_synthetic_text_to_sql
CREATE TABLE CUSTOMER_SIZE (customer_id INT PRIMARY KEY, customer_name VARCHAR(50), preferred_size VARCHAR(10), country VARCHAR(50)); INSERT INTO CUSTOMER_SIZE (customer_id, customer_name, preferred_size, country) VALUES (1, 'Alice', 'M', 'USA'), (2, 'Bob', 'L', 'USA'), (3, 'Carol', 'XL', 'Spain');
What is the preferred size of customers from Spain?
SELECT preferred_size FROM CUSTOMER_SIZE WHERE country = 'Spain';
gretelai_synthetic_text_to_sql
CREATE TABLE permit (id INT, city VARCHAR(20), project_type VARCHAR(20), cost INT); INSERT INTO permit (id, city, project_type, cost) VALUES (1, 'Austin', 'Residential', 5000); INSERT INTO permit (id, city, project_type, cost) VALUES (2, 'Austin', 'Commercial', 15000); INSERT INTO permit (id, city, project_type, cost) ...
What is the total cost of permits issued for residential projects in Austin?
SELECT SUM(cost) FROM permit WHERE city = 'Austin' AND project_type = 'Residential';
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (id INT, donor_name VARCHAR(255), donation_amount DECIMAL(10,2), donation_date DATE); INSERT INTO Donations (id, donor_name, donation_amount, donation_date) VALUES (1, 'Ivan Petrov', 20.00, '2021-07-22'), (2, 'Natalia Ivanova', 30.00, '2021-10-07');
What was the total donation amount by individuals in Russia in Q3 2021?
SELECT SUM(donation_amount) FROM Donations WHERE donor_name NOT LIKE '%org%' AND donation_date BETWEEN '2021-07-01' AND '2021-09-30';
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (id INT, donor_name VARCHAR(50), donation_amount INT, initiative_type VARCHAR(50)); INSERT INTO Donors (id, donor_name, donation_amount, initiative_type) VALUES (1, 'Donor1', 5000, 'education'), (2, 'Donor2', 10000, 'education'); CREATE TABLE Initiatives (initiative_id INT, initiative_type VARCHAR(5...
Who are the top 5 donors to education initiatives in Haiti, and how much have they donated in total?
SELECT Donors.donor_name, SUM(Donors.donation_amount) AS total_donated FROM Donors JOIN Initiatives ON Donors.initiative_type = Initiatives.initiative_type WHERE Initiatives.initiative_type = 'education' AND Donors.donor_name IN (SELECT Donors.donor_name FROM Donors WHERE Donors.initiative_type = 'education' GROUP BY D...
gretelai_synthetic_text_to_sql
CREATE TABLE adaptation_projects (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), budget FLOAT, start_date DATE, end_date DATE); INSERT INTO adaptation_projects (id, name, location, budget, start_date, end_date) VALUES (1, 'Seawall Construction', 'New York City, USA', 2000000, '2022-01-01', '2023-12-31'),...
List all adaptation projects that started after January 2023
SELECT * FROM adaptation_projects WHERE start_date > '2023-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE teachers (teacher_id INT, years_of_experience INT, professional_development_course_completion_date DATE); INSERT INTO teachers (teacher_id, years_of_experience, professional_development_course_completion_date) VALUES (1, 5, '2022-01-01'), (2, 10, '2021-12-15'), (3, 2, '2022-03-05');
What is the average number of professional development courses completed by teachers in the past year, broken down by their years of experience?
SELECT years_of_experience, AVG(COUNT(*)) as avg_courses FROM teachers WHERE professional_development_course_completion_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY years_of_experience;
gretelai_synthetic_text_to_sql
CREATE TABLE patients (id INT, name VARCHAR(50), age INT, gender VARCHAR(10), ethnicity VARCHAR(30), diagnosis VARCHAR(50), state VARCHAR(20), date DATE); INSERT INTO patients (id, name, age, gender, ethnicity, diagnosis, state, date) VALUES (1, 'Jessica', 34, 'Female', 'Hispanic', 'Tuberculosis', 'California', '2020-0...
What is the average age of female patients diagnosed with tuberculosis, grouped by ethnicity, in California during 2020?
SELECT AVG(age) as avg_age, ethnicity FROM patients WHERE diagnosis = 'Tuberculosis' AND gender = 'Female' AND state = 'California' AND YEAR(date) = 2020 GROUP BY ethnicity;
gretelai_synthetic_text_to_sql
CREATE TABLE MilitaryPatents (ID INT, Entity VARCHAR(50), Patent VARCHAR(50), Year INT); INSERT INTO MilitaryPatents (ID, Entity, Patent, Year) VALUES (1, 'Government Entity A', 'Patent1', 2020); INSERT INTO MilitaryPatents (ID, Entity, Patent, Year) VALUES (2, 'Government Entity B', 'Patent2', 2021);
What is the total number of military technology patents filed by 'Government Entity A' and 'Government Entity B'?
SELECT COUNT(*) FROM MilitaryPatents WHERE Entity IN ('Government Entity A', 'Government Entity B');
gretelai_synthetic_text_to_sql
CREATE TABLE programs (program_id INT, program_name VARCHAR(50), funds_raised DECIMAL(10,2), program_start_date DATE);
List the programs that had the highest and lowest impact in terms of funds raised in 2020?
SELECT program_name, funds_raised FROM programs WHERE program_start_date <= '2020-12-31' AND program_start_date >= '2020-01-01' ORDER BY funds_raised DESC LIMIT 1; SELECT program_name, funds_raised FROM programs WHERE program_start_date <= '2020-12-31' AND program_start_date >= '2020-01-01' ORDER BY funds_raised ASC ...
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_pricing.carbon_prices (country varchar(2), year int, price decimal(5,2)); INSERT INTO carbon_pricing.carbon_prices (country, year, price) VALUES ('FR', 2020, 30.5), ('FR', 2021, 32.0), ('DE', 2020, 28.0), ('DE', 2021, 30.2);
What is the carbon pricing for country 'FR' in the 'carbon_pricing' schema?
SELECT price FROM carbon_pricing.carbon_prices WHERE country = 'FR' AND year = (SELECT MAX(year) FROM carbon_pricing.carbon_prices);
gretelai_synthetic_text_to_sql
CREATE TABLE Doctors (ID INT, Name TEXT, Specialty TEXT); CREATE TABLE Nurses (ID INT, Name TEXT, Specialty TEXT); CREATE TABLE Patients (ID INT, Name TEXT, Condition TEXT);
Show the number of doctors, nurses, and patients in the rural healthcare system.
SELECT (SELECT COUNT(*) FROM Doctors) + (SELECT COUNT(*) FROM Nurses) + (SELECT COUNT(*) FROM Patients) AS Total;
gretelai_synthetic_text_to_sql
CREATE TABLE Policyholders (ID INT, Name VARCHAR(50), Age INT, Gender VARCHAR(10), City VARCHAR(50), State VARCHAR(20), ZipCode VARCHAR(10)); CREATE TABLE RiskModels (ID INT, PolicyholderID INT, ModelName VARCHAR(50), ModelScore DECIMAL(5,2));
Insert new records into the RiskModels table for policyholders with a low risk score.
INSERT INTO RiskModels (ID, PolicyholderID, ModelName, ModelScore) SELECT Policyholders.ID, Policyholders.ID AS PolicyholderID, 'Risk Model A' AS ModelName, 0.5 AS ModelScore FROM Policyholders WHERE Age < 30;
gretelai_synthetic_text_to_sql
CREATE TABLE education_resources (id INT, quantity INT, country TEXT, quarter INT, year INT); INSERT INTO education_resources (id, quantity, country, quarter, year) VALUES (1, 200, 'India', 2, 2022), (2, 300, 'India', 3, 2022), (3, 400, 'India', 4, 2022);
How many education resources were distributed in India in Q2 and Q3 2022?
SELECT SUM(quantity) FROM education_resources WHERE country = 'India' AND (quarter = 2 OR quarter = 3) AND year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE projects (project_id INT, project_name VARCHAR(100), state CHAR(2), planned_cost FLOAT, actual_cost FLOAT); INSERT INTO projects VALUES (1, 'TX Bullet Train', 'TX', 12000000000, 14000000000), (2, 'Dallas-Fort Worth Connector', 'TX', 800000000, 900000000), (3, 'Houston Ship Channel Expansion', 'TX', 1000000...
Which infrastructure projects in Texas have experienced cost overruns of over 20%?
SELECT * FROM projects WHERE state = 'TX' AND actual_cost > planned_cost * 1.2;
gretelai_synthetic_text_to_sql
CREATE TABLE ai_models (model_id INT, name VARCHAR(50), category VARCHAR(50), creation_date DATE); INSERT INTO ai_models (model_id, name, category, creation_date) VALUES (1, 'LIME', 'Explainable AI', '2019-06-15'); INSERT INTO ai_models (model_id, name, category, creation_date) VALUES (2, 'SHAP', 'Explainable AI', '201...
Get the names of all AI models that were created before 2020-01-01 and are part of the Explainable AI category.
SELECT name FROM ai_models WHERE creation_date < '2020-01-01' AND category = 'Explainable AI';
gretelai_synthetic_text_to_sql
CREATE TABLE production (prod_id INT, well_id INT, prod_date DATE, production_rate FLOAT); INSERT INTO production (prod_id, well_id, prod_date, production_rate) VALUES (1, 1, '2020-01-01', 1000), (2, 1, '2020-01-02', 1100), (3, 1, '2020-01-03', 1200), (4, 1, '2020-01-04', 1300), (5, 1, '2020-01-05', 1400);
What is the daily production trend for a specific well?
SELECT prod_date, production_rate, LAG(production_rate, 1) OVER (ORDER BY prod_date) AS previous_day_rate FROM production WHERE well_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE donations (donation_id INT, donation_date DATE, donation_amount FLOAT); INSERT INTO donations (donation_id, donation_date, donation_amount) VALUES (1, '2022-01-01', 50.00), (2, '2022-02-01', 100.00), (3, '2022-03-01', 150.00);
What is the total amount donated and number of donations for each quarter in the 'donations' table?
SELECT DATE_TRUNC('quarter', donation_date) as quarter, SUM(donation_amount) as total_donation, COUNT(donation_id) as num_donations FROM donations GROUP BY quarter ORDER BY quarter;
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name TEXT, industry TEXT, founders_gender TEXT, funding FLOAT);
What is the average funding received by companies founded by women in the renewable energy sector?
SELECT AVG(funding) FROM companies WHERE founders_gender = 'female' AND industry = 'renewable energy';
gretelai_synthetic_text_to_sql
CREATE TABLE AquacultureFarms (region VARCHAR(50), area_size INT); INSERT INTO AquacultureFarms (region, area_size) VALUES ('Africa', 10000), ('Asia', 15000), ('Europe', 12000), ('North America', 18000), ('South America', 14000);
What is the average area size of aquaculture farms in Africa?
SELECT AVG(area_size) as avg_area_size FROM AquacultureFarms WHERE region = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels (ID INT, Name VARCHAR(50), Type VARCHAR(50), Safety_Inspections INT, Engine_Capacity INT); INSERT INTO Vessels (ID, Name, Type, Safety_Inspections, Engine_Capacity) VALUES (1, 'MV Andromeda', 'Cargo Ship', 1, 3500), (2, 'MV Antares', 'Cargo Ship', 0, 6000);
List the vessel names, their types, and safety inspection status for all vessels with an engine capacity greater than 3000, ordered by safety inspection status and engine capacity in descending order?
SELECT Name, Type, Safety_Inspections, Engine_Capacity FROM Vessels WHERE Engine_Capacity > 3000 ORDER BY Safety_Inspections DESC, Engine_Capacity DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE housing (id INT, units INT, city VARCHAR(20), inclusive BOOLEAN); INSERT INTO housing (id, units, city, inclusive) VALUES (1, 50, 'Portland', TRUE), (2, 75, 'San Francisco', TRUE), (3, 100, 'NYC', FALSE);
What is the total number of inclusive housing units in Portland and San Francisco?
SELECT SUM(units) FROM housing WHERE inclusive = TRUE AND city IN ('Portland', 'San Francisco');
gretelai_synthetic_text_to_sql
CREATE TABLE permit_cost_comparison (cost_id INT, province VARCHAR(50), building_type VARCHAR(50), permit_cost FLOAT, structure_height INT, issue_date DATE); INSERT INTO permit_cost_comparison (cost_id, province, building_type, permit_cost, structure_height, issue_date) VALUES (7, 'British Columbia', 'High-rise', 10000...
What is the difference in average permit cost between high-rise and low-rise buildings in British Columbia in 2021?
SELECT AVG(permit_cost) - LAG(AVG(permit_cost)) OVER (PARTITION BY province ORDER BY EXTRACT(YEAR FROM issue_date)) FROM permit_cost_comparison WHERE province = 'British Columbia' AND building_type IN ('High-rise', 'Low-rise') AND issue_date BETWEEN '2021-01-01' AND '2021-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE green_buildings (id INT, country VARCHAR(50), offset INT); INSERT INTO green_buildings (id, country, offset) VALUES (1, 'CountryA', 50), (2, 'CountryB', 100), (3, 'CountryA', 75), (4, 'CountryA', 125), (5, 'CountryB', 150);
What is the maximum and minimum carbon offset per green building in each country?
SELECT g.country, MAX(g.offset) as max_offset, MIN(g.offset) as min_offset FROM green_buildings g GROUP BY g.country;
gretelai_synthetic_text_to_sql
CREATE TABLE projects (id INT, technology VARCHAR(20), energy_efficiency_rating INT); INSERT INTO projects (id, technology, energy_efficiency_rating) VALUES (1, 'wind', 80), (2, 'solar', 90), (3, 'wind', 75), (4, 'hydro', 95);
Find the maximum energy efficiency rating of projects in the 'solar' technology type.
SELECT MAX(energy_efficiency_rating) AS max_rating FROM projects WHERE technology = 'solar';
gretelai_synthetic_text_to_sql
CREATE TABLE Accommodations (Id INT, StudentId INT, AccommodationType VARCHAR(50), Description TEXT, DateProvided DATETIME); INSERT INTO Accommodations (Id, StudentId, AccommodationType, Description, DateProvided) VALUES (1, 1, 'Sign Language Interpreter', 'Interpreted lectures for a student with hearing impairment', '...
What is the name and description of the oldest accommodation provided?
SELECT AccommodationType, Description FROM Accommodations ORDER BY DateProvided ASC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE waste_generation (country VARCHAR(50), year INT, waste_generation_grams INT); INSERT INTO waste_generation (country, year, waste_generation_grams) VALUES ('India', 2021, 5000000), ('China', 2021, 4000000), ('Indonesia', 2021, 3000000), ('Vietnam', 2021, 2000000);
What is the total waste generation in grams for the bottom 3 countries in 2021, ordered by the least total amount?
SELECT country, SUM(waste_generation_grams) as total_waste_generation_2021 FROM waste_generation WHERE year = 2021 GROUP BY country ORDER BY total_waste_generation_2021 ASC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE tech_investments (id INT, network_tech VARCHAR(30)); INSERT INTO tech_investments (id, network_tech) VALUES (1, '5G');
How many network technologies has the company invested in?
SELECT COUNT(*) FROM tech_investments;
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (transaction_id INT, transaction_date DATE, transaction_category VARCHAR(255), transaction_value DECIMAL(10,2)); INSERT INTO transactions (transaction_id, transaction_date, transaction_category, transaction_value) VALUES (1, '2022-04-02', 'Food', 75.00), (2, '2022-04-05', 'Electronics', 350.00...
What is the total transaction value for each hour of the day for the month of April 2022?
SELECT HOUR(transaction_date) as hour_of_day, SUM(transaction_value) as total_value FROM transactions WHERE transaction_date BETWEEN '2022-04-01' AND '2022-04-30' GROUP BY hour_of_day;
gretelai_synthetic_text_to_sql
CREATE TABLE cybersecurity_strategies (id INT, strategy VARCHAR(50), department VARCHAR(50), budget INT, fiscal_year INT); INSERT INTO cybersecurity_strategies (id, strategy, department, budget, fiscal_year) VALUES (1, 'Endpoint Protection', 'IT', 500000, 2022), (2, 'Network Security', 'IT', 600000, 2022), (3, 'Inciden...
What are the top 2 cybersecurity strategies by budget allocated for the current fiscal year, and which departments have been assigned to implement them?
SELECT strategy, department, SUM(budget) as total_budget FROM cybersecurity_strategies WHERE fiscal_year = 2022 GROUP BY strategy, department HAVING COUNT(*) >= 2 ORDER BY total_budget DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE education_programs (program_name VARCHAR(255), country VARCHAR(255), habitat_type VARCHAR(255)); CREATE TABLE countries (country VARCHAR(255), region VARCHAR(255)); CREATE TABLE habitat_preservation (habitat_type VARCHAR(255), location VARCHAR(255));
Identify the top 3 countries with the most community education programs, based on the "education_programs", "countries", and "habitat_preservation" tables
SELECT e1.country, COUNT(e1.program_name) as num_programs FROM education_programs e1 INNER JOIN countries c1 ON e1.country = c1.country INNER JOIN habitat_preservation h1 ON e1.habitat_type = h1.habitat_type GROUP BY e1.country ORDER BY num_programs DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE products (id INT, company VARCHAR(255), price DECIMAL(5,2)); INSERT INTO products (id, company, price) VALUES (1, 'ABC', 50.99), (2, 'DEF', 35.49), (3, 'XYZ', 75.99), (4, 'ABC', 60.99);
What is the most expensive product from company 'XYZ'?
SELECT MAX(price) FROM products WHERE company = 'XYZ';
gretelai_synthetic_text_to_sql
CREATE TABLE broadband_subscribers(id INT, name VARCHAR(50), city VARCHAR(50)); CREATE TABLE broadband_usage(subscriber_id INT, usage FLOAT);
List the top 5 cities with the highest broadband subscription rates.
SELECT broadband_subscribers.city, COUNT(*) as num_subscribers, AVG(broadband_usage.usage) as avg_usage FROM broadband_subscribers JOIN broadband_usage ON broadband_subscribers.id = broadband_usage.subscriber_id GROUP BY broadband_subscribers.city ORDER BY num_subscribers DESC, avg_usage DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE CommunityProjects (id INT PRIMARY KEY, project_name VARCHAR(255), location VARCHAR(255), status VARCHAR(255));
Update the "CommunityProjects" table to reflect that the project status for the 'IrrigationInfrastructure' project changed to 'completed'
UPDATE CommunityProjects SET status = 'completed' WHERE project_name = 'IrrigationInfrastructure';
gretelai_synthetic_text_to_sql
CREATE TABLE rd_expenditure (drug_name TEXT, region TEXT, amount INTEGER);
What is the total R&D expenditure for drugs in 'Europe'?
SELECT SUM(amount) FROM rd_expenditure WHERE region = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE local_economy (city TEXT, year INT, quarter INT, impact INT); INSERT INTO local_economy (city, year, quarter, impact) VALUES ('Barcelona', 2022, 1, 5000), ('Barcelona', 2022, 2, 5500), ('Barcelona', 2022, 3, 6000), ('Barcelona', 2022, 4, 6500);
What is the local economic impact of tourism in Barcelona per quarter?
SELECT quarter, SUM(impact) FROM local_economy WHERE city = 'Barcelona' GROUP BY quarter;
gretelai_synthetic_text_to_sql
CREATE TABLE education (id INT, type VARCHAR(50), programs INT); INSERT INTO education (id, type, programs) VALUES (1, 'Forest', 5), (2, 'Savannah', 3), (3, 'Wetlands', 7);
How many community education programs are there for each habitat type?
SELECT type, SUM(programs) FROM education GROUP BY type;
gretelai_synthetic_text_to_sql
CREATE TABLE MarineLife (id INT, species VARCHAR(50), population INT, last_sighting DATE); INSERT INTO MarineLife (id, species, population, last_sighting) VALUES (1, 'Shark', 500, '2019-01-01'), (2, 'Starfish', 3000, '2020-05-15'), (3, 'Jellyfish', 1500, '2018-12-27'), (4, 'Lionfish', 800, '2020-07-08');
Delete the 'MarineLife' table records for species with a population less than 500
DELETE FROM MarineLife WHERE population < 500;
gretelai_synthetic_text_to_sql