context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE SatelliteDeployments (id INT, country VARCHAR(255), year INT, success BOOLEAN); INSERT INTO SatelliteDeployments VALUES (1, 'China', 2010, true), (2, 'USA', 2012, false), (3, 'China', 2015, true), (4, 'India', 2017, true);
How many successful satellite deployments were there in China since 2010?
SELECT COUNT(*) FROM SatelliteDeployments WHERE country = 'China' AND success = true AND year >= 2010;
gretelai_synthetic_text_to_sql
CREATE TABLE healthcare_facilities (facility_id INT, state VARCHAR(2), serves_aapi BOOLEAN, violations INT); INSERT INTO healthcare_facilities (facility_id, state, serves_aapi, violations) VALUES (1, 'CA', TRUE, 10), (2, 'NY', TRUE, 15), (3, 'CA', FALSE, 5), (4, 'NY', FALSE, 20);
What is the average mental health parity violation score for healthcare facilities serving predominantly Asian American and Pacific Islander communities in California and New York?
SELECT AVG(h.violations) FROM healthcare_facilities h WHERE h.state IN ('CA', 'NY') AND h.serves_aapi = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tourism_japan (vendor_id INT, vendor_name VARCHAR(255), country VARCHAR(255), participation INT); INSERT INTO virtual_tourism_japan (vendor_id, vendor_name, country, participation) VALUES (1, 'Vendor A', 'Japan', 1); INSERT INTO virtual_tourism_japan (vendor_id, vendor_name, country, participation)...
How many local vendors are part of the virtual tourism initiative in Japan?
SELECT COUNT(*) FROM virtual_tourism_japan WHERE country = 'Japan';
gretelai_synthetic_text_to_sql
CREATE TABLE Events (id INT, museum VARCHAR(30), price DECIMAL(5,2)); INSERT INTO Events (id, museum, price) VALUES (1, 'Museum of Modern Art', 25.00), (2, 'Metropolitan Museum of Art', 30.00), (3, 'Museum of Modern Art', 20.00);
What is the average ticket price for events at the Museum of Modern Art?
SELECT AVG(price) FROM Events WHERE museum = 'Museum of Modern Art';
gretelai_synthetic_text_to_sql
CREATE TABLE Chemicals (Id INT, Name VARCHAR(50), Type VARCHAR(50), ManufacturingDate DATE); INSERT INTO Chemicals (Id, Name, Type, ManufacturingDate) VALUES (1, 'Acetone', 'Solvent', '2021-01-01'), (2, 'Ammonia', 'Gas', '2022-02-01');
Find chemicals with 'Solvent' type.
SELECT * FROM Chemicals WHERE Type = 'Solvent';
gretelai_synthetic_text_to_sql
CREATE TABLE players (player_id INT, name VARCHAR(50)); INSERT INTO players VALUES (1, 'John'); INSERT INTO players VALUES (2, 'Jane'); CREATE TABLE game_sessions (session_id INT, player_id INT, game VARCHAR(50), duration INT); INSERT INTO game_sessions VALUES (1, 1, 'RPG', 12); INSERT INTO game_sessions VALUES (2, 1, ...
Which players have played more than 10 hours of 'RPG' games since 2017?
SELECT p.name, COUNT(*) as rpg_sessions FROM players p JOIN game_sessions s ON p.player_id = s.player_id WHERE s.game = 'RPG' AND s.duration > 0 AND s.duration < 61 GROUP BY p.player_id HAVING COUNT(*) > 10;
gretelai_synthetic_text_to_sql
CREATE TABLE ContractorBuildings (ContractorID int, Region varchar(20), Year int, GreenCertified bit, SquareFootage decimal(10,2)); INSERT INTO ContractorBuildings (ContractorID, Region, Year, GreenCertified, SquareFootage) VALUES (1, 'Midwest', 2021, 1, 75000.00), (2, 'Midwest', 2021, 1, 60000.00), (3, 'Midwest', 2021...
Identify the top 3 contractors with the highest average square footage of green-certified buildings in the Midwest, for the year 2021.
SELECT ContractorID, AVG(SquareFootage) as Avg_SqFt FROM ContractorBuildings WHERE Region = 'Midwest' AND Year = 2021 AND GreenCertified = 1 GROUP BY ContractorID ORDER BY Avg_SqFt DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tours (tour_id INT, location VARCHAR(255), country VARCHAR(255), tour_date DATE); INSERT INTO virtual_tours (tour_id, location, country, tour_date) VALUES (1, 'Statue of Liberty', 'USA', '2022-01-01'), (2, 'Golden Gate Bridge', 'USA', '2022-02-15');
How many virtual tours were conducted in the USA in Q1 2022?
SELECT COUNT(*) FROM virtual_tours WHERE country = 'USA' AND tour_date BETWEEN '2022-01-01' AND '2022-03-31';
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_pricing (scheme VARCHAR(255), year INT, carbon_price FLOAT); INSERT INTO carbon_pricing (scheme, year, carbon_price) VALUES ('ETS', 2021, 30.56);
List the carbon pricing schemes and their corresponding carbon prices for the year 2021, sorted by carbon price in descending order.
SELECT * FROM carbon_pricing WHERE year = 2021 ORDER BY carbon_price DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE workforce (id INT, name VARCHAR(50), position VARCHAR(50), department VARCHAR(50), operation_type VARCHAR(50)); INSERT INTO workforce (id, name, position, department, operation_type) VALUES (1, 'John Doe', 'Engineer', 'Mining', 'Coal'), (2, 'Jane Smith', 'Technician', 'Environment', 'Gold'), (3, 'Alice Joh...
What is the number of employees working in each mining operation type?
SELECT operation_type, COUNT(*) as num_employees FROM workforce GROUP BY operation_type;
gretelai_synthetic_text_to_sql
CREATE TABLE satellite_database (id INT, name VARCHAR(50), type VARCHAR(50), orbit_type VARCHAR(50), country VARCHAR(50), launch_date DATE);
Show the number of satellites in the satellite_database table, grouped by their country, and order by the count in descending order, only showing the top 5 countries
SELECT country, COUNT(*) as satellite_count FROM satellite_database GROUP BY country ORDER BY satellite_count DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE women_businesses (country VARCHAR(50), business_count INT); INSERT INTO women_businesses (country, business_count) VALUES ('Bangladesh', 500), ('Kenya', 300), ('Guatemala', 250);
What is the number of women-led businesses in the agricultural sector in each country?
SELECT country, business_count FROM women_businesses;
gretelai_synthetic_text_to_sql
CREATE TABLE vulnerabilities (vulnerability_id INT, organization VARCHAR(255), country VARCHAR(255), severity_score INT, vulnerability_date DATE); INSERT INTO vulnerabilities (vulnerability_id, organization, country, severity_score, vulnerability_date) VALUES (1, 'Org1', 'USA', 7, '2022-06-01'), (2, 'Org2', 'Canada', 5...
What is the total number of vulnerabilities and the average severity score for each organization, ordered by the highest average severity score, for the last 90 days?
SELECT organization, COUNT(vulnerability_id) as total_vulnerabilities, AVG(severity_score) as avg_severity_score FROM vulnerabilities WHERE vulnerability_date >= DATEADD(day, -90, GETDATE()) GROUP BY organization ORDER BY avg_severity_score DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Visitors (id INT, exhibition_id INT, age INT, prefers_digital BOOLEAN); INSERT INTO Visitors (id, exhibition_id, age, prefers_digital) VALUES (1, 1, 30, TRUE), (2, 1, 35, FALSE), (3, 2, 40, TRUE);
What percentage of visitors identified as preferring digital experiences?
SELECT 100.0 * COUNT(v.id) / (SELECT COUNT(id) FROM Visitors) AS percentage FROM Visitors v WHERE v.prefers_digital = TRUE
gretelai_synthetic_text_to_sql
CREATE TABLE cargo_inspections (inspection_id INT, inspection_date DATE);
Show the number of cargo inspections per month, including months with no inspections.
SELECT EXTRACT(MONTH FROM inspection_date) as month, COUNT(*) as num_inspections FROM cargo_inspections GROUP BY month ORDER BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE platform (platform_id INT, platform_name TEXT, oil_production_q2_2021 FLOAT); INSERT INTO platform (platform_id, platform_name, oil_production_q2_2021) VALUES (1, 'X', 1400), (2, 'Y', 1600), (3, 'Z', 1900);
What was the average oil production per platform in Q2 2021?
SELECT AVG(oil_production_q2_2021) as avg_oil_production FROM platform;
gretelai_synthetic_text_to_sql
CREATE TABLE explainable_ai_algorithms (algorithm_id INT, algorithm_name TEXT, application_domain TEXT, complexity_score INT); INSERT INTO explainable_ai_algorithms (algorithm_id, algorithm_name, application_domain, complexity_score) VALUES (1, 'AI Transparency', 'Healthcare', 7), (2, 'Explainable Deep Learning', 'Fina...
What is the distribution of explainable AI algorithms by application domain and complexity score?
SELECT application_domain, complexity_score, COUNT(*) as num_algorithms FROM explainable_ai_algorithms GROUP BY application_domain, complexity_score;
gretelai_synthetic_text_to_sql
CREATE TABLE socially_responsible_loans (loan_id INT, loan_type VARCHAR(20), transaction_value DECIMAL(10,2), transaction_date DATE); INSERT INTO socially_responsible_loans (loan_id, loan_type, transaction_value, transaction_date) VALUES (1, 'Microfinance', 500, '2022-01-05'), (2, 'Green Energy', 1500, '2022-01-10'), (...
What is the total transaction value for socially responsible loans in Q1 2022?
SELECT SUM(transaction_value) FROM socially_responsible_loans WHERE transaction_date BETWEEN '2022-01-01' AND '2022-03-31';
gretelai_synthetic_text_to_sql
CREATE TABLE volunteer_hours (volunteer_id INT, program_id INT, hours DECIMAL(10, 2), hour_date DATE); INSERT INTO volunteer_hours VALUES (23, 101, 3.00, '2023-01-01'), (24, 101, 2.50, '2023-02-01'), (25, 102, 4.00, '2023-01-10');
What was the average volunteer hours per volunteer in 2023?
SELECT AVG(hours) FROM volunteer_hours GROUP BY volunteer_id HAVING COUNT(*) > 0;
gretelai_synthetic_text_to_sql
CREATE TABLE programs (id INT, category VARCHAR(10), funding_received DECIMAL(10,2)); INSERT INTO programs (id, category, funding_received) VALUES (1, 'Exhibitions', 10000.00), (2, 'Education', 25000.00), (3, 'Performances', 12000.00);
What was the total amount of funding received for programs in the 'Performances' category?
SELECT SUM(funding_received) FROM programs WHERE category = 'Performances';
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (id INT, species_name VARCHAR(255), population INT, habitat VARCHAR(255), ocean VARCHAR(255)); INSERT INTO marine_species (id, species_name, population, habitat, ocean) VALUES (1, 'Atlantic Salmon', 1000000, 'Freshwater', 'Atlantic');
How many marine species are there in each ocean, ranked by population size?
SELECT ocean, COUNT(*) AS num_species, SUM(population) AS total_population FROM marine_species GROUP BY ocean ORDER BY total_population DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE organizations (org_id INT, org_name TEXT, sector TEXT, annual_revenue FLOAT); INSERT INTO organizations (org_id, org_name, sector, annual_revenue) VALUES (1, 'Greenpeace', 'environment', 200000.00), (2, 'World Wildlife Fund', 'environment', 300000.00);
How many non-profit organizations are there in the 'environment' sector with an annual revenue less than $250,000?
SELECT COUNT(*) FROM organizations WHERE sector = 'environment' AND annual_revenue < 250000.00;
gretelai_synthetic_text_to_sql
CREATE TABLE drilling_rigs(region VARCHAR(255), status VARCHAR(255), count INT);INSERT INTO drilling_rigs(region, status, count) VALUES('North Sea', 'Active', 30), ('North Sea', 'Inactive', 10), ('Gulf of Mexico', 'Active', 50), ('Gulf of Mexico', 'Inactive', 20), ('Barents Sea', 'Active', 15), ('Barents Sea', 'Inactiv...
Find the number of active drilling rigs in the North Sea and the Gulf of Mexico.
SELECT region, COUNT(*) AS active_rigs_count FROM drilling_rigs WHERE status = 'Active' AND region IN ('North Sea', 'Gulf of Mexico') GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE chemical_containers (container_id INT, container_name TEXT, last_inspection_date DATE, in_use BOOLEAN); INSERT INTO chemical_containers (container_id, container_name, last_inspection_date, in_use) VALUES (1, 'Container A', '2021-01-01', TRUE), (2, 'Container B', '2021-04-15', FALSE), (3, 'Container C', '20...
Insert a new record of a chemical container that has a container name of 'Container F', has not been inspected yet, and is currently in use.
INSERT INTO chemical_containers (container_name, last_inspection_date, in_use) VALUES ('Container F', NULL, TRUE);
gretelai_synthetic_text_to_sql
CREATE TABLE tourism_initiatives (initiative_id INT, region VARCHAR(50), sustainability_level VARCHAR(50)); INSERT INTO tourism_initiatives (initiative_id, region, sustainability_level) VALUES (1, 'Africa', 'Sustainable'), (2, 'Asia', 'Standard'), (3, 'Africa', 'Sustainable'), (4, 'Europe', 'Luxury'), (5, 'Africa', 'Su...
What is the total number of sustainable tourism initiatives in Africa?
SELECT COUNT(*) FROM tourism_initiatives WHERE region = 'Africa' AND sustainability_level = 'Sustainable';
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_customers (customer_id INT, data_usage FLOAT, state VARCHAR(20), last_update DATE); INSERT INTO mobile_customers (customer_id, data_usage, state, last_update) VALUES (1, 6.0, 'NY', '2022-01-10'), (2, 3.5, 'CA', '2022-01-15'), (3, 8.2, 'TX', '2022-01-28');
What is the average data usage for mobile customers in each state?
SELECT state, AVG(data_usage) FROM mobile_customers GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE Teacher (TeacherID INT, Gender VARCHAR(10)); CREATE TABLE Course (CourseID INT, TeacherID INT); INSERT INTO Teacher (TeacherID, Gender) VALUES (1, 'Female'), (2, 'Male'); INSERT INTO Course (CourseID, TeacherID) VALUES (101, 1), (102, 2), (103, 1);
List all the unique courses taught by female teachers
SELECT CourseID FROM Course c JOIN Teacher t ON c.TeacherID = t.TeacherID WHERE t.Gender = 'Female' GROUP BY CourseID;
gretelai_synthetic_text_to_sql
CREATE TABLE ContractNegotiations (contract_id INT, contractor VARCHAR(50), contract_duration INT); INSERT INTO ContractNegotiations (contract_id, contractor, contract_duration) VALUES (1, 'Acme Corp', 12); INSERT INTO ContractNegotiations (contract_id, contractor, contract_duration) VALUES (2, 'Global Defense', 18);
What is the total number of contracts negotiated by each contractor and their total duration?
SELECT contractor, COUNT(*) as total_contracts, SUM(contract_duration) as total_duration FROM ContractNegotiations GROUP BY contractor;
gretelai_synthetic_text_to_sql
CREATE TABLE companies_funding (id INT, company_id INT, funding_amount INT); CREATE TABLE companies (id INT, name TEXT);
Which companies have not yet received any investment?
SELECT companies.name FROM companies LEFT JOIN companies_funding ON companies.id = companies_funding.company_id WHERE funding_amount IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE excavation_sites (site_id INT, site_name VARCHAR(255)); CREATE TABLE artifacts (artifact_id INT, site_id INT, artifact_type VARCHAR(255), historical_period VARCHAR(255)); INSERT INTO excavation_sites (site_id, site_name) VALUES (1, 'site_a'), (2, 'site_b'), (3, 'site_c'); INSERT INTO artifacts (artifact_id...
Find the number of distinct artifact types per site and their historical periods.
SELECT site_name, historical_period, COUNT(DISTINCT artifact_type) as artifact_count FROM excavation_sites s JOIN artifacts a ON s.site_id = a.site_id GROUP BY site_name, historical_period;
gretelai_synthetic_text_to_sql
CREATE TABLE subscribers (id INT, region VARCHAR(10), monthly_data_usage DECIMAL(5,2)); INSERT INTO subscribers (id, region, monthly_data_usage) VALUES (1, 'urban', 3.5), (2, 'rural', 2.2), (3, 'urban', 4.1), (4, 'rural', 1.9), (5, 'urban', 3.9);
What is the monthly data usage distribution for customers in the 'rural' region?
SELECT monthly_data_usage, COUNT(*) FROM subscribers WHERE region = 'rural' GROUP BY monthly_data_usage;
gretelai_synthetic_text_to_sql
CREATE TABLE investments(id INT, sector VARCHAR(20), esg_score INT); INSERT INTO investments VALUES(1, 'Tech', 85), (2, 'Healthcare', 75), (3, 'Tech', 82);
What is the sum of ESG scores for investments in the Healthcare sector?
SELECT SUM(esg_score) as total_esg_score FROM investments WHERE sector = 'Healthcare';
gretelai_synthetic_text_to_sql
CREATE TABLE climate_adaptation (region VARCHAR(255), funding FLOAT); INSERT INTO climate_adaptation (region, funding) VALUES ('Climate Adaptation Asia', 1500000), ('Climate Adaptation Africa', 1200000);
Update the funding amount for 'Climate Adaptation Asia' project to '1800000'
UPDATE climate_adaptation SET funding = 1800000 WHERE region = 'Climate Adaptation Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE satellites_by_orbit (satellite_id INT, country VARCHAR(50), orbit_type VARCHAR(50)); INSERT INTO satellites_by_orbit (satellite_id, country, orbit_type) VALUES (1, 'USA', 'Geostationary'); INSERT INTO satellites_by_orbit (satellite_id, country, orbit_type) VALUES (2, 'Russia', 'Low Earth Orbit'); INSERT IN...
Show the number of satellites in geostationary orbit by each country
SELECT country, COUNT(*) as num_satellites FROM satellites_by_orbit WHERE orbit_type = 'Geostationary' GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE water_temperature (id INT, farm_id INT, region TEXT, temperature FLOAT); INSERT INTO water_temperature (id, farm_id, region, temperature) VALUES (1, 1, 'Indian Ocean', 29.2), (2, 1, 'Indian Ocean', 29.3), (3, 2, 'Atlantic Ocean', 28.1);
What is the maximum water temperature in the 'Indian Ocean' region?
SELECT MAX(water_temperature.temperature) FROM water_temperature WHERE water_temperature.region = 'Indian Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE Customers (CustomerID INT, Name VARCHAR(50));CREATE TABLE Investments (CustomerID INT, InvestmentType VARCHAR(10), Sector VARCHAR(10));INSERT INTO Customers VALUES (1,'John Doe'),(2,'Jane Smith'),(3,'Bob Johnson');INSERT INTO Investments VALUES (1,'Stocks','Healthcare'),(2,'Stocks','Technology'),(2,'Stocks...
What are the names of customers who have invested in the healthcare sector but not in the technology sector?
SELECT DISTINCT c.Name FROM Customers c INNER JOIN Investments i ON c.CustomerID = i.CustomerID WHERE i.Sector = 'Healthcare' AND c.CustomerID NOT IN (SELECT CustomerID FROM Investments WHERE Sector = 'Technology');
gretelai_synthetic_text_to_sql
CREATE TABLE healthcare_centers_india (name TEXT, location TEXT, patients_served INT); INSERT INTO healthcare_centers_india (name, location, patients_served) VALUES ('HC A', 'Rural Tamil Nadu', 100), ('HC B', 'Rural Karnataka', 200), ('HC C', 'Rural Andhra Pradesh', 150);
What is the total number of patients served by rural healthcare centers in India, excluding those served in the state of Tamil Nadu?
SELECT SUM(patients_served) as total_patients FROM healthcare_centers_india WHERE location NOT LIKE 'Rural Tamil Nadu%';
gretelai_synthetic_text_to_sql
CREATE TABLE support_programs (program_id INT, program_name VARCHAR(50), budget INT, disability_type VARCHAR(50)); INSERT INTO support_programs (program_id, program_name, budget, disability_type) VALUES (1, 'Assistive Technology', 50000, 'Physical');
What is the average budget for support programs by disability type?
SELECT disability_type, AVG(budget) as avg_budget FROM support_programs GROUP BY disability_type;
gretelai_synthetic_text_to_sql
CREATE TABLE southeast_asian_countries (country TEXT); INSERT INTO southeast_asian_countries VALUES ('Indonesia'), ('Malaysia'), ('Philippines'), ('Thailand'), ('Vietnam'); CREATE TABLE ai_safety_projects (project_name TEXT, funding INTEGER, country TEXT);
Find the total number of AI safety projects in Southeast Asia.
SELECT COUNT(*) FROM ai_safety_projects WHERE country IN (SELECT * FROM southeast_asian_countries);
gretelai_synthetic_text_to_sql
CREATE TABLE Festivals (id INT, name VARCHAR(50), country VARCHAR(50), year INT, revenue INT, genre VARCHAR(50)); INSERT INTO Festivals (id, name, country, year, revenue, genre) VALUES (1, 'Rock in Rio', 'Brazil', 2024, 8000000, 'Latin'), (2, 'Lollapalooza', 'Argentina', 2024, 7000000, 'Latin'), (3, 'Vive Latino', 'Mex...
What is the total revenue generated by Latin music festivals in South America in 2024?
SELECT SUM(revenue) FROM Festivals WHERE country IN ('Brazil', 'Argentina', 'Mexico') AND genre = 'Latin' AND year = 2024;
gretelai_synthetic_text_to_sql
CREATE TABLE CommunityHealthWorkers (CHW_ID INT, Region VARCHAR(50)); INSERT INTO CommunityHealthWorkers (CHW_ID, Region) VALUES (1, 'North'), (2, 'South'), (3, 'East'), (4, 'West'); CREATE TABLE MentalHealthScores (Patient_ID INT, CHW_ID INT, Parity_Score INT); INSERT INTO MentalHealthScores (Patient_ID, CHW_ID, Parit...
What is the average mental health parity score for patients in each community health worker's region?
SELECT c.Region, AVG(m.Parity_Score) as Avg_Parity_Score FROM MentalHealthScores m JOIN CommunityHealthWorkers c ON m.CHW_ID = c.CHW_ID GROUP BY c.Region;
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, Age INT, GameGenre VARCHAR(20));INSERT INTO Players (PlayerID, Age, GameGenre) VALUES (1, 25, 'RPG'), (2, 24, 'RPG'), (3, 30, 'FPS');
What is the most common age range of players who play 'RPG' games?
SELECT Age, COUNT(PlayerID) FROM Players WHERE GameGenre = 'RPG' GROUP BY Age ORDER BY COUNT(PlayerID) DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Habitats (id INT, animal_id INT, size FLOAT, region VARCHAR(255)); INSERT INTO Habitats (id, animal_id, size, region) VALUES (1, 1, 5.6, 'Africa'), (2, 2, 3.2, 'Asia'), (3, 3, 7.8, 'Africa');
What is the maximum and minimum size of protected habitats in square kilometers for each region?
SELECT region, MIN(size) AS min_size, MAX(size) AS max_size FROM Habitats WHERE size IS NOT NULL GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE satellites (id INT, country VARCHAR(50), launch_date DATETIME); INSERT INTO satellites (id, country, launch_date) VALUES (1, 'USA', '2000-01-01'), (2, 'Russia', '2001-01-01'), (3, 'China', '2002-01-01'), (4, 'Japan', '2003-01-01'), (5, 'India', '2004-01-01'), (6, 'Germany', '2005-01-01'), (7, 'France', '20...
Who are the top 5 countries with the most satellites in orbit?
SELECT country, COUNT(s.id) as total_satellites FROM satellites s JOIN launches l ON s.id = l.satellite_id GROUP BY country ORDER BY total_satellites DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE department (id INT, name VARCHAR(255)); INSERT INTO department (id, name) VALUES (1, 'Justice'); INSERT INTO department (id, name) VALUES (2, 'Interior'); CREATE TABLE foia (id INT, department_id INT, date DATE); INSERT INTO foia (id, department_id, date) VALUES (1, 1, '2020-01-01'); INSERT INTO foia (id, ...
How many FOIA requests were submitted in each department for the year 2020?
SELECT department.name, COUNT(foia.id) as num_foia_requests FROM department JOIN foia ON department.id = foia.department_id WHERE YEAR(foia.date) = 2020 GROUP BY department.name;
gretelai_synthetic_text_to_sql
CREATE TABLE funding(startup VARCHAR(50), country VARCHAR(20), founder_gender VARCHAR(10));INSERT INTO funding(startup, country, founder_gender) VALUES('StartupA', 'Canada', 'Female'), ('StartupB', 'US', 'Male'), ('StartupC', 'Canada', 'Female');
Which biotech startups received funding in Canada and have a female founder?
SELECT startup FROM funding WHERE country = 'Canada' AND founder_gender = 'Female';
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (DonationID INT, DonationDate DATE, DonationAmount DECIMAL, CauseID INT);
Which causes received the most funding in Q1 2022?
SELECT C.CauseName, SUM(D.DonationAmount) as Q1Funding FROM Donations D JOIN Causes C ON D.CauseID = C.CauseID WHERE D.DonationDate BETWEEN '2022-01-01' AND '2022-03-31' GROUP BY C.CauseName ORDER BY Q1Funding DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT PRIMARY KEY, drug_id INT, country VARCHAR(255), year INT, revenue DECIMAL(10,2)); CREATE TABLE drugs (id INT PRIMARY KEY, name VARCHAR(255), manufacturer VARCHAR(255), approval_date DATE);
Which countries had the highest sales revenue for a specific drug in 2020?
SELECT country, SUM(revenue) as total_sales FROM sales JOIN drugs ON sales.drug_id = drugs.id WHERE drugs.name = 'Specific Drug' AND year = 2020 GROUP BY country ORDER BY total_sales DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE shipments(id INT, product VARCHAR(20), weight FLOAT, country VARCHAR(20), date DATE); INSERT INTO shipments(id, product, weight, country, date) VALUES (1, 'apples', 500, 'Costa Rica', '2022-01-05'); INSERT INTO shipments(id, product, weight, country, date) VALUES (2, 'bananas', 800, 'Costa Rica', '2022-01-...
What is the total weight of organic apples and bananas shipped from Costa Rica to New York in the first quarter of 2022?
SELECT SUM(weight) FROM shipments WHERE product IN ('apples', 'bananas') AND country = 'Costa Rica' AND date BETWEEN '2022-01-01' AND '2022-03-31' AND product LIKE 'organic%';
gretelai_synthetic_text_to_sql
CREATE TABLE manufacturing_processes (process_id INT, process_name VARCHAR(255), energy_consumption INT); INSERT INTO manufacturing_processes (process_id, process_name, energy_consumption) VALUES (1, 'Process A', 1000), (2, 'Process B', 1500), (3, 'Process C', 2000), (4, 'Process D', 2500);
Calculate the average energy consumption for each manufacturing process
SELECT process_name, AVG(energy_consumption) as avg_energy_consumption FROM manufacturing_processes GROUP BY process_name;
gretelai_synthetic_text_to_sql
CREATE TABLE gym_checkins (id INT, user_id INT, checkin_date DATE); INSERT INTO gym_checkins (id, user_id, checkin_date) VALUES (1, 33, '2022-09-12'), (2, 33, '2022-09-10'), (3, 55, '2022-08-15');
Who has the highest number of gym check-ins in the past week?
SELECT user_id, COUNT(*) as checkin_count FROM gym_checkins WHERE checkin_date >= CURDATE() - INTERVAL 7 DAY GROUP BY user_id ORDER BY checkin_count DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE eras (era_id INT, era_name TEXT); INSERT INTO eras (era_id, era_name) VALUES (1, 'pre-Columbian'); CREATE TABLE excavation_sites (site_id INT, site_name TEXT, country TEXT, era_id INT); INSERT INTO excavation_sites (site_id, site_name, country, era_id) VALUES (1, 'Mayan Ruins', 'Mexico', 1), (2, 'Inca Trai...
Which countries have the most excavation sites in the 'pre-Columbian' era?
SELECT country, COUNT(site_id) as site_count FROM excavation_sites WHERE era_id = 1 GROUP BY country ORDER BY site_count DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE defense_diplomacy (id INT, country VARCHAR, military_spending FLOAT);
What is the average military spending for countries involved in defense diplomacy?
SELECT country, AVG(military_spending) FROM defense_diplomacy GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE seating_sections (seating_section_id INT, seating_section_name VARCHAR(50), avg_price DECIMAL(10,2));
What is the average ticket price by seating section?
SELECT s.seating_section_name, AVG(t.revenue/t.quantity) as avg_price FROM tickets t JOIN seating_sections s ON t.seating_section_id = s.seating_section_id GROUP BY s.seating_section_name;
gretelai_synthetic_text_to_sql
CREATE TABLE chemical_substance_info (substance_id INT, substance_name TEXT); INSERT INTO chemical_substance_info (substance_id, substance_name) VALUES (101, 'CompoundX'), (102, 'SolutionY'), (103, 'MixtureZ');
What are the unique chemical substance IDs and their corresponding substance names from the chemical_substance_info table, ordered by the substance ID in ascending order?
SELECT substance_id, substance_name FROM chemical_substance_info ORDER BY substance_id ASC;
gretelai_synthetic_text_to_sql
CREATE TABLE wells (id INT, well_name VARCHAR(100), location VARCHAR(50), status VARCHAR(20)); INSERT INTO wells VALUES (1, 'Well A', 'North Sea', 'Producing'); INSERT INTO wells VALUES (2, 'Well B', 'Gulf of Mexico', 'Abandoned'); INSERT INTO wells VALUES (3, 'Well C', 'Gulf of Mexico', 'Producing'); INSERT INTO wells...
Identify the idle wells in the Gulf of Mexico
SELECT well_name FROM wells WHERE location = 'Gulf of Mexico' AND status = 'Idle';
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, name VARCHAR(50), posts_count INT); CREATE TABLE posts (id INT, user_id INT, post_text VARCHAR(255), post_date DATE);
What is the maximum number of posts in a single day for users in the social_media schema?
SELECT MAX(post_count) FROM (SELECT user_id, COUNT(*) AS post_count FROM posts GROUP BY user_id, post_date) AS post_counts;
gretelai_synthetic_text_to_sql
CREATE TABLE Supplier (id INT PRIMARY KEY, name VARCHAR(50), country VARCHAR(50), sustainability_score INT);
Insert a new textile supplier 'Sustainable Textiles Inc.' from 'Bangladesh' into the 'Supplier' table
INSERT INTO Supplier (id, name, country, sustainability_score) VALUES (15, 'Sustainable Textiles Inc.', 'Bangladesh', 80);
gretelai_synthetic_text_to_sql
CREATE TABLE regions (id INT, name VARCHAR(255)); CREATE TABLE supplies (id INT, region_id INT, sent_date DATE, quantity INT);
How many supplies were sent to each region in 2021?
SELECT regions.name, COUNT(supplies.id) FROM supplies JOIN regions ON supplies.region_id = regions.id WHERE supplies.sent_date BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY supplies.region_id;
gretelai_synthetic_text_to_sql
CREATE TABLE donors (id INT, name TEXT, donation DECIMAL); INSERT INTO donors (id, name, donation) VALUES (1, 'John Doe', 500.00), (2, 'Jane Smith', 1000.00), (3, 'Mike Johnson', 750.00);
List all unique donors who have donated more than $500.00.
SELECT DISTINCT name FROM donors WHERE donation > 500.00;
gretelai_synthetic_text_to_sql
CREATE TABLE campaigns (campaign_id INT, name TEXT, condition TEXT, start_date DATE, end_date DATE); INSERT INTO campaigns (campaign_id, name, condition, start_date, end_date) VALUES (1, 'Break the Stigma', 'Depression', '2018-01-01', '2018-12-31'); INSERT INTO campaigns (campaign_id, name, condition, start_date, end_d...
List the names and total number of campaigns for public awareness campaigns related to depression in the last 5 years, ordered by the number of campaigns in descending order.
SELECT name, COUNT(*) as total FROM campaigns WHERE condition = 'Depression' AND start_date >= DATEADD(year, -5, GETDATE()) GROUP BY name ORDER BY total DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE space_missions (id INT, mission_name VARCHAR(255), astronaut_name VARCHAR(255), duration INT); INSERT INTO space_missions (id, mission_name, astronaut_name, duration) VALUES (1, 'Apollo 11', 'Neil Armstrong', 195), (2, 'Apollo 12', 'Jane Foster', 244), (3, 'Ares 3', 'Mark Watney', 568); CREATE TABLE missio...
What is the maximum duration of a space mission led by 'Space Riders Inc.'?
SELECT MAX(space_missions.duration) FROM space_missions JOIN mission_contractors ON space_missions.mission_name = mission_contractors.mission_name WHERE mission_contractors.contractor = 'Space Riders Inc.';
gretelai_synthetic_text_to_sql
CREATE TABLE Forwarders (id INT, name VARCHAR(255)); CREATE TABLE Shipments (id INT, forwarder_id INT, shipped_date DATE, delivered_date DATE, delay INT);
List the freight forwarders with more than 10% of their shipments delayed by more than 5 days in the last 6 months?
SELECT f.name, COUNT(s.id) AS total_shipments, SUM(CASE WHEN s.delay > 5 THEN 1 ELSE 0 END) AS delayed_shipments, 100.0 * SUM(CASE WHEN s.delay > 5 THEN 1 ELSE 0 END) / COUNT(s.id) AS pct_delayed_shipments FROM Forwarders f JOIN Shipments s ON f.id = s.forwarder_id WHERE shipped_date >= DATEADD(month, -6, GETDATE()) GR...
gretelai_synthetic_text_to_sql
CREATE TABLE FarmTemperature (farm_id INT, date DATE, temperature DECIMAL(5,2)); INSERT INTO FarmTemperature (farm_id, date, temperature) VALUES (1, '2021-01-01', 25.2), (1, '2021-01-02', 25.4);
What is the average water temperature for each month in 2021 for the Tilapia farm?
SELECT AVG(temperature) avg_temp, EXTRACT(MONTH FROM date) month FROM FarmTemperature WHERE farm_id = 1 AND YEAR(date) = 2021 GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE events (id INT PRIMARY KEY, event_name VARCHAR(100), event_city VARCHAR(50), num_attendees INT);
How many events had more than 50 attendees from each city in the 'events' table?
SELECT event_city, COUNT(id) AS num_events_with_50_plus_attendees FROM events WHERE num_attendees > 50 GROUP BY event_city;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas (name VARCHAR(255), depth FLOAT, location VARCHAR(255)); INSERT INTO marine_protected_areas (name, depth, location) VALUES ('Galapagos Islands', 2000.0, 'Pacific Ocean'), ('Great Barrier Reef', 500.0, 'Pacific Ocean');
Insert a new record into the marine_protected_areas table with the name 'Coral Sea', depth 1000.0, and location 'Pacific Ocean'
INSERT INTO marine_protected_areas (name, depth, location) VALUES ('Coral Sea', 1000.0, 'Pacific Ocean');
gretelai_synthetic_text_to_sql
CREATE TABLE cosmetics_ingredients (product VARCHAR(255), ingredient VARCHAR(255), safety_rating INTEGER); CREATE TABLE cosmetics (product VARCHAR(255), product_category VARCHAR(255)); CREATE TABLE ingredients (ingredient VARCHAR(255), chemical_class VARCHAR(255)); CREATE VIEW sulfate_shampoo AS SELECT * FROM cosmetics...
Update the safety rating of all records related to shampoo products with the word 'sulfate' in their ingredient list to 3.
UPDATE cosmetics_ingredients SET safety_rating = 3 WHERE product IN (SELECT product FROM sulfate_shampoo);
gretelai_synthetic_text_to_sql
CREATE TABLE vehicles (vehicle_id INT, vehicle_type TEXT); INSERT INTO vehicles (vehicle_id, vehicle_type) VALUES (1, 'Tram'), (2, 'Bus'), (3, 'Train'); CREATE TABLE maintenance (maintenance_id INT, vehicle_id INT, maintenance_date DATE); INSERT INTO maintenance (maintenance_id, vehicle_id, maintenance_date) VALUES (1,...
Delete all records for tram vehicle maintenance older than 3 years.
DELETE FROM maintenance WHERE vehicle_id IN (SELECT vehicle_id FROM vehicles WHERE vehicle_type = 'Tram') AND maintenance_date < DATE_SUB(CURRENT_DATE, INTERVAL 3 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE aid_distribution_asia (family_id INT, region VARCHAR(20), disaster_type VARCHAR(20), amount_aid FLOAT); INSERT INTO aid_distribution_asia (family_id, region, disaster_type, amount_aid) VALUES (1, 'Asia', 'Flood', 5000), (2, 'Asia', 'Earthquake', 7000), (3, 'Asia', 'Flood', 6000), (4, 'Asia', 'Tsunami', 800...
What is the total amount of humanitarian aid distributed in Asia by type of disaster, ordered from the highest to the lowest?
SELECT disaster_type, SUM(amount_aid) as total_aid FROM aid_distribution_asia JOIN disaster_type ON aid_distribution_asia.disaster_type = disaster_type.disaster_type GROUP BY disaster_type ORDER BY total_aid DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE construction_projects_2 (project_id INT, city VARCHAR(20), state VARCHAR(20), value DECIMAL(10,2)); INSERT INTO construction_projects_2 (project_id, city, state, value) VALUES (1, 'San Francisco', 'CA', 1000000.00), (2, 'Los Angeles', 'CA', 2000000.00), (3, 'San Diego', 'CA', 1500000.00);
Get the total value of construction projects in each city in California, grouped by city
SELECT city, SUM(value) FROM construction_projects_2 WHERE state = 'CA' GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (DonationID int, DonorID int, DonationDate date, DonationAmount decimal(10,2)); INSERT INTO Donations (DonationID, DonorID, DonationDate, DonationAmount) VALUES (1, 1, '2020-01-01', 1000.00), (2, 1, '2020-02-01', 1500.00), (3, 2, '2020-01-01', 2000.00), (4, 2, '2020-02-01', 1000.00), (5, 3, '2020...
Find the top 3 donors who have made the largest cumulative donations, and show their donation amounts and rank.
SELECT DonorID, DonationAmount, ROW_NUMBER() OVER (ORDER BY SUM(DonationAmount) DESC) as DonorRank FROM Donations GROUP BY DonorID ORDER BY DonorRank ASC;
gretelai_synthetic_text_to_sql
CREATE TABLE SalesData (SaleID INT, ProductID INT, SaleDate DATE, QuantitySold INT, Gender TEXT, Size INT); INSERT INTO SalesData (SaleID, ProductID, SaleDate, QuantitySold, Gender, Size) VALUES (1, 1001, '2022-01-01', 25, 'Women', 14), (2, 1002, '2022-02-10', 30, 'Men', 32), (3, 1003, '2022-03-20', 20, 'Men', 30), (4,...
How many size 36 garments for women's wear were sold in the last month?
SELECT COUNT(*) FROM SalesData WHERE Gender = 'Women' AND Size = 36 AND SaleDate >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH);
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists biotech;CREATE TABLE if not exists biotech.startups (id INT, name VARCHAR(255), country VARCHAR(255)); INSERT INTO biotech.startups (id, name, country) VALUES (1, 'Genetix', 'USA'), (2, 'BioSense', 'Canada'), (3, 'BioEngine', 'USA');
How many biotech startups are located in each country?
SELECT country, COUNT(*) num_startups FROM biotech.startups GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE waste_generation (sector VARCHAR(20), waste_quantity INT); INSERT INTO waste_generation (sector, waste_quantity) VALUES ('residential', 1500), ('commercial', 2000), ('industrial', 3000);
What is the total waste generated in the residential sector?
SELECT waste_quantity FROM waste_generation WHERE sector = 'residential';
gretelai_synthetic_text_to_sql
CREATE TABLE mining_sites (site_id INT, site_name TEXT, location TEXT);
List all the unique mining sites located in the African continent.
SELECT DISTINCT site_name FROM mining_sites WHERE location LIKE 'Africa%';
gretelai_synthetic_text_to_sql
CREATE TABLE incident_duration (id INT, incident_type VARCHAR(255), incident_time TIMESTAMP, duration INT);
What is the total duration of security incidents related to 'unpatched systems' in the last month?
SELECT SUM(duration) as total_duration FROM incident_duration WHERE incident_type = 'unpatched systems' AND incident_time >= DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 1 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE fabric_source (source_id INT, country VARCHAR(255), fabric_type VARCHAR(255), quantity INT, is_sustainable BOOLEAN); INSERT INTO fabric_source (source_id, country, fabric_type, quantity, is_sustainable) VALUES (1, 'USA', 'Organic Cotton', 500, true), (2, 'China', 'Recycled Polyester', 800, true), (3, 'Indi...
What is the total quantity of sustainable fabric sourced from each country?
SELECT country, SUM(quantity) FROM fabric_source WHERE is_sustainable = true GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE general_atomics_contracts (contract_id INT, project_id INT, contract_value DECIMAL(10,2)); CREATE TABLE aerojet_rocketry_contracts (contract_id INT, project_id INT, contract_value DECIMAL(10,2));
What is the difference between the total contract values for the defense projects with General Atomics and Aerojet Rocketdyne?
SELECT (SELECT SUM(contract_value) FROM general_atomics_contracts) - (SELECT SUM(contract_value) FROM aerojet_rocketry_contracts) as difference;
gretelai_synthetic_text_to_sql
CREATE TABLE projects (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), capacity FLOAT, renewable_energy_source VARCHAR(255)); CREATE TABLE sustainability_reports (id INT PRIMARY KEY, project_id INT, report_date DATE, co2_emissions INT, energy_efficiency_score INT);
What are the average CO2 emissions and energy efficiency scores for projects that use wind energy?
SELECT s.project_id, AVG(s.co2_emissions) as avg_co2, AVG(s.energy_efficiency_score) as avg_efficiency FROM sustainability_reports s JOIN projects p ON s.project_id = p.id WHERE p.renewable_energy_source = 'Wind' GROUP BY s.project_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, Gender VARCHAR(10), HireDate DATE, Department VARCHAR(50), Training VARCHAR(50)); INSERT INTO Employees (EmployeeID, Gender, HireDate, Department, Training) VALUES (1, 'Male', '2020-01-01', 'HR', 'Diversity and Inclusion'); INSERT INTO Employees (EmployeeID, Gender, HireDate, Dep...
How many employees have been trained in diversity and inclusion in each department?
SELECT Department, COUNT(*) as Num_Trained_Employees FROM Employees WHERE Training = 'Diversity and Inclusion' GROUP BY Department;
gretelai_synthetic_text_to_sql
CREATE TABLE production (year INT, element VARCHAR(10), quantity INT); INSERT INTO production (year, element, quantity) VALUES (2015, 'Gadolinium', 5000), (2016, 'Gadolinium', 5500);
What is the minimum production quantity of Gadolinium since 2015?
SELECT MIN(quantity) FROM production WHERE element = 'Gadolinium' AND year >= 2015
gretelai_synthetic_text_to_sql
CREATE TABLE hospital_data (hospital_id INT, hospital_name TEXT, type TEXT, city TEXT); INSERT INTO hospital_data (hospital_id, hospital_name, type, city) VALUES (1, 'Hospital A', 'Public', 'San Francisco'), (2, 'Hospital B', 'Private', 'San Francisco'), (3, 'Hospital C', 'Public', 'Los Angeles'), (4, 'Hospital D', 'Pr...
How many public hospitals are there in the city of San Francisco?
SELECT COUNT(*) FROM hospital_data WHERE type = 'Public' AND city = 'San Francisco';
gretelai_synthetic_text_to_sql
CREATE TABLE SustainableFactories (id INT, factory_name TEXT, num_garments INT); INSERT INTO SustainableFactories (id, factory_name, num_garments) VALUES (1, 'Eco-Friendly Factory 1', 500), (2, 'Sustainable Factory 2', 700), (3, 'Green Factory 3', 800), (4, 'Sustainable Factory 4', 600);
Which factories have produced the most garments using sustainable practices?
SELECT factory_name, SUM(num_garments) FROM SustainableFactories GROUP BY factory_name ORDER BY SUM(num_garments) DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE TV_VIEWERS (id INT, title VARCHAR(100), genre VARCHAR(50), viewers INT, view_date DATE); INSERT INTO TV_VIEWERS (id, title, genre, viewers, view_date) VALUES (1, 'The Mandalorian', 'Sci-fi', 5000, '2022-01-01'), (2, 'Breaking Bad', 'Drama', 6000, '2021-12-31'), (3, 'Friends', 'Comedy', 4000, '2021-12-31');
What's the viewership trend for TV shows by genre in Q1 and Q4?
SELECT genre, EXTRACT(QUARTER FROM view_date) as quarter, AVG(viewers) as avg_viewers FROM TV_VIEWERS GROUP BY genre, quarter;
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (artist_id INT, artist VARCHAR(255)); CREATE TABLE Streams (stream_id INT, artist_id INT, stream_date DATE, streams INT); INSERT INTO Artists (artist_id, artist) VALUES (1, 'Taylor Swift'), (2, 'BTS'), (3, 'Drake'); INSERT INTO Streams (stream_id, artist_id, stream_date, streams) VALUES (1, 1, '202...
How many streams does each artist have on average per day?
SELECT artist, AVG(streams / NULLIF(DATEDIFF(day, stream_date, LEAD(stream_date) OVER (PARTITION BY artist_id ORDER BY stream_date)), 0)) as avg_daily_streams FROM Streams JOIN Artists ON Streams.artist_id = Artists.artist_id GROUP BY artist;
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (ArtistID int, Name varchar(50), Nationality varchar(50)); INSERT INTO Artists VALUES (1, 'Pablo Picasso', 'Spanish'); INSERT INTO Artists VALUES (2, 'Andy Warhol', 'American'); INSERT INTO Artists VALUES (3, 'Mohammed Ali', 'Egyptian'); INSERT INTO Artists VALUES (4, 'Anju Jain', 'Indian'); INSERT...
What are the total sales of artwork created by artists from Europe?
SELECT SUM(Artworks.Sales) FROM Artworks JOIN Artists ON Artworks.ArtistID = Artists.ArtistID WHERE Artists.Nationality = 'French';
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists rural_development; use rural_development; CREATE TABLE IF NOT EXISTS agricultural_innovation (id INT, name VARCHAR(255), cost FLOAT, success BOOLEAN, PRIMARY KEY (id)); INSERT INTO agricultural_innovation (id, name, cost, success) VALUES (1, 'Precision Agriculture', 300000.00, true), (2, 'Dr...
Delete all records with a success status of false from the 'agricultural_innovation' table.
DELETE FROM agricultural_innovation WHERE success = false;
gretelai_synthetic_text_to_sql
CREATE TABLE Dishes (dish_id INT, dish_name VARCHAR(50), is_vegetarian BOOLEAN, price DECIMAL(5,2), region VARCHAR(50)); INSERT INTO Dishes (dish_id, dish_name, is_vegetarian, price, region) VALUES (1, 'Quinoa Salad', true, 12.99, 'Chicago'), (2, 'Cheeseburger', false, 9.99, 'NY'), (3, 'Veggie Burger', true, 10.99, 'LA...
What is the total price of vegetarian dishes served in the Chicago region?
SELECT SUM(price) FROM Dishes WHERE is_vegetarian = true AND region = 'Chicago';
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, category VARCHAR(20), price DECIMAL(5,2)); INSERT INTO products (product_id, category, price) VALUES (1, 'Natural', 25.99), (2, 'Organic', 30.49), (3, 'Natural', 19.99), (4, 'Conventional', 15.99);
What is the difference in price between the most expensive and least expensive product in each category?
SELECT category, MAX(price) - MIN(price) as price_difference FROM products GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE berlin_buses (bus_id INT, speed FLOAT, location VARCHAR(20));
What is the average speed of public buses in Berlin?
SELECT AVG(speed) FROM berlin_buses;
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tours (tour_id INT, tour_name TEXT, city TEXT, has_3D_VR BOOLEAN); INSERT INTO virtual_tours (tour_id, tour_name, city, has_3D_VR) VALUES (1, 'Museum Tour', 'New York', true), (2, 'Historical Site Tour', 'Paris', false);
What is the percentage of virtual tours with 3D or VR capabilities?
SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM virtual_tours)) AS percentage FROM virtual_tours WHERE has_3D_VR = true;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, DonorAge INT, DonationAmount DECIMAL); INSERT INTO Donors (DonorID, DonorAge, DonationAmount) VALUES (1, 35, 500.00), (2, 42, 350.00), (3, 28, 700.00);
What is the average donation amount by age group?
SELECT AVG(DonationAmount) as AverageDonation, FLOOR(DonorAge / 10) * 10 as AgeGroup FROM Donors GROUP BY AgeGroup;
gretelai_synthetic_text_to_sql
CREATE TABLE Sustainable_Tourism (Destination VARCHAR(50), CO2_Emissions INT, Water_Usage INT); INSERT INTO Sustainable_Tourism (Destination, CO2_Emissions, Water_Usage) VALUES ('Bali', 120, 3500), ('Kyoto', 80, 2000), ('Rio de Janeiro', 150, 4000), ('Cairo', 200, 5000);
Find all destinations in the Sustainable_Tourism table with CO2 emissions higher than the average.
SELECT Destination FROM Sustainable_Tourism WHERE CO2_Emissions > (SELECT AVG(CO2_Emissions) FROM Sustainable_Tourism);
gretelai_synthetic_text_to_sql
CREATE TABLE RugbyMatches (MatchID INT, HomeTeam VARCHAR(50), AwayTeam VARCHAR(50), HomeScore INT, AwayScore INT);
What is the total number of matches played in the RugbyMatches table, for matches where the home team won by more than 10 points?
SELECT COUNT(*) FROM RugbyMatches WHERE HomeScore > AwayScore + 10;
gretelai_synthetic_text_to_sql
CREATE TABLE Water_Usage (Id INT, Mine_Site VARCHAR(50), Usage INT, Date DATE); INSERT INTO Water_Usage (Id, Mine_Site, Usage, Date) VALUES (1, 'SiteA', 5200, '2020-01-01'); INSERT INTO Water_Usage (Id, Mine_Site, Usage, Date) VALUES (2, 'SiteB', 5600, '2020-01-02');
What is the average water usage per day at each mine site in January 2020, only showing sites with usage over 5000 liters per day?
SELECT Mine_Site, AVG(Usage) as Average_Water_Usage FROM Water_Usage WHERE Date >= '2020-01-01' AND Date < '2020-02-01' GROUP BY Mine_Site HAVING Average_Water_Usage > 5000;
gretelai_synthetic_text_to_sql
CREATE TABLE contractors(id INT, company VARCHAR(50), num_contracts INT, contract_date DATE);
Find the defense contractors with the lowest number of awarded contracts in the last 5 years.
SELECT company, num_contracts FROM (SELECT company, COUNT(*) AS num_contracts FROM contractors WHERE contract_date >= DATE(NOW()) - INTERVAL 5 YEAR GROUP BY company ORDER BY num_contracts ASC) AS bottom_contractors;
gretelai_synthetic_text_to_sql
CREATE TABLE program_data (program_id INT, sector TEXT, donation DECIMAL(10,2), volunteer_hours INT); INSERT INTO program_data (program_id, sector, donation, volunteer_hours) VALUES (1, 'education', 1500.00, 500), (2, 'health', 2000.00, 300), (3, 'education', 1000.00, 700);
What are the total donations and volunteer hours for programs in the education sector?
SELECT SUM(donation) as total_donations, SUM(volunteer_hours) as total_volunteer_hours FROM program_data WHERE sector = 'education';
gretelai_synthetic_text_to_sql
CREATE TABLE labor_violations_us (id INT, report_date DATE, state TEXT, incident_count INT); INSERT INTO labor_violations_us (id, report_date, state, incident_count) VALUES (1, '2022-01-01', 'California', 25); INSERT INTO labor_violations_us (id, report_date, state, incident_count) VALUES (2, '2022-02-01', 'Texas', 30)...
What is the average number of labor rights violation incidents per month in the past year for each state in the US?
SELECT state, AVG(incident_count) as avg_incidents FROM labor_violations_us WHERE report_date >= DATE_TRUNC('year', NOW() - INTERVAL '1 year') GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE orders (id INT, order_type TEXT, order_date DATE);
Calculate the percentage of orders that were takeout in the month of February 2022.
SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM orders WHERE order_date BETWEEN '2022-02-01' AND '2022-02-28')) as pct_takeout FROM orders WHERE order_type = 'takeout' AND order_date BETWEEN '2022-02-01' AND '2022-02-28';
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (ArtistID INT PRIMARY KEY, Name TEXT); CREATE TABLE Artworks (ArtworkID INT PRIMARY KEY, Title TEXT, ArtistID INT, Category TEXT, Quantity INT);
Which artists have created more than 10 works in the 'Surrealism' category?
SELECT Artists.Name FROM Artists INNER JOIN Artworks ON Artists.ArtistID = Artworks.ArtistID WHERE Artworks.Category = 'Surrealism' GROUP BY Artists.Name HAVING SUM(Artworks.Quantity) > 10;
gretelai_synthetic_text_to_sql