context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE Peacekeeping_Operations (Operation_ID INT, Country_Name VARCHAR(50), Start_Date DATE, End_Date DATE); INSERT INTO Peacekeeping_Operations (Operation_ID, Country_Name, Start_Date, End_Date) VALUES (1, 'Bangladesh', '2005-01-01', '2007-12-31');
What is the maximum and minimum duration of peacekeeping operations?
SELECT MIN(DATEDIFF(End_Date, Start_Date)) as Min_Duration, MAX(DATEDIFF(End_Date, Start_Date)) as Max_Duration FROM Peacekeeping_Operations;
gretelai_synthetic_text_to_sql
CREATE TABLE ProtectedAreas (country VARCHAR(255), area INT); INSERT INTO ProtectedAreas (country, area) VALUES ('Canada', 1000000), ('US', 800000), ('Brazil', 1500000), ('Mexico', 500000);
What is the number of protected areas in each country?
SELECT country, COUNT(*) as num_protected_areas FROM ProtectedAreas GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE MilitarySatellites (Id INT, Country VARCHAR(50), SatelliteName VARCHAR(50), LaunchYear INT, Function VARCHAR(50));INSERT INTO MilitarySatellites (Id, Country, SatelliteName, LaunchYear, Function) VALUES (1, 'Australia', 'AustraliaSat-1', 2017, 'Communication');
What is the earliest launch year for military satellites in the Oceanic region?
SELECT MIN(LaunchYear) AS EarliestLaunchYear FROM MilitarySatellites WHERE Country = 'Australia';
gretelai_synthetic_text_to_sql
CREATE TABLE refugee_support (id INT, organization VARCHAR(50), sector VARCHAR(50)); INSERT INTO refugee_support (id, organization, sector) VALUES (1, 'UNHCR', 'Refugee Agency'), (2, 'WFP', 'Food Assistance');
Which organizations provided support in 'refugee_support' table, and what sectors did they support?
SELECT organization, sector FROM refugee_support;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists arts_culture; CREATE TABLE if not exists arts_culture.programs(program_id INT, program_name VARCHAR(50), demographic VARCHAR(10), category VARCHAR(20), impact_score INT);
What is the average program impact score for the 'Women' demographic in the 'Visual Arts' category?
SELECT AVG(programs.impact_score) FROM arts_culture.programs WHERE programs.demographic = 'Women' AND programs.category = 'Visual Arts';
gretelai_synthetic_text_to_sql
CREATE TABLE cultural_heritage (id INT, name VARCHAR(50), region VARCHAR(50), description VARCHAR(100));
Update the "description" to "Discover the ancient Mayan civilization" for all records in the "cultural_heritage" table where the "region" is "Central America"
UPDATE cultural_heritage SET description = 'Discover the ancient Mayan civilization' WHERE region = 'Central America';
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists cardano_assets (asset_id INT, asset_name VARCHAR(255), total_txn_volume DECIMAL(18,2)); INSERT INTO cardano_assets (asset_id, asset_name, total_txn_volume) VALUES (1, 'ADA', 150000000), (2, 'USDt', 120000000), (3, 'wADA', 90000000), (4, 'USDC', 80000000), (5, 'BSV', 70000000), (6, 'DOT', 6000...
What is the total transaction volume for each digital asset in the Cardano network?
SELECT asset_name, SUM(total_txn_volume) as total_volume FROM cardano_assets GROUP BY asset_name;
gretelai_synthetic_text_to_sql
CREATE TABLE volunteer_hours (volunteer_id INT, hours INT, volunteer_date DATE); INSERT INTO volunteer_hours (volunteer_id, hours, volunteer_date) VALUES (1, 5, '2021-10-10'), (2, 3, '2022-01-15');
Delete records of volunteers who have not volunteered in the last year?
DELETE FROM volunteers WHERE volunteer_id NOT IN (SELECT volunteer_id FROM volunteer_hours WHERE volunteer_date >= (CURRENT_DATE - INTERVAL '1 year'));
gretelai_synthetic_text_to_sql
CREATE TABLE developers (developer_id INT, name VARCHAR(50), country VARCHAR(50)); CREATE TABLE digital_assets (asset_id INT, name VARCHAR(50), developer_id INT, network VARCHAR(50)); INSERT INTO digital_assets (asset_id, name, developer_id, network) VALUES (1, 'Asset1', 1, 'Ethereum'), (2, 'BSCDApp', 2, 'Binance Smart...
Who are the developers that have created digital assets on the Binance Smart Chain?
SELECT developers.name FROM developers INNER JOIN digital_assets ON developers.developer_id = digital_assets.developer_id WHERE digital_assets.network = 'Binance Smart Chain';
gretelai_synthetic_text_to_sql
CREATE TABLE customers (id INT, name TEXT, region TEXT, savings REAL);
How many customers have a savings balance greater than $5000?
SELECT COUNT(*) FROM customers WHERE savings > 5000;
gretelai_synthetic_text_to_sql
CREATE TABLE HeritageSites (id INT, name VARCHAR(255), location VARCHAR(255), type VARCHAR(255), year_established INT, UNIQUE(id)); CREATE TABLE Events (id INT, name VARCHAR(255), date DATE, HeritageSite_id INT, PRIMARY KEY(id), FOREIGN KEY(HeritageSite_id) REFERENCES HeritageSites(id)); CREATE VIEW EventsPerSite AS SE...
What is the earliest event at each heritage site, grouped by site location?
SELECT EventsPerSite.heritage_site, MIN(EventsPerSite.min_date) as earliest_event FROM EventsPerSite;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists sales (sale_id serial PRIMARY KEY, sale_date date, title varchar(255), revenue decimal(10,2));
Insert a new record for the single 'Stairway to Heaven' with 500,000 sales in 2022-03-25
insert into sales (sale_date, title, revenue) values ('2022-03-25', 'Stairway to Heaven', 500000 * 0.01);
gretelai_synthetic_text_to_sql
CREATE TABLE defense_projects (id INT, year INT, region VARCHAR(20), project_name VARCHAR(30), completed BOOLEAN); INSERT INTO defense_projects (id, year, region, project_name, completed) VALUES (1, 2019, 'North America', 'Project A', true); INSERT INTO defense_projects (id, year, region, project_name, completed) VALUE...
How many defense projects were completed in the North American region in 2019?
SELECT COUNT(*) FROM defense_projects WHERE year = 2019 AND region = 'North America' AND completed = true;
gretelai_synthetic_text_to_sql
CREATE TABLE shipments (id INT, source_airport VARCHAR(5), destination_airport VARCHAR(5), shipped_date DATE); INSERT INTO shipments (id, source_airport, destination_airport, shipped_date) VALUES (1, 'SYD', 'DEL', '2022-04-02'), (2, 'SYD', 'DEL', '2022-04-10'), (3, 'PEK', 'DEL', '2022-04-15'), (4, 'NRT', 'DEL', '2022-0...
How many parcels were shipped to 'DEL' from each airport?
SELECT source_airport, COUNT(*) FROM shipments WHERE destination_airport = 'DEL' GROUP BY source_airport;
gretelai_synthetic_text_to_sql
CREATE TABLE projects (id INT, name VARCHAR(255), category VARCHAR(255), budget FLOAT, status VARCHAR(255)); INSERT INTO projects (id, name, category, budget, status) VALUES (6, 'Dam Rehabilitation', 'Water Supply', 3000000.00, 'Completed');
What is the maximum budget for all completed projects in the 'Water Supply' category?
SELECT MAX(budget) FROM projects WHERE category = 'Water Supply' AND status = 'Completed';
gretelai_synthetic_text_to_sql
CREATE TABLE freight_forwarders (id INT, name VARCHAR(255));CREATE TABLE shipments (id INT, forwarder_id INT, origin_country VARCHAR(255), destination_country VARCHAR(255));INSERT INTO freight_forwarders (id, name) VALUES (1, 'ABC Freight'), (2, 'XYZ Logistics');INSERT INTO shipments (id, forwarder_id, origin_country, ...
What are the names of all freight forwarders who have handled shipments from the United States to Canada?
SELECT f.name FROM freight_forwarders f INNER JOIN shipments s ON f.id = s.forwarder_id WHERE s.origin_country = 'USA' AND s.destination_country = 'Canada';
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'),...
Get total budget for projects in 'adaptation_projects' table
SELECT SUM(budget) FROM adaptation_projects;
gretelai_synthetic_text_to_sql
CREATE TABLE drugs (drug_id INT, drug_name TEXT, rd_expenditure INT, region TEXT); INSERT INTO drugs (drug_id, drug_name, rd_expenditure, region) VALUES (1, 'DrugA', 20000, 'Africa'), (2, 'DrugB', 30000, 'Europe');
What is the R&D expenditure for each drug in the 'drugs' table, grouped by drug name, including drugs with no expenditure in Africa?
SELECT d.drug_name, COALESCE(SUM(d.rd_expenditure), 0) AS total_expenditure FROM drugs d WHERE d.region = 'Africa' GROUP BY d.drug_name;
gretelai_synthetic_text_to_sql
CREATE TABLE Attendance (id INT, program_type VARCHAR(50), attendees INT); INSERT INTO Attendance (id, program_type, attendees) VALUES (1, 'Concert', 100), (2, 'Theater', 150), (3, 'Workshop', 50), (4, 'Concert', 120);
What is the total attendance by program type?
SELECT program_type, SUM(attendees) as total_attendance FROM Attendance GROUP BY program_type;
gretelai_synthetic_text_to_sql
CREATE TABLE MarinePollution (Id INT, Region VARCHAR(20), Type VARCHAR(10));
Insert a new record into the "MarinePollution" table with values (1, 'Asia', 'Oil Spill')
INSERT INTO MarinePollution (Id, Region, Type) VALUES (1, 'Asia', 'Oil Spill');
gretelai_synthetic_text_to_sql
CREATE TABLE workforce (id INT, name VARCHAR(50), position VARCHAR(50), age INT); INSERT INTO workforce (id, name, position, age) VALUES (1, 'John Doe', 'Mining Engineer', 35), (2, 'Jane Smith', 'Geologist', 32), (3, 'Alice Johnson', 'Mining Engineer', 38);
What is the average age of mining engineers and geologists in the workforce?
SELECT AVG(age) AS avg_age FROM workforce WHERE position IN ('Mining Engineer', 'Geologist');
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, investments_amount INT, registration_date DATE);
What is the total amount of Shariah-compliant investments made by customers in the year 2020?
SELECT SUM(investments_amount) FROM customers WHERE EXTRACT(YEAR FROM registration_date) = 2020 AND investments_amount >= 0;
gretelai_synthetic_text_to_sql
CREATE TABLE restaurants (restaurant_id INT, name VARCHAR(255), city VARCHAR(255), food_safety_score INT); INSERT INTO restaurants (restaurant_id, name, city, food_safety_score) VALUES (1, 'Restaurant A', 'City A', 95), (2, 'Restaurant B', 'City A', 85), (3, 'Restaurant C', 'City B', 98), (4, 'Restaurant D', 'City B', ...
What is the percentage of restaurants with a food safety score above 90 in each city?
SELECT city, AVG(CASE WHEN food_safety_score > 90 THEN 1 ELSE 0 END) * 100 as passing_percentage FROM restaurants GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE china_shipments (id INT, freight_cost DECIMAL(10,2), shipment_date DATE); INSERT INTO china_shipments (id, freight_cost, shipment_date) VALUES (1, 2500.00, '2021-05-01'); INSERT INTO china_shipments (id, freight_cost, shipment_date) VALUES (2, 3000.00, '2021-05-10');
What was the maximum freight cost for a single shipment to China in May 2021?
SELECT MAX(freight_cost) FROM china_shipments WHERE shipment_date >= '2021-05-01' AND shipment_date < '2021-06-01' AND country = 'China';
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, DonorName VARCHAR(50)); INSERT INTO Donors (DonorID, DonorName) VALUES (1001, 'John Doe'), (1002, 'Jane Doe'), (2001, 'Mike Johnson'), (3001, 'Emma Smith'); CREATE TABLE Donations (DonationID INT, DonorID INT, DonationAmount DECIMAL(10,2)); INSERT INTO Donations (DonationID, DonorID, D...
What's the average donation amount for donors who made more than one donation?
SELECT AVG(d.DonationAmount) AS AverageDonationAmount FROM (SELECT DonorID, COUNT(*) AS DonationCount FROM Donations GROUP BY DonorID) dc JOIN Donations d ON dc.DonorID = d.DonorID WHERE dc.DonationCount > 1;
gretelai_synthetic_text_to_sql
CREATE TABLE nhl_players (player VARCHAR(50), age INT); INSERT INTO nhl_players (player, age) VALUES ('Alex Ovechkin', 37), ('Sidney Crosby', 34), ('Connor McDavid', 25);
What is the average age of NHL players in the 2021-2022 season?
SELECT AVG(age) AS avg_age FROM nhl_players;
gretelai_synthetic_text_to_sql
CREATE TABLE SchoolTypes (id INT, name VARCHAR(20)); INSERT INTO SchoolTypes (id, name) VALUES (1, 'Public'), (2, 'Private'), (3, 'Charter'); CREATE TABLE StudentEnrollment (student_id INT, school_type_id INT); INSERT INTO StudentEnrollment (student_id, school_type_id) VALUES (1, 1), (2, 1), (3, 2), (4, 3), (5, 3);
What is the number of students who have ever enrolled in lifelong learning programs in 'Charter' school type?
SELECT s.name, COUNT(DISTINCT se.student_id) FROM SchoolTypes s JOIN StudentEnrollment se ON s.id = se.school_type_id WHERE s.name = 'Charter' GROUP BY s.name;
gretelai_synthetic_text_to_sql
CREATE TABLE ethereum_smart_contracts (id INT, gas_fees DECIMAL(10, 2), nft_involvement BOOLEAN); INSERT INTO ethereum_smart_contracts (id, gas_fees, nft_involvement) VALUES (1, 50, TRUE);
What are the average gas fees for Ethereum smart contracts involved in NFTs?
SELECT AVG(gas_fees) FROM ethereum_smart_contracts WHERE nft_involvement = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE labor_practices (id INT PRIMARY KEY, company VARCHAR(255), compliance_score INT); INSERT INTO labor_practices (id, company, compliance_score) VALUES (1, 'Green Manufacturing', 8), (2, 'Ethical Apparel', 9), (3, 'Sustainable Fabrics', 7), (4, 'Green Manufacturing', 6);
Delete records in the labor_practices table where the company is 'Green Manufacturing' and compliance_score is less than 7
DELETE FROM labor_practices WHERE company = 'Green Manufacturing' AND compliance_score < 7;
gretelai_synthetic_text_to_sql
CREATE TABLE crop_data (crop_type VARCHAR(20), area FLOAT, region VARCHAR(20)); INSERT INTO crop_data (crop_type, area, region) VALUES ('Rice', 150.0, 'Northeast India');
Calculate the total area (in hectares) under cultivation for each crop type in 'Northeast' India.
SELECT crop_type, SUM(area) / 10000 as total_area_ha FROM crop_data WHERE region = 'Northeast India' GROUP BY crop_type
gretelai_synthetic_text_to_sql
CREATE TABLE community_dev (id INT, initiative_name VARCHAR(255), start_date DATE); INSERT INTO community_dev (id, initiative_name, start_date) VALUES (1, 'Education Program', '2020-01-01'), (2, 'Health Care Center', '2019-07-01');
What are the names of community development initiatives that started in 2019?
SELECT initiative_name FROM community_dev WHERE start_date LIKE '2019-%';
gretelai_synthetic_text_to_sql
CREATE TABLE IntelligenceOperations (region TEXT, year INTEGER, num_operations INTEGER); INSERT INTO IntelligenceOperations (region, year, num_operations) VALUES ('Asia-Pacific', 2021, 15), ('Europe', 2021, 10), ('Asia-Pacific', 2020, 12), ('Europe', 2020, 14);
What is the maximum number of intelligence operations conducted in a single region last year?
SELECT MAX(num_operations) FROM IntelligenceOperations WHERE year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE Exhibition_Attendance (exhibition_id INT, visit_date DATE, visitor_count INT); CREATE TABLE Exhibitions (id INT, name VARCHAR(50)); INSERT INTO Exhibitions (id, name) VALUES (1, 'Impressionist'); ALTER TABLE Exhibition_Attendance ADD FOREIGN KEY (exhibition_id) REFERENCES Exhibitions(id);
What is the maximum number of visitors in a single day for the 'Impressionist' exhibition?
SELECT MAX(visitor_count) FROM Exhibition_Attendance WHERE exhibition_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE clients (id INT, name TEXT, age INT, state TEXT, transaction_amount DECIMAL(10,2)); INSERT INTO clients (id, name, age, state, transaction_amount) VALUES (1, 'Maria Garcia', 45, 'California', 500.00); INSERT INTO clients (id, name, age, state, transaction_amount) VALUES (2, 'Roberto Rodriguez', 50, 'Califo...
What is the average transaction amount for clients in California?
SELECT AVG(transaction_amount) FROM clients WHERE state = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE articles (title VARCHAR(255));
What is the maximum number of words in an article title in the 'articles' table?
SELECT MAX(LENGTH(title) - LENGTH(REPLACE(title, ' ', '')) + 1) AS max_words FROM articles;
gretelai_synthetic_text_to_sql
CREATE TABLE landfills (country VARCHAR(50), capacity INT, year INT); INSERT INTO landfills (country, capacity, year) VALUES ('Mexico', 15000, 2022), ('Canada', 13000, 2022), ('USA', 11000, 2022);
How many landfills are there in North America with a capacity greater than 10000 tons as of 2022?'
SELECT COUNT(*) as num_landfills FROM landfills WHERE capacity > 10000 AND year = 2022 AND country IN ('Mexico', 'Canada', 'USA');
gretelai_synthetic_text_to_sql
CREATE TABLE climate_adaptation (project_name VARCHAR(255), location VARCHAR(255), year INT, type VARCHAR(255)); INSERT INTO climate_adaptation (project_name, location, year, type) VALUES ('GreenTech Education', 'Nepal', 2015, 'Adaptation'), ('Solar for Agriculture', 'Bangladesh', 2016, 'Adaptation'), ('Climate Resilie...
How many climate adaptation projects were implemented in Asia between 2015 and 2018?
SELECT COUNT(*) FROM climate_adaptation WHERE location LIKE 'Asia%' AND year BETWEEN 2015 AND 2018 AND type = 'Adaptation';
gretelai_synthetic_text_to_sql
CREATE TABLE Hotels (id INT, country VARCHAR(50), rating INT); INSERT INTO Hotels (id, country, rating) VALUES (1, 'France', 4), (2, 'France', 5), (3, 'France', 3), (4, 'France', 4), (5, 'France', 5);
What is the average hotel rating in France?
SELECT AVG(h.rating) as avg_rating FROM Hotels h WHERE h.country = 'France';
gretelai_synthetic_text_to_sql
CREATE TABLE revenue (restaurant_id INT, revenue INT, score INT, area VARCHAR(255));INSERT INTO revenue (restaurant_id, revenue, score, area) VALUES (1, 5000, 95, 'urban'), (2, 4000, 85, 'urban'), (3, 8000, 90, 'suburban'), (4, 3000, 80, 'rural'), (5, 6000, 92, 'urban');
Calculate the total revenue for restaurants in the "suburban" area with a food safety score above 90.
SELECT SUM(revenue.revenue) FROM revenue WHERE revenue.area = 'suburban' AND revenue.score > 90;
gretelai_synthetic_text_to_sql
CREATE TABLE rural_health_facilities (id INT, name TEXT, facility_type TEXT, num_workers INT); INSERT INTO rural_health_facilities (id, name, facility_type, num_workers) VALUES (1, 'Rural Clinic A', 'clinic', 10), (2, 'Rural Clinic B', 'clinic', 15), (3, 'Rural Hospital A', 'hospital', 60), (4, 'Rural Hospital B', 'hos...
How many healthcare workers are there in total in the rural health clinics and hospitals?
SELECT SUM(num_workers) FROM rural_health_facilities WHERE facility_type IN ('clinic', 'hospital');
gretelai_synthetic_text_to_sql
CREATE TABLE Equipment_Types (equipment_id INT, equipment_type VARCHAR(50), equipment_region VARCHAR(50), sale_value FLOAT);
What is the percentage of military equipment sales by type, in the European Union?
SELECT equipment_type, equipment_region, SUM(sale_value) as total_sales, 100.0 * SUM(sale_value) / (SELECT SUM(sale_value) FROM Equipment_Types WHERE equipment_region = 'European Union') as sales_percentage FROM Equipment_Types WHERE equipment_region = 'European Union' GROUP BY equipment_type, equipment_region;
gretelai_synthetic_text_to_sql
CREATE TABLE hotel_revenue (id INT, hotel_id INT, region TEXT, year INT, revenue FLOAT);
What is the total revenue generated by hotels in the 'EMEA' region for the year 2022?
SELECT region, SUM(revenue) FROM hotel_revenue WHERE region = 'EMEA' AND YEAR(calendar) = 2022 GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (hotel_id INT, hotel_name TEXT, country TEXT, virtual_tour BOOLEAN); INSERT INTO hotels (hotel_id, hotel_name, country, virtual_tour) VALUES (1, 'The Nile River', 'Egypt', true), (2, 'The Sahara Desert', 'Tunisia', false), (3, 'The African Safari', 'South Africa', true);
What is the total number of hotels in Africa that have adopted virtual tour technology?
SELECT COUNT(*) FROM hotels WHERE virtual_tour = true AND country = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE Cities (id INT, name VARCHAR(255), population INT); INSERT INTO Cities (id, name, population) VALUES (1, 'San Francisco', 884000); INSERT INTO Cities (id, name, population) VALUES (2, 'New York', 8500000); CREATE TABLE EV_Sales (id INT, city_id INT, year INT, sales INT); INSERT INTO EV_Sales (id, city_id, ...
What is the total number of electric vehicles sold in cities with a population greater than 5 million?
SELECT SUM(EV_Sales.sales) FROM EV_Sales JOIN Cities ON EV_Sales.city_id = Cities.id WHERE Cities.population > 5000000;
gretelai_synthetic_text_to_sql
CREATE TABLE districts (id INT, district_name TEXT, num_students INT, avg_mental_health_score FLOAT); INSERT INTO districts (id, district_name, num_students, avg_mental_health_score) VALUES (1, 'Downtown', 600, 75.3), (2, 'Uptown', 400, 78.1), (3, 'Midtown', 700, 72.5);
What is the average mental health score of students in each district with more than 500 students?
SELECT district_name, AVG(avg_mental_health_score) as avg_score FROM districts GROUP BY district_name HAVING num_students > 500;
gretelai_synthetic_text_to_sql
CREATE TABLE Program (id INT, name VARCHAR(50), budget DECIMAL(10,2)); INSERT INTO Program (id, name, budget) VALUES (1, 'Arts', 125000.00), (2, 'Education', 550000.00), (3, 'Environment', 375000.00);
What is the total budget for programs in the 'Environment' category?
SELECT SUM(budget) FROM Program WHERE name = 'Environment';
gretelai_synthetic_text_to_sql
CREATE TABLE diabetes_cases (id INT, area VARCHAR(10), cases INT); INSERT INTO diabetes_cases (id, area, cases) VALUES (1, 'Area 1', 50), (2, 'Area 2', 30), (3, 'Area 3', 70), (4, 'Area 4', 40), (5, 'Area 5', 60);
Identify the top 3 rural areas with the highest number of diabetes cases.
SELECT area, cases FROM diabetes_cases WHERE area = 'Rural' ORDER BY cases DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE energy_sources (country VARCHAR(255), source_type VARCHAR(255), capacity INT); INSERT INTO energy_sources (country, source_type, capacity) VALUES ('Germany', 'Solar', 53000), ('Spain', 'Solar', 9500), ('USA', 'Solar', 97000);
Which country has the highest solar energy capacity?
SELECT country, MAX(capacity) FROM energy_sources WHERE source_type = 'Solar' GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE Concerts (ConcertID INT, ConcertName VARCHAR(100), ArtistID INT, Genre VARCHAR(50), Year INT, Revenue INT); INSERT INTO Concerts VALUES (1, 'Concert1', 1, 'Rock', 2020, 10000); INSERT INTO Concerts VALUES (2, 'Concert2', 2, 'Pop', 2021, 15000); INSERT INTO Concerts VALUES (3, 'Concert3', 3, 'Jazz', 2019, 1...
What is the total revenue from concert ticket sales for artists from a specific genre?
SELECT Genre, SUM(Revenue) FROM Concerts WHERE Genre = 'Rock' GROUP BY Genre;
gretelai_synthetic_text_to_sql
CREATE TABLE violations (id INT, law_code TEXT, description TEXT, violation_date DATE); INSERT INTO violations (id, law_code, description, violation_date) VALUES (1, 'LAW123', 'Speeding', '2021-07-01'), (2, 'LAW456', 'Illegal fishing', '2021-08-15');
Which maritime law violations occurred in the last 6 months, ordered by date?
SELECT * FROM violations WHERE violation_date >= DATE(NOW()) - INTERVAL 6 MONTH ORDER BY violation_date;
gretelai_synthetic_text_to_sql
CREATE TABLE Warehouse (id INT PRIMARY KEY, product VARCHAR(255), quantity INT); INSERT INTO Warehouse (id, product, quantity) VALUES (1, 'Quinoa', 100), (2, 'Rice', 75), (3, 'Quinoa', 125);
Find the maximum quantity of 'Quinoa' in the 'Warehouse' table
SELECT MAX(quantity) FROM Warehouse WHERE product = 'Quinoa';
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists biotech;USE biotech;CREATE TABLE if not exists startups (name VARCHAR(255), country VARCHAR(255), funding FLOAT);INSERT INTO startups (name, country, funding) VALUES ('Startup1', 'India', 5000000), ('Startup2', 'USA', 8000000), ('Startup3', 'India', 3000000), ('Startup4', 'USA', 6000000);
What is the average funding received by biotech startups in India and USA?
SELECT AVG(funding) FROM startups WHERE country IN ('India', 'USA');
gretelai_synthetic_text_to_sql
CREATE TABLE Inventory (id INT, item VARCHAR(255), quantity INT, warehouse VARCHAR(255)); INSERT INTO Inventory (id, item, quantity, warehouse) VALUES (1, 'apples', 100, 'Seattle'), (2, 'bananas', 200, 'Miami');
Calculate the total quantity of items in inventory for each warehouse, sorted by warehouse name.
SELECT warehouse, SUM(quantity) as total_quantity FROM Inventory GROUP BY warehouse ORDER BY warehouse;
gretelai_synthetic_text_to_sql
CREATE TABLE garment_manufacturing (garment_id INT, garment_type VARCHAR(50), production_date DATE, units_manufactured INT); CREATE TABLE garments (garment_id INT, garment_name VARCHAR(50));
What is the number of units manufactured for each garment type by month in 2021?
SELECT garment_type, EXTRACT(MONTH FROM production_date) AS month, SUM(units_manufactured) FROM garment_manufacturing JOIN garments ON garment_manufacturing.garment_id = garments.garment_id WHERE EXTRACT(YEAR FROM production_date) = 2021 GROUP BY garment_type, month;
gretelai_synthetic_text_to_sql
CREATE TABLE oceanography (id INT PRIMARY KEY, name VARCHAR(255), average_depth FLOAT, area FLOAT, volume FLOAT);
Update the average depth of the 'Arctic Ocean' in the 'oceanography' table
WITH updated_arctic AS (UPDATE oceanography SET average_depth = 1205 WHERE name = 'Arctic Ocean') SELECT * FROM updated_arctic;
gretelai_synthetic_text_to_sql
CREATE TABLE donor_causes (donor_id INT, cause_category VARCHAR(255)); INSERT INTO donor_causes (donor_id, cause_category) VALUES (1, 'Education'), (2, 'Health'), (3, 'Environment'), (1, 'Health'), (4, 'Education');
What is the percentage of donors who have donated to each cause category?
SELECT cause_category, COUNT(donor_id) * 100.0 / (SELECT COUNT(DISTINCT donor_id) FROM donor_causes) AS donor_percentage FROM donor_causes GROUP BY cause_category;
gretelai_synthetic_text_to_sql
CREATE TABLE Production (ProductionID INT PRIMARY KEY, EquipmentID INT, ResourceType VARCHAR(50), Quantity INT, ProductionDate DATE); INSERT INTO Production (ProductionID, EquipmentID, ResourceType, Quantity, ProductionDate) VALUES (1, 1, 'Gold', 500, '2021-01-01'), (2, 2, 'Gold', 750, '2021-05-10'), (3, 3, 'Iron', 120...
What is the total quantity of gold produced by the company in 2021?
SELECT SUM(Quantity) FROM Production WHERE ResourceType = 'Gold' AND YEAR(ProductionDate) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE concerts (concert_id INT, artist_id INT, genre VARCHAR(50), country VARCHAR(50), timestamp TIMESTAMP); INSERT INTO concerts (concert_id, artist_id, genre, country, timestamp) VALUES (1, 2001, 'Hip Hop', 'Japan', '2022-01-01 00:00:00'), (2, 2002, 'Hip Hop', 'China', '2022-01-02 12:30:00'); CREATE TABLE arti...
What is the total number of concerts for the Hip Hop genre in Asia in the last 2 years?
SELECT COUNT(*) FROM concerts JOIN artists ON concerts.artist_id = artists.artist_id WHERE artists.genre = 'Hip Hop' AND concerts.country IN ('Japan', 'China', 'India', 'South Korea', 'Indonesia') AND concerts.timestamp >= '2020-01-01' AND concerts.timestamp < '2022-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE AIModels (model_id INT, model_name VARCHAR(50), explainability_score DECIMAL(3,2)); INSERT INTO AIModels (model_id, model_name, explainability_score) VALUES (1, 'ModelA', 82.00), (2, 'ModelB', 88.50), (3, 'ModelC', 76.75), (4, 'ModelD', 91.00), (5, 'ModelE', 87.00);
List AI models with explainability scores above 85.
SELECT model_name FROM AIModels WHERE explainability_score > 85;
gretelai_synthetic_text_to_sql
CREATE TABLE SeaSurfaceTemperature (location varchar(50), date DATE, temperature float);
What is the average sea surface temperature in the Arctic Ocean by month?
SELECT MONTH(date) AS month, AVG(temperature) AS avg_temperature FROM SeaSurfaceTemperature WHERE location = 'Arctic Ocean' GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE Waste_Management (project_id INT, project_name VARCHAR(50), location VARCHAR(50)); INSERT INTO Waste_Management (project_id, project_name, location) VALUES (1, 'Landfill Expansion', 'Rural Area'), (2, 'Recycling Center Construction', 'Industrial Area'), (3, 'Composting Facility', 'Suburbs'), (4, 'Hazardous...
List all unique locations from the 'Waste_Management' table.
SELECT DISTINCT location FROM Waste_Management;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists genetics;CREATE TABLE genetics.project_timeline (id INT, project_name VARCHAR(50), start_date DATE, end_date DATE);INSERT INTO genetics.project_timeline (id, project_name, start_date, end_date) VALUES (1, 'ProjectX', '2020-01-01', '2021-12-31'), (2, 'ProjectY', '2022-01-01', '2023-12-31'), (...
How many genetic research projects were completed in 2021?
SELECT COUNT(*) FROM genetics.project_timeline WHERE YEAR(start_date) = 2021 AND YEAR(end_date) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE Members (MemberID INT, Age INT, Gender VARCHAR(10)); INSERT INTO Members (MemberID, Age, Gender) VALUES (7, 55, 'Female'); CREATE TABLE Workouts (WorkoutID INT, WorkoutType VARCHAR(20), Duration INT, MemberID INT); INSERT INTO Workouts (WorkoutID, WorkoutType, Duration, MemberID) VALUES (70, 'Zumba', 45, 7...
List all the distinct workouts and their average duration for members aged 50 or older, grouped by the workout type and gender.
SELECT Workouts.WorkoutType, Members.Gender, AVG(Workouts.Duration) FROM Members INNER JOIN Workouts ON Members.MemberID = Workouts.MemberID WHERE Members.Age >= 50 GROUP BY Workouts.WorkoutType, Members.Gender;
gretelai_synthetic_text_to_sql
CREATE TABLE state (id INT PRIMARY KEY, name VARCHAR(50));CREATE TABLE energy_storage (id INT PRIMARY KEY, name VARCHAR(50), state_id INT, FOREIGN KEY (state_id) REFERENCES state(id));CREATE TABLE battery_storage (id INT PRIMARY KEY, date DATE, energy_stored DECIMAL(10,2));
What is the total energy stored in batteries in California for the month of May 2021?
SELECT s.name AS state_name, es.name AS energy_storage_name, SUM(bs.energy_stored) AS total_energy_stored FROM battery_storage bs JOIN energy_storage es ON bs.energy_storage_id = es.id JOIN state s ON es.state_id = s.id WHERE s.name = 'California' AND bs.date BETWEEN '2021-05-01' AND '2021-05-31' GROUP BY s.name, es...
gretelai_synthetic_text_to_sql
CREATE TABLE HeritageSites (id INT, name VARCHAR(255), num_art_forms INT, UNIQUE(id)); CREATE TABLE ArtFormsPracticed (id INT, heritage_site_id INT, form_id INT, UNIQUE(id)); CREATE TABLE ArtForms (id INT, name VARCHAR(255), UNIQUE(id));
What is the maximum and minimum number of art forms practiced at each heritage site, and the average number?
SELECT HeritageSites.name, MAX(ArtFormsPracticed.num_art_forms) as max_art_forms, MIN(ArtFormsPracticed.num_art_forms) as min_art_forms, AVG(ArtFormsPracticed.num_art_forms) as avg_art_forms FROM HeritageSites INNER JOIN (SELECT heritage_site_id, COUNT(DISTINCT form_id) as num_art_forms FROM ArtFormsPracticed GROUP BY ...
gretelai_synthetic_text_to_sql
CREATE TABLE decathlon_results (athlete_id INT, athlete_name VARCHAR(50), distance_covered INT); INSERT INTO decathlon_results (athlete_id, athlete_name, distance_covered) VALUES (1, 'Kevin Mayer', 8750), (2, 'Damian Warner', 8800), (3, 'Ashley Moloney', 8600), (4, 'Garrett Scantling', 8400), (5, 'Pierce Lepage', 8500)...
What is the average distance covered by each athlete in the 2022 decathlon event?
SELECT athlete_name, AVG(distance_covered) as avg_distance_covered FROM decathlon_results GROUP BY athlete_name;
gretelai_synthetic_text_to_sql
CREATE TABLE Fabrics_History (id INT PRIMARY KEY, type VARCHAR(20), year INT, quantity INT); INSERT INTO Fabrics_History (id, type, year, quantity) VALUES (1, 'Organic_Cotton', 2021, 6000), (2, 'Recycled_Polyester', 2020, 7000), (3, 'Organic_Cotton', 2020, 4000);
Show the total quantity of sustainable fabric types used in the last two years.
SELECT SUM(quantity) FROM Fabrics_History WHERE type IN ('Organic_Cotton', 'Recycled_Polyester') AND year BETWEEN 2020 AND 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE cybersecurity_incidents (id INT, incident_type VARCHAR(255), year INT, affected_systems VARCHAR(255), region VARCHAR(255)); INSERT INTO cybersecurity_incidents (id, incident_type, year, affected_systems, region) VALUES (1, 'Data Breach', 2020, 'Web Servers', 'Asia'), (2, 'Phishing', 2019, 'Email Accounts',...
What is the most common type of cybersecurity incident in each region in the year 2020?
SELECT region, MAX(incident_type) as most_common_incident FROM cybersecurity_incidents WHERE year = 2020 GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name TEXT, rating FLOAT, product_category TEXT); INSERT INTO products (product_id, product_name, rating, product_category) VALUES (1, 'Product A', 4.5, 'Category 1'), (2, 'Product B', 4.2, 'Category 2'), (3, 'Product C', 4.8, 'Category 1'), (4, 'Product D', 4.6, 'Category ...
Find the product name and rating for the product with the highest rating in each product category.
SELECT product_name, rating FROM (SELECT product_name, rating, product_category, DENSE_RANK() OVER (PARTITION BY product_category ORDER BY rating DESC) as rnk FROM products) t WHERE rnk = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Designers (DesignerID INT, DesignerName VARCHAR(50), VR_Designer BOOLEAN);CREATE TABLE Games (GameID INT, GameName VARCHAR(50), DesignerID INT, GameGenre VARCHAR(20));
Identify virtual reality (VR) game designers who have designed games for more than one genre.
SELECT d.DesignerName FROM Designers d INNER JOIN Games g1 ON d.DesignerID = g1.DesignerID INNER JOIN Games g2 ON d.DesignerID = g2.DesignerID AND g1.GameGenre != g2.GameGenre WHERE d.VR_Designer = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE workout_sessions (id INT, user_id INT, session_date DATE, workout_type VARCHAR(20));
Top 3 most popular workout types by gender.
SELECT s.gender, w.workout_type, COUNT(*) as session_count FROM workout_sessions s JOIN user_profile u ON s.user_id = u.user_id GROUP BY s.workout_type, s.gender ORDER BY session_count DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE donors (donor_id INT, donor_name TEXT, total_donations DECIMAL(10, 2));
What is the total amount donated by each donor in the 'donors' table, ordered by the total amount donated in descending order?
SELECT donor_name, SUM(total_donations) as total_donated FROM donors GROUP BY donor_name ORDER BY total_donated DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE multimodal_trips (trip_id INT, trip_duration INT, start_time TIMESTAMP, end_time TIMESTAMP, start_station TEXT, end_station TEXT, city TEXT, mode TEXT, electric BOOLEAN);
What is the total number of multimodal trips taken in Los Angeles, California using electric vehicles?
SELECT COUNT(*) FROM multimodal_trips WHERE city = 'Los Angeles' AND electric = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE judges (id INT, name TEXT, state TEXT); INSERT INTO judges (id, name, state) VALUES (1, 'Judge A', 'California'), (2, 'Judge B', 'California'), (3, 'Judge C', 'California'); CREATE TABLE cases (id INT, judge_id INT, year INT, case_type TEXT); INSERT INTO cases (id, judge_id, year, case_type) VALUES (1, 1, ...
What is the total number of criminal cases heard by each judge in the state of California in 2021?
SELECT j.name, COUNT(*) as cases_heard FROM cases JOIN judges j ON cases.judge_id = j.id WHERE cases.year = 2021 AND cases.case_type = 'Criminal' GROUP BY j.name;
gretelai_synthetic_text_to_sql
CREATE TABLE projects (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), type VARCHAR(255), capacity FLOAT, start_date DATE, end_date DATE); INSERT INTO projects (id, name, location, type, capacity, start_date, end_date) VALUES (4, 'Solar Farm 2', 'Arizona', 'Solar', 75.0, '2014-01-01', '2024-12-31');
Which renewable energy projects started before 2015?
SELECT * FROM projects WHERE start_date < '2015-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE DisasterPreparedness (id INT, state VARCHAR(20), date DATE, drill_type VARCHAR(20), quantity INT);
What is the average number of disaster preparedness drills conducted per state in the past year?
SELECT AVG(SUM(quantity)) FROM DisasterPreparedness GROUP BY state HAVING date >= DATEADD(year, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE donors_4 (id INT PRIMARY KEY, name VARCHAR(50), age INT, city VARCHAR(50), state VARCHAR(50)); INSERT INTO donors_4 (id, name, age, city, state) VALUES (1, 'John Doe', 35, 'New York', 'NY'), (2, 'Jane Smith', 40, 'Buffalo', 'NY'), (3, 'Mike Johnson', 50, 'Boston', 'MA'), (4, 'Emily Davis', 30, 'Chicago', '...
How many donors are there in 'NY' and 'MA'?
SELECT state, COUNT(DISTINCT donors_4.id) as num_donors FROM donors_4 WHERE state IN ('NY', 'MA') GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE Income (ID INT, FamilySize INT, Income INT, HealthInsurance BOOLEAN); INSERT INTO Income (ID, FamilySize, Income, HealthInsurance) VALUES (1, 4, 80000, TRUE); INSERT INTO Income (ID, FamilySize, Income, HealthInsurance) VALUES (2, 2, 50000, FALSE);
What is the average income of families without health insurance coverage in California?
SELECT AVG(Income) FROM Income WHERE HealthInsurance = FALSE;
gretelai_synthetic_text_to_sql
CREATE TABLE fabrics (id INT, fabric_type VARCHAR(50), is_sustainable BOOLEAN); INSERT INTO fabrics (id, fabric_type, is_sustainable) VALUES (1, 'Organic Cotton', TRUE), (2, 'Recycled Polyester', TRUE), (3, 'Conventional Cotton', FALSE); CREATE TABLE products (id INT, fabric_id INT, quantity INT); INSERT INTO products ...
Which sustainable fabric types are most frequently used in our products, and how many units of each are available?
SELECT f.fabric_type, SUM(p.quantity) AS total_quantity FROM fabrics f INNER JOIN products p ON f.id = p.fabric_id WHERE f.is_sustainable = TRUE GROUP BY f.fabric_type;
gretelai_synthetic_text_to_sql
CREATE TABLE sea_depths (id INT, sea TEXT, deepest_part TEXT, depth INT); INSERT INTO sea_depths (id, sea, deepest_part, depth) VALUES (1, 'South China Sea', 'Sulu Sea Trench', 8040), (2, 'Indian Ocean', 'Java Trench', 8075);
What is the name of the deepest part of the South China Sea?
SELECT deepest_part FROM sea_depths WHERE sea = 'South China Sea';
gretelai_synthetic_text_to_sql
CREATE TABLE transportation (id INT, agreement_length INT); INSERT INTO transportation (id, agreement_length) VALUES (1, 36), (2, 48), (3, 60);
What is the maximum collective bargaining agreement length in the transportation industry?
SELECT MAX(agreement_length) FROM transportation;
gretelai_synthetic_text_to_sql
CREATE TABLE Transactions (tx_id INT, contract_name VARCHAR(255), tx_value DECIMAL(10,2)); INSERT INTO Transactions (tx_id, contract_name, tx_value) VALUES (1, 'SmartContractD', 100.50); INSERT INTO Transactions (tx_id, contract_name, tx_value) VALUES (2, 'SmartContractD', 200.75);
What is the maximum transaction value for 'SmartContractD'?
SELECT MAX(tx_value) FROM Transactions WHERE contract_name = 'SmartContractD';
gretelai_synthetic_text_to_sql
CREATE TABLE MaterialSourcing (Brand VARCHAR(255), Material VARCHAR(255), Quantity INT); INSERT INTO MaterialSourcing (Brand, Material, Quantity) VALUES ('BrandP', 'Recycled Polyester', 30000), ('BrandQ', 'Organic Cotton', 25000), ('BrandR', 'Recycled Polyester', 35000);
Which sustainable fashion brand sources the most recycled polyester?
SELECT Brand, MAX(Quantity) FROM MaterialSourcing WHERE Material = 'Recycled Polyester';
gretelai_synthetic_text_to_sql
CREATE TABLE Military_Personnel (ID INT, Branch VARCHAR(50), Personnel INT); INSERT INTO Military_Personnel (ID, Branch, Personnel) VALUES (1, 'Army', 500000), (2, 'Navy', 400000), (3, 'Air_Force', 350000);
What is the maximum number of military personnel in each branch?
SELECT Branch, MAX(Personnel) FROM Military_Personnel GROUP BY Branch;
gretelai_synthetic_text_to_sql
CREATE TABLE mining_operations (id INT, first_name VARCHAR(50), last_name VARCHAR(50), job_title VARCHAR(50), department VARCHAR(50), PRIMARY KEY (id)); INSERT INTO mining_operations (id, first_name, last_name, job_title, department, salary) VALUES (1, 'John', 'Doe', 'Engineer', 'Mining', 80000.00), (2, 'Jane', 'Doe', ...
What is the number of employees in each department in the 'mining_operations' table, for employees with a salary greater than $70,000?
SELECT department, COUNT(*) FROM mining_operations WHERE salary > 70000 GROUP BY department;
gretelai_synthetic_text_to_sql
CREATE TABLE emissions (emission_id INT, activity_type TEXT, country TEXT, CO2_emissions FLOAT, reduction_percentage FLOAT, year INT); INSERT INTO emissions (emission_id, activity_type, country, CO2_emissions, reduction_percentage, year) VALUES (1, 'Eco-tours', 'Brazil', 1000, 0.2, 2021), (2, 'Wildlife sanctuaries', 'A...
What is the total CO2 emissions reduction achieved by sustainable tourism practices in South America in 2021?
SELECT SUM(CO2_emissions * reduction_percentage) FROM emissions WHERE country LIKE 'South%' AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE arctic_weather (date DATE, temperature FLOAT); INSERT INTO arctic_weather (date, temperature) VALUES ('2020-01-01', -10.0), ('2020-01-02', -15.0), ('2020-01-03', -8.0);
What is the average temperature recorded in the 'arctic_weather' table for January?
SELECT AVG(temperature) FROM arctic_weather WHERE EXTRACT(MONTH FROM date) = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Events (event_id INT PRIMARY KEY, event_name TEXT, category TEXT, attendees INT);
Delete all events with attendance below 50 in the 'Music' category.
DELETE FROM Events WHERE category = 'Music' AND attendees < 50;
gretelai_synthetic_text_to_sql
CREATE TABLE production (year INT, element TEXT, quantity INT); INSERT INTO production (year, element, quantity) VALUES (2015, 'Dysprosium', 100), (2016, 'Dysprosium', 150), (2017, 'Dysprosium', 200), (2018, 'Dysprosium', 250), (2019, 'Dysprosium', 300), (2020, 'Dysprosium', 350), (2015, 'Neodymium', 500), (2016, 'Neod...
What was the total REE production in 2018?
SELECT SUM(quantity) FROM production WHERE year = 2018 AND element IN ('Dysprosium', 'Neodymium');
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_plans (plan_id INT, plan_name VARCHAR(50), data_limit INT, price DECIMAL(5,2), contract_length INT, created_at TIMESTAMP);
Update the data limit for a mobile plan in the mobile_plans table
UPDATE mobile_plans SET data_limit = 75000 WHERE plan_id = 2001;
gretelai_synthetic_text_to_sql
CREATE TABLE startups (id INT, name TEXT, founder_gender TEXT, founder_ethnicity TEXT, founding_date DATE);
What is the earliest founding date for a startup with a diverse founding team (at least one founder identifies as female and one founder identifies as a person of color)?
SELECT MIN(founding_date) FROM startups WHERE (founder_gender = 'Female' OR founder_ethnicity IN ('African American', 'Asian', 'Hispanic', 'Latinx')) AND EXISTS (SELECT 1 FROM startups s2 WHERE s2.id = startups.id AND (s2.founder_gender <> 'Female' OR s2.founder_ethnicity NOT IN ('African American', 'Asian', 'Hispanic'...
gretelai_synthetic_text_to_sql
CREATE TABLE Programs (ProgramID INT, ProgramName VARCHAR(50), StartDate DATE); INSERT INTO Programs (ProgramID, ProgramName, StartDate) VALUES (1, 'Accessible Tech', '2020-01-01'), (2, 'Sign Language Interpretation', '2019-06-15'), (3, 'Mobility Assistance', '2018-02-20'), (4, 'Assistive Listening', '2021-03-25'), (5,...
List all disability support programs and their start dates in descending order.
SELECT ProgramName, StartDate FROM Programs ORDER BY StartDate DESC;
gretelai_synthetic_text_to_sql
CREATE VIEW multi_crop_farmers AS SELECT farmer_id, COUNT(crop_name) AS num_crops FROM crops GROUP BY farmer_id HAVING num_crops > 1; INSERT INTO crops (id, farmer_id, crop_name, acres) VALUES (1, 1, 'maize', 50), (2, 2, 'maize', 75), (3, 3, 'soybean', 100), (4, 1, 'carrot', 25);
Find the number of farmers who cultivate more than one crop.
SELECT COUNT(*) FROM multi_crop_farmers;
gretelai_synthetic_text_to_sql
CREATE TABLE employees (id INT, first_name VARCHAR(50), last_name VARCHAR(50), job_title VARCHAR(50), department VARCHAR(50), age INT, PRIMARY KEY (id)); INSERT INTO employees (id, first_name, last_name, job_title, department, age) VALUES (1, 'John', 'Doe', 'Engineer', 'Mining', 35), (2, 'Jane', 'Doe', 'Operator', 'Min...
Delete all records from the 'employees' table where the department is 'Sustainability' and the employee's age is less than 30.
DELETE FROM employees WHERE department = 'Sustainability' AND age < 30;
gretelai_synthetic_text_to_sql
CREATE TABLE species_measurements (species_id INT, measurement_date DATE, temperature DECIMAL(5,2));
What is the average temperature recorded for each species in the species_measurements table?
SELECT species_id, AVG(temperature) OVER (PARTITION BY species_id) FROM species_measurements;
gretelai_synthetic_text_to_sql
CREATE TABLE students (student_id INT, name VARCHAR(50), department VARCHAR(50)); CREATE TABLE publications (publication_id INT, student_id INT, title VARCHAR(50), department VARCHAR(50));
Who are the graduate students who have published the most papers in the Mathematics department?
SELECT students.name, COUNT(publications.publication_id) AS num_publications FROM students JOIN publications ON students.student_id = publications.student_id WHERE students.department = 'Mathematics' GROUP BY students.name ORDER BY num_publications DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Country (id INT, name TEXT, continent TEXT); INSERT INTO Country (id, name, continent) VALUES (1, 'Brazil', 'South America'); CREATE TABLE Violations (id INT, country_id INT, year INT, type TEXT); INSERT INTO Violations (id, country_id, year, type) VALUES (1, 1, 2020, 'Wage Theft'), (2, 1, 2021, 'Child Lab...
How many labor rights violations have been reported in Brazil in the last 2 years?
SELECT COUNT(*) FROM Violations WHERE year BETWEEN (SELECT YEAR(CURRENT_DATE) - 2) AND YEAR(CURRENT_DATE) AND country_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Consumer_Preference (id INT, consumer_id INT, product VARCHAR(255), preference BOOLEAN); INSERT INTO Consumer_Preference (id, consumer_id, product, preference) VALUES (1, 1001, 'Lush Soak Stimulant Bath Bomb', true), (2, 1002, 'The Body Shop Born Lippy Strawberry Lip Balm', true), (3, 1003, 'Estee Lauder A...
What is the total number of consumers who prefer cruelty-free cosmetics in the database?
SELECT COUNT(DISTINCT consumer_id) as total_consumers FROM Consumer_Preference WHERE preference = true;
gretelai_synthetic_text_to_sql
CREATE TABLE indigenous_communities (community_name VARCHAR(50), region VARCHAR(50)); INSERT INTO indigenous_communities (community_name, region) VALUES ('Inuit', 'Arctic North America'), ('Sami', 'Arctic Europe');
How many indigenous communities are in each Arctic region?
SELECT i.region, COUNT(i.community_name) as community_count FROM indigenous_communities i GROUP BY i.region;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (donor_id INT, name VARCHAR(255), country VARCHAR(255), first_time BOOLEAN); CREATE TABLE Donations (donation_id INT, donor_id INT, event_id INT, amount DECIMAL(10, 2));
What is the average donation amount for first-time donors in 'CountryY'?
SELECT AVG(amount) FROM Donations D JOIN Donors DD ON D.donor_id = DD.donor_id WHERE DD.first_time = TRUE AND DD.country = 'CountryY';
gretelai_synthetic_text_to_sql