context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE user_posts (user_id INT, post_topic VARCHAR(50), job_title VARCHAR(50)); INSERT INTO user_posts (user_id, post_topic, job_title) VALUES (1, 'sustainability', 'Environmental Scientist'), (2, 'technology', 'Software Engineer'), (3, 'sustainability', 'Sustainability Consultant'), (4, 'education', 'Teacher'), ... | What are the unique job titles of users who have engaged with posts about sustainability but have not applied to any jobs in the sustainability sector? | SELECT job_title FROM user_posts WHERE post_topic = 'sustainability' AND user_id NOT IN (SELECT user_id FROM user_posts WHERE job_title LIKE '%sustainability%'); | gretelai_synthetic_text_to_sql |
CREATE TABLE regions (id INT, name VARCHAR(50), co2_emissions INT); INSERT INTO regions (id, name, co2_emissions) VALUES (1, 'North', 5000), (2, 'South', 7000), (3, 'East', 9000), (4, 'West', 8000); | What is the total CO2 emissions for each region? | SELECT name, SUM(co2_emissions) as total_emissions FROM regions GROUP BY name; | gretelai_synthetic_text_to_sql |
CREATE TABLE systems (system_id INT PRIMARY KEY, system_name VARCHAR(255), last_updated TIMESTAMP);CREATE TABLE malware_events (event_id INT PRIMARY KEY, system_id INT, event_date TIMESTAMP, malware_type VARCHAR(50)); | Which systems have been affected by ransomware in the past month? | SELECT s.system_name FROM systems s JOIN malware_events m ON s.system_id = m.system_id WHERE m.event_date >= NOW() - INTERVAL 1 MONTH AND m.malware_type = 'ransomware'; | gretelai_synthetic_text_to_sql |
CREATE TABLE boroughs (bid INT, borough_name VARCHAR(255)); CREATE TABLE events (eid INT, bid INT, event_date DATE); | How many community policing events occurred in each borough in 2020? | SELECT b.borough_name, COUNT(e.eid) FROM boroughs b INNER JOIN events e ON b.bid = e.bid WHERE YEAR(e.event_date) = 2020 GROUP BY b.borough_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE anti_discrimination_training (id INT, worker_id INT, training_date DATE); INSERT INTO anti_discrimination_training (id, worker_id, training_date) VALUES (1, 789, '2021-04-01'), (2, 789, '2021-06-15'); CREATE TABLE community_health_workers (id INT, name VARCHAR(50), region VARCHAR(50)); INSERT INTO communit... | What is the percentage of community health workers in Florida who have received anti-discrimination training? | SELECT 100.0 * COUNT(DISTINCT anti_discrimination_training.worker_id) / COUNT(DISTINCT community_health_workers.id) FROM anti_discrimination_training RIGHT JOIN community_health_workers ON anti_discrimination_training.worker_id = community_health_workers.id WHERE community_health_workers.region = 'Florida'; | gretelai_synthetic_text_to_sql |
CREATE TABLE events (event_id INT, event_name VARCHAR(50), event_date DATE, event_discipline VARCHAR(20)); CREATE TABLE event_attendance (attendee_id INT, event_id INT, attendance INT); CREATE TABLE funding_sources (funding_id INT, event_id INT, source_name VARCHAR(50), funding_amount DECIMAL(10,2)); INSERT INTO events... | How many events in each art discipline had an attendance of over 500 people in the past year, and what is the total funding received by these events? | SELECT e.event_discipline, COUNT(e.event_id) AS event_count, SUM(fs.funding_amount) AS total_funding FROM events e INNER JOIN event_attendance ea ON e.event_id = ea.event_id INNER JOIN funding_sources fs ON e.event_id = fs.event_id WHERE e.event_date >= DATEADD(year, -1, GETDATE()) AND ea.attendance > 500 GROUP BY e.ev... | gretelai_synthetic_text_to_sql |
CREATE TABLE Agricultural_Innovation(hectare_id INT, hectare_area FLOAT, country VARCHAR(50), fertilizer_used FLOAT); INSERT INTO Agricultural_Innovation(hectare_id, hectare_area, country, fertilizer_used) VALUES (1, 2.5, 'Australia', 200), (2, 3.0, 'New Zealand', 250); | What is the maximum and average amount of fertilizer used per hectare in the 'Agricultural Innovation' program in 'Oceania'? | SELECT MAX(fertilizer_used) as max_fertilizer_used, AVG(fertilizer_used) as avg_fertilizer_used FROM Agricultural_Innovation WHERE country = 'Oceania'; | gretelai_synthetic_text_to_sql |
CREATE TABLE field_sensors (field_id INT, sensor_type VARCHAR(20), value FLOAT, timestamp TIMESTAMP); INSERT INTO field_sensors (field_id, sensor_type, value, timestamp) VALUES (4, 'temperature', 25.5, '2023-02-15 10:00:00'), (4, 'humidity', 70.0, '2023-02-15 10:00:00'); | Find the maximum temperature and humidity for the crops in field 4 during the last 7 days. | SELECT field_id, MAX(value) FROM field_sensors WHERE sensor_type IN ('temperature', 'humidity') AND timestamp >= NOW() - INTERVAL 7 DAY GROUP BY field_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE cuisine (id INT, type VARCHAR(255)); INSERT INTO cuisine (id, type) VALUES (1, 'Italian'), (2, 'Mexican'), (3, 'Chinese'); CREATE TABLE restaurant (id INT, name VARCHAR(255), cuisine_id INT); INSERT INTO restaurant (id, name, cuisine_id) VALUES (1, 'Pizzeria', 1), (2, 'Taco House', 2), (3, 'Wok Palace', 3)... | Show the total revenue for each cuisine type | SELECT c.type, SUM(m.price * m.daily_sales) as revenue FROM menu m JOIN restaurant r ON m.restaurant_id = r.id JOIN cuisine c ON r.cuisine_id = c.id GROUP BY c.type; | gretelai_synthetic_text_to_sql |
CREATE TABLE podcasts (id INT, title VARCHAR(255), publish_date DATE, location VARCHAR(50)); INSERT INTO podcasts (id, title, publish_date, location) VALUES (1, 'Podcast1', '2022-06-01', 'Brazil'), (2, 'Podcast2', '2021-08-05', 'Brazil'), (3, 'Podcast3', '2022-01-03', 'Brazil'); | How many podcasts were published in Brazil in the last year? | SELECT COUNT(*) FROM podcasts WHERE location = 'Brazil' AND publish_date BETWEEN DATE_SUB(CURDATE(), INTERVAL 1 YEAR) AND CURDATE(); | gretelai_synthetic_text_to_sql |
CREATE TABLE Programs (ProgramID INT, ProgramName VARCHAR(50)); INSERT INTO Programs (ProgramID, ProgramName) VALUES (1, 'Food Bank'), (2, 'Elderly Care'), (3, 'Youth Mentoring'); CREATE TABLE Donors (DonorID INT, DonorName VARCHAR(50)); INSERT INTO Donors (DonorID, DonorName) VALUES (1001, 'John Doe'), (1002, 'Jane Do... | Who are the top 5 donors for the 'Food Bank' program? | SELECT d.DonorName, SUM(d.DonationAmount) AS TotalDonationAmount FROM Donors d JOIN Donations don ON d.DonorID = don.DonorID WHERE don.ProgramID = 1 GROUP BY d.DonorName ORDER BY TotalDonationAmount DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE Projects (id INT, division VARCHAR(10)); INSERT INTO Projects (id, division) VALUES (1, 'water'), (2, 'transport'), (3, 'energy'); CREATE TABLE TransportProjects (id INT, project_id INT, length DECIMAL(10,2)); INSERT INTO TransportProjects (id, project_id, length) VALUES (1, 2, 500), (2, 2, 550), (3, 3, 60... | What is the average bridge length in the transport division? | SELECT AVG(t.length) FROM TransportProjects t JOIN Projects p ON t.project_id = p.id WHERE p.division = 'transport'; | gretelai_synthetic_text_to_sql |
CREATE TABLE policies (policy_number INT, policy_type VARCHAR(50), coverage_amount INT, policy_start_date DATE); INSERT INTO policies (policy_number, policy_type, coverage_amount, policy_start_date) VALUES (12345, 'Auto', 50000, '2022-01-01'); INSERT INTO policies (policy_number, policy_type, coverage_amount, policy_st... | What is the policy number, policy type, and coverage amount for policies with a policy start date within the last 30 days? | SELECT policy_number, policy_type, coverage_amount FROM policies WHERE policy_start_date >= CURDATE() - INTERVAL 30 DAY; | gretelai_synthetic_text_to_sql |
CREATE TABLE trades (trade_id INT PRIMARY KEY, customer_id INT, trade_date DATE, security_symbol VARCHAR(10), quantity INT); | Insert a new row into the 'trades' table with a trade ID of 123, a customer ID of 456, a trade date of '2022-01-01', a security symbol of 'ABC', and a quantity of 100 | INSERT INTO trades (trade_id, customer_id, trade_date, security_symbol, quantity) VALUES (123, 456, '2022-01-01', 'ABC', 100); | gretelai_synthetic_text_to_sql |
CREATE SCHEMA IF NOT EXISTS MilitaryTech; CREATE TABLE IF NOT EXISTS MilitaryTech.Tech_Expenditures (expenditure_id INT, tech_name VARCHAR(255), year INT, amount DECIMAL(10, 2), description TEXT); INSERT INTO MilitaryTech.Tech_Expenditures (expenditure_id, tech_name, year, amount, description) VALUES (1, 'Artificial In... | Get the details of military technology expenditures for 'Artificial Intelligence' in the 'MilitaryTech' schema. | SELECT * FROM MilitaryTech.Tech_Expenditures WHERE tech_name = 'Artificial Intelligence'; | gretelai_synthetic_text_to_sql |
CREATE TABLE concert_sales (id INT, city VARCHAR, price DECIMAL); | What is the average ticket price for concerts in the city of Chicago? | SELECT AVG(price) FROM concert_sales WHERE city = 'Chicago'; | gretelai_synthetic_text_to_sql |
CREATE TABLE affordable_housing (id INT, city VARCHAR(20), price INT); INSERT INTO affordable_housing (id, city, price) VALUES (1, 'Miami', 200000), (2, 'Houston', 150000), (3, 'Dallas', 180000); | What is the minimum property price in the 'affordable_housing' table? | SELECT MIN(price) FROM affordable_housing; | gretelai_synthetic_text_to_sql |
CREATE TABLE FoodInspections (InspectionID int, RestaurantID varchar(50), InspectionDate date); | Delete records from the FoodInspections table where the InspectionDate is older than 90 days from today. | DELETE FI FROM FoodInspections FI WHERE DATEDIFF(day, FI.InspectionDate, GETDATE()) > 90; | gretelai_synthetic_text_to_sql |
CREATE TABLE Patients (ID INT, Age INT, Disease VARCHAR(20), State VARCHAR(20)); INSERT INTO Patients (ID, Age, Disease, State) VALUES (1, 45, 'Diabetes', 'New York'); | What is the percentage of patients with Diabetes in New York who are over 40 years old? | SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM Patients WHERE Disease = 'Diabetes' AND State = 'New York')) FROM Patients WHERE Age > 40 AND Disease = 'Diabetes' AND State = 'New York'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Districts (DId INT, Name VARCHAR(50)); CREATE TABLE EmergencyResponses (ResponseId INT, DId INT, Cost INT); CREATE TABLE DisasterRecovery (RecoveryId INT, DId INT, Cost INT); | What is the total cost of emergency responses and disaster recovery efforts in each district, sorted by the total cost in descending order? | SELECT D.Name, SUM(ER.Cost) + SUM(DR.Cost) AS TotalCost FROM Districts D LEFT JOIN EmergencyResponses ER ON D.DId = ER.DId LEFT JOIN DisasterRecovery DR ON D.DId = DR.DId GROUP BY D.Name ORDER BY TotalCost DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE platforms (platform_id INT, platform_name VARCHAR(255), field_name VARCHAR(255), started_production BOOLEAN); INSERT INTO platforms (platform_id, platform_name, field_name, started_production) VALUES (1, 'A', 'Field A', true), (2, 'B', 'Field B', false); | List all the platforms, including the ones that have not started production yet, with their corresponding field names | SELECT platform_name, field_name FROM platforms; | gretelai_synthetic_text_to_sql |
CREATE TABLE daily_revenue(menu_category VARCHAR(20), revenue DECIMAL(10, 2), order_date DATE); INSERT INTO daily_revenue(menu_category, revenue, order_date) VALUES ('Dinner', 7000, '2021-04-01'), ('Snacks', 3000, '2021-04-01'), ('Dinner', 6000, '2021-04-02'), ('Snacks', 3500, '2021-04-02'); | Find the daily average revenue for 'Dinner' and 'Snacks' menu categories in the last month. | SELECT menu_category, AVG(revenue) AS avg_daily_revenue FROM daily_revenue WHERE order_date >= (SELECT DATE(CURRENT_DATE - INTERVAL 30 DAY)) AND menu_category IN ('Dinner', 'Snacks') GROUP BY menu_category; | gretelai_synthetic_text_to_sql |
CREATE TABLE Exhibitions (ExhibitionID INT, Gallery VARCHAR(100), ArtworkID INT, Country VARCHAR(50), Year INT); | How many exhibitions were held in each country since 2000? | SELECT Exhibitions.Country, COUNT(DISTINCT Exhibitions.ExhibitionID) AS ExhibitionCount FROM Exhibitions WHERE Exhibitions.Year >= 2000 GROUP BY Exhibitions.Country; | gretelai_synthetic_text_to_sql |
CREATE TABLE office (office_id INT, office_state VARCHAR(50), program_name VARCHAR(50)); CREATE TABLE staff (staff_id INT, staff_name VARCHAR(50), role VARCHAR(50)); INSERT INTO office (office_id, office_state, program_name) VALUES (1, 'California', 'Assistive Technology'); INSERT INTO staff (staff_id, staff_name, role... | Who is the policy advocate for the 'Assistive Technology' program in the 'California' office? | SELECT staff_name FROM office o JOIN staff s ON o.office_state = s.staff_name WHERE o.program_name = 'Assistive Technology' AND s.role = 'Policy Advocate'; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, product_name VARCHAR(100), product_type VARCHAR(50), vegan BOOLEAN, cruelty_free BOOLEAN, rating FLOAT); | What is the average rating of skincare products that are vegan and have not been tested on animals? | SELECT AVG(rating) FROM products WHERE product_type = 'skincare' AND vegan = TRUE AND cruelty_free = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE customers (customer_id INT, customer_name VARCHAR(50), account_number VARCHAR(20), primary_contact VARCHAR(50)); CREATE TABLE transactions (transaction_id INT, customer_id INT, transaction_type VARCHAR(20), transaction_amount DECIMAL(10,2), transaction_date DATE); | What is the number of transactions by customer name for the month of April 2022? | SELECT c.customer_name, COUNT(t.transaction_id) as number_of_transactions FROM customers c JOIN transactions t ON c.customer_id = t.customer_id WHERE transaction_date BETWEEN '2022-04-01' AND '2022-04-30' GROUP BY c.customer_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE health_metrics (id INT, species VARCHAR(50), metric FLOAT); INSERT INTO health_metrics (id, species, metric) VALUES (1, 'Tilapia', 75.0), (2, 'Catfish', 80.0), (3, 'Salmon', 60.0); | What is the average health metric for all species? | SELECT AVG(metric) FROM health_metrics; | gretelai_synthetic_text_to_sql |
CREATE TABLE property_type (property_id INT, city VARCHAR(50), model VARCHAR(50)); INSERT INTO property_type VALUES (1, 'Seattle', 'co-housing'), (2, 'Seattle', 'rental'), (3, 'Portland', 'co-housing'); | What is the total number of properties in Seattle with a co-housing model? | SELECT COUNT(*) FROM property_type WHERE city = 'Seattle' AND model = 'co-housing'; | gretelai_synthetic_text_to_sql |
CREATE TABLE environmental_impact (country VARCHAR(20), element VARCHAR(10), impact FLOAT); INSERT INTO environmental_impact VALUES ('China', 'Samarium', 6.1), ('China', 'Gadolinium', 7.6), ('United States', 'Samarium', 2.7), ('United States', 'Gadolinium', 3.5), ('Australia', 'Samarium', 2.2), ('Australia', 'Gadoliniu... | Compare the environmental impact of Samarium and Gadolinium production | SELECT element, impact FROM environmental_impact WHERE country = 'China' UNION SELECT element, impact FROM environmental_impact WHERE country = 'United States' ORDER BY element, impact; | gretelai_synthetic_text_to_sql |
CREATE TABLE CulturallyCompetentHealthcareProviders (ProviderID INT, FirstName VARCHAR(50), LastName VARCHAR(50), Culture VARCHAR(50), Specialty VARCHAR(50)); INSERT INTO CulturallyCompetentHealthcareProviders (ProviderID, FirstName, LastName, Culture, Specialty) VALUES (1, 'Ali', 'Ahmed', 'Arabic', 'Pediatrics'); | What are the unique combinations of Culture and Specialty for CulturallyCompetentHealthcareProviders table? | SELECT Culture, Specialty FROM CulturallyCompetentHealthcareProviders; | gretelai_synthetic_text_to_sql |
CREATE TABLE Underwriting (policy_number INT, coverage_amount INT, underwriter VARCHAR(20)); INSERT INTO Underwriting (policy_number, coverage_amount, underwriter) VALUES (123, 50000, 'Jane Smith'), (234, 75000, 'John Smith'), (345, 30000, 'John Smith'); | What is the policy number, coverage amount, and effective date for policies underwritten by 'John Smith'? | SELECT policy_number, coverage_amount, effective_date FROM Underwriting JOIN Policy ON Underwriting.policy_number = Policy.policy_number WHERE underwriter = 'John Smith'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (DonationID int, Amount decimal(10,2), PaymentMethod varchar(50), DonationDate date, Program varchar(50)); INSERT INTO Donations (DonationID, Amount, PaymentMethod, DonationDate, Program) VALUES (1, 100.00, 'Credit Card', '2021-01-01', 'Education'); INSERT INTO Donations (DonationID, Amount, Paym... | Which program had the highest average donation amount? | SELECT Program, AVG(Amount) as AverageDonationAmount FROM Donations GROUP BY Program ORDER BY AverageDonationAmount DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Founding_Data (company_name VARCHAR(50), founding_year INT, founding_location VARCHAR(50)); INSERT INTO Founding_Data (company_name, founding_year, founding_location) VALUES ('Waystar Royco', 1980, 'New York'); INSERT INTO Founding_Data (company_name, founding_year, founding_location) VALUES ('Pied Piper',... | What are the founding years and locations for companies based in Texas? | SELECT company_name, founding_year FROM Founding_Data WHERE founding_location = 'Texas'; | gretelai_synthetic_text_to_sql |
CREATE TABLE CityBudget (CityName VARCHAR(50), Department VARCHAR(50), Budget INT); INSERT INTO CityBudget (CityName, Department, Budget) VALUES ('CityA', 'Parks', 5000000), ('CityA', 'Roads', 7000000), ('CityB', 'Parks', 6000000), ('CityB', 'Roads', 8000000); | What is the difference in budget between consecutive departments in each city? | SELECT CityName, Department, LAG(Budget) OVER(PARTITION BY CityName ORDER BY Department) as PreviousBudget, Budget - LAG(Budget) OVER(PARTITION BY CityName ORDER BY Department) as BudgetDifference FROM CityBudget; | gretelai_synthetic_text_to_sql |
CREATE TABLE port_updates (update_id INT, port_name VARCHAR(50), total_cargo INT, update_date DATE); INSERT INTO port_updates VALUES (1, 'Port of Shanghai', 43032442, '2022-02-15'); INSERT INTO port_updates VALUES (2, 'Port of Singapore', 37439402, '2022-03-20'); INSERT INTO port_updates VALUES (3, 'Port of Shenzhen', ... | Which ports have had a decrease in cargo handling in the last month? | SELECT port_name FROM port_updates WHERE total_cargo < LAG(total_cargo) OVER (PARTITION BY port_name ORDER BY update_date); | gretelai_synthetic_text_to_sql |
CREATE TABLE rural_infrastructure_projects (id INT, project_name VARCHAR(50), country VARCHAR(50), start_date DATE); INSERT INTO rural_infrastructure_projects (id, project_name, country, start_date) VALUES (1, 'Rajiv Gandhi Rural Electrification Program', 'India', '2010-04-01'), (2, 'BharatNet Rural Broadband Initiativ... | List all rural infrastructure projects in India and their respective start dates. | SELECT project_name, start_date FROM rural_infrastructure_projects WHERE country = 'India'; | gretelai_synthetic_text_to_sql |
CREATE TABLE VisitorsAndSites (id INT, site_name VARCHAR(255), continent VARCHAR(255), visitors INT); INSERT INTO VisitorsAndSites (id, site_name, continent, visitors) VALUES (1, 'Machu Picchu', 'South America', 1200000), (2, 'Angkor Wat', 'Asia', 2000000), (3, 'Petra', 'Asia', 800000); | What is the total number of visitors and the number of heritage sites in each continent? | SELECT continent, COUNT(*), SUM(visitors) FROM VisitorsAndSites GROUP BY continent; | gretelai_synthetic_text_to_sql |
CREATE TABLE Crops (id INT, name VARCHAR(50), yield INT, farm_id INT); INSERT INTO Crops (id, name, yield, farm_id) VALUES (1, 'Corn', 120, 1); INSERT INTO Crops (id, name, yield, farm_id) VALUES (2, 'Soybeans', 50, 1); INSERT INTO Crops (id, name, yield, farm_id) VALUES (3, 'Wheat', 75, 2); | What is the average yield of soybeans grown in the USA? | SELECT AVG(yield) FROM Crops WHERE name = 'Soybeans' AND farm_id IN (SELECT id FROM Farmers WHERE country = 'USA'); | gretelai_synthetic_text_to_sql |
CREATE TABLE AutonomousVehicles(Region VARCHAR(50), Type VARCHAR(50), InUse INT); | How many autonomous vehicles are in use in each region? | SELECT Region, SUM(InUse) FROM AutonomousVehicles GROUP BY Region; | gretelai_synthetic_text_to_sql |
CREATE TABLE campaigns (campaign_id INT, name TEXT, start_date DATE, location TEXT); INSERT INTO campaigns (campaign_id, name, start_date, location) VALUES (1, 'End Stigma', '2017-12-01', 'New York'); INSERT INTO campaigns (campaign_id, name, start_date, location) VALUES (2, 'Mental Health Matters', '2019-06-01', 'Cali... | List all campaigns in Oregon that started before 2017-01-01. | SELECT name, start_date FROM campaigns WHERE location = 'Oregon' AND start_date < '2017-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE arctic_weather (measurement_id INT, measurement_date DATE, temperature DECIMAL(5,2)); INSERT INTO arctic_weather (measurement_id, measurement_date, temperature) VALUES (1, '2020-01-01', 20.5), (2, '2020-01-02', 21.3); | What is the average temperature recorded in the 'arctic_weather' table for each month in 2020, grouped by month? | SELECT AVG(temperature) as avg_temperature, EXTRACT(MONTH FROM measurement_date) as month FROM arctic_weather WHERE EXTRACT(YEAR FROM measurement_date) = 2020 GROUP BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE explainable_ai (record_id INT, algorithm_name TEXT, fairness_score REAL); INSERT INTO explainable_ai VALUES (1, 'SHAP', 0.8), (2, 'LIME', 0.6), (3, 'Anchors', 0.9); | Calculate the number of records in the explainable_ai table with a fairness score greater than 0.8. | SELECT COUNT(*) FROM explainable_ai WHERE fairness_score > 0.8; | gretelai_synthetic_text_to_sql |
CREATE TABLE refugees (id INT, name TEXT, country TEXT, status TEXT); INSERT INTO refugees (id, name, country, status) VALUES (1, 'Sara', 'Syria', 'active'); INSERT INTO refugees (id, name, country, status) VALUES (2, 'Hussein', 'Afghanistan', 'active'); INSERT INTO refugees (id, name, country, status) VALUES (3, 'Mari... | Which countries have our organization supported the most refugees, and how many refugees were supported in each? | SELECT country, COUNT(*) as refugee_count FROM refugees GROUP BY country ORDER BY refugee_count DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE TraditionalArt (art_id INT, art_name VARCHAR(20), art_type VARCHAR(20), last_updated_date DATE); | List all traditional art pieces along with their respective art types and the dates when they were last updated. | SELECT art_name, art_type, last_updated_date FROM TraditionalArt; | gretelai_synthetic_text_to_sql |
CREATE TABLE Patients (PatientID INT, Age INT, Gender VARCHAR(10), Disease VARCHAR(20), Region VARCHAR(20)); INSERT INTO Patients (PatientID, Age, Gender, Disease, Region) VALUES (1, 34, 'Male', 'Influenza', 'Los Angeles'); INSERT INTO Patients (PatientID, Age, Gender, Disease, Region) VALUES (2, 42, 'Female', 'Pneumon... | Find the minimum age of female patients diagnosed with any disease in the 'Florida' region. | SELECT MIN(Age) FROM Patients WHERE Gender = 'Female' AND Region = 'Florida'; | gretelai_synthetic_text_to_sql |
CREATE TABLE vehicle_safety_test (id INT, vehicle_make VARCHAR(50), test_result VARCHAR(10)); INSERT INTO vehicle_safety_test (id, vehicle_make, test_result) VALUES (1, 'Toyota', 'Pass'), (2, 'Toyota', 'Pass'), (3, 'Honda', 'Fail'), (4, 'Tesla', 'Pass'); | Find the number of vehicles that passed the safety test, grouped by make | SELECT vehicle_make, COUNT(*) as passed_count FROM vehicle_safety_test WHERE test_result = 'Pass' GROUP BY vehicle_make; | gretelai_synthetic_text_to_sql |
CREATE TABLE Tours (id INT, name TEXT, country TEXT, type TEXT, revenue INT); INSERT INTO Tours (id, name, country, type, revenue) VALUES (1, 'Cultural Heritage Tour', 'Italy', 'Cultural', 30000); | Find the top 3 countries with the highest revenue from cultural heritage tours? | SELECT country, SUM(revenue) AS total_revenue FROM Tours GROUP BY country ORDER BY total_revenue DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE Producers (id INT, name TEXT, state TEXT);CREATE TABLE Strains (id INT, producer_id INT, name TEXT, year INT); INSERT INTO Producers (id, name, state) VALUES (1, 'Producer A', 'Michigan'); INSERT INTO Strains (id, producer_id, name, year) VALUES (1, 1, 'Strain X', 2021); | How many unique cannabis strains were produced in Michigan in 2021? | SELECT COUNT(DISTINCT s.name) FROM Producers p INNER JOIN Strains s ON p.id = s.producer_id WHERE p.state = 'Michigan' AND s.year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE market_access (drug_name TEXT, year INTEGER, strategy_count INTEGER); INSERT INTO market_access (drug_name, year, strategy_count) VALUES ('DrugD', 2021, 3); | How many market access strategies were implemented for 'DrugD' in 2021? | SELECT strategy_count FROM market_access WHERE drug_name = 'DrugD' AND year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE Users (UserID INT, AgeGroup VARCHAR(20)); INSERT INTO Users (UserID, AgeGroup) VALUES (1, 'Young Adults'), (2, 'Seniors'); CREATE TABLE Workshops (WorkshopID INT, Title VARCHAR(50), UsersAttended INT); INSERT INTO Workshops (WorkshopID, Title, UsersAttended) VALUES (1, 'Watercolor Basics', 30), (2, 'Potter... | What is the total number of art workshops attended by users from the "Young Adults" age group? | SELECT SUM(Workshops.UsersAttended) AS TotalWorkshopsAttended FROM Users INNER JOIN Workshops ON Users.AgeGroup = 'Young Adults' AND Workshops.WorkshopID = Users.UserID; | gretelai_synthetic_text_to_sql |
CREATE TABLE div_initiatives (initiative TEXT, region TEXT); INSERT INTO div_initiatives (initiative, region) VALUES ('digital divide', 'Africa'), ('digital divide', 'Asia'), ('ethical AI', 'Europe'); | How many digital divide initiatives were implemented in Africa? | SELECT COUNT(*) FROM div_initiatives WHERE region = 'Africa'; | gretelai_synthetic_text_to_sql |
CREATE TABLE DanceAttendance (id INT, age_group VARCHAR(10), program VARCHAR(20), attendance INT, attendance_date DATE); INSERT INTO DanceAttendance (id, age_group, program, attendance, attendance_date) VALUES (1, '5-10', 'Ballet', 25, '2022-01-05'), (2, '11-15', 'Hip Hop', 30, '2022-03-12'), (3, '16-20', 'Contemporary... | How many attendees participated in dance programs by age group in H1 2022? | SELECT program, age_group, SUM(attendance) as total_attendance FROM DanceAttendance WHERE YEAR(attendance_date) = 2022 AND MONTH(attendance_date) <= 6 AND program = 'Dance' GROUP BY program, age_group; | gretelai_synthetic_text_to_sql |
CREATE TABLE Festivals (FestivalID INT, Name VARCHAR(255), Genre VARCHAR(255), Location VARCHAR(255), Country VARCHAR(255), Year INT, Revenue INT); INSERT INTO Festivals VALUES (1, 'Lollapalooza', 'Various', 'Grant Park', 'USA', 2022, 2000000); INSERT INTO Festivals VALUES (2, 'Rock in Rio', 'Various', 'City of Rock', ... | What is the total revenue generated by Latin music festivals in South America? | SELECT SUM(Revenue) FROM Festivals WHERE Genre = 'Latin' AND Country = 'South America'; | gretelai_synthetic_text_to_sql |
CREATE TABLE rural_clinic_d (id INT, visit_date DATE); INSERT INTO rural_clinic_d (id, visit_date) VALUES (1, '2022-01-01'), (2, '2022-02-01'), (3, '2022-03-01'); | What is the total number of healthcare visits in the "rural_clinic_d" table? | SELECT COUNT(*) FROM rural_clinic_d; | gretelai_synthetic_text_to_sql |
CREATE TABLE ai_projects (id INT, region VARCHAR(255), budget DECIMAL(10, 2)); INSERT INTO ai_projects (id, region, budget) VALUES (1, 'North America', 1500000.00), (2, 'Asia', 900000.00), (3, 'South America', 600000.00); | What is the total budget for AI projects in Asia? | SELECT SUM(budget) FROM ai_projects WHERE region = 'Asia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE africa_travel_advisories (country VARCHAR(50), advisory TEXT, date DATE); INSERT INTO africa_travel_advisories VALUES ('Kenya', 'Terrorism threat', '2022-01-01'), ('Tanzania', 'Political unrest', '2022-02-15'), ('Nigeria', 'Health warnings', '2021-12-30'), ('Egypt', 'Protests', '2022-03-10'), ('Morocco', '... | What are the unique travel advisories issued for African countries in the past year? | SELECT DISTINCT country, advisory FROM africa_travel_advisories WHERE date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR); | gretelai_synthetic_text_to_sql |
CREATE TABLE tv_show (id INT, title VARCHAR(100), genre VARCHAR(20), production_country VARCHAR(50), runtime INT); INSERT INTO tv_show (id, title, genre, production_country, runtime) VALUES (1, 'Breaking Bad', 'Drama', 'United States', 45); | Find the number of unique genres for TV shows produced in the US and their average runtime. | SELECT COUNT(DISTINCT genre), AVG(runtime) FROM tv_show WHERE production_country = 'United States'; | gretelai_synthetic_text_to_sql |
CREATE TABLE historical_water_consumption (id INT, state VARCHAR(255), year INT, water_consumption FLOAT); INSERT INTO historical_water_consumption (id, state, year, water_consumption) VALUES (1, 'Florida', 2020, 2000000), (2, 'Florida', 2021, 2100000), (3, 'Florida', 2022, 2200000); | What is the water consumption trend in the state of Florida over the past 3 years? | SELECT year, water_consumption FROM historical_water_consumption WHERE state = 'Florida' ORDER BY year; | gretelai_synthetic_text_to_sql |
CREATE TABLE investment (project_location VARCHAR(255), year INT, investment FLOAT); INSERT INTO investment (project_location, year, investment) VALUES ('US', 2021, 5000000), ('Canada', 2021, 3000000), ('Mexico', 2021, 2000000); | What was the total investment in energy efficiency projects in the US in 2021? | SELECT SUM(investment) as total_investment FROM investment WHERE project_location = 'US' AND year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE labor_violations (brand VARCHAR(50), violation_count INT); INSERT INTO labor_violations (brand, violation_count) VALUES ('Brand A', 15), ('Brand B', 5), ('Brand C', 2), ('Brand D', NULL); | Which brands in the ethical fashion database have not been involved in any labor practice violations? | SELECT brand FROM labor_violations WHERE violation_count IS NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID int, FirstName varchar(50), LastName varchar(50)); CREATE TABLE Trainings (TrainingID int, EmployeeID int, TrainingTitle varchar(100), TrainingDate date); INSERT INTO Employees (EmployeeID, FirstName, LastName) VALUES (1, 'John', 'Doe'); INSERT INTO Employees (EmployeeID, FirstName, L... | How many training sessions did each employee attend in descending order? | SELECT EmployeeID, COUNT(*) as SessionCount FROM Trainings GROUP BY EmployeeID ORDER BY SessionCount DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE weather_data (id INT, date DATE, temp FLOAT); | What is the maximum temperature recorded in the Arctic per month? | SELECT MAX(temp) FROM weather_data WHERE date >= DATE_SUB(CURDATE(), INTERVAL 12 MONTH) GROUP BY MONTH(date); | gretelai_synthetic_text_to_sql |
CREATE TABLE threats (threat_id INT, category VARCHAR(50), description TEXT); INSERT INTO threats (threat_id, category, description) VALUES (1, 'Phishing', 'Email-based phishing attack...'), (2, 'Malware', 'New ransomware variant...'), (3, 'Phishing', 'Spear-phishing attack...'), (4, 'Malware', 'Advanced persistent thr... | How many threat intelligence entries are in the 'threats' table? | SELECT COUNT(*) FROM threats; | gretelai_synthetic_text_to_sql |
CREATE TABLE vaccination_stats (id INT PRIMARY KEY, state VARCHAR(50), total_vaccinations INT); INSERT INTO vaccination_stats (id, state, total_vaccinations) VALUES (1, 'California', 25000000); | Update the 'vaccination_stats' table with new data | UPDATE vaccination_stats SET total_vaccinations = 26000000 WHERE state = 'California'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT, FirstName VARCHAR(50), LastName VARCHAR(50), Department VARCHAR(50), HireDate DATE); INSERT INTO Employees (EmployeeID, FirstName, LastName, Department, HireDate) VALUES (1, 'Lena', 'Spencer', 'HR', '2022-01-05'); | Retrieve the ID and name of the employee in the 'Lena Spencer' department with the latest hire date, excluding any employees in the same department with earlier hire dates. | SELECT EmployeeID, FirstName, LastName FROM Employees WHERE Department = (SELECT Department FROM Employees WHERE FirstName = 'Lena' AND LastName = 'Spencer') AND HireDate > ALL(SELECT HireDate FROM Employees E2 WHERE E2.Department = (SELECT Department FROM Employees WHERE FirstName = 'Lena' AND LastName = 'Spencer')); | gretelai_synthetic_text_to_sql |
CREATE TABLE Drivers (DriverID INT, DriverName VARCHAR(50), Service VARCHAR(50)); INSERT INTO Drivers (DriverID, DriverName, Service) VALUES (1, 'John Doe', 'LightRail'), (2, 'Jane Smith', 'Bus'), (3, 'Alice Johnson', 'LightRail'); CREATE TABLE Fares (FareID INT, DriverID INT, FareAmount DECIMAL(5,2)); INSERT INTO Fare... | What is the total fare collected by each driver for the 'LightRail' service? | SELECT d.DriverName, SUM(f.FareAmount) as TotalFare FROM Drivers d JOIN Fares f ON d.DriverID = f.DriverID WHERE d.Service = 'LightRail' GROUP BY d.DriverName; | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists smart_cities (city_id INT, city_name VARCHAR(255), country VARCHAR(255), adoption_score FLOAT); | What is the minimum adoption score for smart cities in the 'smart_cities' table? | SELECT MIN(adoption_score) FROM smart_cities WHERE adoption_score IS NOT NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE mobile_plans (plan_id INT, plan_name VARCHAR(255), monthly_cost DECIMAL(10,2)); INSERT INTO mobile_plans (plan_id, plan_name, monthly_cost) VALUES (1, 'Basic', 30.00), (2, 'Premium', 60.00); | What is the total revenue for each mobile plan in the current quarter? | SELECT plan_name, SUM(monthly_cost) as total_revenue FROM mobile_plans JOIN subscriptions ON mobile_plans.plan_id = subscriptions.plan_id WHERE subscriptions.subscription_date >= DATE_SUB(CURDATE(), INTERVAL QUARTER(CURDATE()) QUARTER) AND subscriptions.subscription_date < DATE_ADD(LAST_DAY(CURDATE()), INTERVAL 1 DAY) ... | gretelai_synthetic_text_to_sql |
CREATE TABLE algorand_transactions (gas_limit INT); | What is the maximum gas limit for transactions on the Algorand network? | SELECT MAX(gas_limit) FROM algorand_transactions; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT, username VARCHAR(50)); CREATE TABLE content (id INT, user_id INT, content_time TIMESTAMP); CREATE TABLE likes (content_id INT, user_id INT, like_time TIMESTAMP); CREATE TABLE comments (content_id INT, user_id INT, comment_time TIMESTAMP); CREATE TABLE shares (content_id INT, user_id INT, sha... | What are the top 5 most active users in terms of content creation and engagement, and what is their total number of interactions? | SELECT users.username, COUNT(content.id) + COUNT(likes.content_id) + COUNT(comments.content_id) + COUNT(shares.content_id) as total_interactions FROM users LEFT JOIN content ON users.id = content.user_id LEFT JOIN likes ON users.id = likes.user_id LEFT JOIN comments ON users.id = comments.user_id LEFT JOIN shares ON us... | gretelai_synthetic_text_to_sql |
CREATE TABLE Buildings (building_id INT, name VARCHAR(50), building_type VARCHAR(50), year_built INT);CREATE TABLE Units (unit_id INT, building_id INT, square_footage INT); | What is the difference in square footage between the largest and smallest units in each building, partitioned by building type and ordered by difference? | SELECT b.building_type, b.name, b.year_built, MAX(u.square_footage) - MIN(u.square_footage) as square_footage_difference FROM Units u JOIN Buildings b ON u.building_id = b.building_id GROUP BY b.building_type, b.name, b.year_built ORDER BY b.building_type, square_footage_difference; | gretelai_synthetic_text_to_sql |
CREATE TABLE ai_projects (sector VARCHAR(20), budget INT); INSERT INTO ai_projects (sector, budget) VALUES ('Education', 200000), ('Healthcare', 500000), ('Finance', 1000000), ('Technology', 300000); | What is the total budget for AI projects in all sectors? | SELECT SUM(budget) FROM ai_projects; | gretelai_synthetic_text_to_sql |
CREATE TABLE restaurant (restaurant_id INT, name TEXT); CREATE TABLE menu (menu_id INT, restaurant_id INT, food_category TEXT, price DECIMAL(5,2)); INSERT INTO restaurant (restaurant_id, name) VALUES (1, 'Restaurant A'); INSERT INTO menu (menu_id, restaurant_id, food_category, price) VALUES (1, 1, 'Appetizers', 7.99), ... | What is the total revenue by food category for a specific restaurant in March 2021? | SELECT m.food_category, SUM(m.price) AS total_revenue FROM menu m JOIN restaurant r ON m.restaurant_id = r.restaurant_id WHERE r.name = 'Restaurant A' AND m.food_category IS NOT NULL AND m.price > 0 AND EXTRACT(MONTH FROM m.order_date) = 3 AND EXTRACT(YEAR FROM m.order_date) = 2021 GROUP BY m.food_category; | gretelai_synthetic_text_to_sql |
CREATE TABLE train_ridership (user_id INT, trip_date DATE, trip_train_line VARCHAR(20)); INSERT INTO train_ridership (user_id, trip_date, trip_train_line) VALUES (1, '2022-03-01', 'Yamanote'), (2, '2022-03-01', 'Chuo'); | Identify the number of public transit users in Tokyo by train line. | SELECT trip_train_line, COUNT(DISTINCT user_id) AS unique_users FROM train_ridership GROUP BY trip_train_line; | gretelai_synthetic_text_to_sql |
CREATE TABLE investors (id INT, gender VARCHAR(50), investments INT); INSERT INTO investors (id, gender, investments) VALUES (1, 'Female', 3), (2, 'Male', 2), (3, 'Female', 4), (4, 'Male', 5); CREATE TABLE investments (id INT, investor_id INT, sector VARCHAR(50), amount FLOAT); INSERT INTO investments (id, investor_id,... | What is the minimum investment in healthcare initiatives by female investors? | SELECT MIN(i.amount) as min_investment FROM investments i JOIN investors j ON i.investor_id = j.id WHERE j.gender = 'Female' AND i.sector = 'Healthcare'; | gretelai_synthetic_text_to_sql |
CREATE TABLE LegalPrecedents ( PrecedentID INT, PrecedentName VARCHAR(50), BillingAmount DECIMAL(10,2) ); INSERT INTO LegalPrecedents (PrecedentID, PrecedentName, BillingAmount) VALUES (1, 'Precedent A', 15000.00), (2, 'Precedent B', 20000.00), (3, 'Precedent C', 12000.00), (4, 'Precedent D', 18000.00), (5, 'Precedent ... | What is the total billing amount for each legal precedent? | SELECT PrecedentName, SUM(BillingAmount) AS TotalBillingAmount FROM LegalPrecedents GROUP BY PrecedentName; | gretelai_synthetic_text_to_sql |
CREATE TABLE employees (id INT, name VARCHAR(50), department VARCHAR(50), salary DECIMAL(10,2)); INSERT INTO employees (id, name, department, salary) VALUES (1, 'John Doe', 'Software Engineer', 150000.00), (2, 'Jane Smith', 'Software Engineer', 220000.00); | What is the average salary of software engineers in the "tech_company" database, excluding those who earn more than $200,000? | SELECT AVG(salary) FROM employees WHERE department = 'Software Engineer' AND salary < 200000.00; | gretelai_synthetic_text_to_sql |
CREATE TABLE Projects (ProjectID int, State varchar(25), Cost decimal(10,2)); INSERT INTO Projects (ProjectID, State, Cost) VALUES (1, 'NY', 150000.00), (2, 'CA', 200000.00), (3, 'TX', 120000.00); | What is the average project cost per state? | SELECT State, AVG(Cost) AS AvgCostPerState FROM Projects GROUP BY State; | gretelai_synthetic_text_to_sql |
CREATE TABLE Missions (name VARCHAR(30), astronaut_name VARCHAR(30), astronaut_gender VARCHAR(10), astronaut_nationality VARCHAR(20)); INSERT INTO Missions (name, astronaut_name, astronaut_gender, astronaut_nationality) VALUES ('Mars Exploration', 'Sally Ride', 'Female', 'United States'); | How many space missions were led by female astronauts from the US? | SELECT COUNT(*) FROM Missions WHERE astronaut_gender = 'Female' AND astronaut_nationality = 'United States'; | gretelai_synthetic_text_to_sql |
CREATE TABLE HybridVehicles (Id INT, Make VARCHAR(50), Model VARCHAR(50), Year INT, Horsepower INT); | What is the minimum horsepower of hybrid vehicles in the 'GreenCar' database produced after 2015? | SELECT MIN(Horsepower) FROM HybridVehicles WHERE Year > 2015; | gretelai_synthetic_text_to_sql |
CREATE TABLE farms (id INT, name TEXT, continent TEXT, size INT, practice TEXT); INSERT INTO farms (id, name, continent, size, practice) VALUES (1, 'Smith Farm', 'South America', 10, 'Agroecology'); INSERT INTO farms (id, name, continent, size, practice) VALUES (2, 'Jones Farm', 'North America', 15, 'Conventional'); IN... | Identify the number of farms in each continent practicing agroecology and the average farm size. | SELECT f.continent, COUNT(f.id), AVG(f.size) FROM farms f WHERE f.practice = 'Agroecology' GROUP BY f.continent; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteer_hours (id INT, region VARCHAR(255), hours_served INT); INSERT INTO volunteer_hours (id, region, hours_served) VALUES (1, 'Northeast', 500), (2, 'Southeast', 700), (3, 'Northwest', 600), (4, 'Southwest', 800), (5, 'Northeast', 400), (6, 'Southeast', 900); | What is the total number of volunteers and their average hours served per region this year? | SELECT region, COUNT(*) AS num_volunteers, AVG(hours_served) AS avg_hours_served FROM volunteer_hours WHERE activity_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE College_of_Arts_and_Humanities (faculty_member VARCHAR(50), publications INT, publication_year INT); INSERT INTO College_of_Arts_and_Humanities (faculty_member, publications, publication_year) VALUES ('Taylor, Emily', 3, 2019), ('Miller, James', 2, 2019), ('Thomas, Laura', 5, 2019), ('Wilson, Susan', 4, 20... | How many publications did each faculty member in the College of Arts and Humanities publish in 2019, ordered alphabetically by faculty member? | SELECT faculty_member, publications FROM College_of_Arts_and_Humanities WHERE publication_year = 2019 ORDER BY faculty_member; | gretelai_synthetic_text_to_sql |
CREATE TABLE green_buildings (id INT, area FLOAT, city VARCHAR(20), state VARCHAR(20)); INSERT INTO green_buildings (id, area, city, state) VALUES (1, 5000.5, 'San Francisco', 'CA'), (2, 7000.3, 'Los Angeles', 'CA'); | What is the minimum area of a green building in the 'smart_cities' schema? | SELECT MIN(area) FROM green_buildings; | gretelai_synthetic_text_to_sql |
CREATE TABLE Agents (AgentID INT, AgentName VARCHAR(255), PolicyID INT); INSERT INTO Agents VALUES (1, 'John Smith', 1), (2, 'Jane Doe', 2), (1, 'John Smith', 3), (2, 'Jane Doe', 4), (3, 'Mike Johnson', 5), (3, 'Mike Johnson', 6); CREATE TABLE Policies (PolicyID INT); INSERT INTO Policies VALUES (1), (2), (3), (4), (5)... | What is the number of policies sold by each agent? | SELECT a.AgentName, COUNT(p.PolicyID) AS PoliciesSold FROM Agents a JOIN Policies p ON a.PolicyID = p.PolicyID GROUP BY a.AgentName; | gretelai_synthetic_text_to_sql |
CREATE TABLE defense_contracts (contract_id INT, vendor VARCHAR(255), contract_value DECIMAL(10,2), contract_date DATE); | List the top 5 vendors with the highest defense contract awards in 2022 | SELECT vendor, SUM(contract_value) as total_contract_value FROM defense_contracts WHERE YEAR(contract_date) = 2022 GROUP BY vendor ORDER BY total_contract_value DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE OrganicCottonProducts (productID INT, revenue FLOAT); INSERT INTO OrganicCottonProducts (productID, revenue) VALUES (1, 100.00), (2, 150.00); | What is the total revenue of organic cotton products? | SELECT SUM(revenue) FROM OrganicCottonProducts; | gretelai_synthetic_text_to_sql |
CREATE TABLE digital_divide (id INT PRIMARY KEY, problem VARCHAR(50), description TEXT); INSERT INTO digital_divide (id, problem, description) VALUES (1, 'Lack of internet access', 'High-speed internet unavailable in many rural areas'), (2, 'Expensive devices', 'Cost of devices is a barrier for low-income households'),... | Update the 'description' of the record with an id of 3 in the 'digital_divide' table to 'Limited digital literacy and skills among older adults' | UPDATE digital_divide SET description = 'Limited digital literacy and skills among older adults' WHERE id = 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE InternationalTVShows (title VARCHAR(255), country VARCHAR(255), viewership FLOAT, air_date DATE); INSERT INTO InternationalTVShows (title, country, viewership, air_date) VALUES ('TVShowX', 'USA', 25000, '2022-01-01'), ('TVShowY', 'Canada', 30000, '2022-01-02'), ('TVShowZ', 'Mexico', 20000, '2022-01-03'); | What was the average viewership for TV shows, by day of the week and country? | SELECT country, DATE_PART('dow', air_date) as day_of_week, AVG(viewership) FROM InternationalTVShows GROUP BY country, day_of_week; | gretelai_synthetic_text_to_sql |
CREATE TABLE PeacekeepingCasualties (Country VARCHAR(50), Year INT, Casualties INT); INSERT INTO PeacekeepingCasualties (Country, Year, Casualties) VALUES ('USA', 2020, 50), ('USA', 2021, 40), ('China', 2020, 30), ('China', 2021, 35), ('France', 2020, 20), ('France', 2021, 18); | Which countries have experienced a decrease in peacekeeping operation casualties from 2020 to 2021? | SELECT Country FROM (SELECT Country, Year, Casualties, LAG(Casualties) OVER (PARTITION BY Country ORDER BY Year) AS PreviousYearCasualties FROM PeacekeepingCasualties) AS Subquery WHERE Subquery.Country = Subquery.Country AND Subquery.Casualties < Subquery.PreviousYearCasualties; | gretelai_synthetic_text_to_sql |
CREATE TABLE emergency_incidents (id INT, incident_type VARCHAR(255), response_time INT); INSERT INTO emergency_incidents (id, incident_type, response_time) VALUES (1, 'Medical Emergency', 10), (2, 'Fire', 8), (3, 'Traffic Accident', 12); CREATE TABLE crime_reports (id INT, report_type VARCHAR(255), response_time INT);... | What is the minimum response time for each type of emergency incident and crime report? | SELECT incident_type, MIN(response_time) as min_response_time FROM emergency_incidents GROUP BY incident_type UNION SELECT report_type, MIN(response_time) as min_response_time FROM crime_reports GROUP BY report_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE budget (category TEXT, amount INTEGER); INSERT INTO budget (category, amount) VALUES ('national security', 15000), ('intelligence operations', 10000), ('cybersecurity', 12000); | Show the total budget allocated for each category. | SELECT category, SUM(amount) FROM budget GROUP BY category | gretelai_synthetic_text_to_sql |
CREATE TABLE clinical_trials (trial_id INT, country VARCHAR(255), approval_date DATE); | How many clinical trials were approved for each country in 2020? | SELECT country, COUNT(*) as num_trials FROM clinical_trials WHERE YEAR(approval_date) = 2020 GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE legal_organizations (org_id INT, org_name VARCHAR(255), PRIMARY KEY (org_id)); INSERT INTO legal_organizations (org_id, org_name) VALUES (1, 'Access Now'), (2, 'Legal Aid Society'), (3, 'Justice for Migrants'); | List all legal organizations that provide services related to access to justice | SELECT org_name FROM legal_organizations WHERE org_name LIKE '%access to justice%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ether_tokens (token_id INT, contract_address VARCHAR(42), holder_address VARCHAR(42), balance INT); | What is the distribution of token holdings for the smart contract with the address '0xAbCdEfGhIjKlMnOpQrStUvWxYz01' on the Ethereum blockchain? | SELECT holder_address, SUM(balance) FROM ether_tokens WHERE contract_address = '0xAbCdEfGhIjKlMnOpQrStUvWxYz01' GROUP BY holder_address ORDER BY SUM(balance) DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE excavation_sites (id INT, name VARCHAR(255), country VARCHAR(255)); CREATE TABLE artifacts (id INT, excavation_site_id INT, year INT, type VARCHAR(255)); | Find the total number of artifacts excavated from each country. | SELECT country, COUNT(a.id) as artifact_count FROM excavation_sites es JOIN artifacts a ON es.id = a.excavation_site_id GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE dams_inventory (id INT, dam_name VARCHAR(255), hazard_potential_rating INT); INSERT INTO dams_inventory (id, dam_name, hazard_potential_rating) VALUES (1, 'Smith Dam', 12), (2, 'Johnson Dam', 15), (3, 'Williams Dam', 8), (4, 'Brown Dam', 18), (5, 'Davis Dam', 9); | Which dams have a higher hazard potential rating than the median rating in the dams inventory? | SELECT dam_name, hazard_potential_rating FROM dams_inventory WHERE hazard_potential_rating > (SELECT AVG(hazard_potential_rating) FROM dams_inventory) ORDER BY hazard_potential_rating DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE players (player_id INT, name VARCHAR(100)); CREATE TABLE vr_sessions (session_id INT, player_id INT, duration INT); | Get player's VR sessions and total playtime | SELECT p.name, COUNT(s.session_id) AS sessions_count, SUM(s.duration) AS total_playtime_seconds FROM players p JOIN vr_sessions s ON p.player_id = s.player_id GROUP BY p.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE public_transportation( transport_id INT, passengers INT, transport_type VARCHAR(50), usage_date DATE, city VARCHAR(50)); CREATE VIEW q1_2022 AS SELECT * FROM public_transportation WHERE usage_date BETWEEN '2022-01-01' AND '2022-03-31'; | What is the total number of passengers that used public transportation in Chicago during Q1 of 2022? | SELECT SUM(passengers) FROM q1_2022 WHERE city = 'Chicago'; | gretelai_synthetic_text_to_sql |
CREATE TABLE IF NOT EXISTS threat_intelligence (threat_id INT, threat_type VARCHAR(50), reported_date DATE, severity INT, target_region VARCHAR(50)); | Which threats have been reported most frequently in each region over the past year? | SELECT target_region, threat_type, COUNT(*) as num_reports, RANK() OVER (PARTITION BY target_region ORDER BY COUNT(*) DESC) as rank FROM threat_intelligence WHERE reported_date >= '2021-01-01' GROUP BY target_region, threat_type; | gretelai_synthetic_text_to_sql |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.