context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28 values |
|---|---|---|---|
CREATE SCHEMA if not exists bioprocess_engineering;CREATE TABLE if not exists bioprocess_engineering.patents (id INT, name VARCHAR(255), country VARCHAR(255), patent_number VARCHAR(255));INSERT INTO bioprocess_engineering.patents (id, name, country, patent_number) VALUES (1, 'PatentA', 'DE', '123456'), (2, 'PatentB', 'UK', '789012'), (3, 'PatentC', 'DE', '345678'), (4, 'PatentD', 'US', '901234'); | How many bioprocess engineering patents were granted in Germany and the UK? | SELECT country, COUNT(*) as num_patents FROM bioprocess_engineering.patents WHERE country IN ('DE', 'UK') GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE therapists (therapist_id INT, name VARCHAR(255), age INT, gender VARCHAR(10)); CREATE TABLE patients (patient_id INT, name VARCHAR(255), age INT, gender VARCHAR(10), condition VARCHAR(255)); CREATE TABLE therapy_sessions (session_id INT, patient_id INT, therapist_id INT, session_date DATE, success BOOLEAN); CREATE TABLE treatment_approaches (approach_id INT, therapist_id INT, name VARCHAR(255)); | List the names, treatment approaches, and the number of successful sessions for therapists who have treated more than 75 patients with PTSD? | SELECT therapists.name, treatment_approaches.name, COUNT(*) AS successful_sessions FROM therapists JOIN therapy_sessions ON therapists.therapist_id = therapy_sessions.therapist_id JOIN patients ON therapy_sessions.patient_id = patients.patient_id JOIN treatment_approaches ON therapists.therapist_id = treatment_approaches.therapist_id WHERE patients.condition = 'PTSD' AND therapy_sessions.success = TRUE GROUP BY therapists.therapist_id HAVING COUNT(*) > 75; | gretelai_synthetic_text_to_sql |
CREATE TABLE Exhibitions (ExhibitionID INT, Name VARCHAR(255), City VARCHAR(255), Rating FLOAT); | What is the distribution of visitor ratings for exhibitions in Paris? | SELECT City, AVG(Rating) OVER(PARTITION BY City) as AvgRating FROM Exhibitions WHERE City = 'Paris'; | gretelai_synthetic_text_to_sql |
CREATE TABLE hydro_plants (id INT, name TEXT, country TEXT, capacity FLOAT); INSERT INTO hydro_plants (id, name, country, capacity) VALUES (1, 'Robert-Bourassa', 'Canada', 5616.0), (2, 'Churchill Falls', 'Canada', 5428.0), (3, 'Garrison', 'Canada', 418.0); | What is the maximum capacity (MW) of hydroelectric power plants in Canada, and how many of them have a capacity greater than 500 MW? | SELECT MAX(capacity), COUNT(*) FROM hydro_plants WHERE country = 'Canada' AND capacity > 500; | gretelai_synthetic_text_to_sql |
CREATE TABLE waste_generation (id INT, waste_type VARCHAR(20), year INT, quantity INT); | Update records in waste_generation table where waste_type is 'Plastic' and year is 2022 | WITH data_to_update AS (UPDATE waste_generation SET quantity = quantity * 1.05 WHERE waste_type = 'Plastic' AND year = 2022 RETURNING *) UPDATE waste_generation SET quantity = (SELECT quantity FROM data_to_update) WHERE id IN (SELECT id FROM data_to_update); | gretelai_synthetic_text_to_sql |
CREATE TABLE initiatives (id INT, name TEXT, location TEXT, type TEXT); INSERT INTO initiatives (id, name, location, type) VALUES (1, 'Green Safari', 'India', 'Sustainable'), (2, 'Eco-Lodge', 'Nepal', 'Sustainable'), (3, 'Sustainable Trekking', 'Bhutan', 'Sustainable'); | What is the average number of sustainable tourism initiatives in Asia? | SELECT AVG(id) FROM initiatives WHERE location = 'Asia' AND type = 'Sustainable'; | gretelai_synthetic_text_to_sql |
CREATE TABLE transactions (id INT, app_id INT, timestamp TIMESTAMP); INSERT INTO transactions (id, app_id, timestamp) VALUES (1, 1, '2022-01-01 10:00:00'), (2, 1, '2022-01-01 12:00:00'), (3, 2, '2022-01-01 14:00:00'); CREATE TABLE digital_assets (id INT, name TEXT, app_id INT); INSERT INTO digital_assets (id, name, app_id) VALUES (1, 'Coin1', 1), (2, 'Coin2', 2); | What is the name of the digital asset with the most transactions? | SELECT name FROM digital_assets JOIN transactions ON digital_assets.app_id = transactions.app_id GROUP BY name ORDER BY COUNT(*) DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE projects (id INT, name TEXT, category TEXT, funding FLOAT); INSERT INTO projects (id, name, category, funding) VALUES (1, 'ProjA', 'DigitalDivide', 50000), (2, 'ProjB', 'SocialGood', 35000), (3, 'ProjC', 'DigitalDivide', 75000); | What is the maximum funding for projects in the digital divide category? | SELECT MAX(funding) FROM projects WHERE category = 'DigitalDivide'; | gretelai_synthetic_text_to_sql |
CREATE TABLE revenue_by_cuisine (cuisine VARCHAR(255), revenue DECIMAL(10,2)); INSERT INTO revenue_by_cuisine (cuisine, revenue) VALUES ('Italian', 5000.00), ('Mexican', 4000.00), ('Chinese', 3000.00), ('Japanese', 2000.00), ('Indian', 1000.00); | What was the total revenue for each cuisine type in the last 30 days? | SELECT cuisine, SUM(revenue) as total_revenue FROM revenue_by_cuisine WHERE revenue_by_cuisine.cuisine IN (SELECT cuisine FROM restaurant_revenue WHERE date >= DATE_SUB(CURDATE(), INTERVAL 30 DAY)) GROUP BY cuisine; | gretelai_synthetic_text_to_sql |
CREATE TABLE comm_reach (project_name TEXT, people_reached INTEGER);INSERT INTO comm_reach (project_name, people_reached) VALUES ('Climate Change Basics', 5000), ('Climate Solutions', 7000); | Identify the climate communication projects and the number of people reached for each project in South America. | SELECT project_name, people_reached FROM comm_reach WHERE region = 'South America'; | gretelai_synthetic_text_to_sql |
CREATE TABLE satellites (company VARCHAR(50), num_satellites INT); INSERT INTO satellites (company, num_satellites) VALUES ('SpaceX', 1500), ('OneWeb', 500), ('Blue Origin', 200); | How many satellites were launched by private companies? | SELECT SUM(num_satellites) as total_private_satellites FROM satellites WHERE company IS NOT NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE arctic_institutions (institution_name VARCHAR(100), country VARCHAR(50)); | What is the total number of research institutions in the 'arctic_institutions' table, located in Canada? | SELECT COUNT(*) FROM arctic_institutions WHERE country = 'Canada'; | gretelai_synthetic_text_to_sql |
CREATE TABLE storage (id INT, name VARCHAR(50), type VARCHAR(50), capacity INT, location VARCHAR(50)); | What are the energy storage capacities for each energy storage technology in the storage table by location? | SELECT type, location, SUM(capacity) as total_capacity FROM storage GROUP BY type, location ORDER BY total_capacity DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE research_vessels (vessel_name TEXT, last_inspection_date DATE, law_compliance INTEGER); | List all research vessels that have not complied with maritime law in the last year. | SELECT vessel_name FROM research_vessels WHERE last_inspection_date < NOW() - INTERVAL '1 year' AND law_compliance = 0; | gretelai_synthetic_text_to_sql |
CREATE TABLE TraditionalArts (id INT, type VARCHAR(255), artist VARCHAR(255)); INSERT INTO TraditionalArts (id, type, artist) VALUES (1, 'Painting', 'John Doe'), (2, 'Sculpture', 'Jane Smith'), (3, 'Pottery', 'Alice Johnson'); | What is the total number of traditional art pieces by type? | SELECT type, COUNT(*) OVER(PARTITION BY type) as total_by_type FROM TraditionalArts; | gretelai_synthetic_text_to_sql |
CREATE TABLE adaptation_measures (measure VARCHAR(50), location VARCHAR(50), success_rate NUMERIC); INSERT INTO adaptation_measures (measure, location, success_rate) VALUES ('Construction of sea walls', 'Africa', 0.87), ('Improved agricultural practices', 'Africa', 0.91); | What are the climate adaptation measures with a success rate over 85% in Africa? | SELECT measure, success_rate FROM adaptation_measures WHERE location = 'Africa' AND success_rate > 0.85; | gretelai_synthetic_text_to_sql |
CREATE TABLE Job_Applications (Application_ID INT, Applicant_Name VARCHAR(50), Job_Title VARCHAR(50), Application_Date DATE, Interview_Date DATE, Hired BOOLEAN); CREATE TABLE Jobs (Job_ID INT, Job_Title VARCHAR(50), Department VARCHAR(50), Location VARCHAR(50), Salary DECIMAL(10,2)); | How many job applications were received for the Data Scientist position? | SELECT COUNT(*) as 'Number of Applications' FROM Job_Applications WHERE Job_Title = 'Data Scientist'; | gretelai_synthetic_text_to_sql |
CREATE TABLE MentalHealthParity (ID INT PRIMARY KEY, State VARCHAR(2), ParityStatus VARCHAR(10)); CREATE TABLE CulturalCompetency (ID INT PRIMARY KEY, State VARCHAR(2), CompetencyStatus VARCHAR(10)); INSERT INTO MentalHealthParity (ID, State, ParityStatus) VALUES (1, 'AK', 'Yes'), (2, 'AL', 'No'), (3, 'AR', 'No'), (4, 'AZ', 'Yes'), (5, 'CA', 'Yes'), (6, 'CO', 'Yes'), (7, 'CT', 'Yes'), (8, 'DC', 'Yes'), (9, 'DE', 'Yes'), (10, 'FL', 'No'), (11, 'GA', 'No'), (12, 'HI', 'Yes'); | Delete records with no parity from MentalHealthParity | DELETE FROM MentalHealthParity WHERE ParityStatus = 'No'; | gretelai_synthetic_text_to_sql |
CREATE TABLE states (state_id INT, state_name VARCHAR(100)); INSERT INTO states (state_id, state_name) VALUES (1, 'California'), (2, 'Texas'), (3, 'New York'); CREATE TABLE community_health_workers (worker_id INT, state_id INT, health_equity_metrics_score INT); INSERT INTO community_health_workers (worker_id, state_id, health_equity_metrics_score) VALUES (1, 1, 85), (2, 1, 90), (3, 2, 80), (4, 3, 95), (5, 1, 92); | What is the distribution of health equity metrics scores for community health workers in California? | SELECT state_id, health_equity_metrics_score, COUNT(*) OVER (PARTITION BY state_id ORDER BY health_equity_metrics_score) as rank FROM community_health_workers WHERE state_id = 1 ORDER BY health_equity_metrics_score; | gretelai_synthetic_text_to_sql |
CREATE TABLE deep_sea_species (name VARCHAR(255), habitat VARCHAR(255)); CREATE TABLE endangered_species (name VARCHAR(255), habitat VARCHAR(255)); | Which deep-sea species have been found in the same habitats as endangered species? | SELECT dss.name FROM deep_sea_species dss INNER JOIN endangered_species es ON dss.habitat = es.habitat; | gretelai_synthetic_text_to_sql |
CREATE TABLE carbon_prices (participant TEXT, year INT, price FLOAT); INSERT INTO carbon_prices (participant, year, price) VALUES ('Participant A', 2018, 14.0), ('Participant A', 2019, 15.0), ('Participant B', 2018, 16.0), ('Participant B', 2019, 17.0), ('Participant C', 2018, 13.0), ('Participant C', 2019, 14.0); | What is the minimum carbon price (USD) in the California carbon market, and how many carbon market participants have a carbon price greater than 15 USD? | SELECT MIN(price), COUNT(*) FROM carbon_prices WHERE price > 15; | gretelai_synthetic_text_to_sql |
CREATE TABLE renewable_energy_projects (project_name TEXT, country TEXT, capacity FLOAT); INSERT INTO renewable_energy_projects VALUES ('ProjectX', 'Country1', 1000.0), ('ProjectY', 'Country2', 1200.0), ('ProjectZ', 'Country3', 800.0), ('ProjectW', 'Country1', 1500.0); | What is the total installed renewable energy capacity for each country, ranked by capacity? | SELECT country, SUM(capacity) OVER (PARTITION BY country) AS total_capacity, RANK() OVER (ORDER BY SUM(capacity) DESC) AS rank FROM renewable_energy_projects GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE TemperatureData (ID INT, Year INT, Location VARCHAR(255), Temperature INT); INSERT INTO TemperatureData (ID, Year, Location, Temperature) VALUES (1, 2000, 'Antarctica', -10), (2, 2000, 'Antarctica', -15), (3, 2001, 'Antarctica', -12), (4, 2001, 'Antarctica', -18), (5, 2002, 'Antarctica', -14), (6, 2002, 'Antarctica', -16); | What is the minimum and maximum temperature in Antarctica for each year since 2000? | SELECT Year, MIN(Temperature), MAX(Temperature) FROM TemperatureData WHERE Location = 'Antarctica' GROUP BY Year; | gretelai_synthetic_text_to_sql |
CREATE TABLE languages (id INT PRIMARY KEY, name VARCHAR(255), region VARCHAR(255), status VARCHAR(255)); | Delete a language from the 'languages' table | DELETE FROM languages WHERE id = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE water_usage_la (sector VARCHAR(20), amount INTEGER); INSERT INTO water_usage_la (sector, amount) VALUES ('Residential', 120000), ('Industrial', 150000); | What are the total water usage amounts for residential and industrial sectors in the Los Angeles region, and how do they compare? | SELECT sector, amount FROM water_usage_la WHERE sector IN ('Residential', 'Industrial') | gretelai_synthetic_text_to_sql |
CREATE TABLE advertisers (id INT, name VARCHAR(255), category VARCHAR(255), spend DECIMAL(10, 2)); INSERT INTO advertisers (id, name, category, spend) VALUES (1, 'Advertiser1', 'Gaming', 5000), (2, 'Advertiser2', 'Gaming', 7000), (3, 'Advertiser3', 'Gaming', 3000), (4, 'Advertiser4', 'Fashion', 8000); | Who are the top 3 advertisers by total ad spend in the gaming category? | SELECT name, SUM(spend) as total_spend FROM advertisers WHERE category = 'Gaming' GROUP BY name ORDER BY total_spend DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE wastewater_treatment(plant_id INT, city VARCHAR(50), year INT, recycled_water_volume FLOAT, total_water_volume FLOAT); INSERT INTO wastewater_treatment(plant_id, city, year, recycled_water_volume, total_water_volume) VALUES (1, 'Los Angeles', 2018, 5000000, 8000000), (2, 'Los Angeles', 2018, 6000000, 9000000); | What is the percentage of water that is recycled by wastewater treatment plants in the city of Los Angeles for the year 2018? | SELECT city, (SUM(recycled_water_volume) / SUM(total_water_volume)) * 100 FROM wastewater_treatment WHERE city = 'Los Angeles' AND year = 2018; | gretelai_synthetic_text_to_sql |
CREATE TABLE social_enterprises (id INT, name TEXT, sector TEXT, net_income FLOAT); INSERT INTO social_enterprises (id, name, sector, net_income) VALUES (1, 'EdTech Startup', 'Technology', 20000.0), (2, 'GreenTech Company', 'Technology', -15000.0); | Find the number of social enterprises in the Technology sector with a positive net income. | SELECT COUNT(*) FROM social_enterprises WHERE sector = 'Technology' AND net_income > 0; | gretelai_synthetic_text_to_sql |
CREATE TABLE ProjectBudgets (id INT, project_name VARCHAR(255), start_date DATE, end_date DATE, budget DECIMAL(10,2)); | Find the average budget of defense projects that started between July 1st, 2017 and June 30th, 2018. | SELECT AVG(budget) FROM ProjectBudgets WHERE start_date BETWEEN '2017-07-01' AND '2018-06-30'; | gretelai_synthetic_text_to_sql |
CREATE TABLE chemical_plants (id INT, name TEXT, region TEXT, production_volume INT); INSERT INTO chemical_plants (id, name, region, production_volume) VALUES (1, 'Plant A', 'Northeast', 1200), (2, 'Plant B', 'Midwest', 900), (3, 'Plant C', 'West', 1300); | What is the total production volume for each plant? | SELECT name, SUM(production_volume) FROM chemical_plants GROUP BY name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Visitor_Exhibitions (visitor_id INT, exhibition_id INT); | What is the maximum number of exhibitions attended by a single visitor? | SELECT MAX(Visitor_Exhibitions_agg.visitor_exhibitions) FROM (SELECT COUNT(*) AS visitor_exhibitions FROM Visitor_Exhibitions GROUP BY visitor_id) AS Visitor_Exhibitions_agg; | gretelai_synthetic_text_to_sql |
CREATE TABLE cities (name VARCHAR(50), population INT, women_workforce_percentage DECIMAL(5,2)); INSERT INTO cities (name, population, women_workforce_percentage) VALUES ('New York', 8500000, 48.5), ('Los Angeles', 4000000, 47.3), ('Chicago', 2700000, 48.4), ('Houston', 2300000, 46.2), ('Phoenix', 1700000, 45.8); | List the names of all cities with a population over 500,000 that have a higher percentage of women in the workforce than the national average. | SELECT name FROM cities WHERE population > 500000 AND women_workforce_percentage > (SELECT AVG(women_workforce_percentage) FROM cities); | gretelai_synthetic_text_to_sql |
CREATE TABLE workforce_diversity (id INT, state VARCHAR(50), position VARCHAR(50), gender VARCHAR(50)); INSERT INTO workforce_diversity (id, state, position, gender) VALUES (4, 'California', 'Miner', 'Non-binary'); INSERT INTO workforce_diversity (id, state, position, gender) VALUES (5, 'California', 'Miner', 'Male'); INSERT INTO workforce_diversity (id, state, position, gender) VALUES (6, 'California', 'Miner', 'Non-binary'); INSERT INTO workforce_diversity (id, state, position, gender) VALUES (7, 'California', 'Miner', 'Female'); | What is the percentage of non-binary workers in mining operations in the state of California? | SELECT (COUNT(*) FILTER (WHERE gender = 'Non-binary')) * 100.0 / COUNT(*) FROM workforce_diversity WHERE state = 'California'; | gretelai_synthetic_text_to_sql |
CREATE TABLE production (product VARCHAR(50), units_produced INT, production_date DATE); | Insert a new record into the "production" table for product "Widget X" with 100 units produced on 2022-06-01 | INSERT INTO production (product, units_produced, production_date) VALUES ('Widget X', 100, '2022-06-01'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Budget (Year INT, Category VARCHAR(255), Amount INT); INSERT INTO Budget (Year, Category, Amount) VALUES (2020, 'Education', 5000000), (2020, 'Infrastructure', 10000000), (2021, 'Environmental Protection', 12000000), (2021, 'Education', 6000000), (2021, 'Infrastructure', 15000000); | What was the total budget allocated for environmental protection in the year 2021? | SELECT SUM(Amount) FROM Budget WHERE Year = 2021 AND Category = 'Environmental Protection'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Education_Program (Id INT, Location VARCHAR(50), Attendees INT); INSERT INTO Education_Program (Id, Location, Attendees) VALUES (1, 'New York', 60); INSERT INTO Education_Program (Id, Location, Attendees) VALUES (2, 'Los Angeles', 40); | Count the number of education programs that had more than 50 attendees in New York. | SELECT COUNT(*) FROM Education_Program WHERE Location = 'New York' AND Attendees > 50; | gretelai_synthetic_text_to_sql |
CREATE TABLE VRSales (Manufacturer VARCHAR(50), Model VARCHAR(50), UnitsSold INT); | Get the total number of VR headsets sold for each manufacturer in 'VRSales' table | SELECT Manufacturer, SUM(UnitsSold) as TotalUnitsSold FROM VRSales GROUP BY Manufacturer; | gretelai_synthetic_text_to_sql |
CREATE TABLE Startup (ID INT, Name TEXT, Funding DECIMAL(10,2)); INSERT INTO Startup (ID, Name, Funding) VALUES (1, 'Startup_B', 1500000.50); | What is the total funding raised by the biotech startup 'Startup_B'? | SELECT SUM(Funding) FROM Startup WHERE Name = 'Startup_B'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Training (TrainingID INT, TrainingName VARCHAR(50), Department VARCHAR(50)); | Delete the 'Diversity and Inclusion' training program | DELETE FROM Training WHERE TrainingName = 'Diversity and Inclusion'; | gretelai_synthetic_text_to_sql |
CREATE TABLE districts (district_id INT, district_name VARCHAR(20), region VARCHAR(10)); INSERT INTO districts (district_id, district_name, region) VALUES (1, 'Central', 'North'), (2, 'Westwood', 'South'), (3, 'Springfield', 'North'); CREATE TABLE public_services (service_id INT, district_id INT); INSERT INTO public_services (service_id, district_id) VALUES (1, 1), (2, 1), (3, 2), (4, 2), (5, 3), (6, 3); | How many public services are available in northern districts? | SELECT COUNT(service_id) FROM public_services WHERE district_id IN (SELECT district_id FROM districts WHERE region = 'North'); | gretelai_synthetic_text_to_sql |
CREATE TABLE production (element VARCHAR(10), year INT, month INT, producer VARCHAR(20), quantity INT); | Identify the top 3 producers of Dysprosium by total quantity in the 'production' table, ordered by total quantity in descending order. | SELECT producer, SUM(quantity) as total_quantity FROM production WHERE element = 'Dysprosium' GROUP BY producer ORDER BY total_quantity DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE rural_infrastructure (id INT, project_name VARCHAR(50), location VARCHAR(50), cost FLOAT, status VARCHAR(10)); INSERT INTO rural_infrastructure (id, project_name, location, cost, status) VALUES (1, 'Road Construction', 'Village A', 50000.00, 'completed'), (2, 'Water Supply', 'Village B', 35000.00, 'rolled_back'); | What is the total cost of all infrastructure projects in the 'rural_infrastructure' table, including those that were rolled back? | SELECT SUM(cost) FROM rural_infrastructure WHERE status IN ('completed', 'rolled_back'); | gretelai_synthetic_text_to_sql |
CREATE TABLE eco_activities (activity_id INT, country VARCHAR(50), revenue FLOAT, activity_date DATE); INSERT INTO eco_activities (activity_id, country, revenue, activity_date) VALUES (1, 'Colombia', 8000, '2022-01-01'), (2, 'Colombia', 9000, '2022-02-15'), (3, 'Brazil', 10000, '2022-03-01'); | What is the maximum revenue generated by eco-friendly tourism activities in Colombia in the last 6 months? | SELECT MAX(ea.revenue) FROM eco_activities ea WHERE ea.country = 'Colombia' AND ea.activity_date >= DATE_SUB(NOW(), INTERVAL 6 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE aircrafts (id INT, name VARCHAR(255), manufacturer VARCHAR(255), year INT); INSERT INTO aircrafts (id, name, manufacturer, year) VALUES (1, 'B737', 'Boeing', 1967); INSERT INTO aircrafts (id, name, manufacturer, year) VALUES (2, 'A320', 'Airbus', 1988); INSERT INTO aircrafts (id, name, manufacturer, year) VALUES (3, 'Falcon 9', 'SpaceX', 2010); | Delete all aircrafts from the aircrafts table that were not manufactured after 2015 | DELETE FROM aircrafts WHERE year < 2016; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT, Name VARCHAR(50), Department VARCHAR(50), Salary FLOAT, HireDate DATE); INSERT INTO Employees (EmployeeID, Name, Department, Salary, HireDate) VALUES (1, 'John Doe', 'IT', 75000.00, '2021-01-01'), (2, 'Jane Smith', 'HR', 60000.00, '2022-01-01'), (3, 'Jim Brown', 'IT', 80000.00, '2021-03-01'), (4, 'Sara Johnson', 'Sales', 65000.00, '2023-01-05'), (5, 'Bob Williams', 'Sales', 70000.00, '2023-01-15'), (6, 'Alice Davis', 'Sales', 75000.00, '2023-02-01'); | What is the name and hire date of the most recent hire? | SELECT Name, HireDate FROM (SELECT Name, HireDate, ROW_NUMBER() OVER (ORDER BY HireDate DESC) AS Rank FROM Employees) AS EmployeeRankings WHERE Rank = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE satellites (id INT, country VARCHAR(255), launch_date DATE); INSERT INTO satellites (id, country, launch_date) VALUES (1, 'USA', '2000-01-01'), (2, 'Russia', '2005-01-01'), (3, 'USA', '2010-01-01'), (4, 'Russia', '2015-01-01'), (5, 'China', '2001-01-01'), (6, 'China', '2011-01-01'), (7, 'China', '2016-01-01'), (8, 'USA', '2002-01-01'), (9, 'Russia', '2007-01-01'), (10, 'China', '2018-01-01'); | How many satellites were launched by each country? | SELECT country, COUNT(*) FROM satellites GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE cities (city_id INT, city_name VARCHAR(255)); CREATE TABLE medical_emergencies (emergency_id INT, emergency_date TIMESTAMP, city_id INT, response_time INT); INSERT INTO cities VALUES (1, 'Chicago'), (2, 'New York'); INSERT INTO medical_emergencies VALUES (1, '2021-01-01 10:00:00', 1, 600), (2, '2021-01-01 11:00:00', 2, 500); | What is the percentage of medical emergencies answered within 10 minutes in each city? | SELECT city_id, AVG(CASE WHEN response_time <= 600 THEN 1.0 ELSE 0.0 END) as pct_answered_within_10_minutes FROM medical_emergencies GROUP BY city_id | gretelai_synthetic_text_to_sql |
CREATE TABLE Players (PlayerID INT, Name VARCHAR(100), Country VARCHAR(50)); INSERT INTO Players (PlayerID, Name, Country) VALUES (1, 'John Doe', 'USA'), (2, 'Jane Smith', 'Canada'), (3, 'James Brown', 'England'), (4, 'Sophia Johnson', 'Germany'), (5, 'Emma White', 'USA'), (6, 'Oliver Black', 'Canada'), (7, 'Lucas Green', 'Brazil'), (8, 'Ava Blue', 'Australia'); | What are the names and IDs of the top 3 countries with the most players in the 'Players' table? | SELECT Country, COUNT(*) AS PlayerCount FROM Players GROUP BY Country ORDER BY PlayerCount DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE beauty_products (product_name TEXT, price DECIMAL(5,2), brand TEXT); INSERT INTO beauty_products (product_name, price, brand) VALUES ('Face Wash', 19.99, 'Natural Glow'), ('Toner', 14.99, 'Natural Glow'), ('Moisturizer', 29.99, 'Natural Glow'); | Which beauty products have the highest price point for a specific brand? | SELECT product_name, price FROM beauty_products WHERE brand = 'Natural Glow' ORDER BY price DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE artworks (id INT, added_date DATE); INSERT INTO artworks (id, added_date) VALUES (1, '2021-01-01'), (2, '2021-12-26'), (3, '2021-12-31'); | Which artworks were added in the last week of 2021? | SELECT * FROM artworks WHERE added_date >= '2021-12-26' AND added_date <= '2021-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (donor_id INT, donor_name TEXT, donation_amount FLOAT); INSERT INTO donors (donor_id, donor_name, donation_amount) VALUES (1, 'John Doe', 200.00), (2, 'Jane Smith', 300.00); CREATE TABLE donations (donation_id INT, donor_id INT, donation_date DATE, donation_amount FLOAT); INSERT INTO donations (donation_id, donor_id, donation_date, donation_amount) VALUES (1, 1, '2022-01-05', 100.00), (2, 1, '2022-03-15', 100.00), (3, 2, '2022-01-10', 300.00); | What was the total amount donated by each donor in Q1 2022? | SELECT donor_name, SUM(donation_amount) as total_donation FROM donations d JOIN donors don ON d.donor_id = don.donor_id WHERE donation_date BETWEEN '2022-01-01' AND '2022-03-31' GROUP BY donor_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE habitat_ages (animal_id INT, age INT); INSERT INTO habitat_ages (animal_id, age) VALUES (1, 3), (2, 7), (3, 5), (4, 6); | What is the maximum age of animals in the habitat preservation program? | SELECT MAX(age) FROM habitat_ages; | gretelai_synthetic_text_to_sql |
CREATE TABLE Scholars (ScholarID int, ScholarName text, Affiliation text); CREATE TABLE Publications (PublicationID int, PublicationTitle text, ScholarID int, Focus text); | Who has published research on the Mayan civilization? | SELECT ScholarName FROM Scholars INNER JOIN Publications ON Scholars.ScholarID = Publications.ScholarID WHERE Focus = 'Mayan Civilization'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Vendors (VendorID int, VendorName varchar(50), Country varchar(50)); INSERT INTO Vendors (VendorID, VendorName, Country) VALUES (1, 'VendorA', 'Asia'), (2, 'VendorB', 'Africa'), (3, 'VendorC', 'Europe'); CREATE TABLE Materials (MaterialID int, MaterialName varchar(50), Sustainable bit); INSERT INTO Materials (MaterialID, MaterialName, Sustainable) VALUES (1, 'Organic Cotton', 1), (2, 'Polyester', 0); CREATE TABLE Source (SourceID int, VendorID int, MaterialID int, Quantity int); INSERT INTO Source (SourceID, VendorID, MaterialID, Quantity) VALUES (1, 1, 1, 500), (2, 1, 2, 300), (3, 2, 1, 800), (4, 3, 2, 700); | What is the total quantity of 'Organic Cotton' sourced from 'Africa' by our vendors? | SELECT SUM(Quantity) FROM Source JOIN Materials ON Source.MaterialID = Materials.MaterialID JOIN Vendors ON Source.VendorID = Vendors.VendorID WHERE Vendors.Country = 'Africa' AND Materials.MaterialName = 'Organic Cotton'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Resources (ResourceID INT, MineSite VARCHAR(50), ResourceType VARCHAR(50), Quantity INT, Units VARCHAR(50), WasteGeneration INT); INSERT INTO Resources (ResourceID, MineSite, ResourceType, Quantity, Units, WasteGeneration) VALUES (1, 'Site A', 'Gold', 1000, 'ounces', 5000), (2, 'Site B', 'Silver', 2000, 'ounces', 3000); | How many units of each resource type are present in the mine with the highest waste generation? | SELECT ResourceType, Quantity, Units FROM Resources WHERE WasteGeneration = (SELECT MAX(WasteGeneration) FROM Resources); | gretelai_synthetic_text_to_sql |
CREATE TABLE drilling_activity (well_name VARCHAR(50), location VARCHAR(50), year INT, drilled BOOLEAN); INSERT INTO drilling_activity (well_name, location, year, drilled) VALUES ('Well A', 'Niger Delta', 2020, TRUE), ('Well B', 'Niger Delta', 2019, TRUE); | How many wells were drilled in the Niger Delta in 2020? | SELECT COUNT(*) FROM drilling_activity WHERE location = 'Niger Delta' AND year = 2020 AND drilled = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE physician (physician_id INT, name VARCHAR(50), specialty VARCHAR(30), gender VARCHAR(10)); CREATE TABLE visit (visit_id INT, physician_id INT, rural BOOLEAN); | What is the name of the rural specialist with the most male patients? | SELECT physician.name FROM physician JOIN (SELECT physician_id FROM visit JOIN patient ON visit.patient_id = patient.patient_id WHERE visit.rural = TRUE AND patient.gender = 'male' GROUP BY physician_id ORDER BY COUNT(*) DESC LIMIT 1) AS subquery ON physician.physician_id = subquery.physician_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE MentalHealthPatients (PatientID INT, Age INT, MentalHealthIssue VARCHAR(20)); CREATE TABLE Providers (ProviderID INT, ProviderName VARCHAR(20), CulturalCompetencyTraining DATE); INSERT INTO MentalHealthPatients (PatientID, Age, MentalHealthIssue) VALUES (1, 30, 'Anxiety'); INSERT INTO Providers (ProviderID, ProviderName, CulturalCompetencyTraining) VALUES (1, 'Dr. Smith', '2022-01-01'); | How many patients with mental health issues are being treated by cultural competency trained providers? | SELECT COUNT(MentalHealthPatients.PatientID) FROM MentalHealthPatients INNER JOIN Providers ON MentalHealthPatients.PatientID = Providers.ProviderID WHERE Providers.CulturalCompetencyTraining IS NOT NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE Project_Count (id INT, project_name TEXT, state TEXT); INSERT INTO Project_Count (id, project_name, state) VALUES (1, 'Green Homes', 'Georgia'), (2, 'Conventional Buildings', 'Georgia'); | What is the total number of construction projects in Georgia with 'Green' in their names? | SELECT COUNT(*) FROM Project_Count WHERE state = 'Georgia' AND project_name LIKE '%Green%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Suppliers (SupplierID int, SupplierName varchar(50)); INSERT INTO Suppliers VALUES (1, 'SupplierA'), (2, 'SupplierB'); CREATE TABLE Sales (SaleID int, SupplierID int, TimberVolume float, TreeSpecies varchar(50)); INSERT INTO Sales VALUES (1, 1, 500, 'Oak'), (2, 1, 700, 'Maple'), (3, 2, 600, 'Pine'); | What is the total volume of timber sold by each supplier, grouped by tree species? | SELECT Suppliers.SupplierName, Sales.TreeSpecies, SUM(Sales.TimberVolume) as TotalTimberVolume FROM Suppliers INNER JOIN Sales ON Suppliers.SupplierID = Sales.SupplierID GROUP BY Suppliers.SupplierName, Sales.TreeSpecies; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (DonorID int, DonorName text, Country text); INSERT INTO Donors VALUES (1, 'John Doe', 'United States'); INSERT INTO Donors VALUES (2, 'Jane Smith', 'Nigeria'); | How many donors are there from African countries? | SELECT COUNT(*) FROM Donors WHERE Country IN (SELECT Country FROM Countries WHERE Continent = 'Africa'); | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (name TEXT, ocean TEXT, affected_by_acidification BOOLEAN); CREATE TABLE ocean_regions (name TEXT, area FLOAT); | How many marine species are found in the Southern Ocean that are affected by ocean acidification? | SELECT COUNT(*) FROM marine_species WHERE ocean = (SELECT name FROM ocean_regions WHERE area = 'Southern Ocean') AND affected_by_acidification = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (DonorID INT, DonorName TEXT, Country TEXT); CREATE TABLE Donations (DonationID INT, DonorID INT, DonationDate DATE, DonationAmount DECIMAL(10,2)); CREATE TABLE NonProfitLocations (LocationID INT, Country TEXT); | What is the total number of donors and total donations for each country where the non-profit operates, ordered by the total number of donors in descending order? | SELECT D.Country, COUNT(D.DonorID) as NumDonors, SUM(D.DonationAmount) as TotalDonations FROM Donors D JOIN Donations DO ON D.DonorID = DO.DonorID JOIN NonProfitLocations NP ON NP.Country = D.Country GROUP BY D.Country ORDER BY NumDonors DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE DefenseProjects (project_id INT, country VARCHAR(50), start_date DATE, end_date DATE, risk_level INT); INSERT INTO DefenseProjects (project_id, country, start_date, end_date, risk_level) VALUES (1, 'Australia', '2018-01-01', '2023-12-31', 3); INSERT INTO DefenseProjects (project_id, country, start_date, end_date, risk_level) VALUES (2, 'Japan', '2020-01-01', '2021-12-31', 1); | What is the geopolitical risk level for the defense projects in the Asia-Pacific region? | SELECT project_id, country, start_date, end_date, risk_level FROM DefenseProjects WHERE country IN ('Australia', 'Japan', 'South Korea'); | gretelai_synthetic_text_to_sql |
CREATE TABLE economic_diversification_ghana (id INT, country VARCHAR(255), project VARCHAR(255), cost FLOAT, year INT); INSERT INTO economic_diversification_ghana (id, country, project, cost, year) VALUES (1, 'Ghana', 'Manufacturing Plant', 9000000, 2020), (2, 'Ghana', 'Renewable Energy', 11000000, 2021), (3, 'Ghana', 'Tourism Development', 7000000, 2021); | What was the total cost of economic diversification projects in Ghana in 2020 and 2021? | SELECT SUM(cost) FROM economic_diversification_ghana WHERE country = 'Ghana' AND year IN (2020, 2021); | gretelai_synthetic_text_to_sql |
CREATE TABLE GeneticResearch (project_id INT, completion_date DATE, region VARCHAR(10)); INSERT INTO GeneticResearch (project_id, completion_date, region) VALUES (1, '2019-01-01', 'Africa'), (2, '2018-12-31', 'Asia'), (3, '2021-03-15', 'Europe'), (4, '2017-06-20', 'Africa'), (5, '2019-12-27', 'Asia'); | How many genetic research projects were completed before 2020 in African countries? | SELECT COUNT(project_id) FROM GeneticResearch WHERE completion_date < '2020-01-01' AND region = 'Africa'; | gretelai_synthetic_text_to_sql |
CREATE TABLE vessels (id INT PRIMARY KEY, name VARCHAR(255), type VARCHAR(255), year INT); | Delete a vessel from the "vessels" table | DELETE FROM vessels WHERE id = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE co2_emissions (id INT PRIMARY KEY, chemical_name VARCHAR(255), co2_emissions INT, date DATE); INSERT INTO co2_emissions (id, chemical_name, co2_emissions, date) VALUES (1, 'Hydrochloric Acid', 100, '2022-04-01'); INSERT INTO co2_emissions (id, chemical_name, co2_emissions, date) VALUES (2, 'Sulfuric Acid', 150, '2022-04-02'); | What is the CO2 emissions rank for each chemical in the past quarter? | SELECT chemical_name, co2_emissions, RANK() OVER(ORDER BY co2_emissions DESC) as co2_rank FROM co2_emissions WHERE date >= DATEADD(quarter, -1, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE Artists (ArtistID INT, Name VARCHAR(50), Nationality VARCHAR(50)); INSERT INTO Artists (ArtistID, Name, Nationality) VALUES (1, 'Vincent van Gogh', 'Dutch'); INSERT INTO Artists (ArtistID, Name, Nationality) VALUES (2, 'Frida Kahlo', 'Mexican'); CREATE TABLE Paintings (PaintingID INT, Title VARCHAR(50), ArtistID INT, YearCreated INT, Movement VARCHAR(50)); INSERT INTO Paintings (PaintingID, Title, ArtistID, YearCreated, Movement) VALUES (1, 'The Two Fridas', 2, 1939, 'Surrealism'); INSERT INTO Paintings (PaintingID, Title, ArtistID, YearCreated, Movement) VALUES (2, 'The Persistence of Memory', 3, 1931, 'Surrealism'); CREATE TABLE Movements (MovementID INT, Name VARCHAR(50)); INSERT INTO Movements (MovementID, Name) VALUES (1, 'Impressionism'); INSERT INTO Movements (MovementID, Name) VALUES (2, 'Surrealism'); | Find the artist with the most works in the 'Surrealism' movement. | SELECT ArtistID, Name, COUNT(*) as TotalPaintings FROM Paintings JOIN Artists ON Paintings.ArtistID = Artists.ArtistID WHERE Movement = 'Surrealism' GROUP BY ArtistID, Name ORDER BY TotalPaintings DESC FETCH FIRST 1 ROW ONLY; | gretelai_synthetic_text_to_sql |
CREATE TABLE patient (patient_id INT, age INT, gender VARCHAR(10), state VARCHAR(10)); INSERT INTO patient (patient_id, age, gender, state) VALUES (1, 45, 'Female', 'New York'); INSERT INTO patient (patient_id, age, gender, state) VALUES (2, 50, 'Male', 'New York'); | What is the ratio of male to female patients in New York who received a flu shot in the last week? | SELECT (SUM(CASE WHEN gender = 'Male' THEN 1 ELSE 0 END) OVER (PARTITION BY state ORDER BY flu_shot_date DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)) / (SUM(CASE WHEN gender = 'Female' THEN 1 ELSE 0 END) OVER (PARTITION BY state ORDER BY flu_shot_date DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)) AS ratio FROM patient WHERE state = 'New York' AND flu_shot_date >= DATEADD(week, -1, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE customer_transactions (customer_id TEXT, transaction_amount FLOAT); INSERT INTO customer_transactions (customer_id, transaction_amount) VALUES ('CustomerA', 100.50), ('CustomerB', 200.75), ('CustomerC', 300.90); | What is the sum of transaction amounts for each customer in the 'customer_transactions' table? | SELECT customer_id, SUM(transaction_amount) OVER (PARTITION BY customer_id) AS total_transaction_amount FROM customer_transactions; | gretelai_synthetic_text_to_sql |
CREATE TABLE nyc_ev (id INT, make VARCHAR(20), model VARCHAR(20), avg_speed DECIMAL(5,2)); | What is the average speed of electric vehicles in 'nyc_ev' table, grouped by make and model? | SELECT make, model, AVG(avg_speed) FROM nyc_ev GROUP BY make, model; | gretelai_synthetic_text_to_sql |
CREATE TABLE mine (id INT, name TEXT, location TEXT, Yttrium_production FLOAT); INSERT INTO mine (id, name, location, Yttrium_production) VALUES (1, 'Malaysian Mine', 'Malaysia', 1300.0), (2, 'Vietnamese Mine', 'Vietnam', 1100.0); | Update the production amount for the mine in Malaysia producing Yttrium. | UPDATE mine SET Yttrium_production = 1400.0 WHERE name = 'Malaysian Mine'; | gretelai_synthetic_text_to_sql |
CREATE TABLE MarineLife (id INT PRIMARY KEY, species VARCHAR(255), population INT); CREATE TABLE PollutionProjects (id INT PRIMARY KEY, marine_life_id INT, name VARCHAR(255), location VARCHAR(255), start_date DATE, end_date DATE, FOREIGN KEY (marine_life_id) REFERENCES MarineLife(id)); | Retrieve all the marine life data and the related projects in the 'MarineLife' and 'PollutionProjects' tables | SELECT MarineLife.species, PollutionProjects.name FROM MarineLife INNER JOIN PollutionProjects ON MarineLife.id = PollutionProjects.marine_life_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE SpacecraftManufacturing (company VARCHAR(255), spacecraft_model VARCHAR(255), cost INT); INSERT INTO SpacecraftManufacturing (company, spacecraft_model, cost) VALUES ('SpaceTech Inc.', 'Voyager', 800000), ('SpaceTech Inc.', 'Galileo', 1200000), ('SpaceTech Inc.', 'Cassini', 1500000); | What is the average cost of spacecraft manufactured by SpaceTech Inc.? | SELECT AVG(cost) FROM SpacecraftManufacturing WHERE company = 'SpaceTech Inc.'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Visitor (id INT, name TEXT, age INT); INSERT INTO Visitor (id, name, age) VALUES (1, 'Alice', 30), (2, 'Bob', 40), (3, 'Charlie', 25); | Calculate the average age of visitors | SELECT AVG(age) FROM Visitor; | gretelai_synthetic_text_to_sql |
CREATE TABLE education_data (education_id INT, region VARCHAR(255), program_type VARCHAR(255), program_name VARCHAR(255)); INSERT INTO education_data (education_id, region, program_type, program_name) VALUES (1, 'North', 'Animal Tracking', 'Animal Tracking 101'), (2, 'North', 'Animal Tracking', 'Advanced Animal Tracking'), (3, 'South', 'Endangered Species', 'Endangered Species 101'), (4, 'South', 'Endangered Species', 'Advanced Endangered Species'), (5, 'East', 'Bird Watching', 'Bird Watching 101'), (6, 'East', 'Wildlife Photography', 'Wildlife Photography 101'), (7, 'West', 'Animal Rescue', 'Animal Rescue 101'), (8, 'West', 'Nature Walks', 'Nature Walks 101'); | What is the number of education programs that have been held in each region, grouped by the program type? | SELECT region, program_type, COUNT(program_name) AS program_count FROM education_data GROUP BY region, program_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_health_workers (worker_id INT, name VARCHAR(50), age INT, race VARCHAR(50)); INSERT INTO community_health_workers (worker_id, name, age, race) VALUES (1, 'John Doe', 35, 'White'), (2, 'Jane Smith', 40, 'Black'), (3, 'Maria Garcia', 45, 'Hispanic'); | What is the average age of community health workers by their race? | SELECT race, AVG(age) as avg_age FROM community_health_workers GROUP BY race; | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (id INT PRIMARY KEY, donor_status VARCHAR(20), donor_since DATE); INSERT INTO donors (id, donor_status, donor_since) VALUES (1, 'new', '2021-07-01'); INSERT INTO donors (id, donor_status, donor_since) VALUES (2, 'existing', '2020-01-01'); | What was the total amount donated by new donors after June 2021? | SELECT SUM(donation_amount) FROM donations d JOIN donors don ON d.id = don.id WHERE donor_status = 'new' AND donation_date > '2021-06-30'; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (product VARCHAR(255), sale_date DATE, quantity INT, is_vegan BOOLEAN, country VARCHAR(255)); INSERT INTO sales (product, sale_date, quantity, is_vegan, country) VALUES ('Mascara', '2022-01-01', 10, false, 'Canada'), ('Eyeshadow', '2022-02-03', 15, true, 'Canada'), ('Blush', '2022-03-05', 5, false, 'Canada'); | What is the total number of vegan products sold in Canada in 2022? | SELECT SUM(quantity) as total_quantity FROM sales WHERE sale_date BETWEEN '2022-01-01' AND '2022-12-31' AND is_vegan = true AND country = 'Canada'; | gretelai_synthetic_text_to_sql |
CREATE TABLE SupportProgramsCost (ProgramID INT, ProgramName VARCHAR(50), Cost DECIMAL(5,2), ImplementationDate DATE); INSERT INTO SupportProgramsCost VALUES (1, 'Buddy Program', 5000.00, '2020-01-15'), (2, 'Mentorship Program', 8000.00, '2019-05-01'), (3, 'Tutoring Program', 7000.00, '2020-08-01'), (4, 'Peer Mentoring', 6000.00, '2019-12-20'), (5, 'Adaptive Technology Lab', 10000.00, '2020-03-01'); | What is the average cost of support programs implemented in the last year? | SELECT AVG(Cost) FROM SupportProgramsCost WHERE ImplementationDate >= '2019-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE PolicyData (PolicyID INT, ProgramName VARCHAR(50), StartDate DATE); | List the carbon offset programs and their start dates in ascending order, along with their corresponding policy IDs in the "PolicyData" table. | SELECT PolicyID, ProgramName, StartDate FROM PolicyData ORDER BY StartDate; | gretelai_synthetic_text_to_sql |
CREATE TABLE states_obesity (id INT, state VARCHAR(50), obesity_rate FLOAT); INSERT INTO states_obesity (id, state, obesity_rate) VALUES (1, 'Alabama', 36.6), (2, 'Mississippi', 37.3), (3, 'West Virginia', 37.7); | Which states have the highest obesity rates? | SELECT state, obesity_rate FROM states_obesity ORDER BY obesity_rate DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE Events (EventID INT, EventName TEXT, Attendance INT); INSERT INTO Events (EventID, EventName, Attendance) VALUES (1, 'Jazz', 50), (2, 'Rock', 100), (3, 'Pop', 80), (4, 'Art', 70); | What is the total number of attendees at all events? | SELECT SUM(Attendance) FROM Events; | gretelai_synthetic_text_to_sql |
CREATE TABLE travel_advisories (advisory_id INT, country VARCHAR(255), region VARCHAR(255), issue_date DATE); | How many travel advisories were issued in Europe and North America in the last 2 years? | SELECT COUNT(*) FROM travel_advisories WHERE region IN ('Europe', 'North America') AND issue_date >= DATEADD(year, -2, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE buildings (id INT, city VARCHAR(20), construction_year INT, co2_emissions FLOAT); INSERT INTO buildings (id, city, construction_year, co2_emissions) VALUES (1, 'Seattle', 1999, 1200.5), (2, 'Seattle', 2001, 950.3), (3, 'Portland', 2005, 1100.1); | What is the average CO2 emission of buildings in the city of Seattle, constructed between 2000 and 2010? | SELECT AVG(co2_emissions) FROM buildings WHERE city = 'Seattle' AND construction_year BETWEEN 2000 AND 2010; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_policing (id INT, user_id INT, follow_up VARCHAR(10)); INSERT INTO community_policing (id, user_id, follow_up) VALUES (1001, 250, 'pending'), (1002, 251, 'done'); | Update the community_policing table to mark the 'follow-up' column as done for record with id 1001 and user id 250? | UPDATE community_policing SET follow_up = 'done' WHERE id = 1001 AND user_id = 250; | gretelai_synthetic_text_to_sql |
CREATE TABLE ports_cargo (port_id INT, port_name TEXT, cargo_quantity INT); INSERT INTO ports_cargo VALUES (1, 'Port F', 1800), (2, 'Port G', 1500), (3, 'Port H', 1000); | What is the total quantity of cargo handled by each port, sorted in descending order? | SELECT ports_cargo.port_name, SUM(ports_cargo.cargo_quantity) FROM ports_cargo GROUP BY ports_cargo.port_name ORDER BY SUM(ports_cargo.cargo_quantity) DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE genetic_research (id INT, name TEXT, description TEXT); INSERT INTO genetic_research (id, name, description) VALUES (1, 'ProjectX', 'Genome sequencing'), (2, 'ProjectY', 'CRISPR study'), (3, 'ProjectZ', 'Gene therapy'); | List all genetic research projects in the 'genetic_research' table with a description containing 'sequencing'. | SELECT * FROM genetic_research WHERE description LIKE '%sequencing%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists risk_assessments (id INT PRIMARY KEY, score INT, description TEXT); | update a risk assessment score and description | UPDATE risk_assessments SET score = 4, description = 'Medium Risk' WHERE id = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE water_treatment_plants (id INT, name VARCHAR(50), location VARCHAR(50), year_established INT); INSERT INTO water_treatment_plants (id, name, location, year_established) VALUES (1, 'PlantA', 'CityA', 1990), (2, 'PlantB', 'CityB', 2005), (3, 'PlantC', 'CityC', 2010), (4, 'PlantD', 'CityD', 2015); CREATE TABLE water_consumption_plants (plant_id INT, year INT, consumption INT); INSERT INTO water_consumption_plants (plant_id, year, consumption) VALUES (1, 2019, 4000000), (2, 2019, 5000000), (3, 2019, 6000000), (4, 2019, 7000000), (1, 2020, 5500000), (2, 2020, 6500000), (3, 2020, 7500000), (4, 2020, 8500000); | What was the average water consumption by water treatment plants in 2019 and 2020? | SELECT wtp.name, AVG(wcp.consumption) as avg_consumption FROM water_treatment_plants wtp JOIN water_consumption_plants wcp ON wtp.id = wcp.plant_id WHERE wcp.year IN (2019, 2020) GROUP BY wtp.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE SpaceMissions (ID INT, MissionName VARCHAR(50), LaunchCompany VARCHAR(50)); INSERT INTO SpaceMissions VALUES (1, 'Apollo 11', 'NASA'), (2, 'Falcon 9', 'SpaceX'), (3, 'Atlas V', 'ULA'); | How many space missions were launched by SpaceX? | SELECT COUNT(*) FROM SpaceMissions WHERE LaunchCompany = 'SpaceX'; | gretelai_synthetic_text_to_sql |
CREATE TABLE donations (id INT, donor_state VARCHAR(255), recipient_sector VARCHAR(255), donation_amount DECIMAL(10,2)); INSERT INTO donations (id, donor_state, recipient_sector, donation_amount) VALUES (1, 'New York', 'arts and culture', 1500.00), (2, 'New York', 'healthcare', 500.00), (3, 'Texas', 'arts and culture', 2000.00); | What is the average donation amount to arts and culture organizations in New York? | SELECT AVG(donation_amount) FROM donations WHERE donor_state = 'New York' AND recipient_sector = 'arts and culture'; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA rural; CREATE TABLE rural.doctors (id INT, name TEXT, country TEXT); | Insert new records into the 'doctors' table for Dr. José Hernández from Mexico. | INSERT INTO rural.doctors (id, name, country) VALUES (1, 'José Hernández', 'Mexico'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Oil_Production (well text, production_date date, quantity real); INSERT INTO Oil_Production (well, production_date, quantity) VALUES ('W006', '2021-02-01', 150.5), ('W007', '2021-02-02', 160.3), ('W008', '2021-02-15', 180.0); | Which well has the highest production in the month of February 2021 in the Oil_Production table? | SELECT well, MAX(quantity) FROM Oil_Production WHERE production_date BETWEEN '2021-02-01' AND '2021-02-28' GROUP BY well; | gretelai_synthetic_text_to_sql |
CREATE TABLE maritime_law_species (id INT, species_name TEXT, law_applicable TEXT);INSERT INTO maritime_law_species (id, species_name, law_applicable) VALUES (1, 'Krill', 'Yes'), (2, 'Blue Whale', 'Yes'), (3, 'Giant Pacific Octopus', 'No');CREATE TABLE marine_species (id INT, species_name TEXT, region TEXT);INSERT INTO marine_species (id, species_name, region) VALUES (1, 'Great White Shark', 'Pacific'), (2, 'Blue Whale', 'Antarctic'), (3, 'Giant Pacific Octopus', 'Pacific'), (4, 'Green Sea Turtle', 'Atlantic'); | Which marine species are present in the 'Antarctic' region and also subject to maritime law? | SELECT DISTINCT species_name FROM marine_species m INNER JOIN maritime_law_species ml ON m.species_name = ml.species_name WHERE m.region = 'Antarctic' AND ml.law_applicable = 'Yes'; | gretelai_synthetic_text_to_sql |
CREATE TABLE carbon_offset_initiatives (id INT, name VARCHAR(255), location VARCHAR(255), start_date DATE); INSERT INTO carbon_offset_initiatives (id, name, location, start_date) VALUES (1, 'TreePlanting1', 'CityC', '2020-01-01'), (2, 'WasteReduction1', 'CityD', '2019-06-15'), (3, 'TreePlanting2', 'CityC', '2020-07-01'), (4, 'SoilRemediation1', 'CityE', '2018-12-25'); | Earliest start date for carbon offset initiatives | SELECT MIN(start_date) as earliest_start_date FROM carbon_offset_initiatives; | gretelai_synthetic_text_to_sql |
CREATE TABLE organic_cafe (dish_name TEXT, calories INTEGER); INSERT INTO organic_cafe (dish_name, calories) VALUES ('Quinoa Salad', 350), ('Tofu Stir Fry', 450), ('Veggie Wrap', 600); | What is the average calorie count for all dishes in the organic_cafe restaurant? | SELECT AVG(calories) FROM organic_cafe; | gretelai_synthetic_text_to_sql |
CREATE TABLE faculty (faculty_id INT, name VARCHAR(50), gender VARCHAR(10), department VARCHAR(50), position VARCHAR(50)); INSERT INTO faculty VALUES (1, 'John Doe', 'Male', 'Mathematics', 'Professor'), (2, 'Jane Smith', 'Female', 'Physics', 'Assistant Professor'), (3, 'Alice Johnson', 'Female', 'Mathematics', 'Associate Professor'); CREATE TABLE grants (grant_id INT, faculty_id INT, title VARCHAR(50), amount DECIMAL(10,2)); INSERT INTO grants VALUES (1, 2, 'Grant A', 50000), (2, 2, 'Grant B', 75000), (3, 3, 'Grant C', 60000); | List the top 3 departments with the highest total research grant amounts for female faculty. | SELECT department, SUM(amount) as total_grant_amount, ROW_NUMBER() OVER (PARTITION BY f.gender ORDER BY SUM(amount) DESC) as rank FROM faculty f LEFT JOIN grants g ON f.faculty_id = g.faculty_id WHERE f.gender = 'Female' GROUP BY department, f.gender ORDER BY rank ASC; | gretelai_synthetic_text_to_sql |
CREATE TABLE If Not Exists disaster_response (disaster_id INT, disaster_type TEXT, location TEXT, response_time DATETIME); INSERT INTO disaster_response (disaster_id, disaster_type, location, response_time) VALUES (4, 'Fire', 'California', '2022-05-01 15:00:00'), (5, 'Tornado', 'Oklahoma', '2022-06-10 09:30:00'); | What is the average response time for each disaster type? | SELECT disaster_type, AVG(DATEDIFF('2022-12-31', response_time)) as avg_response_time FROM disaster_response GROUP BY disaster_type; | gretelai_synthetic_text_to_sql |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.