context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE defense_projects (proj_id INT, proj_name VARCHAR(50), region VARCHAR(50), start_date DATE, end_date DATE); | Update contract status for 'Middle East' defense projects with timelines > 2023 | UPDATE defense_projects SET contract_status = 'Active' WHERE region = 'Middle East' AND start_date < '2023-01-01' AND end_date > '2023-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE projects_2 (id INT, name VARCHAR, type VARCHAR, budget FLOAT); INSERT INTO projects_2 (id, name, type, budget) VALUES (1, 'Accessible Software Development', 'Accessibility', 150000), (2, 'Adaptive Hardware Research', 'Accessibility', 200000), (3, 'AI for Good', 'AI', 100000), (4, 'Digital Divide Initiative... | What is the maximum budget for projects addressing technology accessibility? | SELECT MAX(budget) FROM projects_2 WHERE type = 'Accessibility'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Haircare_Europe(Product VARCHAR(30), Brand VARCHAR(30), Revenue DECIMAL(10,2)); INSERT INTO Haircare_Europe(Product, Brand, Revenue) VALUES('Shampoo A', 'Brand X', 2000), ('Conditioner B', 'Brand Y', 1500), ('Styling C', 'Brand Z', 1200), ('Shampoo D', 'Brand X', 2500), ('Conditioner E', 'Brand Y', 1800), ... | What is the total revenue for organic hair care products in the European market? | SELECT SUM(Revenue) FROM Haircare_Europe WHERE Product LIKE '%Organic%' AND Country = 'Europe'; | gretelai_synthetic_text_to_sql |
CREATE TABLE PatientConditions (PatientID int, ConditionID int, Age int); INSERT INTO PatientConditions (PatientID, ConditionID, Age) VALUES (1, 1, 30), (2, 2, 35); | What is the average age of patients by condition? | SELECT Conditions.Condition, AVG(PatientConditions.Age) FROM PatientConditions JOIN Conditions ON PatientConditions.ConditionID = Conditions.ConditionID GROUP BY Conditions.Condition; | gretelai_synthetic_text_to_sql |
CREATE TABLE threat_intelligence (country VARCHAR(100), threat_level VARCHAR(20), quarter VARCHAR(10)); | Find the number of countries with a threat level of 'high' in Q2 2022 | SELECT COUNT(DISTINCT country) FROM threat_intelligence WHERE threat_level = 'high' AND quarter = 'Q2 2022'; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, category VARCHAR(50), cruelty_free BOOLEAN, preference_rating INT, revenue INT); INSERT INTO products (product_id, category, cruelty_free, preference_rating, revenue) VALUES (1, 'Eyeliner', true, 8, 150), (2, 'Lipstick', false, 9, 300), (3, 'Eyeshadow', true, 7, 250); | What is the average preference rating for makeup products that are not cruelty-free and have a revenue above 200? | SELECT AVG(products.preference_rating) FROM products WHERE products.cruelty_free = false AND products.revenue > 200; | gretelai_synthetic_text_to_sql |
CREATE TABLE africa_tourists (id INT, country VARCHAR(20), tourists INT); INSERT INTO africa_tourists (id, country, tourists) VALUES (1, 'Egypt', 10000000), (2, 'South Africa', 15000000), (3, 'Morocco', 8000000); | What is the average number of tourists visiting countries in the African continent? | SELECT AVG(tourists) FROM africa_tourists; | gretelai_synthetic_text_to_sql |
CREATE TABLE Student (StudentID INT, Gender VARCHAR(10)); INSERT INTO Student (StudentID, Gender) VALUES (1, 'Male'), (2, 'Female'), (3, 'Male'); | Find the number of male and female students in the 'Student' table | SELECT Gender, COUNT(*) FROM Student GROUP BY Gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE transactions (user_id INT, transaction_amount DECIMAL(10, 2), transaction_date DATE, country VARCHAR(255)); INSERT INTO transactions (user_id, transaction_amount, transaction_date, country) VALUES (1, 50.00, '2022-01-01', 'Mexico'), (2, 150.50, '2022-01-02', 'Mexico'), (3, 100.00, '2022-01-03', 'Mexico'); | What is the difference between the maximum and minimum transaction amounts for Mexico? | SELECT country, MAX(transaction_amount) - MIN(transaction_amount) as transaction_amount_difference FROM transactions WHERE country = 'Mexico' GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE conservation_programs (id INT, program_name VARCHAR(255), location VARCHAR(255)); CREATE TABLE animal_populations (id INT, program_id INT, animal_type VARCHAR(255), population INT); INSERT INTO conservation_programs (id, program_name, location) VALUES (1, 'Australian Wildlife Conservancy', 'Australia'), (2... | Calculate the total population of all animals in Australian conservation programs | SELECT SUM(animal_populations.population) FROM conservation_programs INNER JOIN animal_populations ON conservation_programs.id = animal_populations.program_id WHERE conservation_programs.location = 'Australia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ocean_health (zone VARCHAR(255), dissolved_oxygen DECIMAL(4,2)); INSERT INTO ocean_health (zone, dissolved_oxygen) VALUES ('Zone A', 7.6), ('Zone B', 6.8), ('Zone C', 8.3), ('Zone A', 7.9), ('Zone B', 7.1); | What is the maximum dissolved oxygen level for each zone in the 'ocean_health' table? | SELECT zone, MAX(dissolved_oxygen) as max_dissolved_oxygen FROM ocean_health GROUP BY zone; | gretelai_synthetic_text_to_sql |
CREATE TABLE production_data (fabric_type VARCHAR(20), month VARCHAR(10), units_produced INT); INSERT INTO production_data (fabric_type, month, units_produced) VALUES ('Eco-friendly', 'July', 5000), ('Regular', 'July', 7000), ('Eco-friendly', 'August', 5500); | How many units of the "Eco-friendly" fabric were produced in July 2021? | SELECT SUM(units_produced) FROM production_data WHERE fabric_type = 'Eco-friendly' AND month = 'July'; | gretelai_synthetic_text_to_sql |
CREATE TABLE clients (client_id INT, name VARCHAR(50), region VARCHAR(20)); CREATE TABLE transactions (transaction_id INT, client_id INT, amount DECIMAL(10, 2)); INSERT INTO clients (client_id, name, region) VALUES (1, 'John Doe', 'African'), (2, 'Jane Smith', 'African'), (3, 'Mike Johnson', 'European'); INSERT INTO tr... | Calculate the total value of transactions for each client in the African region. | SELECT c.client_id, c.name, SUM(t.amount) FROM clients c INNER JOIN transactions t ON c.client_id = t.client_id WHERE c.region = 'African' GROUP BY c.client_id, c.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Forests (id INT, name VARCHAR(50), hectares FLOAT, country VARCHAR(50)); INSERT INTO Forests (id, name, hectares, country) VALUES (1, 'Black Forest', 150000.0, 'Germany'); CREATE TABLE Timber_Production (id INT, forest_id INT, year INT, production_cubic_meters INT); INSERT INTO Timber_Production (id, fores... | Which forests in Germany have more than 5 distinct years of timber production data? | SELECT forest_id FROM Timber_Production WHERE forest_id IN (SELECT id FROM Forests WHERE country = 'Germany') GROUP BY forest_id HAVING COUNT(DISTINCT year) > 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_conservation_laws (id INT PRIMARY KEY, law_name VARCHAR(255), region VARCHAR(255)); | Add a new marine conservation law in the Caribbean Sea | INSERT INTO marine_conservation_laws (id, law_name, region) VALUES (1, 'Caribbean Marine Protected Areas Act', 'Caribbean Sea'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Patients (PatientID INT, Disabilities TEXT, LastHospitalVisit DATE, State TEXT); INSERT INTO Patients (PatientID, Disabilities, LastHospitalVisit, State) VALUES (1, 'Mobility Impairment', '2020-01-01', 'Illinois'); | How many patients with disabilities in Illinois have not visited a hospital in the last year? | SELECT COUNT(*) FROM Patients WHERE Disabilities IS NOT NULL AND LastHospitalVisit < DATEADD(year, -1, GETDATE()) AND State = 'Illinois'; | gretelai_synthetic_text_to_sql |
CREATE TABLE grant_data (id INT, student_id INT, amount FLOAT, department VARCHAR(50), year INT); INSERT INTO grant_data (id, student_id, amount, department, year) VALUES (1, 1, 10000, 'Physics', 2019), (2, 2, 15000, 'Physics', 2020); | What is the average grant amount awarded to graduate students in the Physics department? | SELECT AVG(amount) FROM grant_data WHERE department = 'Physics' AND year IN (2019, 2020) GROUP BY department; | gretelai_synthetic_text_to_sql |
CREATE TABLE Games (Id INT, Name VARCHAR(100), Genre VARCHAR(50), Sales INT, Players INT); INSERT INTO Games VALUES (1, 'GameX', 'Adventure', 3000, 10000), (2, 'GameY', 'Simulation', 4000, 15000), (3, 'GameZ', 'Adventure', 5000, 12000), (4, 'GameW', 'Strategy', 6000, 18000); | What is the total revenue and player count for each game in the 'Adventure' genre? | SELECT Genre, SUM(Sales) AS Total_Revenue, COUNT(*) AS Player_Count FROM Games WHERE Genre = 'Adventure' GROUP BY Genre; | gretelai_synthetic_text_to_sql |
CREATE TABLE Customers (CustomerID INT, Name VARCHAR(255), Country VARCHAR(255)); INSERT INTO Customers (CustomerID, Name, Country) VALUES (1, 'Juan Perez', 'Mexico'); INSERT INTO Customers (CustomerID, Name, Country) VALUES (2, 'Maria Rodriguez', 'Brazil'); CREATE TABLE Transactions (TransactionID INT, CustomerID IN... | What is the maximum transaction amount for customers from Latin America in the last week? | SELECT MAX(Amount) FROM Transactions JOIN Customers ON Transactions.CustomerID = Customers.CustomerID WHERE Customers.Country IN ('Mexico', 'Brazil') AND Transactions.TransactionDate >= DATEADD(day, -7, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE subway (line_id INT, city VARCHAR(50), daily_ridership INT); INSERT INTO subway (line_id, city, daily_ridership) VALUES (1, 'Tokyo', 300000), (2, 'Tokyo', 450000), (3, 'Tokyo', 400000), (4, 'Tokyo', 500000), (5, 'Seoul', 250000), (6, 'Seoul', 300000); | What is the average daily ridership for each subway line in Seoul? | SELECT line_id, city, AVG(daily_ridership) FROM subway WHERE city = 'Seoul' GROUP BY line_id, city; | gretelai_synthetic_text_to_sql |
CREATE TABLE mental_health (patient_id INT, patient_age INT, hospitalized TEXT, date DATE); INSERT INTO mental_health (patient_id, patient_age, hospitalized, date) VALUES (1, 18, 'Yes', '2021-01-01'), (2, 25, 'No', '2021-01-02'), (3, 30, 'Yes', '2021-01-03'); | What is the trend in mental health hospitalizations for each age group? | SELECT patient_age, hospitalized, COUNT(*) AS count, LAG(count, 1) OVER (ORDER BY patient_age) AS previous_age_count FROM mental_health GROUP BY patient_age, hospitalized ORDER BY patient_age; | gretelai_synthetic_text_to_sql |
CREATE TABLE strategies (id INT, country VARCHAR(255), description VARCHAR(255));INSERT INTO strategies (id, country, description) VALUES (1, 'Canada', 'Training on malware and phishing'); | Update the cybersecurity strategy for Canada to include training on social engineering. | UPDATE strategies SET description = 'Training on malware, phishing, and social engineering' WHERE country = 'Canada'; | gretelai_synthetic_text_to_sql |
CREATE TABLE AstrophysicsResearch (object_name VARCHAR(255), distance_from_sun FLOAT); INSERT INTO AstrophysicsResearch (object_name, distance_from_sun) VALUES ('Sun', 0), ('Mercury', 57.9), ('Venus', 108.2), ('Earth', 149.6), ('Mars', 227.9); | What is the average distance from the sun for objects studied in astrophysics research? | SELECT AVG(distance_from_sun) FROM AstrophysicsResearch WHERE object_name != 'Sun'; | gretelai_synthetic_text_to_sql |
CREATE TABLE music_track (track_id INT, title VARCHAR(100), artist VARCHAR(100)); INSERT INTO music_track (track_id, title, artist) VALUES (1, 'Bohemian Rhapsody', 'Queen'); | Update the title of the music track 'Bohemian Rhapsody' to 'Queen's Bohemian Rhapsody'. | UPDATE music_track SET title = 'Queen''s Bohemian Rhapsody' WHERE title = 'Bohemian Rhapsody'; | gretelai_synthetic_text_to_sql |
CREATE TABLE spacecraft_manufacturing(id INT, cost FLOAT, year INT, manufacturer VARCHAR(20)); INSERT INTO spacecraft_manufacturing(id, cost, year, manufacturer) VALUES (1, 5000000, 2025, 'SpaceCorp'); INSERT INTO spacecraft_manufacturing(id, cost, year, manufacturer) VALUES (2, 7000000, 2025, 'Galactic Inc'); | List spacecraft manufacturers who have never manufactured a spacecraft priced over 10 million. | SELECT DISTINCT manufacturer FROM spacecraft_manufacturing WHERE id NOT IN (SELECT id FROM spacecraft_manufacturing WHERE cost > 10000000); | gretelai_synthetic_text_to_sql |
CREATE TABLE state_facts (state VARCHAR(2), capital VARCHAR(50), population INT, area_sq_miles INT); | Delete the 'state_facts' table | DROP TABLE state_facts; | gretelai_synthetic_text_to_sql |
CREATE TABLE crimes (id INT, crime_type VARCHAR(255), district VARCHAR(255), response_time INT); INSERT INTO crimes (id, crime_type, district, response_time) VALUES (1, 'Theft', 'Camden', 10); INSERT INTO crimes (id, crime_type, district, response_time) VALUES (2, 'Vandalism', 'Kensington', 15); CREATE TABLE districts ... | Identify crime rates and response times for each district in London. | SELECT c.crime_type, d.district, COUNT(c.id) AS crime_count, AVG(c.response_time) AS response_time_avg FROM crimes c INNER JOIN districts d ON c.district = d.district WHERE d.city = 'London' GROUP BY c.crime_type, d.district; | gretelai_synthetic_text_to_sql |
CREATE TABLE PlayerPlatform (PlayerID INT, Platform VARCHAR(10)); INSERT INTO PlayerPlatform (PlayerID, Platform) VALUES (1, 'PC'), (2, 'Console'), (3, 'Mobile'), (4, 'Console'), (5, 'VR'); | Find the number of distinct players who have played games on each platform, excluding mobile and PC gamers. | SELECT Platform, COUNT(DISTINCT PlayerID) as NumPlayers FROM PlayerPlatform WHERE Platform NOT IN ('PC', 'Mobile') GROUP BY Platform; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (id INT PRIMARY KEY, name VARCHAR(255), conservation_status VARCHAR(255)); | Insert a new marine species record into the marine_species table. | INSERT INTO marine_species (id, name, conservation_status) VALUES (4, 'Giant Pacific Octopus', 'vulnerable'); | gretelai_synthetic_text_to_sql |
CREATE VIEW top_articles_this_week AS SELECT * FROM articles WHERE publication_date >= CURDATE() - INTERVAL 7 DAY ORDER BY pageviews DESC; | Delete the view "top_articles_this_week" from the database | DROP VIEW top_articles_this_week; | gretelai_synthetic_text_to_sql |
CREATE TABLE transportation_projects (project VARCHAR(50), budget INT); INSERT INTO transportation_projects (project, budget) VALUES ('Road Construction', 1000000); INSERT INTO transportation_projects (project, budget) VALUES ('Bridge Building', 5000000); INSERT INTO transportation_projects (project, budget) VALUES ('B... | What is the average budget for transportation projects in the 'transportation_projects' table? | SELECT AVG(budget) FROM transportation_projects; | gretelai_synthetic_text_to_sql |
CREATE TABLE ProtectedForests (id INT, country VARCHAR(255), region VARCHAR(255), name VARCHAR(255), area FLOAT); INSERT INTO ProtectedForests (id, country, region, name, area) VALUES (1, 'United States', 'Pacific Northwest', 'Olympic National Park', 922600); | What is the total area of protected forests in the United States? | SELECT SUM(area) FROM ProtectedForests WHERE country = 'United States'; | gretelai_synthetic_text_to_sql |
CREATE TABLE CybersecurityIncidents (ID INT, Country VARCHAR(50), Year INT, Incidents INT); INSERT INTO CybersecurityIncidents (ID, Country, Year, Incidents) VALUES (1, 'Country1', 2020, 100); INSERT INTO CybersecurityIncidents (ID, Country, Year, Incidents) VALUES (2, 'Country2', 2021, 150); INSERT INTO CybersecurityI... | What is the total number of cybersecurity incidents in 'Asia' and 'Africa' in 2020 and 2021? | SELECT Country, SUM(Incidents) as TotalIncidents FROM CybersecurityIncidents WHERE Country IN ('Asia', 'Africa') AND Year IN (2020, 2021) GROUP BY Country; | gretelai_synthetic_text_to_sql |
CREATE TABLE Customers (id INT, name VARCHAR(255), state VARCHAR(255));CREATE TABLE Purchases (id INT, customer_id INT, revenue DECIMAL(10, 2), year INT);INSERT INTO Customers (id, name, state) VALUES (1, 'John Doe', 'CO');INSERT INTO Purchases (id, customer_id, revenue, year) VALUES (1, 1, 1500, 2021); | Who were the top 3 customers by total revenue in the state of Colorado in 2021? | SELECT c.name, SUM(p.revenue) as total_revenue FROM Customers c JOIN Purchases p ON c.id = p.customer_id WHERE c.state = 'CO' GROUP BY c.name ORDER BY total_revenue DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE player_activity (player_id INT, play_date DATE, num_games INT); INSERT INTO player_activity (player_id, play_date, num_games) VALUES (1, '2021-01-01', 3), (1, '2021-01-02', 2), (2, '2021-01-01', 1), (2, '2021-01-03', 5), (3, '2021-01-02', 4), (3, '2021-01-03', 3); | What is the maximum number of games played in a single day by any player? | SELECT MAX(num_games) FROM player_activity; | gretelai_synthetic_text_to_sql |
CREATE TABLE program_donations (donation_id INT, program_id INT, donor_id INT, donation_amount FLOAT, donation_date DATE); INSERT INTO program_donations (donation_id, program_id, donor_id, donation_amount, donation_date) VALUES (1, 1, 1, 80, '2021-01-01'); INSERT INTO program_donations (donation_id, program_id, donor_i... | What is the number of unique donors and total donation amount for each program in H1 2021? | SELECT p.program_name, COUNT(DISTINCT d.donor_id) AS num_donors, SUM(d.donation_amount) AS total_donation FROM program_donations d INNER JOIN programs p ON d.program_id = p.program_id WHERE EXTRACT(YEAR FROM d.donation_date) = 2021 AND EXTRACT(MONTH FROM d.donation_date) BETWEEN 1 AND 6 GROUP BY p.program_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE job_titles (id INT, department_id INT, title VARCHAR(255)); INSERT INTO job_titles (id, department_id, title) VALUES (1, 1, 'Manager'), (2, 1, 'Associate'), (3, 2, 'Engineer'), (4, 2, 'Analyst'), (5, 3, 'Designer'); | What is the distribution of job titles by department? | SELECT department_id, title, COUNT(*) as count FROM job_titles GROUP BY department_id, title; | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists Scooters (id INT, city VARCHAR(20), rentals INT, date DATE); INSERT INTO Scooters (id, city, rentals, date) VALUES (1, 'Paris', 3000, '2022-03-15'), (2, 'Paris', 2800, '2022-03-16'), (3, 'Berlin', 2000, '2022-03-15'); | What is the minimum number of electric scooter rentals in Paris in a day? | SELECT MIN(rentals) FROM Scooters WHERE city = 'Paris'; | gretelai_synthetic_text_to_sql |
CREATE TABLE rural_water_consumption (id INT, city VARCHAR(50), year INT, monthly_consumption FLOAT); INSERT INTO rural_water_consumption (id, city, year, monthly_consumption) VALUES (1, 'Smalltown', 2019, 120000), (2, 'Smalltown', 2020, 130000); | Find the percentage change in water consumption in rural areas from 2019 to 2020. | SELECT (SUM(t2.monthly_consumption) - SUM(t1.monthly_consumption)) * 100.0 / SUM(t1.monthly_consumption) FROM rural_water_consumption t1, rural_water_consumption t2 WHERE t1.city = t2.city AND t1.year = 2019 AND t2.year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE charging_stations (company VARCHAR(255), city VARCHAR(255), charging_level VARCHAR(255), count INT); | Insert a new row into the 'charging_stations' table with the following values: 'Rivian', 'Los Angeles', 'Level 3', 25 | INSERT INTO charging_stations (company, city, charging_level, count) VALUES ('Rivian', 'Los Angeles', 'Level 3', 25); | gretelai_synthetic_text_to_sql |
CREATE TABLE fans (fan_id INT, state VARCHAR(255)); CREATE TABLE events (fan_id INT, event_id INT); INSERT INTO fans (fan_id, state) VALUES (1, 'Texas'), (2, 'California'), (3, 'Texas'), (4, 'New York'), (5, 'California'), (6, 'California'), (7, 'Texas'), (8, 'Texas'), (9, 'New York'), (10, 'New York'); INSERT INTO eve... | Which fans have not attended any events? | SELECT f.fan_id, f.state FROM fans f LEFT JOIN events e ON f.fan_id = e.fan_id WHERE e.fan_id IS NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE incident_types (id INT, name VARCHAR, description TEXT); INSERT INTO incident_types (id, name, description) VALUES (1, 'Data Breach', 'Unauthorized access to data'); | Remove the 'Data Breach' record from the 'incident_types' table | DELETE FROM incident_types WHERE name='Data Breach'; | gretelai_synthetic_text_to_sql |
CREATE TABLE teams (team_id INT, team_name VARCHAR(100)); INSERT INTO teams (team_id, team_name) VALUES (1, 'Barcelona'), (2, 'Bayern Munich'); CREATE TABLE matches (match_id INT, team_home_id INT, team_away_id INT, tickets_sold INT); INSERT INTO matches (match_id, team_home_id, team_away_id, tickets_sold) VALUES (1, 1... | Find the teams with the greatest difference in ticket sales between home and away matches. | SELECT team_name, home_sales - away_sales as diff FROM (SELECT team_home_id, SUM(tickets_sold) as home_sales FROM matches GROUP BY team_home_id) home_sales JOIN (SELECT team_away_id, SUM(tickets_sold) as away_sales FROM matches GROUP BY team_away_id) away_sales JOIN teams t ON home_sales.team_home_id = t.team_id OR awa... | gretelai_synthetic_text_to_sql |
CREATE TABLE employee (id INT, name VARCHAR(50), department VARCHAR(50), salary INT); INSERT INTO employee (id, name, department, salary) VALUES (1, 'John Doe', 'Engineering', 50000), (2, 'Jane Smith', 'Engineering', 55000), (3, 'Mike Johnson', 'Manufacturing', 60000), (4, 'Alice Williams', 'Manufacturing', 65000), (5,... | What is the total salary cost for each department, sorted alphabetically by department name? | SELECT department, SUM(salary) as total_salary FROM employee GROUP BY department ORDER BY department; | gretelai_synthetic_text_to_sql |
CREATE TABLE claims (claim_id INT, policyholder_id INT); INSERT INTO claims (claim_id, policyholder_id) VALUES (1, 1), (2, 3), (3, 2), (4, 1); CREATE TABLE policyholders (policyholder_id INT); INSERT INTO policyholders (policyholder_id) VALUES (1), (2), (3), (4), (5); | How many policyholders have never filed a claim? | SELECT COUNT(DISTINCT ph.policyholder_id) as num_policyholders_no_claims FROM policyholders ph LEFT JOIN claims c ON ph.policyholder_id = c.policyholder_id WHERE c.claim_id IS NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (id INT, name TEXT, country TEXT, donation_amount DECIMAL, donation_date DATE); INSERT INTO donors (id, name, country, donation_amount, donation_date) VALUES (1, 'John Doe', 'USA', 50.00, '2021-05-12'); INSERT INTO donors (id, name, country, donation_amount, donation_date) VALUES (2, 'Jane Smith', '... | What is the average donation amount per donor in the United States, for donations made in 2021? | SELECT AVG(donation_amount) FROM donors WHERE country = 'USA' AND YEAR(donation_date) = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE project (id INT PRIMARY KEY, name TEXT, budget INT, status TEXT, city_id INT, FOREIGN KEY (city_id) REFERENCES city(id)); | What is the maximum budget for a single public works project in the state of Texas? | SELECT MAX(budget) FROM project WHERE city_id IN (SELECT id FROM city WHERE state = 'TX') AND status = 'Open'; | gretelai_synthetic_text_to_sql |
CREATE TABLE bus_trips (trip_id INT, start_date DATETIME, end_date DATETIME, route_id INT, total_amount FLOAT); INSERT INTO bus_trips VALUES (1, '2022-03-01 07:30:00', '2022-03-01 08:00:00', 45, 2.50); | What is the average trip length for bus rides in London during peak hours? | SELECT AVG(EXTRACT(MINUTE FROM end_date - start_date)) FROM bus_trips WHERE EXTRACT(HOUR FROM start_date) BETWEEN 7 AND 9 OR EXTRACT(HOUR FROM start_date) BETWEEN 16 AND 19; | gretelai_synthetic_text_to_sql |
CREATE TABLE Allergens (ProductID INT, Allergen VARCHAR(100)); INSERT INTO Allergens (ProductID, Allergen) VALUES (1, 'Nuts'); INSERT INTO Allergens (ProductID, Allergen) VALUES (2, 'Gluten'); | List all suppliers and their products that have potential allergens. | SELECT S.SupplierID, S.SupplierName, P.ProductName FROM Suppliers S INNER JOIN Products P ON S.SupplierID = P.SupplierID INNER JOIN Allergens A ON P.ProductID = A.ProductID; | gretelai_synthetic_text_to_sql |
CREATE TABLE programs (id INT, name VARCHAR(50), category VARCHAR(50), budget DECIMAL(10,2)); INSERT INTO programs (id, name, category, budget) VALUES (1, 'Primary Healthcare', 'Health', 25000.00); INSERT INTO programs (id, name, category, budget) VALUES (2, 'Secondary Healthcare', 'Health', 30000.00); INSERT INTO prog... | Get the average program budget for programs in the 'Health' category | SELECT category, AVG(budget) as avg_budget FROM programs WHERE category = 'Health' GROUP BY category; | gretelai_synthetic_text_to_sql |
CREATE TABLE IndustrialLandfills (id INT, area VARCHAR(20), capacity INT); INSERT INTO IndustrialLandfills (id, area, capacity) VALUES (1, 'Industrial', 4000), (2, 'Industrial', 5000); | What is the average landfill capacity in the 'Industrial' area? | SELECT AVG(capacity) FROM IndustrialLandfills WHERE area = 'Industrial'; | gretelai_synthetic_text_to_sql |
CREATE TABLE sea_surface_temperature (ocean VARCHAR(255), date DATE, temperature FLOAT); INSERT INTO sea_surface_temperature (ocean, date, temperature) VALUES ('Atlantic', '2017-01-01', 20.5), ('Atlantic', '2017-07-01', 21.2), ('Atlantic', '2018-01-01', 20.8), ('Atlantic', '2018-07-01', 21.1), ('Atlantic', '2019-01-01'... | What is the 5-year trend of sea surface temperature in the Atlantic Ocean? | SELECT date, temperature, ROW_NUMBER() OVER (ORDER BY date) as rn, AVG(temperature) OVER (ORDER BY date ROWS BETWEEN 4 PRECEDING AND CURRENT ROW) as moving_avg FROM sea_surface_temperature WHERE ocean = 'Atlantic'; | gretelai_synthetic_text_to_sql |
CREATE TABLE species (id INT PRIMARY KEY, name VARCHAR(255), population INT); INSERT INTO species (id, name, population) VALUES (1, 'Spruce', 5000000); INSERT INTO species (id, name, population) VALUES (2, 'Pine', 6000000); INSERT INTO species (id, name, population) VALUES (3, 'Oak', 4000000); | What is the current population of the 'Oak' species? | SELECT population FROM species WHERE name = 'Oak'; | gretelai_synthetic_text_to_sql |
CREATE TABLE disaster_data (id INT, year INT, type VARCHAR(50), location VARCHAR(50)); | List types of disasters and their frequency in 'disaster_data' table. | SELECT type, COUNT(*) as frequency FROM disaster_data GROUP BY type; | gretelai_synthetic_text_to_sql |
CREATE TABLE railroads (id INT, name VARCHAR(255), location VARCHAR(255), length FLOAT); INSERT INTO railroads (id, name, location, length) VALUES (1, 'Western Railway', 'India', 1435), (2, 'Eastern Railway', 'India', 2202); | What is the maximum length of a railroad in India? | SELECT MAX(length) FROM railroads WHERE location = 'India'; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotels (id INT, name TEXT, city TEXT, rating FLOAT); INSERT INTO hotels (id, name, city, rating) VALUES (1, 'Eco Hotel Barcelona', 'Barcelona', 4.3), (2, 'Green Hotel Barcelona', 'Barcelona', 4.1); | What are the names of eco-friendly hotels in Barcelona with a rating above 4? | SELECT name FROM hotels WHERE city = 'Barcelona' AND rating > 4 AND (name = 'Eco Hotel Barcelona' OR name = 'Green Hotel Barcelona'); | gretelai_synthetic_text_to_sql |
CREATE TABLE cases (case_id INT, attorney_id INT); | How many cases were handled by each attorney? | SELECT attorney_id, COUNT(*) FROM cases GROUP BY attorney_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE CustomerDemographics (id INT, customer_id INT, age INT, size_category TEXT); INSERT INTO CustomerDemographics (id, customer_id, age, size_category) VALUES (1, 1, 25, 'S'), (2, 2, 35, 'M'), (3, 3, 45, 'L'), (4, 4, 55, 'XL'), (5, 5, 65, 'XXL'); | Which size category has the highest number of customers? | SELECT size_category, COUNT(*) AS count FROM CustomerDemographics GROUP BY size_category ORDER BY count DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Smart_Contracts (contract_name TEXT, transaction_value NUMERIC, blockchain TEXT); INSERT INTO Smart_Contracts (contract_name, transaction_value, blockchain) VALUES ('Contract A', 50, 'Ethereum'), ('Contract A', 75, 'Ethereum'), ('Contract A', 100, 'Ethereum'), ('Contract B', 25, 'Bitcoin'), ('Contract B', ... | What is the minimum transaction value for Smart Contracts located in the 'Ethereum' blockchain? | SELECT MIN(transaction_value) FROM Smart_Contracts WHERE blockchain = 'Ethereum'; | gretelai_synthetic_text_to_sql |
CREATE TABLE indian_plate (trench_name TEXT, location TEXT, average_depth FLOAT); INSERT INTO indian_plate (trench_name, location, average_depth) VALUES ('Java Trench', 'Indonesia', 7680.0); | What is the maximum depth of oceanic trenches in the Indian plate? | SELECT MAX(average_depth) FROM indian_plate WHERE trench_name = 'Java Trench'; | gretelai_synthetic_text_to_sql |
CREATE TABLE posts (post_id INT, post_text TEXT, brand_mentioned TEXT, post_date DATE); INSERT INTO posts (post_id, post_text, brand_mentioned, post_date) VALUES (1, 'I love using @brandA', 'brandA', '2022-01-01'), (2, 'Check out @brandB, it is amazing!', 'brandB', '2022-01-02'); | Show top 3 most mentioned brands in India in 2022 | SELECT brand_mentioned, COUNT(*) as mention_count FROM posts WHERE YEAR(post_date) = 2022 AND country = 'India' GROUP BY brand_mentioned ORDER BY mention_count DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE creative_ai (application_id TEXT, region TEXT, submission_half TEXT); INSERT INTO creative_ai (application_id, region, submission_half) VALUES ('App1', 'North America', 'H2 2020'), ('App2', 'Africa', 'H2 2020'), ('App3', 'Europe', 'H1 2021'), ('App4', 'Africa', 'H1 2021'); | Count of creative AI applications submitted from Africa in H2 of 2020? | SELECT COUNT(*) FROM creative_ai WHERE region = 'Africa' AND submission_half = 'H2 2020'; | gretelai_synthetic_text_to_sql |
CREATE TABLE SportsScores (PlayerID int, PlayerName varchar(50), Game varchar(50), Score int); | Insert a new player with a score of 1500 in the 'Sports' game category. | INSERT INTO SportsScores (PlayerID, PlayerName, Game, Score) VALUES (1, 'Player5', 'Game5', 1500); | gretelai_synthetic_text_to_sql |
CREATE TABLE mining_sites (id INT, site_name VARCHAR(50), location VARCHAR(50), environmental_score FLOAT); INSERT INTO mining_sites (id, site_name, location, environmental_score) VALUES (1, 'Site A', 'USA', 78.50); | List the top 5 mining sites with the highest environmental impact scores in the 'Americas' region. | SELECT site_name, environmental_score FROM mining_sites WHERE location LIKE 'Americas' ORDER BY environmental_score DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotels (hotel_id INT, hotel_name VARCHAR(255), rating DECIMAL(2,1), country VARCHAR(255)); INSERT INTO hotels (hotel_id, hotel_name, rating, country) VALUES (1, 'Hotel Sydney', 4.8, 'Australia'), (2, 'Hotel Tokyo', 4.2, 'Japan'), (3, 'Hotel Singapore', 4.6, 'Singapore'); | Delete all records of hotels with a rating above 4.5 in the 'Asia-Pacific' region. | DELETE FROM hotels WHERE country IN ('Australia', 'Japan', 'Singapore', 'China', 'India') AND rating > 4.5; | gretelai_synthetic_text_to_sql |
CREATE TABLE bioprocess (id INT PRIMARY KEY, name TEXT); CREATE TABLE equipment (bioprocess_id INT, reactor_id INT, temperature INT, pressure INT, volume INT, stir_speed INT, pH REAL, FOREIGN KEY (bioprocess_id) REFERENCES bioprocess(id)); | Update the 'equipment' table to set the temperature to 35 where the bioprocess_id is 1 | UPDATE equipment SET temperature = 35 WHERE bioprocess_id = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE ProductPrices (product VARCHAR(255), country VARCHAR(255), price DECIMAL(10,2)); INSERT INTO ProductPrices (product, country, price) VALUES ('Foundation', 'Canada', 25), ('Foundation', 'Canada', 30), ('Mascara', 'Canada', 20); | What is the average price of foundation products in Canada? | SELECT AVG(price) FROM ProductPrices WHERE product = 'Foundation' AND country = 'Canada'; | gretelai_synthetic_text_to_sql |
CREATE TABLE schools (id INT, name VARCHAR(100), city VARCHAR(50), public BOOLEAN); INSERT INTO schools (id, name, city, public) VALUES (1, 'School 1', 'City 1', true); INSERT INTO schools (id, name, city, public) VALUES (2, 'School 2', 'City 2', false); | What is the number of public schools in each city of Brazil? | SELECT city, COUNT(*) FROM schools WHERE public = true GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteers (id INT, name VARCHAR(50)); CREATE TABLE volunteer_events (id INT, volunteer_id INT, organization_id INT, hours DECIMAL(10, 2)); CREATE TABLE organizations (id INT, name VARCHAR(50), category VARCHAR(20)); INSERT INTO volunteers (id, name) VALUES (1, 'Volunteer1'), (2, 'Volunteer2'), (3, 'Volunt... | What is the total number of volunteers for organizations in the 'Health' category? | SELECT COUNT(DISTINCT volunteer_id) FROM volunteer_events JOIN organizations ON volunteer_events.organization_id = organizations.id WHERE organizations.category = 'Health'; | gretelai_synthetic_text_to_sql |
CREATE TABLE bookings (booking_id INT, hotel_name VARCHAR(255), booking_date DATE, device_type VARCHAR(255)); | What is the number of hotel bookings made through mobile devices in the last month? | SELECT COUNT(*) FROM bookings WHERE device_type = 'mobile' AND booking_date >= DATEADD(month, -1, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE asia_artifacts (id INT, site_name VARCHAR(50), artifact_name VARCHAR(50), period VARCHAR(20), weight INT); | How many 'pottery' items in 'asia_artifacts' weigh more than 200g? | SELECT COUNT(*) FROM asia_artifacts WHERE artifact_name = 'pottery' AND weight > 200; | gretelai_synthetic_text_to_sql |
CREATE TABLE companies (id INT, name TEXT, founding_date DATE);CREATE TABLE funds (id INT, company_id INT, amount INT, funding_round TEXT); | List the names of companies that have had at least one round of funding over $10 million and were founded before 2010. | SELECT companies.name FROM companies INNER JOIN funds ON companies.id = funds.company_id WHERE funds.amount > 10000000 AND companies.founding_date < '2010-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE audience_stats (id INT, user_id INT, age INT, gender VARCHAR(50), location VARCHAR(255)); | What is the distribution of audience demographics by gender in the 'audience_stats' table? | SELECT gender, COUNT(*) as audience_count FROM audience_stats GROUP BY gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE OrganicProductSales (product_id INT, sale_date DATE, revenue DECIMAL(10,2)); | What was the total revenue of organic products sold in the USA in Q1 2022? | SELECT SUM(revenue) FROM OrganicProductSales WHERE sale_date BETWEEN '2022-01-01' AND '2022-03-31' AND country = 'USA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Cases (CaseID INT, State VARCHAR(255), BillingAmount DECIMAL(10, 2)); INSERT INTO Cases (CaseID, State, BillingAmount) VALUES (1, 'California', 2000.00); INSERT INTO Cases (CaseID, State, BillingAmount) VALUES (2, 'Texas', 3000.00); INSERT INTO Cases (CaseID, State, BillingAmount) VALUES (3, 'California', ... | What is the total billing amount for cases in the state of California? | SELECT SUM(BillingAmount) FROM Cases WHERE State = 'California'; | gretelai_synthetic_text_to_sql |
CREATE TABLE dishes (dish_id INT, dish VARCHAR(50), category VARCHAR(50), created_at TIMESTAMP);CREATE TABLE orders (order_id INT, dish_id INT, price DECIMAL(5,2)); | What is the total revenue for each category in the last month? | SELECT c.category, SUM(o.price) as total_revenue FROM dishes d JOIN orders o ON d.dish_id = o.dish_id WHERE d.created_at >= NOW() - INTERVAL '1 month' GROUP BY c.category; | gretelai_synthetic_text_to_sql |
CREATE TABLE suppliers (supplier_id INT, name VARCHAR(50), msc_certified BOOLEAN); CREATE TABLE seafood_purchases (purchase_id INT, supplier_id INT, weight DECIMAL(10,2)); INSERT INTO suppliers (supplier_id, name, msc_certified) VALUES (1, 'Sea Fresh', true), (2, 'Ocean Bounty', false), (3, 'Fish Direct', false); INSER... | What is the total weight of seafood sourced from MSC-certified suppliers? | SELECT SUM(weight) FROM seafood_purchases JOIN suppliers ON seafood_purchases.supplier_id = suppliers.supplier_id WHERE suppliers.msc_certified = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE ESA_Spacecraft (SpacecraftID INT, Name VARCHAR(50), Manufacturer VARCHAR(30)); INSERT INTO ESA_Spacecraft (SpacecraftID, Name, Manufacturer) VALUES (1, 'ATV-1 Jules Verne', 'EADS Astrium'), (2, 'ATV-2 Johannes Kepler', 'Airbus Defence and Space'), (3, 'ATV-3 Edoardo Amaldi', 'Airbus Safran Launchers'), (4,... | Which companies have manufactured spacecraft for ESA? | SELECT DISTINCT Manufacturer FROM ESA_Spacecraft; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (name TEXT, region TEXT, impacted_by TEXT); INSERT INTO marine_species (name, region, impacted_by) VALUES ('Polar Bear', 'Arctic', 'climate_change'), ('Narwhal', 'Arctic', 'climate_change'), ('Greenland Shark', 'Arctic', 'ocean_acidification'), ('Harp Seal', 'Arctic', 'climate_change'); | How many marine species are impacted by climate change in the Arctic region? | SELECT impacted_by, COUNT(*) AS count FROM marine_species WHERE region = 'Arctic' AND impacted_by = 'climate_change' GROUP BY impacted_by; | gretelai_synthetic_text_to_sql |
CREATE TABLE global_environment_facility (fund_id INT, project_name VARCHAR(100), country VARCHAR(50), sector VARCHAR(50), adaptation_flag BOOLEAN); INSERT INTO global_environment_facility (fund_id, project_name, country, sector, adaptation_flag) VALUES (1, 'Mangrove Restoration', 'Indonesia', 'Forestry', TRUE); | How many climate adaptation projects are in Southeast Asia funded by the Global Environment Facility? | SELECT COUNT(*) FROM global_environment_facility WHERE country LIKE '%%southeast%asia%%' AND adaptation_flag = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE mining_sites (site_id INT, site_name VARCHAR(255)); INSERT INTO mining_sites (site_id, site_name) VALUES (1, 'Site A'), (2, 'Site B'); CREATE TABLE mining_activities (activity_id INT, site_id INT, activity_date DATE); INSERT INTO mining_activities (activity_id, site_id, activity_date) VALUES (1, 1, '2022-0... | Delete the mining sites that have been inactive for the past six months | DELETE s FROM mining_sites s LEFT JOIN mining_activities a ON s.site_id = a.site_id WHERE a.activity_date IS NULL OR a.activity_date < DATE_SUB(CURDATE(), INTERVAL 6 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE regional_newspapers (article_id INT, publication_date DATE, region VARCHAR(50));CREATE TABLE international_newswire (article_id INT, publication_date DATE, country VARCHAR(50)); | How many articles were published in 'regional_newspapers' table and 'international_newswire' table for each month in 2020? | SELECT DATE_FORMAT(publication_date, '%Y-%m') AS month, COUNT(*) FROM regional_newspapers WHERE YEAR(publication_date) = 2020 GROUP BY month;SELECT DATE_FORMAT(publication_date, '%Y-%m') AS month, COUNT(*) FROM international_newswire WHERE YEAR(publication_date) = 2020 GROUP BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (user_id INT, user_disability BOOLEAN, user_country VARCHAR(50)); INSERT INTO users (user_id, user_disability, user_country) VALUES (1, true, 'Brazil'); | Find the top 2 countries with the highest number of users with visual impairments in the second quarter of 2021, and display the total number of users for each. | SELECT user_country, COUNT(*) as user_count FROM users WHERE EXTRACT(MONTH FROM user_last_login) BETWEEN 4 AND 6 AND user_disability = true GROUP BY user_country ORDER BY user_count DESC LIMIT 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE daily_water_usage (id INT, city VARCHAR(255), usage_liters INT, date DATE); INSERT INTO daily_water_usage (id, city, usage_liters, date) VALUES (1, 'Melbourne', 120000, '2020-01-01'), (2, 'Melbourne', 130000, '2020-01-02'), (3, 'Melbourne', 140000, '2020-01-03'); | What is the maximum water consumption (in liters) in a single day for the city of Melbourne, Australia in 2020? | SELECT MAX(usage_liters) FROM daily_water_usage WHERE city = 'Melbourne' AND date BETWEEN '2020-01-01' AND '2020-12-31'; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists indigenous_food; use indigenous_food; CREATE TABLE indigenous_farms (id INT, name TEXT, size_ha FLOAT, location TEXT); INSERT INTO indigenous_farms (id, name, size_ha, location) VALUES (1, 'Farm 3', 30.0, 'City E'), (2, 'Farm 4', 45.0, 'City F'); | What is the average size (in hectares) of all indigenous food system farms in the 'indigenous_food' schema? | SELECT AVG(size_ha) FROM indigenous_food.indigenous_farms; | gretelai_synthetic_text_to_sql |
CREATE TABLE Teams (TeamID INT, TeamName VARCHAR(50), AvgVIPTicketPrice DECIMAL(5,2)); | Which teams have the highest and lowest average ticket prices for VIP seats? | SELECT TeamName FROM Teams WHERE AvgVIPTicketPrice = (SELECT MAX(AvgVIPTicketPrice) FROM Teams) OR AvgVIPTicketPrice = (SELECT MIN(AvgVIPTicketPrice) FROM Teams); | gretelai_synthetic_text_to_sql |
CREATE TABLE chemical_production (id INT PRIMARY KEY, chemical_id VARCHAR(10), quantity INT, country VARCHAR(50)); INSERT INTO chemical_production (id, chemical_id, quantity, country) VALUES (1, 'C123', 500, 'USA'), (2, 'C456', 300, 'Canada'), (3, 'C123', 100, 'Germany'), (4, 'C456', 250, 'USA'), (5, 'C456', 350, 'Cana... | Find the average production quantity of chemical 'C456' in each country | SELECT country, AVG(quantity) FROM chemical_production WHERE chemical_id = 'C456' GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE TokyoVisitorAge (id INT, exhibition_name VARCHAR(30), city VARCHAR(20), year INT, visitor_age INT); INSERT INTO TokyoVisitorAge (id, exhibition_name, city, year, visitor_age) VALUES (1, 'Modern Art', 'Tokyo', 2021, 25), (2, 'Modern Art', 'Tokyo', 2021, 35), (3, 'Modern Art', 'Tokyo', 2021, 45); | What is the distribution of visitor ages for the 'Modern Art' exhibition in Tokyo in 2021? | SELECT visitor_age, COUNT(*) FROM TokyoVisitorAge WHERE exhibition_name = 'Modern Art' AND city = 'Tokyo' AND year = 2021 GROUP BY visitor_age; | gretelai_synthetic_text_to_sql |
CREATE TABLE menu (menu_id INT, menu_name VARCHAR(50), category VARCHAR(50), quantity_sold INT, price DECIMAL(5,2), month_sold INT); INSERT INTO menu (menu_id, menu_name, category, quantity_sold, price, month_sold) VALUES (3, 'New York Cheesecake', 'Desserts', 25, 7.99, 1), (4, 'Chocolate Lava Cake', 'Desserts', 30, 8.... | Which menu item in the 'Desserts' category has the highest price? | SELECT menu_name, MAX(price) FROM menu WHERE category = 'Desserts'; | gretelai_synthetic_text_to_sql |
CREATE TABLE suppliers (supplier_id INT, supplier_name TEXT);CREATE TABLE inventory (product_id INT, product_name TEXT, category TEXT);INSERT INTO suppliers VALUES (1, 'Supplier A'), (2, 'Supplier B'), (3, 'Supplier C'), (4, 'Supplier D'), (5, 'Supplier E');INSERT INTO inventory VALUES (100, 'Apples', 'Fruits'), (101, ... | Find the number of suppliers that have supplied at least one product in each of the following categories: fruits, vegetables, and grains. | SELECT COUNT(DISTINCT supplier_id) FROM (SELECT supplier_id FROM inventory WHERE category = 'Fruits' INTERSECT SELECT supplier_id FROM inventory WHERE category = 'Vegetables' INTERSECT SELECT supplier_id FROM inventory WHERE category = 'Grains') AS intersection; | gretelai_synthetic_text_to_sql |
CREATE TABLE restorative_completions (completion_id INT, program_id INT, state VARCHAR(20), completions INT); INSERT INTO restorative_completions (completion_id, program_id, state, completions) VALUES (1, 1, 'New York', 35), (2, 2, 'Florida', 42), (3, 3, 'Texas', 21); | Which restorative program in Florida has the highest number of successful completions? | SELECT program_id, MAX(completions) FROM restorative_completions WHERE state = 'Florida' GROUP BY program_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE mobile_subscribers (id INT, name VARCHAR(255), data_allowance INT, contract_start DATE); INSERT INTO mobile_subscribers (id, name, data_allowance, contract_start) VALUES (1, 'John Doe', 5000, '2020-01-01'), (2, 'Jane Doe', 3000, '2019-01-01'); CREATE TABLE customer_complaints (id INT, subscriber_id INT, co... | Update contract start date for mobile subscribers with data speed complaints | UPDATE mobile_subscribers SET contract_start = '2020-02-02' WHERE id IN (SELECT subscriber_id FROM customer_complaints WHERE complaint_type = 'Data Speed'); | gretelai_synthetic_text_to_sql |
CREATE TABLE countries (id INT, name TEXT, region TEXT); INSERT INTO countries (id, name, region) VALUES (1, 'USA', 'Americas'), (2, 'China', 'APAC'), (3, 'France', 'EMEA'), (4, 'Canada', 'Americas'); | Count the number of packages shipped to each country in the 'EMEA' region | SELECT country, COUNT(*) FROM packages JOIN (SELECT id, name FROM countries WHERE region = 'EMEA') countries ON packages.country = countries.name GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE treatments (treatment_id INT, condition VARCHAR(20)); INSERT INTO treatments (treatment_id, condition) VALUES (1, 'PTSD'), (2, 'OCD'); | Identify the unique treatments for PTSD and OCD | SELECT DISTINCT condition FROM treatments; | gretelai_synthetic_text_to_sql |
CREATE TABLE employees (ssn VARCHAR(11), first_name VARCHAR(20), last_name VARCHAR(20), job_title VARCHAR(30)); | Update the job title for the veteran with the SSN 123-45-6789 to 'Senior Software Engineer'. | UPDATE employees SET job_title = 'Senior Software Engineer' WHERE ssn = '123-45-6789'; | gretelai_synthetic_text_to_sql |
CREATE TABLE SafetyIncidents (id INT, year INT, accident_reported INT); INSERT INTO SafetyIncidents (id, year, accident_reported) VALUES (1, 2019, 1), (2, 2020, 2), (3, 2021, 3); | What is the number of accidents reported in '2021' in the 'SafetyIncidents' table? | SELECT SUM(accident_reported) FROM SafetyIncidents WHERE year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE mineral_extraction (id INT, mine_id INT, year INT, quantity INT);CREATE TABLE mine (id INT, name VARCHAR(255), location VARCHAR(255)); INSERT INTO mine (id, name, location) VALUES (1, 'Indonesian Coal', 'Indonesia'); INSERT INTO mineral_extraction (id, mine_id, year, quantity) VALUES (1, 1, 2019, 5000); | Present total mineral extraction in Indonesia by year. | SELECT year, SUM(quantity) as total_mineral_extraction FROM mineral_extraction JOIN mine ON mineral_extraction.mine_id = mine.id WHERE mine.location = 'Indonesia' GROUP BY year; | gretelai_synthetic_text_to_sql |
CREATE TABLE customers (customer_id INT, customer_name TEXT, country TEXT); INSERT INTO customers (customer_id, customer_name, country) VALUES (1, 'Jessica Smith', 'US'), (2, 'David Johnson', 'CA'), (3, 'Sarah Thompson', 'US'), (4, 'Michael Brown', 'UK'), (5, 'Emily Davis', 'US'); CREATE TABLE sales (sale_id INT, custo... | Who are the top 3 customers in terms of spending on vegan skincare products in the United States? | SELECT c.customer_name, SUM(s.sale_quantity * p.is_vegan) as total_spent_on_vegan_products FROM sales s JOIN customers c ON s.customer_id = c.customer_id JOIN products p ON s.product_id = p.product_id WHERE c.country = 'US' GROUP BY c.customer_name ORDER BY total_spent_on_vegan_products DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE chemical_production (id INT PRIMARY KEY, chemical_id VARCHAR(10), quantity INT, country VARCHAR(50)); INSERT INTO chemical_production (id, chemical_id, quantity, country) VALUES (1, 'C123', 500, 'USA'), (2, 'C456', 300, 'Canada'), (3, 'C123', 100, 'Germany'), (4, 'C456', 250, 'USA'), (5, 'C456', 350, 'Cana... | List the chemical_ids and total production quantities for chemicals produced in the USA | SELECT chemical_id, SUM(quantity) FROM chemical_production WHERE country = 'USA' GROUP BY chemical_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Volunteers (id INT, volunteer_name VARCHAR(255), program VARCHAR(255), volunteer_hours INT, volunteer_date DATE); INSERT INTO Volunteers (id, volunteer_name, program, volunteer_hours, volunteer_date) VALUES (1, 'Yamada Taro', 'Disaster Relief', 25, '2020-03-14'), (2, 'Tanaka Hanako', 'Disaster Relief', 30,... | How many hours did volunteers contribute to disaster relief programs in Japan in 2020? | SELECT SUM(volunteer_hours) FROM Volunteers WHERE program = 'Disaster Relief' AND volunteer_date BETWEEN '2020-01-01' AND '2020-12-31'; | 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.