context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE donors (id INT, name TEXT, country TEXT, donation FLOAT); INSERT INTO donors (id, name, country, donation) VALUES (1, 'John Doe', 'USA', 100.00), (2, 'Jane Smith', 'Canada', 150.00); CREATE TABLE refugee_donations (id INT, donor_id INT, refugee_id INT, donation FLOAT); INSERT INTO refugee_donations (id, do...
What is the average donation amount received by refugees from each country?
SELECT r.country, AVG(d.donation) as avg_donation FROM refugee_donations d JOIN donors dd ON d.donor_id = dd.id JOIN refugees r ON d.refugee_id = r.id GROUP BY r.country;
gretelai_synthetic_text_to_sql
CREATE TABLE customer_orders (order_id INT PRIMARY KEY, customer_id INT, total_cost DECIMAL(5,2), order_date TIMESTAMP, status VARCHAR(255));
Update customer orders with a total cost under $25 and order date over a year ago, setting the status to 'Inactive'
UPDATE customer_orders SET status = 'Inactive' WHERE total_cost < 25 AND order_date < NOW() - INTERVAL 1 YEAR;
gretelai_synthetic_text_to_sql
CREATE TABLE game_revenue (game_id INT, revenue INT); INSERT INTO game_revenue (game_id, revenue) VALUES (1, 500), (2, 1500), (3, 800);
Delete records in the "game_revenue" table where the "revenue" is less than 1000
DELETE FROM game_revenue WHERE revenue < 1000;
gretelai_synthetic_text_to_sql
CREATE TABLE energy_production (id INT, country VARCHAR(255), source VARCHAR(255), production FLOAT); INSERT INTO energy_production (id, country, source, production) VALUES (1, 'Germany', 'wind', 2500), (2, 'France', 'solar', 2300), (3, 'Germany', 'solar', 2450), (4, 'France', 'wind', 2700), (5, 'Germany', 'hydro', 300...
What is the average energy production per renewable energy source in each country?
SELECT country, source, AVG(production) as avg_production FROM energy_production GROUP BY country, source;
gretelai_synthetic_text_to_sql
CREATE TABLE students (id INT, name VARCHAR(30), program VARCHAR(30)); INSERT INTO students (id, name, program) VALUES (1, 'John Doe', 'Computer Science'), (2, 'Jane Smith', 'Physics');
List the names of all graduate students in the 'Computer Science' program
SELECT name FROM students WHERE program = 'Computer Science';
gretelai_synthetic_text_to_sql
CREATE TABLE Stablecoins (id INT, name VARCHAR(100), symbol VARCHAR(50), total_supply DECIMAL(20,2)); INSERT INTO Stablecoins (id, name, symbol, total_supply) VALUES (1, 'Tether', 'USDT', 80000000), (2, 'USD Coin', 'USDC', 50000000), (3, 'Binance USD', 'BUSD', 20000000), (4, 'TrueUSD', 'TUSD', 10000000), (5, 'Pax Dolla...
What is the total supply of the top 5 stablecoins on the Ethereum network?
SELECT SUM(total_supply) FROM Stablecoins WHERE symbol IN ('USDT', 'USDC', 'BUSD', 'TUSD', 'USDP');
gretelai_synthetic_text_to_sql
CREATE TABLE TrainingScores(EmployeeID INT, Department VARCHAR(255), TrainingType VARCHAR(255), Score INT);
What is the average diversity and inclusion training score for each department?
SELECT Department, AVG(CASE WHEN TrainingType = 'Diversity and Inclusion' THEN Score END) AS AverageScore FROM TrainingScores GROUP BY Department;
gretelai_synthetic_text_to_sql
CREATE TABLE Attorneys (AttorneyID INT, Name TEXT, Wins INT, Losses INT, HourlyRate DECIMAL); INSERT INTO Attorneys VALUES (1, 'Smith', 10, 0, 200), (2, 'Johnson', 5, 2, 180), (3, 'Williams', 15, 0, 220); CREATE TABLE Cases (CaseID INT, AttorneyID INT, Hours DECIMAL); INSERT INTO Cases VALUES (1, 1, 10), (2, 2, 8), (3,...
What is the total billing amount for cases handled by attorneys who have never lost a case?
SELECT SUM(c.Hours * a.HourlyRate) FROM Attorneys a INNER JOIN Cases c ON a.AttorneyID = c.AttorneyID WHERE a.Wins > a.Losses;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas (id INT, name VARCHAR(255), location VARCHAR(255), avg_depth FLOAT); INSERT INTO marine_protected_areas (id, name, location, avg_depth) VALUES (1, 'Galapagos', 'Pacific', -2);
What is the maximum and minimum depth of marine protected areas in the Pacific?
SELECT location, MIN(avg_depth) AS min_depth, MAX(avg_depth) AS max_depth FROM marine_protected_areas WHERE location = 'Pacific'
gretelai_synthetic_text_to_sql
CREATE TABLE regulatory_compliance (id INT PRIMARY KEY, report_date DATE, compliance_score INT);
Delete records in the regulatory_compliance table where the report_date is before '2021-01-01'
WITH cte1 AS (DELETE FROM regulatory_compliance WHERE report_date < '2021-01-01') SELECT * FROM cte1;
gretelai_synthetic_text_to_sql
CREATE TABLE artists (artist_id INT, name VARCHAR(50), age INT, country VARCHAR(50)); INSERT INTO artists (artist_id, name, age, country) VALUES (1, 'Yayoi Kusama', 93, 'Japan'); INSERT INTO artists (artist_id, name, age, country) VALUES (2, 'Takashi Murakami', 61, 'Japan');
What is the average age of artists in the 'artists' table from Japan?
SELECT AVG(age) FROM artists WHERE country = 'Japan';
gretelai_synthetic_text_to_sql
CREATE TABLE Projects (id INT, name VARCHAR(50), category VARCHAR(50), cost FLOAT, year_started INT, year_completed INT, status VARCHAR(20)); INSERT INTO Projects (id, name, category, cost, year_started, year_completed, status) VALUES (1, 'Dam Reconstruction', 'Water Supply', 500000, 2018, 2019, 'Completed'), (2, 'Wast...
Identify the top 3 most expensive 'Water Supply' projects that started in 2018 or later.
SELECT * FROM (SELECT *, RANK() OVER (PARTITION BY category ORDER BY cost DESC) rnk FROM Projects WHERE year_started >= 2018 AND category = 'Water Supply') t WHERE rnk <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE pandas (panda_id INT, panda_name VARCHAR(50), age INT, weight FLOAT, sanctuary VARCHAR(50)); INSERT INTO pandas (panda_id, panda_name, age, weight, sanctuary) VALUES (1, 'Panda_1', 12, 100, 'Chinese Forest'); INSERT INTO pandas (panda_id, panda_name, age, weight, sanctuary) VALUES (2, 'Panda_2', 8, 90, 'Ch...
Update the weight of all adult pandas in the 'Chinese Forest' sanctuary.
UPDATE pandas SET weight = weight * 1.1 WHERE sanctuary = 'Chinese Forest' AND age >= 18;
gretelai_synthetic_text_to_sql
CREATE TABLE PlayerTournaments (PlayerID INT, TournamentID INT, Wins INT); INSERT INTO PlayerTournaments (PlayerID, TournamentID, Wins) VALUES (1, 1, 3), (2, 2, 5), (3, 1, 4), (4, 3, 6), (5, 2, 7), (6, 1, 8), (7, 4, 9), (8, 3, 10), (9, 2, 11), (10, 5, 12); CREATE TABLE PlayerInfo (PlayerID INT, Country VARCHAR(50)); ...
What is the maximum number of wins in eSports tournaments by a player from North America?
SELECT MAX(Wins) as MaxWins FROM PlayerTournaments INNER JOIN PlayerInfo ON PlayerTournaments.PlayerID = PlayerInfo.PlayerID WHERE Country LIKE 'North%';
gretelai_synthetic_text_to_sql
CREATE TABLE libraries (state VARCHAR(20), city VARCHAR(20), library_name VARCHAR(30), type VARCHAR(20)); INSERT INTO libraries VALUES ('New York', 'New York City', 'New York Public Library', 'Public'), ('New York', 'Albany', 'Albany Public Library', 'Public');
How many public libraries are there in New York state?
SELECT COUNT(*) FROM libraries WHERE state = 'New York' AND type = 'Public';
gretelai_synthetic_text_to_sql
CREATE TABLE claims (claim_id INT PRIMARY KEY, policyholder_id INT, claim_amount DECIMAL(10, 2), claim_date DATE);
Insert sample data into 'claims' table
INSERT INTO claims (claim_id, policyholder_id, claim_amount, claim_date) VALUES (1, 1, 500, '2022-01-01'), (2, 2, 300, '2022-02-15'), (3, 3, 700, '2022-03-05');
gretelai_synthetic_text_to_sql
CREATE TABLE marine_life_depth (name VARCHAR(255), depth FLOAT); INSERT INTO marine_life_depth (name, depth) VALUES ('Giant Squid', 3000.0), ('Anglerfish', 2000.0);
What is the maximum depth at which marine life is found?
SELECT MAX(depth) FROM marine_life_depth;
gretelai_synthetic_text_to_sql
CREATE TABLE inventory (inventory_id INT, item VARCHAR(50), quantity INT); INSERT INTO inventory (inventory_id, item, quantity) VALUES (1, 'Beef', 100), (2, 'Pork', 75);
Delete all records from the inventory table where the quantity is less than 50
DELETE FROM inventory WHERE quantity < 50;
gretelai_synthetic_text_to_sql
CREATE TABLE menu_items (menu_id INT, name VARCHAR(50), region VARCHAR(50), price FLOAT, cost FLOAT);
Identify the top 5 menu items with the highest profit margin in each region.
SELECT menu_id, name, region, price - cost as profit_margin FROM menu_items WHERE region IN (SELECT region FROM (SELECT region, RANK() OVER (PARTITION BY region ORDER BY price - cost DESC) as rank FROM menu_items) x WHERE rank <= 5) ORDER BY region, profit_margin DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE production (element VARCHAR(10), year INT, quantity INT); INSERT INTO production VALUES ('Neodymium', 2015, 1200), ('Praseodymium', 2015, 1500), ('Dysprosium', 2015, 800), ('Neodymium', 2016, 1300), ('Praseodymium', 2016, 1600), ('Dysprosium', 2016, 900), ('Neodymium', 2017, 1400), ('Praseodymium', 2017, 1...
What is the total production quantity of all rare earth elements in 2017?
SELECT SUM(quantity) FROM production WHERE year = 2017;
gretelai_synthetic_text_to_sql
CREATE TABLE claims (id INT, policy_number INT, claim_amount INT, issue_date DATE); INSERT INTO claims VALUES (1, 1234, 5000, '2021-01-01'); INSERT INTO claims VALUES (2, 5678, 7000, '2021-02-01'); INSERT INTO claims VALUES (3, 9012, 9000, '2021-03-01'); INSERT INTO claims VALUES (4, 3456, 6000, '2020-01-01');
What is the maximum claim amount for policies issued in '2021'?
SELECT MAX(claim_amount) FROM claims WHERE EXTRACT(YEAR FROM issue_date) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE Disability_Support_Programs (Location VARCHAR(20), Program VARCHAR(50), Type VARCHAR(20)); INSERT INTO Disability_Support_Programs VALUES ('Campus A', 'Assistive Technology', 'Resource Center'), ('Campus A', 'ASL Interpretation', 'Service'), ('Campus A', 'Mobility Support', 'Service'), ('Campus B', 'Assist...
What is the number of disability support programs offered, partitioned by location and ordered from highest to lowest?
SELECT Location, COUNT(*) as Number_of_Programs, RANK() OVER (ORDER BY COUNT(*) DESC) as Rank FROM Disability_Support_Programs GROUP BY Location ORDER BY Rank;
gretelai_synthetic_text_to_sql
CREATE TABLE intelligence_operations (id INT, operation TEXT, region TEXT); INSERT INTO intelligence_operations (id, operation, region) VALUES (1, 'Op1', 'americas'), (2, 'Op2', 'americas'), (3, 'Op3', 'asia'), (4, 'Op4', 'asia'), (5, 'Op5', 'africa'), (6, 'Op6', 'africa');
What are the unique regions in the intelligence_operations table?
SELECT DISTINCT region FROM intelligence_operations;
gretelai_synthetic_text_to_sql
CREATE TABLE shared_bicycles (bicycle_id INT, city VARCHAR(20)); INSERT INTO shared_bicycles (bicycle_id, city) VALUES (1, 'Sydney'), (2, 'Sydney'), (3, 'Melbourne'), (4, 'Melbourne');
How many shared bicycles are there in Sydney?
SELECT city, COUNT(*) FROM shared_bicycles WHERE city = 'Sydney' GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE MilitaryPersonnel (id INT PRIMARY KEY, country VARCHAR(50), branch VARCHAR(50), number_of_personnel INT); INSERT INTO MilitaryPersonnel (id, country, branch, number_of_personnel) VALUES (1, 'USA', 'Army', 450000), (2, 'Canada', 'Navy', 32000), (3, 'France', 'Air Force', 200000);
What is the average number of military personnel in each branch of the military for NATO countries?
SELECT branch, AVG(number_of_personnel) as avg_personnel FROM MilitaryPersonnel WHERE country IN ('USA', 'Canada', 'France') GROUP BY branch;
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (transaction_id INT, customer_id INT, region VARCHAR(20), transaction_amount DECIMAL(10,2)); INSERT INTO transactions (transaction_id, customer_id, region, transaction_amount) VALUES (1, 1, 'West Coast', 500.00), (2, 1, 'East Coast', 700.00), (3, 2, 'West Coast', 800.00), (4, 3, 'North East', ...
What is the minimum transaction amount in the East coast region?
SELECT MIN(transaction_amount) FROM transactions WHERE region = 'East Coast';
gretelai_synthetic_text_to_sql
CREATE TABLE plans (id INT, name VARCHAR(255), type VARCHAR(255), price DECIMAL(10,2));
What is the total revenue for each mobile plan in the "plans" table?
SELECT type, SUM(price) FROM plans GROUP BY type;
gretelai_synthetic_text_to_sql
CREATE TABLE Programs (program_id INT, program_name VARCHAR(50), start_date DATE); CREATE TABLE Attendance (attendance_id INT, program_id INT, attendee_count INT); INSERT INTO Programs (program_id, program_name, start_date) VALUES (8, 'Sculpture Class', '2022-01-01'), (9, 'Writing Workshop', '2022-04-01'); INSERT INTO ...
Which programs had the highest attendance in the last three months?
SELECT p.program_name, a.attendee_count FROM Programs p JOIN Attendance a ON p.program_id = a.program_id WHERE p.start_date >= '2022-01-01' GROUP BY p.program_name, a.attendee_count ORDER BY a.attendee_count DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE ResearchVessels (id INT, name VARCHAR(50), species VARCHAR(50), population INT); INSERT INTO ResearchVessels (id, name, species, population) VALUES (1, 'Okeanos Explorer', 'Dolphin', 1200), (2, 'Nautilus', 'Shark', 800); CREATE TABLE MarineLife (id INT, name VARCHAR(50), species VARCHAR(50), population INT...
What are the names of all marine species with a population over 1000 in the 'ResearchVessels' and 'MarineLife' tables?
SELECT R.species FROM ResearchVessels R WHERE R.population > 1000 INTERSECT SELECT M.species FROM MarineLife M WHERE M.population > 1000;
gretelai_synthetic_text_to_sql
CREATE TABLE Concerts (id INT, city VARCHAR(255), genre VARCHAR(255), revenue DECIMAL(10,2));
Identify the top 5 cities with the highest total revenue from concert ticket sales for artists from the Jazz genre, and the total revenue generated in each of those cities.
SELECT city, SUM(revenue) as total_revenue FROM Concerts WHERE genre = 'Jazz' GROUP BY city ORDER BY total_revenue DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE green_buildings (id INT, name VARCHAR(50), city VARCHAR(50), country VARCHAR(50), certification_date DATE, certified_sustainable BOOLEAN);CREATE VIEW green_buildings_percentage AS SELECT city, COUNT(*) * 100.0 / SUM(COUNT(*)) OVER (PARTITION BY NULL) AS green_buildings_percentage FROM green_buildings WHERE...
Find the percentage of green buildings in each city, using a SQL query with a window function.
SELECT city, green_buildings_percentage FROM green_buildings_percentage;
gretelai_synthetic_text_to_sql
CREATE TABLE country_donations (donor_id INT, donation_amount FLOAT, donation_date DATE, country VARCHAR(50)); INSERT INTO country_donations (donor_id, donation_amount, donation_date, country) VALUES (1, 500, '2020-01-01', 'USA'), (2, 300, '2020-01-02', 'Mexico');
What is the average donation amount per donor from 'country_donations' table for the year 2020?
SELECT AVG(donation_amount) FROM country_donations WHERE EXTRACT(YEAR FROM donation_date) = 2020 GROUP BY donor_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Suppliers (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255)); INSERT INTO Suppliers (id, name, location) VALUES (1, 'Supplier A', 'Colorado'), (2, 'Supplier B', 'New York'), (3, 'Supplier C', 'Texas');
List all suppliers from 'Colorado' in the 'Suppliers' table
SELECT name FROM Suppliers WHERE location = 'Colorado';
gretelai_synthetic_text_to_sql
CREATE TABLE AIModels (model_id INT, model_name VARCHAR(50), fairness_score DECIMAL(3,2)); INSERT INTO AIModels (model_id, model_name, fairness_score) VALUES (1, 'ModelA', 87.00), (2, 'ModelB', 92.50), (3, 'ModelC', 75.25), (4, 'ModelD', 93.00);
Show AI models with fairness scores above 90.
SELECT model_name, fairness_score FROM AIModels WHERE fairness_score > 90;
gretelai_synthetic_text_to_sql
CREATE TABLE MentalHealthScores (Patient_ID INT, Region VARCHAR(50), Parity_Score INT); INSERT INTO MentalHealthScores (Patient_ID, Region, Parity_Score) VALUES (1, 'North', 80), (2, 'North', 85), (3, 'South', 70), (4, 'South', 75), (5, 'East', 90), (6, 'East', 95), (7, 'West', 60), (8, 'West', 65);
What is the total mental health parity score for patients in each region?
SELECT m.Region, SUM(m.Parity_Score) as Total_Score FROM MentalHealthScores m GROUP BY m.Region;
gretelai_synthetic_text_to_sql
CREATE TABLE user_activity (user_id INT, activity_date DATE); INSERT INTO user_activity (user_id, activity_date) VALUES (1, '2021-01-01'), (2, '2021-01-02'), (3, '2021-01-03'), (4, '2021-02-04'), (5, '2021-02-05'), (6, '2021-03-06');
What is the number of active users in the 'gaming' database for each month in the year 2021?
SELECT EXTRACT(MONTH FROM activity_date) as month, COUNT(DISTINCT user_id) as active_users FROM user_activity GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE ai_projects_detailed (project_id INT, project_name VARCHAR(20), project_domain VARCHAR(30), funding FLOAT, project_location VARCHAR(20)); INSERT INTO ai_projects_detailed VALUES (1, 'AI for Bridging Digital Divide', 'digital divide', 500000, 'Global South'), (2, 'AI for Health', 'healthcare', 200000, 'Glob...
What is the total number of AI projects addressing digital divide?
SELECT COUNT(*) FROM ai_projects_detailed WHERE project_domain = 'digital divide';
gretelai_synthetic_text_to_sql
CREATE TABLE theatre (play VARCHAR(255), date DATE, revenue FLOAT); INSERT INTO theatre (play, date, revenue) VALUES ('Romeo and Juliet', '2020-01-01', 1500), ('Romeo and Juliet', '2020-01-02', 2000), ('Macbeth', '2020-01-01', 1200);
What was the total revenue from ticket sales for the play "Romeo and Juliet" in the year 2020?
SELECT SUM(revenue) FROM theatre WHERE play = 'Romeo and Juliet' AND YEAR(date) = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE Cities (id INT, city VARCHAR(50)); INSERT INTO Cities (id, city) VALUES (1, 'New York'), (2, 'Los Angeles'), (3, 'Chicago'); CREATE TABLE Donors (id INT, city INT, donation_id INT); INSERT INTO Donors (id, city, donation_id) VALUES (1, 1, 1001), (2, 2, 1002), (3, 3, 1003); CREATE TABLE Donations (id INT, d...
What is the total amount donated per city?
SELECT c.city, SUM(d.amount) as total_amount FROM Donors g JOIN Donations d ON g.id = d.donor_id JOIN Cities c ON g.city = c.id GROUP BY c.city;
gretelai_synthetic_text_to_sql
CREATE TABLE SafetyTests (Id INT, TestType VARCHAR(50), VehicleId INT, TestDate DATE, SafetyRating FLOAT); INSERT INTO SafetyTests (Id, TestType, VehicleId, TestDate, SafetyRating) VALUES (1, 'Lane Keeping', 1, '2020-01-10', 5.1); INSERT INTO SafetyTests (Id, TestType, VehicleId, TestDate, SafetyRating) VALUES (2, 'Eme...
List all vehicles that have been in at least 3 safety tests and their average safety rating.
SELECT VehicleId, AVG(SafetyRating) FROM SafetyTests GROUP BY VehicleId HAVING COUNT(*) >= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE asian_autonomous_vehicles (vehicle_id INT, city VARCHAR(20), country VARCHAR(20)); INSERT INTO asian_autonomous_vehicles (vehicle_id, city, country) VALUES (1, 'Singapore', 'Singapore'), (2, 'Singapore', 'Singapore'), (3, 'Jakarta', 'Indonesia'), (4, 'Jakarta', 'Indonesia');
What is the total number of autonomous vehicles in Singapore and Jakarta?
SELECT COUNT(*) FROM asian_autonomous_vehicles WHERE city IN ('Singapore', 'Jakarta') AND country IN ('Singapore', 'Indonesia');
gretelai_synthetic_text_to_sql
CREATE TABLE threat_actors (threat_actor_id INT, threat_actor_name VARCHAR(255));CREATE TABLE targeted_systems (system_id INT, system_name VARCHAR(255), sector VARCHAR(255), threat_actor_id INT);CREATE TABLE cve_scores (system_id INT, score INT, scan_date DATE);CREATE TABLE scan_dates (scan_date DATE, system_id INT);
What are the number of unique threat actors that have targeted systems with a CVE score greater than 7 in the last year, and their names?
SELECT COUNT(DISTINCT ta.threat_actor_id) as num_actors, STRING_AGG(ta.threat_actor_name, ', ') as actor_names FROM threat_actors ta INNER JOIN targeted_systems ts ON ta.threat_actor_id = ts.threat_actor_id INNER JOIN cve_scores c ON ts.system_id = c.system_id INNER JOIN scan_dates sd ON ts.system_id = sd.system_id WHE...
gretelai_synthetic_text_to_sql
CREATE TABLE RenewableProjects (ProjectID INT, ProjectName VARCHAR(255), Country VARCHAR(255), Capacity FLOAT); INSERT INTO RenewableProjects (ProjectID, ProjectName, Country, Capacity) VALUES (1, 'SolarFarm1', 'USA', 5000), (2, 'WindFarm2', 'Germany', 7000), (3, 'HydroPlant3', 'Brazil', 6000), (4, 'GeoThermal4', 'Chin...
What is the total installed capacity of renewable energy projects for the top 5 countries?
SELECT Country, SUM(Capacity) AS Total_Capacity FROM RenewableProjects GROUP BY Country ORDER BY Total_Capacity DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE social_good_tech (tech_name VARCHAR(50), accessibility_feature VARCHAR(50)); INSERT INTO social_good_tech VALUES ('TechA', 'Screen Reader'), ('TechA', 'Closed Captions'), ('TechB', 'Voice Command'), ('TechC', 'Keyboard Navigation');
What are the unique accessibility features available in social_good_tech table?
SELECT DISTINCT accessibility_feature FROM social_good_tech;
gretelai_synthetic_text_to_sql
CREATE TABLE vulnerabilities (id INT, name VARCHAR, description TEXT, cvss_score FLOAT); INSERT INTO vulnerabilities (id, name, description, cvss_score) VALUES (1, 'Heartbleed', 'Serious vulnerability in OpenSSL', 7.4);
Update the cvss_score of the 'Heartbleed' vulnerability to 10.0 in the 'vulnerabilities' table
UPDATE vulnerabilities SET cvss_score=10.0 WHERE name='Heartbleed';
gretelai_synthetic_text_to_sql
CREATE TABLE Programs (ProgramID INT, Category TEXT, Name TEXT); CREATE TABLE Volunteers (VolunteerID INT, ProgramID INT, Hours INT); INSERT INTO Programs VALUES (1, 'Education', 'Tutoring'), (2, 'Environment', 'Clean-up'); INSERT INTO Volunteers VALUES (1, 1, 20), (2, 1, 30), (3, 2, 10);
How many volunteers engaged in each program category in 2019?
SELECT p.Category, COUNT(v.VolunteerID) FROM Programs p INNER JOIN Volunteers v ON p.ProgramID = v.ProgramID WHERE YEAR(v.VolunteerDate) = 2019 GROUP BY p.Category;
gretelai_synthetic_text_to_sql
CREATE SCHEMA art; CREATE TABLE art_pieces (art_id INT, art_name VARCHAR(255), artist_name VARCHAR(255), artist_gender VARCHAR(10), medium VARCHAR(50), creation_date DATE); INSERT INTO art.art_pieces (art_id, art_name, artist_name, artist_gender, medium, creation_date) VALUES (1, 'Painting', 'Sarah Johnson', 'Female', ...
What is the total number of art pieces created by each artist?
SELECT artist_name, COUNT(*) as count FROM art.art_pieces GROUP BY artist_name;
gretelai_synthetic_text_to_sql
CREATE TABLE chemical_reactions (reaction_id INT, chemical_name TEXT, reaction_time FLOAT); INSERT INTO chemical_reactions (reaction_id, chemical_name, reaction_time) VALUES (1, 'Hydrogenation', 34.5), (2, 'Nitration', 21.7), (3, 'Sulfonation', 45.9);
What is the average reaction time for each chemical reaction, ordered from longest to shortest?
SELECT AVG(reaction_time) AS avg_reaction_time, chemical_name FROM chemical_reactions GROUP BY chemical_name ORDER BY avg_reaction_time DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE donors(id INT, name TEXT, total_donation FLOAT);CREATE TABLE donations(id INT, donor_id INT, amount FLOAT, donation_date DATE);
Identify the top 5 donors by total donation amount in the last 12 months, and their respective donation amounts.
SELECT donors.name, SUM(donations.amount) as total_donations FROM donors JOIN donations ON donations.donor_id = donors.id WHERE donations.donation_date BETWEEN DATE_SUB(CURDATE(), INTERVAL 12 MONTH) AND CURDATE() GROUP BY donors.id ORDER BY total_donations DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (id INT PRIMARY KEY, name VARCHAR(255), conservation_status VARCHAR(255)); INSERT INTO marine_species (id, name, conservation_status) VALUES (1, 'Leatherback Sea Turtle', 'Vulnerable'); CREATE TABLE oceanography (id INT PRIMARY KEY, species_id INT, sea_surface_temperature INT); INSERT INTO o...
What is the sea surface temperature of the species with the lowest conservation status?
SELECT o.sea_surface_temperature FROM oceanography o JOIN marine_species m ON o.species_id = m.id WHERE m.conservation_status = (SELECT MIN(conservation_status) FROM marine_species);
gretelai_synthetic_text_to_sql
CREATE TABLE north_atlantic_species (species TEXT, biomass INT); INSERT INTO north_atlantic_species (species, biomass) VALUES ('Blue Whale', 3000), ('Sperm Whale', 2000), ('Giant Squid', 1500), ('Tuna', 500);
What is the maximum biomass of any species in the North Atlantic Ocean?
SELECT MAX(biomass) FROM north_atlantic_species;
gretelai_synthetic_text_to_sql
CREATE TABLE attractions (id INT PRIMARY KEY, name VARCHAR(255), type VARCHAR(255), num_reviews INT);
Which cultural heritage sites have more than 1000 reviews?
SELECT name, type FROM attractions WHERE num_reviews > 1000 GROUP BY name, type HAVING COUNT(*) > 1;
gretelai_synthetic_text_to_sql
CREATE TABLE model_details (model_id INT, explainability_score FLOAT, ai_application_area VARCHAR(50));
Find the top 3 models with the highest explainability score in the creative AI application area.
SELECT model_id, explainability_score FROM (SELECT model_id, explainability_score, ai_application_area, ROW_NUMBER() OVER (PARTITION BY ai_application_area ORDER BY explainability_score DESC) rn FROM model_details) md WHERE md.ai_application_area = 'creative AI' AND rn <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE eco_hotels (hotel_id INT, name TEXT, city TEXT); INSERT INTO eco_hotels (hotel_id, name, city) VALUES (1, 'Eco Hotel London', 'London'), (2, 'Green Haven London', 'London'), (3, 'Eco Lodge London', 'London'), (4, 'Eco Hotel Paris', 'Paris'), (5, 'Green Haven Paris', 'Paris'), (6, 'Eco Lodge Paris', 'Paris'...
What is the total number of eco-friendly hotels in London and Paris combined?
SELECT COUNT(*) FROM eco_hotels WHERE city IN ('London', 'Paris');
gretelai_synthetic_text_to_sql
CREATE TABLE threat_intel_vulnerabilities (id INT, source TEXT, vulnerability_id INT, date_reported DATE); INSERT INTO threat_intel_vulnerabilities (id, source, vulnerability_id, date_reported) VALUES (1, 'Malware Exchange', 1, '2022-02-03'); INSERT INTO threat_intel_vulnerabilities (id, source, vulnerability_id, date_...
What are the top 5 threat intelligence sources with the most vulnerabilities reported in 2022?
SELECT source, COUNT(*) as count FROM threat_intel_vulnerabilities WHERE date_reported >= '2022-01-01' GROUP BY source ORDER BY count DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, Age INT, Platform VARCHAR(10)); INSERT INTO Players (PlayerID, Age, Platform) VALUES (1, 25, 'PC'), (2, 30, 'Console'), (3, 22, 'PC'), (4, 19, 'VR'), (5, 35, 'Console');
What is the minimum age of players who play games on each platform?
SELECT Platform, MIN(Age) FROM Players GROUP BY Platform;
gretelai_synthetic_text_to_sql
CREATE TABLE network_devices (id INT, region VARCHAR(20), install_date DATE); CREATE TABLE mobile_subscribers (id INT, region VARCHAR(20), data_usage INT, usage_date DATE);
What is the total number of network devices installed in each region and the total number of mobile subscribers in those regions?
SELECT n.region, COUNT(n.id) AS num_devices, COUNT(m.id) AS num_subscribers FROM network_devices n INNER JOIN mobile_subscribers m ON n.region = m.region GROUP BY n.region;
gretelai_synthetic_text_to_sql
CREATE TABLE national_parks (park_id INT, name TEXT, country TEXT, has_virtual_tour BOOLEAN); INSERT INTO national_parks (park_id, name, country, has_virtual_tour) VALUES (1, 'Banff National Park', 'Canada', true), (2, 'Jasper National Park', 'Canada', true), (3, 'Waterton Lakes National Park', 'Canada', false);
Which national parks in Canada offer virtual tours?
SELECT name FROM national_parks WHERE country = 'Canada' AND has_virtual_tour = true;
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name VARCHAR(255), sector VARCHAR(255), ESG_score FLOAT); INSERT INTO companies (id, name, sector, ESG_score) VALUES (1, 'Vestas Wind Systems', 'Renewable Energy', 92.1), (2, 'Siemens Gamesa Renewable Energy', 'Renewable Energy', 89.5), (3, 'Tesla', 'Automotive', 78.3);
What is the maximum ESG score for companies in the renewable energy sector?
SELECT MAX(ESG_score) FROM companies WHERE sector = 'Renewable Energy';
gretelai_synthetic_text_to_sql
CREATE TABLE cosmetic_ingredients (ingredient_id INT, ingredient_name TEXT, brand_name TEXT, ingredient_type TEXT);
Update the ingredient type of 'Palm Oil' to 'Unsustainable' in the 'cosmetic_ingredients' table.
UPDATE cosmetic_ingredients SET ingredient_type = 'Unsustainable' WHERE ingredient_name = 'Palm Oil';
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, name VARCHAR(50), risk_level VARCHAR(10)); INSERT INTO customers VALUES (1, 'John Doe', 'medium'); INSERT INTO customers VALUES (2, 'Jane Smith', 'high'); CREATE TABLE transactions (transaction_id INT, customer_id INT, amount DECIMAL(10, 2), transaction_date DATE); INSERT INTO t...
How many high-risk customers have had transactions exceeding $1000 in the past week?
SELECT COUNT(c.customer_id) AS high_risk_customers FROM customers c INNER JOIN transactions t ON c.customer_id = t.customer_id WHERE c.risk_level = 'high' AND t.amount > 1000 AND t.transaction_date >= DATE_SUB(CURDATE(), INTERVAL 1 WEEK);
gretelai_synthetic_text_to_sql
CREATE TABLE vulnerabilities (id integer, threat text, exploited integer, timestamp timestamp); INSERT INTO vulnerabilities (id, threat, exploited, timestamp) VALUES (1, 'APT29', 1, '2022-01-01 10:00:00'), (2, 'APT35', 0, '2022-01-02 11:00:00'), (3, 'APT29', 1, '2022-01-03 12:00:00'), (4, 'APT35', 0, '2022-01-04 13:00:...
What is the percentage of vulnerabilities that were successfully exploited in the last quarter by threat actor 'APT29'?
SELECT 100.0 * SUM(CASE WHEN threat = 'APT29' AND exploited = 1 THEN 1 ELSE 0 END) / COUNT(*) as exploited_percentage FROM vulnerabilities WHERE timestamp >= DATEADD(quarter, -1, CURRENT_TIMESTAMP);
gretelai_synthetic_text_to_sql
CREATE TABLE CulturalEvents (EventID INT, Country TEXT, Attendance INT); INSERT INTO CulturalEvents (EventID, Country, Attendance) VALUES (1, 'France', 500), (2, 'Mexico', 300), (3, 'Netherlands', 700), (4, 'USA', 600), (5, 'France', 600), (6, 'Mexico', 400), (7, 'Netherlands', 800), (8, 'USA', 700);
What is the average attendance at cultural events in each country?
SELECT Country, AVG(Attendance) as AvgAttendance FROM CulturalEvents GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE student_budget (student_id INT, student_school TEXT, student_state TEXT, student_count INT, school_budget FLOAT); INSERT INTO student_budget (student_id, student_school, student_state, student_count, school_budget) VALUES (1, 'Edison', 'Illinois', 500, 2500000), (2, 'Franklin', 'Illinois', 750, 3750000), (...
What is the average amount of budget allocated per student in public schools in the state of Illinois?
SELECT AVG(school_budget / student_count) FROM student_budget WHERE student_state = 'Illinois';
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_towers (tower_id INT, location VARCHAR(50), compliance_date DATE);
List all mobile towers that are not compliant with the latest environmental regulations.
SELECT tower_id, location FROM mobile_towers WHERE compliance_date IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE ad_impressions (id INT, country VARCHAR(255), ad_format VARCHAR(255), timestamp TIMESTAMP); INSERT INTO ad_impressions (id, country, ad_format, timestamp) VALUES (1, 'Egypt', 'Story', '2022-07-15 12:00:00'), (2, 'Egypt', 'Image', '2022-07-16 14:30:00');
Identify the number of ad impressions in Egypt for the 'Story' ad format in the last month.
SELECT COUNT(*) FROM ad_impressions WHERE country = 'Egypt' AND ad_format = 'Story' AND timestamp >= DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 1 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE departments (department VARCHAR(50), num_publications INT); INSERT INTO departments VALUES ('Computer Science', 30), ('Mathematics', 25), ('Physics', 35);
How many graduate students have published in each department?
SELECT d.department, COUNT(gs.student_id) FROM departments d JOIN graduate_students gs ON d.department = gs.department GROUP BY d.department;
gretelai_synthetic_text_to_sql
CREATE TABLE Household_Water_Usage (ID INT, Household VARCHAR(20), Year INT, Month INT, Usage FLOAT);
What is the change in monthly water usage for each household in Austin from 2020 to 2021?
SELECT h20_21.Household, AVG(h20_21.Usage - h20_20.Usage) as Avg_Change FROM Household_Water_Usage h20_21, Household_Water_Usage h20_20 WHERE h20_21.Household = h20_20.Household AND h20_20.Year = 2020 AND h20_21.Year = 2021 GROUP BY h20_21.Household;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists expenses (id INT PRIMARY KEY, sector VARCHAR(255), expense_date DATE, amount DECIMAL(10, 2)); INSERT INTO expenses (id, sector, expense_date, amount) VALUES (1, 'retail', '2022-01-15', 2000.00), (2, 'retail', '2022-03-01', 3000.00), (3, 'manufacturing', '2022-04-20', 1500.00);
What is the total amount spent on labor rights advocacy for the 'retail' sector in the last 6 months?
SELECT SUM(amount) FROM expenses WHERE sector = 'retail' AND expense_date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE temperatures (id INT, depth FLOAT, temperature FLOAT); INSERT INTO temperatures (id, depth, temperature) VALUES (1, 100.0, 5.0), (2, 3000.0, 2.0), (3, 6000.0, 0.5); CREATE VIEW ocean_floor_temperatures AS SELECT temperature FROM temperatures WHERE depth = (SELECT MAX(depth) FROM temperatures);
What is the average temperature at the ocean floor?
SELECT AVG(temperature) FROM ocean_floor_temperatures;
gretelai_synthetic_text_to_sql
CREATE TABLE factories (factory_id INT, location VARCHAR(50), capacity INT); INSERT INTO factories (factory_id, location, capacity) VALUES (1, 'Madrid, Spain', 5000), (2, 'Paris, France', 7000), (3, 'London, UK', 6000);
How many factories are located in Spain?
SELECT COUNT(*) FROM factories WHERE location LIKE '%Spain%';
gretelai_synthetic_text_to_sql
CREATE TABLE disaster_response.households (id INT, head_name VARCHAR(50), head_gender VARCHAR(10), region VARCHAR(50));
How many female-led households are in the 'disaster_response' schema?
SELECT COUNT(*) FROM disaster_response.households WHERE head_gender = 'female';
gretelai_synthetic_text_to_sql
CREATE TABLE sales_by_country (country VARCHAR(255), revenue FLOAT); INSERT INTO sales_by_country (country, revenue) VALUES ('USA', 15000), ('Canada', 12000), ('Mexico', 11000), ('Brazil', 9000), ('Argentina', 7000);
Find the top 3 countries with the highest total sales in the year 2021?
SELECT country, SUM(revenue) FROM sales_by_country WHERE revenue IS NOT NULL AND country IS NOT NULL GROUP BY country ORDER BY SUM(revenue) DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Applicants (ApplicantID INT, Gender VARCHAR(10), Position VARCHAR(20)); INSERT INTO Applicants (ApplicantID, Gender, Position) VALUES (1, 'Female', 'Marketing'), (2, 'Male', 'Marketing'), (3, 'Female', 'IT'), (4, 'Non-binary', 'HR');
What is the number of female and non-binary applicants for the marketing position?
SELECT Gender, COUNT(*) FROM Applicants WHERE Position = 'Marketing' GROUP BY Gender;
gretelai_synthetic_text_to_sql
CREATE TABLE drugs (id INT, name VARCHAR(255), class VARCHAR(255)); CREATE TABLE approvals (id INT, drug_id INT, time INT);
What is the average approval time for a specific drug class?
SELECT AVG(approvals.time) FROM approvals JOIN drugs ON approvals.drug_id = drugs.id WHERE drugs.class = 'Antidepressants';
gretelai_synthetic_text_to_sql
CREATE TABLE Members (MemberID INT, MembershipType VARCHAR(20)); INSERT INTO Members (MemberID, MembershipType) VALUES (1, 'Silver'), (2, 'Platinum'), (3, 'Silver'), (4, 'Gold');
How many members have the 'Silver' membership?
SELECT COUNT(*) FROM Members WHERE MembershipType = 'Silver';
gretelai_synthetic_text_to_sql
CREATE TABLE mutual_funds (fund_id INT, fund_name VARCHAR(50), agency_1_rating DECIMAL(3,1), agency_2_rating DECIMAL(3,1), agency_3_rating DECIMAL(3,1)); INSERT INTO mutual_funds (fund_id, fund_name, agency_1_rating, agency_2_rating, agency_3_rating) VALUES (1, 'Fund A', 4.5, 4.2, 4.0), (2, 'Fund B', 3.8, 3.9, 3.6), (3...
Show the names of all mutual funds that have been rated highly by at least two rating agencies.
SELECT fund_name FROM mutual_funds WHERE (agency_1_rating IS NOT NULL AND agency_1_rating >= 4.5) OR (agency_2_rating IS NOT NULL AND agency_2_rating >= 4.5) OR (agency_3_rating IS NOT NULL AND agency_3_rating >= 4.5) GROUP BY fund_name HAVING COUNT(*) >= 2;
gretelai_synthetic_text_to_sql
CREATE TABLE athletes (athlete_id INT, name VARCHAR(255), age INT, team_id INT); INSERT INTO athletes (athlete_id, name, age, team_id) VALUES (1, 'Alex', 31, 1), (2, 'Bella', 25, 1), (3, 'Charlie', 35, 2); CREATE TABLE wellbeing_programs (program_id INT, athlete_id INT, program_name VARCHAR(255), start_date DATE, end_d...
List all wellbeing programs for athletes over 30 years old
SELECT w.program_name FROM athletes a JOIN wellbeing_programs w ON a.athlete_id = w.athlete_id WHERE a.age > 30;
gretelai_synthetic_text_to_sql
CREATE TABLE districts (id INT, name TEXT); INSERT INTO districts (id, name) VALUES (1, 'City Center'), (2, 'North District'); CREATE TABLE crimes (id INT, district_id INT, type TEXT, year INT, month INT, day INT); INSERT INTO crimes (id, district_id, type, year, month, day) VALUES (1, 1, 'Theft', 2020, 1, 1), (2, 1, '...
What is the total number of crimes committed in each district for the year 2020?
SELECT d.name, COUNT(c.id) as total_crimes FROM districts d JOIN crimes c ON d.id = c.district_id WHERE c.year = 2020 GROUP BY d.id;
gretelai_synthetic_text_to_sql
CREATE TABLE dietary_restrictions (dietary_restriction_id INT, dietary_restriction VARCHAR(255)); INSERT INTO dietary_restrictions (dietary_restriction_id, dietary_restriction) VALUES (1, 'Vegan'), (2, 'Gluten-Free'); CREATE TABLE menu_items_dr (menu_item_id INT, menu_category VARCHAR(255), item_name VARCHAR(255), diet...
How many vegan and gluten-free options are there in each menu category?
SELECT m.menu_category, dr.dietary_restriction, COUNT(*) as num_options FROM menu_items_dr midr JOIN menus m ON midr.menu_category = m.menu_category JOIN dietary_restrictions dr ON midr.dietary_restriction_id = dr.dietary_restriction_id GROUP BY m.menu_category, dr.dietary_restriction;
gretelai_synthetic_text_to_sql
CREATE TABLE FarmStocks (FarmID INT, Species VARCHAR(20), AvgDissolvedOxygen FLOAT); CREATE TABLE Farms (FarmID INT, FarmName VARCHAR(50)); INSERT INTO Farms (FarmID, FarmName) VALUES (1, 'Farm A'), (2, 'Farm B'), (3, 'Farm C'); INSERT INTO FarmStocks (FarmID, Species, AvgDissolvedOxygen) VALUES (1, 'Tilapia', 6.5), (1...
Which farms have fish stocks with the lowest dissolved oxygen levels?
SELECT Farms.FarmName, FarmStocks.AvgDissolvedOxygen FROM FarmStocks JOIN Farms ON FarmStocks.FarmID = Farms.FarmID ORDER BY FarmStocks.AvgDissolvedOxygen ASC;
gretelai_synthetic_text_to_sql
CREATE TABLE MilitaryInnovationAsia (id INT, project VARCHAR(50), country VARCHAR(50), budget INT); INSERT INTO MilitaryInnovationAsia (id, project, country, budget) VALUES (1, 'Stealth Technology', 'China', 10000000), (2, 'Cyber Warfare', 'Japan', 8000000), (3, 'Artificial Intelligence', 'South Korea', 9000000);
What is the total number of military innovation projects and their average budget in Asia?
SELECT COUNT(*) AS total_projects, AVG(budget) AS avg_budget FROM MilitaryInnovationAsia;
gretelai_synthetic_text_to_sql
CREATE TABLE MiningFirms (Company VARCHAR(50), Employees INT); INSERT INTO MiningFirms (Company, Employees) VALUES ('JKL Inc', 400), ('MNO Group', 500), ('PQR Ltd', 600); CREATE TABLE SouthAmericanMines (Company VARCHAR(50), Location VARCHAR(10)); INSERT INTO SouthAmericanMines (Company, Location) VALUES ('STU Co', 'So...
How many employees work in mining companies with operations in South America?
SELECT SUM(Employees) FROM MiningFirms WHERE Company IN (SELECT Company FROM SouthAmericanMines)
gretelai_synthetic_text_to_sql
CREATE TABLE MilitaryEquipmentSales (id INT, region VARCHAR(50), amount FLOAT, sale_date DATE); INSERT INTO MilitaryEquipmentSales (id, region, amount, sale_date) VALUES (1, 'South America', 8000000, '2021-11-15'); INSERT INTO MilitaryEquipmentSales (id, region, amount, sale_date) VALUES (2, 'South America', 6000000, '...
How many military equipment sales were made to South America in Q4 2021?
SELECT COUNT(*) FROM MilitaryEquipmentSales WHERE region = 'South America' AND sale_date BETWEEN '2021-10-01' AND '2021-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE yearly_waste (year INT, total_waste FLOAT); INSERT INTO yearly_waste (year, total_waste) VALUES (2018, 4500), (2019, 4700), (2020, 5000), (2021, 5200), (2022, 5500);
What is the total waste generation for each year?
SELECT year, SUM(total_waste) OVER (ORDER BY year ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM yearly_waste;
gretelai_synthetic_text_to_sql
CREATE TABLE Archaeologists (ArchaeologistID INT, Age INT, Name VARCHAR(50)); INSERT INTO Archaeologists (ArchaeologistID, Age, Name) VALUES (1, 35, 'Mei Lee'); INSERT INTO Archaeologists (ArchaeologistID, Age, Name) VALUES (2, 40, 'Kenji Watanabe'); INSERT INTO Archaeologists (ArchaeologistID, Age, Name) VALUES (3, 50...
What is the age distribution of archaeologists who have excavated in the 'Asian' region?
SELECT A.Age, COUNT(*) AS Archaeologist_Count FROM Archaeologists A INNER JOIN Excavations E ON A.ArchaeologistID = E.ArchaeologistID WHERE E.Country = 'Asia' GROUP BY A.Age;
gretelai_synthetic_text_to_sql
CREATE TABLE menu_items_all_restaurants (id INT, name VARCHAR(50), vegetarian BOOLEAN, vegan BOOLEAN, restaurant_id INT); INSERT INTO menu_items_all_restaurants (id, name, vegetarian, vegan, restaurant_id) VALUES (1, 'Salad', true, true, 1), (2, 'Burger', false, false, 2), (3, 'Pizza', true, false, 3);
List the menu items that are not served in any restaurant.
SELECT name FROM menu_items_all_restaurants GROUP BY name HAVING COUNT(restaurant_id) = 0;
gretelai_synthetic_text_to_sql
CREATE TABLE cosmetics (product_name TEXT, consumer_preference_score INTEGER); INSERT INTO cosmetics (product_name, consumer_preference_score) VALUES ('ProductA', 85), ('ProductB', 90), ('ProductC', 70), ('ProductD', 95), ('ProductE', 80), ('ProductF', 75);
What are the names of the cosmetic products that have a consumer preference score between 75 and 90 inclusive?
SELECT product_name FROM cosmetics WHERE consumer_preference_score BETWEEN 75 AND 90;
gretelai_synthetic_text_to_sql
CREATE SCHEMA PrecisionFarming; CREATE TABLE IoT_Sensors (sensor_id INT, sensor_name VARCHAR(50), measurement VARCHAR(50)); INSERT INTO IoT_Sensors (sensor_id, sensor_name, measurement) VALUES (1, 'Sensor1', 'temperature'), (2, 'Sensor2', 'humidity'), (3, 'Sensor3', 'temperature');
List all the distinct measurement types for IoT sensors in the 'PrecisionFarming' schema.
SELECT DISTINCT measurement FROM PrecisionFarming.IoT_Sensors;
gretelai_synthetic_text_to_sql
CREATE TABLE oil_reservoirs (reservoir_id INT PRIMARY KEY, reservoir_name VARCHAR(255), discovered_year INT, oil_volume_bbls BIGINT);
Delete all records from the 'oil_reservoirs' table where the oil_volume_bbls is less than 500000000
DELETE FROM oil_reservoirs WHERE oil_volume_bbls < 500000000;
gretelai_synthetic_text_to_sql
CREATE TABLE satellites (id INT, name VARCHAR(50), type VARCHAR(50), launch_date DATE, orbit VARCHAR(50), country VARCHAR(50));
How many satellites are in geostationary orbit?
SELECT COUNT(*) FROM satellites WHERE orbit = 'geostationary';
gretelai_synthetic_text_to_sql
CREATE TABLE Artwork (artwork_id INT, artwork_name VARCHAR(255), artist_id INT, artist_origin VARCHAR(255)); INSERT INTO Artwork (artwork_id, artwork_name, artist_id, artist_origin) VALUES (1, 'Starry Night', 1, 'Dutch'), (2, 'The Persistence of Memory', 2, 'Spanish');
List artworks by underrepresented indigenous artists from 'Artwork' table.
SELECT artwork_name, artist_id FROM Artwork WHERE artist_origin IN ('Native American', 'First Nations', 'Aboriginal Australian');
gretelai_synthetic_text_to_sql
CREATE TABLE mines (id INT, name TEXT, location TEXT, production_volume INT, year INT, mineral TEXT); INSERT INTO mines (id, name, location, production_volume, year, mineral) VALUES (1, 'Mexican Silver Mine 1', 'Mexico', 6000, 2020, 'silver'); INSERT INTO mines (id, name, location, production_volume, year, mineral) VAL...
What is the average production volume for all silver mines in Mexico, grouped by year?
SELECT year, AVG(production_volume) FROM mines WHERE location = 'Mexico' AND mineral = 'silver' GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE Companies (id INT, name TEXT, location TEXT, founders TEXT); INSERT INTO Companies (id, name, location, founders) VALUES (1, 'GreenTech', 'Bay Area', 'Latinx, Male'); INSERT INTO Companies (id, name, location, founders) VALUES (2, 'CodeUp', 'Bay Area', 'Latinx'); CREATE TABLE Exit_Strategies (company_id IN...
List all the exit strategies for companies founded in the Bay Area with at least one Latinx founder.
SELECT e.strategy FROM Companies c JOIN Exit_Strategies e ON c.id = e.company_id WHERE c.location = 'Bay Area' AND founders LIKE '%Latinx%';
gretelai_synthetic_text_to_sql
CREATE TABLE RouteFrequency (RouteID int, Frequency int); INSERT INTO RouteFrequency (RouteID, Frequency) VALUES (1, 30), (2, 45), (3, 60); CREATE TABLE RouteAvgFares (RouteID int, AvgFare decimal(5,2)); INSERT INTO RouteAvgFares (RouteID, AvgFare) VALUES (1, 4.00), (2, 3.25), (3, 2.75);
What is the average fare for routes that have a frequency of more than once per hour?
SELECT AVG(AvgFare) FROM RouteAvgFares INNER JOIN RouteFrequency ON RouteAvgFares.RouteID = RouteFrequency.RouteID WHERE RouteFrequency.Frequency > 60;
gretelai_synthetic_text_to_sql
CREATE TABLE Trees (id INT, species VARCHAR(255), age INT); INSERT INTO Trees (id, species, age) VALUES (1, 'Oak', 50), (2, 'Pine', 30), (3, 'Maple', 40);
What is the average timber volume of all the trees in the Trees table, if each tree has a timber volume of 0.002 cubic feet per year per inch of age?
SELECT AVG(age * 0.002) FROM Trees;
gretelai_synthetic_text_to_sql
CREATE TABLE space_missions (id INT, name VARCHAR(50), type VARCHAR(50), country VARCHAR(50), launch_date DATE, has_astrobiology BOOLEAN);
Return the total number of space missions in the space_missions table that include an astrobiology component
SELECT COUNT(*) as total_astrobiology_missions FROM space_missions WHERE has_astrobiology = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE shark_sightings (id INT, name TEXT, location TEXT, depth INT); INSERT INTO shark_sightings (id, name, location, depth) VALUES (1, 'Greenland Shark', 'Arctic Ocean', 2000), (2, 'Pacific Sleeper Shark', 'Arctic Ocean', 2500), (3, 'Basking Shark', 'Atlantic Ocean', 1000);
What is the average depth at which sharks have been recorded in the Arctic Ocean?
SELECT AVG(depth) FROM shark_sightings WHERE location = 'Arctic Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (volunteer_id INT, volunteer_name VARCHAR(50), first_volunteer_date DATE, last_volunteer_date DATE); CREATE TABLE Volunteer_Hours (volunteer_id INT, program_id INT, hours DECIMAL(5,2), volunteer_date DATE);
What was the retention rate of volunteers who engaged in arts & culture programs in 2021?
SELECT 100.0 * COUNT(DISTINCT v1.volunteer_id) / COUNT(DISTINCT v2.volunteer_id) AS retention_rate FROM Volunteers v1 JOIN Volunteers v2 ON v1.volunteer_id = v2.volunteer_id WHERE v1.first_volunteer_date BETWEEN '2021-01-01' AND '2021-12-31' AND v2.last_volunteer_date BETWEEN '2021-01-01' AND '2021-12-31' AND v1.volunt...
gretelai_synthetic_text_to_sql
CREATE TABLE LawFirms (LawFirmID INT, LawFirmName VARCHAR(255)); CREATE TABLE Tools (ToolID INT, LawFirmID INT, ToolDate DATE);
What is the total number of legal technology tools used by each law firm, for the past year, ordered by the number of tools in descending order?
SELECT LawFirms.LawFirmName, COUNT(*) AS NumberOfTools FROM LawFirms JOIN Tools ON LawFirms.LawFirmID = Tools.LawFirmID WHERE ToolDate >= DATEADD(YEAR, -1, GETDATE()) GROUP BY LawFirms.LawFirmID, LawFirms.LawFirmName ORDER BY NumberOfTools DESC;
gretelai_synthetic_text_to_sql