context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE Attorneys (AttorneyID INT, YearsOfExperience INT, State VARCHAR(255)); INSERT INTO Attorneys (AttorneyID, YearsOfExperience, State) VALUES (1, 10, 'New York'); INSERT INTO Attorneys (AttorneyID, YearsOfExperience, State) VALUES (2, 3, 'California'); INSERT INTO Attorneys (AttorneyID, YearsOfExperience, Sta... | What is the minimum billing amount for cases handled by attorneys from New York with more than 5 years of experience? | SELECT MIN(BillingAmount) FROM Cases JOIN Attorneys ON Cases.AttorneyID = Attorneys.AttorneyID WHERE Attorneys.State = 'New York' AND Attorneys.YearsOfExperience > 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE ExplainableAI_Table1 (id INT, data VARCHAR(50), explanation TEXT); CREATE TABLE ExplainableAI_Table2 (id INT, model VARCHAR(50), metrics VARCHAR(500)); CREATE TABLE ExplainableAI_Logs (id INT, log_message TEXT); | What is the total number of records in explainable AI tables, excluding the 'ExplainableAI_Logs' table? | SELECT SUM(table_rows) as total_rows FROM information_schema.tables WHERE table_name NOT IN ('ExplainableAI_Logs') AND table_schema = 'your_schema'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Cases (CaseID INT, State VARCHAR(20), BillingAmount DECIMAL(10, 2)); INSERT INTO Cases (CaseID, State, BillingAmount) VALUES (1, 'California', 5000.00), (2, 'Texas', 3500.00), (3, 'California', 4000.00), (4, 'New York', 6000.00); | What is the average billing amount for cases in Texas and New York? | SELECT AVG(BillingAmount) FROM Cases WHERE State IN ('Texas', 'New York'); | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists biotech; CREATE TABLE if not exists biotech.startups (id INT, name VARCHAR(100), location VARCHAR(50), total_funding FLOAT); INSERT INTO biotech.startups (id, name, location, total_funding) VALUES (1, 'Genomic Inc', 'San Francisco', 25000000.00); INSERT INTO biotech.startups (id, name, locat... | What is the total funding received by biotech startups in the Bay Area? | SELECT SUM(total_funding) FROM biotech.startups WHERE location = 'San Francisco' OR location = 'San Jose'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Stations (line VARCHAR(20), station VARCHAR(20), accessibility BOOLEAN); INSERT INTO Stations (line, station, accessibility) VALUES ('Red Line', 'Park Street', true), ('Red Line', 'Downtown Crossing', false); | Which stations on the Red Line have wheelchair accessibility? | SELECT station FROM Stations WHERE line = 'Red Line' AND accessibility = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE Events (event_id INT, event_name VARCHAR(50), event_date DATE, event_type VARCHAR(50), attendee_id INT); CREATE TABLE Attendees (attendee_id INT, first_name VARCHAR(50), last_name VARCHAR(50), birthdate DATE); | What is the average age of audience members for events held in the past month, sorted by event type? | SELECT event_type, AVG(YEAR(CURRENT_DATE) - YEAR(a.birthdate)) AS avg_age FROM Events e JOIN Attendees a ON e.attendee_id = a.attendee_id WHERE e.event_date >= DATEADD(month, -1, GETDATE()) GROUP BY event_type ORDER BY avg_age DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE counselors (counselor_id INT, name TEXT, age INT); INSERT INTO counselors (counselor_id, name, age) VALUES (1, 'James', 35), (2, 'Michelle', 40); CREATE TABLE patients (patient_id INT, counselor_id INT, age INT); INSERT INTO patients (patient_id, counselor_id, age) VALUES (1, 1, 25), (2, 1, 30), (3, 2, 45)... | What is the average age of patients who received therapy from counselors named "James" or "Michelle"? | SELECT AVG(patients.age) FROM patients JOIN counselors ON patients.counselor_id = counselors.counselor_id WHERE counselors.name IN ('James', 'Michelle'); | gretelai_synthetic_text_to_sql |
CREATE SCHEMA Africa; CREATE TABLE IntelligenceAgencies (id INT, name VARCHAR(255), location VARCHAR(255), date DATE); INSERT INTO IntelligenceAgencies (id, name, location, date) VALUES (1, 'NISA', 'Nigeria', '2013-08-01'); INSERT INTO IntelligenceAgencies (id, name, location, date) VALUES (2, 'DGSE', 'Algeria', '1989-... | Show all intelligence agencies in the 'Africa' schema. | SELECT * FROM Africa.IntelligenceAgencies; | gretelai_synthetic_text_to_sql |
CREATE TABLE Visitor_Events (visitor_id INT, event_id INT); CREATE TABLE Events (id INT, name VARCHAR(20)); ALTER TABLE Visitors ADD COLUMN attended_event BOOLEAN DEFAULT FALSE; | What is the number of visitors who have never attended a special event? | SELECT COUNT(*) FROM Visitors WHERE attended_event = FALSE; | gretelai_synthetic_text_to_sql |
bikes (id, model, year, battery_capacity) | Insert new records for electric bikes produced in 2021 in the bikes table. | INSERT INTO bikes (model, year, battery_capacity) VALUES ('E-Cruiser', 2021, 48), ('E-Roadster', 2021, 52), ('E-Hybrid', 2021, 42); | gretelai_synthetic_text_to_sql |
CREATE TABLE energy_generation (country VARCHAR(255), energy_source VARCHAR(255), percentage INT); INSERT INTO energy_generation (country, energy_source, percentage) VALUES ('Canada', 'Renewable', 60), ('Canada', 'Non-renewable', 40); | What is the percentage of energy generated from renewable sources in Canada? | SELECT percentage FROM energy_generation WHERE country = 'Canada' AND energy_source = 'Renewable'; | gretelai_synthetic_text_to_sql |
CREATE TABLE providers (provider_id INT, provider_name VARCHAR(255)); CREATE TABLE cases (case_id INT, provider_id INT, case_date DATE, case_type VARCHAR(255)); | What is the number of access to justice cases handled by each provider by month? | SELECT MONTH(case_date) as month, provider_name, COUNT(*) as total_cases FROM cases JOIN providers ON cases.provider_id = providers.provider_id WHERE case_type = 'Access to Justice' GROUP BY month, provider_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE vessels (vessel_id VARCHAR(255), vessel_name VARCHAR(255)); INSERT INTO vessels (vessel_id, vessel_name) VALUES (1, 'Vessel1'), (2, 'Vessel2'); CREATE TABLE cargo (cargo_id INT, vessel_id VARCHAR(255), weight FLOAT); INSERT INTO cargo (cargo_id, vessel_id, weight) VALUES (1, 1, 3000), (2, 1, 5000), (3, 2, ... | What is the total weight of cargo for vessel 'Vessel1'? | SELECT SUM(weight) FROM cargo WHERE vessel_name = 'Vessel1'; | gretelai_synthetic_text_to_sql |
CREATE TABLE RegulatoryFrameworks (id INT, framework VARCHAR(255), country VARCHAR(255), effective_date DATE); INSERT INTO RegulatoryFrameworks (id, framework, country, effective_date) VALUES (1, 'FrameworkA', 'China', '2021-12-01'), (2, 'FrameworkB', 'Japan', '2022-02-01'); | List the regulatory frameworks in place for smart contracts in the Asia-Pacific region as of 2022-01-01. | SELECT framework FROM RegulatoryFrameworks WHERE country IN ('Asia', 'Pacific') AND effective_date <= '2022-01-01' GROUP BY framework; | gretelai_synthetic_text_to_sql |
CREATE TABLE museum_exhibits (exhibit_id INT, age INT, num_visitors INT); INSERT INTO museum_exhibits (exhibit_id, age, num_visitors) VALUES (1, 10, 50), (2, 20, 75), (3, 30, 100); | What is the total number of visitors at the "museum_exhibits" table by age group? | SELECT age, SUM(num_visitors) FROM museum_exhibits GROUP BY age; | gretelai_synthetic_text_to_sql |
CREATE TABLE security_incidents (id INT, sector VARCHAR(20), incident VARCHAR(50)); INSERT INTO security_incidents (id, sector, incident) VALUES (1, 'Transportation', 'Data Breach'); | What is the most common type of security incident in the transportation sector? | SELECT incident, COUNT(*) as count FROM security_incidents WHERE sector = 'Transportation' GROUP BY incident ORDER BY count DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE MonitoringStation (ID INT, Name VARCHAR(100), Location VARCHAR(100), Elevation FLOAT, AnnualCO2 FLOAT); INSERT INTO MonitoringStation (ID, Name, Location, Elevation, AnnualCO2) VALUES (1, 'Station C', 'Svalbard', 150, 420); INSERT INTO MonitoringStation (ID, Name, Location, Elevation, AnnualCO2) VALUES (2,... | What is the average carbon dioxide concentration in the past 5 years for each monitoring station? | SELECT Name, AVG(AnnualCO2) OVER (PARTITION BY Name ORDER BY Name ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS AvgAnnualCO2 FROM MonitoringStation WHERE YEAR(CurrentDate) - YEAR(DateInstalled) BETWEEN 1 AND 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE space_missions (launch_year INT, launch_country VARCHAR(50)); INSERT INTO space_missions (launch_year, launch_country) VALUES (1990, 'USA'), (1991, 'Russia'), (1992, 'USA'), (1993, 'China'), (1994, 'Russia'), (1995, 'USA'), (1996, 'Russia'), (1997, 'USA'), (1998, 'Russia'), (1999, 'USA'); | Find the number of space missions launched by each country in the 1990s | SELECT launch_country, COUNT(*) as mission_count FROM space_missions WHERE launch_year BETWEEN 1990 AND 1999 GROUP BY launch_country; | gretelai_synthetic_text_to_sql |
CREATE TABLE SiteB (artifact_id INT, artifact_name VARCHAR(50), date_found DATE); | How many artifacts are in 'SiteB'? | SELECT COUNT(artifact_id) FROM SiteB; | gretelai_synthetic_text_to_sql |
CREATE TABLE forest_management (id INT, name VARCHAR(50), region VARCHAR(50), country VARCHAR(50)); | How many forest management records are there for Mexico? | SELECT COUNT(*) FROM forest_management WHERE country = 'Mexico'; | gretelai_synthetic_text_to_sql |
CREATE TABLE exoplanet (name VARCHAR(50), discovery_mission VARCHAR(50));INSERT INTO exoplanet (name, discovery_mission) VALUES ('Kepler-22b', 'Kepler'), ('Kepler-62e', 'Kepler'), ('Kepler-62f', 'Kepler'), ('Kepler-186f', 'Kepler'), ('Kepler-296e', 'Kepler'), ('Kepler-296f', 'Kepler'), ('Kepler-442b', 'Kepler'), ('Kepl... | What are the names of the exoplanets discovered by the Kepler mission? | SELECT name FROM exoplanet WHERE discovery_mission = 'Kepler'; | gretelai_synthetic_text_to_sql |
CREATE TABLE PublicTransportation (id INT, trip_id INT, mode VARCHAR(50), country VARCHAR(50)); INSERT INTO PublicTransportation (id, trip_id, mode, country) VALUES (1, 12345, 'Bus', 'Japan'), (2, 67890, 'Train', 'Japan'), (3, 23456, 'Subway', 'Japan'), (4, 78901, 'Ferry', 'Japan'); | What is the total number of public transportation trips in Japan, broken down by mode of transportation? | SELECT context.mode, COUNT(context.id) FROM (SELECT * FROM PublicTransportation WHERE PublicTransportation.country = 'Japan') AS context GROUP BY context.mode; | gretelai_synthetic_text_to_sql |
CREATE TABLE InfrastructureProjects (Id INT, Name VARCHAR(255), Type VARCHAR(255), ConstructionCost FLOAT); INSERT INTO InfrastructureProjects (Id, Name, Type, ConstructionCost) VALUES (1, 'Dam', 'Road', 5000000), (2, 'Bridge', 'Bridge', 2000000), (3, 'Road', 'Railway', 1500000), (4, 'Tunnel', 'Tunnel', 8000000), (5, '... | What is the maximum and minimum construction cost for each infrastructure type? | SELECT Type, MIN(ConstructionCost) as MinCost, MAX(ConstructionCost) as MaxCost FROM InfrastructureProjects GROUP BY Type; | gretelai_synthetic_text_to_sql |
CREATE TABLE donations (id INT, donor_id INT, amount DECIMAL); INSERT INTO donations (id, donor_id, amount) VALUES (1, 1, 50.00), (2, 2, 100.00); CREATE TABLE donors (id INT, name TEXT, country TEXT); INSERT INTO donors (id, name, country) VALUES (1, 'Ravi', 'India'), (2, 'Sita', 'Nepal'); | What is the minimum donation amount for donors from India? | SELECT MIN(amount) FROM donations JOIN donors ON donations.donor_id = donors.id WHERE donors.country = 'India'; | gretelai_synthetic_text_to_sql |
CREATE TABLE tv_show (tv_show_id INT, title VARCHAR(50), genre VARCHAR(50), viewers INT); INSERT INTO tv_show (tv_show_id, title, genre, viewers) VALUES (1, 'Show 1', 'Comedy', 1000), (2, 'Show 2', 'Drama', 2000), (3, 'Show 3', 'Comedy', 1500); | What's the number of viewers for each TV show genre? | SELECT genre, SUM(viewers) FROM tv_show GROUP BY genre; | gretelai_synthetic_text_to_sql |
CREATE TABLE WasteGeneration (region VARCHAR(50), date DATE, waste_quantity INT); INSERT INTO WasteGeneration VALUES ('North', '2021-01-01', 1500), ('North', '2021-01-02', 1700), ('South', '2021-01-01', 1200), ('South', '2021-01-02', 1300), ('East', '2021-01-01', 1800), ('East', '2021-01-02', 2000), ('West', '2021-01-0... | What is the total waste generation by region in the past year? | SELECT region, SUM(waste_quantity) FROM WasteGeneration WHERE date >= DATEADD(year, -1, GETDATE()) GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE USLaunchedSatellites (SatelliteName TEXT, Country TEXT);CREATE TABLE RussiaLaunchedSatellites (SatelliteName TEXT, Country TEXT); | Find all satellites that have been launched by the US and Russia, but not by both. | (SELECT SatelliteName FROM USLaunchedSatellites WHERE Country = 'United States' EXCEPT SELECT SatelliteName FROM RussiaLaunchedSatellites WHERE Country = 'United States') UNION (SELECT SatelliteName FROM RussiaLaunchedSatellites WHERE Country = 'Russia' EXCEPT SELECT SatelliteName FROM USLaunchedSatellites WHERE Countr... | gretelai_synthetic_text_to_sql |
CREATE TABLE Tunnels (id INT, country VARCHAR(20), continent VARCHAR(20), year INT, length FLOAT); INSERT INTO Tunnels (id, country, continent, year, length) VALUES (1, 'France', 'Europe', 2005, 10000); INSERT INTO Tunnels (id, country, continent, year, length) VALUES (2, 'Germany', 'Europe', 2008, 12000); INSERT INTO ... | List the number of tunnels constructed in each 'European' country per year, in reverse chronological order. | SELECT country, year, COUNT(*) as tunnel_count FROM Tunnels WHERE continent = 'Europe' GROUP BY country, year ORDER BY country, year DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE investments (investment_id INT, sector VARCHAR(50), esg_score INT, investment_date DATE); INSERT INTO investments (investment_id, sector, esg_score, investment_date) VALUES (1, 'Healthcare', 4, '2022-01-01'), (2, 'Healthcare', 5, '2022-02-01'), (3, 'Healthcare', 3, '2022-03-01'), (4, 'Healthcare', 6, '2022... | What is the average ESG score for investments in the healthcare sector, broken down by quarter? | SELECT EXTRACT(QUARTER FROM investment_date) as quarter, AVG(esg_score) as avg_esg_score FROM investments WHERE sector = 'Healthcare' GROUP BY quarter ORDER BY quarter ASC; | gretelai_synthetic_text_to_sql |
CREATE TABLE user_activity (user_id INT, date DATE, platform VARCHAR(20), engagement_time INT); INSERT INTO user_activity VALUES (1, '2022-01-01', 'Facebook', 120), (2, '2022-01-01', 'Facebook', 150); | What is the average daily engagement time on Facebook for users aged 18-24 in the past month, broken down by gender? | SELECT u.gender, AVG(ua.engagement_time) as avg_daily_time FROM user_activity ua JOIN user_profile up ON ua.user_id = up.user_id WHERE ua.platform = 'Facebook' AND up.age BETWEEN 18 AND 24 AND ua.date >= DATEADD(month, -1, GETDATE()) GROUP BY u.gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE Volunteers (VolunteerID INT, Community VARCHAR(50), HoursSpent FLOAT, VolunteerDate DATE); | What is the total number of volunteer hours contributed by volunteers from underrepresented communities in 2021? | SELECT SUM(HoursSpent) as TotalHours FROM Volunteers WHERE VolunteerDate BETWEEN '2021-01-01' AND '2021-12-31' AND Community IN ('Historically Black', 'Indigenous', 'LGBTQ+', 'Persons with Disabilities'); | gretelai_synthetic_text_to_sql |
CREATE TABLE hotels (hotel_id INT, name VARCHAR(50), location VARCHAR(50), stars INT); | Show all the hotels located in 'Paris' from the hotels table. | SELECT * FROM hotels WHERE location = 'Paris'; | gretelai_synthetic_text_to_sql |
CREATE TABLE escape_incidents (id INT, farm_country TEXT, year INT, escaped_fish INT); INSERT INTO escape_incidents (id, farm_country, year, escaped_fish) VALUES (1, 'Japan', 2020, 20), (2, 'Japan', 2021, 30); | How many fish escape incidents were reported in Japan in 2020? | SELECT COUNT(*) FROM escape_incidents WHERE farm_country = 'Japan' AND year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID int, EmployeeName varchar(50), Department varchar(50), Salary float, Gender varchar(10)); INSERT INTO Employees (EmployeeID, EmployeeName, Department, Salary, Gender) VALUES (1, 'John Doe', 'IT', 80000, 'Male'), (2, 'Jane Smith', 'HR', 70000, 'Female'), (3, 'Mike Johnson', 'IT', 85000... | How many female employees are there in each department? | SELECT Department, COUNT(*) as Num_Female_Employees FROM Employees WHERE Gender = 'Female' GROUP BY Department; | gretelai_synthetic_text_to_sql |
CREATE TABLE City (id INT, name VARCHAR(255)); INSERT INTO City (id, name) VALUES (1, 'New York'), (2, 'Los Angeles'), (3, 'Chicago'); CREATE TABLE Agriculture (id INT, city_id INT, minimum_temperature INT, maximum_temperature INT); INSERT INTO Agriculture (id, city_id, minimum_temperature, maximum_temperature) VALUES ... | What is the average temperature required for urban agriculture in specific cities? | SELECT City.name, AVG(Agriculture.minimum_temperature + (Agriculture.maximum_temperature - Agriculture.minimum_temperature)/2) FROM City INNER JOIN Agriculture ON City.id = Agriculture.city_id GROUP BY City.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists car_share (id INT, state VARCHAR(20), car_type VARCHAR(20), quantity INT);INSERT INTO car_share (id, state, car_type, quantity) VALUES (1, 'California', 'electric_car', 1000), (2, 'California', 'hybrid_car', 800), (3, 'Oregon', 'electric_car', 600), (4, 'Oregon', 'hybrid_car', 500); | What is the average number of electric cars in the states of California and Oregon? | SELECT AVG(quantity) FROM car_share WHERE state IN ('California', 'Oregon') AND car_type = 'electric_car'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Vulnerabilities (id INT, name VARCHAR(255), category VARCHAR(255), risk_score INT, resolved DATE); INSERT INTO Vulnerabilities (id, name, category, risk_score, resolved) VALUES (1, 'Heartbleed', 'Software', 8, '2022-01-15'); | What is the average risk score of vulnerabilities in the 'Software' category that have been resolved in the last month? | SELECT AVG(risk_score) FROM Vulnerabilities WHERE category = 'Software' AND resolved >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH) AND resolved IS NOT NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE Players (PlayerID INT, Name VARCHAR(50), Game VARCHAR(50), Score INT); INSERT INTO Players (PlayerID, Name, Game, Score) VALUES (1, 'John Doe', 'GameA', 1000); INSERT INTO Players (PlayerID, Name, Game, Score) VALUES (2, 'Jane Doe', 'GameB', 2000); INSERT INTO Players (PlayerID, Name, Game, Score) VALUES (... | Select the names, games, and scores of players who have a higher score than the average score in game A or game B. | SELECT Name, Game, Score FROM Players WHERE Game IN ('GameA', 'GameB') AND Score > (SELECT AVG(Score) FROM Players WHERE Game = Players.Game); | gretelai_synthetic_text_to_sql |
CREATE TABLE MiningLocations (LocationID INT, Country VARCHAR(20), Site INT); INSERT INTO MiningLocations (LocationID, Country, Site) VALUES (1, 'Canada', 3), (2, 'USA', 5), (3, 'Mexico', 2); | How many mining sites are there in each country? | SELECT Country, COUNT(*) FROM MiningLocations GROUP BY Country; | gretelai_synthetic_text_to_sql |
CREATE TABLE forests_location (id INT, region VARCHAR(255), country VARCHAR(255)); INSERT INTO forests_location VALUES (1, 'Amazon Basin', 'Brazil'); | How many forests are there in the Amazon basin? | SELECT COUNT(*) FROM forests_location WHERE region = 'Amazon Basin'; | gretelai_synthetic_text_to_sql |
CREATE TABLE donations (id INT, donor INT, donation FLOAT, donation_date DATE, country TEXT); INSERT INTO donations (id, donor, donation, donation_date, country) VALUES (1, 1, 50.00, '2020-04-01', 'Canada'), (2, 1, 75.00, '2020-05-01', 'Canada'), (3, 2, 100.00, '2020-06-01', 'Canada'), (4, 3, 25.00, '2021-01-01', 'Cana... | What was the average donation amount per month in Canada for the last two years? | SELECT EXTRACT(MONTH FROM donation_date) AS month, AVG(donation) FROM donations WHERE country = 'Canada' AND donation_date BETWEEN DATEADD(year, -2, CURRENT_DATE) AND CURRENT_DATE GROUP BY month ORDER BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE properties (id INT, city VARCHAR(20), listing_price INT, inclusive_housing BOOLEAN); INSERT INTO properties (id, city, listing_price, inclusive_housing) VALUES (1, 'Los Angeles', 700000, true); INSERT INTO properties (id, city, listing_price, inclusive_housing) VALUES (2, 'Los Angeles', 600000, false); | Count the number of properties in Los Angeles with a listing price above $600,000 and inclusive housing features. | SELECT COUNT(*) FROM properties WHERE city = 'Los Angeles' AND listing_price > 600000 AND inclusive_housing = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE HealthcareAccess (Area VARCHAR(50), Score INT, Year INT); INSERT INTO HealthcareAccess (Area, Score, Year) VALUES ('Rural', 70, 2020), ('Urban', 85, 2020), ('Suburban', 80, 2020); | Minimum healthcare access score in rural areas in 2020. | SELECT MIN(Score) FROM HealthcareAccess WHERE Area = 'Rural' AND Year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE ArtWorkSales (artworkID INT, artistID INT, saleDate DATE, revenue DECIMAL(10,2)); CREATE TABLE Artists (artistID INT, artistName VARCHAR(50)); | Who are the top 10 artists with the highest total revenue in the last 3 years? | SELECT a.artistName, SUM(aws.revenue) as total_revenue FROM ArtWorkSales aws JOIN Artists a ON aws.artistID = a.artistID WHERE saleDate BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 3 YEAR) AND CURRENT_DATE GROUP BY a.artistName ORDER BY total_revenue DESC LIMIT 10; | gretelai_synthetic_text_to_sql |
CREATE TABLE Players (PlayerID INT, Wins INT, Losses INT, Game VARCHAR(50), Region VARCHAR(50)); INSERT INTO Players (PlayerID, Wins, Losses, Game, Region) VALUES (1, 150, 50, 'Dota 2', 'Asia'); INSERT INTO Players (PlayerID, Wins, Losses, Game, Region) VALUES (2, 200, 30, 'Dota 2', 'Asia'); INSERT INTO Players (Player... | What is the maximum number of wins for players from Asia in Dota 2? | SELECT Region, MAX(Wins) as MaxWins FROM Players WHERE Game = 'Dota 2' AND Region = 'Asia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE SALES(city VARCHAR(20), item VARCHAR(20), price DECIMAL(5,2)); INSERT INTO SALES(city, item, price) VALUES('New York', 'Sustainable Dress', 100.00), ('New York', 'Sustainable Shirt', 50.00), ('London', 'Sustainable Pants', 75.00), ('London', 'Sustainable Jacket', 125.00); | What is the average price of sustainable clothing items sold in New York and London? | SELECT AVG(price) FROM SALES WHERE city IN ('New York', 'London') AND item LIKE '%Sustainable%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Countries (id INT, name VARCHAR(50), region VARCHAR(50)); INSERT INTO Countries (id, name, region) VALUES (1, 'India', 'South Asia'), (2, 'Pakistan', 'South Asia'), (3, 'Bangladesh', 'South Asia'), (4, 'Sri Lanka', 'South Asia'), (5, 'Nepal', 'South Asia'); CREATE TABLE EndangeredLanguages (id INT, country... | What is the maximum number of endangered languages in South Asian countries? | SELECT COUNT(*) as max_endangered_languages FROM (SELECT * FROM EndangeredLanguages WHERE country_id = Countries.id GROUP BY country_id ORDER BY COUNT(*) DESC LIMIT 1) el; | gretelai_synthetic_text_to_sql |
CREATE TABLE patients (id INT, name VARCHAR(50), age INT, gender VARCHAR(10), race VARCHAR(20), ethnicity VARCHAR(30)); INSERT INTO patients (id, name, age, gender, race, ethnicity) VALUES (1, 'John Doe', 35, 'Male', 'Caucasian', 'Non-Hispanic'), (2, 'Jane Smith', 40, 'Female', 'African American', 'African American'), ... | Retrieve the number of patients by age group in the patients table. | SELECT CASE WHEN age >= 18 AND age < 30 THEN '18-29' WHEN age >= 30 AND age < 50 THEN '30-49' WHEN age >= 50 AND age < 65 THEN '50-64' ELSE '65+' END AS age_group, COUNT(*) as count FROM patients GROUP BY age_group; | gretelai_synthetic_text_to_sql |
See context | What is the average claim amount by gender? | SELECT * FROM avg_claim_by_gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE wind_capacity (country VARCHAR(255), year INT, capacity FLOAT); INSERT INTO wind_capacity (country, year, capacity) VALUES ('Germany', 2018, 50000), ('Germany', 2019, 55000), ('Spain', 2018, 45000), ('Spain', 2019, 50000); | What was the total installed capacity of wind energy in Germany in 2018 and 2019? | SELECT SUM(capacity) as total_capacity, year FROM wind_capacity WHERE country = 'Germany' GROUP BY year; | gretelai_synthetic_text_to_sql |
CREATE TABLE menu_categories (category_id INT, category_name TEXT); CREATE TABLE menu (menu_id INT, category_id INT, dish_name TEXT); CREATE TABLE menu_ingredients (menu_ingredient_id INT, menu_id INT, ingredient_id INT); CREATE TABLE ingredients (ingredient_id INT, ingredient_name TEXT, weight REAL); | Display the average weight (in kg) of ingredients for each dish category in the menu_categories, menu, menu_ingredients, and ingredients tables. | SELECT menu_categories.category_name, AVG(ingredients.weight) FROM menu_categories INNER JOIN menu ON menu_categories.category_id = menu.category_id INNER JOIN menu_ingredients ON menu.menu_id = menu_ingredients.menu_id INNER JOIN ingredients ON menu_ingredients.ingredient_id = ingredients.ingredient_id GROUP BY menu_c... | gretelai_synthetic_text_to_sql |
CREATE TABLE warehouses(id INT, name VARCHAR(255), capacity INT); INSERT INTO warehouses VALUES(1, 'A01', 5000), (2, 'A02', 7000); | Get total warehouse capacity for warehouses A01 and A02 | SELECT SUM(capacity) FROM warehouses WHERE name IN ('A01', 'A02'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Space_Mission (id INT, name VARCHAR(255), manufacturer VARCHAR(255), launch_date DATE, launch_status VARCHAR(255)); INSERT INTO Space_Mission (id, name, manufacturer, launch_date, launch_status) VALUES (1, 'GPS III SV03', 'SpaceX', '2020-06-30', 'Success'), (2, 'Starlink-9', 'SpaceX', '2020-08-18', 'Succes... | How many space missions has each manufacturer launched? | SELECT manufacturer, COUNT(*) as number_of_missions FROM Space_Mission GROUP BY manufacturer; | gretelai_synthetic_text_to_sql |
CREATE TABLE matches (id INT, player_id INT, opponent_id INT, winner_id INT); INSERT INTO matches VALUES (1, 1, 2, 1); INSERT INTO matches VALUES (2, 2, 1, 2); INSERT INTO matches VALUES (3, 1, 3, 1); INSERT INTO matches VALUES (4, 3, 1, 3); | What are the total number of matches played by each player and their respective win rates? | SELECT player_id, COUNT(*) as total_matches, SUM(CASE WHEN player_id = winner_id THEN 1 ELSE 0 END) / COUNT(*) as win_rate FROM matches GROUP BY player_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE virtual_tourism_extended (country TEXT, revenue FLOAT, date DATE); INSERT INTO virtual_tourism_extended (country, revenue, date) VALUES ('Spain', 25000.0, '2022-03-01'), ('Spain', 28000.0, '2022-04-01'), ('Italy', 18000.0, '2022-03-01'), ('Italy', 20000.0, '2022-04-01'), ('Germany', 30000.0, '2022-02-01'),... | Virtual tourism revenue in the last 6 months for each country? | SELECT country, SUM(revenue) FROM virtual_tourism_extended WHERE date >= '2022-01-01' AND date <= '2022-06-01' GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE virtual_tours (tour_id INT, tour_name TEXT, country TEXT, hotel_count INT); INSERT INTO virtual_tours (tour_id, tour_name, country, hotel_count) VALUES (1, 'Tour 1', 'France', 150), (2, 'Tour 2', 'Spain', 200), (3, 'Tour 3', 'France', 250); | What is the market share of each virtual tour platform for hotels in France? | SELECT tour_name, (hotel_count / (SELECT SUM(hotel_count) FROM virtual_tours WHERE country = 'France')) as market_share FROM virtual_tours WHERE country = 'France'; | gretelai_synthetic_text_to_sql |
CREATE TABLE company (id INT, name VARCHAR(255), sector VARCHAR(255), founding_date DATE, funding FLOAT, founder_veteran BOOLEAN); INSERT INTO company (id, name, sector, founding_date, funding, founder_veteran) VALUES (1, 'Echo Inc', 'Technology', '2010-01-01', 3000000.0, FALSE); INSERT INTO company (id, name, sector, ... | What is the maximum funding amount received by a startup founded by a veteran in the healthcare sector? | SELECT MAX(funding) FROM company WHERE sector = 'Healthcare' AND founder_veteran = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE green_buildings (id INT, name TEXT, country TEXT); CREATE TABLE countries (id INT, name TEXT); | Minimum number of green buildings in each country? | SELECT countries.name, MIN(green_buildings.id) FROM countries LEFT JOIN green_buildings ON countries.id = green_buildings.country GROUP BY countries.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE renewable_projects (id INT PRIMARY KEY, project_name VARCHAR(255), project_location VARCHAR(255), project_type VARCHAR(255), capacity_mw FLOAT); | Find the number of renewable energy projects for each project type. | SELECT project_type, COUNT(*) FROM renewable_projects GROUP BY project_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE IndigenousSeedBanks (bank_name VARCHAR(50), country VARCHAR(50), num_varieties INT); INSERT INTO IndigenousSeedBanks (bank_name, country, num_varieties) VALUES ('Semillas de Vida', 'Guatemala', 3000), ('Banco de Semillas Nativas', 'Mexico', 4000), ('Semillas Ancestrales', 'Peru', 2500); | How many indigenous seed banks exist in Latin America, and what is the total number of seed varieties they store? | SELECT COUNT(*), SUM(num_varieties) FROM IndigenousSeedBanks WHERE country IN (SELECT country FROM Country WHERE region = 'Latin America'); | gretelai_synthetic_text_to_sql |
CREATE TABLE regions_lang (region_id INT, region VARCHAR(20), language VARCHAR(20), initiative_id INT, initiative_type VARCHAR(20)); INSERT INTO regions_lang (region_id, region, language, initiative_id, initiative_type) VALUES (1, 'North', 'English', 1, 'Open Pedagogy'), (2, 'South', 'Spanish', 2, 'Open Pedagogy'), (3,... | How many open pedagogy initiatives were conducted in each region by language? | SELECT region, language, COUNT(*) as num_initiatives FROM regions_lang WHERE initiative_type = 'Open Pedagogy' GROUP BY region, language; | gretelai_synthetic_text_to_sql |
CREATE TABLE Customers (Customer_ID INT, Customer_Name TEXT, Dispensary_ID INT); INSERT INTO Customers (Customer_ID, Customer_Name, Dispensary_ID) VALUES (1, 'John Smith', 1); CREATE TABLE Sales (Sale_ID INT, Customer_ID INT, Total_Purchase DECIMAL); INSERT INTO Sales (Sale_ID, Customer_ID, Total_Purchase) VALUES (1, 1... | Identify the top 3 customers with the highest total purchases at a specific dispensary. | SELECT Customer_Name, SUM(Total_Purchase) as Total FROM Sales JOIN Customers ON Sales.Customer_ID = Customers.Customer_ID WHERE Dispensary_ID = 1 GROUP BY Customer_ID ORDER BY Total DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE Volunteers (VolunteerID int, ProjectID int, VolunteerHours decimal(10, 2), VolunteerDate date); INSERT INTO Volunteers (VolunteerID, ProjectID, VolunteerHours, VolunteerDate) VALUES (1, 1, 5.0, '2022-01-01'), (2, 1, 8.0, '2022-02-01'), (3, 2, 3.0, '2022-01-01'), (4, 3, 7.0, '2022-01-01'); | Find the total number of volunteers and total volunteer hours per project, in descending order of the total volunteer hours? | SELECT ProjectID, COUNT(DISTINCT VolunteerID) AS TotalNumberOfVolunteers, SUM(VolunteerHours) OVER (PARTITION BY ProjectID ORDER BY SUM(VolunteerHours)) AS TotalVolunteerHours FROM Volunteers GROUP BY ProjectID ORDER BY TotalVolunteerHours DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE StreamingData (StreamID INT, SongID INT, StreamDate DATE, Genre VARCHAR(50), SongName VARCHAR(100), StreamCount INT, Country VARCHAR(50)); INSERT INTO StreamingData (StreamID, SongID, StreamDate, Genre, SongName, StreamCount, Country) VALUES (7, 7, '2022-04-01', 'Pop', 'Shape of You', 400, 'US'); INSERT IN... | What is the most streamed song in the US? | SELECT SongName, StreamCount FROM StreamingData WHERE Country = 'US' AND StreamCount = (SELECT MAX(StreamCount) FROM StreamingData WHERE Country = 'US'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Exhibitions (ExhibitionID INT, Name VARCHAR(50)); INSERT INTO Exhibitions (ExhibitionID, Name) VALUES (1, 'Impressionists'), (2, 'Ancient Art'); CREATE TABLE Visits (VisitID INT, VisitorID INT, ExhibitionID INT); INSERT INTO Visits (VisitID, VisitorID, ExhibitionID) VALUES (1, 1, 1), (2, 2, 1), (3, 3, 2), ... | Rank exhibitions by the number of repeat visitors, ordered from the highest to the lowest? | SELECT ExhibitionID, Name, RANK() OVER (ORDER BY COUNT(VisitorID) DESC) AS RepeatVisitorRank FROM Visits V JOIN Exhibitions E ON V.ExhibitionID = E.ExhibitionID GROUP BY ExhibitionID, Name ORDER BY RepeatVisitorRank DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE construction_workers (id INT, name VARCHAR(50), hourly_rate DECIMAL(10, 2), state VARCHAR(2), hours_worked INT); INSERT INTO construction_workers (id, name, hourly_rate, state, hours_worked) VALUES (1, 'John Doe', 40, 'Texas', 160); INSERT INTO construction_workers (id, name, hourly_rate, state, hours_work... | What is the total labor cost for construction workers in Texas and California? | SELECT SUM(hourly_rate * hours_worked) FROM construction_workers WHERE state IN ('Texas', 'California'); | gretelai_synthetic_text_to_sql |
CREATE TABLE cranes (id INT PRIMARY KEY, name VARCHAR(50), type VARCHAR(50), quantity INT); | What is the total number of containers handled by all cranes in the 'cranes' table? | SELECT SUM(quantity) FROM cranes; | gretelai_synthetic_text_to_sql |
CREATE TABLE field_temperature (field_id INT, date DATE, temperature FLOAT); INSERT INTO field_temperature (field_id, date, temperature) VALUES (6, '2021-06-01', 28.5), (6, '2021-06-02', 29.3), (6, '2021-06-03', 30.1); | What was the average temperature in field 6 over the last month? | SELECT AVG(temperature) FROM field_temperature WHERE field_id = 6 AND date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE Programs (ProgramID INT, ProgramName VARCHAR(50)); INSERT INTO Programs (ProgramID, ProgramName) VALUES (1, 'Education'), (2, 'Health'), (3, 'Environment'); CREATE TABLE Volunteers (VolunteerID INT, ProgramID INT); INSERT INTO Volunteers (VolunteerID, ProgramID) VALUES (1, 1), (2, 1), (3, 2), (4, 2), (5, 2... | Find the programs that have more than 10 volunteers? | SELECT ProgramID, ProgramName FROM Programs WHERE ProgramID IN (SELECT ProgramID FROM Volunteers GROUP BY ProgramID HAVING COUNT(DISTINCT VolunteerID) > 10); | gretelai_synthetic_text_to_sql |
CREATE TABLE events (id INT PRIMARY KEY, name VARCHAR(50), type VARCHAR(30), date DATE); INSERT INTO events (id, name, type, date) VALUES (1, 'Throat Singing Festival', 'Music', '2023-07-20'), (2, 'Language Preservation Conference', 'Language', '2023-08-01'); | Delete all events related to language preservation. | DELETE FROM events WHERE type = 'Language'; | gretelai_synthetic_text_to_sql |
CREATE TABLE satellite_data (satellite_id INT, name VARCHAR(100), launch_date DATE, country_of_origin VARCHAR(50), function VARCHAR(50), lifespan INT); | What is the average lifespan of satellites in the satellite_data table, grouped by country of origin? | SELECT country_of_origin, AVG(lifespan) FROM satellite_data GROUP BY country_of_origin; | gretelai_synthetic_text_to_sql |
CREATE TABLE Labor (LaborID INT, MineID INT, Year INT, LaborProductivityScore FLOAT); INSERT INTO Labor (LaborID, MineID, Year, LaborProductivityScore) VALUES (1, 1, 2019, 5.5); INSERT INTO Labor (LaborID, MineID, Year, LaborProductivityScore) VALUES (2, 1, 2018, 6.0); INSERT INTO Labor (LaborID, MineID, Year, LaborPro... | What is the minimum labor productivity score in diamond mines in South Africa? | SELECT MIN(l.LaborProductivityScore) as MinLaborProductivity FROM Labor l INNER JOIN Mines m ON l.MineID = m.MineID WHERE m.MineType = 'Diamond' AND m.Country = 'South Africa'; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteer_hours (id INT, volunteer_id INT, volunteer_date DATE, hours_volunteered DECIMAL(10, 2)); INSERT INTO volunteer_hours (id, volunteer_id, volunteer_date, hours_volunteered) VALUES (1, 1, '2022-01-01', 2.0), (2, 2, '2022-02-02', 3.0); | How many volunteers joined each month in 2022, and what was their total volunteering time? | SELECT DATE_TRUNC('month', volunteer_date) AS month, COUNT(DISTINCT volunteer_id) AS volunteers_joined, SUM(hours_volunteered) AS total_volunteering_time FROM volunteer_hours WHERE volunteer_date >= '2022-01-01' AND volunteer_date < '2023-01-01' GROUP BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE Satellites (Id INT, Name VARCHAR(20), Age INT, DeploymentDate DATE); INSERT INTO Satellites VALUES (1, 'Sat1', 15, '2005-01-01'), (2, 'Sat2', 20, '2002-05-05'), (3, 'Sat3', 12, '2010-03-03'); | List the top 3 oldest satellites and their deployment dates? | SELECT Name, DeploymentDate FROM (SELECT Name, Age, DeploymentDate, ROW_NUMBER() OVER (ORDER BY Age DESC) as rn FROM Satellites) t WHERE rn <= 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE berlin.metro_stations (id INT, station_name VARCHAR); CREATE TABLE berlin.station_lines (id INT, station_id INT, line_name VARCHAR); | List all unique metro stations and their respective lines in the 'berlin' schema. | SELECT DISTINCT berlin.metro_stations.station_name, berlin.station_lines.line_name FROM berlin.metro_stations INNER JOIN berlin.station_lines ON berlin.metro_stations.id = berlin.station_lines.station_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE departments (id INT, department TEXT); CREATE TABLE volunteers (id INT, name TEXT, department_id INT, volunteer_hours INT); INSERT INTO departments (id, department) VALUES (1, 'Marketing'), (2, 'Finance'), (3, 'Operations'); INSERT INTO volunteers (id, name, department_id, volunteer_hours) VALUES (1, '... | How many volunteers are there in each department in 'volunteers' table? | SELECT d.department, COUNT(v.id) as volunteer_count FROM departments d INNER JOIN volunteers v ON d.id = v.department_id GROUP BY d.department; | gretelai_synthetic_text_to_sql |
CREATE TABLE VirtualTours (TourID INTEGER, TourName TEXT, Location TEXT); INSERT INTO VirtualTours (TourID, TourName, Location) VALUES (1, 'Virtual Safari', 'Kenya'), (2, 'Virtual Castle Tour', 'Scotland'), (3, 'Virtual Trek', 'Nepal'), (4, 'Virtual Skiing', 'Switzerland'), (5, 'Virtual Temple Tour', 'Japan'); | What is the total number of virtual tours in 'Asia' and 'Europe'? | SELECT SUM(CASE WHEN Location IN ('Asia', 'Europe') THEN 1 ELSE 0 END) FROM VirtualTours; | gretelai_synthetic_text_to_sql |
CREATE TABLE permits (permit_id INT, project_id INT, labor_cost DECIMAL(10, 2), state VARCHAR(255), issue_date DATE); | What is the total number of building permits issued for projects with a labor cost greater than $1,000,000 in the state of Texas in 2019? | SELECT COUNT(*) FROM permits WHERE state = 'Texas' AND labor_cost > 1000000 AND YEAR(issue_date) = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE PlayerDailySessions (PlayerID int, Age int, HoursPlayedPerDay int); INSERT INTO PlayerDailySessions (PlayerID, Age, HoursPlayedPerDay) VALUES (1, 30, 2), (2, 25, 3); | What is the average number of hours played per day for players in the 25-34 age range? | SELECT AVG(HoursPlayedPerDay) FROM PlayerDailySessions WHERE Age BETWEEN 25 AND 34; | gretelai_synthetic_text_to_sql |
CREATE TABLE plans (id INT PRIMARY KEY, name VARCHAR(50), monthly_cost DECIMAL(5,2)); INSERT INTO plans (id, name, monthly_cost) VALUES (1, 'Basic', 20.00), (2, 'Premium', 50.00); | What is the total revenue for each mobile plan in the "plans" table, including plans that have never been sold? | SELECT name, IFNULL(SUM(monthly_cost), 0) AS total_revenue FROM plans LEFT JOIN sales ON plans.id = sales.plan_id GROUP BY name; | gretelai_synthetic_text_to_sql |
CREATE TABLE NewStaff (StaffID INT, FirstName VARCHAR(50), LastName VARCHAR(50), Email VARCHAR(50)); INSERT INTO NewStaff (StaffID, FirstName, LastName, Email) VALUES (4, 'Ahmed', 'Khan', 'ahmedkhan@example.com'); CREATE TABLE NewAccommodations (RequestID INT, StaffID INT, RequestDate DATETIME); | Insert a new record for a disability accommodations request made by a new staff member. | INSERT INTO NewAccommodations (RequestID, StaffID, RequestDate) VALUES (1, (SELECT StaffID FROM NewStaff WHERE Email = 'ahmedkhan@example.com'), '2021-09-01'); | gretelai_synthetic_text_to_sql |
CREATE TABLE incidents (incident_id INT PRIMARY KEY, incident_date DATE, incident_location VARCHAR(50)); INSERT INTO incidents (incident_id, incident_date, incident_location) VALUES (1, '2022-01-01', 'HQ'), (2, '2022-02-15', 'Branch01'), (3, '2022-03-30', 'HQ'); | Identify the number of security incidents in the 'HQ' location from the last quarter. | SELECT COUNT(*) FROM incidents WHERE incident_location = 'HQ' AND incident_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE OceanFloorMapping (id INT, location VARCHAR(50), depth INT); INSERT INTO OceanFloorMapping (id, location, depth) VALUES (1, 'Mariana Trench', 10000), (2, 'Sunda Trench', 8000), (3, 'Philippine Trench', 6500), (4, 'Kermadec Trench', 10000), (5, 'Tonga Trench', 10800); | Delete all records from the 'OceanFloorMapping' table with depths greater than 5000 meters | DELETE FROM OceanFloorMapping WHERE depth > 5000; | gretelai_synthetic_text_to_sql |
CREATE TABLE patients (patient_id INT PRIMARY KEY AUTO_INCREMENT, first_name VARCHAR(50), last_name VARCHAR(50), age INT, gender VARCHAR(10), ethnicity VARCHAR(50)); | Find the number of patients in each ethnicity group in the 'patients' table, ordered by the number of patients in descending order. | SELECT ethnicity, COUNT(*) as num_patients FROM patients GROUP BY ethnicity ORDER BY num_patients DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE recipients (id INT, name TEXT, age INT, gender TEXT); CREATE TABLE aid (id INT, recipient_id INT, program_id INT); CREATE TABLE programs (id INT, name TEXT, location TEXT); INSERT INTO recipients VALUES (1, 'Ahmed Al-Sayed', 30, 'Male'), (2, 'Fatima Al-Hamadi', 25, 'Female'); INSERT INTO aid VALUES (1, 1, ... | Who are the recipients that received aid from both the Food Security and Health programs in Yemen? | SELECT r.name FROM recipients r INNER JOIN aid a1 ON r.id = a1.recipient_id INNER JOIN programs p1 ON a1.program_id = p1.id INNER JOIN aid a2 ON r.id = a2.recipient_id INNER JOIN programs p2 ON a2.program_id = p2.id WHERE p1.name = 'Food Security' AND p2.name = 'Health' AND p1.location = 'Yemen' AND p2.location = 'Yeme... | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (donor_id INT, is_recurring BOOLEAN, country VARCHAR(50)); INSERT INTO donors (donor_id, is_recurring, country) VALUES (1, true, 'India'), (2, false, 'United States'); CREATE TABLE donations (donor_id INT, donation_amount DECIMAL(10,2), donation_date DATE); INSERT INTO donations (donor_id, donation_... | What was the average donation amount for recurring donors from India? | SELECT AVG(donation_amount) FROM donations d JOIN donors don ON d.donor_id = don.donor_id WHERE don.is_recurring = true AND don.country = 'India'; | gretelai_synthetic_text_to_sql |
CREATE TABLE crypto_assets (asset_id INT, asset_name VARCHAR(50), blockchain_id INT); CREATE TABLE blockchains (blockchain_id INT, blockchain_name VARCHAR(50)); INSERT INTO crypto_assets (asset_id, asset_name, blockchain_id) VALUES (1, 'Bitcoin', 1); INSERT INTO blockchains (blockchain_id, blockchain_name) VALUES (1, '... | List the digital assets and their corresponding blockchain networks from the 'crypto_assets' and 'blockchains' tables. | SELECT crypto_assets.asset_name, blockchains.blockchain_name FROM crypto_assets INNER JOIN blockchains ON crypto_assets.blockchain_id = blockchains.blockchain_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE clean_energy_investments (id INT, country VARCHAR(255), year INT, investment_amount INT); INSERT INTO clean_energy_investments (id, country, year, investment_amount) VALUES (1, 'Japan', 2019, 2000000), (2, 'South Korea', 2019, 3000000); | What was the total investment in clean energy policy trends in Japan and South Korea in 2019? | SELECT SUM(investment_amount) FROM clean_energy_investments WHERE country IN ('Japan', 'South Korea') AND year = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE CommunityPrograms (ProgramName VARCHAR(50), StartDate DATE); | Insert a new record into the 'CommunityPrograms' table with the following data: 'NeighborhoodWatch', '2023-03-14' | INSERT INTO CommunityPrograms (ProgramName, StartDate) VALUES ('NeighborhoodWatch', '2023-03-14'); | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, price DECIMAL, ethical BOOLEAN); INSERT INTO products (product_id, price, ethical) VALUES (1, 15.99, true), (2, 25.49, false), (3, 12.99, true), (4, 18.99, true), (5, 9.99, false); | Identify products with a price higher than the average price of ethical products. | SELECT product_id, price FROM products WHERE price > (SELECT AVG(price) FROM products WHERE ethical = true); | gretelai_synthetic_text_to_sql |
CREATE TABLE products (id INT, name VARCHAR(255)); INSERT INTO products (id, name) VALUES (1, 'Product K'); INSERT INTO products (id, name) VALUES (2, 'Product L'); CREATE TABLE food_safety_inspections (id INT, product_id INT, inspection_date DATE); INSERT INTO food_safety_inspections (id, product_id, inspection_date) ... | What is the earliest food safety inspection date for each product? | SELECT p.name AS product_name, MIN(f.inspection_date) AS earliest_inspection_date FROM products p JOIN food_safety_inspections f ON p.id = f.product_id GROUP BY p.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE recycled_materials (product_id INT, material_type VARCHAR(50), material_quantity INT); CREATE TABLE sales (sale_id INT, sale_date DATE, product_id INT); INSERT INTO recycled_materials (product_id, material_type, material_quantity) VALUES (1, 'recycled material A', 100), (2, 'recycled material B', 50), (3, ... | What is the total quantity of recycled materials used in the production of products sold in the last quarter of 2021? | SELECT SUM(recycled_materials.material_quantity) FROM recycled_materials INNER JOIN sales ON recycled_materials.product_id = sales.product_id WHERE sales.sale_date BETWEEN '2021-10-01' AND '2021-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Recipients (Country VARCHAR(255), Received DECIMAL(10,2)); INSERT INTO Recipients (Country, Received) VALUES ('Syria', 42000000), ('Yemen', 39000000), ('SouthSudan', 35000000), ('Somalia', 31000000); | List the top 3 recipients of humanitarian assistance during peacekeeping operations? | SELECT Country, Received FROM (SELECT Country, Received, ROW_NUMBER() OVER (ORDER BY Received DESC) AS Rank FROM Recipients) AS RankedRecipients WHERE Rank <= 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE Infrastructure (id INT, name VARCHAR(100), type VARCHAR(50), location VARCHAR(100), state VARCHAR(50)); INSERT INTO Infrastructure (id, name, type, location, state) VALUES (12, 'Grand Coulee Dam', 'Hydroelectric Dam', 'Grand Coulee', 'Washington'); | Show the number of hydroelectric dams in Washington | SELECT COUNT(*) FROM Infrastructure WHERE type = 'Hydroelectric Dam' AND state = 'Washington'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Students (StudentID INT, DisabilityType TEXT, Region TEXT); INSERT INTO Students (StudentID, DisabilityType, Region) VALUES (1, 'VisualImpairment', 'North'), (2, 'HearingImpairment', 'South'), (3, 'MentalHealth', 'East'); CREATE TABLE Accommodations (StudentID INT, DisabilityType TEXT, AccommodationCost DE... | What is the total cost of accommodations for students with hearing impairments in the Midwest region? | SELECT SUM(AccommodationCost) as TotalCost FROM Accommodations JOIN Students ON Accommodations.StudentID = Students.StudentID WHERE DisabilityType = 'HearingImpairment' AND Region = 'Midwest'; | gretelai_synthetic_text_to_sql |
CREATE TABLE cases (case_id INT, case_type VARCHAR(255)); CREATE TABLE billing (bill_id INT, case_id INT, amount DECIMAL(10,2)); | What is the total billing amount for each case type, based on the 'case_type' column in the 'cases' table? | SELECT c.case_type, SUM(b.amount) FROM cases c INNER JOIN billing b ON c.case_id = b.case_id GROUP BY c.case_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE green_buildings (id INT, city VARCHAR(50), year INT); CREATE TABLE green_buildings_stats (city VARCHAR(50), avg_buildings_per_year FLOAT); | What is the average number of green buildings constructed per year in each city? | INSERT INTO green_buildings_stats SELECT city, AVG(year) FROM green_buildings GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE WeatherData (Station VARCHAR(255), Date DATE, Temperature FLOAT); INSERT INTO WeatherData (Station, Date, Temperature) VALUES ('StationA', '2021-01-01', -10.5), ('StationB', '2021-01-01', -12.3); | What is the highest temperature recorded at each Arctic research station in 2021? | SELECT Station, MAX(Temperature) FROM WeatherData WHERE YEAR(Date) = 2021 GROUP BY Station; | gretelai_synthetic_text_to_sql |
CREATE TABLE digital_assets (asset_name VARCHAR(10), transaction_count INT); INSERT INTO digital_assets (asset_name, transaction_count) VALUES ('BTC', 5000), ('ETH', 7000), ('LTC', 3000); | What is the total number of transactions for the digital asset 'ETH' on a particular date? | SELECT transaction_count FROM digital_assets WHERE asset_name = 'ETH'; | gretelai_synthetic_text_to_sql |
CREATE TABLE threat_intelligence (id INT, report_number VARCHAR(255), country VARCHAR(255), date DATE); | What is the number of threat intelligence reports generated for each country in the last 6 months? | SELECT country, COUNT(*) FROM threat_intelligence WHERE date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) GROUP BY country; | 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.