context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE WaterConservationInitiatives (InitiativeID INT PRIMARY KEY, Location VARCHAR(255), InitiativeType VARCHAR(255), Cost INT, StartDate DATETIME, EndDate DATETIME); INSERT INTO WaterConservationInitiatives (InitiativeID, Location, InitiativeType, Cost, StartDate, EndDate) VALUES (1, 'Georgia', 'Water-efficient... | What is the total cost and number of initiatives for water conservation in Georgia in the year 2022? | SELECT InitiativeType, SUM(Cost) as TotalCost, COUNT(*) as TotalInitiatives FROM WaterConservationInitiatives WHERE Location = 'Georgia' AND YEAR(StartDate) = 2022 GROUP BY InitiativeType; | gretelai_synthetic_text_to_sql |
CREATE TABLE astronauts (id INT, name VARCHAR(50), gender VARCHAR(10), nationality VARCHAR(50)); CREATE TABLE space_missions (id INT, mission_name VARCHAR(50), launch_date DATE, return_date DATE, astronaut_id INT); | Who are the first and last female astronauts to go to the International Space Station? | SELECT astronauts.name FROM astronauts INNER JOIN space_missions ON astronauts.id = space_missions.astronaut_id WHERE gender = 'Female' AND space_missions.mission_name = 'International Space Station' GROUP BY astronauts.name ORDER BY launch_date LIMIT 1; SELECT astronauts.name FROM astronauts INNER JOIN space_missions ... | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (DonationID INT, DonationDate DATE, DonationAmount DECIMAL(10,2), ProgramID INT); INSERT INTO Donations (DonationID, DonationDate, DonationAmount, ProgramID) VALUES (1, '2022-01-01', 100.00, 1), (2, '2022-01-15', 200.00, 1), (3, '2022-02-01', 300.00, 2), (4, '2022-02-15', 400.00, 2); | What is the total donation amount per program? | SELECT ProgramID, SUM(DonationAmount) OVER (PARTITION BY ProgramID ORDER BY ProgramID) AS TotalDonation FROM Donations; | gretelai_synthetic_text_to_sql |
CREATE TABLE transactions (id INT, customer_region VARCHAR(20), transaction_amount DECIMAL(10,2)); INSERT INTO transactions (id, customer_region, transaction_amount) VALUES (1, 'North America', 500.00), (2, 'North America', 750.00), (3, 'South America', 800.00), (4, 'Europe', 900.00); | What is the total transaction amount for 'South America' customers? | SELECT SUM(transaction_amount) FROM transactions WHERE customer_region = 'South America'; | gretelai_synthetic_text_to_sql |
CREATE TABLE media_contents (content_id INTEGER, title VARCHAR(255), duration INTEGER, release_year INTEGER); INSERT INTO media_contents (content_id, title, duration, release_year) VALUES (1, 'Content1', 120, 2021), (2, 'Content2', 90, 2020), (3, 'Content3', 150, 2022), (4, 'Content4', 100, 2019), (5, 'Content5', 110, ... | What is the total duration of all media contents produced in 2022? | SELECT SUM(duration) FROM media_contents WHERE release_year = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE forests (id INT PRIMARY KEY, name VARCHAR(50), country VARCHAR(50), hectares DECIMAL(10,2)); CREATE TABLE trees (id INT PRIMARY KEY, species VARCHAR(50), age INT, forest_id INT, FOREIGN KEY (forest_id) REFERENCES forests(id)); INSERT INTO forests (id, name, country, hectares) VALUES (1, 'Eucalyptus Forest'... | Which forests in Australia have eucalyptus trees? | SELECT forests.name FROM forests INNER JOIN trees ON forests.id = trees.forest_id WHERE forests.country = 'Australia' AND trees.species = 'Eucalyptus'; | gretelai_synthetic_text_to_sql |
CREATE TABLE charging_stations (country VARCHAR(50), num_stations INT); INSERT INTO charging_stations (country, num_stations) VALUES ('Germany', 25000), ('France', 22000), ('Spain', 12000); | How many electric vehicle charging stations are there in Germany, France, and Spain? | SELECT country, num_stations FROM charging_stations WHERE country IN ('Germany', 'France', 'Spain'); | gretelai_synthetic_text_to_sql |
CREATE TABLE company (id INT, name VARCHAR(255), industry VARCHAR(255)); INSERT INTO company (id, name, industry) VALUES (1, 'Acme Inc', 'tech'), (2, 'Beta Corp', 'finance'); | Find the number of female founders in the "tech" industry | SELECT COUNT(*) FROM company WHERE industry = 'tech' AND gender = 'female'; | gretelai_synthetic_text_to_sql |
CREATE TABLE games (id INT, player_id INT, kills INT, deaths INT, assists INT); INSERT INTO games VALUES (1, 1, 10, 5, 3); INSERT INTO games VALUES (2, 1, 15, 7, 5); INSERT INTO games VALUES (3, 2, 5, 2, 1); INSERT INTO games VALUES (4, 2, 8, 4, 2); | What are the average kills, deaths, and assists per game for each player? | SELECT player_id, AVG(kills) as avg_kills, AVG(deaths) as avg_deaths, AVG(assists) as avg_assists FROM games GROUP BY player_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE national_parks (country VARCHAR(20), name VARCHAR(50), visitors INT); INSERT INTO national_parks (country, name, visitors) VALUES ('Canada', 'Banff', 4000000), ('Canada', 'Jasper', 2500000), ('US', 'Yosemite', 3000000), ('US', 'Yellowstone', 4500000); | What is the total number of tourists visiting national parks in Canada and the US? | SELECT SUM(visitors) FROM national_parks WHERE country IN ('Canada', 'US'); | gretelai_synthetic_text_to_sql |
CREATE TABLE SpaceMissions (MissionID INT, MissionName VARCHAR(255), LaunchDate DATE); INSERT INTO SpaceMissions (MissionID, MissionName, LaunchDate) VALUES (100, 'Apollo 10', '1969-05-18'), (101, 'Apollo 11', '1969-07-16'); | Insert a new space mission record for 'Mars Sample Return Mission 1' with a launch date of '2030-10-01' into the SpaceMissions table. | INSERT INTO SpaceMissions (MissionID, MissionName, LaunchDate) VALUES (102, 'Mars Sample Return Mission 1', '2030-10-01'); | gretelai_synthetic_text_to_sql |
CREATE TABLE broadband_subscribers (subscriber_id INT, region VARCHAR(20), plan_start_date DATE, plan_end_date DATE); INSERT INTO broadband_subscribers (subscriber_id, region, plan_start_date, plan_end_date) VALUES (1, 'South', '2021-01-01', '2021-01-31'), (2, 'East', '2021-02-01', '2021-02-28'); | Find the total number of broadband subscribers who have upgraded their plans in the last month in the 'South' and 'East' regions. | SELECT COUNT(*) FROM broadband_subscribers WHERE region IN ('South', 'East') AND plan_end_date >= CURDATE() - INTERVAL 1 MONTH AND plan_start_date < CURDATE() - INTERVAL 1 MONTH; | gretelai_synthetic_text_to_sql |
CREATE TABLE Crops(state VARCHAR(255), name VARCHAR(255)); INSERT INTO Crops(state, name) VALUES('California', 'Corn'), ('California', 'Soybean'), ('California', 'Wheat'), ('Texas', 'Cotton'), ('Texas', 'Rice'); | List the precision farming crops that are grown in either California or Texas, but not in both. | SELECT name FROM Crops WHERE state = 'California' UNION SELECT name FROM Crops WHERE state = 'Texas' EXCEPT SELECT name FROM Crops WHERE state = 'California' INTERSECT SELECT name FROM Crops WHERE state = 'Texas'; | gretelai_synthetic_text_to_sql |
CREATE TABLE healthcare_staff (name VARCHAR(255), gender VARCHAR(255), position VARCHAR(255), hospital_id INT); INSERT INTO healthcare_staff (name, gender, position, hospital_id) VALUES ('Dr. John Doe', 'Male', 'Doctor', 1), ('Dr. Jane Smith', 'Female', 'Doctor', 2), ('Dr. Maria Garcia', 'Female', 'Doctor', 3); | What is the name, position, and hospital_id of the staff member with name 'Dr. John Doe' in the 'healthcare_staff' table? | SELECT name, position, hospital_id FROM healthcare_staff WHERE name = 'Dr. John Doe'; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (sale_id INT, product_category VARCHAR(255), sale_date DATE, revenue DECIMAL(10,2)); CREATE TABLE garment_manufacturing (garment_category VARCHAR(255), manufacturing_date DATE, co2_emissions INT); | Find the total revenue and CO2 emissions for each garment category in 2022. | SELECT sales.product_category, SUM(sales.revenue) as total_revenue, SUM(garment_manufacturing.co2_emissions) as total_co2_emissions FROM sales JOIN garment_manufacturing ON sales.product_category = garment_manufacturing.garment_category WHERE sales.sale_date BETWEEN '2022-01-01' AND '2022-12-31' GROUP BY sales.product_... | gretelai_synthetic_text_to_sql |
CREATE TABLE startups(id INT, name TEXT, industry TEXT, funding_round TEXT, founder TEXT); INSERT INTO startups VALUES(1, 'StartupA', 'Tech', 'Seed', 'Asian'); INSERT INTO startups VALUES(2, 'StartupB', 'Tech', 'Series A', 'Man'); INSERT INTO startups VALUES(3, 'StartupC', 'Healthcare', 'Seed', 'Hispanic'); INSERT INTO... | How many startups founded by individuals from underrepresented racial or ethnic backgrounds have received Series A funding or higher in the Tech sector? | SELECT COUNT(*) FROM startups WHERE industry = 'Tech' AND founder IN ('Underrepresented Minority', 'African American', 'Hispanic', 'Native American') AND funding_round >= 'Series A'; | gretelai_synthetic_text_to_sql |
CREATE TABLE waste_generation (city VARCHAR(255), year INT, waste_kg FLOAT); INSERT INTO waste_generation (city, year, waste_kg) VALUES ('San Francisco', 2020, 300000); | What is the total waste generation in kg for the city of San Francisco in 2020? | SELECT waste_kg FROM waste_generation WHERE city = 'San Francisco' AND year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE construction_workers (worker_id INT, name TEXT); CREATE TABLE project_types (project_id INT, project_type TEXT); CREATE TABLE worker_projects (worker_id INT, project_id INT, total_labor_hours INT); INSERT INTO construction_workers (worker_id, name) VALUES (1, 'John Doe'), (2, 'Jane Smith'), (3, 'Maria Garc... | Show the average labor hours per worker for sustainable building projects, excluding workers who have not worked on any sustainable projects. | SELECT AVG(worker_projects.total_labor_hours / NULLIF(COUNT(DISTINCT worker_projects.project_id), 0)) FROM worker_projects INNER JOIN (SELECT DISTINCT worker_id FROM worker_projects INNER JOIN project_types ON worker_projects.project_id = project_types.project_id WHERE project_types.project_type = 'Sustainable') AS sus... | gretelai_synthetic_text_to_sql |
CREATE TABLE SatelliteLaunches (SatelliteName TEXT, LaunchCountry TEXT);CREATE TABLE ISSMissions (AstronautName TEXT, MissionCountry TEXT); | Find all countries that have launched satellites, but have not launched any missions to the International Space Station, and display them in reverse alphabetical order. | (SELECT LaunchCountry FROM SatelliteLaunches EXCEPT SELECT MissionCountry FROM ISSMissions) EXCEPT (SELECT NULL) ORDER BY LaunchCountry DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE menu(id INT, item VARCHAR(255), price DECIMAL(10,2), rating INT); INSERT INTO menu(id, item, price, rating) VALUES (1, 'Salad', 10.00, 4), (2, 'Sandwich', 12.00, 5), (3, 'Pasta', 15.00, 3); | What is the average rating for menu items in each price range? | SELECT price_range, AVG(rating) as avg_rating FROM (SELECT CASE WHEN price <= 10 THEN 'Low' WHEN price <= 20 THEN 'Medium' ELSE 'High' END as price_range, rating FROM menu) subquery GROUP BY price_range; | gretelai_synthetic_text_to_sql |
CREATE TABLE SiteArtifactCount (SiteID varchar(5), ArtifactCount int); INSERT INTO SiteArtifactCount (SiteID, ArtifactCount) VALUES ('S001', 250), ('S002', 300), ('S003', 400); | Which sites have the most artifacts? | SELECT SiteID, ArtifactCount FROM SiteArtifactCount ORDER BY ArtifactCount DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Mining_Sites (Id INT, Name VARCHAR(50), Mineral VARCHAR(50), Elevation FLOAT, Type VARCHAR(50)); INSERT INTO Mining_Sites (Id, Name, Mineral, Elevation, Type) VALUES (1, 'Site A', 'Gold', 5000.00, 'underground'); INSERT INTO Mining_Sites (Id, Name, Mineral, Elevation, Type) VALUES (2, 'Site B', 'Silver', 6... | What is the total number of mining sites and their average elevation, partitioned by the type of mineral extracted? | SELECT Type, COUNT(*) as Total_Sites, AVG(Elevation) as Avg_Elevation FROM Mining_Sites GROUP BY Type; | gretelai_synthetic_text_to_sql |
CREATE TABLE mobile_customers (customer_id INT, data_usage FLOAT, city VARCHAR(20), state VARCHAR(20)); INSERT INTO mobile_customers (customer_id, data_usage, city, state) VALUES (1, 3.5, 'San Francisco', 'California'), (2, 6.2, 'Los Angeles', 'California'); | What is the average data usage by mobile customers in California, grouped by the city? | SELECT city, AVG(data_usage) FROM mobile_customers WHERE state = 'California' GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE complaints (department VARCHAR(20), complaint_count INT, complaint_date DATE); INSERT INTO complaints (department, complaint_count, complaint_date) VALUES ('Public Works', 300, '2022-03-01'); | How many complaints were filed with the city of Sydney, broken down by department, for the month of March 2022? | SELECT department, SUM(complaint_count) FROM complaints WHERE complaint_date BETWEEN '2022-03-01' AND '2022-03-31' GROUP BY department; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (id INT, species_name VARCHAR(50), habitat_depth FLOAT); INSERT INTO marine_species (id, species_name, habitat_depth) VALUES (1, 'Orca', 200.0), (2, 'Blue Whale', 500.0); | Find the maximum depth at which the Orca is found. | SELECT MAX(habitat_depth) FROM marine_species WHERE species_name = 'Orca'; | gretelai_synthetic_text_to_sql |
CREATE TABLE drug_approval (drug_name TEXT, approval_year INTEGER); | List all drugs approved in 2020 with their sales in Q4 2020 | SELECT a.drug_name, s.revenue FROM drug_approval a INNER JOIN sales s ON a.drug_name = s.drug_name WHERE a.approval_year = 2020 AND s.quarter = 'Q4'; | gretelai_synthetic_text_to_sql |
CREATE TABLE storage_temperature (id INT PRIMARY KEY, chemical_name VARCHAR(50), region VARCHAR(50), minimum_temperature INT); INSERT INTO storage_temperature (id, chemical_name, region, minimum_temperature) VALUES (1, 'Nitric Acid', 'APAC', -20); | What are the average minimum storage temperatures for chemicals produced in the APAC region? | SELECT region, AVG(minimum_temperature) as avg_min_temperature FROM storage_temperature WHERE region = 'APAC' GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE Policyholders (PolicyholderID INT, Premium DECIMAL(10, 2), PolicyholderState VARCHAR(10)); INSERT INTO Policyholders (PolicyholderID, Premium, PolicyholderState) VALUES (1, 2500, 'California'), (2, 1500, 'New York'), (3, 1000, 'California'); | What is the average policy premium for policyholders living in 'California'? | SELECT AVG(Premium) FROM Policyholders WHERE PolicyholderState = 'California'; | gretelai_synthetic_text_to_sql |
CREATE TABLE graduate_students (id INT, name VARCHAR(50), department VARCHAR(50)); CREATE TABLE grants (id INT, title VARCHAR(100), amount INT, student_id INT); | What is the total amount of research grants awarded to graduate students in the Engineering department? | SELECT SUM(grants.amount) FROM grants INNER JOIN graduate_students ON grants.student_id = graduate_students.id WHERE graduate_students.department = 'Engineering'; | gretelai_synthetic_text_to_sql |
CREATE TABLE museum_visitors (id INT, visitor_name VARCHAR(255), visit_date DATE); INSERT INTO museum_visitors (id, visitor_name, visit_date) VALUES ('John Smith', '2022-01-01'), ('Jane Doe', '2022-01-02'), ('Mike Johnson', '2022-07-01'); | Find the number of museum visitors in the last 6 months from Tokyo, Japan. | SELECT COUNT(*) FROM museum_visitors WHERE visit_date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) AND city = 'Tokyo'; | gretelai_synthetic_text_to_sql |
CREATE TABLE incident_ip_addresses (incident_id INT, ip_address VARCHAR(15)); INSERT INTO incident_ip_addresses (incident_id, ip_address) VALUES (1, '192.168.1.1'); INSERT INTO incident_ip_addresses (incident_id, ip_address) VALUES (2, '192.168.1.2'); INSERT INTO incident_ip_addresses (incident_id, ip_address) VALUES (... | What is the total number of unique IP addresses involved in incidents per month? | SELECT DATEADD(month, DATEDIFF(month, 0, incident_date), 0) as month, COUNT(DISTINCT ip_address) as num_unique_ips FROM incident_ip_addresses GROUP BY month ORDER BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE Highways(state VARCHAR(255), length FLOAT, type VARCHAR(255), lanes INT); INSERT INTO Highways VALUES('California',500.0,'Rural',4),('California',700.0,'Urban',6),('Texas',400.0,'Rural',2),('Texas',800.0,'Urban',8),('NewYork',300.0,'Rural',3),('NewYork',600.0,'Urban',5); | What is the average number of lanes for highways in 'Highways' table? | SELECT AVG(lanes) FROM Highways; | gretelai_synthetic_text_to_sql |
CREATE TABLE CO2Emissions (factory VARCHAR(50), certification VARCHAR(50), CO2_emission INT); INSERT INTO CO2Emissions VALUES ('Factory1', 'Fair Trade', 500), ('Factory2', 'Not Certified', 600), ('Factory3', 'Fair Trade', 450), ('Factory4', 'Not Certified', 700); | What is the maximum CO2 emission for a fair trade certified factory in Bangladesh? | SELECT MAX(CO2_emission) FROM CO2Emissions WHERE certification = 'Fair Trade' AND country = 'Bangladesh'; | gretelai_synthetic_text_to_sql |
CREATE TABLE port (port_id INT, port_name VARCHAR(50)); INSERT INTO port (port_id, port_name) VALUES (1, 'Port of Sydney'), (2, 'Port of Melbourne'); CREATE TABLE cargo (cargo_id INT, cargo_type VARCHAR(50)); CREATE TABLE transport (transport_id INT, cargo_id INT, port_id INT); INSERT INTO transport (transport_id, carg... | What are the distinct cargo types that have been transported to the Port of Sydney and the Port of Melbourne? | SELECT cargo_type FROM cargo, transport WHERE cargo.cargo_id = transport.cargo_id AND port_id IN (1, 2) GROUP BY cargo_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE production_rates (rate_id INT, chemical VARCHAR(20), production_rate INT, measurement_date DATE); INSERT INTO production_rates (rate_id, chemical, production_rate, measurement_date) VALUES (1, 'P', 500, '2021-01-01'), (2, 'P', 700, '2021-01-02'), (3, 'Q', 600, '2021-01-01'), (4, 'P', 800, '2021-02-01'); | What is the total quantity of chemicals produced in January 2021? | SELECT SUM(production_rate) FROM production_rates WHERE measurement_date BETWEEN '2021-01-01' AND '2021-01-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Training (EmployeeID INT, TrainingName VARCHAR(30), CompletionDate DATE); INSERT INTO Training (EmployeeID, TrainingName, CompletionDate) VALUES (2, 'Unconscious Bias', '2021-11-05'); | What is the percentage of employees who have completed unconscious bias training? | SELECT (COUNT(*) / (SELECT COUNT(*) FROM Employees)) * 100 AS Percentage FROM Training WHERE TrainingName = 'Unconscious Bias'; | gretelai_synthetic_text_to_sql |
CREATE TABLE voter_registration (voter_id INT, voter_name VARCHAR(255), registration_date DATE, county VARCHAR(255)); | What is the total number of registered voters in 'voter_registration' table, grouped by county? | SELECT county, COUNT(voter_id) AS total_registered_voters FROM voter_registration GROUP BY county; | gretelai_synthetic_text_to_sql |
CREATE TABLE machine_usage (machine TEXT, usage INTEGER, start_time TIMESTAMP, end_time TIMESTAMP); | List the number of times each agricultural machine was used in the past week. | SELECT machine, COUNT(*) as usage_count FROM machine_usage WHERE start_time BETWEEN DATEADD(day, -7, CURRENT_TIMESTAMP) AND CURRENT_TIMESTAMP GROUP BY machine; | gretelai_synthetic_text_to_sql |
CREATE TABLE ModelTests (Id INT PRIMARY KEY, Model VARCHAR(50), TestId INT, FOREIGN KEY (TestId) REFERENCES SafetyTests(Id)); | Number of safety tests per vehicle model | SELECT Model, COUNT(*) FROM ModelTests JOIN SafetyTests ON ModelTests.TestId = SafetyTests.Id GROUP BY Model; | gretelai_synthetic_text_to_sql |
CREATE TABLE npr (article_id INT, title TEXT, category TEXT, publisher TEXT); INSERT INTO npr (article_id, title, category, publisher) VALUES (1, 'Article 1', 'Politics', 'National Public Radio'), (2, 'Article 2', 'Business', 'National Public Radio'); | List all the articles published by 'National Public Radio' in the 'Politics' category. | SELECT * FROM npr WHERE category = 'Politics'; | gretelai_synthetic_text_to_sql |
CREATE TABLE taxi_usage (id INT, hour INT, usage INT, date DATE); INSERT INTO taxi_usage (id, hour, usage, date) VALUES (1, 10, 1500, '2022-01-01'), (2, 12, 2000, '2022-01-01'); | Which hour of the day has the highest usage of autonomous taxis in New York? | SELECT hour, MAX(usage) AS max_usage FROM taxi_usage WHERE city = 'New York' AND trip_type = 'autonomous' GROUP BY hour; | gretelai_synthetic_text_to_sql |
CREATE TABLE restaurants (id INT, name TEXT, location TEXT); INSERT INTO restaurants (id, name, location) VALUES (1, 'Restaurant A', 'City A'), (2, 'Restaurant B', 'City B'); CREATE TABLE inspections (restaurant_id INT, date DATE, violations INT); INSERT INTO inspections (restaurant_id, date, violations) VALUES (1, '20... | How many food safety violations were there in each restaurant in February 2022? | SELECT r.id, SUM(i.violations) as total_violations FROM inspections i JOIN restaurants r ON i.restaurant_id = r.id WHERE i.date BETWEEN '2022-02-01' AND '2022-02-28' GROUP BY r.id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Vessels (vessel_name VARCHAR(255)); INSERT INTO Vessels (vessel_name) VALUES ('VesselK'), ('VesselL'); CREATE TABLE Inspections (vessel_name VARCHAR(255), inspection_date DATE); INSERT INTO Inspections (vessel_name, inspection_date) VALUES ('VesselK', '2022-01-03'), ('VesselK', '2022-03-19'), ('VesselL', '... | List all safety inspection records for 'VesselK' in Q1 2022. | SELECT * FROM Inspections WHERE vessel_name = 'VesselK' AND inspection_date BETWEEN '2022-01-01' AND '2022-03-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE workplaces (id INT, name TEXT, country TEXT, type TEXT, total_employees INT); INSERT INTO workplaces (id, name, country, type, total_employees) VALUES (1, 'ABC Company', 'Canada', 'Manufacturing', 500); INSERT INTO workplaces (id, name, country, type, total_employees) VALUES (2, 'XYZ Corporation', 'Canada'... | What is the total number of workplaces with successful collective bargaining agreements in Canada, grouped by province? | SELECT country, type, COUNT(*) as total_workplaces FROM workplaces WHERE country = 'Canada' AND type = 'Manufacturing' AND total_employees > 0 GROUP BY country, type; | gretelai_synthetic_text_to_sql |
CREATE TABLE Arctic_Communities (name TEXT, population INTEGER); CREATE TABLE Antarctic_Communities (name TEXT, population INTEGER); | Find the names of all the indigenous communities in the 'Arctic_Communities' table that have a population size greater than any community in the 'Antarctic_Communities' table. | SELECT name FROM Arctic_Communities WHERE Arctic_Communities.population > (SELECT MAX(population) FROM Antarctic_Communities) | gretelai_synthetic_text_to_sql |
CREATE TABLE transactions (id INT, transaction_number VARCHAR(20), account_number VARCHAR(20), transaction_type VARCHAR(20), transaction_date DATE, amount DECIMAL(10,2)); CREATE TABLE accounts (id INT, account_number VARCHAR(20), customer_id INT, account_type VARCHAR(20), balance DECIMAL(10,2)); INSERT INTO transaction... | What are the transactions done on credit cards? | SELECT * FROM transactions WHERE account_number IN (SELECT account_number FROM accounts WHERE account_type = 'Credit Card'); | gretelai_synthetic_text_to_sql |
CREATE TABLE events (id INT, name VARCHAR(255), date DATE, category VARCHAR(255), price DECIMAL(5,2), attendance INT); INSERT INTO events (id, name, date, category, price, attendance) VALUES (1, 'Exhibition', '2022-06-01', 'museums', 75.00, 1000), (2, 'Tour', '2022-06-02', 'historical', 40.00, 600), (3, 'Workshop', '20... | What is the total number of historical events with attendance over 500? | SELECT COUNT(*) FROM events WHERE category = 'historical' AND attendance > 500; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_development_2 (id INT, initiative_name VARCHAR(50), budget DECIMAL(10, 2)); INSERT INTO community_development_2 (id, initiative_name, budget) VALUES (1, 'Clean Water Initiative', 50000.00), (2, 'Renewable Energy', 75000.00), (3, 'Waste Management', 45000.00); | Which community development initiatives have the lowest budget allocations in the 'community_development_2' table? | SELECT initiative_name FROM community_development_2 ORDER BY budget ASC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE environmental_impact_table (record_id INT, chemical_id INT, environmental_impact_float); | Insert records for the environmental impact of 'Ethyl Acetate' and 'Methyl Ethyl Ketone' in the environmental_impact_table | INSERT INTO environmental_impact_table (chemical_id, environmental_impact_float) VALUES (1, 2.5), (2, 3.2); | gretelai_synthetic_text_to_sql |
CREATE SCHEMA agroecology;CREATE TABLE organic_farms (id INT, name VARCHAR(50), production_value INT); | What is the maximum production value (in USD) of organic farms in the 'agroecology' schema? | SELECT MAX(production_value) FROM agroecology.organic_farms; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT, name VARCHAR(50), country VARCHAR(50)); INSERT INTO users (id, name, country) VALUES (1, 'John Doe', 'USA'), (2, 'Jane Smith', 'Canada'), (3, 'Pedro Martinez', 'Mexico'), (4, 'Sophia Garcia', 'Spain'), (5, 'Michael Lee', 'USA'), (6, 'Emily White', 'Canada'), (7, 'Daniel Kim', 'South Korea'),... | What is the total number of registered users from each country, ordered by the number of users in descending order? | SELECT country, COUNT(*) OVER (PARTITION BY country) as total_users FROM users ORDER BY total_users DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE MedicalSupport (Id INT, Region VARCHAR(50), Item VARCHAR(50), Quantity INT); INSERT INTO MedicalSupport (Id, Region, Item, Quantity) VALUES (1, 'Middle East', 'Medical Supplies', 500), (2, 'Asia', 'Medical Supplies', 800), (3, 'Africa', 'Medical Supplies', 1000), (4, 'South America', 'Medical Supplies', 60... | Which regions received the most support in the form of medical supplies and how much support did they receive? | SELECT Region, SUM(Quantity) FROM MedicalSupport WHERE Item = 'Medical Supplies' GROUP BY Region ORDER BY SUM(Quantity) DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE excavation_sites (site_id INT, site_name VARCHAR(255), site_period VARCHAR(255)); INSERT INTO excavation_sites (site_id, site_name, site_period) VALUES (1, 'Site A', 'Stone Age'), (2, 'Site B', 'Iron Age'), (3, 'Site C', 'Bronze Age'); CREATE TABLE artifacts (artifact_id INT, site_id INT, artifact_weight D... | What is the total weight of artifacts from the 'Stone Age' context? | SELECT SUM(a.artifact_weight) AS total_weight FROM excavation_sites s JOIN artifacts a ON s.site_id = a.site_id WHERE s.site_period = 'Stone Age'; | gretelai_synthetic_text_to_sql |
CREATE TABLE creators (id INT, name TEXT, country TEXT); INSERT INTO creators (id, name, country) VALUES (1, 'Alice', 'USA'), (2, 'Bob', 'Canada'), (3, 'Charlie', 'China'); CREATE TABLE transactions (id INT, creator_id INT, network TEXT); INSERT INTO transactions (id, creator_id, network) VALUES (1, 1, 'Ethereum'), (2,... | What is the name of the creator with the most transactions on the Binance network? | SELECT c.name FROM creators c INNER JOIN transactions t ON c.id = t.creator_id WHERE t.network = 'Binance' GROUP BY c.name ORDER BY COUNT(*) DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE research (year INT, type VARCHAR(15)); INSERT INTO research VALUES (2018, 'autonomous driving'), (2019, 'autonomous driving'), (2020, 'autonomous driving'), (2020, 'electric vehicle'), (2021, 'autonomous driving'); | What is the number of autonomous driving research projects completed before '2020' in the 'research' table? | SELECT COUNT(*) FROM research WHERE type = 'autonomous driving' AND year < 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE Exhibitions (exhibition_id INT, name VARCHAR(100), visitor_count INT); INSERT INTO Exhibitions (exhibition_id, name, visitor_count) VALUES (1, 'Impressionist Art', 800), (2, 'Contemporary Art', 600); | What is the total number of visitors for 'Impressionist Art' and 'Contemporary Art' exhibitions? | SELECT SUM(visitor_count) FROM Exhibitions WHERE name IN ('Impressionist Art', 'Contemporary Art'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Countries (Country_ID INT, Country_Name VARCHAR(255)); INSERT INTO Countries (Country_ID, Country_Name) VALUES (1, 'United States'), (2, 'Mexico'), (3, 'Canada'), (4, 'Brazil'), (5, 'Argentina'); CREATE TABLE Visitor_Origins (Visitor_ID INT, Country_ID INT); | Identify the top contributing countries in terms of visitor count. | SELECT c.Country_Name, COUNT(v.Visitor_ID) AS Visitor_Count FROM Countries c JOIN Visitor_Origins v ON c.Country_ID = v.Country_ID GROUP BY c.Country_Name ORDER BY Visitor_Count DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE Founding_Data (company_name VARCHAR(50), founding_year INT, founding_location VARCHAR(50)); INSERT INTO Founding_Data (company_name, founding_year, founding_location) VALUES ('Waystar Royco', 1980, 'New York'); INSERT INTO Founding_Data (company_name, founding_year, founding_location) VALUES ('Pied Piper',... | What is the founding year and location of the most recently founded company? | SELECT company_name, founding_year, founding_location FROM Founding_Data WHERE founding_year = (SELECT MAX(founding_year) FROM Founding_Data); | gretelai_synthetic_text_to_sql |
CREATE TABLE patients (id INT, region VARCHAR(50), therapy_sessions INT); INSERT INTO patients (id, region, therapy_sessions) VALUES (1, 'Africa', 5), (2, 'Africa', 3), (3, 'Asia', NULL); | What is the total number of patients who have completed therapy sessions in the African region? | SELECT SUM(therapy_sessions) FROM patients WHERE region = 'Africa' AND therapy_sessions IS NOT NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE news_articles (id INT, title TEXT, publish_date DATE, word_count INT); CREATE VIEW news_summary AS SELECT id, title, publish_date, EXTRACT(MONTH FROM publish_date) as month, EXTRACT(YEAR FROM publish_date) as year, word_count FROM news_articles WHERE section = 'politics'; | What is the monthly trend of news article word counts for the "politics" section in 2022? | SELECT month, AVG(word_count) as avg_word_count FROM news_summary WHERE year = 2022 GROUP BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE employees (id INT, name VARCHAR(50), department VARCHAR(20), salary DECIMAL(10, 2)); INSERT INTO employees (id, name, department, salary) VALUES (1, 'John Doe', 'manufacturing', 50000.00), (2, 'Jane Smith', 'engineering', 60000.00), (3, 'Alice Johnson', 'HR', 55000.00), (4, 'Bob Brown', 'research', 70000.0... | What is the average salary of employees in the 'research' department? | SELECT AVG(salary) FROM employees WHERE department = 'research'; | gretelai_synthetic_text_to_sql |
CREATE TABLE facilities(facility_id INT, facility_name TEXT, country TEXT); CREATE TABLE scores(facility_id INT, environmental_score INT); | List the facilities located outside of the United States and their corresponding environmental impact scores from the 'facilities' and 'scores' tables. | SELECT facilities.facility_name, scores.environmental_score FROM facilities INNER JOIN scores ON facilities.facility_id = scores.facility_id WHERE facilities.country NOT IN ('United States', 'USA', 'US'); | gretelai_synthetic_text_to_sql |
CREATE TABLE faculty (faculty_id INT, name VARCHAR(50), department VARCHAR(50)); CREATE TABLE grants (grant_id INT, faculty_id INT, amount FLOAT); | What is the total amount of research grants awarded to each faculty member in the Physics department? | SELECT faculty.name, SUM(grants.amount) FROM faculty JOIN grants ON faculty.faculty_id = grants.faculty_id WHERE faculty.department = 'Physics' GROUP BY faculty.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE companies (id INT, name VARCHAR(50), founder_immigrant INT); CREATE TABLE diversity_data (id INT, company_id INT, gender_diversity INT, racial_diversity INT); INSERT INTO companies VALUES (1, 'Ada Tech', 1); INSERT INTO companies VALUES (2, 'Beta Corp', 0); INSERT INTO diversity_data VALUES (1, 1, 50, 30);... | Show the diversity score for companies founded by immigrants | SELECT companies.name, (diversity_data.gender_diversity + diversity_data.racial_diversity)/2 AS diversity_score FROM companies INNER JOIN diversity_data ON companies.id = diversity_data.company_id WHERE companies.founder_immigrant = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Temperature (id INT, timestamp DATE, temperature REAL); | What is the average temperature for each day of the week for the last 6 months? | SELECT EXTRACT(DOW FROM timestamp) as day_of_week, AVG(temperature) as avg_temperature FROM Temperature WHERE timestamp >= DATEADD(MONTH, -6, CURRENT_DATE) GROUP BY day_of_week; | gretelai_synthetic_text_to_sql |
CREATE TABLE treatment (treatment_id INT, patient_id INT, condition VARCHAR(50), provider VARCHAR(50), date DATE); INSERT INTO treatment (treatment_id, patient_id, condition, provider, date) VALUES (1, 1, 'Anxiety Disorder', 'Dr. Jane', '2021-01-01'); INSERT INTO treatment (treatment_id, patient_id, condition, provider... | List the number of unique mental health conditions treated in the 'treatment' table. | SELECT COUNT(DISTINCT condition) FROM treatment; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (id INT, species VARCHAR(255), region VARCHAR(255), endemic BOOLEAN); | List all marine species that are endemic to the Indian Ocean. | SELECT species FROM marine_species WHERE region LIKE '%Indian%' AND endemic = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE matches (id INT, game VARCHAR(10), rank VARCHAR(20), match_duration INT); INSERT INTO matches (id, game, rank, match_duration) VALUES (1, 'League of Legends', 'Diamond', 45); | Show the average 'League of Legends' match duration for the top 5 longest matches played in the 'Diamond' rank. | SELECT AVG(match_duration) FROM matches WHERE game = 'League of Legends' AND rank = 'Diamond' AND match_duration IN (SELECT DISTINCT match_duration FROM matches WHERE game = 'League of Legends' AND rank = 'Diamond' ORDER BY match_duration DESC LIMIT 5); | gretelai_synthetic_text_to_sql |
CREATE VIEW luxury_hotels AS SELECT * FROM hotels WHERE revenue > 1000000; CREATE TABLE hotel_ratings (hotel_id INT, rating INT); | What is the average rating of each hotel in the luxury_hotels view? | SELECT h.hotel_name, AVG(hr.rating) FROM luxury_hotels h JOIN hotel_ratings hr ON h.id = hr.hotel_id GROUP BY h.hotel_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE transportation (transport_id INT, name TEXT, city TEXT, co2_emission FLOAT); INSERT INTO transportation (transport_id, name, city, co2_emission) VALUES (1, 'Taxi', 'Cairo', 2.5), (2, 'Bus', 'Cairo', 1.8); | What is the average CO2 emission of transportation methods used for tourism in Cairo? | SELECT AVG(co2_emission) FROM transportation WHERE city = 'Cairo'; | gretelai_synthetic_text_to_sql |
CREATE TABLE employee_history (employee_id INT, hire_date DATE, department VARCHAR(255)); | Find the number of new employees hired each month in 2021, by department. | SELECT department, COUNT(DISTINCT employee_id) FROM employee_history WHERE hire_date BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY department; | gretelai_synthetic_text_to_sql |
CREATE TABLE peacekeeping_training(id INT, personnel_id INT, trained_by VARCHAR(255), trained_in VARCHAR(255), training_year INT); INSERT INTO peacekeeping_training(id, personnel_id, trained_by, trained_in, training_year) VALUES (1, 111, 'UN', 'Counter-Terrorism', 2016), (2, 222, 'AU', 'Peacekeeping Tactics', 2017), (3... | What is the maximum number of peacekeeping personnel trained by the United Nations in counter-terrorism between 2016 and 2021, inclusive? | SELECT MAX(personnel_id) FROM peacekeeping_training WHERE trained_by = 'UN' AND trained_in = 'Counter-Terrorism' AND training_year BETWEEN 2016 AND 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE teachers_pd (teacher_id INT, subject_area TEXT, highest_degree TEXT, last_pd_program_date DATE); INSERT INTO teachers_pd (teacher_id, subject_area, highest_degree, last_pd_program_date) VALUES (1, 'Math', 'Master', '2020-01-01'), (2, 'Science', 'Doctorate', '2019-06-15'), (3, 'English', 'Bachelor', '2021-0... | How many teachers have not participated in any professional development programs in the last 3 years, grouped by subject area and highest degree obtained? | SELECT subject_area, highest_degree, COUNT(*) FROM teachers_pd WHERE last_pd_program_date < DATE_SUB(CURRENT_DATE, INTERVAL 3 YEAR) GROUP BY subject_area, highest_degree; | gretelai_synthetic_text_to_sql |
CREATE TABLE Policy_Advocacy (advocacy_id INT, region VARCHAR(20), budget DECIMAL(10, 2), year INT); INSERT INTO Policy_Advocacy (advocacy_id, region, budget, year) VALUES (1, 'Southeast', 5000, 2020), (2, 'Northwest', 6000, 2019), (3, 'East Coast', 7000, 2020), (4, 'East Coast', 6000, 2019), (5, 'Northeast', 8000, 201... | What was the total budget for policy advocacy in "Africa" region in 2018? | SELECT SUM(budget) FROM Policy_Advocacy WHERE region = 'Africa' AND year = 2018; | gretelai_synthetic_text_to_sql |
CREATE TABLE producers (id INT PRIMARY KEY, name VARCHAR(50), country VARCHAR(50)); INSERT INTO producers (id, name, country) VALUES (1, 'ABC Rare Earths', 'Morocco'); INSERT INTO producers (id, name, country) VALUES (2, 'XYZ Mining', 'South Africa'); INSERT INTO producers (id, name, country) VALUES (3, 'DEF Rare Earth... | How many rare earth element producers are there in Africa? | SELECT COUNT(DISTINCT p.country) AS num_producers FROM producers p WHERE p.country IN ('Morocco', 'South Africa', 'Egypt', 'Nigeria', 'Madagascar'); | gretelai_synthetic_text_to_sql |
CREATE TABLE startup (id INT, name TEXT, founder_gender TEXT, funding_round_size INT); INSERT INTO startup (id, name, founder_gender, funding_round_size) VALUES (1, 'StartupX', 'Female', 5000000); | What is the average funding round size for startups founded by women? | SELECT AVG(funding_round_size) FROM startup WHERE founder_gender = 'Female'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Students (StudentID INT, FirstName VARCHAR(50), LastName VARCHAR(50)); INSERT INTO Students (StudentID, FirstName, LastName) VALUES (1, 'Mia', 'Smith'); INSERT INTO Students (StudentID, FirstName, LastName) VALUES (2, 'Jamal', 'Johnson'); CREATE TABLE Accommodations (AccommodationID INT, StudentID INT, Acc... | Who are the top 5 students with the most accommodations in the past academic year? | SELECT Students.FirstName, Students.LastName, COUNT(Accommodations.AccommodationID) as NumberOfAccommodations FROM Students INNER JOIN Accommodations ON Students.StudentID = Accommodations.StudentID WHERE Accommodations.Date BETWEEN DATEADD(year, -1, GETDATE()) AND GETDATE() GROUP BY Students.FirstName, Students.LastNa... | gretelai_synthetic_text_to_sql |
CREATE TABLE rural_settlements (name VARCHAR(255), population INT, country VARCHAR(255)); | Delete records with a population less than 500 from the 'rural_settlements' table | DELETE FROM rural_settlements WHERE population < 500; | gretelai_synthetic_text_to_sql |
CREATE TABLE departments (name VARCHAR(255), physician_count INT); INSERT INTO departments (name, physician_count) VALUES (1, 2), (2, 1); | What are the names of the rural health departments that have more than one physician? | SELECT name FROM departments WHERE physician_count > 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE weather (city VARCHAR(255), temperature FLOAT, date DATE); INSERT INTO weather (city, temperature, date) VALUES ('Tokyo', 80, '2022-08-01'); | Delete the record for 'Tokyo' on '2022-08-01'. | DELETE FROM weather WHERE city = 'Tokyo' AND date = '2022-08-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE tour (id INT, name TEXT, type TEXT); INSERT INTO tour (id, name, type) VALUES (1, 'Historical Tour', 'Virtual'); INSERT INTO tour (id, name, type) VALUES (2, 'Cultural Tour', 'In-person'); INSERT INTO tour (id, name, type) VALUES (3, 'Nature Tour', 'Virtual'); | What is the total number of virtual tours of historical sites in Europe? | SELECT COUNT(*) as total_virtual_tours FROM tour WHERE type = 'Virtual' AND name LIKE '%historical%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (Employee_ID INT, Name VARCHAR(100), Department VARCHAR(50), Salary DECIMAL(10,2), Hire_Date DATE, Program VARCHAR(50)); INSERT INTO Employees (Employee_ID, Name, Department, Salary, Hire_Date, Program) VALUES (1, 'John Doe', 'Marketing', 70000, '2021-05-15', 'Diversity_Hiring'); INSERT INTO Empl... | Delete all employees who were part of the 'Internship' program and hired before 2020 | DELETE FROM Employees WHERE Program = 'Internship' AND Hire_Date < '2020-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE international_visitors (visitor_id INT, country TEXT, arrival_date DATE); INSERT INTO international_visitors (visitor_id, country, arrival_date) VALUES (1, 'China', '2022-01-01'), (2, 'Japan', '2022-02-01'), (3, 'India', '2022-03-01'), (4, 'Australia', '2022-01-15'), (5, 'New Zealand', '2022-02-20'), (6, '... | How many international visitors arrived in New Zealand from Asia in the last 3 months? | SELECT COUNT(*) FROM international_visitors WHERE country IN ('China', 'Japan', 'India') AND arrival_date >= DATE('now', '-3 month'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Archaeologists (ArchaeologistID INT, Age INT, Name VARCHAR(50)); INSERT INTO Archaeologists (ArchaeologistID, Age, Name) VALUES (1, 35, 'John Doe'); INSERT INTO Archaeologists (ArchaeologistID, Age, Name) VALUES (2, 42, 'Jane Smith'); INSERT INTO Archaeologists (ArchaeologistID, Age, Name) VALUES (3, 50, '... | What is the average age of archaeologists who have excavated at the 'Ancient City' site? | SELECT AVG(A.Age) FROM Archaeologists A INNER JOIN Excavations E ON A.ArchaeologistID = E.ArchaeologistID WHERE E.Site = 'Ancient City'; | gretelai_synthetic_text_to_sql |
CREATE TABLE renewable_projects (project_id INT, project_name VARCHAR(255), location VARCHAR(255), technology VARCHAR(255), installed_capacity FLOAT); | Show the average installed capacity of solar power projects for each location in the renewable_projects table. | SELECT location, AVG(installed_capacity) FROM renewable_projects WHERE technology = 'Solar' GROUP BY location; | gretelai_synthetic_text_to_sql |
CREATE TABLE urban_areas (id INT, area TEXT, population INT); INSERT INTO urban_areas (id, area, population) VALUES (1, 'Area 1', 900000), (2, 'Area 2', 1050000), (3, 'Area 3', 850000); CREATE TABLE emergency_incidents (id INT, area TEXT, incident_type TEXT, incident_count INT); INSERT INTO emergency_incidents (id, are... | What is the total number of emergency incidents reported in urban areas, broken down by incident type, and the total population of those urban areas? | SELECT area, incident_type, SUM(incident_count) AS total_incidents, population FROM urban_areas u JOIN emergency_incidents e ON u.area = e.area GROUP BY area, incident_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE eco_materials (id INT, country VARCHAR(20), price DECIMAL(5,2)); INSERT INTO eco_materials (id, country, price) VALUES (1, 'Italy', 25.99), (2, 'France', 30.49), (3, 'Italy', 28.50); | What is the average price of eco-friendly materials sourced from Italy? | SELECT AVG(price) FROM eco_materials WHERE country = 'Italy'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ResearchPapers (Id INT, Publisher VARCHAR(50), Year INT, Title VARCHAR(100)); INSERT INTO ResearchPapers (Id, Publisher, Year, Title) VALUES (1, 'Waymo', 2018, 'Autonomous Driving and Its Impact'), (2, 'Waymo', 2020, 'Improving Perception for Autonomous Vehicles'), (3, 'Waymo', 2019, 'Deep Learning for Aut... | How many autonomous driving research papers were published by Waymo in 2020? | SELECT COUNT(*) FROM ResearchPapers WHERE Publisher = 'Waymo' AND Year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE social_good_initiatives (id INT, initiative_name VARCHAR(255), location VARCHAR(255), accessibility_score FLOAT); | Which technology for social good initiatives in South Asia have the highest accessibility score? | SELECT initiative_name, accessibility_score FROM social_good_initiatives WHERE location = 'South Asia' ORDER BY accessibility_score DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Shipments (id INT, item VARCHAR(50), shipped_date DATE, source_country VARCHAR(50), destination_country VARCHAR(50)); INSERT INTO Shipments (id, item, shipped_date, source_country, destination_country) VALUES (1, 'Foo', '2022-01-01', 'Japan', 'India'), (2, 'Bar', '2022-01-05', 'India', 'Japan'); | What is the earliest date a package was shipped from Japan to India? | SELECT MIN(shipped_date) FROM Shipments WHERE source_country = 'Japan' AND destination_country = 'India'; | gretelai_synthetic_text_to_sql |
CREATE TABLE mental_health_treatments (id INT, patient_id INT, treatment_name TEXT, country TEXT); INSERT INTO mental_health_treatments (id, patient_id, treatment_name, country) VALUES (1, 123, 'CBT', 'Canada'); | What is the average age of patients who received cognitive behavioral therapy (CBT) in Canada? | SELECT AVG(patient_age) FROM patients JOIN mental_health_treatments ON patients.id = mental_health_treatments.patient_id WHERE treatment_name = 'CBT' AND country = 'Canada'; | gretelai_synthetic_text_to_sql |
CREATE TABLE athletes (athlete_id INT, name VARCHAR(50), sport VARCHAR(50), join_year INT, leave_year INT); INSERT INTO athletes (athlete_id, name, sport, join_year, leave_year) VALUES (1, 'Jane Doe', 'Basketball', 2021, 2022), (2, 'John Smith', 'Soccer', 2019, NULL); | Delete records of athletes who left the team before 2020 | DELETE FROM athletes WHERE leave_year IS NOT NULL AND leave_year < 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (DonationID INT, DonationDate DATE, Amount DECIMAL(10,2)); INSERT INTO Donations (DonationID, DonationDate, Amount) VALUES (1, '2021-01-01', 100.00), (2, '2021-02-01', 200.00); | What is the average donation amount per month in 2021? | SELECT AVG(Amount) as AvgDonation, DATE_FORMAT(DonationDate, '%Y-%m') as Month FROM Donations WHERE YEAR(DonationDate) = 2021 GROUP BY Month; | gretelai_synthetic_text_to_sql |
CREATE TABLE farms (id INT, name TEXT, location TEXT, size FLOAT); INSERT INTO farms (id, name, location, size) VALUES (1, 'Lush Prairies', 'Canada', 250.0); CREATE TABLE crops (id INT, farm_id INT, crop TEXT, yield INT, year INT); | Insert a new record of crop 'taro' for farm 'Lush Prairies' in 2024 | INSERT INTO crops (id, farm_id, crop, yield, year) VALUES (6, (SELECT id FROM farms WHERE name = 'Lush Prairies'), 'taro', 80, 2024); | gretelai_synthetic_text_to_sql |
CREATE TABLE ai_researcher(id INT PRIMARY KEY, name VARCHAR(50), country VARCHAR(50)); INSERT INTO ai_researcher (id, name, country) VALUES (1, 'Alice', 'USA'), (2, 'Bob', 'Canada'), (3, 'Charlie', 'UK'); CREATE TABLE ai_papers(id INT PRIMARY KEY, title VARCHAR(50), researcher_id INT, conference_id INT); INSERT INTO ai... | Which AI researchers have published papers in AI conferences held in Canada? | SELECT DISTINCT r.name FROM ai_researcher r INNER JOIN researcher_conferences rc ON r.id = rc.researcher_id WHERE rc.conference_id IN (SELECT id FROM ai_conferences WHERE location = 'Canada'); | gretelai_synthetic_text_to_sql |
CREATE TABLE companies (id INT, name TEXT, founded_date DATE, founder_gender TEXT, region TEXT); INSERT INTO companies (id, name, founded_date, founder_gender, region) VALUES (1, 'Acme Inc', '2010-01-01', 'male', 'NA'); INSERT INTO companies (id, name, founded_date, founder_gender, region) VALUES (2, 'Beta Corp', '2015... | Calculate the total funding amount for companies in specific geographic regions. | SELECT companies.region, SUM(investments.funding_amount) FROM companies JOIN investments ON companies.id = investments.company_id GROUP BY companies.region; | gretelai_synthetic_text_to_sql |
CREATE TABLE departments (dept_id INT, dept_name TEXT); CREATE TABLE employees (emp_id INT, dept_id INT, hire_date DATE, annual_salary INT); INSERT INTO departments (dept_id, dept_name) VALUES (1, 'HR'), (2, 'IT'), (4, 'Accessibility'); INSERT INTO employees (emp_id, dept_id, hire_date, annual_salary) VALUES (1, 1, '20... | Update the annual salary of all employees in the Accessibility department to 85000. | UPDATE employees SET annual_salary = 85000 WHERE dept_id = 4; | gretelai_synthetic_text_to_sql |
CREATE TABLE ContractNegotiations (NegotiationID INT, SalesRepID INT, NegotiationStartDate DATE, NegotiationEndDate DATE); INSERT INTO ContractNegotiations (NegotiationID, SalesRepID, NegotiationStartDate, NegotiationEndDate) VALUES (1, 1, '2020-01-01', '2020-01-10'), (2, 1, '2020-02-01', '2020-02-15'), (3, 2, '2020-03... | What is the average contract negotiation duration in days for each sales representative? | SELECT SalesRepName, AVG(DATEDIFF(day, NegotiationStartDate, NegotiationEndDate)) AS AvgNegotiationDuration FROM ContractNegotiations JOIN SalesReps ON ContractNegotiations.SalesRepID = SalesReps.SalesRepID GROUP BY SalesRepName; | gretelai_synthetic_text_to_sql |
CREATE TABLE seafood_sales (region VARCHAR(255), product VARCHAR(255), revenue DECIMAL(8,2), quantity INT); INSERT INTO seafood_sales (region, product, revenue, quantity) VALUES ('North', 'Tilapia', 1250.00, 500), ('South', 'Salmon', 3500.00, 800), ('North', 'Catfish', 2000.00, 600), ('East', 'Tilapia', 1750.00, 450), ... | What is the total revenue for each product in the 'seafood_sales' table? | SELECT product, SUM(revenue) as total_revenue FROM seafood_sales GROUP BY product; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artifacts (ArtifactID int, Name text, SiteID int, ExcavationYear int); INSERT INTO Artifacts (ArtifactID, Name, SiteID, ExcavationYear) VALUES (1, 'Artifact1', 1, 2005); CREATE TABLE Sites (SiteID int, Name text, Country text); INSERT INTO Sites (SiteID, Name, Country) VALUES (1, 'SiteA', 'Asia'); | What is the average number of artifacts excavated per site in 'Asia'? | SELECT AVG(ArtifactCount) FROM (SELECT COUNT(*) as ArtifactCount FROM Artifacts INNER JOIN Sites ON Artifacts.SiteID = Sites.SiteID WHERE Sites.Country = 'Asia' GROUP BY SiteID) as Subquery; | 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.