context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE inventory (ingredient_id INT, ingredient_name VARCHAR(50), packaging_type VARCHAR(50), quantity INT, order_date DATE); INSERT INTO inventory VALUES (1, 'Tomatoes', 'Plastic', 100, '2022-01-01'), (2, 'Chicken', 'Cardboard', 50, '2022-01-02'), (3, 'Lettuce', 'Biodegradable', 80, '2022-01-03'); CREATE TABLE packaging (packaging_id INT, packaging_type VARCHAR(50), is_recyclable BOOLEAN, weekly_waste INT); INSERT INTO packaging VALUES (1, 'Plastic', false, 5), (2, 'Cardboard', true, 2), (3, 'Biodegradable', true, 1);
What is the total waste generated by packaging materials per week?
SELECT SUM(packaging.weekly_waste) FROM inventory INNER JOIN packaging ON inventory.packaging_type = packaging.packaging_type WHERE inventory.order_date >= '2022-01-01' AND inventory.order_date < '2022-01-08';
gretelai_synthetic_text_to_sql
CREATE TABLE salaries_dept (id INT, employee VARCHAR(50), department VARCHAR(50), salary DECIMAL(10,2)); INSERT INTO salaries_dept (id, employee, department, salary) VALUES (1, 'John Doe', 'manufacturing', 50000.00), (2, 'Jane Smith', 'engineering', 65000.00), (3, 'Alice Johnson', 'engineering', 60000.00);
Calculate the total salary paid to the 'engineering' department
SELECT SUM(salary) FROM salaries_dept WHERE department = 'engineering';
gretelai_synthetic_text_to_sql
CREATE TABLE wells (well_id INT, field VARCHAR(50), region VARCHAR(50), production_oil FLOAT, production_gas FLOAT, production_date DATE); INSERT INTO wells (well_id, field, region, production_oil, production_gas, production_date) VALUES (1, 'Lula', 'Brazil', 15000.0, 5000.0, '2018-01-01'), (2, 'Buzios', 'Brazil', 8000.0, 6000.0, '2018-02-01');
What was the daily average production of oil in 'Brazil' in 2018?
SELECT AVG(production_oil) FROM wells WHERE region = 'Brazil' AND YEAR(production_date) = 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE readers (id INT, name VARCHAR(50), age INT, preferred_category VARCHAR(20)); INSERT INTO readers (id, name, age, preferred_category) VALUES (1, 'John Doe', 25, 'Sports');
What is the average age of readers who prefer 'Entertainment' news category and are from Canada?
SELECT AVG(age) FROM readers WHERE preferred_category = 'Entertainment' AND country = 'Canada'
gretelai_synthetic_text_to_sql
CREATE TABLE Public_Works (project_id int, project_name varchar(255), state varchar(255), category varchar(255));
Show the number of public works projects in each state
SELECT state, COUNT(*) FROM Public_Works GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE menu_items (item_id INT, name VARCHAR(255), category VARCHAR(255)); INSERT INTO menu_items (item_id, name, category) VALUES (1, 'Burger', 'Main Course'), (2, 'Salad', 'Side Dish'), (3, 'Pizza', 'Main Course');
Show the total number of menu items in each category.
SELECT category, COUNT(item_id) as total_items FROM menu_items GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE Sales (sale_id INT PRIMARY KEY, menu_item VARCHAR(50), sale_quantity INT, sale_price DECIMAL(5,2), sale_date DATE); CREATE TABLE Inventory (inventory_id INT PRIMARY KEY, menu_item VARCHAR(50), inventory_quantity INT, inventory_cost DECIMAL(5,2), inventory_date DATE); CREATE TABLE Menu (menu_item VARCHAR(50) PRIMARY KEY, menu_item_category VARCHAR(50));
Which menu items have a higher inventory cost than sales revenue in the past month?
SELECT i.menu_item FROM Inventory i JOIN Menu m ON i.menu_item = m.menu_item JOIN Sales s ON i.menu_item = s.menu_item WHERE i.inventory_cost > s.sale_price * s.sale_quantity AND i.inventory_date >= DATEADD(month, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE materials (material_id INT, name VARCHAR(255), is_sustainable BOOLEAN); INSERT INTO materials VALUES (1, 'Hemp Fiber', true); INSERT INTO materials VALUES (2, 'Bamboo Fabric', true); INSERT INTO materials VALUES (3, 'Nylon', false); CREATE TABLE inventory (inventory_id INT, material_id INT, factory_id INT, quantity INT); INSERT INTO inventory VALUES (1, 1, 1, 1200); INSERT INTO inventory VALUES (2, 2, 2, 500); INSERT INTO inventory VALUES (3, 3, 1, 800);
Which sustainable materials have the least and most inventory available across all factories?
SELECT material.name, MAX(inventory.quantity) AS max_quantity, MIN(inventory.quantity) AS min_quantity FROM material JOIN inventory ON material.material_id = inventory.material_id WHERE material.is_sustainable = true GROUP BY material.name;
gretelai_synthetic_text_to_sql
CREATE TABLE Policyholders (PolicyID INT, Age INT, Region VARCHAR(10)); INSERT INTO Policyholders (PolicyID, Age, Region) VALUES (1, 35, 'RegionA'), (2, 42, 'RegionB');
Find the average age of policyholders in 'RegionA' and 'RegionB'.
SELECT AVG(Age) FROM Policyholders WHERE Region IN ('RegionA', 'RegionB');
gretelai_synthetic_text_to_sql
CREATE TABLE safety_incidents (vessel_id INT, incident_date DATE, vessel_type VARCHAR(50));
What is the number of vessels that had a safety incident in the past year, by vessel type?
SELECT vessel_type, COUNT(*) FROM safety_incidents WHERE incident_date >= DATEADD(year, -1, GETDATE()) GROUP BY vessel_type;
gretelai_synthetic_text_to_sql
CREATE TABLE CityData (city VARCHAR(50), age INT); INSERT INTO CityData (city, age) VALUES ('CityA', 35), ('CityA', 40), ('CityB', 28), ('CityB', 32);
What is the average age of residents in 'CityData' table, grouped by city?
SELECT city, AVG(age) FROM CityData GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE city (id INT, name VARCHAR(255), population INT, sustainable_projects INT); INSERT INTO city (id, name, population, sustainable_projects) VALUES (1, 'San Francisco', 884363, 450); INSERT INTO city (id, name, population, sustainable_projects) VALUES (2, 'Los Angeles', 4000000, 650); CREATE TABLE building (id INT, name VARCHAR(255), city_id INT, size FLOAT, is_green BOOLEAN); INSERT INTO building (id, name, city_id, size, is_green) VALUES (1, 'City Hall', 1, 12000.0, true); INSERT INTO building (id, name, city_id, size, is_green) VALUES (2, 'Library', 1, 8000.0, false);
What is the average size of green buildings in city 1?
SELECT AVG(size) as avg_size FROM building WHERE city_id = 1 AND is_green = true;
gretelai_synthetic_text_to_sql
CREATE TABLE regulatory_frameworks (framework_id INT, asset_id INT, country VARCHAR(255), name VARCHAR(255), description TEXT);
What are the regulatory frameworks for a specific digital asset?
SELECT rf.name, rf.description FROM regulatory_frameworks rf JOIN digital_assets da ON rf.asset_id = da.asset_id WHERE da.name = 'Ethereum';
gretelai_synthetic_text_to_sql
CREATE TABLE community_development (id INT PRIMARY KEY, name VARCHAR(255), description TEXT, start_date DATE, end_date DATE);
Delete records with no end_date in the community_development table
WITH cte AS (DELETE FROM community_development WHERE end_date IS NULL) SELECT * FROM cte;
gretelai_synthetic_text_to_sql
CREATE TABLE RenewableEnergy (ProjectID INT, CO2EmissionReduction FLOAT);
What is the maximum CO2 emission reduction of renewable energy projects in the RenewableEnergy schema?
select max(CO2EmissionReduction) as max_reduction from RenewableEnergy;
gretelai_synthetic_text_to_sql
CREATE TABLE Countries (id INT PRIMARY KEY, country VARCHAR(50), region VARCHAR(50)); INSERT INTO Countries (id, country, region) VALUES (1, 'USA', 'North America'); INSERT INTO Countries (id, country, region) VALUES (2, 'Canada', 'North America');
What is the total transaction amount per country, excluding the Gaming category?
SELECT c.country, SUM(t.amount) FROM Transactions t INNER JOIN Users u ON t.user_id = u.id INNER JOIN Countries c ON u.country = c.country INNER JOIN Smart_Contracts sc ON t.smart_contract_id = sc.id WHERE sc.category != 'Gaming' GROUP BY c.country;
gretelai_synthetic_text_to_sql
CREATE TABLE RuralInfrastructure (id INT, project_id INT, type VARCHAR(255), sector VARCHAR(255), jobs_created INT); CREATE TABLE AgriculturalProjects (id INT, project_name VARCHAR(255), location VARCHAR(255), start_date DATE, end_date DATE, budget FLOAT); INSERT INTO AgriculturalProjects (id, project_name, location, start_date, end_date, budget) VALUES (1, 'Drip Irrigation', 'Village B', '2018-01-01', '2019-01-01', 5000.00); INSERT INTO RuralInfrastructure (id, project_id, type, sector, jobs_created) VALUES (1, 1, 'Electricity', 'Agriculture', 20);
How many jobs have been created in rural infrastructure projects by sector?
SELECT AgriculturalProjects.location, RuralInfrastructure.sector, SUM(RuralInfrastructure.jobs_created) as total_jobs_created FROM AgriculturalProjects INNER JOIN RuralInfrastructure ON AgriculturalProjects.id = RuralInfrastructure.project_id WHERE AgriculturalProjects.location LIKE 'Village%' GROUP BY AgriculturalProjects.location, RuralInfrastructure.sector;
gretelai_synthetic_text_to_sql
CREATE TABLE network_investments (quarter VARCHAR(10), region VARCHAR(10), investment FLOAT); INSERT INTO network_investments (quarter, region, investment) VALUES ('Q1', 'Asia', 500000.0), ('Q2', 'Asia', 600000.0);
What is the average network investment per quarter in the 'Asia' region?
SELECT quarter, AVG(investment) FROM network_investments WHERE region = 'Asia' GROUP BY quarter;
gretelai_synthetic_text_to_sql
CREATE TABLE countries (country VARCHAR(50), population INT); INSERT INTO countries (country, population) VALUES ('China', 1439323776), ('USA', 331002651), ('Russia', 145934462), ('India', 1380004385), ('Japan', 126476461); CREATE TABLE space_agencies (country VARCHAR(50), agency VARCHAR(50)); INSERT INTO space_agencies (country, agency) VALUES ('China', 'China National Space Administration'), ('USA', 'National Aeronautics and Space Administration'), ('Russia', 'Roscosmos'), ('India', 'Indian Space Research Organisation'), ('Japan', 'Japan Aerospace Exploration Agency');
List all space agencies with their corresponding country, including joined data from the 'space_agencies' and 'countries' tables.
SELECT sa.country, sa.agency AS space_agency FROM space_agencies sa INNER JOIN countries c ON sa.country = c.country;
gretelai_synthetic_text_to_sql
CREATE TABLE Advocates (Advocate VARCHAR(30), Program VARCHAR(20), Budget INT); INSERT INTO Advocates (Advocate, Program, Budget) VALUES ('Carlos Gonzalez', 'Low Vision Services', 50000); INSERT INTO Advocates (Advocate, Program, Budget) VALUES ('Fatima Patel', 'Braille Services', 65000);
Who are the advocates and their total budgets for visual support programs?
SELECT Advocate, SUM(Budget) FROM Advocates WHERE Program LIKE '%Visual%' GROUP BY Advocate;
gretelai_synthetic_text_to_sql
CREATE TABLE AssetRegulatoryDurations (AssetID int, AssetType varchar(50), RegulatoryStatus varchar(50), Duration int); INSERT INTO AssetRegulatoryDurations (AssetID, AssetType, RegulatoryStatus, Duration) VALUES (1, 'Cryptocurrency', 'Regulated', 36), (2, 'Security Token', 'Partially Regulated', 12), (3, 'Utility Token', 'Unregulated', 24), (4, 'Stablecoin', 'Partially Regulated', 48), (5, 'Cryptocurrency', 'Unregulated', 60);
What is the average regulatory status duration for digital assets?
SELECT AssetType, AVG(Duration) as AvgRegulatoryDuration FROM AssetRegulatoryDurations GROUP BY AssetType;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, Department VARCHAR(50), Gender VARCHAR(10), Salary FLOAT, HireDate DATE); INSERT INTO Employees (EmployeeID, Department, Gender, Salary, HireDate) VALUES (1, 'IT', 'Male', 85000, '2021-04-20'), (2, 'HR', 'Female', 75000, '2019-12-15'), (3, 'IT', 'Female', 80000, '2020-01-08'), (4, 'IT', 'Male', 90000, '2021-04-01'), (5, 'Finance', 'Male', 75000, '2019-12-28'), (6, 'IT', 'Male', 88000, '2021-05-12'), (7, 'Marketing', 'Female', 78000, '2021-07-01');
What is the average salary of employees in the IT department hired after January 2020?
SELECT AVG(Salary) FROM Employees WHERE Department = 'IT' AND HireDate > '2020-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE patients (id INT, age INT, diagnosis VARCHAR(20), location VARCHAR(20)); INSERT INTO patients (id, age, diagnosis, location) VALUES (1, 50, 'diabetes', 'rural'), (2, 45, 'diabetes', 'rural'), (3, 60, 'not diabetes', 'urban');
What is the average age of patients diagnosed with diabetes in rural areas?
SELECT AVG(age) FROM patients WHERE diagnosis = 'diabetes' AND location = 'rural';
gretelai_synthetic_text_to_sql
CREATE TABLE games (id INT, player TEXT, country TEXT, points_scored INT); INSERT INTO games (id, player, country, points_scored) VALUES (1, 'Raj Singh', 'IND', 12), (2, 'Priya Patel', 'IND', 16), (3, 'Amit Kumar', 'IND', 10);
What is the average points scored by players from India in a single game?
SELECT AVG(points_scored) FROM games WHERE country = 'IND';
gretelai_synthetic_text_to_sql
CREATE TABLE community_development_initiatives (id INT, country VARCHAR(255), size_ha FLOAT, completion_date DATE); INSERT INTO community_development_initiatives (id, country, size_ha, completion_date) VALUES (1, 'Kenya', 50.2, '2016-03-01'), (2, 'Kenya', 32.1, '2017-08-15'), (3, 'Tanzania', 45.6, '2018-09-22');
What is the average size, in hectares, of community development initiatives in Kenya that were completed after 2015?
SELECT AVG(size_ha) FROM community_development_initiatives WHERE country = 'Kenya' AND completion_date >= '2015-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE bridges (id INT, name VARCHAR(50), division VARCHAR(50), maintenance_date DATE); INSERT INTO bridges (id, name, division, maintenance_date) VALUES (1, 'Bridge A', 'Transportation', '2024-02-01'), (2, 'Bridge B', 'Transportation', '2023-07-15'), (3, 'Bridge C', 'Transportation', '2025-03-20');
Identify the bridges in the transportation division that require maintenance in the next 6 months and display their maintenance schedule.
SELECT name, maintenance_date FROM bridges WHERE division = 'Transportation' AND maintenance_date BETWEEN CURDATE() AND DATE_ADD(CURDATE(), INTERVAL 6 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE dapps (name VARCHAR(255), category VARCHAR(50), transaction_count INT); INSERT INTO dapps (name, category, transaction_count) VALUES ('App1', 'DeFi', 500), ('App2', 'Gaming', 200), ('App3', 'DeFi', 800);
What are the names and transaction counts of decentralized applications in the 'DeFi' category?
SELECT name, transaction_count FROM dapps WHERE category = 'DeFi';
gretelai_synthetic_text_to_sql
CREATE TABLE bsc_smart_contracts (contract_id INT, contract_address VARCHAR(40), network VARCHAR(20)); INSERT INTO bsc_smart_contracts (contract_id, contract_address, network) VALUES (1, '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c', 'Binance Smart Chain'); CREATE TABLE bsc_smart_contract_transactions (transaction_id INT, contract_id INT, block_number INT, value DECIMAL(10,2)); INSERT INTO bsc_smart_contract_transactions (transaction_id, contract_id, block_number, value) VALUES (1, 1, 10, 10000); INSERT INTO bsc_smart_contract_transactions (transaction_id, contract_id, block_number, value) VALUES (2, 1, 20, 20000);
What is the maximum transaction value for 'Wrapped Ether' smart contract on the 'Binance Smart Chain'?
SELECT MAX(t.value) as max_value FROM bsc_smart_contracts c JOIN bsc_smart_contract_transactions t ON c.contract_id = t.contract_id WHERE c.contract_address = '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c' AND c.network = 'Binance Smart Chain' AND c.contract_name = 'Wrapped Ether';
gretelai_synthetic_text_to_sql
CREATE TABLE Artworks (Artist VARCHAR(50), Artwork VARCHAR(50), Year INT); INSERT INTO Artworks
Find the number of artworks by each artist in the 'Artworks' table
SELECT Artist, COUNT(Artwork) as ArtworkCount FROM Artworks GROUP BY Artist
gretelai_synthetic_text_to_sql
CREATE TABLE Stations (StationID INT, StationName VARCHAR(50), RouteID INT, IsStart VARCHAR(50)); INSERT INTO Stations (StationID, StationName, RouteID, IsStart) VALUES (1, 'StationA', 1, 'true'), (2, 'StationB', 1, 'false'), (3, 'StationC', 1, 'false'), (4, 'StationD', 2, 'true'), (5, 'StationE', 2, 'false'), (6, 'StationF', 3, 'true'), (7, 'StationG', 3, 'false'), (8, 'StationH', 3, 'false');
What is the most frequently used boarding station for each route?
SELECT RouteID, StationName FROM Stations S1 WHERE IsStart = 'true' AND NOT EXISTS (SELECT * FROM Stations S2 WHERE S2.RouteID = S1.RouteID AND S2.IsStart = 'true' AND S2.StationID > S1.StationID);
gretelai_synthetic_text_to_sql
CREATE TABLE mental_health_conditions (patient_id INT, condition VARCHAR(50), state VARCHAR(50)); INSERT INTO mental_health_conditions (patient_id, condition, state) VALUES (1, 'Anxiety', 'California'), (2, 'Depression', 'California'); CREATE TABLE treatment_approaches (patient_id INT, approach VARCHAR(50), duration INT); INSERT INTO treatment_approaches (patient_id, approach, duration) VALUES (1, 'CBT', 12), (1, 'Medication', 10), (2, 'Medication', 15), (2, 'Therapy', 20);
What is the total number of patients treated with CBT and medication in California?
SELECT SUM(duration) FROM (SELECT duration FROM treatment_approaches WHERE approach IN ('CBT', 'Medication') AND patient_id IN (SELECT patient_id FROM mental_health_conditions WHERE state = 'California') GROUP BY patient_id) AS subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE multimodal_systems (id INT, city VARCHAR(20), num_systems INT); INSERT INTO multimodal_systems (id, city, num_systems) VALUES (1, 'New York', 3), (2, 'Chicago', 2);
How many public transportation systems support multimodal travel in New York?
SELECT num_systems FROM multimodal_systems WHERE city = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE shrimp_farms (id INT, name TEXT, country TEXT, water_depth FLOAT); INSERT INTO shrimp_farms (id, name, country, water_depth) VALUES (1, 'Farm R', 'Vietnam', 6.2); INSERT INTO shrimp_farms (id, name, country, water_depth) VALUES (2, 'Farm S', 'Vietnam', 7.5); INSERT INTO shrimp_farms (id, name, country, water_depth) VALUES (3, 'Farm T', 'Vietnam', 8.9);
What is the maximum water depth for shrimp farms in Vietnam?
SELECT MAX(water_depth) FROM shrimp_farms WHERE country = 'Vietnam';
gretelai_synthetic_text_to_sql
CREATE TABLE Attorneys (AttorneyID INT PRIMARY KEY, Gender VARCHAR(6), Name VARCHAR(255)); INSERT INTO Attorneys (AttorneyID, Gender, Name) VALUES (1, 'Female', 'Sarah Johnson'), (2, 'Male', 'Daniel Lee'), (3, 'Non-binary', 'Jamie Taylor'); CREATE TABLE CaseOutcomes (CaseID INT PRIMARY KEY, AttorneyID INT, Outcome VARCHAR(10)); INSERT INTO CaseOutcomes (CaseID, AttorneyID, Outcome) VALUES (1, 1, 'Won'), (2, 2, 'Lost'), (3, 3, 'Won');
How many cases were won by attorneys who identify as female?
SELECT COUNT(*) FROM CaseOutcomes JOIN Attorneys ON CaseOutcomes.AttorneyID = Attorneys.AttorneyID WHERE Attorneys.Gender = 'Female' AND Outcome = 'Won';
gretelai_synthetic_text_to_sql
CREATE TABLE temperature (temp_id INT, location TEXT, temperature FLOAT); INSERT INTO temperature (temp_id, location, temperature) VALUES (1, 'Arctic', 25.7);
What is the maximum water temperature in the Arctic ocean?
SELECT MAX(temperature) FROM temperature WHERE location = 'Arctic'
gretelai_synthetic_text_to_sql
CREATE TABLE forest (id INT, name TEXT, region TEXT, is_fsc_certified BOOLEAN);
What is the total area of forests in the temperate region that have been certified as sustainable by the Forest Stewardship Council (FSC)?
SELECT SUM(area_sqkm) FROM forest WHERE region = 'temperate' AND is_fsc_certified = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE broadband_subscribers (subscriber_id INT, last_usage DATE); INSERT INTO broadband_subscribers (subscriber_id, last_usage) VALUES (1, '2021-06-01'), (2, '2021-02-15'), (3, '2021-01-05'), (4, '2021-07-20');
Delete inactive broadband subscribers who haven't used the service in the last 6 months?
DELETE FROM broadband_subscribers WHERE last_usage < DATE_SUB(CURDATE(), INTERVAL 6 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE ProjectTimeline (permit_id INT, project_type VARCHAR(255), duration INT, issue_year INT); INSERT INTO ProjectTimeline (permit_id, project_type, duration, issue_year) VALUES (1, 'residential', 120, 2021), (2, 'commercial', 180, 2022);
What is the average duration of residential permits issued in 2021?
SELECT AVG(duration) FROM ProjectTimeline WHERE project_type = 'residential' AND issue_year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE farm_asia (farm_id INT, country VARCHAR(255), density FLOAT); INSERT INTO farm_asia (farm_id, country, density) VALUES (1, 'Japan', 50), (2, 'Japan', 60), (3, 'South Korea', 70), (4, 'South Korea', 80);
Determine the average stocking density of fish farms in Japan and South Korea.
SELECT AVG(density) FROM farm_asia WHERE country IN ('Japan', 'South Korea');
gretelai_synthetic_text_to_sql
CREATE TABLE productivity (id INT PRIMARY KEY, company VARCHAR(100), value DECIMAL(5,2));
Insert new labor productivity data
INSERT INTO productivity (company, value) VALUES ('Teck Resources', 320);
gretelai_synthetic_text_to_sql
CREATE TABLE ports (port_id INT, port_name VARCHAR(100), country VARCHAR(100)); INSERT INTO ports (port_id, port_name, country) VALUES (1, 'Port of Rotterdam', 'Netherlands'); CREATE TABLE cargo_ships (ship_id INT, ship_name VARCHAR(100), port_id INT, container_size INT); INSERT INTO cargo_ships (ship_id, ship_name, port_id, container_size) VALUES (1, 'South American Ship 1', 1, 20), (2, 'South American Ship 2', 1, 30), (3, 'South American Ship 3', 1, 40);
What is the maximum container size of cargo ships from South American countries that docked at the Port of Rotterdam?
SELECT MAX(container_size) FROM cargo_ships WHERE country = 'South America' AND port_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE digital_assets (asset_id INT, name VARCHAR(255), market_cap DECIMAL(18,2)); INSERT INTO digital_assets (asset_id, name, market_cap) VALUES (1, 'Bitcoin', 1000000000000.00), (2, 'Ethereum', 300000000000.00); CREATE TABLE transactions (transaction_id INT, asset_id INT, value DECIMAL(18,2)); INSERT INTO transactions (transaction_id, asset_id, value) VALUES (1, 1, 50000.00), (2, 1, 60000.00), (3, 2, 20000.00), (4, 2, 30000.00);
What is the total number of transactions and their combined value for digital assets with a market cap greater than $1 billion?
SELECT SUM(value) AS total_value, COUNT(*) AS total_transactions FROM transactions JOIN digital_assets ON transactions.asset_id = digital_assets.asset_id WHERE digital_assets.market_cap > 1000000000;
gretelai_synthetic_text_to_sql
CREATE TABLE ArtSales (id INT, painting_name VARCHAR(50), price FLOAT, sale_date DATE, painting_style VARCHAR(20), sale_location VARCHAR(30)); INSERT INTO ArtSales (id, painting_name, price, sale_date, painting_style, sale_location) VALUES (1, 'Painting1', 9000, '2011-01-01', 'Cubism', 'USA');
Average revenue of Cubism paintings sold worldwide since 2010?
SELECT AVG(price) FROM ArtSales WHERE painting_style = 'Cubism' AND sale_date >= '2010-01-01';
gretelai_synthetic_text_to_sql
CREATE SCHEMA mental_health; USE mental_health; CREATE TABLE treatments (patient_id INT, treatment_type VARCHAR(50), treatment_date DATE, country VARCHAR(50)); INSERT INTO treatments VALUES (1, 'CBT', '2019-01-01', 'Canada');
How many patients were treated with CBT in Canada in 2019?
SELECT COUNT(*) FROM treatments WHERE treatment_type = 'CBT' AND country = 'Canada' AND treatment_date LIKE '2019%';
gretelai_synthetic_text_to_sql
CREATE TABLE FoodTrends (trend_name VARCHAR(50), year_of_introduction INT, popularity_score INT, country VARCHAR(50)); INSERT INTO FoodTrends (trend_name, year_of_introduction, popularity_score, country) VALUES ('Vertical Farming', 2016, 80, 'UK'), ('Plant-based Meat Substitutes', 2017, 85, 'UK'), ('Zero-waste Grocery Stores', 2018, 75, 'UK'), ('Regenerative Agriculture', 2019, 70, 'UK'), ('Edible Packaging', 2020, 65, 'UK');
Which sustainable food trends have gained popularity in the UK in the last 5 years?
SELECT trend_name, year_of_introduction, popularity_score FROM FoodTrends WHERE country = 'UK' AND year_of_introduction >= 2016;
gretelai_synthetic_text_to_sql
CREATE TABLE DefenseProjects (id INT, project_name VARCHAR(100), region VARCHAR(50), start_date DATE, end_date DATE, budget FLOAT);
Insert new defense project record for 'Project X' in the Middle East on 2023-02-15 with a budget of $25 million.
INSERT INTO DefenseProjects (project_name, region, start_date, end_date, budget) VALUES ('Project X', 'Middle East', '2023-02-15', '2023-12-31', 25000000);
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_offset_initiatives (initiative_id INT, location TEXT, carbon_offset_tons FLOAT); INSERT INTO carbon_offset_initiatives (initiative_id, location, carbon_offset_tons) VALUES (1, 'Toronto', 500), (2, 'Montreal', 700), (3, 'Vancouver', 300);
What is the average carbon offset for initiatives in the 'carbon_offset_initiatives' table?
SELECT AVG(carbon_offset_tons) FROM carbon_offset_initiatives;
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (id INT, department VARCHAR(20), registered_date DATE); INSERT INTO Volunteers (id, department, registered_date) VALUES (1, 'Animals', '2021-01-01'), (2, 'Education', '2021-02-01');
What is the total number of volunteers for the 'Education' department in the 'Volunteers' table?
SELECT COUNT(*) FROM Volunteers WHERE department = 'Education'
gretelai_synthetic_text_to_sql
CREATE TABLE Games (GameID INT, Title VARCHAR(50), Genre VARCHAR(20), Platform VARCHAR(10));
Insert a new record into the Games table with the title 'CyberSphere', genre 'Action', and platform 'PC'.
INSERT INTO Games (GameID, Title, Genre, Platform) VALUES (1, 'CyberSphere', 'Action', 'PC');
gretelai_synthetic_text_to_sql
CREATE TABLE Cases (CaseID INT, CaseType VARCHAR(50)); INSERT INTO Cases (CaseID, CaseType) VALUES (1, 'Civil'); INSERT INTO Cases (CaseID, CaseType) VALUES (2, 'Criminal'); CREATE TABLE CaseBilling (CaseBillingID INT, CaseID INT, BillingID INT); INSERT INTO CaseBilling (CaseBillingID, CaseID, BillingID) VALUES (1, 1, 1); INSERT INTO CaseBilling (CaseBillingID, CaseID, BillingID) VALUES (2, 1, 2); INSERT INTO CaseBilling (CaseBillingID, CaseID, BillingID) VALUES (3, 2, 3);
What is the average billing amount per case, by attorney?
SELECT AT.Name, AVG(B.Amount) AS AvgBillingPerCase FROM Attorneys AT JOIN Assignments A ON AT.AttorneyID = A.AttorneyID JOIN CaseBilling CB ON A.AssignmentID = CB.AssignmentID JOIN Billing B ON CB.BillingID = B.BillingID JOIN Cases C ON CB.CaseID = C.CaseID GROUP BY AT.Name;
gretelai_synthetic_text_to_sql
CREATE TABLE payments (payment_id INT, payment_amount DECIMAL(5,2), vehicle_id INT); INSERT INTO payments (payment_id, payment_amount, vehicle_id) VALUES (1, 2.75, 1000), (2, 3.50, 1001), (3, 2.50, 1000), (4, 4.25, 1003), (5, 1.75, 1002), (6, 3.00, 1001); CREATE TABLE vehicles (vehicle_id INT, vehicle_type VARCHAR(50)); INSERT INTO vehicles (vehicle_id, vehicle_type) VALUES (1000, 'Bus'), (1001, 'Tram'), (1002, 'Bus'), (1003, 'Tram'), (1004, 'Trolleybus');
Show the total fare collected from the payments table, grouped by vehicle type from the vehicles table
SELECT v.vehicle_type, SUM(p.payment_amount) FROM payments p JOIN vehicles v ON p.vehicle_id = v.vehicle_id GROUP BY v.vehicle_type;
gretelai_synthetic_text_to_sql
CREATE TABLE City_Satisfaction (City VARCHAR(20), Satisfaction_Score INT); INSERT INTO City_Satisfaction (City, Satisfaction_Score) VALUES ('CityH', 7); INSERT INTO City_Satisfaction (City, Satisfaction_Score) VALUES ('CityH', 8); INSERT INTO City_Satisfaction (City, Satisfaction_Score) VALUES ('CityH', 6);
What is the average citizen satisfaction score for CityH?
SELECT City, AVG(Satisfaction_Score) AS 'Average Citizen Satisfaction Score' FROM City_Satisfaction WHERE City = 'CityH' GROUP BY City;
gretelai_synthetic_text_to_sql
CREATE TABLE wells (well_id INT, name VARCHAR(50), location VARCHAR(50), production FLOAT); INSERT INTO wells (well_id, name, location, production) VALUES (1, 'D1', 'South China Sea', 7000), (2, 'D2', 'South China Sea', 6000), (3, 'D3', 'South China Sea', 8000);
What is the average production of wells in the South China Sea?
SELECT AVG(production) FROM wells WHERE location = 'South China Sea';
gretelai_synthetic_text_to_sql
CREATE TABLE provinces (province_name VARCHAR(255), budget INT); INSERT INTO provinces (province_name, budget) VALUES ('Ontario', 7000000), ('Quebec', 6000000), ('British Columbia', 5000000); CREATE TABLE services (service_name VARCHAR(255), province_name VARCHAR(255), budget INT); INSERT INTO services (service_name, province_name, budget) VALUES ('education', 'Ontario', 4000000), ('education', 'Quebec', 3000000), ('education', 'British Columbia', 2500000), ('infrastructure', 'Ontario', 2000000), ('infrastructure', 'Quebec', 1500000), ('infrastructure', 'British Columbia', 1250000);
Identify the top 3 provinces with the highest budget allocation for education and infrastructure?
SELECT province_name, budget FROM (SELECT province_name, SUM(budget) AS budget FROM services WHERE service_name IN ('education', 'infrastructure') GROUP BY province_name ORDER BY budget DESC) AS subquery LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE FilmLength (genre VARCHAR(20), duration INT); INSERT INTO FilmLength (genre, duration) VALUES ('Drama', 120), ('Drama', 150), ('Action', 80), ('Action', 90);
What is the average duration of films in the drama and action genres?
SELECT AVG(duration) FROM FilmLength WHERE genre IN ('Drama', 'Action');
gretelai_synthetic_text_to_sql
CREATE TABLE animal_population (id INT, animal_name VARCHAR(50), population INT); CREATE TABLE endangered_animals (id INT, animal_name VARCHAR(50));
What are the average population sizes of animals in the 'animal_population' table that are also present in the 'endangered_animals' table?
SELECT AVG(a.population) FROM animal_population a INNER JOIN endangered_animals e ON a.animal_name = e.animal_name;
gretelai_synthetic_text_to_sql
CREATE TABLE mining_accidents (accident_id INT, accident_date DATE, accident_type VARCHAR(50), method_id INT); INSERT INTO mining_accidents (accident_id, accident_date, accident_type, method_id) VALUES (1, '2020-01-01', 'Equipment Failure', 1), (2, '2020-03-15', 'Gas Explosion', 2), (3, '2019-12-31', 'Fire', 3);
What is the total number of mining accidents by year?
SELECT YEAR(accident_date), COUNT(*) FROM mining_accidents GROUP BY YEAR(accident_date);
gretelai_synthetic_text_to_sql
CREATE TABLE environmental_impact_q2 (site_id INT, impact_score INT, impact_date DATE); INSERT INTO environmental_impact_q2 (site_id, impact_score, impact_date) VALUES (1, 65, '2022-04-10'), (2, 75, '2022-05-22'), (3, 80, '2022-06-30');
What is the maximum environmental impact score for a mine site in Q2 2022?
SELECT MAX(impact_score) FROM environmental_impact_q2 WHERE impact_date BETWEEN '2022-04-01' AND '2022-06-30';
gretelai_synthetic_text_to_sql
CREATE TABLE climate_finance (id INT, project_location VARCHAR(20), finance_type VARCHAR(20), amount INT, finance_year INT); INSERT INTO climate_finance (id, project_location, finance_type, amount, finance_year) VALUES (1, 'Africa', 'Government Grants', 500000, 2015);
Update the amount of climate finance for a specific record in the climate_finance table.
UPDATE climate_finance SET amount = 600000 WHERE id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE sour_streams (week INT, streams_in_week INT); INSERT INTO sour_streams (week, streams_in_week) VALUES (1, 250000), (2, 230000), (3, 220000);
How many streams did the 2021 album release 'Sour' by Olivia Rodrigo receive in its first week?
SELECT streams_in_week FROM sour_streams WHERE week = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE peacekeeping_operations_continents (id INT, operation VARCHAR(50), continent VARCHAR(50)); INSERT INTO peacekeeping_operations_continents (id, operation, continent) VALUES (1, 'Operation United Nations Mission in South Sudan', 'Africa'), (2, 'Operation United Nations Assistance Mission in Somalia', 'Africa'), (3, 'Operation United Nations Multidimensional Integrated Stabilization Mission in Mali', 'Africa'), (4, 'Operation United Nations Peacekeeping Force in Cyprus', 'Europe'), (5, 'Operation United Nations Disengagement Observer Force', 'Asia'), (6, 'Operation United Nations Mission in the Republic of South Sudan', 'Africa'), (7, 'Operation United Nations Mission in Liberia', 'Africa');
What is the total number of peacekeeping operations in each continent, ordered by the number of operations in descending order?
SELECT continent, COUNT(operation) as total_operations FROM peacekeeping_operations_continents GROUP BY continent ORDER BY total_operations DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE investments (id INT, category VARCHAR(255), date DATE, amount FLOAT); INSERT INTO investments (id, category, date, amount) VALUES (1, 'gender diversity', '2021-02-15', 10000), (2, 'renewable energy', '2020-12-21', 15000), (3, 'gender diversity', '2021-04-03', 13000);
What is the average investment amount in the gender diversity category for the past year?
SELECT AVG(amount) FROM investments WHERE category = 'gender diversity' AND date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE vessel_loading (vessel_type VARCHAR(50), loading_date DATE, total_containers INT); INSERT INTO vessel_loading VALUES ('VesselA', '2022-02-01', 500), ('VesselA', '2022-02-02', 600), ('VesselB', '2022-02-01', 700), ('VesselB', '2022-02-02', 800), ('VesselC', '2022-02-01', 800), ('VesselC', '2022-02-02', 900);
What is the total number of containers loaded on vessels in February 2022?
SELECT vessel_type, SUM(total_containers) FROM vessel_loading WHERE EXTRACT(MONTH FROM loading_date) = 2 AND EXTRACT(YEAR FROM loading_date) = 2022 GROUP BY vessel_type;
gretelai_synthetic_text_to_sql
CREATE TABLE Policyholders (PolicyID INT, PolicyholderName TEXT, State TEXT); INSERT INTO Policyholders (PolicyID, PolicyholderName, State) VALUES (1, 'John Smith', 'GA'), (2, 'Jane Doe', 'NY'); CREATE TABLE Claims (ClaimID INT, PolicyID INT, ClaimAmount INT); INSERT INTO Claims (ClaimID, PolicyID, ClaimAmount) VALUES (1, 1, 5000), (2, 1, 3000), (3, 2, 7000);
Find policyholders in 'GA' who have not filed any claims.
SELECT Policyholders.* FROM Policyholders LEFT JOIN Claims ON Policyholders.PolicyID = Claims.PolicyID WHERE Claims.PolicyID IS NULL AND Policyholders.State = 'GA';
gretelai_synthetic_text_to_sql
CREATE TABLE tram_rides(ride_date DATE, revenue FLOAT); INSERT INTO tram_rides (ride_date, revenue) VALUES ('2022-01-01', 3000), ('2022-01-02', 3200);
What is the daily revenue for tram rides in Madrid?
SELECT ride_date, SUM(revenue) AS daily_revenue FROM tram_rides GROUP BY ride_date;
gretelai_synthetic_text_to_sql
CREATE TABLE MilitaryExpenditure (id INT, country VARCHAR(255), military_expenditure DECIMAL(10,2), gdp DECIMAL(10,2)); INSERT INTO MilitaryExpenditure (id, country, military_expenditure, gdp) VALUES (1, 'Country1', 0.15, 50000000), (2, 'Country2', 0.20, 60000000), (3, 'Country3', 0.10, 40000000), (4, 'Country4', 0.12, 45000000);
What are the top 3 countries with the highest military expenditure as a percentage of GDP?
SELECT country FROM (SELECT country, ROW_NUMBER() OVER (ORDER BY (military_expenditure / gdp) DESC) AS rank FROM MilitaryExpenditure) AS ranked_military_expenditure WHERE rank <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE energy_efficiency (year INT, region VARCHAR(255), rating FLOAT); INSERT INTO energy_efficiency (year, region, rating) VALUES (2021, 'North America', 80), (2021, 'South America', 70), (2022, 'North America', 85);
What was the average energy efficiency rating in North America in 2021?
SELECT AVG(rating) FROM energy_efficiency WHERE year = 2021 AND region = 'North America'
gretelai_synthetic_text_to_sql
CREATE TABLE WastewaterTreatmentPlants (Id INT, Name VARCHAR(100), Location VARCHAR(100), Capacity INT, AnnualTreatmentVolume INT); INSERT INTO WastewaterTreatmentPlants (Id, Name, Location, Capacity, AnnualTreatmentVolume) VALUES (1, 'Plant A', 'City1', 50000, 45000); INSERT INTO WastewaterTreatmentPlants (Id, Name, Location, Capacity, AnnualTreatmentVolume) VALUES (2, 'Plant B', 'City2', 75000, 67000); INSERT INTO WastewaterTreatmentPlants (Id, Name, Location, Capacity, AnnualTreatmentVolume) VALUES (3, 'Plant C', 'Region1', 60000, 54000); INSERT INTO WastewaterTreatmentPlants (Id, Name, Location, Capacity, AnnualTreatmentVolume) VALUES (4, 'Plant D', 'Region1', 45000, 42000);
How many wastewater treatment plants are there in Region1 with a capacity greater than 50000?
SELECT COUNT(*) FROM WastewaterTreatmentPlants WHERE Location = 'Region1' AND Capacity > 50000;
gretelai_synthetic_text_to_sql
CREATE TABLE RenewableEnergy (factory VARCHAR(50), energy_source VARCHAR(50)); INSERT INTO RenewableEnergy VALUES ('Factory1', 'Renewable'), ('Factory2', 'Non-Renewable'), ('Factory3', 'Renewable'), ('Factory4', 'Non-Renewable');
How many garment factories in Ethiopia use renewable energy?
SELECT COUNT(*) FROM RenewableEnergy WHERE energy_source = 'Renewable' AND factory LIKE '%Ethiopia%';
gretelai_synthetic_text_to_sql
indigenous_communities (community_id, community_name, location_id, population, language_family)
Add new indigenous community record
INSERT INTO indigenous_communities (community_id, community_name, location_id, population, language_family)
gretelai_synthetic_text_to_sql
CREATE TABLE Companies (id INT, name TEXT, country TEXT); INSERT INTO Companies (id, name, country) VALUES (1, 'Eh Inc', 'Canada'); INSERT INTO Companies (id, name, country) VALUES (2, 'Maple Co', 'Canada'); CREATE TABLE Funding (id INT, company_id INT, investor_type TEXT, amount INT); INSERT INTO Funding (id, company_id, investor_type, amount) VALUES (1, 1, 'VC', 6000000); INSERT INTO Funding (id, company_id, investor_type, amount) VALUES (2, 1, 'Angel', 2500000); INSERT INTO Funding (id, company_id, investor_type, amount) VALUES (3, 2, 'Crowdfunding', 1000000);
Find the average funding amount for companies founded in Canada, excluding companies that have received funding from crowdfunding platforms.
SELECT AVG(Funding.amount) FROM Companies INNER JOIN Funding ON Companies.id = Funding.company_id WHERE Companies.country = 'Canada' AND Funding.investor_type != 'Crowdfunding'
gretelai_synthetic_text_to_sql
CREATE TABLE SustainableFabrics (fabric_id INT, fabric_name VARCHAR(50), source_country VARCHAR(50), price DECIMAL(5,2), popularity INT); INSERT INTO SustainableFabrics (fabric_id, fabric_name, source_country, price, popularity) VALUES (1, 'Organic Cotton', 'Brazil', 3.50, 100), (2, 'Recycled Polyester', 'Argentina', 4.25, 75), (3, 'Tencel', 'Peru', 5.00, 90);
What are the top 3 most popular sustainable fabrics among customers in South America?
SELECT fabric_name, popularity FROM SustainableFabrics WHERE source_country = 'South America' ORDER BY popularity DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE public_transportation (transport_mode VARCHAR(50), trips INT);
What is the most popular public transportation mode in Berlin?
SELECT transport_mode, MAX(trips) FROM public_transportation WHERE transport_mode LIKE '%Berlin%' GROUP BY transport_mode;
gretelai_synthetic_text_to_sql
CREATE TABLE projects (id INT, name VARCHAR(255), category VARCHAR(255), budget FLOAT); INSERT INTO projects (id, name, category, budget) VALUES (1, 'Road Reconstruction', 'Transportation', 500000.00);
What is the total budget for projects in the transportation category?
SELECT SUM(budget) FROM projects WHERE category = 'Transportation';
gretelai_synthetic_text_to_sql
CREATE TABLE DefenseDiplomacy (id INT PRIMARY KEY, event VARCHAR(100), country VARCHAR(50), year INT, participants INT); INSERT INTO DefenseDiplomacy (id, event, country, year, participants) VALUES (1, 'Joint Military Exercise', 'Colombia', 2017, 12);
How many defense diplomacy events occurred in South America in 2017?
SELECT COUNT(*) FROM DefenseDiplomacy WHERE country LIKE '%South America%' AND year = 2017;
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (transaction_id INT, customer_id INT, amount DECIMAL(10,2), transaction_date DATE, currency VARCHAR(50)); CREATE VIEW daily_transactions AS SELECT transaction_date, SUM(amount) as total_amount FROM transactions WHERE transaction_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY transaction_date;
What is the total transaction value by currency for each day in the past month?
SELECT dt.transaction_date, t.currency, SUM(t.amount) as currency_total FROM daily_transactions dt INNER JOIN transactions t ON dt.transaction_date = t.transaction_date GROUP BY dt.transaction_date, t.currency;
gretelai_synthetic_text_to_sql
CREATE TABLE hospitals_canada (id INT, name TEXT, budget INT, province TEXT); INSERT INTO hospitals_canada VALUES (1, 'Rural Hospital A', 1000000, 'Alberta'); INSERT INTO hospitals_canada VALUES (2, 'Rural Hospital B', 1500000, 'British Columbia'); CREATE TABLE clinics_canada (id INT, name TEXT, budget INT, province TEXT); INSERT INTO clinics_canada VALUES (1, 'Rural Clinic A', 300000, 'Alberta'); INSERT INTO clinics_canada VALUES (2, 'Rural Clinic B', 400000, 'British Columbia'); INSERT INTO clinics_canada VALUES (3, 'Rural Clinic C', 500000, 'Ontario');
What is the total budget allocated to rural hospitals and clinics in Canada, grouped by province?
SELECT province, SUM(budget) FROM hospitals_canada GROUP BY province UNION SELECT province, SUM(budget) FROM clinics_canada GROUP BY province;
gretelai_synthetic_text_to_sql
CREATE TABLE patients (patient_id INT, age INT, gender TEXT, country TEXT); INSERT INTO patients (patient_id, age, gender, country) VALUES (1, 35, 'Male', 'Australia'); INSERT INTO patients (patient_id, age, gender, country) VALUES (2, 42, 'Female', 'Australia'); CREATE TABLE treatments (treatment_id INT, patient_id INT, treatment_type TEXT, outcome TEXT); INSERT INTO treatments (treatment_id, patient_id, treatment_type, outcome) VALUES (1, 1, 'Support Group', 'Success'); INSERT INTO treatments (treatment_id, patient_id, treatment_type, outcome) VALUES (2, 2, 'Support Group', 'Failure');
What is the success rate of support groups in Australia?
SELECT ROUND(100.0 * COUNT(CASE WHEN outcome = 'Success' THEN 1 END) / COUNT(*), 2) AS success_rate FROM treatments JOIN patients ON patients.patient_id = treatments.patient_id WHERE patients.country = 'Australia' AND treatments.treatment_type = 'Support Group';
gretelai_synthetic_text_to_sql
CREATE TABLE Companies (id INT, name VARCHAR(50), industry VARCHAR(50), country VARCHAR(50), founding_year INT, founder_lgbtqia VARCHAR(10)); INSERT INTO Companies (id, name, industry, country, founding_year, founder_lgbtqia) VALUES (1, 'TechFair', 'Tech', 'USA', 2019, 'Yes'); INSERT INTO Companies (id, name, industry, country, founding_year, founder_lgbtqia) VALUES (2, 'InnoPower', 'Tech', 'USA', 2018, 'No');
How many companies were founded by individuals who identify as LGBTQIA+ each year?
SELECT founding_year, COUNT(*) as lgbtqia_count FROM Companies WHERE founder_lgbtqia = 'Yes' GROUP BY founding_year;
gretelai_synthetic_text_to_sql
CREATE TABLE investments (sector VARCHAR(50), risk_score INT); INSERT INTO investments (sector, risk_score) VALUES ('Education', 3), ('Healthcare', 4), ('Housing', 2), ('Employment', 5), ('Criminal Justice', 3);
What is the average risk score for investments in the healthcare sector?
SELECT AVG(risk_score) as avg_risk_score FROM investments WHERE sector = 'Healthcare';
gretelai_synthetic_text_to_sql
CREATE TABLE investments (id INT, sector VARCHAR(20), amount DECIMAL(10,2)); INSERT INTO investments (id, sector, amount) VALUES (1, 'education', 15000.00), (2, 'poverty reduction', 18000.00), (3, 'education', 22000.00);
What is the average investment size in the poverty reduction sector?
SELECT AVG(amount) FROM investments WHERE sector = 'poverty reduction';
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (id INT, program VARCHAR(255)); INSERT INTO volunteers (id, program) VALUES (1, 'Food Security'), (2, 'Education'), (3, 'Environment');
How many unique volunteers worked on the 'Food Security' and 'Environment' programs?
SELECT COUNT(DISTINCT id) FROM volunteers WHERE program IN ('Food Security', 'Environment');
gretelai_synthetic_text_to_sql
CREATE TABLE circular_economy (city VARCHAR(255), year INT, initiative VARCHAR(255)); INSERT INTO circular_economy (city, year, initiative) VALUES ('Paris', 2017, 'Glass waste recycling program');
Delete the record for circular economy initiative in Paris in 2017.
DELETE FROM circular_economy WHERE city = 'Paris' AND year = 2017;
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (id INT, name TEXT, type TEXT);CREATE TABLE cargoes (id INT, vessel_id INT, tonnage INT); INSERT INTO vessels (id, name, type) VALUES (1, 'Cargo Master', 'Cargo Ship'); INSERT INTO cargoes (id, vessel_id, tonnage) VALUES (1, 1, 10000), (2, 1, 15000);
What is the total tonnage of cargo transported by the 'Cargo Master' vessel in the current year?
SELECT SUM(cargoes.tonnage) FROM cargoes JOIN vessels ON cargoes.vessel_id = vessels.id WHERE vessels.name = 'Cargo Master' AND YEAR(cargoes.id) = YEAR(CURRENT_DATE);
gretelai_synthetic_text_to_sql
CREATE TABLE farm_locations (location VARCHAR, fish_id INT); CREATE TABLE fish_stock (fish_id INT, species VARCHAR, biomass FLOAT); INSERT INTO farm_locations (location, fish_id) VALUES ('Location A', 1), ('Location B', 2), ('Location A', 3), ('Location C', 4); INSERT INTO fish_stock (fish_id, species, biomass) VALUES (1, 'Tilapia', 500.0), (2, 'Salmon', 800.0), (3, 'Trout', 300.0), (4, 'Bass', 700.0);
What is the average biomass of fish for each farming location?
SELECT f.location, AVG(fs.biomass) FROM farm_locations f JOIN fish_stock fs ON f.fish_id = fs.fish_id GROUP BY f.location;
gretelai_synthetic_text_to_sql
CREATE TABLE organization (org_id INT, org_name TEXT); INSERT INTO organization (org_id, org_name) VALUES (1, 'Volunteers Inc'); INSERT INTO organization (org_id, org_name) VALUES (2, 'Helping Hands'); CREATE TABLE volunteer (vol_id INT, vol_name TEXT, org_id INT, vol_email TEXT); INSERT INTO volunteer (vol_id, vol_name, org_id, vol_email) VALUES (1, 'Alice', 1, 'alice@example.com'); INSERT INTO volunteer (vol_id, vol_name, org_id, vol_email) VALUES (2, 'Bob', 1, 'bob@example.com'); INSERT INTO volunteer (vol_id, vol_name, org_id, vol_email) VALUES (3, 'Charlie', 2, 'charlie@example.com');
Delete an organization and all associated volunteers
DELETE FROM volunteer WHERE org_id = 1; DELETE FROM organization WHERE org_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE menu(dish VARCHAR(255), category VARCHAR(255), price DECIMAL(5,2)); INSERT INTO menu(dish, category, price) VALUES ('Tofu Stir Fry', 'Starter', 9.99), ('Lentil Soup', 'Starter', 7.99), ('Chickpea Curry', 'Main', 12.99), ('Tofu Curry', 'Main', 13.99), ('Quinoa Salad', 'Side', 6.99);
Identify dishes with an average price above the overall average price.
SELECT dish, category, price FROM menu WHERE price > (SELECT AVG(price) FROM menu);
gretelai_synthetic_text_to_sql
CREATE TABLE VESSEL_OPERATION (id INT, vessel_name VARCHAR(50), propulsion VARCHAR(50), status VARCHAR(50), timestamp TIMESTAMP);
Determine the percentage of time vessels with diesel engines spend idling
SELECT 100.0 * COUNT(CASE WHEN propulsion = 'diesel' AND status = 'idle' THEN 1 END) / COUNT(*) FROM VESSEL_OPERATION WHERE propulsion = 'diesel';
gretelai_synthetic_text_to_sql
CREATE TABLE SustainableTourismActivities (activity_id INT, activity_name TEXT, country TEXT, local_economic_impact FLOAT); INSERT INTO SustainableTourismActivities (activity_id, activity_name, country, local_economic_impact) VALUES (1, 'Biking Tour', 'Portugal', 12000.0), (2, 'Hiking Adventure', 'Portugal', 15000.0);
List all the sustainable tourism activities in Portugal and their local economic impact.
SELECT * FROM SustainableTourismActivities WHERE country = 'Portugal';
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name VARCHAR(100), sales INT, certification VARCHAR(20)); INSERT INTO products (product_id, product_name, sales, certification) VALUES (1, 'Lipstick A', 5000, 'cruelty-free'), (2, 'Mascara B', 7000, 'not_certified'), (3, 'Foundation C', 8000, 'cruelty-free'); CREATE TABLE countries (country_code CHAR(2), country_name VARCHAR(50)); INSERT INTO countries (country_code, country_name) VALUES ('UK', 'United Kingdom');
What are the sales figures for cruelty-free certified cosmetics in the UK market?
SELECT sales FROM products WHERE certification = 'cruelty-free' AND country_code = 'UK';
gretelai_synthetic_text_to_sql
CREATE TABLE traffic_accidents (id INT, accident_date DATE, city VARCHAR(50)); INSERT INTO traffic_accidents (id, accident_date, city) VALUES (1, '2021-03-15', 'New York'), (2, '2021-06-20', 'New York');
How many traffic accidents occurred in New York in 2021?
SELECT COUNT(*) FROM traffic_accidents WHERE accident_date >= '2021-01-01' AND accident_date < '2022-01-01' AND city = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (DonationID INT, VisitorID INT, Amount DECIMAL(10,2));
What's the maximum donation amount given by a visitor from 'Asia'?
SELECT MAX(d.Amount) FROM Donations d JOIN Visitors v ON d.VisitorID = v.VisitorID WHERE v.Country IN (SELECT CountryName FROM Countries WHERE Region = 'Asia');
gretelai_synthetic_text_to_sql
CREATE TABLE GamePlay (PlayerID INT, GameName VARCHAR(255), Playtime INT); INSERT INTO GamePlay (PlayerID, GameName, Playtime) VALUES (1, 'Cosmic Racers', 120); INSERT INTO GamePlay (PlayerID, GameName, Playtime) VALUES (2, 'Cosmic Racers', 180); CREATE TABLE Players (PlayerID INT, PlayerAge INT, GameName VARCHAR(255)); INSERT INTO Players (PlayerID, PlayerAge, GameName) VALUES (1, 27, 'Cosmic Racers'); INSERT INTO Players (PlayerID, PlayerAge, GameName) VALUES (2, 30, 'Cosmic Racers');
What is the average playtime of 'Cosmic Racers' for players aged 25 or older?
SELECT AVG(GamePlay.Playtime) FROM GamePlay JOIN Players ON GamePlay.PlayerID = Players.PlayerID WHERE Players.PlayerAge >= 25 AND GamePlay.GameName = 'Cosmic Racers';
gretelai_synthetic_text_to_sql
CREATE TABLE investments (id INT, investor_id INT, sector VARCHAR(20), value FLOAT); INSERT INTO investments (id, investor_id, sector, value) VALUES (1, 1, 'Real Estate', 50000.0), (2, 2, 'Real Estate', 75000.0), (3, 3, 'Technology', 60000.0);
What is the total value of investments in the real estate sector?
SELECT SUM(value) FROM investments WHERE sector = 'Real Estate';
gretelai_synthetic_text_to_sql
CREATE TABLE freight_forwarders (freight_forwarder_id INT, name VARCHAR(50));CREATE TABLE forwarder_shipments (shipment_id INT, freight_forwarder_id INT, ship_date DATE); INSERT INTO freight_forwarders (freight_forwarder_id, name) VALUES (1, 'ABC Logistics'), (2, 'XYZ Shipping'), (3, '123 Cargo'); INSERT INTO forwarder_shipments (shipment_id, freight_forwarder_id, ship_date) VALUES (1, 1, '2021-08-01'), (2, 2, '2021-08-03'), (3, 1, '2021-09-05');
Which freight forwarders have not had any shipments in the last 60 days?
SELECT name FROM freight_forwarders LEFT JOIN forwarder_shipments ON freight_forwarders.freight_forwarder_id = forwarder_shipments.freight_forwarder_id WHERE forwarder_shipments.ship_date IS NULL OR forwarder_shipments.ship_date < DATE(NOW()) - INTERVAL 60 DAY;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists water_demand (id INT PRIMARY KEY, city VARCHAR(50), water_demand FLOAT); CREATE TABLE if not exists water_price (id INT PRIMARY KEY, city VARCHAR(50), price FLOAT); CREATE TABLE if not exists water_treatment_plants (id INT PRIMARY KEY, city VARCHAR(50), num_treatment_plants INT); CREATE VIEW if not exists water_demand_price AS SELECT wd.city, wd.water_demand, wp.price FROM water_demand wd JOIN water_price wp ON wd.city = wp.city;
What is the water demand and water price by city, and how many water treatment plants serve each city?
SELECT wdp.city, AVG(wdp.water_demand) as avg_water_demand, AVG(wdp.price) as avg_price, wt.num_treatment_plants FROM water_demand_price wdp JOIN water_treatment_plants wt ON wdp.city = wt.city GROUP BY wt.city;
gretelai_synthetic_text_to_sql
CREATE TABLE SpacecraftVisits (spacecraft_id INT, planet VARCHAR(50), visit_date DATE); CREATE TABLE Spacecraft (id INT, name VARCHAR(50), manufacturer VARCHAR(50)); INSERT INTO Spacecraft (id, name, manufacturer) VALUES (1, 'Voyager 1', 'SpaceCorp'), (2, 'Cassini', 'NASA'), (3, 'InSight', 'JPL'), (4, 'Perseverance', 'NASA');
Identify the spacecraft that have not visited any planet?
SELECT Spacecraft.name FROM Spacecraft LEFT JOIN SpacecraftVisits ON Spacecraft.id = SpacecraftVisits.spacecraft_id WHERE SpacecraftVisits.planet IS NULL;
gretelai_synthetic_text_to_sql
fan_stats; fan_demographics
Show the average amount spent by fans in each city
SELECT city, AVG(total_spent) as avg_spent FROM fan_stats INNER JOIN fan_demographics ON fan_stats.fan_id = fan_demographics.id GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE mining_operations (id INT, mine_name TEXT, location TEXT, material TEXT, quantity INT, date DATE); INSERT INTO mining_operations (id, mine_name, location, material, quantity, date) VALUES (2, 'Silver Ridge', 'Peru', 'silver', 5000, '2019-01-01');
List all mines in Peru that mined silver in 2019
SELECT DISTINCT mine_name FROM mining_operations WHERE material = 'silver' AND location = 'Peru' AND date = '2019-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (vessel_id INT, vessel_name VARCHAR(50), registry VARCHAR(50), capacity INT); INSERT INTO vessels (vessel_id, vessel_name, registry, capacity) VALUES (1, 'CSCL Globe', 'China', 197500), (2, 'OOCL Hong Kong', 'Hong Kong', 210000), (3, 'MSC Maya', 'Panama', 192240);
What is the total cargo capacity for all vessels in the 'vessels' table that have an even ID?
SELECT SUM(capacity) FROM vessels WHERE MOD(vessel_id, 2) = 0;
gretelai_synthetic_text_to_sql