context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE companies (company_id INT, sector VARCHAR(50), esg_score FLOAT); INSERT INTO companies (company_id, sector, esg_score) VALUES (1, 'Healthcare', 85.7), (2, 'Finance', 80.1), (3, 'Healthcare', 88.3);
What is the maximum ESG score for companies in the healthcare sector?
SELECT MAX(esg_score) FROM companies WHERE sector = 'Healthcare';
gretelai_synthetic_text_to_sql
CREATE TABLE categories (category_id INT, category_name VARCHAR(255)); CREATE TABLE products (product_id INT, category_id INT, product_quantity INT);
What is the total quantity of products sold by each category?
SELECT categories.category_name, SUM(products.product_quantity) as total_quantity FROM products JOIN categories ON products.category_id = categories.category_id GROUP BY categories.category_name;
gretelai_synthetic_text_to_sql
CREATE TABLE PublicServices (ServiceID INT, ServiceName VARCHAR(255), State VARCHAR(255), AllocationDate DATE); INSERT INTO PublicServices (ServiceID, ServiceName, State, AllocationDate) VALUES (1, 'Waste Management', 'California', '2020-03-15'), (2, 'Street Lighting', 'California', '2019-08-28');
List all public services in the state of California that received budget allocations in the last 5 years, ordered by allocation amount in descending order.
SELECT ServiceName, AllocationDate, Budget FROM PublicServices INNER JOIN BudgetAllocation ON PublicServices.ServiceID = BudgetAllocation.ServiceID WHERE State = 'California' AND AllocationDate >= DATEADD(year, -5, GETDATE()) ORDER BY Budget DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE smart_city_sensors (id INT, sensor_name VARCHAR(255), city_name VARCHAR(255), install_date DATE, last_report_date DATE); INSERT INTO smart_city_sensors (id, sensor_name, city_name, install_date, last_report_date) VALUES (1, 'Air Quality Sensor', 'Paris', '2018-04-01', '2021-09-30'); INSERT INTO smart_city_sensors (id, sensor_name, city_name, install_date, last_report_date) VALUES (2, 'Traffic Sensor', 'Berlin', '2019-11-15', '2022-02-28'); INSERT INTO smart_city_sensors (id, sensor_name, city_name, install_date, last_report_date) VALUES (3, 'Noise Sensor', 'Tokyo', '2020-06-15', '2022-03-14');
What are the sensor names, city names, and the number of days in service for sensors installed in 2020?
SELECT sensor_name, city_name, install_date, DATEDIFF(day, install_date, last_report_date) as days_in_service FROM smart_city_sensors WHERE YEAR(install_date) = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE mining_operations (id INT, first_name VARCHAR(50), last_name VARCHAR(50), job_title VARCHAR(50), department VARCHAR(50), PRIMARY KEY (id)); INSERT INTO mining_operations (id, first_name, last_name, job_title, department) VALUES (1, 'John', 'Doe', 'Engineer', 'Mining'), (2, 'Jane', 'Doe', 'Operator', 'Mining'), (3, 'Mike', 'Johnson', 'Manager', 'Environment');
What is the total number of employees in the 'mining_operations' table, grouped by their job_title?
SELECT job_title, COUNT(*) FROM mining_operations GROUP BY job_title;
gretelai_synthetic_text_to_sql
CREATE TABLE cannabis_production (license_number VARCHAR(10), license_type VARCHAR(1));
Add new record into 'cannabis_production' table with data: license_number: 456A, license_type: 'B'
INSERT INTO cannabis_production (license_number, license_type) VALUES ('456A', 'B');
gretelai_synthetic_text_to_sql
CREATE TABLE cybersecurity_strategies (strategy_id INT PRIMARY KEY, strategy_name VARCHAR(100), strategy_description TEXT); INSERT INTO cybersecurity_strategies (strategy_id, strategy_name, strategy_description) VALUES (1, 'Zero Trust', 'Network security model based on strict identity verification'), (2, 'Cybersecurity Mesh', 'Decentralized network architecture for increased security');
Get the 'strategy_name' for all records in the 'cybersecurity_strategies' table
SELECT strategy_name FROM cybersecurity_strategies;
gretelai_synthetic_text_to_sql
CREATE TABLE open_pedagogy (project_id INT, project_name VARCHAR(255), topic VARCHAR(255), word_count INT); INSERT INTO open_pedagogy VALUES (1, 'Decolonizing Education', 'Indigenous Studies', 700); INSERT INTO open_pedagogy VALUES (2, 'Exploring Indigenous Art', 'Indigenous Studies', 900);
What is the number of open pedagogy projects and their total word count for the topic 'Indigenous Studies'?
SELECT COUNT(*), SUM(word_count) FROM open_pedagogy WHERE topic = 'Indigenous Studies';
gretelai_synthetic_text_to_sql
CREATE TABLE Research.Species ( id INT, species_name VARCHAR(255), population INT );
Display the names and populations of marine species, excluding those with populations less than 500, in the 'Research' schema's 'Species' table
SELECT species_name, population FROM Research.Species WHERE population >= 500;
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tours (tour_id INT, hotel_id INT, country TEXT, engagement_time INT); INSERT INTO virtual_tours (tour_id, hotel_id, country, engagement_time) VALUES (1, 1, 'UAE', 60), (2, 2, 'Saudi Arabia', 90), (3, 3, 'Israel', 45);
What is the average engagement time for virtual tours of hotels in the Middle East?
SELECT AVG(engagement_time) FROM virtual_tours WHERE country = 'Middle East';
gretelai_synthetic_text_to_sql
CREATE TABLE eco_hotels_germany (hotel_id INT, hotel_name VARCHAR(255), country VARCHAR(255), revenue DECIMAL(10,2)); INSERT INTO eco_hotels_germany (hotel_id, hotel_name, country, revenue) VALUES (1, 'Eco Hotel Berlin', 'Germany', 80000); INSERT INTO eco_hotels_germany (hotel_id, hotel_name, country, revenue) VALUES (2, 'Green Hotel Munich', 'Germany', 75000); INSERT INTO eco_hotels_germany (hotel_id, hotel_name, country, revenue) VALUES (3, 'Eco Hotel Hamburg', 'Germany', 70000);
What is the total revenue generated by eco-friendly hotels in Germany?
SELECT SUM(revenue) FROM eco_hotels_germany WHERE country = 'Germany';
gretelai_synthetic_text_to_sql
CREATE TABLE ports (port_id INT, port_name VARCHAR(50), country VARCHAR(50)); INSERT INTO ports VALUES (1, 'Lagos', 'Nigeria'); INSERT INTO ports VALUES (2, 'Port Harcourt', 'Nigeria'); CREATE TABLE cargo_handling (handling_id INT, port_id INT, operation_type VARCHAR(50), operation_date DATE); INSERT INTO cargo_handling VALUES (1, 1, 'loading', '2021-01-01'); INSERT INTO cargo_handling VALUES (2, 1, 'unloading', '2021-01-02'); INSERT INTO cargo_handling VALUES (3, 2, 'loading', '2021-01-03'); INSERT INTO cargo_handling VALUES (4, 2, 'unloading', '2021-01-04');
How many cargo handling operations were performed in Nigeria?
SELECT COUNT(*) FROM cargo_handling WHERE port_id IN (SELECT port_id FROM ports WHERE country = 'Nigeria');
gretelai_synthetic_text_to_sql
CREATE TABLE clients (client_id INT, name VARCHAR(50), region VARCHAR(20)); CREATE TABLE transactions (transaction_id INT, client_id INT, date DATE, amount DECIMAL(10, 2)); INSERT INTO clients (client_id, name, region) VALUES (1, 'John Doe', 'Asian'), (2, 'Jane Smith', 'European'); INSERT INTO transactions (transaction_id, client_id, date, amount) VALUES (1, 1, '2021-01-01', 1000.00), (2, 1, '2021-06-15', 2000.00), (3, 2, '2021-03-01', 500.00);
List all transactions that occurred in the first half of 2021 for clients in the Asian region.
SELECT t.transaction_id, t.client_id, t.date, t.amount FROM clients c INNER JOIN transactions t ON c.client_id = t.client_id WHERE c.region = 'Asian' AND t.date BETWEEN '2021-01-01' AND '2021-06-30';
gretelai_synthetic_text_to_sql
CREATE TABLE SkincareProducts (productID INT, productName VARCHAR(50), category VARCHAR(50), country VARCHAR(50), isCrueltyFree BOOLEAN, popularity INT); INSERT INTO SkincareProducts (productID, productName, category, country, isCrueltyFree, popularity) VALUES (1, 'Vitamin C Serum', 'Skincare', 'Canada', TRUE, 500);
What are the top 3 most popular cruelty-free skincare products in Canada?
SELECT * FROM SkincareProducts WHERE country = 'Canada' AND isCrueltyFree = TRUE ORDER BY popularity DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE emissions (company_id INT, year INT, co2_emissions INT); INSERT INTO emissions (company_id, year, co2_emissions) VALUES (1, 2019, 120), (1, 2020, 150), (1, 2021, 180), (2, 2019, 100), (2, 2020, 120), (2, 2021, 140);
Find average CO2 emissions for REE production.
SELECT company_id, AVG(co2_emissions) as avg_co2_emissions FROM emissions GROUP BY company_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Greenhouse1 (date DATE, temperature FLOAT);
What is the average temperature in the 'Greenhouse1' for the month of June?
SELECT AVG(temperature) FROM Greenhouse1 WHERE EXTRACT(MONTH FROM date) = 6 AND greenhouse_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE MenuItems (MenuItemID int, RestaurantID int, CuisineType varchar(255)); INSERT INTO MenuItems (MenuItemID, RestaurantID, CuisineType) VALUES (1, 1, 'Italian'), (2, 2, 'Mexican'), (3, 3, 'Chinese');
How many menu items are there for each cuisine type?
SELECT R.CuisineType, COUNT(MI.MenuItemID) as Count FROM Restaurants R INNER JOIN MenuItems MI ON R.RestaurantID = MI.RestaurantID GROUP BY R.CuisineType;
gretelai_synthetic_text_to_sql
CREATE TABLE tv_shows(show_id INT, title VARCHAR(50), release_year INT); INSERT INTO tv_shows(show_id, title, release_year) VALUES (1, 'Stranger Things', 2016), (2, 'The Mandalorian', 2019), (3, 'The Witcher', 2019), (4, 'Barry', 2018), (5, 'Chernobyl', 2019), (6, 'Watchmen', 2019);
How many TV shows have been produced since 2018?
SELECT COUNT(*) FROM tv_shows WHERE release_year >= 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (name VARCHAR(255), region VARCHAR(255), affected_by_ocean_acidification BOOLEAN); INSERT INTO marine_species (name, region, affected_by_ocean_acidification) VALUES ('Giant Clam', 'Indian', true), ('Whale Shark', 'Indian', false), ('Coral', 'Indian', true);
List the names of all marine species that are found in the Indian region and are affected by ocean acidification.
SELECT name FROM marine_species WHERE region = 'Indian' AND affected_by_ocean_acidification = true;
gretelai_synthetic_text_to_sql
CREATE TABLE stations (id INT, name TEXT, city TEXT, capacity INT);
Delete all records from the 'stations' table where the 'city' is 'San Francisco'
DELETE FROM stations WHERE city = 'San Francisco';
gretelai_synthetic_text_to_sql
CREATE TABLE ExcavationSites (SiteID INT, Name VARCHAR(50), Region VARCHAR(50), ArtifactCount INT); INSERT INTO ExcavationSites (SiteID, Name, Region, ArtifactCount) VALUES (1, 'Site A', 'americas', 5), (2, 'Site B', 'africa', 3);
List all excavation sites in the 'americas' region with at least 5 artifacts, in alphabetical order?
SELECT * FROM ExcavationSites WHERE Region = 'americas' AND ArtifactCount >= 5 ORDER BY Name;
gretelai_synthetic_text_to_sql
CREATE TABLE VRPlayersByGenre (PlayerID INT, GameGenre VARCHAR(50), VRUser BOOLEAN); INSERT INTO VRPlayersByGenre (PlayerID, GameGenre, VRUser) VALUES (1, 'Action', true), (2, 'Strategy', false), (3, 'Simulation', true);
What is the total number of players who use VR technology, grouped by their preferred game genre?
SELECT GameGenre, COUNT(*) as PlayerCount FROM VRPlayersByGenre WHERE VRUser = true GROUP BY GameGenre;
gretelai_synthetic_text_to_sql
CREATE TABLE exit_strategy (id INT, company_id INT, strategy TEXT); INSERT INTO exit_strategy (id, company_id, strategy) VALUES (1, 1, 'Merger'); CREATE TABLE company (id INT, name TEXT, industry TEXT, founder_gender TEXT); INSERT INTO company (id, name, industry, founder_gender) VALUES (1, 'GreenBounty', 'Agriculture', 'Female');
Insert a new exit strategy for a startup in the agriculture sector founded by a woman entrepreneur.
INSERT INTO exit_strategy (id, company_id, strategy) VALUES (2, (SELECT id FROM company WHERE name = 'GreenBounty'), 'Acquisition');
gretelai_synthetic_text_to_sql
CREATE TABLE ReindeerPopulation (country TEXT, year INTEGER, population INTEGER); INSERT INTO ReindeerPopulation (country, year, population) VALUES ('Norway', 2015, 240000); INSERT INTO ReindeerPopulation (country, year, population) VALUES ('Norway', 2020, 250000); INSERT INTO ReindeerPopulation (country, year, population) VALUES ('Finland', 2015, 200000); INSERT INTO ReindeerPopulation (country, year, population) VALUES ('Finland', 2020, 210000); INSERT INTO ReindeerPopulation (country, year, population) VALUES ('Sweden', 2015, 220000); INSERT INTO ReindeerPopulation (country, year, population) VALUES ('Sweden', 2020, 230000);
What is the total number of reindeer in Norway, Finland, and Sweden, as of 2020?
SELECT SUM(population) FROM ReindeerPopulation WHERE country IN ('Norway', 'Finland', 'Sweden') AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE Regions (region_id INT, name VARCHAR(50), avg_annual_rainfall DECIMAL(5,2));CREATE TABLE Infrastructure_Projects (project_id INT, region_id INT, status VARCHAR(50));INSERT INTO Regions (region_id, name, avg_annual_rainfall) VALUES (1, 'Rural Region A', 1200.00), (2, 'Rural Region B', 800.00), (3, 'Rural Region C', 1500.00);INSERT INTO Infrastructure_Projects (project_id, region_id, status) VALUES (1, 1, 'ongoing'), (2, 2, 'completed'), (3, 3, 'ongoing');
What is the average annual rainfall in the regions with ongoing rural infrastructure projects?
SELECT AVG(Regions.avg_annual_rainfall) FROM Regions INNER JOIN Infrastructure_Projects ON Regions.region_id = Infrastructure_Projects.region_id WHERE Infrastructure_Projects.status = 'ongoing';
gretelai_synthetic_text_to_sql
CREATE TABLE contract_deployments (id INT PRIMARY KEY, contract_name VARCHAR(255), deploy_date DATE); INSERT INTO contract_deployments (id, contract_name, deploy_date) VALUES (1, 'ContractA', '2023-02-15'), (2, 'ContractB', '2023-02-20');
How many smart contracts were deployed in the last 30 days?
SELECT COUNT(*) FROM contract_deployments WHERE deploy_date >= CURDATE() - INTERVAL 30 DAY;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (id INT, common_name TEXT, scientific_name TEXT, conservation_status TEXT); INSERT INTO marine_species (id, common_name, scientific_name, conservation_status) VALUES (1, 'Green Sea Turtle', 'Chelonia mydas', 'Endangered'), (2, 'Loggerhead Sea Turtle', 'Caretta caretta', 'Vulnerable'), (3, 'Leatherback Sea Turtle', 'Dermochelys coriacea', 'Vulnerable'), (4, 'Hawksbill Sea Turtle', 'Eretmochelys imbricata', 'Critically Endangered'), (5, 'Olive Ridley Sea Turtle', 'Lepidochelys olivacea', 'Least Concern');
List all marine species with a conservation status of 'Least Concern' or 'Near Threatened'.
SELECT * FROM marine_species WHERE conservation_status IN ('Least Concern', 'Near Threatened');
gretelai_synthetic_text_to_sql
CREATE TABLE categories (id INT, name VARCHAR(50)); INSERT INTO categories (id, name) VALUES (1, 'Politics'), (2, 'Sports'), (3, 'Entertainment'), (4, 'Business'), (5, 'Technology'); CREATE TABLE articles (id INT, category_id INT, title VARCHAR(100)); INSERT INTO articles (id, category_id, title) VALUES (1, 1, 'News article 1'), (2, 2, 'News article 2'), (3, 2, 'News article 3'), (4, 3, 'News article 4'), (5, 4, 'News article 5');
What are the top 5 news categories with the most articles in the "articles" table?
SELECT categories.name, COUNT(*) AS article_count FROM categories INNER JOIN articles ON categories.id = articles.category_id GROUP BY categories.name ORDER BY article_count DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (id INT, name TEXT, country TEXT, has_fitness_center BOOLEAN, rating FLOAT); INSERT INTO hotels (id, name, country, has_fitness_center, rating) VALUES (1, 'Hotel X', 'USA', true, 4.5), (2, 'Hotel Y', 'Canada', false, 4.2);
What is the average rating of hotels in the USA that have a fitness center?
SELECT AVG(rating) FROM hotels WHERE country = 'USA' AND has_fitness_center = true;
gretelai_synthetic_text_to_sql
CREATE TABLE weights (id INT, member_id INT, weight FLOAT); INSERT INTO weights (id, member_id, weight) VALUES (1, 101, 120.5), (2, 102, 150.3), (3, 103, 90.7); CREATE TABLE members (id INT, gender VARCHAR(10)); INSERT INTO members (id, gender) VALUES (101, 'male'), (102, 'female'), (103, 'male');
What is the distribution of weights lifted by gender?
SELECT gender, AVG(weight) as avg_weight, STDDEV(weight) as stddev_weight FROM weights JOIN members ON weights.member_id = members.id GROUP BY gender;
gretelai_synthetic_text_to_sql
CREATE TABLE SubscriptionCountries (Country VARCHAR(20), SubCount INT); INSERT INTO SubscriptionCountries (Country, SubCount) VALUES ('USA', '15000000'), ('UK', '8000000'), ('Canada', '6000000'), ('Australia', '5000000'), ('Germany', '7000000');
Identify the top 3 countries with the highest number of music streaming subscriptions.
SELECT Country, SubCount FROM SubscriptionCountries ORDER BY SubCount DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE obesity_rates (country VARCHAR(20), obesity_rate DECIMAL(5,2)); INSERT INTO obesity_rates (country, obesity_rate) VALUES ('United States', 35.0), ('Mexico', 30.0);
What is the average obesity rate in the United States and Mexico?
SELECT AVG(obesity_rate) FROM obesity_rates WHERE country IN ('United States', 'Mexico');
gretelai_synthetic_text_to_sql
CREATE TABLE tree_inventory (id INT, species VARCHAR(50), diameter FLOAT); INSERT INTO tree_inventory (id, species, diameter) VALUES (1, 'Cedar', 28.2), (2, 'Cedar', 25.1), (3, 'Oak', 31.5), (4, 'Pine', 22.6);
Delete all records in the tree_inventory table where the species is 'Cedar' and the diameter at breast height is less than 30 inches
DELETE FROM tree_inventory WHERE species = 'Cedar' AND diameter < 30;
gretelai_synthetic_text_to_sql
CREATE TABLE irrigation_events (event_id INT, region VARCHAR(255), usage_liters INT); INSERT INTO irrigation_events (event_id, region, usage_liters) VALUES (1, 'Andalusia', 12000), (2, 'Andalusia', 15000), (3, 'Andalusia', 11000);
What is the average water usage (in liters) per irrigation event for farms in the region of Andalusia, Spain?
SELECT AVG(usage_liters) FROM irrigation_events WHERE region = 'Andalusia';
gretelai_synthetic_text_to_sql
CREATE TABLE broadband_subscribers (id INT, region VARCHAR(20), subscription_date DATE); INSERT INTO broadband_subscribers (id, region, subscription_date) VALUES (1, 'urban', '2022-01-01'), (2, 'rural', '2022-03-15'), (3, 'urban', '2022-02-01'), (4, 'rural', '2022-01-05');
How many new broadband subscribers were added in the last month in the 'rural' region?
SELECT COUNT(*) FROM broadband_subscribers WHERE region = 'rural' AND subscription_date BETWEEN DATE_SUB('2022-04-01', INTERVAL 1 MONTH) AND '2022-04-01';
gretelai_synthetic_text_to_sql
CREATE TABLE munch_paintings (painting_id INT, painting_title VARCHAR(255), painting_creation_date DATE); INSERT INTO munch_paintings (painting_id, painting_title, painting_creation_date) VALUES (1, 'The Scream', '1893-04-22'); INSERT INTO munch_paintings (painting_id, painting_title, painting_creation_date) VALUES (2, 'Madonna', '1894-11-11');
Which painting was created right after 'The Scream' by Edvard Munch?
SELECT painting_id, painting_title, painting_creation_date, LEAD(painting_creation_date, 1) OVER (ORDER BY painting_creation_date ASC) as next_painting_date FROM munch_paintings WHERE painting_title = 'The Scream';
gretelai_synthetic_text_to_sql
CREATE TABLE CommunityHealthWorkers (WorkerID INT, Age INT, Race VARCHAR(25), Gender VARCHAR(10)); INSERT INTO CommunityHealthWorkers (WorkerID, Age, Race, Gender) VALUES (1, 45, 'Hispanic', 'Female'); INSERT INTO CommunityHealthWorkers (WorkerID, Age, Race, Gender) VALUES (2, 50, 'African American', 'Male'); INSERT INTO CommunityHealthWorkers (WorkerID, Age, Race, Gender) VALUES (3, 35, 'Asian', 'Female'); INSERT INTO CommunityHealthWorkers (WorkerID, Age, Race, Gender) VALUES (4, 40, 'Caucasian', 'Non-binary');
What is the distribution of community health workers by race and gender?
SELECT Race, Gender, COUNT(*) FROM CommunityHealthWorkers GROUP BY Race, Gender;
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, donor_id INT, country TEXT, amount_donated DECIMAL(10,2)); INSERT INTO donations (id, donor_id, country, amount_donated) VALUES (1, 1, 'USA', 5000.00), (2, 2, 'Canada', 3000.00), (3, 3, 'USA', 7000.00), (4, 4, 'UK', 8000.00), (5, 5, 'Germany', 9000.00);
List the names and total donation amounts for donors in the top 10 countries by total donated amount.
SELECT d.name, SUM(donations.amount_donated) FROM donations JOIN (SELECT country, SUM(amount_donated) AS total_donated FROM donations GROUP BY country ORDER BY total_donated DESC LIMIT 10) d_totals ON donations.country = d.country GROUP BY d.name;
gretelai_synthetic_text_to_sql
CREATE TABLE solar_power_installations (id INT, installation_name VARCHAR(255), city VARCHAR(255), state VARCHAR(255), capacity FLOAT, installation_date DATE);
Count of solar power installations in the USA
SELECT COUNT(*) FROM solar_power_installations WHERE state = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE tokens (name VARCHAR(255), category VARCHAR(255), circulating_supply INT); INSERT INTO tokens (name, category, circulating_supply) VALUES ('TokenA', 'DeFi', 50000), ('TokenB', 'DeFi', 75000), ('TokenC', 'NFT', 100000), ('TokenD', 'DeFi', 20000);
What is the maximum number of tokens in circulation for projects with the 'DeFi' category, and what are their respective names?
SELECT name, MAX(circulating_supply) FROM tokens WHERE category = 'DeFi';
gretelai_synthetic_text_to_sql
CREATE TABLE Latin_Streaming (user INT, artist VARCHAR(50), year INT, streams INT); INSERT INTO Latin_Streaming (user, artist, year, streams) VALUES (1, 'Shakira', 2018, 10), (1, 'Bad Bunny', 2019, 5), (2, 'Shakira', 2020, 7), (2, 'Bad Bunny', 2020, 8), (3, 'Shakira', 2021, 9), (3, 'Bad Bunny', 2021, 6);
What was the average number of streams per user for a Latin artist's songs in 2020?
SELECT artist, AVG(streams) FROM Latin_Streaming WHERE year = 2020 AND artist IN ('Shakira', 'Bad Bunny') GROUP BY artist;
gretelai_synthetic_text_to_sql
CREATE TABLE defense_projects (id INT, name VARCHAR(255), contractor_id INT, original_completion_date DATE, current_completion_date DATE); INSERT INTO defense_projects (id, name, contractor_id, original_completion_date, current_completion_date) VALUES (1, 'F-35 Joint Strike Fighter', 1, '2025-01-01', '2025-02-01'), (2, 'Boeing 777X', 2, '2024-01-01', '2024-01-15'), (3, 'Columbia-class Submarine', 3, '2028-01-01', '2028-05-01'); CREATE TABLE contractors (id INT, name VARCHAR(255)); INSERT INTO contractors (id, name) VALUES (1, 'Lockheed Martin'), (2, 'Boeing'), (3, 'General Dynamics');
List all defense projects that have experienced delays of more than 30 days, along with their original and current completion dates, and the names of the contractors responsible for each project.
SELECT d.name, c.name as contractor_name, d.original_completion_date, d.current_completion_date, DATEDIFF(d.current_completion_date, d.original_completion_date) as delay_days FROM defense_projects d JOIN contractors c ON d.contractor_id = c.id WHERE DATEDIFF(d.current_completion_date, d.original_completion_date) > 30;
gretelai_synthetic_text_to_sql
CREATE TABLE ExcavationSites (SiteID INT, SiteName VARCHAR(50), Country VARCHAR(50), Year INT, ArtifactWeight FLOAT, ArtifactType VARCHAR(50)); INSERT INTO ExcavationSites (SiteID, SiteName, Country, Year, ArtifactWeight, ArtifactType) VALUES (1, 'SiteA', 'USA', 2020, 23.5, 'Pottery'), (2, 'SiteB', 'Mexico', 2020, 14.2, 'Stone Tool'), (3, 'SiteC', 'USA', 2019, 34.8, 'Bone Tool'), (4, 'SiteD', 'Canada', 2019, 45.6, 'Ceramic Figurine'), (5, 'SiteE', 'Canada', 2019, 56.7, 'Metal Artifact');
Identify the excavation site with the highest total artifact weight for each artifact type, along with the artifact weight.
SELECT SiteName, ArtifactType, ArtifactWeight FROM (SELECT SiteName, ArtifactType, ArtifactWeight, ROW_NUMBER() OVER (PARTITION BY ArtifactType ORDER BY ArtifactWeight DESC) rn FROM ExcavationSites) x WHERE rn = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE industrial_water_usage (state VARCHAR(20), year INT, sector VARCHAR(30), usage FLOAT); INSERT INTO industrial_water_usage (state, year, sector, usage) VALUES ('California', 2021, 'Agriculture', 45612.3), ('California', 2021, 'Manufacturing', 34567.2), ('California', 2021, 'Mining', 23456.1), ('California', 2021, 'Gasoline Production', 12345.0), ('California', 2021, 'Food Processing', 56789.0);
Identify the top 2 water consuming industries in California in 2021.
SELECT sector, usage FROM industrial_water_usage WHERE state = 'California' AND year = 2021 ORDER BY usage DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE SocialImpact (id INT, region VARCHAR(20), score FLOAT); INSERT INTO SocialImpact (id, region, score) VALUES (1, 'Northeast', 80.0), (2, 'Southeast', 85.0), (3, 'Midwest', 90.0), (4, 'Southwest', 70.0), (5, 'Northwest', 75.0);
Which regions have the highest and lowest social impact scores?
SELECT region, score FROM SocialImpact ORDER BY score DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE skincare_products (product_id INT, brand_id INT, launch_date DATE); CREATE TABLE brands (brand_id INT, name VARCHAR(255), is_b_corp BOOLEAN);
How many new skincare products were launched in the second half of 2021 by brands that are certified B Corporations?
SELECT COUNT(*) FROM skincare_products INNER JOIN brands ON skincare_products.brand_id = brands.brand_id WHERE EXTRACT(MONTH FROM launch_date) BETWEEN 7 AND 12 AND is_b_corp = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE flu_cases (id INT, case_date DATE, location TEXT, cases INT); INSERT INTO flu_cases (id, case_date, location, cases) VALUES (1, '2022-01-01', 'Texas', 500); INSERT INTO flu_cases (id, case_date, location, cases) VALUES (2, '2022-02-14', 'Texas', 600);
What is the maximum number of flu cases reported in a single day in Texas?
SELECT MAX(cases) FROM flu_cases WHERE location = 'Texas';
gretelai_synthetic_text_to_sql
CREATE TABLE military_tech_samerica (id INT, tech_type TEXT, tech_development_date DATE, country TEXT); INSERT INTO military_tech_samerica (id, tech_type, tech_development_date, country) VALUES (1, 'Stealth Boat', '2018-01-01', 'Brazil'), (2, 'Cyber Defense System', '2019-12-15', 'Argentina');
List all military technologies developed in South American countries, including the technology type and development date.
SELECT mt.tech_type, mt.tech_development_date FROM military_tech_samerica mt;
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, Age INT, GameType VARCHAR(10), GameRevenue INT); INSERT INTO Players (PlayerID, Age, GameType, GameRevenue) VALUES (1, 25, 'Action', 500000), (2, 30, 'RPG', 600000), (3, 22, 'Action', 400000), (4, 28, 'RPG', 800000), (5, 24, 'RPG', 700000);
What is the slope and intercept of the regression line for the relationship between the age of players and the revenue of RPG games?
SELECT SLOPE(Age, GameRevenue) as Slope, INTERCEPT(Age, GameRevenue) as Intercept FROM Players WHERE GameType = 'RPG';
gretelai_synthetic_text_to_sql
CREATE TABLE ports(port_id INT, port_name TEXT);CREATE TABLE cargo(cargo_id INT, port_id_start INT, port_id_end INT, transit_time_days INT);INSERT INTO ports VALUES (1,'Port A'),(2,'Port B'),(3,'Port C'),(4,'Port D');INSERT INTO cargo VALUES (1,1,2,7),(2,1,3,10),(3,2,4,5),(4,3,1,12),(5,3,2,8),(6,4,1,9);
Display the average number of days it takes to transport cargo between each pair of ports, excluding pairs with no cargo transported between them, and show the results for the top 5 pairs with the longest average transit time.
SELECT p1.port_name as port_name_start, p2.port_name as port_name_end, AVG(c.transit_time_days) as avg_transit_time FROM cargo c JOIN ports p1 ON c.port_id_start = p1.port_id JOIN ports p2 ON c.port_id_end = p2.port_id GROUP BY p1.port_id, p2.port_id HAVING avg_transit_time > 0 ORDER BY avg_transit_time DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists biosensors;CREATE TABLE if not exists biosensors.startups(id INT, name TEXT, location TEXT, funding DECIMAL(10,2), sector TEXT);INSERT INTO biosensors.startups (id, name, location, funding, sector) VALUES (1, 'StartupA', 'Germany', 1500000.00, 'Biosensor'), (2, 'StartupB', 'USA', 2000000.00, 'Biosensor'), (3, 'StartupC', 'Canada', 1000000.00, 'Biotech');
What is the total funding received by biosensor tech startups in Germany?
SELECT SUM(funding) FROM biosensors.startups WHERE location = 'Germany' AND sector = 'Biosensor';
gretelai_synthetic_text_to_sql
CREATE TABLE workers (id INT, name VARCHAR(50), industry VARCHAR(50), salary FLOAT, country VARCHAR(50)); INSERT INTO workers (id, name, industry, salary, country) VALUES (1, 'John Doe', 'oil', 60000, 'Canada'); INSERT INTO workers (id, name, industry, salary, country) VALUES (2, 'Jane Smith', 'gas', 65000, 'Canada'); INSERT INTO workers (id, name, industry, salary, country) VALUES (3, 'Mike Johnson', 'gas', 70000, 'Canada'); INSERT INTO workers (id, name, industry, salary, country) VALUES (4, 'Peter Lee', 'oil', 80000, 'Canada'); CREATE TABLE provinces (id INT, name VARCHAR(50), country VARCHAR(50)); INSERT INTO provinces (id, name, country) VALUES (1, 'Alberta', 'Canada'); INSERT INTO provinces (id, name, country) VALUES (2, 'British Columbia', 'Canada');
Update the salary of 'Peter Lee' to $85,000 in the 'oil' industry in Alberta, Canada.
UPDATE workers SET salary = 85000 WHERE name = 'Peter Lee' AND industry = 'oil' AND country = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE Project (id INT, name TEXT, location TEXT, type TEXT, completion_date DATE); INSERT INTO Project (id, name, location, type, completion_date) VALUES (1, 'Gautrain Rapid Rail Link', 'Johannesburg, South Africa', 'Transport', '2010-06-07');
What is the total number of transport projects completed in South Africa since 2000?
SELECT COUNT(*) FROM Project WHERE location = 'South Africa' AND type = 'Transport' AND completion_date >= '2000-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE concerts (concert_id INT PRIMARY KEY, artist_name VARCHAR(100), concert_date DATE, location VARCHAR(100), tickets_sold INT); INSERT INTO concerts (concert_id, artist_name, concert_date, location, tickets_sold) VALUES (1, 'Melody Jazz Trio', '2023-06-15', 'New York City', 250);
Insert data into 'concerts' table for an upcoming jazz concert
INSERT INTO concerts (concert_id, artist_name, concert_date, location, tickets_sold) VALUES (2, 'Smooth Groove Band', '2023-07-01', 'Chicago', 300);
gretelai_synthetic_text_to_sql
CREATE TABLE faculty (id INT, name VARCHAR(100), department VARCHAR(50), gender VARCHAR(50), sexuality VARCHAR(50)); INSERT INTO faculty VALUES (1, 'Morgan Smith', 'Biology', 'Non-binary', 'Queer'); CREATE TABLE grants (id INT, faculty_id INT, amount DECIMAL(10,2)); INSERT INTO grants VALUES (1, 1, 50000);
What is the average number of research grants received by faculty members who identify as LGBTQ+ in the Biology department?
SELECT AVG(number_of_grants) FROM (SELECT faculty.sexuality, COUNT(grants.id) AS number_of_grants FROM faculty JOIN grants ON faculty.id = grants.faculty_id WHERE faculty.department = 'Biology' AND faculty.sexuality = 'Queer' GROUP BY faculty.id) AS subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE medical_supplies_yemen (id INT, location VARCHAR(50), aid_type VARCHAR(50), amount FLOAT, date DATE); INSERT INTO medical_supplies_yemen (id, location, aid_type, amount, date) VALUES (1, 'Yemen', 'medical_supplies', 600000, '2022-02-01');
What is the total amount of aid sent to Yemen in the form of medical supplies in the past year?
SELECT SUM(amount) as total_medical_aid FROM medical_supplies_yemen WHERE location = 'Yemen' AND date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE unions (id INT, name TEXT, member_count INT); CREATE TABLE members (id INT, union_id INT);
Add a new union 'Retail Workers Union' with 300 members.
INSERT INTO unions (id, name, member_count) VALUES (1, 'Retail Workers Union', 300); INSERT INTO members (id, union_id) SELECT NULL, id FROM (SELECT 1 + (SELECT MAX(id) FROM unions) AS id) AS seq_table;
gretelai_synthetic_text_to_sql
CREATE TABLE InfantMortality (Country VARCHAR(50), Continent VARCHAR(50), Year INT, Rate FLOAT); INSERT INTO InfantMortality (Country, Continent, Year, Rate) VALUES ('Brazil', 'South America', 2019, 15.0), ('Argentina', 'South America', 2019, 9.0), ('Colombia', 'South America', 2019, 12.0);
What is the infant mortality rate in South American countries in 2019?
SELECT Country, Continent, Rate FROM InfantMortality WHERE Continent = 'South America' AND Year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE dept_budget (dept VARCHAR(50), budget INT); INSERT INTO dept_budget (dept, budget) VALUES ('Infrastructure', 800000), ('Education', 700000), ('Health', 900000);
Which departments have a budget allocation below the average budget?
SELECT dept FROM dept_budget WHERE budget < (SELECT AVG(budget) FROM dept_budget);
gretelai_synthetic_text_to_sql
CREATE TABLE Appointments (AppointmentID INT, PatientID INT, Physician VARCHAR(255), Date DATE); INSERT INTO Appointments (AppointmentID, PatientID, Physician, Date) VALUES (1, 1, 'Dr. Smith', '2021-09-01');
What is the percentage of patients who have had a follow-up appointment within 30 days of their initial appointment, grouped by the physician who saw them?
SELECT Physician, (SUM(FollowUpAppointments) / SUM(TotalAppointments)) * 100.0 FROM (SELECT Physician, COUNT(*) AS TotalAppointments, SUM(CASE WHEN DATEDIFF(day, Appointments.Date, FollowUpAppointments.Date) <= 30 THEN 1 ELSE 0 END) AS FollowUpAppointments FROM Appointments LEFT JOIN Appointments AS FollowUpAppointments ON Appointments.PatientID = FollowUpAppointments.PatientID WHERE FollowUpAppointments.Date IS NOT NULL GROUP BY Physician) AS Subquery GROUP BY Physician;
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tours (tour_id INT, tour_name TEXT, country TEXT, revenue FLOAT); INSERT INTO virtual_tours (tour_id, tour_name, country, revenue) VALUES (1, 'Statue of Liberty Virtual Tour', 'US', 15000), (2, 'Golden Gate Bridge Virtual Tour', 'US', 20000);
What is the total revenue generated by virtual tours in the US?
SELECT SUM(revenue) FROM virtual_tours WHERE country = 'US';
gretelai_synthetic_text_to_sql
CREATE TABLE wastewater_treatment_m3 (country VARCHAR(20), region VARCHAR(20), value FLOAT); INSERT INTO wastewater_treatment_m3 (country, region, value) VALUES ('Ghana', NULL, 2000000);
What is the total wastewater treatment capacity in Ghana in cubic meters?
SELECT value FROM wastewater_treatment_m3 WHERE country = 'Ghana';
gretelai_synthetic_text_to_sql
CREATE TABLE boston_properties (type VARCHAR(10), price INT); INSERT INTO boston_properties (type, price) VALUES ('Co-op', 450000); INSERT INTO boston_properties (type, price) VALUES ('Condo', 600000);
What is the minimum listing price for co-op properties in Boston?
SELECT MIN(price) FROM boston_properties WHERE type = 'Co-op';
gretelai_synthetic_text_to_sql
CREATE TABLE ticket_sales (ticket_id INT, country VARCHAR(50), sales INT);
List the top 5 countries with the most ticket sales in the past month.
SELECT country, SUM(sales) as total_sales FROM ticket_sales WHERE sale_date >= DATEADD(month, -1, GETDATE()) GROUP BY country ORDER BY total_sales DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE regions (region_id INT, region_name VARCHAR(255)); CREATE TABLE volunteers (volunteer_id INT, volunteer_name VARCHAR(255), age INT, region_id INT); INSERT INTO regions (region_id, region_name) VALUES (1, 'North'), (2, 'South'), (3, 'East'), (4, 'West'); INSERT INTO volunteers (volunteer_id, volunteer_name, age, region_id) VALUES (1, 'John Doe', 25, 1), (2, 'Jane Smith', 23, 2), (3, 'Bob Johnson', 30, 3), (4, 'Alice Davis', 28, 4);
How many volunteers have registered for each region, and what is the minimum age of volunteers for each region?
SELECT region_id, COUNT(*), MIN(age) FROM volunteers JOIN regions ON volunteers.region_id = regions.region_id GROUP BY region_id;
gretelai_synthetic_text_to_sql
CREATE TABLE products (id INT, name VARCHAR(255), category VARCHAR(255), fair_trade BOOLEAN);
Insert a new record for a fair trade coffee in the products table.
INSERT INTO products (id, name, category, fair_trade) VALUES (1, 'Fair Trade Coffee', 'coffee', true);
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, DonorName TEXT, Country TEXT); INSERT INTO Donors (DonorID, DonorName, Country) VALUES (1, 'Emma Thompson', 'UK'), (2, 'Oliver Jackson', 'UK'), (3, 'Sophie Lee', 'Canada'); CREATE TABLE Donations (DonationID INT, DonorID INT, Amount DECIMAL); INSERT INTO Donations (DonationID, DonorID, Amount) VALUES (1, 1, 200.00), (2, 1, 300.00), (3, 2, 150.00), (4, 3, 400.00);
What is the average donation amount from donors in the United Kingdom?
SELECT AVG(Donations.Amount) AS AverageDonation FROM Donors INNER JOIN Donations ON Donors.DonorID = Donations.DonorID WHERE Donors.Country = 'UK';
gretelai_synthetic_text_to_sql
CREATE TABLE Carrier (CarrierID INT, Name VARCHAR(255), FlagState VARCHAR(255), CallSign VARCHAR(255)); INSERT INTO Carrier (CarrierID, Name, FlagState, CallSign) VALUES (2, 'Mediterranean Shipping Company', 'Greece', 'MSC');
What is the name of all carriers registered in Greece?
SELECT Name FROM Carrier WHERE FlagState = 'Greece';
gretelai_synthetic_text_to_sql
CREATE TABLE graduate_students(student_id INT, name VARCHAR(50), gender VARCHAR(10), discipline VARCHAR(20)); INSERT INTO graduate_students VALUES (1, 'Mira', 'Female', 'Theater Arts'); INSERT INTO graduate_students VALUES (2, 'Nathan', 'Male', 'Visual Arts');
Retrieve the number of graduate students enrolled in each Arts discipline
SELECT discipline, COUNT(*) as enrolled_students FROM graduate_students WHERE discipline LIKE 'Arts%' GROUP BY discipline;
gretelai_synthetic_text_to_sql
CREATE TABLE ExcavationSite (SiteID INT PRIMARY KEY, Name VARCHAR(255), Country VARCHAR(255), StartDate DATE, EndDate DATE); INSERT INTO ExcavationSite (SiteID, Name, Country, StartDate, EndDate) VALUES (3, 'Tutankhamun', 'Egypt', '1922-01-01', '1925-12-31');
What artifacts were found in Egypt between 1920 and 1925?
SELECT Artifact.Name FROM Artifact INNER JOIN ExcavationSite ON Artifact.SiteID = ExcavationSite.SiteID WHERE ExcavationSite.Country = 'Egypt' AND Artifact.DateFound BETWEEN '1920-01-01' AND '1925-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE CulturalCompetencyTraining (TrainingID INT, State VARCHAR(2), CompletionDate DATE); INSERT INTO CulturalCompetencyTraining (TrainingID, State, CompletionDate) VALUES (1, 'NY', '2020-06-01'), (2, 'CA', '2019-12-15'), (3, 'TX', '2021-02-03');
What is the percentage of cultural competency training completed by state?
SELECT State, COUNT(*) OVER (PARTITION BY State) * 100.0 / SUM(COUNT(*)) OVER () AS PercentageCompleted FROM CulturalCompetencyTraining;
gretelai_synthetic_text_to_sql
CREATE TABLE CourierCompany (id INT, name VARCHAR(255), average_delivery_time FLOAT);
What is the average delivery time for each courier company?
SELECT name, AVG(average_delivery_time) AS avg_delivery_time FROM CourierCompany GROUP BY name;
gretelai_synthetic_text_to_sql
CREATE TABLE iron_ore_mines (id INT, name TEXT, location TEXT, production_rate FLOAT); INSERT INTO iron_ore_mines (id, name, location, production_rate) VALUES (1, 'Mount Whaleback', 'Pilbara, Australia', 42.8), (2, 'Yandi', 'Pilbara, Australia', 38.5), (3, 'Paraburdoo', 'Pilbara, Australia', 34.7);
What is the average production rate of iron ore mines in Australia?
SELECT AVG(production_rate) FROM iron_ore_mines WHERE location LIKE '%Australia%';
gretelai_synthetic_text_to_sql
CREATE TABLE accommodation (student_id INT, accommodation_type TEXT, accommodation_date DATE); INSERT INTO accommodation (student_id, accommodation_type, accommodation_date) VALUES (1, 'Note Taker', '2022-05-01'), (2, 'Wheelchair Access', '2022-04-15'), (3, 'Assistive Technology', '2022-03-01'), (4, 'Wheelchair Access', '2022-05-01');
How many students with physical disabilities received more than 2 accommodations in the last month?
SELECT COUNT(DISTINCT student_id) FROM accommodation WHERE student_id IN (SELECT student_id FROM student WHERE disability = 'Physical Disability') AND accommodation_date >= DATEADD(month, -1, GETDATE()) GROUP BY student_id HAVING COUNT(DISTINCT accommodation_date) > 2;
gretelai_synthetic_text_to_sql
CREATE TABLE CommunityPolicingEvents (ID INT, City VARCHAR(20), Year INT, Events INT); INSERT INTO CommunityPolicingEvents (ID, City, Year, Events) VALUES (1, 'Atlanta', 2021, 20);
What is the minimum number of community policing events held in Atlanta in 2021?
SELECT MIN(Events) FROM CommunityPolicingEvents WHERE City = 'Atlanta' AND Year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE cultural_competency_trainings (id INT, worker_id INT, type VARCHAR(50), date DATE); INSERT INTO cultural_competency_trainings (id, worker_id, type, date) VALUES (1, 1, 'Cultural Sensitivity', '2022-01-01'), (2, 3, 'Language Access', '2022-02-15'); CREATE TABLE community_health_workers (id INT, name VARCHAR(50), ethnicity VARCHAR(50), certification BOOLEAN); INSERT INTO community_health_workers (id, name, ethnicity, certification) VALUES (1, 'Charlene', 'Hispanic', true), (2, 'Derek', 'Asian', false), (3, 'Fiona', 'Native American', true), (4, 'George', 'African', true), (5, 'Hannah', 'Caucasian', true);
Find regions with more than 10 community health workers who have cultural competency training.
SELECT region, COUNT(*) FROM (SELECT community_health_workers.id AS worker_id, 'Region1' AS region FROM community_health_workers INNER JOIN cultural_competency_trainings ON community_health_workers.id = cultural_competency_trainings.worker_id WHERE cultural_competency_trainings.type = 'Cultural Sensitivity' UNION ALL SELECT community_health_workers.id AS worker_id, 'Region2' AS region FROM community_health_workers INNER JOIN cultural_competency_trainings ON community_health_workers.id = cultural_competency_trainings.worker_id WHERE cultural_competency_trainings.type = 'Language Access') tmp_table GROUP BY region HAVING COUNT(*) > 10;
gretelai_synthetic_text_to_sql
CREATE TABLE ai_safety (region TEXT, incident_count INT);
Find the total number of AI safety incidents for each region and the overall average in the 'ai_safety' table, excluding regions with less than 10 incidents.
SELECT region, AVG(incident_count) as avg_incident, SUM(incident_count) as total_incidents FROM ai_safety WHERE incident_count >= 10 GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (ArtistID INT, Name VARCHAR(255), BirthYear INT, DeathYear INT, Country VARCHAR(255)); INSERT INTO Artists (ArtistID, Name, BirthYear, DeathYear, Country) VALUES (1, 'Vincent van Gogh', 1853, 1890, 'Netherlands'), (2, 'Pablo Picasso', 1881, 1973, 'Spain');
List all unique countries of origin for artists in the database.
SELECT DISTINCT Country FROM Artists;
gretelai_synthetic_text_to_sql
CREATE TABLE GMCrops (crop_id INT, crop_type VARCHAR(255), origin VARCHAR(255), weight INT); INSERT INTO GMCrops (crop_id, crop_type, origin, weight) VALUES (1, 'Maize', 'Africa', 1200), (2, 'Soybean', 'South America', 2000), (3, 'Cotton', 'North America', 1500);
What is the total weight of genetically modified crops sourced from Africa?
SELECT SUM(weight) FROM GMCrops WHERE crop_type = 'Maize' AND origin = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE rural_infrastructure (id INT, year INT, project VARCHAR(50), budget FLOAT); INSERT INTO rural_infrastructure (id, year, project, budget) VALUES (1, 2018, 'Road Construction', 300000.00), (2, 2019, 'Water Supply', 550000.00), (3, 2020, 'Electrification', 700000.00);
What is the maximum budget for rural infrastructure projects in 2019?
SELECT MAX(budget) FROM rural_infrastructure WHERE year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE news_articles (id INT, title VARCHAR(255), language VARCHAR(255), publication_date DATE); INSERT INTO news_articles (id, title, language, publication_date) VALUES (1, 'Article 1', 'Spanish', '2023-03-01'), (2, 'Article 2', 'English', '2023-03-02');
What is the total number of news articles published in Spanish in the last week?
SELECT COUNT(*) FROM news_articles WHERE language = 'Spanish' AND publication_date >= DATEADD(day, -7, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE support_programs (program_id INT PRIMARY KEY, name VARCHAR(255), description TEXT, category VARCHAR(255), budget DECIMAL(10,2));
Insert data for a new support program
INSERT INTO support_programs (program_id, name, description, category, budget) VALUES (1, 'Assistive Technology Loans', 'Loans for assistive technology equipment', 'Technology', 50000.00);
gretelai_synthetic_text_to_sql
CREATE TABLE sustainable_practices (practice_id INT, building_id INT, city VARCHAR(20)); INSERT INTO sustainable_practices (practice_id, building_id, city) VALUES (1, 101, 'New York'), (2, 101, 'New York'), (3, 102, 'Los Angeles');
Which sustainable building practices were implemented in Los Angeles?
SELECT DISTINCT city, building_type FROM sustainable_practices SP JOIN (SELECT building_id, 'Solar Panels' as building_type FROM sustainable_practices WHERE practice_id = 1 UNION ALL SELECT building_id, 'Green Roofs' as building_type FROM sustainable_practices WHERE practice_id = 2) AS subquery ON SP.building_id = subquery.building_id WHERE city = 'Los Angeles';
gretelai_synthetic_text_to_sql
CREATE TABLE circular_economy(year INT, state VARCHAR(255), initiatives INT); INSERT INTO circular_economy VALUES (2020, 'Florida', 3), (2021, 'Florida', 0);
Insert new records of circular economy initiatives for 2021 in Florida.
INSERT INTO circular_economy (year, state, initiatives) VALUES (2021, 'Florida', 4);
gretelai_synthetic_text_to_sql
CREATE TABLE theater_performances (id INT, performance_date DATE, attendee_count INT, attendee_disability BOOLEAN); INSERT INTO theater_performances (id, performance_date, attendee_count, attendee_disability) VALUES (1, '2021-10-10', 200, true), (2, '2021-10-11', 300, false), (3, '2021-10-12', 150, true), (4, '2021-11-01', 400, false);
How many people with disabilities attended theater performances in the past 3 months?
SELECT SUM(attendee_count) FROM theater_performances WHERE attendee_disability = true AND performance_date BETWEEN '2021-10-01' AND '2021-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE spacecraft_launches (id INT, country VARCHAR, launch_year INT, quantity INT);
What is the average number of spacecraft launched per year by each country?
SELECT country, AVG(quantity) as avg_launches_per_year FROM spacecraft_launches GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists solar_power_plants (plant_id integer, plant_name varchar(255), plant_location varchar(255), commissioning_date date, capacity_mw integer); INSERT INTO solar_power_plants (plant_id, plant_name, plant_location, commissioning_date, capacity_mw) VALUES (1, 'Plant A', 'India', '2016-01-01', 50), (2, 'Plant B', 'India', '2017-01-01', 75), (3, 'Plant C', 'India', '2018-01-01', 100), (4, 'Plant D', 'India', '2020-01-01', 125);
What is the total installed capacity (in MW) of solar power plants in India that were commissioned after 2015?
SELECT plant_location, SUM(capacity_mw) as total_capacity FROM solar_power_plants WHERE plant_location LIKE 'India%' AND commissioning_date > '2015-12-31' GROUP BY plant_location;
gretelai_synthetic_text_to_sql
CREATE TABLE rigs (rig_id INT, rig_name VARCHAR(50), first_active_year INT); INSERT INTO rigs (rig_id, rig_name, first_active_year) VALUES (1, 'Rig1', 2016), (2, 'Rig2', 2017), (3, 'Rig3', 2015);
List all rigs that have been active since 2017
SELECT * FROM rigs WHERE first_active_year <= 2017;
gretelai_synthetic_text_to_sql
CREATE TABLE ProgramDonations (ProgramID INT, DonationDate DATE, DonationAmount DECIMAL(10,2)); INSERT INTO ProgramDonations (ProgramID, DonationDate, DonationAmount) VALUES (1, '2022-01-05', 500.00), (1, '2022-02-10', 750.00), (2, '2022-03-20', 300.00);
What is the total amount donated by each program in the last quarter?
SELECT ProgramID, SUM(DonationAmount) as TotalDonated FROM (SELECT ProgramID, DonationAmount FROM ProgramDonations WHERE DonationDate >= DATE_TRUNC('quarter', CURRENT_DATE - INTERVAL '3 months') AND DonationDate < DATE_TRUNC('quarter', CURRENT_DATE) + INTERVAL '1 day' ) t GROUP BY ProgramID;
gretelai_synthetic_text_to_sql
CREATE TABLE donors (id INT, name TEXT, donation_amount INT); INSERT INTO donors (id, name, donation_amount) VALUES (1, 'John Doe', 3000); INSERT INTO donors (id, name, donation_amount) VALUES (2, 'Jane Smith', 1500);
Show the names and total donations of donors who have donated more than $2000 in total, sorted by their total donations in descending order.
SELECT name, SUM(donation_amount) FROM donors GROUP BY name HAVING SUM(donation_amount) > 2000 ORDER BY SUM(donation_amount) DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE MilitaryExpenses (id INT, year INT, country VARCHAR(50), expenses FLOAT); INSERT INTO MilitaryExpenses (id, year, country, expenses) VALUES (1, 2020, 'USA', 700000000), (2, 2020, 'China', 300000000), (3, 2020, 'Russia', 150000000);
What are the total military expenses for each country in 2020?
SELECT country, SUM(expenses) AS total_expenses FROM MilitaryExpenses WHERE year = 2020 GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE daily_production (mine_id INT, division TEXT, location TEXT, production_volume INT); INSERT INTO daily_production (mine_id, division, location, production_volume) VALUES (1, 'Mining Operations', 'Wyoming, USA', 500), (2, 'Mining Operations', 'Montana, USA', 450), (3, 'Mining Operations', 'Idaho, USA', 400), (4, 'Mining Operations', 'Utah, USA', 350), (5, 'Mining Operations', 'Nevada, USA', 300);
Show the daily production volume of the 'Mining Operations' division, grouped by the mine's location.
SELECT location, SUM(production_volume) as total_daily_production FROM daily_production WHERE division = 'Mining Operations' GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE TVShowsRating (title VARCHAR(255), genre VARCHAR(255), rating FLOAT, air_date DATE); INSERT INTO TVShowsRating (title, genre, rating, air_date) VALUES ('TVShow1', 'Comedy', 7.5, '2022-01-01'), ('TVShow2', 'Action', 8.5, '2022-01-02'), ('TVShow3', 'Drama', 6.5, '2022-01-03'), ('TVShow4', 'Comedy', 8.0, '2022-02-01'), ('TVShow5', 'Action', 7.0, '2022-02-02');
What was the average rating for TV shows, by genre and quarter?
SELECT genre, DATE_PART('quarter', air_date) as quarter, AVG(rating) FROM TVShowsRating GROUP BY genre, quarter;
gretelai_synthetic_text_to_sql
CREATE TABLE IrrigationProjects(ProjectID INT, ProjectName VARCHAR(50), ProjectCost INT);
Insert a new record into the 'IrrigationProjects' table: ProjectID 201, ProjectName 'Drip Irrigation System', ProjectCost 50000
INSERT INTO IrrigationProjects(ProjectID, ProjectName, ProjectCost) VALUES (201, 'Drip Irrigation System', 50000);
gretelai_synthetic_text_to_sql
CREATE TABLE Farmers (id INT, name VARCHAR(50), age INT, location VARCHAR(50)); INSERT INTO Farmers (id, name, age, location) VALUES (1, 'John Doe', 35, 'USA'); INSERT INTO Farmers (id, name, age, location) VALUES (2, 'Jane Smith', 40, 'Canada'); CREATE TABLE Irrigation_Systems (id INT, farmer_id INT, system_name VARCHAR(50), technology VARCHAR(50), year_installed INT, cost INT); INSERT INTO Irrigation_Systems (id, farmer_id, system_name, technology, year_installed, cost) VALUES (1, 1, 'Drip Irrigation', 'Smart', 2018, 5000); INSERT INTO Irrigation_Systems (id, farmer_id, system_name, technology, year_installed, cost) VALUES (2, 2, 'Sprinkler Irrigation', 'Conventional', 2016, 3000);
Find the average age of farmers using drip irrigation systems.
SELECT AVG(f.age) as avg_age FROM Farmers f JOIN Irrigation_Systems i ON f.id = i.farmer_id WHERE i.system_name = 'Drip Irrigation';
gretelai_synthetic_text_to_sql
CREATE TABLE RenewableEnergyProjects (id INT, project_name VARCHAR(100), project_type VARCHAR(50), city VARCHAR(50), country VARCHAR(50), capacity INT);
List the number of renewable energy projects for each type in 'Germany'
SELECT project_type, COUNT(*) FROM RenewableEnergyProjects WHERE country = 'Germany' GROUP BY project_type;
gretelai_synthetic_text_to_sql
CREATE TABLE solana_transactions (transaction_id INT, transaction_fee DECIMAL(10,2), transaction_time TIMESTAMP);
What is the 30-day moving average of transaction fees on the Solana network?
SELECT AVG(transaction_fee) as moving_average FROM (SELECT transaction_fee, AVG(transaction_fee) OVER (ORDER BY transaction_time ROWS BETWEEN 29 PRECEDING AND CURRENT ROW) as moving_avg FROM solana_transactions WHERE transaction_time >= NOW() - INTERVAL '30 day') subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE SecurityIncidents(id INT, shift VARCHAR(50), resolution_time FLOAT, incident_date DATE);
What is the average time to resolve security incidents for each shift in the last month?
SELECT shift, AVG(resolution_time) as avg_resolution_time FROM SecurityIncidents WHERE incident_date >= DATE_SUB(CURRENT_DATE(), INTERVAL 1 MONTH) GROUP BY shift;
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, 'Panda', 'Adult'), (3, 'Lion', 'Cub'), (4, 'Zebra', 'Juvenile');
Update the age of all 'Lion' species records to 'Adult' in the animal_population table.
UPDATE animal_population SET animal_age = 'Adult' WHERE animal_species = 'Lion';
gretelai_synthetic_text_to_sql
CREATE TABLE Concerts (ConcertID INT, Title VARCHAR(50), ArtistID INT, Venue VARCHAR(50), Revenue INT); INSERT INTO Concerts VALUES (1, 'Jazz Concert', 1, 'New York', 5000); INSERT INTO Concerts VALUES (2, 'Rock Concert', 2, 'Toronto', 8000); CREATE TABLE Artists (ArtistID INT, Name VARCHAR(50), Age INT, Genre VARCHAR(50)); INSERT INTO Artists VALUES (1, 'Jazz Artist', 45, 'Jazz'); INSERT INTO Artists VALUES (2, 'Rock Artist', 35, 'Rock');
What is the total revenue from concert ticket sales for jazz artists?
SELECT SUM(C.Revenue) FROM Concerts C INNER JOIN Artists A ON C.ArtistID = A.ArtistID WHERE A.Genre = 'Jazz';
gretelai_synthetic_text_to_sql