context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE investment_rounds (company_id INT); INSERT INTO investment_rounds (company_id) VALUES (1); INSERT INTO investment_rounds (company_id) VALUES (3);
List all companies that have not had any investment rounds
SELECT c.id, c.name FROM company c LEFT JOIN investment_rounds ir ON c.id = ir.company_id WHERE ir.company_id IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE market_share (market_id INT, organization_id INT, region VARCHAR(255), quarter INT, year INT, market_share DECIMAL(4, 2));
What was the market share for each organization in the South region in Q2 2021?
SELECT organization_id, SUM(market_share) as total_market_share FROM market_share WHERE region = 'South' AND quarter = 2 AND year = 2021 GROUP BY organization_id;
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, name VARCHAR(50), followers INT); CREATE TABLE posts (user_id INT, post_text VARCHAR(255));
List the top 5 users with the most number of followers in the social_media schema?
SELECT u.name, u.followers FROM users u JOIN (SELECT user_id, MAX(followers) AS max_followers FROM users GROUP BY user_id) f ON u.id = f.user_id ORDER BY u.followers DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE CulturalEvents (event_date DATE, organizer VARCHAR(50), num_attendees INT); INSERT INTO CulturalEvents (event_date, organizer, num_attendees) VALUES ('2021-04-01', 'Asian Arts Council', 1200), ('2021-04-02', 'Asian Arts Council', 1500), ('2021-04-03', 'Asian Arts Council', 800), ('2021-05-01', 'Asian Heritage Foundation', 900), ('2021-05-02', 'Asian Heritage Foundation', 1200), ('2021-05-03', 'Asian Heritage Foundation', 1500), ('2021-06-01', 'Asian Cultural Society', 800), ('2021-06-02', 'Asian Cultural Society', 900), ('2021-06-03', 'Asian Cultural Society', 1200);
Who are the top 3 cultural event organizers with the highest average attendance in Asia in the last year?
SELECT organizer, AVG(num_attendees) FROM CulturalEvents WHERE event_date >= DATEADD(YEAR, -1, GETDATE()) AND organizer IN ('Asian Arts Council', 'Asian Heritage Foundation', 'Asian Cultural Society') GROUP BY organizer ORDER BY AVG(num_attendees) DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, FirstName VARCHAR(50), LastName VARCHAR(50), JobTitle VARCHAR(50), SupervisesSiteID INT); INSERT INTO Employees (EmployeeID, FirstName, LastName, JobTitle, SupervisesSiteID) VALUES (1, 'John', 'Doe', 'Site Manager', 1), (2, 'Jane', 'Doe', 'Environmental Manager', 2), (3, 'Bob', 'Smith', 'Resource Manager', 3); CREATE TABLE MiningSites (SiteID INT, SiteName VARCHAR(50), Location VARCHAR(50), WaterConsumptionRate INT); INSERT INTO MiningSites (SiteID, SiteName, Location, WaterConsumptionRate) VALUES (1, 'Site A', 'New York', 1000), (2, 'Site B', 'Ohio', 1200), (3, 'Site C', 'Alberta', 1500);
List all workers, their roles, and the mining sites they oversee that have a high water consumption rate
SELECT e.FirstName, e.LastName, e.JobTitle, s.SiteName, s.Location, s.WaterConsumptionRate FROM Employees e INNER JOIN MiningSites s ON e.SupervisesSiteID = s.SiteID WHERE s.WaterConsumptionRate > 1200;
gretelai_synthetic_text_to_sql
CREATE TABLE digital_assets (asset_id INT, asset_name VARCHAR(255), network VARCHAR(255), market_cap DECIMAL(10,2)); INSERT INTO digital_assets (asset_id, asset_name, network, market_cap) VALUES (1, 'ETH', 'ethereum', 2000000000), (2, 'USDC', 'ethereum', 500000000), (3, 'UNI', 'ethereum', 3000000000), (4, 'BTC', 'bitcoin', 6000000000); CREATE TABLE transactions (transaction_id INT, asset_id INT, value DECIMAL(10,2)); INSERT INTO transactions (transaction_id, asset_id, value) VALUES (1, 1, 100), (2, 1, 200), (3, 2, 50), (4, 2, 75), (5, 3, 300), (6, 3, 400), (7, 4, 5000), (8, 4, 6000);
What is the total value of all transactions involving digital assets with a market capitalization greater than $1 billion?
SELECT SUM(t.value) as total_value FROM digital_assets d JOIN transactions t ON d.asset_id = t.asset_id WHERE d.market_cap > 1000000000;
gretelai_synthetic_text_to_sql
CREATE TABLE clinics (country VARCHAR(20), clinic_name VARCHAR(50), patient_satisfaction_score INT); INSERT INTO clinics (country, clinic_name, patient_satisfaction_score) VALUES ('Australia', 'Clinic E', 90), ('Australia', 'Clinic F', 80), ('New Zealand', 'Clinic G', 88), ('New Zealand', 'Clinic H', 92);
How many rural health clinics are there in Australia and New Zealand that have a patient satisfaction score greater than 85?
SELECT country, COUNT(*) FROM clinics WHERE patient_satisfaction_score > 85 GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE SpendingData (Year INT, Country VARCHAR(255), Tourists INT, Spending DECIMAL(10,2)); INSERT INTO SpendingData (Year, Country, Tourists, Spending) VALUES (2019, 'Indonesia', 12000000, 650), (2019, 'Malaysia', 9000000, 800), (2019, 'Singapore', 7000000, 1200), (2019, 'Thailand', 15000000, 900), (2019, 'Philippines', 8000000, 450);
What is the percentage of international tourists in Southeast Asia who spent more than $1000 in 2019?
SELECT (SUM(CASE WHEN Spending > 1000 THEN 1 ELSE 0 END) * 100.0 / COUNT(*)) AS Percentage FROM SpendingData WHERE Country IN ('Indonesia', 'Malaysia', 'Singapore', 'Thailand', 'Philippines') AND Year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE smart_contracts (contract_id INT PRIMARY KEY, contract_name VARCHAR(50), developer_id INT, language VARCHAR(20), FOREIGN KEY (developer_id) REFERENCES developers(developer_id)); INSERT INTO smart_contracts (contract_id, contract_name, developer_id, language) VALUES (1, 'Contract1', 1, 'Solidity'); INSERT INTO smart_contracts (contract_id, contract_name, developer_id, language) VALUES (2, 'Contract2', 2, 'Vyper'); CREATE TABLE dapps (dapp_id INT PRIMARY KEY, dapp_name VARCHAR(50), contract_id INT, category VARCHAR(30), FOREIGN KEY (contract_id) REFERENCES smart_contracts(contract_id)); INSERT INTO dapps (dapp_id, dapp_name, contract_id, category) VALUES (1, 'Dapp1', 1, 'Finance'); INSERT INTO dapps (dapp_id, dapp_name, contract_id, category) VALUES (2, 'Dapp2', 2, 'Gaming');
Which dapps belong to the 'Gaming' category and were developed using Solidity?
SELECT dapps.dapp_name FROM dapps INNER JOIN smart_contracts ON dapps.contract_id = smart_contracts.contract_id WHERE dapps.category = 'Gaming' AND smart_contracts.language = 'Solidity';
gretelai_synthetic_text_to_sql
CREATE TABLE cities (id INT, name VARCHAR(255)); CREATE TABLE parks (id INT, city_id INT, name VARCHAR(255), number INT); CREATE TABLE recreation_centers (id INT, city_id INT, name VARCHAR(255), number INT);
What is the name and number of parks and recreation centers in each city?
SELECT c.name, p.number AS park_count, rc.number AS recreation_center_count FROM cities c LEFT JOIN parks p ON c.id = p.city_id LEFT JOIN recreation_centers rc ON c.id = rc.city_id;
gretelai_synthetic_text_to_sql
CREATE TABLE energy_prices (id INT, region VARCHAR(50), price FLOAT, date DATE); INSERT INTO energy_prices (id, region, price, date) VALUES (1, 'West', 60.1, '2022-02-15');
What is the average energy price for the 'West' region between February 15th and February 21st, 2022?
SELECT region, AVG(price) AS avg_price FROM energy_prices WHERE date BETWEEN '2022-02-15' AND '2022-02-21' AND region = 'West' GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE cybersecurity_incidents (region VARCHAR(50), year INT, num_incidents INT); INSERT INTO cybersecurity_incidents (region, year, num_incidents) VALUES ('China', 2019, 5000), ('China', 2020, 6000), ('China', 2021, 7000), ('India', 2019, 4000), ('India', 2020, 5000), ('India', 2021, 6000); INSERT INTO cybersecurity_incidents (region, year, num_incidents) VALUES ('Indonesia', 2019, 3000), ('Indonesia', 2020, 4000), ('Indonesia', 2021, 5000); INSERT INTO cybersecurity_incidents (region, year, num_incidents) VALUES ('Japan', 2019, 2000), ('Japan', 2020, 2500), ('Japan', 2021, 3000);
What is the maximum number of cybersecurity incidents reported in Asian countries in the last 3 years?
SELECT MAX(num_incidents) FROM cybersecurity_incidents WHERE region IN ('China', 'India', 'Indonesia', 'Japan') AND year BETWEEN 2019 AND 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE SUSTAINABLE_BRANDS (brand_id INT PRIMARY KEY, brand_name VARCHAR(50), country VARCHAR(50), sustainable_practices TEXT); INSERT INTO SUSTAINABLE_BRANDS (brand_id, brand_name, country, sustainable_practices) VALUES (1, 'BrandA', 'USA', 'Organic cotton, fair trade, recycled materials'), (2, 'BrandB', 'Brazil', 'Organic materials, fair trade'), (3, 'BrandC', 'USA', 'Recycled materials'), (4, 'BrandD', 'Brazil', 'Organic materials, fair trade');
Get the number of sustainable brands from each country.
SELECT country, COUNT(*) FROM SUSTAINABLE_BRANDS GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE Workouts (WorkoutID INT, WorkoutName VARCHAR(20), Category VARCHAR(10)); INSERT INTO Workouts (WorkoutID, WorkoutName, Category) VALUES (1, 'Treadmill', 'Cardio'), (2, 'Yoga', 'Strength'), (3, 'Cycling', 'Cardio'), (4, 'Push-ups', 'Strength'), (5, 'Squats', 'Strength');
What is the total number of workouts in each category?
SELECT Category, COUNT(*) FROM Workouts GROUP BY Category;
gretelai_synthetic_text_to_sql
CREATE TABLE emissions (id INT, category VARCHAR(255), subcategory VARCHAR(255), age_group VARCHAR(50), material VARCHAR(50), co2_reduction DECIMAL(10, 2), country VARCHAR(50)); INSERT INTO emissions (id, category, subcategory, age_group, material, co2_reduction, country) VALUES (1, 'Tops', 'T-Shirts', 'Children', 'Recycled Polyester', 2.4, 'United States'); INSERT INTO emissions (id, category, subcategory, age_group, material, co2_reduction, country) VALUES (2, 'Bottoms', 'Pants', 'Children', 'Recycled Polyester', 2.2, 'United States');
Find the average CO2 emissions reduction of children's garments made from recycled polyester in the United States.
SELECT AVG(co2_reduction) FROM emissions WHERE category IN ('Tops', 'Bottoms') AND age_group = 'Children' AND material = 'Recycled Polyester' AND country = 'United States';
gretelai_synthetic_text_to_sql
CREATE TABLE dapps (dapp_name VARCHAR(20), network VARCHAR(20), smart_contracts INT); INSERT INTO dapps (dapp_name, network, smart_contracts) VALUES ('Uniswap', 'Ethereum', 500), ('OpenSea', 'Ethereum', 300), ('Compound', 'Ethereum', 400);
List the top 3 decentralized applications by the number of smart contracts deployed in the 'Ethereum' network.
SELECT dapp_name, network, smart_contracts FROM (SELECT dapp_name, network, smart_contracts, ROW_NUMBER() OVER (PARTITION BY network ORDER BY smart_contracts DESC) as rn FROM dapps) x WHERE rn <= 3 AND network = 'Ethereum';
gretelai_synthetic_text_to_sql
CREATE TABLE monthly_usage (customer_id INT, month DATE, data_usage FLOAT); INSERT INTO monthly_usage VALUES (1, '2022-01-01', 100), (1, '2021-01-01', 110);
What is the difference in data usage in GB between the current month and the same month last year for each customer?
SELECT customer_id, LAG(SUM(data_usage)/1024/1024/1024, 12) OVER(PARTITION BY customer_id ORDER BY month) as previous_year_usage_gb, SUM(data_usage)/1024/1024/1024 as current_month_usage_gb FROM monthly_usage WHERE month >= DATEADD(month, -12, GETDATE()) GROUP BY customer_id, month;
gretelai_synthetic_text_to_sql
CREATE TABLE organizations (org_id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), type VARCHAR(255), contact_name VARCHAR(255), contact_email VARCHAR(255), contact_phone VARCHAR(20));
Update a legal aid organization in the 'organizations' table
UPDATE organizations SET location = 'Los Angeles, CA', type = 'Legal Aid' WHERE name = 'Justice for All';
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_projects (name TEXT, country TEXT, technology TEXT, capacity_mw INTEGER, year INTEGER);
Insert a new solar energy project in Mexico with 25 MW capacity in 2022.
INSERT INTO renewable_projects (name, country, technology, capacity_mw, year) VALUES ('Project D', 'Mexico', 'Solar', 25, 2022);
gretelai_synthetic_text_to_sql
CREATE TABLE fish_stock_4 (species VARCHAR(255), dissolved_oxygen FLOAT); INSERT INTO fish_stock_4 (species, dissolved_oxygen) VALUES ('Tilapia', 6.9), ('Catfish', 5.9), ('Salmon', 7.3);
What is the maximum dissolved oxygen level in the fish_stock_4 table for each species?
SELECT species, MAX(dissolved_oxygen) FROM fish_stock_4 GROUP BY species;
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (volunteer_id INT, volunteer_join_date DATE, state VARCHAR(50));
How many volunteers joined in Q1 2022 from the state of New York?
SELECT COUNT(volunteer_id) FROM volunteers WHERE QUARTER(volunteer_join_date) = 1 AND state = 'New York' AND YEAR(volunteer_join_date) = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE artists(artist_id INT, name VARCHAR(50));
Insert new artists 'Rosalía' and 'Ozuna' into the artists table.
INSERT INTO artists (name) VALUES ('Rosalía'), ('Ozuna');
gretelai_synthetic_text_to_sql
CREATE TABLE bus_routes (route_id INT, city VARCHAR(50), avg_time_between_departures TIME); INSERT INTO bus_routes (route_id, city, avg_time_between_departures) VALUES (1, 'Chicago', '00:15:00'), (2, 'Chicago', '00:20:00'), (3, 'Chicago', '00:10:00');
What is the average time between bus departures for a given route in Chicago?
SELECT AVG(avg_time_between_departures) FROM bus_routes WHERE city = 'Chicago';
gretelai_synthetic_text_to_sql
CREATE TABLE plants (id INT, name TEXT, country TEXT); INSERT INTO plants (id, name, country) VALUES (1, 'PlantA', 'Germany'), (2, 'PlantB', 'France'); CREATE TABLE employees (id INT, name TEXT, department TEXT, plant_id INT); INSERT INTO employees (id, name, department, plant_id) VALUES (1, 'John', 'manufacturing', 1), (2, 'Jane', 'engineering', 1), (3, 'Peter', 'manufacturing', 2);
What is the total number of employees working in the 'manufacturing' department across all plants in Germany?
SELECT COUNT(*) FROM employees INNER JOIN plants ON employees.plant_id = plants.id WHERE employees.department = 'manufacturing' AND plants.country = 'Germany';
gretelai_synthetic_text_to_sql
CREATE TABLE obesity_rates (zip TEXT, rate INT); INSERT INTO obesity_rates (zip, rate) VALUES ('12345', 40);
Which ZIP codes in the US have the highest obesity rates?
SELECT zip, AVG(rate) FROM obesity_rates GROUP BY zip HAVING AVG(rate) >= (SELECT AVG(rate) FROM obesity_rates WHERE zip = '12345') ORDER BY AVG(rate) DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE eco_certified_sites (site_id INT, site_name TEXT, city TEXT, eco_certified BOOLEAN); INSERT INTO eco_certified_sites (site_id, site_name, city, eco_certified) VALUES (1, 'Eco-Park', 'Rio de Janeiro', true), (2, 'Green Castle', 'Dublin', true), (3, 'Sustainable Museum', 'Paris', false);
What is the total number of eco-certified cultural heritage sites?
SELECT COUNT(*) FROM eco_certified_sites WHERE eco_certified = true;
gretelai_synthetic_text_to_sql
CREATE TABLE animals (id INT, name VARCHAR(50), species VARCHAR(50), population_size INT, size_km FLOAT); INSERT INTO animals (id, name, species, population_size, size_km) VALUES (1, 'Bear', 'Ursidae', 450, 45.6);
What is the average population size for mammals in the 'animals' table with a size greater than 25 square kilometers?
SELECT AVG(population_size) FROM animals WHERE size_km > 25 AND species = 'Ursidae';
gretelai_synthetic_text_to_sql
CREATE TABLE wind_turbines (id INT, region VARCHAR(20), power_output FLOAT); INSERT INTO wind_turbines (id, region, power_output) VALUES (1, 'Midwest', 3.4), (2, 'South', 4.2), (3, 'Midwest', 5.1), (4, 'Northeast', 2.9);
What is the maximum power output of a wind turbine in the 'Midwest' region?
SELECT MAX(power_output) FROM wind_turbines WHERE region = 'Midwest';
gretelai_synthetic_text_to_sql
CREATE TABLE rovs (name VARCHAR(255), manufacturer VARCHAR(255), max_depth INT, min_depth INT); INSERT INTO rovs (name, manufacturer, max_depth, min_depth) VALUES ('ROV1', 'Manufacturer1', 6000, 500);
What are the maximum and minimum operating depths for deep-sea ROVs?
SELECT MAX(max_depth), MIN(min_depth) FROM rovs
gretelai_synthetic_text_to_sql
CREATE TABLE excavation_sites (id INT, country VARCHAR(255), depth FLOAT); INSERT INTO excavation_sites (id, country, depth) VALUES (1, 'France', 4.2), (2, 'Spain', 3.9), (3, 'France', 4.5);
What is the average depth of all excavation sites in France?
SELECT AVG(depth) FROM excavation_sites WHERE country = 'France';
gretelai_synthetic_text_to_sql
CREATE TABLE sales_person_data (salesperson VARCHAR(20), product VARCHAR(20), sales_amount DECIMAL(10,2)); INSERT INTO sales_person_data VALUES ('John', 'Laptop', 1200.00), ('John', 'Phone', 500.00), ('Jane', 'Phone', 300.00), ('Jane', 'Tablet', 800.00), ('John', 'Tablet', 600.00);
Identify the salesperson who made the most sales for a specific product, showing the salesperson, product, and sales amount.
SELECT salesperson, product, MAX(sales_amount) AS max_sales FROM sales_person_data GROUP BY product;
gretelai_synthetic_text_to_sql
CREATE TABLE energy (id INT, project_name VARCHAR(50), location VARCHAR(50), cost FLOAT); INSERT INTO energy (id, project_name, location, cost) VALUES (1, 'Wind Farm', 'Region C', 15000000.00), (2, 'Solar Power Plant', 'City D', 20000000.00), (3, 'Geothermal Plant', 'Area E', 18000000.00);
What is the average cost of projects in the 'energy' table?
SELECT AVG(cost) FROM energy;
gretelai_synthetic_text_to_sql
CREATE TABLE districts (id INT, name TEXT);CREATE TABLE emergencies (id INT, district_id INT, date_time DATETIME);
What is the maximum number of emergency calls received in a single hour in each district?
SELECT d.name, MAX(HOUR(e.date_time)) as hour, COUNT(e.id) as calls FROM districts d JOIN emergencies e ON d.id = e.district_id GROUP BY d.id, hour;
gretelai_synthetic_text_to_sql
CREATE TABLE world_news (id INT, headline VARCHAR(255), source VARCHAR(255), published_date DATE, country VARCHAR(255));
Which countries had the most news articles published about them in the 'world_news' table?
SELECT country, COUNT(*) as articles_about_country FROM world_news GROUP BY country ORDER BY articles_about_country DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE species_so (id INT, name TEXT, location TEXT); INSERT INTO species_so (id, name, location) VALUES (1, 'Krill', 'Southern Ocean'); INSERT INTO species_so (id, name, location) VALUES (2, 'Seal', 'Atlantic Ocean');
What is the total number of marine species that have been observed in the Southern Ocean?
SELECT COUNT(*) FROM species_so WHERE location = 'Southern Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE ModelFairness (model_name TEXT, fairness_score FLOAT, observation_date DATE); INSERT INTO ModelFairness (model_name, fairness_score, observation_date) VALUES ('ModelA', 0.85, '2021-01-01'), ('ModelA', 0.86, '2021-02-01'), ('ModelB', 0.90, '2021-01-01'), ('ModelB', 0.91, '2021-02-01');
What is the change in fairness score for each model from the first to the last observation?
SELECT model_name, LAG(fairness_score) OVER (PARTITION BY model_name ORDER BY observation_date) lag_score, fairness_score, fairness_score - LAG(fairness_score) OVER (PARTITION BY model_name ORDER BY observation_date) change FROM ModelFairness;
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT PRIMARY KEY, Name VARCHAR(100), Age INT, Sport VARCHAR(50), Country VARCHAR(50)); CREATE TABLE Players_Stats (PlayerID INT, Stat VARCHAR(50), Value INT); INSERT INTO Players_Stats (PlayerID, Stat, Value) VALUES (1, 'Goals', 10); INSERT INTO Players_Stats (PlayerID, Stat, Value) VALUES (1, 'Assists', 5); INSERT INTO Players_Stats (PlayerID, Stat, Value) VALUES (2, 'Goals', 15); INSERT INTO Players_Stats (PlayerID, Stat, Value) VALUES (2, 'Assists', 8);
What is the sum of goals and assists for all ice hockey players from Russia?
SELECT SUM(Value) as TotalGoalsAndAssists FROM Players_Stats JOIN Players ON Players.PlayerID = Players_Stats.PlayerID WHERE Players.Sport = 'Ice Hockey' AND Players.Country = 'Russia';
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_line VARCHAR(20), calorie_count INT); INSERT INTO products (product_id, product_line, calorie_count) VALUES (1, 'organic', 150), (2, 'conventional', 200);
What is the average calorie count for items in the organic product line?
SELECT AVG(calorie_count) FROM products WHERE product_line = 'organic';
gretelai_synthetic_text_to_sql
CREATE TABLE interactions (id INT, user_id INT, interaction_date DATE); INSERT INTO interactions (id, user_id, interaction_date) VALUES (1, 1001, '2022-02-01'), (2, 1002, '2022-02-15'), (3, 1003, '2022-02-20'), (4, 1001, '2022-02-25'), (5, 1004, '2022-03-01'), (6, 1003, '2022-02-03');
Delete records of users who have not interacted with the explainable AI system in the past month
DELETE FROM interactions WHERE interaction_date < NOW() - INTERVAL 1 MONTH;
gretelai_synthetic_text_to_sql
CREATE TABLE southern_ocean_pollution (report_year INT, incident_count INT); INSERT INTO southern_ocean_pollution (report_year, incident_count) VALUES (2019, 3), (2018, 4);
How many pollution incidents were reported in the Southern Ocean in 2019?
SELECT SUM(incident_count) FROM southern_ocean_pollution WHERE report_year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE usage (id INT, subscriber_id INT, data_usage DECIMAL(10,2), type VARCHAR(10), region VARCHAR(10), usage_date DATE); INSERT INTO usage (id, subscriber_id, data_usage, type, region, usage_date) VALUES (1, 1, 12.5, 'mobile', 'Europe', '2022-01-01'), (2, 2, 8.0, 'mobile', 'Europe', '2022-01-02'), (3, 3, 15.0, 'broadband', 'Europe', '2022-01-03');
What is the maximum amount of data used in a single day by mobile customers in the 'Europe' region?
SELECT MAX(usage.data_usage) AS max_data_usage FROM usage WHERE usage.type = 'mobile' AND usage.region = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE providers (id INT, name TEXT, specialty TEXT); INSERT INTO providers (id, name, specialty) VALUES (1, 'Dr. Patel', 'Obstetrics'), (2, 'Dr. Kim', 'Pediatrics'), (3, 'Dr. Garcia', 'Obstetrics and Pediatrics');
Find the intersection of providers who work in 'Obstetrics' and 'Pediatrics' specialties?
SELECT name FROM providers WHERE specialty = 'Obstetrics' INTERSECT SELECT name FROM providers WHERE specialty = 'Pediatrics';
gretelai_synthetic_text_to_sql
CREATE TABLE company (id INT, name TEXT, founder_age INT, industry TEXT); INSERT INTO company (id, name, founder_age, industry) VALUES (1, 'FinTech', 45, 'Financial Technology'); INSERT INTO company (id, name, founder_age, industry) VALUES (2, 'BankingInnovations', 50, 'Financial Technology');
What is the total funding received by startups founded by people over the age of 40 in the financial technology industry?
SELECT SUM(funding_amount) FROM funding INNER JOIN company ON funding.company_id = company.id WHERE company.founder_age > 40 AND company.industry = 'Financial Technology';
gretelai_synthetic_text_to_sql
CREATE TABLE Roads (name TEXT, number TEXT, state TEXT);
Find the number of roads in each state that intersect with an interstate.
SELECT state, COUNT(*) FROM Roads WHERE number LIKE 'I-%' GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas (area_name VARCHAR(50), region VARCHAR(50), area_size INT);
What is the total area of marine protected areas in the 'marine_protected_areas' table, grouped by region?"
SELECT region, SUM(area_size) FROM marine_protected_areas GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE sites (site_id INT, state VARCHAR(2)); CREATE TABLE environmental_impact_assessments (assessment_id INT, site_id INT, assessment_date DATE);
List all mining sites located in 'CA' and 'NV' that have recorded environmental impact assessments.
SELECT s.site_id, s.state FROM sites s INNER JOIN environmental_impact_assessments e ON s.site_id = e.site_id WHERE s.state IN ('CA', 'NV');
gretelai_synthetic_text_to_sql
CREATE TABLE community_health_workers (worker_id INT, age INT, cultural_competency_score INT); INSERT INTO community_health_workers (worker_id, age, cultural_competency_score) VALUES (1, 35, 80), (2, 40, 85), (3, 45, 90);
What is the average cultural competency score for community health workers by age group?
SELECT age_group, AVG(cultural_competency_score) FROM (SELECT CASE WHEN age < 40 THEN 'Under 40' ELSE '40 and over' END AS age_group, cultural_competency_score FROM community_health_workers) AS subquery GROUP BY age_group;
gretelai_synthetic_text_to_sql
CREATE TABLE equipment_maintenance (maintenance_id INT, maintenance_date DATE, equipment_type VARCHAR(255), region VARCHAR(255)); INSERT INTO equipment_maintenance (maintenance_id, maintenance_date, equipment_type, region) VALUES (1, '2021-12-31', 'aircraft', 'Asia-Pacific'), (2, '2022-04-04', 'tank', 'Europe'), (3, '2022-06-15', 'aircraft', 'Asia-Pacific');
List all military equipment maintenance activities performed on aircraft in the Asia-Pacific region in the last 6 months.
SELECT * FROM equipment_maintenance WHERE equipment_type = 'aircraft' AND region = 'Asia-Pacific' AND maintenance_date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH);
gretelai_synthetic_text_to_sql
CREATE SCHEMA energy_efficiency; CREATE TABLE efficiency_projects (id INT, name VARCHAR(50), carbon_reduction FLOAT, cost_savings FLOAT); INSERT INTO efficiency_projects (id, name, carbon_reduction, cost_savings) VALUES (1, 'Efficiency Project 1', 200.5, 0.16), (2, 'Efficiency Project 2', 150.3, 0.18), (3, 'Efficiency Project 3', 250.0, 0.12), (4, 'Efficiency Project 4', 100.0, 0.22), (5, 'Efficiency Project 5', 300.0, 0.15);
What is the total carbon emissions reduction in metric tons for energy efficiency projects in the 'energy_efficiency' schema, for projects that have achieved a cost savings of at least 15%?
SELECT SUM(carbon_reduction) as total_carbon_reduction FROM energy_efficiency.efficiency_projects WHERE cost_savings >= 0.15;
gretelai_synthetic_text_to_sql
CREATE TABLE Concerts (concert_id INT, artist VARCHAR(50), tier VARCHAR(50), sales INT, price DECIMAL(10, 2)); INSERT INTO Concerts (concert_id, artist, tier, sales, price) VALUES (1, 'Taylor Swift', 'Platinum', 5000, 150), (2, 'The Rolling Stones', 'Gold', 7000, 120), (3, 'Miles Davis', 'Silver', 6000, 90), (4, 'Taylor Swift', 'Platinum', 5000, 160), (5, 'Jay Z', 'Gold', 7000, 130);
Which artist has the highest average ticket price for their concerts?
SELECT artist, AVG(price) as avg_price FROM Concerts GROUP BY artist ORDER BY avg_price DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Restaurants (id INT, name TEXT, type TEXT, revenue FLOAT); INSERT INTO Restaurants (id, name, type, revenue) VALUES (1, 'Restaurant A', 'Italian', 5000.00), (2, 'Restaurant B', 'Chinese', 6000.00), (3, 'Restaurant C', 'Chinese', 9000.00);
What is the average revenue for restaurants serving Chinese food?
SELECT AVG(revenue) FROM Restaurants WHERE type = 'Chinese';
gretelai_synthetic_text_to_sql
CREATE TABLE energy_efficiency (technology VARCHAR(255), year INT, improvement FLOAT);
What was the maximum energy efficiency improvement (in %) for any technology in 2021?
SELECT MAX(improvement) FROM energy_efficiency WHERE year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE organizations (id INT, name VARCHAR(50), type VARCHAR(50), country VARCHAR(50)); INSERT INTO organizations (id, name, type, country) VALUES (1, 'Accessible AI', 'Non-profit', 'USA'), (2, 'Tech for Social Good', 'Non-governmental', 'India'), (3, 'Digital Divide Initiative', 'Non-profit', 'Brazil');
Update the 'name' of organization with 'id' 2 to 'Tech for Social Good Org'
UPDATE organizations SET name = 'Tech for Social Good Org' WHERE id = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE investigative_reports (id INT, title VARCHAR(255), author VARCHAR(255), publication_date DATE, word_count INT);
Who are the top 3 authors with the highest average word count per article in the 'investigative_reports' table?
SELECT author, AVG(word_count) as avg_word_count FROM investigative_reports GROUP BY author ORDER BY avg_word_count DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, DonorName TEXT, Country TEXT); INSERT INTO Donors (DonorID, DonorName, Country) VALUES (1, 'John Doe', 'USA'), (2, 'Jane Smith', 'Canada'); CREATE TABLE Donations (DonationID INT, DonorID INT, DonationAmount DECIMAL); INSERT INTO Donations (DonationID, DonorID, DonationAmount) VALUES (1, 1, 500), (2, 1, 250), (3, 2, 300), (4, 2, 150);
What's the total amount donated by individual donors from the USA and Canada?
SELECT SUM(DonationAmount) FROM Donations D JOIN Donors DON ON D.DonorID = DON.DonorID WHERE DON.Country IN ('USA', 'Canada');
gretelai_synthetic_text_to_sql
CREATE TABLE military_personnel (id INT, personnel_name VARCHAR(255), region VARCHAR(255), rank VARCHAR(255), personnel_date DATE);
How many military personnel are stationed in each region based on the 'military_personnel' table?
SELECT region, COUNT(*) as personnel_count FROM military_personnel GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE public_parks (name VARCHAR(255), city VARCHAR(255), area FLOAT); INSERT INTO public_parks (name, city, area) VALUES ('Central Park', 'New York', 341.0), ('Prospect Park', 'New York', 526.0), ('Washington Square Park', 'New York', 9.75);
What is the total number of public parks in New York City and the total area they cover?
SELECT SUM(area) AS total_area, 'New York' AS city FROM public_parks WHERE city = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_pricing (region VARCHAR(20), price DECIMAL(5,2));CREATE TABLE energy_efficiency (region VARCHAR(20), efficiency INT);
List the carbon pricing for regions with the highest energy efficiency in 2021
SELECT c.region, c.price FROM carbon_pricing c JOIN (SELECT region FROM energy_efficiency WHERE efficiency = (SELECT MAX(efficiency) FROM energy_efficiency) LIMIT 1) e ON c.region = e.region;
gretelai_synthetic_text_to_sql
CREATE TABLE budgets (id INT, city VARCHAR, department VARCHAR, year INT, budget FLOAT); INSERT INTO budgets (id, city, department, year, budget) VALUES (1, 'Los Angeles', 'Education', 2021, 1000000.00);
What is the total budget of the department of education in the city of Los Angeles in 2021?
SELECT SUM(budget) FROM budgets WHERE city = 'Los Angeles' AND department = 'Education' AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE energy_consumption (country VARCHAR(255), sector VARCHAR(255), consumption INT); INSERT INTO energy_consumption (country, sector, consumption) VALUES ('Brazil', 'Residential', 5000), ('Brazil', 'Commercial', 7000), ('Brazil', 'Industrial', 10000);
What is the total energy consumption in Brazil by sector (residential, commercial, industrial)?
SELECT SUM(consumption) FROM energy_consumption WHERE country = 'Brazil';
gretelai_synthetic_text_to_sql
CREATE TABLE players (id INT PRIMARY KEY, name VARCHAR(50), age INT, sport VARCHAR(50));
Delete the sport column from the players table
ALTER TABLE players DROP COLUMN sport;
gretelai_synthetic_text_to_sql
CREATE TABLE artists (artist_id INT, artist_name VARCHAR(100), genre VARCHAR(50)); INSERT INTO artists (artist_id, artist_name, genre) VALUES (1, 'Dolly Parton', 'country'), (2, 'Garth Brooks', 'country'), (3, 'Shania Twain', 'country'), (4, 'Johnny Cash', 'country'), (5, 'Taylor Swift', 'country'), (6, 'Carrie Underwood', 'country'); CREATE TABLE songs (song_id INT, song_name VARCHAR(100), artist_id INT); INSERT INTO songs (song_id, song_name, artist_id) VALUES (1, 'Jolene', 1), (2, 'Friends in Low Places', 2), (3, 'Man! I Feel Like a Woman!', 3), (4, 'I Walk the Line', 4), (5, 'Love Story', 5), (6, 'Before He Cheats', 6), (7, 'Shake it Off', 5);
How many unique artists are there in the country genre?
SELECT COUNT(DISTINCT artists.artist_name) as num_artists FROM artists JOIN songs ON artists.artist_id = songs.artist_id WHERE artists.genre = 'country';
gretelai_synthetic_text_to_sql
CREATE TABLE Policyholders (PolicyholderID INT, Age INT, Country VARCHAR(20)); INSERT INTO Policyholders (PolicyholderID, Age, Country) VALUES (1, 25, 'USA'), (2, 30, 'USA'), (3, 45, 'Canada'), (4, 50, 'Canada'), (5, 60, 'Mexico');
What is the policy count for policyholders in each age group, in 5-year intervals, for policyholders in each country?
SELECT Country, FLOOR(Age / 5) * 5 AS AgeGroup, COUNT(*) AS PolicyCount FROM Policyholders GROUP BY Country, AgeGroup;
gretelai_synthetic_text_to_sql
CREATE TABLE MarineLife (id INT, ocean_id INT, species VARCHAR(50), biomass INT); INSERT INTO MarineLife (id, ocean_id, species, biomass) VALUES (1, 1, 'Blue Whale', 190000), (2, 1, 'Fin Whale', 74000), (3, 2, 'Sperm Whale', 57000), (4, 2, 'Humpback Whale', 36000);
What is the total biomass of all whale species in the Atlantic Ocean?
SELECT SUM(MarineLife.biomass) FROM MarineLife JOIN Oceans ON MarineLife.ocean_id = Oceans.id WHERE Oceans.name = 'Atlantic' AND MarineLife.species LIKE '%Whale%';
gretelai_synthetic_text_to_sql
CREATE TABLE TVShows (id INT, title VARCHAR(100), genre VARCHAR(20), viewers INT, budget FLOAT, revenue FLOAT);
What's the total revenue for TV shows in the 'Drama' genre?
SELECT SUM(revenue) FROM TVShows WHERE genre = 'Drama';
gretelai_synthetic_text_to_sql
CREATE TABLE spacecrafts (id INT, name VARCHAR(50), launches INT, failures INT); INSERT INTO spacecrafts VALUES (1, 'Dragon', 30, 2); INSERT INTO spacecrafts VALUES (2, 'Falcon', 15, 0);
What is the failure rate of each spacecraft model?
SELECT name, (failures * 100 / launches) as failure_rate FROM spacecrafts;
gretelai_synthetic_text_to_sql
CREATE TABLE PolicyTypes (PolicyTypeID INT, PolicyType TEXT); INSERT INTO PolicyTypes (PolicyTypeID, PolicyType) VALUES (1, 'Home'), (2, 'Auto'), (3, 'Life'); CREATE TABLE Policyholders (PolicyholderID INT, PolicyholderName TEXT, PolicyTypeID INT); INSERT INTO Policyholders (PolicyholderID, PolicyholderName, PolicyTypeID) VALUES (1, 'John Doe', 1), (2, 'Jane Smith', 2), (3, 'Bob Johnson', 2), (4, 'Alice Williams', 3), (5, 'Charlie Brown', 3); CREATE TABLE Claims (ClaimID INT, PolicyholderID INT, ClaimDate DATE); INSERT INTO Claims (ClaimID, PolicyholderID, ClaimDate) VALUES (1, 1, '2022-01-15'), (2, 1, '2022-02-10'), (3, 2, '2022-02-20'), (4, 2, '2022-02-25');
List all policy types that have no claims, ordered by policy type.
SELECT PolicyTypes.PolicyType FROM PolicyTypes LEFT JOIN Policyholders ON PolicyTypes.PolicyTypeID = Policyholders.PolicyTypeID LEFT JOIN Claims ON Policyholders.PolicyholderID = Claims.PolicyholderID WHERE Claims.ClaimID IS NULL GROUP BY PolicyTypes.PolicyType ORDER BY PolicyTypes.PolicyType;
gretelai_synthetic_text_to_sql
CREATE TABLE disaster_preparedness (id INT, resource VARCHAR(255), location VARCHAR(255), quantity INT, timestamp TIMESTAMP); INSERT INTO disaster_preparedness (id, resource, location, quantity, timestamp) VALUES (1, 'Water', 'Miami', 500, '2021-01-05 11:00:00'); INSERT INTO disaster_preparedness (id, resource, location, quantity, timestamp) VALUES (2, 'Food', 'San Francisco', 300, '2021-01-06 17:30:00');
Identify the disaster resources with the highest and lowest quantities?
SELECT resource, MIN(quantity) as lowest, MAX(quantity) as highest FROM disaster_preparedness GROUP BY resource;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_research_projects (project_name TEXT, org_name TEXT); INSERT INTO marine_research_projects (project_name, org_name) VALUES ('Project 1', 'Ocean Discoverers'), ('Project 2', 'Ocean Discoverers'), ('Project 3', 'Ocean Explorers');
How many marine research projects does the "Ocean Discoverers" organization have in total?
SELECT COUNT(*) FROM marine_research_projects WHERE org_name = 'Ocean Discoverers';
gretelai_synthetic_text_to_sql
CREATE TABLE Customers (CustomerID int, CustomerName varchar(50), PreferredCategory varchar(50)); INSERT INTO Customers (CustomerID, CustomerName, PreferredCategory) VALUES (1, 'SustainableSam', 'Women''s Dresses'); INSERT INTO Customers (CustomerID, CustomerName, PreferredCategory) VALUES (2, 'EcoElla', 'Men''s Shirts'); CREATE TABLE Orders (OrderID int, CustomerID int, ProductID int, Sustainable boolean); INSERT INTO Orders (OrderID, CustomerID, ProductID, Sustainable) VALUES (1, 1, 1, true); INSERT INTO Orders (OrderID, CustomerID, ProductID, Sustainable) VALUES (2, 2, 2, true);
Show the total number of unique customers who have purchased sustainable clothing items, grouped by their preferred clothing category.
SELECT c.PreferredCategory, COUNT(DISTINCT o.CustomerID) as TotalCustomers FROM Customers c INNER JOIN Orders o ON c.CustomerID = o.CustomerID WHERE o.Sustainable = true GROUP BY c.PreferredCategory;
gretelai_synthetic_text_to_sql
CREATE TABLE VesselCargo (VesselID INT, CargoID INT); INSERT INTO VesselCargo (VesselID, CargoID) VALUES (1, 1), (2, 2), (3, NULL), (4, 4);
Find vessels that have never loaded cargo.
SELECT VesselID FROM VesselCargo WHERE CargoID IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE OceanPollution (PollutantID INT, Pollutant VARCHAR(255), Source VARCHAR(255), Quantity FLOAT, Location VARCHAR(255));
Insert new data into the 'OceanPollution' table
INSERT INTO OceanPollution (PollutantID, Pollutant, Source, Quantity, Location) VALUES (1, 'Oil', 'Offshore Drilling', 150.5, 'Gulf of Mexico');
gretelai_synthetic_text_to_sql
CREATE TABLE policy_start_date (policy_id INT, policy_start_date DATE); CREATE TABLE policies (policy_id INT, policyholder_id INT); INSERT INTO policy_start_date VALUES (1, '2019-01-01'); INSERT INTO policies VALUES (1, 1);
What is the minimum policy start date by policyholder state?
SELECT policyholder_state, MIN(policy_start_date) as min_policy_start_date FROM policies JOIN policy_start_date ON policies.policy_id = policy_start_date.policy_id JOIN policyholder_state ON policies.policyholder_id = policyholder_state.policyholder_id GROUP BY policyholder_state;
gretelai_synthetic_text_to_sql
CREATE TABLE sustainable_practices (id INT PRIMARY KEY, hotel_name VARCHAR(255), country VARCHAR(255), practice VARCHAR(255));
Add a new record to the sustainable_practices table
INSERT INTO sustainable_practices (id, hotel_name, country, practice) VALUES (1, 'Eco-Friendly Hotel', 'Sweden', 'Recycling program');
gretelai_synthetic_text_to_sql
CREATE TABLE landfill_capacity (id INT, region VARCHAR(255), year INT, capacity INT); INSERT INTO landfill_capacity (id, region, year, capacity) VALUES (1, 'Asia', 2019, 20000), (2, 'Asia', 2020, 22000), (3, 'Europe', 2019, 18000), (4, 'Europe', 2020, 20000);
What is the change in landfill capacity for each region between 2019 and 2020?
SELECT region, (capacity - LAG(capacity) OVER (PARTITION BY region ORDER BY year)) AS change FROM landfill_capacity;
gretelai_synthetic_text_to_sql
CREATE TABLE Products (Product_ID INT, Product_Name TEXT, Is_Cruelty_Free BOOLEAN, Is_Vegan BOOLEAN); INSERT INTO Products (Product_ID, Product_Name, Is_Cruelty_Free, Is_Vegan) VALUES (1, 'Lush Dream Cream', true, true), (2, 'Estée Lauder Double Wear Foundation', false, false), (3, 'The Body Shop Vitamin E Moisture Cream', true, true); CREATE TABLE Ratings (Rating_ID INT, Product_ID INT, Rating DECIMAL(2,1)); INSERT INTO Ratings (Rating_ID, Product_ID, Rating) VALUES (1, 1, 4.5), (2, 1, 5.0), (3, 2, 4.0), (4, 3, 4.8), (5, 3, 4.9);
What are the average ratings for cosmetic products that are both cruelty-free and vegan?
SELECT AVG(R.Rating) FROM Products P INNER JOIN Ratings R ON P.Product_ID = R.Product_ID WHERE P.Is_Cruelty_Free = true AND P.Is_Vegan = true;
gretelai_synthetic_text_to_sql
CREATE TABLE green_building_projects (id INT, project_name VARCHAR(50), city VARCHAR(50), country VARCHAR(50), investment FLOAT); INSERT INTO green_building_projects (id, project_name, city, country, investment) VALUES (1, 'Vancouver Green Building', 'Vancouver', 'Canada', 35000000);
What is the total investment in green building projects in Vancouver, Canada?
SELECT SUM(investment) FROM green_building_projects WHERE city = 'Vancouver' AND country = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE views (id INT, article_id INT, region VARCHAR(30), views INT); INSERT INTO views (id, article_id, region, views) VALUES (1, 1, 'asia', 1000), (2, 2, 'europe', 500), (3, 3, 'asia', 2000);
What is the maximum number of views for articles published in 'asia' region?
SELECT MAX(views) FROM views WHERE region = 'asia';
gretelai_synthetic_text_to_sql
CREATE TABLE menu_items (menu_item_id INT, menu_item_name VARCHAR(50), category VARCHAR(50), price FLOAT, quantity_sold INT); INSERT INTO menu_items (menu_item_id, menu_item_name, category, price, quantity_sold) VALUES (1, 'Burger', 'Main Course', 12.99, 1500);
Which menu items have the lowest and highest quantity sold, and what is the price of these items?
SELECT menu_item_name, price, quantity_sold, RANK() OVER (ORDER BY quantity_sold) FROM menu_items;
gretelai_synthetic_text_to_sql
CREATE TABLE Facility(Id INT, Name VARCHAR(50), Location VARCHAR(50)); CREATE TABLE SafetyIncident(Id INT, FacilityId INT, IncidentDate DATE);
How many safety incidents were reported by each facility, in total and per month?
SELECT f.Name, COUNT(si.Id) AS TotalIncidents, DATE_FORMAT(si.IncidentDate, '%Y-%m') AS Month, COUNT(si.Id) AS MonthlyIncidents FROM SafetyIncident si JOIN Facility f ON si.FacilityId = f.Id GROUP BY f.Name, Month WITH ROLLUP;
gretelai_synthetic_text_to_sql
CREATE TABLE student_mental_health (student_id INT, mental_health_score INT, date DATE); INSERT INTO student_mental_health (student_id, mental_health_score, date) VALUES (1, 80, '2021-09-01'), (2, 85, '2021-09-01'), (3, 70, '2021-09-02');
What is the average mental health score of students in 'Fall 2021'?
SELECT AVG(mental_health_score) FROM student_mental_health WHERE date = '2021-09-01';
gretelai_synthetic_text_to_sql
CREATE TABLE legal_aid_services (service_id INT, service_name VARCHAR(25), location VARCHAR(30), access_date DATE);
How many individuals have accessed legal aid services in the 'legal_aid_services' table?
SELECT COUNT(*) FROM legal_aid_services;
gretelai_synthetic_text_to_sql
CREATE TABLE UnionMembers (id INT, name VARCHAR(50), union_name VARCHAR(50), membership_start_date DATE, membership_end_date DATE); INSERT INTO UnionMembers (id, name, union_name, membership_start_date, membership_end_date) VALUES (1, 'John Doe', 'Union A', '2020-01-01', '2022-01-01');
Delete records of members who left before 2020 from Union Members table
DELETE FROM UnionMembers WHERE membership_end_date < '2020-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE SatelliteDeploymentsByType (id INT, organization VARCHAR(50), satellite_type VARCHAR(50), deployment_year INT); INSERT INTO SatelliteDeploymentsByType (id, organization, satellite_type, deployment_year) VALUES (1, 'NASA', 'Communications', 2010), (2, 'NASA', 'Earth Observation', 2015), (3, 'SpaceX', 'Communications', 2017), (4, 'SpaceX', 'Navigation', 2018), (5, 'ISRO', 'Earth Observation', 2020);
What is the distribution of satellite deployments by organization and type?
SELECT organization, satellite_type, deployment_year, COUNT(*) as total_deployments FROM SatelliteDeploymentsByType GROUP BY organization, satellite_type, deployment_year ORDER BY organization, satellite_type, deployment_year;
gretelai_synthetic_text_to_sql
CREATE TABLE daily_deliveries (delivery_id INT, item_count INT, delivery_date DATE, location VARCHAR(50)); INSERT INTO daily_deliveries (delivery_id, item_count, delivery_date, location) VALUES (1, 5, '2021-01-01', 'Oceania'), (2, 10, '2021-01-02', 'Oceania');
What is the minimum number of items delivered per day for 'daily_deliveries' table for 'Oceania' in the year 2021?
SELECT MIN(item_count) FROM daily_deliveries WHERE EXTRACT(YEAR FROM delivery_date) = 2021 AND location = 'Oceania';
gretelai_synthetic_text_to_sql
CREATE TABLE Investors (InvestorID INT, Gender VARCHAR(10), Amount INT); INSERT INTO Investors (InvestorID, Gender, Amount) VALUES (1, 'Male', 5000), (2, 'Female', 7000), (3, 'Non-binary', 6000);
What is the total amount of investments made by different genders?
SELECT Gender, SUM(Amount) as TotalInvestment FROM Investors GROUP BY Gender;
gretelai_synthetic_text_to_sql
CREATE TABLE vehicle_maintenance (maintenance_id INT, route_id INT, maintenance_date DATE);
Determine the average time between vehicle maintenance for each route
SELECT routes.route_name, AVG(DATEDIFF(day, LAG(maintenance_date, 1) OVER (PARTITION BY route_id ORDER BY maintenance_date), maintenance_date)) AS average_days_between_maintenance FROM vehicle_maintenance JOIN routes ON vehicle_maintenance.route_id = routes.route_id GROUP BY routes.route_id, routes.route_name;
gretelai_synthetic_text_to_sql
CREATE TABLE ev_research (id INT, region VARCHAR(50), funding FLOAT); INSERT INTO ev_research VALUES (1, 'Asia', 3000000); INSERT INTO ev_research VALUES (2, 'North America', 4000000);
Get total funding for electric vehicle adoption statistics research in Asia
SELECT SUM(funding) FROM ev_research WHERE region = 'Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE Port_Rotterdam_Crane_Stats (crane_name TEXT, handling_date DATE, containers_handled INTEGER); INSERT INTO Port_Rotterdam_Crane_Stats (crane_name, handling_date, containers_handled) VALUES ('CraneI', '2021-04-01', 70), ('CraneJ', '2021-04-02', 60), ('CraneK', '2021-04-03', 50), ('CraneL', '2021-04-04', 80);
What is the minimum number of containers handled in a single day by cranes in the Port of Rotterdam in April 2021?
SELECT MIN(containers_handled) FROM Port_Rotterdam_Crane_Stats WHERE handling_date >= '2021-04-01' AND handling_date <= '2021-04-30';
gretelai_synthetic_text_to_sql
CREATE TABLE company (id INT, industry TEXT, founders TEXT); INSERT INTO company (id, industry, founders) VALUES (1, 'e-commerce', 'female'), (2, 'fintech', 'male, female'), (3, 'e-commerce', 'non-binary'), (4, 'healthcare', 'male, female, female'), (5, 'e-commerce', 'male'), (6, 'transportation', 'male, female, non-binary');
What is the average number of investment rounds for companies founded by women in the "e-commerce" sector?
SELECT AVG(total_rounds) FROM (SELECT company.id, COUNT(round_data.round) AS total_rounds FROM company LEFT JOIN round_data ON company.id = round_data.company_id WHERE company.industry = 'e-commerce' AND founders LIKE '%female%' GROUP BY company.id) AS subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE StateCropYield (state VARCHAR(20), crop VARCHAR(20), quantity INT, price FLOAT);
What was the total production of 'Corn' and 'Soybeans' in each state in 'StateCropYield' table?
SELECT state, SUM(CASE WHEN crop = 'Corn' THEN quantity ELSE 0 END) + SUM(CASE WHEN crop = 'Soybeans' THEN quantity ELSE 0 END) as total_corn_soybeans FROM StateCropYield GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE athletes (id INT PRIMARY KEY, name VARCHAR(100), age INT, sport VARCHAR(50)); CREATE TABLE teams (id INT PRIMARY KEY, name VARCHAR(100), sport VARCHAR(50));
What is the total number of athletes in each sport in the 'athletes' table?
SELECT t.sport, COUNT(a.id) as total_athletes FROM athletes a JOIN teams t ON a.sport = t.sport GROUP BY t.sport;
gretelai_synthetic_text_to_sql
CREATE TABLE tennis_tickets (ticket_id INT, match_id INT, price DECIMAL(5,2), date DATE);
Update the ticket price for tennis matches in the 'tennis_tickets' table in June to 75?
UPDATE tennis_tickets SET price = 75 WHERE MONTH(date) = 6;
gretelai_synthetic_text_to_sql
CREATE TABLE Startups (startup_id INT, startup_name TEXT, industry TEXT, total_funding FLOAT, region TEXT); CREATE VIEW BiotechStartups AS SELECT * FROM Startups WHERE industry = 'Biotech'; CREATE VIEW MiddleEastStartups AS SELECT * FROM Startups WHERE region = 'Middle East';
What is the minimum funding amount for biotech startups in the Middle East?
SELECT MIN(total_funding) FROM BiotechStartups INNER JOIN MiddleEastStartups ON BiotechStartups.startup_id = MiddleEastStartups.startup_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, FirstName VARCHAR(50), LastName VARCHAR(50), Department VARCHAR(50), Position VARCHAR(50), LGBTQ INT); INSERT INTO Employees (EmployeeID, FirstName, LastName, Department, Position, LGBTQ) VALUES (1, 'John', 'Doe', 'IT', 'Developer', 1), (2, 'Jane', 'Smith', 'IT', 'Developer', 0), (3, 'Alice', 'Johnson', 'IT', 'Manager', 1), (4, 'Bob', 'Brown', 'HR', 'Manager', 0);
What is the total number of employees in each department, and what percentage of them identify as LGBTQ+?
SELECT Employees.Department, COUNT(Employees.EmployeeID) AS Total_Employees, (SUM(Employees.LGBTQ) / COUNT(Employees.EmployeeID)) * 100 AS Percentage_LGBTQ FROM Employees GROUP BY Employees.Department;
gretelai_synthetic_text_to_sql
CREATE TABLE Game_Library (player_id INT, name VARCHAR(50), age INT, gender VARCHAR(10)); INSERT INTO Game_Library (player_id, name, age, gender) VALUES (1, 'John Doe', 25, 'Male'), (2, 'Jane Smith', 30, 'Female'), (3, 'Alice Johnson', 35, 'Female'), (4, 'Bob Brown', 28, 'Male'), (5, 'Charlie Davis', 22, 'Male');
Find the average age of players who have played any game.
SELECT AVG(age) FROM Game_Library;
gretelai_synthetic_text_to_sql
CREATE TABLE hospitals (id INT, name TEXT, city TEXT, state TEXT, beds INT); INSERT INTO hospitals (id, name, city, state, beds) VALUES (1, 'General Hospital', 'Miami', 'Florida', 500); INSERT INTO hospitals (id, name, city, state, beds) VALUES (2, 'Memorial Hospital', 'Boston', 'Massachusetts', 600);
What is the average number of beds in hospitals and total number of beds by state?
SELECT state, AVG(beds) as avg_beds, SUM(beds) as total_beds FROM hospitals GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE country_production (country VARCHAR(50), element VARCHAR(10), year INT, quantity INT); INSERT INTO country_production (country, element, year, quantity) VALUES ('Australia', 'Dy', 2016, 750), ('China', 'Tm', 2016, 500), ('Mongolia', 'Dy', 2016, 600), ('India', 'Tm', 2016, 650);
Which countries produced the most Tm and Dy in 2016?
SELECT cp.country, cp.element, SUM(cp.quantity) as total_quantity FROM country_production cp WHERE cp.year = 2016 AND cp.element IN ('Tm', 'Dy') GROUP BY cp.country, cp.element ORDER BY total_quantity DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, FirstName VARCHAR(50), LastName VARCHAR(50), Country VARCHAR(50), Salary DECIMAL(10,2)); INSERT INTO Employees (EmployeeID, FirstName, LastName, Country, Salary) VALUES (1, 'John', 'Doe', 'USA', 50000.00); INSERT INTO Employees (EmployeeID, FirstName, LastName, Country, Salary) VALUES (2, 'Jane', 'Doe', 'Canada', 60000.00);
Display the average salary for employees, by country, and sort the results by the average salary in descending order
SELECT Country, AVG(Salary) as AverageSalary FROM Employees GROUP BY Country ORDER BY AverageSalary DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Suppliers (SupplierID varchar(10), SupplierName varchar(20)); INSERT INTO Suppliers VALUES ('B', 'Supplier B'); CREATE TABLE Inspections (InspectionID int, InspectionDate date, SupplierID varchar(10), Failed bit); INSERT INTO Inspections VALUES (1, '2022-01-01', 'B', 1), (2, '2022-02-01', 'B', 0), (3, '2022-03-01', 'B', 1);
How many times has supplier B had a failed inspection?
SELECT COUNT(*) FROM Inspections WHERE SupplierID = 'B' AND Failed = 1;
gretelai_synthetic_text_to_sql