context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE Volunteers (VolunteerID INT, FirstName VARCHAR(50), LastName VARCHAR(50), Email VARCHAR(50)); INSERT INTO Volunteers (VolunteerID, FirstName, LastName, Email) VALUES (1, 'John', 'Doe', '[email protected]'), (2, 'Jane', 'Smith', '[email protected]'), (3, 'Alice', 'Johnson', '[email protected]'), (4, ...
How many volunteers have contributed more than 25 hours in total?
SELECT COUNT(*) FROM (SELECT VolunteerID FROM VolunteerHours GROUP BY VolunteerID HAVING SUM(Hours) > 25) subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE investors (investor_id INT, investor_name TEXT, country TEXT); INSERT INTO investors (investor_id, investor_name, country) VALUES (1, 'Investor A', 'USA'), (2, 'Investor B', 'Canada'), (3, 'Investor C', 'India'), (4, 'Investor D', 'Germany'), (5, 'Investor E', 'Brazil'); CREATE TABLE investments (investmen...
Who are the top 5 impact investors in terms of the number of investments made in the climate change sector?
SELECT i.investor_name, COUNT(i.investment_id) as total_investments FROM investors i JOIN investments j ON i.investor_id = j.investor_id WHERE j.sector = 'Climate Change' GROUP BY i.investor_id ORDER BY total_investments DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE chemical_compounds (id INT PRIMARY KEY, name VARCHAR(255), safety_rating INT);
Update records of chemical compounds with a name 'Methanol', changing safety_rating to 6
UPDATE chemical_compounds SET safety_rating = 6 WHERE name = 'Methanol';
gretelai_synthetic_text_to_sql
CREATE TABLE clients (client_id INT, name TEXT, age INT, gender TEXT); INSERT INTO clients VALUES (1, 'John Doe', 35, 'Male'), (2, 'Jane Smith', 45, 'Female'), (3, 'Bob Johnson', 50, 'Male'), (4, 'Alice Lee', 40, 'Female'); CREATE TABLE investments (client_id INT, investment_type TEXT); INSERT INTO investments VALUES (...
List all clients with their age and the number of investments they made, sorted by the number of investments in descending order?
SELECT c.age, COUNT(i.investment_type) AS num_investments FROM clients c LEFT JOIN investments i ON c.client_id = i.client_id GROUP BY c.client_id ORDER BY num_investments DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (id INT, name VARCHAR(50), type VARCHAR(50), max_cargo_weight INT); INSERT INTO vessels (id, name, type, max_cargo_weight) VALUES (1, 'VesselA', 'Cargo', 10000), (2, 'VesselB', 'Tanker', 8000), (3, 'VesselC', 'Passenger', 0); CREATE TABLE voyages (id INT, vessel_id INT, region VARCHAR(50), distance...
What is the maximum cargo weight for vessels traveling in the Mediterranean?
SELECT MAX(max_cargo_weight) FROM vessels v INNER JOIN voyages voy ON v.id = voy.vessel_id WHERE region = 'Mediterranean';
gretelai_synthetic_text_to_sql
CREATE TABLE sales (date DATE, region VARCHAR(50), revenue FLOAT, profit FLOAT); INSERT INTO sales (date, region, revenue, profit) VALUES ('2021-07-01', 'Asia', 5000, 2000);
What is the total revenue and profit for each region in Q3 2021?
SELECT EXTRACT(QUARTER FROM date) as quarter, region, SUM(revenue) as total_revenue, SUM(profit) as total_profit FROM sales WHERE date >= '2021-07-01' AND date <= '2021-09-30' GROUP BY quarter, region;
gretelai_synthetic_text_to_sql
CREATE TABLE wallets (id INT, country VARCHAR(50), type VARCHAR(50)); INSERT INTO wallets (id, country, type) VALUES (1, 'Australia', 'DeFi'), (2, 'New Zealand', 'DeFi'), (3, 'Fiji', 'Crypto');
What is the total number of unique digital wallet addresses associated with DeFi protocols in Oceania?
SELECT COUNT(DISTINCT id) FROM wallets WHERE country IN ('Australia', 'New Zealand') AND type = 'DeFi';
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (id INT, name VARCHAR(255), age INT); INSERT INTO Artists (id, name, age) VALUES (1, 'Taylor Swift', 32), (2, 'Billie Eilish', 20); CREATE TABLE Festivals (id INT, name VARCHAR(255), year INT, artist_id INT); INSERT INTO Festivals (id, name, year, artist_id) VALUES (1, 'Coachella', 2022, 2), (2, 'L...
What is the minimum age of artists who have performed at Lollapalooza?
SELECT MIN(age) FROM Artists INNER JOIN Festivals ON Artists.id = Festivals.artist_id WHERE Festivals.name = 'Lollapalooza';
gretelai_synthetic_text_to_sql
CREATE TABLE Farm (farm_id INT, fish_species VARCHAR(50), water_temperature DECIMAL(5,2)); INSERT INTO Farm (farm_id, fish_species, water_temperature) VALUES (1, 'Salmon', 12.5), (2, 'Tilapia', 26.3), (3, 'Trout', 14.8);
What is the average water temperature for each fish species in the aquaculture farms?
SELECT Fish.fish_species, AVG(Farm.water_temperature) as AvgWaterTemp FROM Farm INNER JOIN Fish ON Farm.fish_species = Fish.fish_species GROUP BY Fish.fish_species;
gretelai_synthetic_text_to_sql
CREATE TABLE faculty (faculty_id INT, name VARCHAR(100), department VARCHAR(50), gender VARCHAR(10), grant_count INT);
What is the average number of research grants received per month by faculty members in the Computer Science department in the past 3 years?
SELECT AVG(grant_count) as avg_grants_per_month FROM (SELECT faculty_id, COUNT(*) as grant_count FROM faculty f JOIN (SELECT grant_id, faculty_id, YEAR(grant_date) as grant_year FROM grants) g ON f.faculty_id = g.faculty_id WHERE f.department = 'Computer Science' AND g.grant_year >= YEAR(DATEADD(year, -3, GETDATE())) G...
gretelai_synthetic_text_to_sql
CREATE TABLE Restaurants (id INT, name VARCHAR(50), type VARCHAR(20)); CREATE TABLE Menu (id INT, restaurant_id INT, dish VARCHAR(50), category VARCHAR(20), price DECIMAL(5,2), sustainable BOOLEAN); INSERT INTO Restaurants (id, name, type) VALUES (1, 'OceanBreeze', 'Seafood'); INSERT INTO Menu (id, restaurant_id, dish,...
What is the total revenue of sustainable seafood dishes?
SELECT SUM(price) FROM Menu WHERE category = 'Seafood' AND sustainable = true;
gretelai_synthetic_text_to_sql
CREATE TABLE WaterRecyclingSystems(brand VARCHAR(255), implementation_year INT);
How many ethical fashion brands have implemented water recycling systems in the past 3 years?
SELECT brand, COUNT(*) FROM WaterRecyclingSystems WHERE implementation_year >= YEAR(CURRENT_DATE) - 3 GROUP BY brand HAVING COUNT(*) > 0;
gretelai_synthetic_text_to_sql
CREATE TABLE agricultural_innovation (id INT, country VARCHAR(50), contributor VARCHAR(50), funding INT); INSERT INTO agricultural_innovation (id, country, contributor, funding) VALUES (1, 'Kenya', 'Government', 5000000), (2, 'Tanzania', 'Private', 6000000), (3, 'Uganda', 'NGO', 7000000), (4, 'Kenya', 'Private', 800000...
What is the total funding for agricultural innovation in each country in Africa?
SELECT country, SUM(funding) as total_funding FROM agricultural_innovation GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE rehabilitation_center (animal_id INT, admission_date DATE); INSERT INTO rehabilitation_center (animal_id, admission_date) VALUES (1, '2021-01-05'), (2, '2021-01-12'), (3, '2021-02-18');
What is the total number of animals in the rehabilitation center admitted in the winter season?
SELECT COUNT(*) FROM rehabilitation_center WHERE admission_date BETWEEN '2021-01-01' AND '2021-03-31';
gretelai_synthetic_text_to_sql
CREATE TABLE farmers(id INT, name TEXT, country TEXT); INSERT INTO farmers(id, name, country) VALUES (1, 'Juan', 'Mexico'); INSERT INTO farmers(id, name, country) VALUES (2, 'Ana', 'Mexico'); CREATE TABLE programs(id INT, farmer_id INT, program TEXT, investment FLOAT); INSERT INTO programs(id, farmer_id, program, inves...
What is the average investment in agricultural innovation programs per farmer in Mexico?
SELECT AVG(p.investment) FROM farmers f INNER JOIN programs p ON f.id = p.farmer_id WHERE f.country = 'Mexico';
gretelai_synthetic_text_to_sql
CREATE TABLE policy_violations (id INT, policy_name VARCHAR(255), region VARCHAR(255), violation_date DATE); INSERT INTO policy_violations (id, policy_name, region, violation_date) VALUES (1, 'Data Privacy', 'MENA', '2022-02-01'), (2, 'Access Control', 'MENA', '2022-02-02'), (3, 'Incident Response', 'MENA', '2022-02-03...
What are the top 2 most frequently violated policies in the Middle East and North Africa region?
SELECT policy_name, COUNT(*) AS violation_count FROM policy_violations WHERE region = 'MENA' AND violation_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY policy_name ORDER BY violation_count DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE ingredient_sources (id INT PRIMARY KEY, product_id INT, ingredient TEXT, country TEXT, source TEXT); CREATE TABLE products (id INT PRIMARY KEY, name TEXT, brand TEXT); INSERT INTO products (id, name, brand) VALUES (1, 'Coconut Body Butter', 'TropicalBliss');
Insert a new ingredient source record for the product named "Coconut Body Butter" from the brand "TropicalBliss" with the ingredient "Coconut Oil", source "Small Farmers Co-op", and country "Sri Lanka".
INSERT INTO ingredient_sources (id, product_id, ingredient, country, source) VALUES (1, (SELECT id FROM products WHERE name = 'Coconut Body Butter' AND brand = 'TropicalBliss'), 'Coconut Oil', 'Sri Lanka', 'Small Farmers Co-op');
gretelai_synthetic_text_to_sql
CREATE TABLE metro_routes (id INT, station_id INT, trip_week DATE); INSERT INTO metro_routes (id, station_id, trip_week) VALUES (1, 1, '2022-01-01'), (2, 2, '2022-01-01'), (3, 1, '2022-01-08');
Find the number of unique metro stations used per week, ordered by the most used week?
SELECT COUNT(DISTINCT station_id) OVER (ORDER BY trip_week DESC) as unique_stations, trip_week FROM metro_routes WHERE trip_week >= DATEADD(day, -365, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE monitoring_stations (id INT PRIMARY KEY, name VARCHAR(50), location VARCHAR(50)); CREATE TABLE temperature_readings (id INT PRIMARY KEY, station_id INT, value FLOAT, timestamp TIMESTAMP); CREATE TABLE humidity_readings (id INT PRIMARY KEY, station_id INT, value FLOAT, timestamp TIMESTAMP);
List all monitoring stations and their respective average temperature and humidity readings, ordered by the average temperature.
SELECT monitoring_stations.name, AVG(temperature_readings.value) AS avg_temperature, AVG(humidity_readings.value) AS avg_humidity FROM monitoring_stations INNER JOIN temperature_readings ON monitoring_stations.id = temperature_readings.station_id INNER JOIN humidity_readings ON monitoring_stations.id = humidity_reading...
gretelai_synthetic_text_to_sql
CREATE TABLE game_R_usage (user_id INT, usage_date DATE);
What is the number of users who played game R on each day of the week?
SELECT DATEPART(dw, usage_date) AS day_of_week, COUNT(DISTINCT user_id) FROM game_R_usage GROUP BY DATEPART(dw, usage_date);
gretelai_synthetic_text_to_sql
CREATE TABLE Companies (id INT, name TEXT, industry TEXT); INSERT INTO Companies VALUES (1, 'Biotech Company', 'Biotech'); CREATE TABLE InvestmentRounds (id INT, company_id INT, round_amount INT); INSERT INTO InvestmentRounds VALUES (1, 1, 2000000); CREATE TABLE Founders (id INT, company_id INT, ethnicity TEXT); INSERT...
List companies founded by Indigenous individuals in the Biotech sector that have had at least one investment round.
SELECT Companies.name FROM Companies JOIN Founders ON Companies.id = Founders.company_id WHERE Founders.ethnicity = 'Indigenous' AND Companies.industry = 'Biotech';
gretelai_synthetic_text_to_sql
CREATE TABLE events (event_id INT, event_name VARCHAR(50), funding_source_id INT, event_date DATE); INSERT INTO events (event_id, event_name, funding_source_id, event_date) VALUES (1, 'Art Exhibit', 1, '2021-06-01'), (2, 'Theater Performance', 2, '2021-07-15'), (3, 'Dance Recital', 1, '2021-09-25'); CREATE TABLE fundin...
How many events did each funding source support in 2021?
SELECT funding_source_name, COUNT(events.funding_source_id) AS event_count FROM funding_sources LEFT JOIN events ON funding_sources.funding_source_id = events.funding_source_id WHERE YEAR(events.event_date) = 2021 GROUP BY funding_source_name;
gretelai_synthetic_text_to_sql
CREATE TABLE network_investments (region VARCHAR(20), investment FLOAT); INSERT INTO network_investments (region, investment) VALUES ('Africa', 5000000); INSERT INTO network_investments (region, investment) VALUES ('Asia', 7000000);
What is the total network investment in telecommunications infrastructure in Africa?
SELECT SUM(investment) FROM network_investments WHERE region = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE Contractors (contractor_id INT, contractor_name VARCHAR(50), contractor_HQ VARCHAR(50), contract_value FLOAT); INSERT INTO Contractors (contractor_id, contractor_name, contractor_HQ, contract_value) VALUES (5, 'MegaDefense', 'USA', 80000000), (6, 'SecureCorp', 'UK', 100000000), (7, 'ShieldTech', 'Israel', ...
Which defense contractors have been involved in contracts with a value greater than $75M, along with their respective headquarters and the total value of contracts they have participated in, ordered by the total contract value in descending order?
SELECT contractor_name, contractor_HQ, SUM(contract_value) AS TotalContractValue FROM Contractors WHERE contract_value > 75000000 GROUP BY contractor_name, contractor_HQ ORDER BY TotalContractValue DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE TraditionalArtsCA_SA (ArtID INT PRIMARY KEY, ArtName VARCHAR(50), Location VARCHAR(50), Type VARCHAR(50)); INSERT INTO TraditionalArtsCA_SA (ArtID, ArtName, Location, Type) VALUES (1, 'Ceramics', 'Guatemala', 'Art'), (2, 'Feather Art', 'Mexico', 'Art');
What is the average number of traditional art forms in 'South America' and 'Central America'?
SELECT AVG(COUNT(*)) FROM TraditionalArtsCA_SA WHERE Location IN ('South America', 'Central America');
gretelai_synthetic_text_to_sql
CREATE TABLE donors (id INT, name TEXT, organization TEXT);CREATE TABLE donations (id INT, donor_id INT, amount DECIMAL(10,2)); INSERT INTO donors (id, name, organization) VALUES (1, 'Donor A', 'Organization 1'), (2, 'Donor B', 'Organization 2'), (3, 'Donor C', 'Organization 3'); INSERT INTO donations (id, donor_id, am...
Who are the top 3 donors, based on the total amount donated?
SELECT d.name, SUM(donations.amount) FROM donors INNER JOIN donations ON donors.id = donations.donor_id GROUP BY donors.id ORDER BY SUM(donations.amount) DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE ai_models (model_name TEXT, safety_principles INT); INSERT INTO ai_models (model_name, safety_principles) VALUES ('ModelA', 3), ('ModelB', 4), ('ModelC', 2), ('ModelD', 3);
How many AI safety principles are associated with each AI model?
SELECT model_name, safety_principles FROM ai_models;
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_acidification (region TEXT, level FLOAT); INSERT INTO ocean_acidification (region, level) VALUES ('Atlantic Ocean', 7.5), ('Pacific Ocean', 7.9), ('Indian Ocean', 7.7), ('Arctic Ocean', 7.4);
What is the average ocean acidification level in the Indian Ocean?
SELECT AVG(level) FROM ocean_acidification WHERE region = 'Indian Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE model_revisions (id INT, model_name VARCHAR(50), vcs VARCHAR(50), revision_count INT); INSERT INTO model_revisions (id, model_name, vcs, revision_count) VALUES (1, 'ModelA', 'Git', 21), (2, 'ModelB', 'SVN', 15), (3, 'ModelC', 'Mercurial', 29);
What is the minimum, maximum, and average number of revisions made to AI models using different version control systems?
SELECT vcs, MIN(revision_count) as min_revision_count, MAX(revision_count) as max_revision_count, AVG(revision_count) as avg_revision_count FROM model_revisions GROUP BY vcs;
gretelai_synthetic_text_to_sql
CREATE TABLE shows (id INT, title VARCHAR(100), genre VARCHAR(50), country VARCHAR(50), release_year INT, runtime INT);
What is the maximum and minimum runtime (in minutes) of shows in the shows table?
SELECT MAX(runtime), MIN(runtime) FROM shows;
gretelai_synthetic_text_to_sql
CREATE TABLE smart_contracts (id INT, name VARCHAR(255)); INSERT INTO smart_contracts (id, name) VALUES (1, 'ERC20');
What is the total number of tokens issued by the 'ERC20' smart contract?
SELECT SUM(tokens_issued) FROM smart_contract_activity WHERE smart_contract_id = (SELECT id FROM smart_contracts WHERE name = 'ERC20');
gretelai_synthetic_text_to_sql
CREATE TABLE RenewableEnergyProjects ( id INT, projectName VARCHAR(50), capacity INT, completionDate YEAR ); INSERT INTO RenewableEnergyProjects (id, projectName, capacity, completionDate) VALUES (1, 'SolarFarm One', 50, 2016), (2, 'WindFarm East', 100, 2017), (3, 'HydroPower Plant South', 150, 2014);
What is the average year of completion for renewable energy projects in the 'RenewableEnergyProjects' table?
SELECT AVG(completionDate) FROM RenewableEnergyProjects;
gretelai_synthetic_text_to_sql
CREATE TABLE LinenProduction (country VARCHAR(50), water_usage INT); INSERT INTO LinenProduction VALUES ('France', 1200), ('Germany', 1000), ('France', 1500), ('Italy', 800);
What is the average water usage of linen production in France?
SELECT AVG(water_usage) FROM LinenProduction WHERE country = 'France';
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_subscribers (subscriber_id INT, monthly_fee FLOAT, plan_type VARCHAR(10), city VARCHAR(20)); INSERT INTO mobile_subscribers (subscriber_id, monthly_fee, plan_type, city) VALUES (1, 50, 'postpaid', 'Chicago'), (2, 30, 'prepaid', 'Chicago'); CREATE TABLE broadband_subscribers (subscriber_id INT, month...
What is the total revenue generated from mobile and broadband subscribers in the city of Chicago?
SELECT SUM(mobile_subscribers.monthly_fee + broadband_subscribers.monthly_fee) FROM mobile_subscribers INNER JOIN broadband_subscribers ON mobile_subscribers.subscriber_id = broadband_subscribers.subscriber_id WHERE mobile_subscribers.city = 'Chicago';
gretelai_synthetic_text_to_sql
CREATE TABLE space_missions (id INT PRIMARY KEY, mission_name VARCHAR(255), country VARCHAR(255), launch_date DATE, mission_type VARCHAR(255));
What is the earliest launch date of any space mission?
SELECT MIN(launch_date) FROM space_missions;
gretelai_synthetic_text_to_sql
CREATE TABLE workers(id INT, name TEXT, department TEXT, year INT);INSERT INTO workers(id, name, department, year) VALUES (1, 'John', 'mining', 2020), (2, 'Jane', 'mining', 2019), (3, 'Mike', 'mining', 2020), (4, 'Lucy', 'mining', 2018), (5, 'Ella', 'mining', 2019);
How many workers were employed in the 'mining' department in each year they were employed?
SELECT year, COUNT(DISTINCT id) FROM workers WHERE department = 'mining' GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE movies (id INT, title VARCHAR(255), release_year INT, runtime_minutes INT, director VARCHAR(255), topic VARCHAR(255));
Who are the top 2 directors with the highest number of movies about media representation?
SELECT director, COUNT(*) as movie_count FROM movies WHERE topic = 'media representation' GROUP BY director ORDER BY movie_count DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE Designers (DesignerID INT, DesignerName TEXT, IsSustainableFabric BOOLEAN); INSERT INTO Designers (DesignerID, DesignerName, IsSustainableFabric) VALUES (1, 'DesignerA', true), (2, 'DesignerB', false); CREATE TABLE FabricUsage (DesignerID INT, Fabric TEXT, Quantity INT); INSERT INTO FabricUsage (DesignerID...
What is the total quantity of sustainable fabric used by each designer?
SELECT DesignerName, SUM(Quantity) as TotalSustainableQuantity FROM Designers JOIN FabricUsage ON Designers.DesignerID = FabricUsage.DesignerID WHERE IsSustainableFabric = true GROUP BY DesignerName;
gretelai_synthetic_text_to_sql
INSERT INTO music_genres_ext (id, genre, popularity) VALUES (2, 'Jazz', 1500000);
number of fans per million people in the world; use a multiplier of 1 million
SELECT 2 AS id, 'Jazz' AS genre, 1500000 AS popularity, 1500000 / (SELECT SUM(popularity) FROM music_genres_ext) * 1000000 AS fans_per_million;
gretelai_synthetic_text_to_sql
CREATE TABLE ChemicalProduction (id INT, chemical VARCHAR(255), region VARCHAR(255), production_rate FLOAT); INSERT INTO ChemicalProduction (id, chemical, region, production_rate) VALUES (1, 'chemical X', 'southeast', 500), (2, 'chemical Y', 'northwest', 300);
What is the average production rate of chemical X in the southeast region?
SELECT AVG(production_rate) FROM ChemicalProduction WHERE chemical = 'chemical X' AND region = 'southeast';
gretelai_synthetic_text_to_sql
CREATE TABLE projects (id INT, name TEXT, region TEXT, capacity_mw FLOAT); INSERT INTO projects (id, name, region, capacity_mw) VALUES (1, 'Geothermal Project 1', 'Americas', 50.2); INSERT INTO projects (id, name, region, capacity_mw) VALUES (2, 'Geothermal Project 2', 'Americas', 60.8);
What is the average capacity (in MW) of geothermal power projects in the 'Americas' region?
SELECT AVG(capacity_mw) FROM projects WHERE region = 'Americas' AND type = 'geothermal';
gretelai_synthetic_text_to_sql
CREATE TABLE artist (artist_id INT, artist_name VARCHAR(50)); INSERT INTO artist (artist_id, artist_name) VALUES (1, 'Artist A'), (2, 'Artist B'); CREATE TABLE song (song_id INT, song_name VARCHAR(50), artist_id INT, platform VARCHAR(20)); INSERT INTO song (song_id, song_name, artist_id, platform) VALUES (1, 'Song 1', ...
Which artists have released songs on the 'indie_platform' platform?
SELECT DISTINCT a.artist_name FROM artist a JOIN song s ON a.artist_id = s.artist_id WHERE s.platform = 'indie_platform';
gretelai_synthetic_text_to_sql
CREATE TABLE Companies (id INT, name VARCHAR(255), region VARCHAR(255)); CREATE TABLE DigitalAssets (id INT, company_id INT, value DECIMAL(10, 2), asset_date DATE); INSERT INTO Companies (id, name, region) VALUES (1, 'CompanyA', 'South America'), (2, 'CompanyB', 'North America'), (3, 'CompanyC', 'South America'); INSER...
What is the total number of digital assets owned by companies based in South America as of 2022-12-31?
SELECT SUM(value) FROM DigitalAssets JOIN Companies ON DigitalAssets.company_id = Companies.id WHERE Companies.region = 'South America' AND DigitalAssets.asset_date <= '2022-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE MuseumVisitors (visitor_id INT, museum_id INT, country VARCHAR(50)); INSERT INTO MuseumVisitors (visitor_id, museum_id, country) VALUES (1, 100, 'USA'), (2, 101, 'Canada'), (3, 102, 'Mexico');
Which countries have the highest number of museum visitors?
SELECT country, COUNT(*) as visitor_count FROM MuseumVisitors GROUP BY country ORDER BY visitor_count DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Organizations (OrgID int, OrgName varchar(50), TotalFunding decimal(10,2)); INSERT INTO Organizations (OrgID, OrgName, TotalFunding) VALUES (1, 'UNHCR', 1500.00), (2, 'World Food Programme', 2000.00); CREATE TABLE RohingyaRelief (ReliefID int, OrgID int, FundingReceived decimal(10,2)); INSERT INTO Rohingya...
What is the total amount of funding received by each organization for the Rohingya refugee crisis?
SELECT OrgName, SUM(FundingReceived) as TotalReceived FROM Organizations INNER JOIN RohingyaRelief ON Organizations.OrgID = RohingyaRelief.OrgID GROUP BY OrgName;
gretelai_synthetic_text_to_sql
CREATE TABLE temperature_data (id INT, year INT, avg_temp FLOAT);
What is the average temperature change in the Arctic circle over the last 30 years?
SELECT AVG(avg_temp) FROM temperature_data WHERE year BETWEEN (YEAR(CURRENT_DATE) - 30) AND YEAR(CURRENT_DATE) AND region = 'Arctic Circle'
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists county; CREATE TABLE if not exists county.community_policing (id INT, event_date DATE); INSERT INTO county.community_policing (id, event_date) VALUES (1, '2021-02-14'), (2, '2021-05-17'), (3, '2022-03-25');
How many community policing events occurred in the 'county' schema in 2021?
SELECT COUNT(*) FROM county.community_policing WHERE YEAR(event_date) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE deliveries (id INT, supplier_id INT, delivery_time INT); INSERT INTO deliveries (id, supplier_id, delivery_time) VALUES (1, 1, 5), (2, 2, 7), (3, 3, 3), (4, 1, 4), (5, 2, 6);
What is the average delivery time for each supplier?
SELECT supplier_id, AVG(delivery_time) AS avg_delivery_time FROM deliveries GROUP BY supplier_id;
gretelai_synthetic_text_to_sql
CREATE TABLE oceans (ocean_id INT, name VARCHAR(50));CREATE TABLE marine_species (species_id INT, name VARCHAR(50), ocean_id INT);INSERT INTO oceans (ocean_id, name) VALUES (1, 'Pacific'), (2, 'Atlantic'), (3, 'Indian'), (4, 'Arctic'), (5, 'Southern');INSERT INTO marine_species (species_id, name, ocean_id) VALUES (1, '...
What are the names of the oceans with the most and least marine life diversity?
SELECT MAX(o.name) AS 'Most Diverse', MIN(o.name) AS 'Least Diverse' FROM oceans o LEFT JOIN marine_species ms ON o.ocean_id = ms.ocean_id GROUP BY o.name HAVING COUNT(DISTINCT ms.species_id) = (SELECT MAX(marine_species_count) FROM (SELECT COUNT(DISTINCT species_id) AS marine_species_count FROM marine_species GROUP BY...
gretelai_synthetic_text_to_sql
CREATE TABLE articles (article_id INT, title VARCHAR(50), type VARCHAR(20), country VARCHAR(20)); INSERT INTO articles (article_id, title, type, country) VALUES (1, 'News from Canada', 'news', 'Canada'), (2, 'Opinion from France', 'opinion', 'France'), (3, 'Investigation from India', 'investigation', 'India');
What is the total number of news articles and opinion pieces, and how many unique authors have written them, for each country?
SELECT country, COUNT(*) as total_articles, COUNT(DISTINCT author_id) as unique_authors FROM (SELECT article_id, country, author_id, MAX(type) AS type FROM articles GROUP BY article_id, country, author_id) AS subquery GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE user_activity (activity_id INT, user_id INT, activity_time TIME); INSERT INTO user_activity (activity_id, user_id, activity_time) VALUES (1, 1, '08:00:00'), (2, 1, '09:00:00'), (3, 2, '10:00:00'), (4, 3, '11:00:00'), (5, 3, '12:00:00');
What is the daily activity of users on our platform, grouped by hour of the day?
SELECT HOUR(activity_time) AS hour, COUNT(user_id) AS user_count FROM user_activity GROUP BY hour;
gretelai_synthetic_text_to_sql
CREATE TABLE Orders (id INT, supplier_id INT, item VARCHAR(255), weight INT); INSERT INTO Orders (id, supplier_id, item, weight) VALUES (1, 1, 'Beef', 150), (2, 1, 'Chicken', 80), (3, 2, 'Beef', 200), (4, 2, 'Turkey', 120); CREATE TABLE Suppliers (id INT, name VARCHAR(255)); INSERT INTO Suppliers (id, name) VALUES (1, ...
What is the total weight of beef sourced from 'GrassFedCattleCo'?
SELECT SUM(weight) FROM Orders WHERE item = 'Beef' AND supplier_id IN (SELECT id FROM Suppliers WHERE name = 'GrassFedCattleCo');
gretelai_synthetic_text_to_sql
CREATE TABLE Visitors (VisitorID int, VisitorName varchar(100), VisitDate date, MuseumName varchar(100)); INSERT INTO Visitors (VisitorID, VisitorName, VisitDate, MuseumName) VALUES (1, 'Visitor A', '2022-01-01', 'Louvre Museum'), (2, 'Visitor B', '2022-01-02', 'Louvre Museum'), (3, 'Visitor A', '2022-01-03', 'Louvre M...
Who is the most frequent visitor to the Louvre Museum?
SELECT VisitorName, COUNT(*) as Visits FROM Visitors WHERE MuseumName = 'Louvre Museum' GROUP BY VisitorName ORDER BY Visits DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE electric_vehicles (id INT, speed FLOAT, city VARCHAR(50));
What is the average speed of electric vehicles in New York City?
SELECT AVG(speed) FROM electric_vehicles WHERE city = 'New York City';
gretelai_synthetic_text_to_sql
CREATE TABLE meat_imports (import_id INT, import_date DATE, product VARCHAR(255), weight INT, country VARCHAR(255));
What is the total weight of meat imported from Brazil in the meat_imports table?
SELECT SUM(weight) FROM meat_imports WHERE product LIKE '%meat%' AND country = 'Brazil';
gretelai_synthetic_text_to_sql
CREATE TABLE stadiums_2 (name TEXT, city TEXT, capacity INTEGER); INSERT INTO stadiums_2 (name, city, capacity) VALUES ('Soldier Field', 'Chicago', 65000), ('United Center', 'Chicago', 21000), ('Wrigley Field', 'Chicago', 40000); CREATE TABLE games_2 (sport TEXT, team TEXT, price DECIMAL(5,2)); INSERT INTO games_2 (spo...
What is the average ticket price for all games in Chicago?
SELECT AVG(price) FROM games_2 WHERE team IN (SELECT team FROM stadiums_2 WHERE city = 'Chicago');
gretelai_synthetic_text_to_sql
CREATE TABLE providers (id INT PRIMARY KEY, name VARCHAR(100), city VARCHAR(50), specialty VARCHAR(50));
Update the record for provider with ID 12345 to reflect their new title, 'Senior Community Health Worker'
UPDATE providers SET specialty = 'Senior Community Health Worker' WHERE id = 12345;
gretelai_synthetic_text_to_sql
CREATE TABLE claims (policyholder_id INT, claim_amount DECIMAL(10,2), state VARCHAR(2)); INSERT INTO claims (policyholder_id, claim_amount, state) VALUES (1, 500, 'AZ'), (2, 200, 'AZ'), (3, 800, 'AZ');
Show the total number of claims and the average claim amount for policyholders in Arizona
SELECT state, COUNT(*), AVG(claim_amount) FROM claims WHERE state = 'AZ' GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE Albums (AlbumID INT, AlbumName VARCHAR(100), ReleaseYear INT, Artist VARCHAR(100)); INSERT INTO Albums (AlbumID, AlbumName, ReleaseYear, Artist) VALUES (1, 'DAMN', 2017, 'Kendrick Lamar'); INSERT INTO Albums (AlbumID, AlbumName, ReleaseYear, Artist) VALUES (2, 'Reputation', 2017, 'Taylor Swift'); INSERT IN...
What are the names of the artists who have released albums in both 2017 and 2018?
SELECT Artist FROM Albums WHERE ReleaseYear = 2017 INTERSECT SELECT Artist FROM Albums WHERE ReleaseYear = 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE Departments (Department_ID INT, Department_Name VARCHAR(20), Manager_ID INT, Location VARCHAR(20)); CREATE TABLE Employees (Employee_ID INT, First_Name VARCHAR(20), Last_Name VARCHAR(20), Department VARCHAR(20), Salary DECIMAL(10,2), Date_Hired DATE);
Who is the manager for the IT department?
SELECT e.First_Name, e.Last_Name FROM Employees e JOIN Departments d ON e.Employee_ID = d.Manager_ID WHERE d.Department_Name = 'IT';
gretelai_synthetic_text_to_sql
CREATE TABLE properties (property_id INT, year INT, property_tax FLOAT);
Identify properties with the largest decrease in property tax between 2020 and 2021?
SELECT property_id, (property_tax_2020 - property_tax_2021) as tax_decrease FROM (SELECT property_id, property_tax as property_tax_2021, LAG(property_tax) OVER (PARTITION BY property_id ORDER BY year) as property_tax_2020 FROM properties WHERE year IN (2020, 2021)) t WHERE property_tax_2021 IS NOT NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE terbium_production (country VARCHAR(255), price DECIMAL(10,2)); INSERT INTO terbium_production (country, price) VALUES ('Japan', 400.00);
What is the minimum price of terbium produced in Japan?
SELECT MIN(price) FROM terbium_production WHERE country = 'Japan';
gretelai_synthetic_text_to_sql
CREATE TABLE port (port_id INT, port_name VARCHAR(50)); INSERT INTO port (port_id, port_name) VALUES (1, 'Port of Barcelona'), (2, 'Port of Valencia'), (3, 'Port of Lisbon'); CREATE TABLE vessel (vessel_id INT, vessel_name VARCHAR(50)); CREATE TABLE transport (transport_id INT, cargo_id INT, vessel_id INT, port_id INT)...
What are the names of the ports where 'Vessel Q' has transported cargo?
SELECT port_name FROM port WHERE port_id IN (SELECT port_id FROM transport WHERE vessel_id = (SELECT vessel_id FROM vessel WHERE vessel_name = 'Vessel Q'));
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (id INT, name TEXT, country TEXT, donation_amount DECIMAL(10, 2), donation_date DATE); INSERT INTO Donors (id, name, country, donation_amount, donation_date) VALUES (1, 'John Doe', 'India', 100.00, '2021-01-01'); INSERT INTO Donors (id, name, country, donation_amount, donation_date) VALUES (2, 'Soph...
Delete all records related to donations made by 'Sophia Lee' from Singapore.
DELETE FROM Donors WHERE name = 'Sophia Lee' AND country = 'Singapore';
gretelai_synthetic_text_to_sql
CREATE TABLE vessels(id INT, name VARCHAR(100), region VARCHAR(50));CREATE TABLE incidents(id INT, vessel_id INT, incident_date DATE);
What is the number of safety incidents for each vessel in the Pacific Ocean in 2018?
SELECT v.name, COUNT(*) AS incident_count FROM incidents i JOIN vessels v ON i.vessel_id = v.id WHERE v.region = 'Pacific Ocean' AND incident_date BETWEEN '2018-01-01' AND '2018-12-31' GROUP BY v.name;
gretelai_synthetic_text_to_sql
CREATE TABLE community_development (id INT, name TEXT, program TEXT, budget INT); INSERT INTO community_development (id, name, program, budget) VALUES (1, 'Initiative A', 'Sustainable Livelihoods', 200000), (2, 'Initiative B', 'Urban Development', 300000);
List the budget for each community development initiative in the 'Sustainable Livelihoods' program.
SELECT name, budget FROM community_development WHERE program = 'Sustainable Livelihoods';
gretelai_synthetic_text_to_sql
CREATE TABLE contract_negotiations (negotiation_id INTEGER, start_date DATE, end_date DATE, country1 TEXT, country2 TEXT, negotiator1 TEXT, negotiator2 TEXT);
Which defense contract negotiations involved the USA or Russia, between 2017 and 2019, and which negotiators were involved?
SELECT * FROM contract_negotiations WHERE (country1 = 'USA' OR country2 = 'USA') OR (country1 = 'Russia' OR country2 = 'Russia') AND start_date BETWEEN '2017-01-01' AND '2019-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE HealthEquity (HEID int, CHWID int, Score int);
What is the health equity metric score for each community health worker?
SELECT CHWID, AVG(Score) as AvgScore FROM HealthEquity GROUP BY CHWID;
gretelai_synthetic_text_to_sql
CREATE TABLE restaurants (id INT, name VARCHAR(255), type VARCHAR(255), revenue FLOAT); INSERT INTO restaurants (id, name, type, revenue) VALUES (1, 'Restaurant A', 'Italian', 5000.00), (2, 'Restaurant B', 'Vegan', 7000.00), (3, 'Restaurant C', 'Mexican', 3000.00);
List the restaurants that have a higher average revenue than the overall average revenue.
SELECT name FROM restaurants WHERE revenue > (SELECT AVG(revenue) FROM restaurants);
gretelai_synthetic_text_to_sql
CREATE TABLE marine_pollutants (id INT, location VARCHAR(255), type VARCHAR(255), concentration FLOAT); INSERT INTO marine_pollutants (id, location, type, concentration) VALUES (1, 'Atlantic Ocean', 'Microplastics', 0.005);
Total microplastics concentration in Atlantic
SELECT location, SUM(concentration) FROM marine_pollutants WHERE type = 'Microplastics' GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE Students (ID INT, Program VARCHAR(50), Gender VARCHAR(10), EnrollmentYear INT); INSERT INTO Students (ID, Program, Gender, EnrollmentYear) VALUES (1, 'Computer Science', 'Female', 2020), (2, 'Electrical Engineering', 'Male', 2019);
How many female graduate students are enrolled in the 'Computer Science' program?
SELECT COUNT(*) FROM Students WHERE Program = 'Computer Science' AND Gender = 'Female';
gretelai_synthetic_text_to_sql
CREATE TABLE hospital (hospital_id INT, name VARCHAR(50), state VARCHAR(20), num_of_beds INT); INSERT INTO hospital (hospital_id, name, state, num_of_beds) VALUES (1, 'Rural Hospital A', 'Texas', 120); INSERT INTO hospital (hospital_id, name, state, num_of_beds) VALUES (2, 'Rural Hospital B', 'California', 80); INSERT ...
What is the total number of hospitals in each state that have more than 100 beds?
SELECT state, COUNT(*) FROM hospital WHERE num_of_beds > 100 GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE CulturalHeritage (site_id INT, site_date DATE, region VARCHAR(20), preservation_cost FLOAT); INSERT INTO CulturalHeritage (site_id, site_date, region, preservation_cost) VALUES (15, '2022-01-01', 'Asia', 250.0), (15, '2022-01-02', 'Asia', 200.0), (16, '2022-01-03', 'Europe', 150.0);
Calculate the average preservation cost for cultural heritage sites with more than two site dates in the Asia region.
SELECT region, AVG(preservation_cost) as avg_preservation_cost FROM CulturalHeritage WHERE region = 'Asia' GROUP BY region HAVING COUNT(site_date) > 2;
gretelai_synthetic_text_to_sql
CREATE TABLE weather_data (region VARCHAR(255), year INT, temperature FLOAT);
What is the average temperature change in the Arctic Circle region over the last 10 years?
SELECT AVG(temperature) FROM (SELECT temperature FROM weather_data WHERE region = 'Arctic Circle' AND year BETWEEN 2012 AND 2022) subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, customer_name TEXT, registration_date TEXT, country TEXT, financing_type TEXT); INSERT INTO customers (customer_id, customer_name, registration_date, country, financing_type) VALUES (1, 'Ali', '2022-01-15', 'Turkey', 'Shariah-compliant'), (2, 'Zeynep', '2022-02-20', 'Turkey', 'C...
What is the average loan amount and maturity for customers who have taken out loans in the last 6 months, in Turkey, considering only Shariah-compliant financing?
SELECT AVG(loan_amount), AVG(maturity) FROM customers JOIN loans ON customers.customer_id = loans.customer_id WHERE country = 'Turkey' AND financing_type = 'Shariah-compliant' AND loans.loan_date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE players (player_id INT, name VARCHAR(100), game VARCHAR(50));
Delete a player from the players table
DELETE FROM players WHERE player_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE dishes (id INT, name VARCHAR(255)); INSERT INTO dishes (id, name) VALUES (1, 'Chicken Alfredo'), (2, 'Vegan Pizza'), (3, 'Beef Stroganoff'), (4, 'Shrimp Scampi'), (5, 'Tofu Stir Fry'); CREATE TABLE allergens (id INT, dish_id INT, name VARCHAR(255)); INSERT INTO allergens (id, dish_id, name) VALUES (1, 1, '...
Identify dishes that contain any allergen and their respective allergens.
SELECT d.name as dish, array_agg(a.name) as allergens FROM dishes d JOIN allergens a ON d.id = a.dish_id GROUP BY d.id HAVING COUNT(DISTINCT a.name) > 1;
gretelai_synthetic_text_to_sql
CREATE TABLE investments (client_id INT, investment_strategy VARCHAR(50), age INT, investment_date DATE); INSERT INTO investments (client_id, investment_strategy, age, investment_date) VALUES (1, 'Stocks', 35, '2022-01-10'), (2, 'Bonds', 45, '2022-01-15'), (3, 'Stocks', 32, '2022-02-01');
Which investment strategies were most popular among clients aged 30-40 in Q1 2022?
SELECT investment_strategy, COUNT(*) as popularity FROM investments WHERE age BETWEEN 30 AND 40 AND investment_date BETWEEN '2022-01-01' AND '2022-03-31' GROUP BY investment_strategy;
gretelai_synthetic_text_to_sql
CREATE TABLE MusicInstruments (id INT, instrument VARCHAR(255), country VARCHAR(255)); INSERT INTO MusicInstruments (id, instrument, country) VALUES (1, 'Didgeridoo', 'Australia'), (2, 'Kora', 'Senegal'), (3, 'Sitar', 'India');
How many traditional music instruments are documented for each country?
SELECT country, COUNT(*) FROM MusicInstruments GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE Fares (FareID INT, City VARCHAR(50), Fare DECIMAL(10,2)); INSERT INTO Fares (FareID, City, Fare) VALUES (1, 'CityA', 2.5), (2, 'CityA', 3.0), (3, 'CityB', 5.0);
What is the maximum fare in each city?
SELECT City, MAX(Fare) as MaxFare FROM Fares GROUP BY City;
gretelai_synthetic_text_to_sql
CREATE TABLE workplaces (id INT, workplace_name VARCHAR(255), region VARCHAR(255)); INSERT INTO workplaces (id, workplace_name, region) VALUES (1, 'Workplace A', 'Southern'), (2, 'Workplace B', 'Southern'), (3, 'Workplace C', 'Northern'); CREATE TABLE violations (id INT, workplace_id INT, violation_count INT); INSERT I...
Delete all records of workplace violations in the Southern region.
DELETE FROM violations WHERE id IN (SELECT v.id FROM violations v JOIN workplaces w ON v.workplace_id = w.id WHERE w.region = 'Southern');
gretelai_synthetic_text_to_sql
CREATE TABLE Programs (ProgramID INT, ProgramType TEXT, ProgramBudget DECIMAL(10,2), ProgramStartDate DATE, ProgramEndDate DATE); INSERT INTO Programs (ProgramID, ProgramType, ProgramBudget, ProgramStartDate, ProgramEndDate) VALUES (1, 'Climate Change Education', 7000.00, '2022-04-01', '2022-06-30');
What was the total budget spent on programs focused on climate change education in Q2 2022?
SELECT SUM(ProgramBudget) as TotalBudget FROM Programs WHERE ProgramType = 'Climate Change Education' AND ProgramStartDate <= '2022-06-30' AND ProgramEndDate >= '2022-04-01';
gretelai_synthetic_text_to_sql
CREATE TABLE detections (id INT, threat_type VARCHAR(255), region VARCHAR(255), detection_date DATE); INSERT INTO detections (id, threat_type, region, detection_date) VALUES (1, 'Malware', 'Africa', '2022-02-01'), (2, 'Phishing', 'Africa', '2022-02-02'), (3, 'Ransomware', 'Africa', '2022-02-03'), (4, 'Spyware', 'Africa...
What are the top 3 threat types detected in the African region in the last month?
SELECT threat_type, COUNT(*) AS detection_count FROM detections WHERE region = 'Africa' AND detection_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY threat_type ORDER BY detection_count DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE safety_records (record_id INT, product_id INT, incident_date DATE); INSERT INTO safety_records (record_id, product_id, incident_date) VALUES (1, 101, '2022-01-15'), (2, 102, '2022-03-04'), (3, 103, '2022-05-09');
Safety incidents by product in the last 6 months?
SELECT product_id, COUNT(*) as safety_incidents FROM safety_records WHERE incident_date >= DATEADD(month, -6, GETDATE()) GROUP BY product_id;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT, date DATE, revenue FLOAT); INSERT INTO sales (id, date, revenue) VALUES (1, '2022-01-01', 5000.00), (2, '2022-02-01', 6000.00), (3, '2022-03-01', 7000.00);
What is the total revenue for each month of the year?
SELECT DATE_FORMAT(date, '%Y-%m') as month, SUM(revenue) as total_revenue FROM sales GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE electric_vehicles (id INT, model VARCHAR(50), type VARCHAR(20)); INSERT INTO electric_vehicles (id, model, type) VALUES (1, 'Tesla Model S', 'Electric'), (2, 'Tesla Model 3', 'Electric');
Find the difference between the number of electric and autonomous vehicles.
SELECT (SELECT COUNT(*) FROM electric_vehicles) - (SELECT COUNT(*) FROM autonomous_vehicles) AS difference;
gretelai_synthetic_text_to_sql
CREATE TABLE decentralized_exchanges (exchange_name VARCHAR(255), digital_asset VARCHAR(255), trading_volume DECIMAL(10, 2));
What is the distribution of digital assets across decentralized exchanges and their respective trading volumes in the 'decentralized_exchanges' table?
SELECT de.digital_asset, de.exchange_name, SUM(de.trading_volume) as total_volume FROM decentralized_exchanges de GROUP BY de.digital_asset, de.exchange_name;
gretelai_synthetic_text_to_sql
CREATE TABLE wells (well_id varchar(10), production int, datetime date); INSERT INTO wells (well_id, production, datetime) VALUES ('W003', 1700, '2021-01-01');
What is the total production of well 'W003' in the year 2021?
SELECT SUM(production) FROM wells WHERE well_id = 'W003' AND YEAR(datetime) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE model_fairness (id INT, model_name VARCHAR(50), dataset_region VARCHAR(50), fairness_score FLOAT); INSERT INTO model_fairness (id, model_name, dataset_region, fairness_score) VALUES (1, 'ModelA', 'North America', 0.85), (2, 'ModelB', 'Europe', 0.92), (3, 'ModelC', 'Asia', 0.88);
What is the distribution of model fairness scores for models trained on datasets from different regions?
SELECT dataset_region, AVG(fairness_score) as avg_fairness_score FROM model_fairness GROUP BY dataset_region;
gretelai_synthetic_text_to_sql
CREATE TABLE attorneys (attorney_id INT, cases_handled INT); INSERT INTO attorneys (attorney_id, cases_handled) VALUES (1, 20), (2, 15), (3, 30), (4, 10); CREATE TABLE clients (client_id INT, attorney_id INT, industry VARCHAR(255)); INSERT INTO clients (client_id, attorney_id, industry) VALUES (1, 1, 'healthcare'), (2,...
How many cases were handled by attorneys in the technology industry?
SELECT SUM(attorneys.cases_handled) FROM attorneys INNER JOIN clients ON attorneys.attorney_id = clients.attorney_id INNER JOIN cases ON clients.client_id = cases.client_id WHERE clients.industry = 'technology';
gretelai_synthetic_text_to_sql
CREATE TABLE workers (id INT, industry VARCHAR(255), salary FLOAT, union_member BOOLEAN); INSERT INTO workers (id, industry, salary, union_member) VALUES (1, 'Manufacturing', 50000.0, true), (2, 'Technology', 80000.0, true), (3, 'Retail', 30000.0, false);
What is the maximum salary of workers in the 'Technology' industry who are part of a union?
SELECT MAX(salary) FROM workers WHERE industry = 'Technology' AND union_member = true;
gretelai_synthetic_text_to_sql
CREATE TABLE SoftwareVulnerabilities (id INT, software VARCHAR(255), vulnerability_date DATE); INSERT INTO SoftwareVulnerabilities (id, software, vulnerability_date) VALUES (1, 'Firefox', '2022-03-12'), (2, 'Chrome', '2022-03-05'), (3, 'Firefox', '2022-03-07');
What is the total number of vulnerabilities found in the last week for each software?
SELECT SoftwareVulnerabilities.software AS Software, COUNT(*) AS Total_Vulnerabilities FROM SoftwareVulnerabilities WHERE SoftwareVulnerabilities.vulnerability_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK) GROUP BY SoftwareVulnerabilities.software;
gretelai_synthetic_text_to_sql
CREATE TABLE Members (MemberID INT, Age INT, Gender VARCHAR(10), JoinDate DATE); INSERT INTO Members (MemberID, Age, Gender, JoinDate) VALUES (1, 35, 'Male', '2022-01-01'), (2, 28, 'Female', '2021-01-01'), (3, 42, 'Male', '2022-01-01'); CREATE TABLE Workouts (WorkoutID INT, MemberID INT, WorkoutDate DATE); INSERT INTO ...
What is the total number of workouts done by members who joined in 2022?
SELECT COUNT(*) FROM Workouts INNER JOIN Members ON Workouts.MemberID = Members.MemberID WHERE Members.JoinDate >= '2022-01-01' AND Members.JoinDate < '2023-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE seafood_certifications (id INT, country VARCHAR(50), certification VARCHAR(50)); INSERT INTO seafood_certifications (id, country, certification) VALUES (1, 'Norway', 'MSC'), (2, 'Norway', 'ASC'), (3, 'Canada', 'MSC');
Find countries with more than one sustainable seafood certification.
SELECT country FROM seafood_certifications GROUP BY country HAVING COUNT(DISTINCT certification) > 1;
gretelai_synthetic_text_to_sql
CREATE TABLE warehouse_cost (item_id INT, warehouse_id TEXT, cost FLOAT, order_date DATE);
What is the average warehouse management cost per item for each warehouse in Q3 2021, excluding warehouse 'WH-003'?
SELECT warehouse_id, AVG(cost/COUNT(*)) as avg_cost_per_item FROM warehouse_cost WHERE EXTRACT(MONTH FROM order_date) BETWEEN 7 AND 9 AND warehouse_id != 'WH-003' GROUP BY warehouse_id;
gretelai_synthetic_text_to_sql
CREATE TABLE funding (funding_id INT, amount FLOAT, region VARCHAR(50)); CREATE TABLE education_programs (program_id INT, funding_id INT, animal_id INT);
What is the total amount of funds spent on community education programs, grouped by the region, in the 'funding' and 'education_programs' tables?
SELECT e.region, SUM(f.amount) FROM funding f INNER JOIN education_programs e ON f.funding_id = e.funding_id GROUP BY e.region;
gretelai_synthetic_text_to_sql
CREATE TABLE properties (id INT, neighborhood VARCHAR(20), meets_policy BOOLEAN); INSERT INTO properties (id, neighborhood, meets_policy) VALUES (1, 'Neighborhood A', true), (2, 'Neighborhood B', false), (3, 'Neighborhood C', true);
What is the number of properties available in each neighborhood meeting inclusive housing policies?
SELECT neighborhood, COUNT(*) FROM properties WHERE meets_policy = true GROUP BY neighborhood;
gretelai_synthetic_text_to_sql
CREATE TABLE Programs (ProgramID INT, Program TEXT, Budget DECIMAL); INSERT INTO Programs (ProgramID, Program, Budget) VALUES (1, 'Women Empowerment', 20000);
Update budget for 'Women Empowerment' program to 25000
UPDATE Programs SET Budget = 25000 WHERE Program = 'Women Empowerment';
gretelai_synthetic_text_to_sql
CREATE TABLE drought_impact (region VARCHAR(20), state VARCHAR(20), population INT); INSERT INTO drought_impact (region, state, population) VALUES ('Central Valley', 'California', 600000), ('Los Angeles', 'California', 4000000), ('San Diego', 'California', 1500000);
Which drought-impacted regions in the state of California have a population greater than 500,000?
SELECT region FROM drought_impact WHERE state = 'California' AND population > 500000;
gretelai_synthetic_text_to_sql
CREATE TABLE Spacecraft (SpacecraftID INT, PropulsionSystem VARCHAR, Mass FLOAT);
What is the total mass of all spacecraft that use a specific type of propulsion system?
SELECT SUM(Mass) FROM Spacecraft WHERE PropulsionSystem = 'Ion Thruster';
gretelai_synthetic_text_to_sql