context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE garments (garment_id INT, garment_name VARCHAR(50), country VARCHAR(30), manufacturing_cost DECIMAL(10,2));
What is the average manufacturing cost for garments made in each country?
SELECT country, AVG(manufacturing_cost) FROM garments GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE Counties (CountyName VARCHAR(20), RoadMaintenanceCost DECIMAL(8,2), MilesOfRoads INT); INSERT INTO Counties (CountyName, RoadMaintenanceCost, MilesOfRoads) VALUES ('CountyC', 50.50, 200), ('CountyD', 60.00, 250);
Show the average road maintenance cost per mile in 'CountyC'
SELECT AVG(RoadMaintenanceCost) FROM Counties WHERE CountyName = 'CountyC';
gretelai_synthetic_text_to_sql
CREATE TABLE community_projects (project_id INT, project_name TEXT, location TEXT, completion_year INT); INSERT INTO community_projects (project_id, project_name, location, completion_year) VALUES (1, 'Community Center', 'Southern Region', 2019); INSERT INTO community_projects (project_id, project_name, location, completion_year) VALUES (2, 'Park Renovation', 'Northern Region', 2018); INSERT INTO community_projects (project_id, project_name, location, completion_year) VALUES (3, 'Library Construction', 'Latin America', 2019);
What is the percentage of community development projects completed in 'Latin America' in 2019?
SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM community_projects WHERE location = 'Latin America')) FROM community_projects WHERE completion_year = 2019 AND location = 'Latin America';
gretelai_synthetic_text_to_sql
CREATE TABLE military_tech_budget (id INT, year INT, amount INT, country TEXT); INSERT INTO military_tech_budget (id, year, amount, country) VALUES (1, 2020, 7000000, 'Saudi Arabia'), (2, 2020, 8000000, 'UAE'), (3, 2019, 9000000, 'Iran');
What is the maximum budget allocated to military technology development in the Middle East?
SELECT MAX(amount) FROM military_tech_budget WHERE country IN ('Saudi Arabia', 'UAE', 'Iran') AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE music_streaming (song_id INT, song_name TEXT, artist_name TEXT, plays INT);
What is the total number of plays for a specific artist in the 'music_streaming' table?
SELECT SUM(plays) FROM music_streaming WHERE artist_name = 'Rihanna';
gretelai_synthetic_text_to_sql
CREATE TABLE Shipment (id INT, source_country VARCHAR(255), destination_continent VARCHAR(255), quantity INT); INSERT INTO Shipment (id, source_country, destination_continent, quantity) VALUES (1, 'Germany', 'Europe', 500), (2, 'France', 'Europe', 300), (3, 'United Kingdom', 'Europe', 200), (4, 'Italy', 'Europe', 100);
What is the total quantity of items shipped from each country to Europe?
SELECT source_country, SUM(quantity) FROM Shipment WHERE destination_continent = 'Europe' GROUP BY source_country
gretelai_synthetic_text_to_sql
CREATE TABLE Projects (ProjectID INT, Name TEXT, Budget INT);CREATE TABLE Locations (ProjectID INT, Country TEXT);
What is the maximum budget for heritage preservation projects in South America?
SELECT MAX(Projects.Budget) FROM Projects INNER JOIN Locations ON Projects.ProjectID = Locations.ProjectID WHERE Locations.Country = 'South America';
gretelai_synthetic_text_to_sql
CREATE TABLE well_production (well_id INT, measurement_date DATE, production_rate FLOAT, location TEXT); INSERT INTO well_production (well_id, measurement_date, production_rate, location) VALUES (1, '2022-02-01', 550, 'Texas'), (2, '2022-02-01', 650, 'California'), (3, '2022-02-01', 750, 'Texas'), (4, '2022-02-01', 850, 'California');
What is the total production rate for each location in the last month?
SELECT location, SUM(production_rate) AS Total_Production_Rate FROM well_production WHERE measurement_date >= DATEADD(month, -1, GETDATE()) GROUP BY location
gretelai_synthetic_text_to_sql
CREATE TABLE Textile_Sourcing (brand VARCHAR(255), waste_per_garment DECIMAL(5,2)); INSERT INTO Textile_Sourcing (brand, waste_per_garment) VALUES ('BrandA', 0.35), ('BrandB', 0.20), ('BrandC', 0.18), ('BrandD', 0.40), ('BrandE', 0.25);
What is the average textile waste generated per garment by sustainable fashion brands?
SELECT AVG(waste_per_garment) FROM Textile_Sourcing WHERE brand IN ('GreenBrand1', 'GreenBrand2', 'EcoBrand', 'SustainableFabrics', 'EthicalTextiles');
gretelai_synthetic_text_to_sql
CREATE TABLE Military_Equipment_Sales(id INT, country VARCHAR(50), equipment_type VARCHAR(50), sale_value FLOAT); INSERT INTO Military_Equipment_Sales(id, country, equipment_type, sale_value) VALUES (1, 'Egypt', 'Aircraft', 60000000), (2, 'South Africa', 'Naval', 40000000), (3, 'Algeria', 'Vehicles', 20000000);
What is the difference in sale value between the highest and lowest sales of military equipment to Africa?
SELECT MAX(sale_value) - MIN(sale_value) FROM Military_Equipment_Sales WHERE country IN ('Egypt', 'South Africa', 'Algeria');
gretelai_synthetic_text_to_sql
CREATE TABLE satellites (satellite_id INT, name VARCHAR(100), manufacturer VARCHAR(100), launch_date DATE); INSERT INTO satellites (satellite_id, name, manufacturer, launch_date) VALUES (1, 'Sat1', 'SpaceTech Inc.', '2005-03-14'); INSERT INTO satellites (satellite_id, name, manufacturer, launch_date) VALUES (2, 'Sat2', 'Aerospace Corp.', '2008-09-27'); INSERT INTO satellites (satellite_id, name, manufacturer, launch_date) VALUES (3, 'Sat3', 'SpaceTech Inc.', '2020-02-17');
Which manufacturers have launched satellites in the last 5 years?
SELECT DISTINCT manufacturer FROM satellites WHERE launch_date BETWEEN DATE_SUB(CURDATE(), INTERVAL 5 YEAR) AND CURDATE();
gretelai_synthetic_text_to_sql
CREATE TABLE safety_reports (report_id INT, state VARCHAR(2), incident_type VARCHAR(15)); INSERT INTO safety_reports (report_id, state, incident_type) VALUES (1, 'NY', 'Fall'), (2, 'CA', 'Electrocution'), (3, 'IL', 'Fall');
How many workplace safety incidents were reported in each state?
SELECT state, COUNT(*) as num_incidents FROM safety_reports GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE CommunityHealthWorkers (ID INT PRIMARY KEY, Name VARCHAR(50), Age INT, Race VARCHAR(20), Gender VARCHAR(10), LanguageSpoken VARCHAR(20), ZipCode VARCHAR(10));
How many community health workers speak each language?
SELECT LanguageSpoken, COUNT(*) FROM CommunityHealthWorkers GROUP BY LanguageSpoken;
gretelai_synthetic_text_to_sql
CREATE TABLE Regional_Revenue (region TEXT, revenue FLOAT); INSERT INTO Regional_Revenue (region, revenue) VALUES ('EMEA', 1200000), ('APAC', 1500000);
What is the total revenue for the 'EMEA' region in the 'Regional_Revenue' table?
SELECT SUM(revenue) FROM Regional_Revenue WHERE region = 'EMEA';
gretelai_synthetic_text_to_sql
CREATE TABLE health_metrics (member_id INT, body_fat_percentage FLOAT, last_checked DATE); INSERT INTO health_metrics (member_id, body_fat_percentage, last_checked) VALUES (1, 22, '2021-01-15'), (2, 28, '2022-03-28');
How many members have a body fat percentage over 25%?
SELECT COUNT(*) FROM health_metrics WHERE body_fat_percentage > 25;
gretelai_synthetic_text_to_sql
CREATE TABLE Ethical_AI_Patents (year INT, country VARCHAR(50), patent VARCHAR(50)); INSERT INTO Ethical_AI_Patents (year, country, patent) VALUES (2018, 'USA', 'AI Ethics Framework'), (2019, 'Canada', 'Ethical AI Algorithm'), (2018, 'Germany', 'Ethical AI Guidelines'), (2019, 'USA', 'Ethical AI Toolkit'), (2018, 'Canada', 'AI Ethics Charter');
What is the number of ethical AI patents filed by year and country?
SELECT year, country, COUNT(patent) as num_patents FROM Ethical_AI_Patents GROUP BY year, country;
gretelai_synthetic_text_to_sql
CREATE TABLE professor_advising (id INT, professor TEXT, num_students INT, year INT); INSERT INTO professor_advising (id, professor, num_students, year) VALUES (13, 'Alice', 7, 2021); INSERT INTO professor_advising (id, professor, num_students, year) VALUES (14, 'Bob', 6, 2020);
What are the research interests of professors who have advised the most graduate students in the past two years, and the number of students they have advised?
SELECT professor, research_interest, num_students FROM professors p JOIN professor_advising pa ON p.name = pa.professor WHERE year BETWEEN 2020 AND 2021 GROUP BY professor, research_interest, num_students ORDER BY num_students DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE community_initiatives (id INT, country VARCHAR(50), initiative VARCHAR(50), year INT, expenditure DECIMAL(10,2)); INSERT INTO community_initiatives (id, country, initiative, year, expenditure) VALUES (1, 'Indonesia', 'Healthcare Center', 2021, 180000.00), (2, 'Indonesia', 'Education Building', 2022, 220000.00);
Calculate the total expenditure on community development initiatives in Indonesia for 2021 and 2022.
SELECT SUM(expenditure) FROM community_initiatives WHERE country = 'Indonesia' AND year IN (2021, 2022);
gretelai_synthetic_text_to_sql
CREATE TABLE Artworks (id INT, value DECIMAL(10,2)); INSERT INTO Artworks (id, value) VALUES (1, 5000); INSERT INTO Artworks (id, value) VALUES (2, 10000);
What is the maximum value of artworks in the 'Artworks' table?
SELECT MAX(value) FROM Artworks;
gretelai_synthetic_text_to_sql
CREATE TABLE visitor_stats (id INT PRIMARY KEY, visitor_country VARCHAR(50), year INT, num_visitors INT); INSERT INTO visitor_stats (id, visitor_country, year, num_visitors) VALUES (1, 'USA', 2015, 50000); INSERT INTO visitor_stats (id, visitor_country, year, num_visitors) VALUES (2, 'USA', 2018, 60000);
What is the average number of visitors to Australia from the USA each year?
SELECT AVG(num_visitors) FROM visitor_stats WHERE visitor_country = 'USA' AND year IS NOT NULL GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE membership_features (id INT, user_id INT, feature VARCHAR(20)); INSERT INTO membership_features (id, user_id, feature) VALUES (1, 1, 'Personal Training'), (2, 2, 'Group Classes'), (3, 3, 'Personal Training'); CREATE TABLE daily_steps (id INT, user_id INT, steps INT, date DATE); INSERT INTO daily_steps (id, user_id, steps, date) VALUES (1, 1, 25000, '2022-01-01'), (2, 2, 15000, '2022-01-05'), (3, 3, 18000, '2022-01-03');
How many users have a membership that includes personal training sessions and have achieved over 20,000 steps in a day?
SELECT COUNT(*) FROM (SELECT user_id FROM membership_features m JOIN daily_steps d ON m.user_id = d.user_id WHERE m.feature = 'Personal Training' AND d.steps > 20000) subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE hospitals (id INT, name TEXT, state TEXT, type TEXT); INSERT INTO hospitals (id, name, state, type) VALUES (1, 'Hospital A', 'State A', 'public'), (2, 'Hospital B', 'State A', 'private'), (3, 'Hospital C', 'State B', 'public');
How many public hospitals are there in each state?
SELECT state, COUNT(*) FROM hospitals WHERE type = 'public' GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE environmental_impact_assessments (assessment_id int,assessment_date date,assessment_description varchar(255),chemical_id varchar(10));
Delete records in the "environmental_impact_assessments" table where the "assessment_date" is before January 1, 2020.
DELETE FROM environmental_impact_assessments WHERE assessment_date < '2020-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE clients (client_id INT, name VARCHAR(50), age INT, assets DECIMAL(10,2), city VARCHAR(50)); INSERT INTO clients VALUES (1, 'John Doe', 55, 500000.00, 'Los Angeles'), (2, 'Jane Smith', 45, 700000.00, 'Los Angeles'), (3, 'Mike Johnson', 58, 300000.00, 'San Francisco'), (4, 'Alice Davis', 35, 800000.00, 'Chicago'), (5, 'Bob Brown', 40, 600000.00, 'San Francisco');
What is the total assets of clients living in Los Angeles or San Francisco?
SELECT SUM(assets) FROM clients WHERE city IN ('Los Angeles', 'San Francisco');
gretelai_synthetic_text_to_sql
CREATE TABLE sales (product_id INT, product_category VARCHAR(255), revenue DECIMAL(10, 2)); INSERT INTO sales (product_id, product_category, revenue) VALUES (1, 'Electronics', 500), (2, 'Books', 200), (3, 'Electronics', 800);
What is the total revenue for each category of products sold?
SELECT product_category, SUM(revenue) as total_revenue FROM sales GROUP BY product_category;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists genetics;CREATE TABLE if not exists genetics.research_projects(id INT, name TEXT, location TEXT, type TEXT, funding DECIMAL(10,2));INSERT INTO genetics.research_projects (id, name, location, type, funding) VALUES (1, 'ProjectX', 'France', 'Genetic', 1200000.00), (2, 'ProjectY', 'USA', 'Genomic', 2000000.00), (3, 'ProjectZ', 'Canada', 'Genomic', 900000.00);
What is the total funding received by genetic research projects in France?
SELECT SUM(funding) FROM genetics.research_projects WHERE location = 'France';
gretelai_synthetic_text_to_sql
CREATE TABLE students (id INT, name VARCHAR(255), gender VARCHAR(6), gpa FLOAT, PRIMARY KEY (id)); CREATE TABLE departments (id INT, name VARCHAR(255)); CREATE TABLE enrollment (student_id INT, department_id INT, PRIMARY KEY (student_id, department_id), FOREIGN KEY (student_id) REFERENCES students(id), FOREIGN KEY (department_id) REFERENCES departments(id)); CREATE TABLE grants (id INT, student_id INT, PRIMARY KEY (id), FOREIGN KEY (student_id) REFERENCES students(id));
What are the names of the graduate students who have not received any research grants, and what is the average GPA of these students?
SELECT AVG(s.gpa) FROM students s WHERE s.id NOT IN (SELECT g.student_id FROM grants g);
gretelai_synthetic_text_to_sql
CREATE TABLE student_mental_health (student_id INT, mental_health_score INT, gender TEXT);
Calculate the average mental health score for each gender
SELECT sd.gender, AVG(smh.mental_health_score) FROM student_mental_health smh INNER JOIN student_demographics sd ON smh.student_id = sd.student_id GROUP BY sd.gender;
gretelai_synthetic_text_to_sql
CREATE TABLE Athletes (athlete_id INT, athlete_name VARCHAR(255), age INT, team VARCHAR(255)); CREATE VIEW WellbeingPrograms AS SELECT athlete_id, team FROM Programs WHERE program_type IN ('NBA', 'NFL');
What is the average age of athletes in 'NBA' and 'NFL' wellbeing programs?
SELECT AVG(Athletes.age) FROM Athletes INNER JOIN WellbeingPrograms ON Athletes.athlete_id = WellbeingPrograms.athlete_id WHERE Athletes.team IN ('NBA', 'NFL');
gretelai_synthetic_text_to_sql
CREATE TABLE students (student_id INT, name VARCHAR(255), major VARCHAR(255), gpa DECIMAL(3,2)); CREATE VIEW top_students AS SELECT * FROM students WHERE gpa >= 3.5;
List the names and GPAs of all students in the "top_students" view.
SELECT name, gpa FROM top_students;
gretelai_synthetic_text_to_sql
CREATE TABLE ExcavationLeaders (LeaderID int, LeaderName text, Affiliation text);
Who has led excavations at the Knossos Palace?
SELECT LeaderName FROM ExcavationLeaders WHERE Affiliation = 'Knossos Palace';
gretelai_synthetic_text_to_sql
CREATE TABLE investors (investor_id INT, investor_name VARCHAR(30), investor_type VARCHAR(20)); CREATE TABLE investments (investment_id INT, investor_id INT, sector_id INT);
How many 'private' investors have made investments in the 'renewable energy' sector?
SELECT COUNT(*) FROM investments i INNER JOIN investors j ON i.investor_id = j.investor_id WHERE j.investor_type = 'private' AND i.sector_id IN (SELECT sector_id FROM sectors WHERE sector_name = 'renewable energy');
gretelai_synthetic_text_to_sql
CREATE TABLE ransomware_threats (id INT, threat_type VARCHAR(50), severity_score INT, threat_date DATE);
What is the minimum severity score of threats related to 'ransomware' in the last year?
SELECT MIN(severity_score) as min_severity FROM ransomware_threats WHERE threat_type = 'ransomware' AND threat_date >= DATEADD(year, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE Movies (movie_id INT, title VARCHAR(100), release_year INT, budget INT); INSERT INTO Movies (movie_id, title, release_year, budget) VALUES (1, 'MovieA', 2018, 50000000); INSERT INTO Movies (movie_id, title, release_year, budget) VALUES (2, 'MovieB', 2019, 60000000);
What is the average production budget for movies released in 2018?
SELECT AVG(budget) FROM Movies WHERE release_year = 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE biotech_startups (id INT, name VARCHAR(50), location VARCHAR(50), funding FLOAT); INSERT INTO biotech_startups (id, name, location, funding) VALUES (1, 'Genomic Inc', 'California', 1500000); INSERT INTO biotech_startups (id, name, location, funding) VALUES (2, 'BioSense', 'Texas', 1200000);
What is the average funding received by biotech startups in California?
SELECT AVG(funding) FROM biotech_startups WHERE location = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_basins (name TEXT, depth_at_summit REAL, depth_at_deepest_point REAL);
Find the maximum depth of the Atlantic Ocean.
SELECT MAX(depth_at_deepest_point) FROM ocean_basins WHERE name = 'Atlantic Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE campaigns (campaign_id INT, campaign_name TEXT, amount_raised DECIMAL(10,2));
Find the average donation per campaign in the 'campaigns' table.
SELECT campaign_name, AVG(amount_raised) FROM campaigns GROUP BY campaign_name;
gretelai_synthetic_text_to_sql
CREATE TABLE GenreSong (GenreID INT, SongID INT);
Which genres have more than 5000 songs?
SELECT Genre.Name FROM Genre INNER JOIN GenreSong ON Genre.GenreID = GenreSong.GenreID GROUP BY Genre.Name HAVING COUNT(GenreSong.SongID)>5000;
gretelai_synthetic_text_to_sql
CREATE TABLE policyholders (policy_id INT, policyholder_age INT, policy_type VARCHAR(20)); CREATE TABLE policies (policy_id INT, policy_state VARCHAR(2));
List policyholders with home insurance policies in Florida who are between 35 and 50 years old
SELECT DISTINCT policyholder_age, policy_type FROM policyholders JOIN policies ON policyholders.policy_id = policies.policy_id WHERE policies.policy_state = 'FL' AND policyholder_age BETWEEN 35 AND 50;
gretelai_synthetic_text_to_sql
CREATE TABLE economic_diversification_investment (year INT, region VARCHAR(20), investment INT); INSERT INTO economic_diversification_investment (year, region, investment) VALUES (2018, 'Latin America', 80000), (2019, 'Latin America', 90000), (2020, 'Latin America', 100000), (2021, 'Latin America', 110000);
Find the total economic diversification investment in the 'Latin America' region over the last 4 years.
SELECT SUM(investment) FROM economic_diversification_investment WHERE region = 'Latin America' AND year BETWEEN 2018 AND 2021;
gretelai_synthetic_text_to_sql
CREATE SCHEMA community; CREATE TABLE community.donors (donor_id INT, donor_name VARCHAR(100)); CREATE TABLE community.donations (donation_id INT, donor_id INT, donation_amount DECIMAL(10, 2), donation_date DATE); INSERT INTO community.donors (donor_id, donor_name) VALUES (1, 'Garcia'), (2, 'Patel'); INSERT INTO community.donations (donation_id, donor_id, donation_amount, donation_date) VALUES (1, 1, 200.00, '2021-05-01'), (2, 2, 300.00, '2021-06-15'), (3, 1, 50.00, '2021-07-28');
What is the total amount donated by donors with the last name 'Garcia' or 'Patel' in the 'community' schema's 'donors' and 'donations' tables?
SELECT SUM(d.donation_amount) FROM community.donors dn INNER JOIN community.donations d ON dn.donor_id = d.donor_id WHERE dn.donor_name IN ('Garcia', 'Patel');
gretelai_synthetic_text_to_sql
CREATE TABLE PatientDemographics (PatientID INT, LGBTQPlus BOOLEAN); INSERT INTO PatientDemographics (PatientID, LGBTQPlus) VALUES (1, true); INSERT INTO PatientDemographics (PatientID, LGBTQPlus) VALUES (2, false); INSERT INTO PatientDemographics (PatientID, LGBTQPlus) VALUES (3, true);
Find the percentage of patients who identify as LGBTQ+, from the total number of patients, rounded to two decimal places.
SELECT ROUND(COUNT(*) FILTER (WHERE LGBTQPlus = true) * 100.0 / COUNT(*), 2) as Percentage FROM PatientDemographics;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, Name TEXT, TotalDonation DECIMAL(10, 2)); INSERT INTO Donors (DonorID, Name, TotalDonation) VALUES (1, 'John Doe', 500.00), (2, 'Jane Smith', 750.00); CREATE TABLE Donations (DonationID INT, DonorID INT, Amount DECIMAL(10, 2), DonationDate DATE); INSERT INTO Donations (DonationID, DonorID, Amount, DonationDate) VALUES (1, 1, 100.00, '2021-01-01'), (2, 1, 150.00, '2021-02-01'), (3, 2, 250.00, '2021-03-01'), (4, 2, 500.00, '2021-04-01');
What's the total amount donated by each donor in 2021?
SELECT d.Name, SUM(donations.Amount) AS TotalDonated FROM Donors d INNER JOIN Donations donations ON d.DonorID = donations.DonorID WHERE YEAR(donations.DonationDate) = 2021 GROUP BY d.Name;
gretelai_synthetic_text_to_sql
CREATE TABLE Incident (id INT PRIMARY KEY, name VARCHAR(255), description TEXT, incident_date DATE, incident_type VARCHAR(255)); CREATE TABLE ForeignEntity (id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255), region VARCHAR(255)); INSERT INTO ForeignEntity (id, name, country, region) VALUES (1, 'Hanoi', 'Vietnam', 'ASEAN'), (2, 'Singapore', 'Singapore', 'ASEAN'), (3, 'Phnom Penh', 'Cambodia', 'ASEAN'), (4, 'Bangkok', 'Thailand', 'ASEAN'), (5, 'Jakarta', 'Indonesia', 'ASEAN'); INSERT INTO Incident (id, name, description, incident_date, incident_type, foreign_entity_id) VALUES (1, 'Incident1', '...', '2020-01-01', 'Espionage', 1), (2, 'Incident2', '...', '2021-01-01', 'Cyberattack', 2), (3, 'Incident3', '...', '2019-01-01', 'Cyberattack', 4);
Find national security incidents involving foreign entities from ASEAN countries
SELECT i.name, i.incident_date, i.incident_type, f.name AS foreign_entity_name FROM Incident i INNER JOIN ForeignEntity f ON i.foreign_entity_id = f.id WHERE f.region = 'ASEAN';
gretelai_synthetic_text_to_sql
CREATE TABLE ExhibitionAnalytics (ExhibitionID INT, ExhibitionName VARCHAR(50), TotalVisitors INT, TotalEngagement INT);
Insert new records into the ExhibitionAnalytics table for the 'Digital Art' exhibition.
INSERT INTO ExhibitionAnalytics (ExhibitionID, ExhibitionName, TotalVisitors, TotalEngagement) VALUES (101, 'Digital Art', 250, 150);
gretelai_synthetic_text_to_sql
CREATE TABLE Brands (id INT, name VARCHAR(255)); CREATE TABLE Products (id INT, brand_id INT, name VARCHAR(255), price DECIMAL(5,2), is_organic BOOLEAN);
Calculate the average price of organic products for each brand.
SELECT b.name, AVG(p.price) as avg_price FROM Brands b JOIN Products p ON b.id = p.brand_id WHERE p.is_organic = TRUE GROUP BY b.name;
gretelai_synthetic_text_to_sql
CREATE TABLE Infrastructure_USA (Type VARCHAR(50), Country VARCHAR(50), Cost FLOAT); INSERT INTO Infrastructure_USA (Type, Country, Cost) VALUES ('Road', 'USA', 5000000), ('Bridge', 'USA', 12000000), ('Highway', 'USA', 9000000);
What is the total cost of infrastructure projects in the USA, categorized by type?
SELECT Type, SUM(Cost) as Total_Cost FROM Infrastructure_USA WHERE Country = 'USA' GROUP BY Type;
gretelai_synthetic_text_to_sql
CREATE TABLE peacekeeping_operations (id INT, operation_name VARCHAR(255), lead_organization VARCHAR(255), start_date DATE); INSERT INTO peacekeeping_operations (id, operation_name, lead_organization, start_date) VALUES (1, 'EUTM Mali', 'European Union', '2013-02-18'), (2, 'MINUSMA', 'United Nations', '2013-07-25'), (3, 'LAS PKO', 'League of Arab States', '2014-03-30');
Identify the peacekeeping operations where the European Union or the League of Arab States is the lead organization
SELECT * FROM peacekeeping_operations WHERE lead_organization IN ('European Union', 'League of Arab States');
gretelai_synthetic_text_to_sql
CREATE TABLE threat_intelligence(id INT, threat_name VARCHAR(255), category VARCHAR(255), origin VARCHAR(255), last_seen DATETIME); INSERT INTO threat_intelligence(id, threat_name, category, origin, last_seen) VALUES (1, 'APT Attack', 'APT', 'China', '2021-03-01 09:00:00');
Which APT attacks were detected in India in the last month?
SELECT ti.threat_name, ti.origin, ti.last_seen FROM threat_intelligence ti WHERE ti.category = 'APT' AND ti.last_seen >= '2021-02-01' AND ti.origin = 'India';
gretelai_synthetic_text_to_sql
CREATE TABLE well_production_averages (well_name TEXT, production_quantity INT); INSERT INTO well_production_averages (well_name, production_quantity) VALUES ('Well A', 4000), ('Well B', 5000), ('Well C', 6000), ('Well D', 7000), ('Well E', 8000);
What is the average production quantity for all wells?
SELECT AVG(production_quantity) FROM well_production_averages;
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (id INT, city VARCHAR(50), hours INT); INSERT INTO volunteers (id, city, hours) VALUES (1, 'New York', 300), (2, 'Los Angeles', 450), (3, 'Chicago', 250), (4, 'New York', 500), (5, 'Los Angeles', 600);
List the top 3 cities with the most volunteer hours in 2020?
SELECT city, SUM(hours) as total_hours FROM volunteers WHERE YEAR(donation_date) = 2020 GROUP BY city ORDER BY total_hours DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE community_development (id INT, initiative_name TEXT, completion_date DATE, country TEXT); INSERT INTO community_development (id, initiative_name, completion_date, country) VALUES (1, 'CommunityDevA', '2021-01-01', 'Country1'); INSERT INTO community_development (id, initiative_name, completion_date, country) VALUES (2, 'CommunityDevB', '2022-03-15', 'Country2');
How many community development initiatives were completed in each country in 'rural_development' database?
SELECT country, COUNT(*) as total_completed FROM community_development WHERE completion_date IS NOT NULL GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE creative_ai (name VARCHAR(255), input_type VARCHAR(255)); INSERT INTO creative_ai (name, input_type) VALUES ('GPT-3', 'text'), ('BERT', 'text'), ('RoBERTa', 'text');
What are the names of all creative AI applications that use text as input?
SELECT name FROM creative_ai WHERE input_type = 'text'
gretelai_synthetic_text_to_sql
CREATE TABLE ai_training_hours (org_id INT, sector VARCHAR(20), hours INT); INSERT INTO ai_training_hours (org_id, sector, hours) VALUES (1, 'healthcare', 30), (2, 'healthcare', 35), (3, 'healthcare', 40);
What is the average number of hours spent on AI training by organizations in the healthcare sector?
SELECT AVG(hours) FROM ai_training_hours WHERE sector = 'healthcare';
gretelai_synthetic_text_to_sql
CREATE TABLE schools (id INT PRIMARY KEY, name VARCHAR(255)); CREATE TABLE teachers (id INT PRIMARY KEY, school_id INT); CREATE TABLE open_pedagogy_initiatives (id INT PRIMARY KEY, teacher_id INT, hours_spent INT);
What is the total number of hours spent on open pedagogy initiatives by teachers in each school?
SELECT s.name, SUM(opi.hours_spent) FROM open_pedagogy_initiatives opi JOIN teachers t ON opi.teacher_id = t.id JOIN schools s ON t.school_id = s.id GROUP BY t.school_id;
gretelai_synthetic_text_to_sql
CREATE TABLE ProgramDates (ProgramID int, ProgramDate date); INSERT INTO ProgramDates (ProgramID, ProgramDate) VALUES (1, '2021-01-01'), (2, '2021-02-01'), (3, '2021-03-01'), (4, '2021-04-01'), (5, '2021-05-01'); CREATE TABLE DisabilitySupportPrograms (ProgramID int, ProgramName varchar(50), AdditionDate date); INSERT INTO DisabilitySupportPrograms (ProgramID, ProgramName, AdditionDate) VALUES (1, 'Assistive Technology', '2021-01-15'), (2, 'Sign Language Interpretation', '2021-02-16'), (3, 'Mental Health Services', '2021-03-17'), (4, 'Physical Therapy', '2021-04-18'), (5, 'Speech Therapy', '2021-05-19');
How many disability support programs were added per month in the past year?
SELECT DATEPART(MONTH, AdditionDate) as Month, COUNT(*) as ProgramsAdded FROM DisabilitySupportPrograms GROUP BY DATEPART(MONTH, AdditionDate);
gretelai_synthetic_text_to_sql
CREATE TABLE tours (tour_id INT, type TEXT, country TEXT, duration INT); INSERT INTO tours (tour_id, type, country, duration) VALUES (1, 'Sustainable', 'Brazil', 4), (2, 'Virtual', 'Brazil', 2);
What is the average tour duration for sustainable tours in Brazil?
SELECT AVG(duration) FROM tours WHERE type = 'Sustainable' AND country = 'Brazil';
gretelai_synthetic_text_to_sql
CREATE TABLE Dispensaries (id INT, name TEXT, state TEXT); INSERT INTO Dispensaries (id, name, state) VALUES (1, 'Dispensary A', 'Washington'), (2, 'Dispensary B', 'Washington'); CREATE TABLE Sales (id INT, dispensary_id INT, revenue INT, sale_date DATE, state TEXT); INSERT INTO Sales (id, dispensary_id, revenue, sale_date, state) VALUES (1, 1, 400, '2022-01-01', 'Washington'), (2, 1, 300, '2022-01-02', 'Washington'), (3, 2, 200, '2022-01-01', 'Washington'), (4, 2, 100, '2022-01-02', 'Washington');
Which dispensaries in Washington sold more than $500 in Q1 2022?
SELECT d.name FROM Dispensaries d INNER JOIN Sales s ON d.id = s.dispensary_id WHERE s.sale_date BETWEEN '2022-01-01' AND '2022-03-31' AND s.revenue > 500 AND d.state = 'Washington' GROUP BY d.name;
gretelai_synthetic_text_to_sql
CREATE TABLE livestock_health (animal_id INT, health_status TEXT, health_check_timestamp TIMESTAMP);
Insert a new record into the "livestock_health" table with a "animal_id" of 4, "health_status" of "healthy", and "health_check_timestamp" of '2022-07-03 09:15:00'
INSERT INTO livestock_health (animal_id, health_status, health_check_timestamp) VALUES (4, 'healthy', '2022-07-03 09:15:00');
gretelai_synthetic_text_to_sql
CREATE TABLE satellites (id INT, name TEXT, country TEXT, launch_date DATE, mass FLOAT); INSERT INTO satellites (id, name, country, launch_date, mass) VALUES (1, 'Hayabusa', 'Japan', '2003-05-09', 510), (2, 'Akatsuki', 'Japan', '2010-05-20', 1300);
What is the total mass of all satellites launched by JAXA?
SELECT SUM(mass) FROM satellites WHERE country = 'Japan';
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species_observations (observation_id INTEGER, year INTEGER, species_name TEXT, ocean TEXT, number_of_observations INTEGER);
What is the average number of marine species observed in the Mediterranean Sea per year, with at least 500 observations per species?
SELECT ocean, AVG(number_of_observations) FROM marine_species_observations WHERE year BETWEEN 2000 AND 2020 AND ocean = 'Mediterranean Sea' GROUP BY ocean HAVING COUNT(DISTINCT species_name) >= 500;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas (id INT, name VARCHAR(50), size FLOAT, country VARCHAR(50));
Delete the record with id 3 from the table "marine_protected_areas"
DELETE FROM marine_protected_areas WHERE id = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE AI_ethics_guidelines (organization_name VARCHAR(255), guideline_text TEXT, review_date DATE);
For the AI_ethics_guidelines table, return the organization_name and guideline_text for the row with the latest review_date, in descending order.
SELECT organization_name, guideline_text FROM AI_ethics_guidelines WHERE review_date = (SELECT MAX(review_date) FROM AI_ethics_guidelines);
gretelai_synthetic_text_to_sql
CREATE TABLE region_recycling (region VARCHAR(255), recycling_rate DECIMAL(5,2), total_waste INT); INSERT INTO region_recycling (region, recycling_rate, total_waste) VALUES ('East Anglia', 0.45, 2500000);
What is the monthly recycling rate for the region of East Anglia?
SELECT recycling_rate*100 FROM region_recycling WHERE region='East Anglia';
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, customer_name TEXT, gender TEXT, age INT, country TEXT); INSERT INTO customers (customer_id, customer_name, gender, age, country) VALUES (1, 'Alex', 'Male', 35, 'Germany'), (2, 'Sarah', 'Female', 40, 'Germany'); CREATE TABLE loans (loan_id INT, customer_id INT, maturity INT); INSERT INTO loans (loan_id, customer_id, maturity) VALUES (1, 1, 5), (2, 2, 6);
Provide the number of customers who have taken out loans with a maturity of 5 years or more, broken down by gender and age group, in Germany?
SELECT gender, CASE WHEN age < 30 THEN '18-29' WHEN age < 50 THEN '30-49' ELSE '50+' END AS age_group, COUNT(*) FROM customers JOIN loans ON customers.customer_id = loans.customer_id WHERE country = 'Germany' AND maturity >= 5 GROUP BY gender, age_group;
gretelai_synthetic_text_to_sql
CREATE TABLE Menu (item VARCHAR(20), type VARCHAR(20), price DECIMAL(5,2), quantity INT); INSERT INTO Menu (item, type, price, quantity) VALUES ('Chickpea Curry', 'Vegan', 12.99, 30);
Update the quantity of 'Chickpea Curry' to 35 in the 'Vegan' section.
UPDATE Menu SET quantity = 35 WHERE item = 'Chickpea Curry' AND type = 'Vegan';
gretelai_synthetic_text_to_sql
CREATE TABLE factory_production (factory VARCHAR(20), quantity INT, production_date DATE); INSERT INTO factory_production (factory, quantity, production_date) VALUES ('Factory A', 500, '2022-01-05'), ('Factory B', 700, '2022-01-10'), ('Factory C', 300, '2022-01-15'), ('Factory A', 400, '2022-01-20'), ('Factory B', 600, '2022-01-25'), ('Factory C', 450, '2022-01-30');
How many garments were produced in each factory in January 2022?
SELECT factory, SUM(quantity) FROM factory_production WHERE EXTRACT(MONTH FROM production_date) = 1 AND EXTRACT(YEAR FROM production_date) = 2022 GROUP BY factory;
gretelai_synthetic_text_to_sql
CREATE TABLE MentalHealthParity (ViolationID INT, State VARCHAR(255), ViolationDate DATE); INSERT INTO MentalHealthParity (ViolationID, State, ViolationDate) VALUES (1, 'California', '2021-12-31'), (2, 'Texas', '2022-03-15'), (3, 'New York', '2022-05-05'), (4, 'Florida', '2022-07-01'), (5, 'Illinois', '2022-09-12'), (6, 'California', '2022-11-01'), (7, 'New York', '2022-12-31'), (8, 'Texas', '2022-01-15'), (9, 'Florida', '2022-02-01');
What is the total number of mental health parity violations in each state for the past year?
SELECT State, COUNT(*) as ViolationCount FROM MentalHealthParity WHERE ViolationDate >= DATEADD(year, -1, GETDATE()) GROUP BY State;
gretelai_synthetic_text_to_sql
CREATE TABLE Menu (id INT, item VARCHAR(50), price DECIMAL(5,2), qty INT);
Insert a new menu item called 'Veggie Burger' with a price of $12.99 and a quantity of 15.
INSERT INTO Menu (item, price, qty) VALUES ('Veggie Burger', 12.99, 15);
gretelai_synthetic_text_to_sql
CREATE TABLE trips (id INT, user_id INT, vehicle_type VARCHAR(20), trip_distance FLOAT, trip_duration INT, departure_time TIMESTAMP, arrival_time TIMESTAMP, city VARCHAR(50));INSERT INTO trips (id, user_id, vehicle_type, trip_distance, trip_duration, departure_time, arrival_time, city) VALUES (10, 112, 'car', 35.0, 75, '2022-01-07 07:00:00', '2022-01-07 07:75:00', 'Toronto');
What is the total trip duration for each city?
SELECT city, SUM(trip_duration) as total_duration FROM trips GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE cybersecurity_strategies (strategy_name VARCHAR(50), implementation_year INT); INSERT INTO cybersecurity_strategies (strategy_name, implementation_year) VALUES ('Firewall', 2018), ('Intrusion Detection System', 2019), ('Multi-Factor Authentication', 2020), ('Zero Trust', 2021), ('Encryption', 2017);
What is the average implementation year of cybersecurity strategies in the 'cybersecurity_strategies' table?
SELECT AVG(implementation_year) as avg_year FROM cybersecurity_strategies;
gretelai_synthetic_text_to_sql
CREATE TABLE startups (id INT, name VARCHAR(50), funding_source_id INT); CREATE TABLE funding_sources (id INT, name VARCHAR(50)); INSERT INTO startups VALUES (1, 'StartupJ', 1001); INSERT INTO startups VALUES (2, 'StartupK', 1002); INSERT INTO startups VALUES (3, 'StartupL', 1003); INSERT INTO funding_sources VALUES (1001, 'Venture Capital'); INSERT INTO funding_sources VALUES (1002, 'Government Grants'); INSERT INTO funding_sources VALUES (1003, 'Angel Investors');
List all biotech startups and their corresponding funding sources.
SELECT startups.name, funding_sources.name FROM startups INNER JOIN funding_sources ON startups.funding_source_id = funding_sources.id;
gretelai_synthetic_text_to_sql
CREATE TABLE portfolio_managers (manager_name VARCHAR(20), id INT); CREATE TABLE investments (manager_id INT, sector VARCHAR(20), ESG_rating FLOAT); INSERT INTO portfolio_managers (manager_name, id) VALUES ('Portfolio Manager 1', 1), ('Portfolio Manager 2', 2), ('Portfolio Manager 3', 3); INSERT INTO investments (manager_id, sector, ESG_rating) VALUES (1, 'renewable_energy', 8.1), (1, 'technology', 7.5), (1, 'finance', 6.8), (2, 'renewable_energy', 6.5), (2, 'technology', 9.0), (3, 'finance', 6.8), (3, 'renewable_energy', 9.2);
What's the number of distinct sectors that 'Portfolio Manager 1' has invested in and their respective ESG ratings?
SELECT investments.sector, AVG(investments.ESG_rating) FROM investments INNER JOIN portfolio_managers ON investments.manager_id = portfolio_managers.id WHERE portfolio_managers.manager_name = 'Portfolio Manager 1' GROUP BY investments.sector;
gretelai_synthetic_text_to_sql
CREATE TABLE military_expenditure (country VARCHAR(50), year INT, amount INT); INSERT INTO military_expenditure (country, year, amount) VALUES ('USA', 2020, 73200000000), ('China', 2020, 261000000000), ('India', 2020, 71400000000), ('USA', 2019, 71200000000), ('China', 2019, 258000000000);
What is the total military spending by each country in the last 5 years?
SELECT country, SUM(amount) FROM military_expenditure WHERE year BETWEEN 2017 AND 2021 GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE public_transportation (id INT, mode VARCHAR(255), usage INT, date DATE); INSERT INTO public_transportation (id, mode, usage, date) VALUES (1, 'bus', 1500, '2022-01-01'), (2, 'tube', 2000, '2022-01-01');
Which day of the week has the highest usage of public transportation in London?
SELECT TO_CHAR(date, 'Day') AS day_of_week, MAX(usage) AS max_usage FROM public_transportation WHERE city = 'London' GROUP BY day_of_week;
gretelai_synthetic_text_to_sql
CREATE TABLE attorneys (attorney_id INT, performance_rating VARCHAR(10)); INSERT INTO attorneys (attorney_id, performance_rating) VALUES (1, 'Excellent'), (2, 'Good'); CREATE TABLE cases (case_id INT, attorney_id INT); INSERT INTO cases (case_id, attorney_id) VALUES (1, 1), (2, 2);
How many cases were handled by attorneys with a 'Good' performance rating?
SELECT COUNT(*) FROM cases JOIN attorneys ON cases.attorney_id = attorneys.attorney_id WHERE attorneys.performance_rating = 'Good';
gretelai_synthetic_text_to_sql
CREATE TABLE water_usage_industrial(customer_id INT, usage FLOAT, month DATE); INSERT INTO water_usage_industrial(customer_id, usage, month) VALUES (3, 850, '2022-01-01'), (4, 780, '2022-02-01'), (5, 900, '2022-03-01');
What is the maximum water consumption by industrial customers in the first quarter of 2022?
SELECT MAX(usage) FROM water_usage_industrial WHERE month BETWEEN '2022-01-01' AND '2022-03-31';
gretelai_synthetic_text_to_sql
CREATE TABLE Claims (ClaimID int, ClaimDate date, ClaimAmount decimal(10, 2), PolicyType varchar(50)); INSERT INTO Claims (ClaimID, ClaimDate, ClaimAmount, PolicyType) VALUES (1, '2022-01-15', 4500.00, 'Auto'), (2, '2022-02-03', 3200.00, 'Home'), (3, '2022-03-17', 5700.00, 'Auto'), (4, '2022-04-01', 6100.00, 'Life'), (5, '2022-05-12', 4200.00, 'Auto'), (6, '2022-06-20', 3800.00, 'Home');
What is the maximum claim amount for each policy type in the last year?
SELECT PolicyType, MAX(ClaimAmount) OVER (PARTITION BY PolicyType) AS MaxClaimAmount FROM Claims WHERE ClaimDate >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR)
gretelai_synthetic_text_to_sql
CREATE TABLE students (id INT, program VARCHAR(50), mental_health_score INT); INSERT INTO students (id, program, mental_health_score) VALUES (1, 'Lifelong Learning', 65), (2, 'Lifelong Learning', 75), (3, 'Lifelong Learning', 85), (4, 'Traditional Program', 60), (5, 'Traditional Program', 80);
How many students in the lifelong learning program have a mental health score below 70?
SELECT COUNT(*) as num_students FROM students WHERE program = 'Lifelong Learning' AND mental_health_score < 70;
gretelai_synthetic_text_to_sql
CREATE TABLE content_creators (creator_id INT, creator_name VARCHAR(50), genre VARCHAR(50), post_count INT, engagement DECIMAL(10, 2)); INSERT INTO content_creators VALUES (104, 'Creator X', 'Gaming', 30, 2500), (105, 'Creator Y', 'Gaming', 45, 2000), (106, 'Creator Z', 'Sports', 60, 800), (107, 'Creator W', 'Gaming', 50, 3000), (108, 'Creator V', 'Gaming', 70, 1000);
Who are the top 5 content creators in terms of post engagement in the gaming genre?
SELECT creator_name, SUM(engagement) as total_engagement FROM content_creators WHERE genre = 'Gaming' GROUP BY creator_name ORDER BY total_engagement DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE green_buildings (building_id INT, state VARCHAR(50), certification_date DATE); INSERT INTO green_buildings (building_id, state, certification_date) VALUES (1, 'California', '2016-01-01');
Identify the number of green buildings in each state that have been certified since 2015.
SELECT state, COUNT(*) as certified_green_buildings FROM green_buildings WHERE certification_date >= '2015-01-01' GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE company_esg (company_id INT, company_name VARCHAR(255), esg_score INT, year INT, sector VARCHAR(255), region VARCHAR(255)); INSERT INTO company_esg (company_id, company_name, esg_score, year, sector, region) VALUES (1, 'AquaTech', 85, 2021, 'Water Management', 'Asia'), (2, 'ClearWater', 90, 2021, 'Water Management', 'Europe'), (3, 'H2O Solutions', 80, 2021, 'Water Management', 'Africa');
Which region had the highest average ESG score for water management in 2021?
SELECT region, AVG(esg_score) as avg_esg_score FROM company_esg WHERE year = 2021 AND sector = 'Water Management' GROUP BY region ORDER BY avg_esg_score DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Articles (article_id INT, title VARCHAR(255), author_gender VARCHAR(10), publication_date DATE); INSERT INTO Articles (article_id, title, author_gender, publication_date) VALUES (1, 'Article1', 'Male', '2022-01-01'), (2, 'Article2', 'Female', '2022-02-15'), (3, 'Article3', 'Male', '2022-03-01');
How many articles were published by male authors in the last week?
SELECT COUNT(*) FROM Articles WHERE author_gender = 'Male' AND publication_date >= DATE_SUB(CURDATE(), INTERVAL 1 WEEK);
gretelai_synthetic_text_to_sql
CREATE TABLE community_engagement (city VARCHAR(50), country VARCHAR(50), event VARCHAR(50), attendees INT);
Insert a new record into the community_engagement table with the following data: 'Seattle', 'USA', 'Cultural festival', 2000.
INSERT INTO community_engagement (city, country, event, attendees) VALUES ('Seattle', 'USA', 'Cultural festival', 2000);
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas (area_name VARCHAR(255), region VARCHAR(255), has_shark_conservation BOOLEAN); INSERT INTO marine_protected_areas (area_name, region, has_shark_conservation) VALUES ('Tubbataha Reefs Natural Park', 'Southeast Asia', TRUE), ('Gulf of Thailand Marine Park', 'Southeast Asia', FALSE);
List marine protected areas in Southeast Asia with shark conservation efforts.
SELECT area_name FROM marine_protected_areas WHERE region = 'Southeast Asia' AND has_shark_conservation = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE organization (org_id INT, name VARCHAR(255)); INSERT INTO organization (org_id, name) VALUES (1, 'CodeTutor'), (2, 'GreenPeace'), (3, 'WorldFoodProgram'); CREATE TABLE donation (don_id INT, donor_id INT, org_id INT, amount DECIMAL(10,2)); INSERT INTO donation (don_id, donor_id, org_id, amount) VALUES (1, 101, 1, 500.00), (2, 102, 1, 250.00), (3, 103, 2, 750.00), (4, 101, 3, 1000.00), (5, 104, 3, 1500.00);
Who are the donors that made a donation to 'WorldFoodProgram'?
SELECT d.donor_id, d.amount FROM donation d JOIN organization o ON d.org_id = o.org_id WHERE o.name = 'WorldFoodProgram';
gretelai_synthetic_text_to_sql
CREATE TABLE tourism (city VARCHAR(255), country VARCHAR(255), spending DECIMAL(10,2)); INSERT INTO tourism (city, country, spending) VALUES ('London', 'India', 800.00), ('London', 'India', 850.00);
What is the average spending of Indian tourists in London?
SELECT AVG(spending) FROM tourism WHERE city = 'London' AND country = 'India';
gretelai_synthetic_text_to_sql
CREATE TABLE community_health_workers (id INT PRIMARY KEY, state VARCHAR(20), worker_count INT); CREATE TABLE cultural_competency_training (id INT PRIMARY KEY, state VARCHAR(20), training_hours INT);
Which states have the most community health workers and the least cultural competency training hours?
SELECT c.state, c.worker_count, t.training_hours FROM community_health_workers c INNER JOIN cultural_competency_training t ON c.state = t.state ORDER BY c.worker_count DESC, t.training_hours ASC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE WildlifeSightings (id INT, species TEXT, year INT, location TEXT); INSERT INTO WildlifeSightings (id, species, year, location) VALUES (1, 'Polar Bear', 2020, 'Barrow'), (2, 'Polar Bear', 2020, 'Barrow'), (3, 'Walrus', 2019, 'Tromso'), (4, 'Walrus', 2019, 'Tromso'), (5, 'Narwhal', 2018, 'Pond Inlet');
Delete duplicate records of Arctic wildlife sightings
DELETE FROM WildlifeSightings WHERE id NOT IN (SELECT MIN(id) FROM WildlifeSightings GROUP BY species, year, location);
gretelai_synthetic_text_to_sql
CREATE TABLE creators (id INT, underrepresented BOOLEAN, hours_of_content FLOAT, country VARCHAR(20)); INSERT INTO creators (id, underrepresented, hours_of_content, country) VALUES (1, TRUE, 10.5, 'Germany'), (2, FALSE, 15.2, 'France'), (3, TRUE, 8.9, 'United States');
What is the total number of hours of content produced by creators in each country, for creators from underrepresented communities?
SELECT country, SUM(hours_of_content) AS total_hours FROM creators WHERE underrepresented = TRUE GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE player (player_id INT, name VARCHAR(50), age INT, game_genre VARCHAR(20)); INSERT INTO player (player_id, name, age, game_genre) VALUES (1, 'John Doe', 25, 'Racing'); INSERT INTO player (player_id, name, age, game_genre) VALUES (2, 'Jane Smith', 30, 'RPG');
How many players are there in the RPG genre?
SELECT COUNT(*) FROM player WHERE game_genre = 'RPG';
gretelai_synthetic_text_to_sql
CREATE TABLE claim_state (claim_id INT, claim_state VARCHAR(20)); CREATE TABLE claims (claim_id INT, claim_amount DECIMAL(10,2)); INSERT INTO claim_state VALUES (1, 'Texas'); INSERT INTO claims VALUES (1, 200.00);
What is the minimum claim amount by policyholder state?
SELECT claim_state, MIN(claim_amount) as min_claim_amount FROM claims JOIN claim_state ON claims.claim_id = claim_state.claim_id GROUP BY claim_state;
gretelai_synthetic_text_to_sql
CREATE TABLE project_sg (id INT PRIMARY KEY, project_name VARCHAR(255), location VARCHAR(255), technology VARCHAR(255)); INSERT INTO project_sg (id, project_name, location, technology) VALUES (1, 'Genome Mapping', 'Singapore', 'Genomics'); CREATE TABLE funding_sg (id INT PRIMARY KEY, project_id INT, fund_type VARCHAR(255), amount INT, funding_date DATE); INSERT INTO funding_sg (id, project_id, fund_type, amount, funding_date) VALUES (1, 1, 'Government Grant', 7000000, '2021-02-01');
Find genomic research projects in Singapore with funding over 5 million since 2020.
SELECT p.project_name FROM project_sg p JOIN funding_sg f ON p.id = f.project_id WHERE p.location = 'Singapore' AND p.technology = 'Genomics' AND f.funding_date >= '2020-01-01' AND f.amount > 5000000;
gretelai_synthetic_text_to_sql
CREATE TABLE workers (id INT, name TEXT, industry TEXT, training_status TEXT); INSERT INTO workers (id, name, industry, training_status) VALUES (1, 'John Doe', 'Automotive', 'Trained'), (2, 'Jane Smith', 'Automotive', 'Not Trained'), (3, 'Bob Johnson', 'Aerospace', 'Trained'); CREATE TABLE trainings (id INT, worker_id INT, training_type TEXT); INSERT INTO trainings (id, worker_id, training_type) VALUES (1, 1, 'Industry 4.0'), (2, 3, 'Industry 4.0');
How many workers in the automotive industry have been trained in Industry 4.0 technologies?
SELECT COUNT(*) FROM workers w JOIN trainings t ON w.id = t.worker_id WHERE w.industry = 'Automotive' AND t.training_type = 'Industry 4.0';
gretelai_synthetic_text_to_sql
CREATE TABLE Users (user_id INT, username VARCHAR(50), registration_date DATE, country VARCHAR(50)); INSERT INTO Users (user_id, username, registration_date, country) VALUES (1, 'UserA', '2022-01-01', 'Brazil'); INSERT INTO Users (user_id, username, registration_date, country) VALUES (2, 'UserB', '2022-01-02', 'USA');
How many users registered for a music streaming service from Brazil?
SELECT COUNT(*) FROM Users WHERE country = 'Brazil';
gretelai_synthetic_text_to_sql
SELECT * FROM win_percentage;
Show the win percentage by coach
SELECT * FROM win_percentage;
gretelai_synthetic_text_to_sql
CREATE TABLE autonomous_vehicles (id INT PRIMARY KEY, make VARCHAR(50), model VARCHAR(50), year INT, top_speed INT);
List the makes and models of autonomous vehicles with a top speed greater than 150 mph
SELECT make, model FROM autonomous_vehicles WHERE top_speed > 150;
gretelai_synthetic_text_to_sql
CREATE TABLE fabric_stock (id INT PRIMARY KEY, fabric VARCHAR(20), quantity INT);
Which sustainable material has the maximum stock quantity?
SELECT fabric, MAX(quantity) FROM fabric_stock WHERE fabric IN ('organic_cotton', 'hemp', 'Tencel') GROUP BY fabric;
gretelai_synthetic_text_to_sql
CREATE TABLE fares (payment_type VARCHAR(255), fare DECIMAL(5,2)); INSERT INTO fares (payment_type, fare) VALUES ('credit_card', 2.50), ('debit_card', 2.25), ('cash', 2.00), ('mobile_payment', 2.75);
What is the average fare for each payment type?
SELECT f.payment_type, AVG(f.fare) AS avg_fare FROM fares f GROUP BY f.payment_type;
gretelai_synthetic_text_to_sql
CREATE TABLE salinity (location VARCHAR(255), year INT, avg_salinity FLOAT);
Calculate the average salinity level in the Pacific and Atlantic oceans.
SELECT location, AVG(avg_salinity) FROM salinity WHERE location IN ('Pacific Ocean', 'Atlantic Ocean') GROUP BY location;
gretelai_synthetic_text_to_sql