context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE fabric (fabric_id INT, fabric_name VARCHAR(50), origin_country VARCHAR(50), sustainability_rating INT); INSERT INTO fabric (fabric_id, fabric_name, origin_country, sustainability_rating) VALUES (1, 'Cotton', 'India', 85), (2, 'Polyester', 'China', 60), (3, 'Bamboo', 'Bangladesh', 95);
What is the average sustainability rating of fabrics from Bangladesh?
SELECT origin_country, AVG(sustainability_rating) FROM fabric WHERE origin_country = 'Bangladesh';
gretelai_synthetic_text_to_sql
CREATE TABLE Freight_Forwarders (forwarder_id INT, name TEXT); CREATE TABLE Shipments (shipment_id INT, forwarder_id INT, units_shipped INT, destination_country TEXT); INSERT INTO Freight_Forwarders (forwarder_id, name) VALUES (1, 'FF1'), (2, 'FF2'), (3, 'FF3'); INSERT INTO Shipments (shipment_id, forwarder_id, units_s...
Which freight forwarders have not shipped any units to Canada?
SELECT f.name FROM Freight_Forwarders f LEFT JOIN Shipments s ON f.forwarder_id = s.forwarder_id AND s.destination_country = 'Canada' WHERE s.shipment_id IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE MenuItems (id INT, is_vegan BOOLEAN, category VARCHAR(20), sodium INT); INSERT INTO MenuItems (id, is_vegan, category, sodium) VALUES (1, true, 'appetizer', 200), (2, false, 'appetizer', 400), (3, true, 'entree', 300);
What is the maximum sodium content in vegan appetizers?
SELECT MAX(sodium) FROM MenuItems WHERE is_vegan = true AND category = 'appetizer';
gretelai_synthetic_text_to_sql
CREATE TABLE assets (asset_id INT PRIMARY KEY, asset_name VARCHAR(255)); CREATE TABLE threats (threat_id INT PRIMARY KEY, asset_id INT, threat_type VARCHAR(255)); INSERT INTO assets (asset_id, asset_name) VALUES (1, 'Server01'), (2, 'Workstation01'); INSERT INTO threats (threat_id, asset_id, threat_type) VALUES (1, 1, ...
List all assets and their associated threat types from the 'assets' and 'threats' tables
SELECT a.asset_name, t.threat_type FROM assets a LEFT JOIN threats t ON a.asset_id = t.asset_id;
gretelai_synthetic_text_to_sql
CREATE TABLE GenreRevenue (Genre VARCHAR(20), Revenue FLOAT); INSERT INTO GenreRevenue (Genre, Revenue) VALUES ('Pop', '4000000'), ('Rock', '3000000'), ('Jazz', '2500000'), ('Hip Hop', '5000000'), ('R&B', '3500000');
What is the total revenue generated by each genre from digital sales?
SELECT Genre, SUM(Revenue) FROM GenreRevenue GROUP BY Genre;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, DonorName TEXT, Age INT); CREATE TABLE Donations (DonationID INT, DonorID INT, DonationDate DATE, DonationAmount DECIMAL(10,2));
What is the number of donors and total donations for each age group, sorted by the number of donors in descending order?
SELECT D.Age, COUNT(D.DonorID) as NumDonors, SUM(DON.DonationAmount) as TotalDonations FROM Donors D JOIN Donations DON ON D.DonorID = DON.DonorID GROUP BY D.Age ORDER BY NumDonors DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE game_playtime (game_id INT, genre VARCHAR(255), playtime FLOAT); INSERT INTO game_playtime (game_id, genre, playtime) VALUES (1, 'RPG', 50), (2, 'FPS', 30), (3, 'Simulation', 70), (4, 'RPG', 60), (5, 'FPS', 40);
What is the maximum, minimum, and average playtime for each game genre?
SELECT genre, MAX(playtime) as max_playtime, MIN(playtime) as min_playtime, AVG(playtime) as avg_playtime FROM game_playtime GROUP BY genre;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_project (project_id INT, project_name TEXT, project_type TEXT, start_date DATE); INSERT INTO climate_project (project_id, project_name, project_type, start_date) VALUES (1, 'African Solar Farm', 'Mitigation', '2018-01-01');
How many climate mitigation projects were completed in Africa in the last 5 years?
SELECT COUNT(*) FROM climate_project WHERE project_type = 'Mitigation' AND start_date >= DATEADD(year, -5, CURRENT_DATE);
gretelai_synthetic_text_to_sql
CREATE TABLE space_missions (id INT, country VARCHAR(255), spacecraft_model VARCHAR(255));
What is the total number of spacecraft launched per country?
SELECT country, COUNT(DISTINCT spacecraft_model) as total_spacecraft_launched FROM space_missions GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE SCHEMA IF NOT EXISTS rural_development;CREATE TABLE IF NOT EXISTS rural_development.community_development (name VARCHAR(255), location VARCHAR(255));INSERT INTO rural_development.community_development (name, location) VALUES ('youth_center', 'Atlanta'), ('community_garden', 'Boston'), ('cultural_festival', 'New ...
What is the number of community development initiatives in the 'rural_development' schema that have a 'location' starting with the letter 'A' or 'B'?
SELECT COUNT(*) FROM rural_development.community_development WHERE location LIKE 'A%' OR location LIKE 'B%';
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (id INT, name VARCHAR(100), department VARCHAR(50), country VARCHAR(50)); INSERT INTO Employees (id, name, department, country) VALUES (1, 'John Doe', 'IT', 'United States'), (2, 'Jane Smith', 'Marketing', 'Canada'), (3, 'Mike Johnson', 'IT', 'France'), (4, 'Sara Connor', 'HR', 'United States'), ...
List all employees who work in the IT department and are located in France or the United States.
SELECT * FROM Employees WHERE department = 'IT' AND (country = 'France' OR country = 'United States');
gretelai_synthetic_text_to_sql
CREATE TABLE RecycledPolyesterGarments (id INT, production_cost DECIMAL);
What is the minimum production cost of recycled polyester garments?
SELECT MIN(production_cost) FROM RecycledPolyesterGarments;
gretelai_synthetic_text_to_sql
CREATE TABLE players (id INT PRIMARY KEY, name VARCHAR(50), age INT, country VARCHAR(50)); INSERT INTO players (id, name, age, country) VALUES (1, 'John Doe', 25, 'USA'); INSERT INTO players (id, name, age, country) VALUES (2, 'Jane Smith', 30, 'Canada'); INSERT INTO players (id, name, age, country) VALUES (3, 'Marcos ...
Show the number of players from each country
SELECT country, COUNT(*) as num_players FROM players GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE diversity_metrics (id INT, company_id INT, year INT, gender_distribution TEXT, racial_distribution TEXT); INSERT INTO diversity_metrics (id, company_id, year, gender_distribution, racial_distribution) VALUES (1, 1, 2020, '...', '...');
Delete records of diversity metrics that are outdated or incomplete for companies in the e-commerce sector.
DELETE FROM diversity_metrics WHERE company_id IN (SELECT id FROM company WHERE industry = 'E-commerce') AND (year < 2018 OR gender_distribution IS NULL OR racial_distribution IS NULL);
gretelai_synthetic_text_to_sql
CREATE TABLE AISafety (id INT, concern VARCHAR(255), explainability_score DECIMAL(5,2), region VARCHAR(255)); INSERT INTO AISafety (id, concern, explainability_score, region) VALUES (1, 'Data Privacy', 78.91, 'North America'), (2, 'Unintended Consequences', 65.23, 'Africa'), (3, 'Bias', 82.34, 'North America'), (4, 'Tr...
What is the explainability score for each AI safety concern in North America?
SELECT concern, AVG(explainability_score) as avg_explainability_score FROM AISafety WHERE region = 'North America' GROUP BY concern;
gretelai_synthetic_text_to_sql
CREATE TABLE animal_population (id INT, animal_species VARCHAR(255), animal_age VARCHAR(255)); INSERT INTO animal_population (id, animal_species, animal_age) VALUES (1, 'Giraffe', 'Juvenile'), (2, 'Giraffe', 'Adult'), (3, 'Giraffe', 'Adult'), (4, 'Zebra', 'Juvenile'), (5, 'Zebra', 'Adult'), (6, 'Lion', 'Senior'), (7, '...
Determine the number of animals in the animal population data, ranked in descending order.
SELECT animal_species, COUNT(*) AS animal_count, ROW_NUMBER() OVER (ORDER BY COUNT(*) DESC) AS rank FROM animal_population GROUP BY animal_species;
gretelai_synthetic_text_to_sql
CREATE TABLE court_types (court_type_id INT, court_type_name VARCHAR(20)); INSERT INTO court_types VALUES (1, 'Community'), (2, 'Juvenile'), (3, 'Traffic'), (4, 'Civil');
How many cases were heard in each court type in each state?
SELECT ct.court_type_name, cc.court_state, COUNT(cc.case_id) FROM court_types ct INNER JOIN community_courts cc ON ct.court_type_id = cc.court_type_id INNER JOIN court_cases cc ON cc.court_id = cc.court_id GROUP BY ct.court_type_name, cc.court_state;
gretelai_synthetic_text_to_sql
CREATE TABLE Circular_Economy (id INT, factory_id INT, implemented BOOLEAN); INSERT INTO Circular_Economy (id, factory_id, implemented) VALUES (1, 1001, TRUE), (2, 1002, FALSE);
How many factories have implemented a circular economy model in their production processes?
SELECT COUNT(*) FROM Circular_Economy WHERE implemented = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE co_ownership (id INT, address VARCHAR(255), city VARCHAR(255), state VARCHAR(255), co_owner_1 VARCHAR(255), co_owner_2 VARCHAR(255)); INSERT INTO co_ownership (id, address, city, state, co_owner_1, co_owner_2) VALUES (1, '456 Oak St', 'Austin', 'TX', 'John Doe', 'Jane Smith'), (2, '135 Palm Ave', 'Los Ange...
List the addresses and co-owner names from the 'co_ownership' table where the state is 'CA'.
SELECT address, co_owner_1, co_owner_2 FROM co_ownership WHERE state = 'CA';
gretelai_synthetic_text_to_sql
CREATE TABLE tea_regions (region VARCHAR(50), avg_precipitation FLOAT, year INT); INSERT INTO tea_regions (region, avg_precipitation, year) VALUES ('Nuwara Eliya', 2500, 2010), ('Kandy', 2000, 2010);
What were the average annual precipitation amounts for tea-growing regions in Sri Lanka between 2010 and 2020?
SELECT region, AVG(avg_precipitation) FROM tea_regions WHERE year BETWEEN 2010 AND 2020 GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE game_scores (id INT PRIMARY KEY, player_id INT, game_name VARCHAR(100), score INT); INSERT INTO game_scores VALUES (1, 1001, 'GameA', 5000), (2, 1002, 'GameB', 7000), (3, 1003, 'GameA', 3000), (4, 1004, 'GameB', 7500), (5, 1001, 'GameA', 5500), (6, 1005, 'GameC', 8000); CREATE VIEW top_scores AS SELECT pla...
Show player names with the highest score for each game
SELECT players.name, top_scores.game_name, top_scores.score FROM players JOIN top_scores ON players.id = top_scores.player_id;
gretelai_synthetic_text_to_sql
CREATE TABLE movie_budgets (id INT, title VARCHAR(255), release_decade INT, budget INT); INSERT INTO movie_budgets (id, title, release_decade, budget) VALUES (1, 'Movie4', 2010, 1500000), (2, 'Movie5', 2000, 800000), (3, 'Movie6', 2020, 2000000);
What is the average production budget for movies by release decade?
SELECT release_decade, AVG(budget) as avg_budget FROM movie_budgets GROUP BY release_decade;
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (DonationID INT, DonationDate DATE, DonationAmount DECIMAL, Program TEXT); INSERT INTO Donations (DonationID, DonationDate, DonationAmount, Program) VALUES (1, '2021-01-01', 100.00, 'Feeding Program'), (2, '2021-01-02', 200.00, 'Education Program'), (3, '2021-01-03', 150.00, 'Feeding Program'), (...
What is the average donation per day for a specific program?
SELECT Program, AVG(DonationAmount) AS AvgDonationPerDay FROM Donations WHERE DonationDate BETWEEN '2021-01-01' AND '2021-01-05' GROUP BY Program, DATE_TRUNC('day', DonationDate);
gretelai_synthetic_text_to_sql
CREATE TABLE ebp_initiatives (id INT, name VARCHAR(255), region VARCHAR(255)); INSERT INTO ebp_initiatives (id, name, region) VALUES (1, 'Initiative 1', 'EU'), (2, 'Initiative 2', 'EU'), (3, 'Initiative 3', 'EU');
What is the total number of evidence-based policy making initiatives in the European Union?
SELECT COUNT(*) FROM ebp_initiatives WHERE region = 'EU';
gretelai_synthetic_text_to_sql
CREATE TABLE permit_labor_cost (permit_id INT, city VARCHAR(50), labor_cost DECIMAL(10,2), application_date DATE); INSERT INTO permit_labor_cost (permit_id, city, labor_cost, application_date) VALUES (1, 'San Francisco', 55000.00, '2022-06-15'), (2, 'Los Angeles', 65000.00, '2022-05-01'), (3, 'San Diego', 47000.00, '20...
Identify the building permit applications that have a higher labor cost than the average labor cost for their respective city.
SELECT permit_id, city, labor_cost FROM (SELECT permit_id, city, labor_cost, AVG(labor_cost) OVER (PARTITION BY city) as avg_labor_cost FROM permit_labor_cost) t WHERE labor_cost > avg_labor_cost;
gretelai_synthetic_text_to_sql
CREATE TABLE Companies (id INT, name TEXT, industry TEXT, founders INT, diversity TEXT); INSERT INTO Companies (id, name, industry, founders, diversity) VALUES (1, 'MedHealth', 'Healthcare', 2, 'Diverse Team'); INSERT INTO Companies (id, name, industry, founders, diversity) VALUES (2, 'TechBoost', 'Technology', 1, 'Non...
What is the total number of founders for companies founded by people from underrepresented communities in the healthcare sector?
SELECT SUM(founders) FROM Companies WHERE industry = 'Healthcare' AND diversity = 'Diverse Team';
gretelai_synthetic_text_to_sql
CREATE TABLE sales_revenue (drug VARCHAR(20), country VARCHAR(20), date DATE, revenue NUMERIC(12, 2)); INSERT INTO sales_revenue (drug, country, date, revenue) VALUES ('DrugA', 'USA', '2022-07-01', 500000.00), ('DrugB', 'USA', '2022-07-01', 600000.00), ('DrugA', 'Canada', '2022-07-01', 450000.00), ('DrugB', 'Canada', '...
What was the sales revenue for each drug in Q3 2022, pivoted by country?
SELECT drug, SUM(CASE WHEN country = 'USA' THEN revenue ELSE 0 END) AS usa_revenue, SUM(CASE WHEN country = 'Canada' THEN revenue ELSE 0 END) AS canada_revenue FROM sales_revenue WHERE date BETWEEN '2022-07-01' AND '2022-09-30' GROUP BY drug;
gretelai_synthetic_text_to_sql
CREATE TABLE Sustainable_Practices (Project_ID INT, Practice_Type VARCHAR(50), Start_Date DATE, End_Date DATE, Cost FLOAT);
How many sustainable practices were implemented in Texas between 2020 and 2022?
SELECT COUNT(*) FROM Sustainable_Practices WHERE Practice_Type = 'Solar' AND State = 'TX' AND Start_Date BETWEEN '2020-01-01' AND '2022-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE explainable_ai (id INT, method VARCHAR(20), technique VARCHAR(30), description TEXT);
Insert new records into the 'explainable_ai' table for 'SHAP' method
INSERT INTO explainable_ai (id, method, technique, description) VALUES (1, 'SHAP', 'Model Explanation', 'SHapley Additive exPlanations'), (2, 'SHAP', 'Feature Importance', 'SHapley Feature Importance');
gretelai_synthetic_text_to_sql
CREATE TABLE mining_sites (id INT, name VARCHAR(255), country VARCHAR(255), water_usage INT); INSERT INTO mining_sites (id, name, country, water_usage) VALUES (1, 'Site A', 'Canada', 75), (2, 'Site B', 'Mexico', 85), (3, 'Site C', 'Brazil', 95);
What is the average water usage score for each mining site, grouped by country?
SELECT country, AVG(water_usage) AS avg_water_usage FROM mining_sites GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE creators (id INT PRIMARY KEY, name TEXT, gender TEXT); INSERT INTO creators (id, name, gender) VALUES (1, 'Alice', 'Female'), (2, 'Brian', 'Male'), (3, 'Carla', 'Female');
Update the gender of creators in the 'creators' table.
UPDATE creators SET gender = 'Non-binary' WHERE name = 'Carla';
gretelai_synthetic_text_to_sql
CREATE TABLE clients (id INT, credit_score INT, registered_date DATE);CREATE TABLE investments (id INT, client_id INT, investment_date DATE); INSERT INTO clients (id, credit_score, registered_date) VALUES (1, 750, '2020-01-01'), (2, 650, '2019-01-01'), (3, 800, '2018-01-01'), (4, 700, '2017-01-01'), (5, 600, '2016-01-0...
What is the minimum credit score of clients who have made an investment in the past month?
SELECT MIN(credit_score) FROM clients c JOIN investments i ON c.id = i.client_id WHERE i.investment_date >= c.registered_date + INTERVAL '1 month';
gretelai_synthetic_text_to_sql
CREATE TABLE DigitalAssets (AssetID int, AssetName varchar(50), LaunchDate date); INSERT INTO DigitalAssets (AssetID, AssetName, LaunchDate) VALUES (1, 'Asset1', '2022-03-01'), (2, 'Asset2', '2022-02-01'), (3, 'Asset3', '2022-01-01');
Find the digital assets that were launched earliest, along with the country they were launched in, in ascending order.
SELECT AssetName, Country, LaunchDate FROM (SELECT AssetName, Country, LaunchDate, ROW_NUMBER() OVER (ORDER BY LaunchDate ASC) as Rank FROM DigitalAssets) as RankedAssets WHERE Rank = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE forest_carbon_seq (id INT, region VARCHAR(20), year INT, carbon_value FLOAT);
How many temperate and tropical forests have experienced a decrease in carbon sequestration values in the last 5 years?
SELECT region, COUNT(*) as num_forests FROM forest_carbon_seq WHERE region IN ('Temperate', 'Tropical') AND carbon_value < (SELECT carbon_value FROM forest_carbon_seq WHERE region = t.region AND year = t.year - 5) GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (id INT, name VARCHAR(50), registered_date DATE); INSERT INTO Volunteers (id, name, registered_date) VALUES (1, 'John Doe', '2021-01-01'), (2, 'Jane Smith', '2021-02-01');
Who are the volunteers registered in the 'Volunteers' table in January 2021?
SELECT * FROM Volunteers WHERE registered_date BETWEEN '2021-01-01' AND '2021-01-31'
gretelai_synthetic_text_to_sql
CREATE TABLE smart_contracts (smart_contract_id INT, name VARCHAR(255), version VARCHAR(255), last_updated DATE, retired VARCHAR(255));
Delete smart contracts from the 'smart_contracts' table that have not been updated in the last 2 years and are not marked as 'retired'.
DELETE FROM smart_contracts WHERE last_updated < (CURRENT_DATE - INTERVAL '2 years') AND retired <> 'yes';
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (VolunteerID INT, SignUpDate DATE);
How many volunteers signed up in the 'Volunteers' table in 2022?
SELECT COUNT(*) FROM Volunteers WHERE YEAR(SignUpDate) = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE ethical_labor_practices( practice_id INT PRIMARY KEY, supplier_id INT, description TEXT, certified_by VARCHAR(255));
Create a table named 'ethical_labor_practices'
CREATE TABLE ethical_labor_practices( practice_id INT PRIMARY KEY, supplier_id INT, description TEXT, certified_by VARCHAR(255));
gretelai_synthetic_text_to_sql
CREATE TABLE bus_distances (id INT, trip_date DATE, distance DECIMAL(5,2)); INSERT INTO bus_distances (id, trip_date, distance) VALUES (1, '2022-01-01', 25.0), (2, '2022-01-01', 30.0), (3, '2022-01-02', 20.0);
What is the average distance traveled by bus per day, partitioned by week and ranked by the longest distance?
SELECT AVG(distance) OVER (PARTITION BY DATEPART(wk, trip_date) ORDER BY distance DESC) as avg_distance, trip_date FROM bus_distances WHERE trip_date >= DATEADD(day, -365, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE investors (investor_id INT, investor_name TEXT); CREATE TABLE investments (investment_id INT, investor_id INT, invested_amount INT);
Identify investors with the highest and lowest total investments in the education sector.
SELECT investor_name, SUM(invested_amount) AS total_investment FROM investments i JOIN investors j ON i.investor_id = j.investor_id WHERE i.sector = 'education' GROUP BY investor_id ORDER BY total_investment DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (id INT, name VARCHAR(100), region VARCHAR(50), assets_value FLOAT); INSERT INTO customers (id, name, region, assets_value) VALUES (1, 'John Doe', 'Greater China', 500000.00);
What is the total assets value for all customers from 'Greater China' region?
SELECT SUM(assets_value) FROM customers WHERE region = 'Greater China';
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, PlayerName VARCHAR(100), Team VARCHAR(100), HomeRuns INT); INSERT INTO Players (PlayerID, PlayerName, Team, HomeRuns) VALUES (1, 'Aaron Judge', 'New York Yankees', 52), (2, 'Mookie Betts', 'Los Angeles Dodgers', 39), (3, 'Fernando Tatis Jr.', 'San Diego Padres', 42);
What is the average number of home runs hit by each player in the MLB?
SELECT Team, AVG(HomeRuns) as AvgHomeRuns FROM Players GROUP BY Team;
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_projects (id INT, project_name TEXT, location TEXT, installed_capacity INT);
What is the maximum installed capacity (in MW) of a renewable energy project in Australia?
SELECT MAX(renewable_projects.installed_capacity) FROM renewable_projects WHERE renewable_projects.location = 'Australia';
gretelai_synthetic_text_to_sql
CREATE SCHEMA IF NOT EXISTS defense_security;CREATE TABLE IF NOT EXISTS defense_security.Worldwide_Naval_Bases (id INT PRIMARY KEY, base_name VARCHAR(255), location VARCHAR(255), type VARCHAR(255));INSERT INTO defense_security.Worldwide_Naval_Bases (id, base_name, location, type) VALUES (1, 'Pearl Harbor', 'Hawaii', 'N...
What is the name of the naval base located in Hawaii in the 'Worldwide_Naval_Bases' table?
SELECT base_name FROM defense_security.Worldwide_Naval_Bases WHERE location = 'Hawaii';
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, project_type VARCHAR(50), donation_amount DECIMAL(10,2), donation_date DATE); INSERT INTO donations (id, project_type, donation_amount, donation_date) VALUES (1, 'Community Development', 100.00, '2022-01-01'), (2, 'Disaster Response', 150.00, '2022-02-15'), (3, 'Community Development', 2...
What was the total amount of donations received by each project type in 2022?
SELECT project_type, SUM(donation_amount) as total_donations FROM donations WHERE donation_date BETWEEN '2022-01-01' AND '2022-12-31' GROUP BY project_type;
gretelai_synthetic_text_to_sql
CREATE TABLE lead_times (id INT, material VARCHAR(20), lead_time INT); INSERT INTO lead_times (id, material, lead_time) VALUES (1, 'Vegan Leather', 30), (2, 'Synthetic Leather', 25), (3, 'Vegan Leather', 35);
What is the minimum lead time for orders involving vegan leather materials?
SELECT MIN(lead_time) FROM lead_times WHERE material = 'Vegan Leather';
gretelai_synthetic_text_to_sql
CREATE TABLE MissionData (MissionID INT, Agency VARCHAR(50), Status VARCHAR(50), Duration INT);
List the number of completed missions and total mission duration (in days) for each space agency.
SELECT MissionData.Agency, COUNT(MissionData.MissionID) as CompletedMissions, SUM(MissionData.Duration) as TotalMissionDurationInDays FROM MissionData WHERE MissionData.Status = 'Completed' GROUP BY MissionData.Agency;
gretelai_synthetic_text_to_sql
CREATE TABLE energy_storage_technology (technology VARCHAR(255), capacity FLOAT); INSERT INTO energy_storage_technology (technology, capacity) VALUES ('Lithium-ion', 18000.0), ('Flow', 25000.1), ('Sodium-ion', 32000.2), ('Lead-acid', 15000.3), ('Flywheel', 12000.4);
What is the total energy storage capacity by technology in 2030, sorted by capacity?
SELECT technology, capacity FROM energy_storage_technology ORDER BY capacity DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE company_production (company VARCHAR(255), oil_production FLOAT, gas_production FLOAT);
Determine the total oil and gas production for each company in the Marcellus Shale.
SELECT company, SUM(oil_production) AS total_oil_production, SUM(gas_production) AS total_gas_production FROM company_production WHERE region = 'Marcellus Shale' GROUP BY company;
gretelai_synthetic_text_to_sql
CREATE TABLE food_inspections (restaurant_id INT, inspection_date DATE);
Insert a new record into the food_inspections table for restaurant_id 789 with inspection_date set to '2022-05-15'
INSERT INTO food_inspections (restaurant_id, inspection_date) VALUES (789, '2022-05-15');
gretelai_synthetic_text_to_sql
CREATE TABLE socially_responsible_lending(customer_id INT, name VARCHAR(50), gender VARCHAR(10), country VARCHAR(50), account_balance DECIMAL(10, 2)); INSERT INTO socially_responsible_lending VALUES (1, 'John Doe', 'Male', 'USA', 5000), (2, 'Jane Smith', 'Female', 'Canada', 7000), (3, 'Ali Hassan', 'Male', 'Pakistan', ...
Identify the top 3 countries with the highest average account balance for socially responsible lending customers.
SELECT country, AVG(account_balance) AS avg_balance FROM socially_responsible_lending GROUP BY country ORDER BY avg_balance DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE wells (well_id INT, well_type VARCHAR(10), location VARCHAR(20), production_rate FLOAT); INSERT INTO wells (well_id, well_type, location, production_rate) VALUES (1, 'offshore', 'Gulf of Mexico', 1000), (2, 'onshore', 'Texas', 800), (3, 'offshore', 'North Sea', 1200), (4, 'onshore', 'Alberta', 400);
Delete wells with production rates below 500.
DELETE FROM wells WHERE production_rate < 500;
gretelai_synthetic_text_to_sql
CREATE TABLE tourists (tourist_id INT, name TEXT, country TEXT, visited_year INT, destination TEXT); INSERT INTO tourists (tourist_id, name, country, visited_year, destination) VALUES (1, 'Jane Smith', 'Canada', 2020, 'Paris'), (2, 'John Doe', 'Mexico', 2020, 'Rome'); CREATE TABLE destinations (destination TEXT, popula...
How many tourists visited the top 3 most popular destinations in 2020?
SELECT COUNT(*) FROM tourists t JOIN destinations d ON t.destination = d.destination WHERE visited_year = 2020 AND d.popularity BETWEEN 1 AND 3;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists research;CREATE TABLE if not exists research.projects (id INT, name VARCHAR(50), country VARCHAR(50)); INSERT INTO research.projects (id, name, country) VALUES (1, 'ProjectX', 'UK'), (2, 'ProjectY', 'Germany'), (3, 'ProjectZ', 'UK'), (4, 'ProjectA', 'USA');
Identify the number of genetic research projects in the UK and Germany.
SELECT COUNT(*), country FROM research.projects WHERE country IN ('UK', 'Germany') GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE Properties (PropertyID int, Price int, SustainabilityRating int, Borough varchar(255)); INSERT INTO Properties (PropertyID, Price, SustainabilityRating, Borough) VALUES (1, 500000, 3, 'Bronx');
How many properties in the Bronx have a SustainabilityRating of at least 2?
SELECT COUNT(*) as PropertyCount FROM Properties WHERE Borough = 'Bronx' AND SustainabilityRating >= 2;
gretelai_synthetic_text_to_sql
CREATE TABLE orders (order_id INT, menu_item_id INT, location VARCHAR(255), order_date DATE); INSERT INTO orders VALUES (1, 1, 'NYC', '2022-03-01'), (2, 2, 'LA', '2022-03-02'), (3, 3, 'NYC', '2022-03-03'), (4, 1, 'LA', '2022-03-04'); CREATE TABLE menu_items (menu_item_id INT, sustainable_ingredients INT, dish_name VARC...
List the top 5 most frequently ordered sustainable menu items for each location in the past month.
SELECT o1.location, m1.menu_item_id, m1.dish_name, COUNT(o1.order_id) AS order_count FROM orders o1 INNER JOIN (SELECT menu_item_id, dish_name FROM menu_items WHERE sustainable_ingredients > 0) m1 ON o1.menu_item_id = m1.menu_item_id WHERE o1.order_date > DATEADD(day, -30, GETDATE()) GROUP BY o1.location, m1.menu_item_...
gretelai_synthetic_text_to_sql
CREATE TABLE EconomicImpact (region VARCHAR(50), impact FLOAT, type VARCHAR(50)); INSERT INTO EconomicImpact (region, impact, type) VALUES ('Australia', 500000.00, 'eco-tourism'), ('Australia', 250000.00, 'traditional-tourism');
Determine the total economic impact of eco-tourism in Australia.
SELECT SUM(impact) FROM EconomicImpact WHERE region = 'Australia' AND type = 'eco-tourism';
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, Name VARCHAR(50), Age INT, Game VARCHAR(50)); INSERT INTO Players (PlayerID, Name, Age, Game) VALUES (1, 'Jamal', 22, 'Fortnite'); INSERT INTO Players (PlayerID, Name, Age, Game) VALUES (2, 'Amina', 18, 'Fortnite'); INSERT INTO Players (PlayerID, Name, Age, Game) VALUES (3, 'Peter', ...
Find the average age of players who play 'Fortnite'.
SELECT AVG(Age) FROM Players WHERE Game = 'Fortnite';
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID int, DonorName varchar(50), Country varchar(50)); INSERT INTO Donors (DonorID, DonorName, Country) VALUES (1, 'Sophia Jones', 'United Kingdom'); INSERT INTO Donors (DonorID, DonorName, Country) VALUES (2, 'Liam Thompson', 'France'); INSERT INTO Donors (DonorID, DonorName, Country) VALUES (3...
Show me the number of donations made by each donor in Europe.
SELECT Donors.DonorName, COUNT(Donations.DonationID) as NumberOfDonations FROM Donors INNER JOIN Donations ON Donations.DonorID = Donors.DonorID GROUP BY Donors.DonorName;
gretelai_synthetic_text_to_sql
CREATE TABLE BuildingPermits (id INT, permit_date DATE, state VARCHAR(20)); INSERT INTO BuildingPermits (id, permit_date, state) VALUES (3, '2021-04-01', 'New York'), (4, '2021-06-15', 'New York');
What is the total number of building permits issued in Q2 2021 for New York?
SELECT COUNT(*) FROM BuildingPermits WHERE state = 'New York' AND MONTH(permit_date) BETWEEN 4 AND 6;
gretelai_synthetic_text_to_sql
CREATE TABLE students (student_id INT, disability_type VARCHAR(255)); INSERT INTO students (student_id, disability_type) VALUES (1, 'Visual Impairment'); INSERT INTO students (student_id, disability_type) VALUES (2, 'Mobility Impairment'); CREATE TABLE assistive_technology_usage (student_id INT, date DATE, technology_t...
How many students with visual impairments have utilized assistive technology in the past year?
SELECT COUNT(*) FROM students s JOIN assistive_technology_usage a ON s.student_id = a.student_id WHERE s.disability_type = 'Visual Impairment' AND a.date BETWEEN DATE_SUB(NOW(), INTERVAL 1 YEAR) AND NOW();
gretelai_synthetic_text_to_sql
CREATE TABLE military_personnel (id INT, name VARCHAR(50), country VARCHAR(50), training_history TEXT); INSERT INTO military_personnel (id, name, country, training_history) VALUES (1, 'John Doe', 'China', 'cybersecurity training,2021'); CREATE TABLE countries (id INT, name VARCHAR(50), region VARCHAR(50)); INSERT INTO ...
What is the total number of military personnel from Asian countries who have received cybersecurity training in the past year?
SELECT COUNT(*) FROM military_personnel m JOIN countries c ON m.country = c.name WHERE c.region = 'Asia' AND m.training_history LIKE '%cybersecurity training,2021%';
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists cities (city_id INT, name TEXT, country TEXT); INSERT INTO cities (city_id, name, country) VALUES (1, 'Paris', 'France'); CREATE TABLE if not exists hotels (hotel_id INT, name TEXT, city_id INT, eco_certified BOOLEAN); INSERT INTO hotels (hotel_id, name, city_id, eco_certified) VALUES (1, 'Gr...
How many hotels in Paris, France, have been certified as eco-friendly?
SELECT COUNT(*) FROM hotels JOIN cities ON hotels.city_id = cities.city_id WHERE cities.name = 'Paris' AND hotels.eco_certified = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE players (id INT, name VARCHAR(50), team VARCHAR(50), sport VARCHAR(20)); CREATE TABLE at_bats (player_id INT, result VARCHAR(5)); CREATE TABLE hits (player_id INT, game_id INT);
List the names of baseball players who have a batting average above .300
SELECT players.name FROM players JOIN at_bats ON players.id = at_bats.player_id JOIN hits ON players.id = hits.player_id GROUP BY players.name HAVING (COUNT(hits.player_id) / SUM(at_bats.player_id = players.id)) > 0.3;
gretelai_synthetic_text_to_sql
CREATE TABLE Streams (StreamID INT, Song TEXT, Platform TEXT, Country TEXT); INSERT INTO Streams (StreamID, Song, Platform, Country) VALUES (1, 'Bohemian Rhapsody', 'Spotify', 'Germany'), (2, 'Hotel California', 'Spotify', 'Germany');
How many times has 'Bohemian Rhapsody' by Queen been streamed on Spotify in Germany?
SELECT COUNT(*) FROM Streams WHERE Song = 'Bohemian Rhapsody' AND Platform = 'Spotify' AND Country = 'Germany';
gretelai_synthetic_text_to_sql
CREATE TABLE Vessel_Region (Vessel_ID INT, Region VARCHAR(255)); INSERT INTO Vessel_Region (Vessel_ID, Region) VALUES (1, 'Pacific'), (2, 'Atlantic'), (3, 'Pacific'), (4, 'Atlantic'), (5, 'Indian'), (6, 'Pacific');
List all regions and their corresponding number of vessels.
SELECT Region, COUNT(*) FROM Vessel_Region GROUP BY Region;
gretelai_synthetic_text_to_sql
CREATE TABLE CityProjectOffsets (City VARCHAR(255), ProjectType VARCHAR(255), CarbonOffset INT); INSERT INTO CityProjectOffsets (City, ProjectType, CarbonOffset) VALUES ('NYC', 'Reforestation', 10000), ('LA', 'SoilManagement', 12000), ('Chicago', 'Reforestation', 15000);
What is the total carbon offset by project type and city, ranked by the total carbon offset?
SELECT City, ProjectType, SUM(CarbonOffset) OVER (PARTITION BY City, ProjectType) AS Total_Carbon_Offset FROM CityProjectOffsets ORDER BY Total_Carbon_Offset DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_offsets (country VARCHAR(255), initiative_type VARCHAR(255));
How many carbon offset initiatives were implemented in each country in the 'carbon_offsets' table, grouped by initiative type?
SELECT initiative_type, country, COUNT(*) FROM carbon_offsets GROUP BY initiative_type, country;
gretelai_synthetic_text_to_sql
CREATE TABLE teams (id INT, name TEXT, titles INT, league TEXT); INSERT INTO teams (id, name, titles, league) VALUES (1, 'Team E', 7, 'National'); INSERT INTO teams (id, name, titles, league) VALUES (2, 'Team F', 5, 'National');
Which team has the most titles in the last decade?
SELECT name, MAX(titles) FROM teams WHERE league = 'National' AND last_title_date >= DATE('2011-01-01') GROUP BY name;
gretelai_synthetic_text_to_sql
CREATE TABLE workplace_safety (id INT, sector VARCHAR(50), num_incidents INT); INSERT INTO workplace_safety (id, sector, num_incidents) VALUES (1, 'healthcare', 6); INSERT INTO workplace_safety (id, sector, num_incidents) VALUES (2, 'technology', 3); INSERT INTO workplace_safety (id, sector, num_incidents) VALUES (3, '...
How many workplace safety incidents were reported in the 'manufacturing' sector with more than 3 incidents?
SELECT COUNT(*) FROM workplace_safety WHERE sector = 'manufacturing' GROUP BY sector HAVING COUNT(*) > 3;
gretelai_synthetic_text_to_sql
CREATE TABLE sightings (id INT, species VARCHAR, biome VARCHAR, sighting_count INT);
Count the number of polar bear sightings in the Arctic Ocean.
SELECT species, SUM(sighting_count) as total_sightings FROM sightings WHERE species = 'Polar bear' AND biome = 'Ocean' GROUP BY species;
gretelai_synthetic_text_to_sql
CREATE TABLE project_timeline (project_number INT, state VARCHAR(2), start_date DATE, end_date DATE);
Which construction projects in Florida were delayed and for how long?
SELECT pt.project_number, pt.state, DATEDIFF(pt.end_date, pt.start_date) AS delay_days FROM project_timeline pt WHERE pt.state = 'FL' AND pt.end_date > pt.start_date;
gretelai_synthetic_text_to_sql
CREATE TABLE OilRigs (RigID VARCHAR(10), Location VARCHAR(20), Status VARCHAR(20), Type VARCHAR(10));
Insert new records into 'OilRigs' table for the following data: (RigID, Location, Status, Type) - ('Rig01', 'North Sea', 'Operational', 'Offshore')
INSERT INTO OilRigs (RigID, Location, Status, Type) VALUES ('Rig01', 'North Sea', 'Operational', 'Offshore');
gretelai_synthetic_text_to_sql
CREATE TABLE Movies (id INT, title VARCHAR(255), production_company VARCHAR(255));
What is the distribution of production companies in our movie database?
SELECT production_company, COUNT(*) AS count FROM Movies GROUP BY production_company;
gretelai_synthetic_text_to_sql
CREATE TABLE rural_area_1 (date TEXT, temperature INTEGER); INSERT INTO rural_area_1 (date, temperature) VALUES ('2022-01-01', -5), ('2022-01-02', -3), ('2022-01-03', -4);
What is the minimum temperature in 'rural_area_1' in January?
SELECT MIN(temperature) FROM rural_area_1 WHERE date LIKE '2022-01-%';
gretelai_synthetic_text_to_sql
CREATE TABLE textile_production (id INT, textile_type VARCHAR(255), production_country VARCHAR(255), volume INT); INSERT INTO textile_production (id, textile_type, production_country, volume) VALUES (1, 'silk', 'China', 3000);
Retrieve the next country in textile production volume order, for each textile type.
SELECT production_country, textile_type, volume, LEAD(volume) OVER (PARTITION BY textile_type ORDER BY volume) as next_volume FROM textile_production;
gretelai_synthetic_text_to_sql
CREATE TABLE flu_vaccinations_2 (id INT, patient_id INT, age_group TEXT, region TEXT, vaccine_date DATE); INSERT INTO flu_vaccinations_2 (id, patient_id, age_group, region, vaccine_date) VALUES (1, 123, '0-4', 'Quebec', '2021-04-05');
What is the number of flu vaccinations administered by age group in Quebec in Q2 2021?
SELECT age_group, COUNT(*) as num_vaccinations FROM flu_vaccinations_2 WHERE region = 'Quebec' AND vaccine_date >= '2021-04-01' AND vaccine_date < '2021-07-01' GROUP BY age_group;
gretelai_synthetic_text_to_sql
CREATE TABLE military_tech_categories (id INT, category VARCHAR(30), tech_count INT); INSERT INTO military_tech_categories (id, category, tech_count) VALUES (1, 'Aircraft', 3); INSERT INTO military_tech_categories (id, category, tech_count) VALUES (2, 'Naval', 2);
List the total number of military technologies for each category.
SELECT category, tech_count FROM military_tech_categories;
gretelai_synthetic_text_to_sql
CREATE TABLE voting_data (voter_id INT, name VARCHAR(100), age INT, state VARCHAR(50), registration_date DATE);
Insert a new record for a registered voter with the following details: ID '54321', Name 'John Doe', Age '35', State 'NY', Registration Date '2021-12-31'.
INSERT INTO voting_data (voter_id, name, age, state, registration_date) VALUES (54321, 'John Doe', 35, 'NY', '2021-12-31');
gretelai_synthetic_text_to_sql
CREATE TABLE blockchain_projects (project_id INT, jurisdiction VARCHAR, regulatory_framework VARCHAR);
Which regulatory frameworks are most frequently used in blockchain projects based in the United States?
SELECT regulatory_framework, COUNT(project_id) FROM blockchain_projects WHERE jurisdiction = 'United States' GROUP BY regulatory_framework ORDER BY COUNT(project_id) DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE makeup_sales (product_name TEXT, price DECIMAL(5,2), is_vegan BOOLEAN, sale_country TEXT); INSERT INTO makeup_sales (product_name, price, is_vegan, sale_country) VALUES ('Lipstick', 12.99, true, 'USA'), ('Mascara', 10.99, false, 'USA'), ('Eyeshadow', 18.99, true, 'Canada');
What is the total revenue of makeup products that are vegan-friendly, per country?
SELECT sale_country, SUM(price) FILTER (WHERE is_vegan = true) as vegan_friendly_revenue FROM makeup_sales GROUP BY sale_country;
gretelai_synthetic_text_to_sql
CREATE TABLE Legislator (id INT, name VARCHAR(50), district_number INT, party VARCHAR(10)); INSERT INTO Legislator (id, name, district_number, party) VALUES (1, 'Alice Adams', 1, 'Democrat'), (2, 'Bob Brown', 2, 'Republican'), (3, 'Charlie Davis', 3, 'Independent');
Which district has the most legislators?
SELECT district_number, COUNT(*) FROM Legislator GROUP BY district_number ORDER BY COUNT(*) DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists investments (investment_id INT, region VARCHAR(50), sector VARCHAR(50), amount DECIMAL(10,2), investment_year INT); INSERT INTO investments (investment_id, region, sector, amount, investment_year) VALUES (1, 'USA', 'Technology', 1000000, 2020), (2, 'Canada', 'Renewable Energy', 550000, 2020),...
List the unique sectors with investments greater than $500,000 in 2020.
SELECT DISTINCT sector FROM investments WHERE amount > 500000 AND investment_year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE ResearchStations (station_name varchar(50), region varchar(50), operational_status varchar(50));
What is the total number of research stations in the Arctic region?
SELECT COUNT(DISTINCT station_name) AS total_stations FROM ResearchStations WHERE region LIKE '%Arctic%';
gretelai_synthetic_text_to_sql
CREATE TABLE restorative_justice (id INT, case_id INT, case_type VARCHAR(50), participant_count INT); INSERT INTO restorative_justice (id, case_id, case_type, participant_count) VALUES (1, 1001, 'Mediation', 3), (2, 1002, 'Restorative Circle', 5), (3, 1003, 'Victim Offender Conference', 4);
What is the total number of cases in the 'restorative_justice' table?
SELECT COUNT(*) FROM restorative_justice;
gretelai_synthetic_text_to_sql
CREATE TABLE Project_Timelines (project VARCHAR(50), start_date DATE, end_date DATE);
Which defense projects in the Project_Timelines table have a start date after 2022-01-01 and an end date before 2023-12-31?
SELECT project FROM Project_Timelines WHERE start_date > '2022-01-01' AND end_date < '2023-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE Customers (CustomerID int, Name varchar(50), Division varchar(50)); INSERT INTO Customers (CustomerID, Name, Division) VALUES (1, 'John Doe', 'Banking'), (2, 'Jane Smith', 'Investment'), (3, 'Mike Johnson', 'Banking'); CREATE TABLE Accounts (AccountID int, CustomerID int, Balance decimal(10,2)); INSERT INT...
What is the average balance for clients in the 'Banking' division who have an account with a balance greater than 5000?
SELECT AVG(a.Balance) as AverageBalance FROM Customers c INNER JOIN Accounts a ON c.CustomerID = a.CustomerID WHERE c.Division = 'Banking' AND a.Balance > 5000;
gretelai_synthetic_text_to_sql
CREATE TABLE machinery (id INT PRIMARY KEY, mine_id INT, type VARCHAR(255), purchase_date DATE);
What is the average labor hours for machinery that was purchased after 2016?
SELECT AVG(labor_hours) FROM maintenance_records m JOIN machinery ma ON m.machinery_id = ma.id WHERE YEAR(purchase_date) > 2016;
gretelai_synthetic_text_to_sql
CREATE TABLE Rural_Patients (Patient_ID INT, Age INT, Gender VARCHAR(10), Diagnosis VARCHAR(20)); INSERT INTO Rural_Patients (Patient_ID, Age, Gender, Diagnosis) VALUES (1, 35, 'Male', 'Asthma'); INSERT INTO Rural_Patients (Patient_ID, Age, Gender, Diagnosis) VALUES (2, 42, 'Female', 'Asthma'); CREATE TABLE Asthma_Diag...
What is the average age of patients diagnosed with Asthma in Rural Areas?
SELECT AVG(Rural_Patients.Age) FROM Rural_Patients INNER JOIN Asthma_Diagnosis ON Rural_Patients.Diagnosis = Asthma_Diagnosis.Diagnosis;
gretelai_synthetic_text_to_sql
CREATE TABLE platform_operators (platform_id INT, operator_name VARCHAR(50));
Which companies operate oil platforms in the North Sea?
SELECT DISTINCT oil_platforms.name FROM oil_platforms INNER JOIN platform_operators ON oil_platforms.platform_id = platform_operators.platform_id WHERE platform_operators.operator_name IN (SELECT name FROM companies WHERE region = 'North Sea');
gretelai_synthetic_text_to_sql
CREATE TABLE upskilled_workers (id INT, name TEXT, industry TEXT, salary FLOAT); INSERT INTO upskilled_workers (id, name, industry, salary) VALUES (1, 'Alice', 'textile', 35000.00), (2, 'David', 'textile', 37000.00); CREATE TABLE upskilling_programs (id INT, worker_id INT, program TEXT); INSERT INTO upskilling_programs...
What is the average salary of workers in the textile industry who have completed upskilling programs?
SELECT AVG(salary) FROM upskilled_workers w JOIN upskilling_programs p ON w.id = p.worker_id WHERE w.industry = 'textile' AND program IN ('Automation', 'AI');
gretelai_synthetic_text_to_sql
CREATE TABLE FundingSources (FundingSourceID INT PRIMARY KEY, Name VARCHAR(100), Amount FLOAT, Date DATE); INSERT INTO FundingSources (FundingSourceID, Name, Amount, Date) VALUES (1, 'National Endowment for the Arts', 50000, '2021-12-15'), (2, 'Local Arts Foundation', 25000, '2021-06-20'), (3, 'Private Donor', 10000, '...
Calculate the total funding received in 2021
SELECT SUM(Amount) FROM FundingSources WHERE YEAR(Date) = 2021;
gretelai_synthetic_text_to_sql
USE biotech; CREATE TABLE if not exists patents (id INT, name VARCHAR(255), country VARCHAR(255), filed_date DATE); INSERT INTO patents (id, name, country, filed_date) VALUES (1, 'Patent1', 'India', '2015-01-01'), (2, 'Patent2', 'USA', '2014-01-01'), (3, 'Patent3', 'India', '2017-01-01'), (4, 'Patent4', 'Germany', '201...
How many biosensor technology patents have been filed in India since 2015?
SELECT COUNT(*) FROM patents WHERE country = 'India' AND filed_date >= '2015-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name TEXT, industry TEXT, founders TEXT, funding FLOAT); INSERT INTO companies (id, name, industry, founders, funding) VALUES (1, 'BioLab', 'Biotech', 'Latinx', 5000000.0);
What is the total funding received by companies founded by Latinx individuals in the biotech sector?
SELECT SUM(funding) FROM companies WHERE founders = 'Latinx' AND industry = 'Biotech';
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 SpacecraftVisits (spacecraft_id, planet, visit_date) VALUES (1, 'Jupiter', '2022-09-01'); INSERT INTO SpacecraftVisits (spacecraft_id, planet,...
What is the number of missions to each planet?
SELECT SpacecraftVisits.planet, COUNT(DISTINCT SpacecraftVisits.spacecraft_id) FROM SpacecraftVisits GROUP BY SpacecraftVisits.planet;
gretelai_synthetic_text_to_sql
CREATE TABLE BusinessInclusion (EffortID INT, Effort VARCHAR(50)); CREATE TABLE HealthInclusion (EffortID INT, Effort VARCHAR(50)); INSERT INTO BusinessInclusion VALUES (1, 'Diversity Training'), (2, 'Accessible Spaces'), (3, 'Flexible Work Arrangements'); INSERT INTO HealthInclusion VALUES (2, 'Accessible Spaces'), (3...
Show the inclusion efforts in the Business faculty that are not offered in the Health faculty.
SELECT Effort FROM BusinessInclusion WHERE Effort NOT IN (SELECT Effort FROM HealthInclusion);
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_capacity (country VARCHAR(255), solar INT, wind INT, hydro INT); INSERT INTO renewable_capacity (country, solar, wind, hydro) VALUES ('Brazil', 15000, 12000, 25000); INSERT INTO renewable_capacity (country, solar, wind, hydro) VALUES ('India', 20000, 8000, 18000);
What is the total installed renewable energy capacity for 'Brazil' and 'India' from the 'renewable_capacity' table?
SELECT country, solar + wind + hydro AS total_capacity FROM renewable_capacity WHERE country IN ('Brazil', 'India');
gretelai_synthetic_text_to_sql
CREATE TABLE ev_sales (country TEXT, year INT, units INT); INSERT INTO ev_sales (country, year, units) VALUES ('Japan', 2018, 20000), ('Japan', 2018, 22000), ('Japan', 2019, 25000), ('Japan', 2019, 28000), ('Indonesia', 2018, 1000), ('Indonesia', 2018, 1500), ('Indonesia', 2019, 1200), ('Indonesia', 2019, 1700);
What is the total number of electric vehicles (units) sold in Japan and Indonesia, for the years 2018 and 2019?
SELECT country, SUM(units) FROM ev_sales WHERE country IN ('Japan', 'Indonesia') AND year IN (2018, 2019) GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE music_events (id INT, visitor_age INT); INSERT INTO music_events VALUES (1, 30);
What is the average age of visitors who attended music events?
SELECT AVG(music_events.visitor_age) FROM music_events WHERE music_events.id IN (SELECT e.id FROM events e WHERE e.category = 'Music');
gretelai_synthetic_text_to_sql
CREATE TABLE ArtEvents (Id INT PRIMARY KEY, Title VARCHAR(100), Date DATE, MuseumId INT, FOREIGN KEY (MuseumId) REFERENCES Museums(Id)); INSERT INTO ArtEvents (Id, Title, Date, MuseumId) VALUES (1, 'Art Night', '2022-12-10', 1);
How many art events were held in the second half of the month (days 16-31) for museums located in Paris?
SELECT SUM(CASE WHEN EXTRACT(DAY FROM Date) BETWEEN 16 AND 31 THEN 1 ELSE 0 END) FROM ArtEvents WHERE MuseumId IN (SELECT Id FROM Museums WHERE City = 'Paris');
gretelai_synthetic_text_to_sql