context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28 values |
|---|---|---|---|
CREATE TABLE Patients (PatientID INT, Age INT, Gender TEXT, VaccinationStatus TEXT, State TEXT); INSERT INTO Patients (PatientID, Age, Gender, VaccinationStatus, State) VALUES (1, 45, 'Female', 'Vaccinated', 'California'); | What is the average age of female patients who have been vaccinated against influenza in California? | SELECT AVG(Age) FROM Patients WHERE Gender = 'Female' AND VaccinationStatus = 'Vaccinated' AND State = 'California'; | gretelai_synthetic_text_to_sql |
CREATE TABLE agroecology_initiatives (id INT, name VARCHAR(255), area FLOAT, continent VARCHAR(255)); INSERT INTO agroecology_initiatives (id, name, area, continent) VALUES (1, 'Initiative A', 12345.6, 'Africa'), (2, 'Initiative B', 23456.7, 'Europe'), (3, 'Initiative C', 34567.8, 'Asia'); | How many agroecology initiatives are there in Africa and what is the average size of land in square kilometers used for these initiatives? | SELECT continent, COUNT(*), AVG(area * 0.0001) as avg_area_sq_km FROM agroecology_initiatives WHERE continent = 'Africa' GROUP BY continent; | gretelai_synthetic_text_to_sql |
CREATE TABLE basketball_sales (team VARCHAR(50), game_date DATE, tickets_sold INT, ticket_price DECIMAL(5,2)); INSERT INTO basketball_sales (team, game_date, tickets_sold, ticket_price) VALUES ('Boston Celtics', '2023-01-01', 5000, 75.50), ('Golden State Warriors', '2023-01-02', 7000, 65.00), ('Los Angeles Lakers', '2023-01-03', 6000, 80.00), ('Brooklyn Nets', '2023-01-04', 8000, 70.00), ('Philadelphia 76ers', '2023-01-05', 9000, 60.00); | Which basketball teams had the highest total ticket sales in the first quarter of 2023, and what was the average ticket price for each team? | SELECT team, SUM(tickets_sold) AS total_sales, AVG(ticket_price) AS avg_price FROM basketball_sales WHERE game_date BETWEEN '2023-01-01' AND '2023-03-31' GROUP BY team ORDER BY total_sales DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE user_content_views (view_id INT, user_id INT, content_id INT, view_date DATE, user_gender VARCHAR(10)); CREATE TABLE content (content_id INT, content_type VARCHAR(20)); | What is the distribution of views by gender for each content type? | SELECT content_type, user_gender, COUNT(*) as view_count FROM user_content_views JOIN content ON user_content_views.content_id = content.content_id GROUP BY content_type, user_gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE dishes (id INT, name VARCHAR(255), calories INT); INSERT INTO dishes (id, name, calories) VALUES (1, 'Pad Thai', 600), (2, 'Fried Rice', 700), (3, 'Pizza', 1200), (4, 'Tacos', 800), (5, 'Curry', 900), (6, 'Coq au Vin', 1000), (7, 'Salad', 200), (8, 'Soup', 300), (9, 'Fruit Salad', 400); | What is the name and total calorie count for the 3 dishes with the lowest calorie count? | SELECT name, SUM(calories) as total_calories FROM dishes ORDER BY total_calories ASC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE exit_strategies(id INT, startup_id INT, type TEXT); INSERT INTO exit_strategies (id, startup_id, type) VALUES (1, 1, 'Acquisition'); | List the exit strategies for startups founded by BIPOC individuals in the sustainability sector. | SELECT DISTINCT startup_id, type FROM exit_strategies JOIN startups ON exit_strategies.startup_id = startups.id JOIN founders ON startups.id = founders.startup_id WHERE industry = 'Sustainability' AND founder_identity = 'BIPOC'; | gretelai_synthetic_text_to_sql |
USE biotech; CREATE TABLE if not exists startups (id INT, name VARCHAR(255), location VARCHAR(255), funding DECIMAL(10,2)); INSERT INTO startups (id, name, location, funding) VALUES (1, 'StartupA', 'Germany', 2500000.00), (2, 'StartupB', 'France', 3000000.00), (3, 'StartupC', 'Germany', 1500000.00), (4, 'StartupD', 'France', 2000000.00); | What is the total funding received by biotech startups in Germany and France? | SELECT SUM(funding) FROM startups WHERE location IN ('Germany', 'France'); | gretelai_synthetic_text_to_sql |
CREATE TABLE SportsCars (Id INT PRIMARY KEY, Name VARCHAR(100), Year INT, Horsepower INT); INSERT INTO SportsCars (Id, Name, Year, Horsepower) VALUES (1, 'Ferrari 488', 2015, 661), (2, 'Porsche 911 GT3', 2017, 500), (3, 'Audi R8 V10', 2016, 610), (4, 'McLaren 720S', 2017, 720), (5, 'Lamborghini Huracan', 2014, 602), (6, 'Chevrolet Corvette Z06', 2015, 650), (7, 'Mercedes-AMG GT R', 2018, 577), (8, 'Jaguar F-Type SVR', 2016, 575), (9, 'Nissan GT-R Nismo', 2017, 600), (10, 'Aston Martin DB11 V12', 2017, 600); | What is the average horsepower of sports cars released between 2015 and 2020? | SELECT AVG(Horsepower) FROM SportsCars WHERE Year BETWEEN 2015 AND 2020 AND Name LIKE '%Sports%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE couriers (courier_id INT, courier TEXT); INSERT INTO couriers (courier_id, courier) VALUES (1, 'DHL'), (2, 'UPS'), (3, 'FedEx'); CREATE TABLE deliveries (delivery_id INT, courier_id INT, delivery_time INT); INSERT INTO deliveries (delivery_id, courier_id, delivery_time) VALUES (1, 1, 500), (2, 2, 700), (3, 3, 400), (4, 1, 600), (5, 3, 300); | What is the average delivery time for each courier? | SELECT c.courier, AVG(d.delivery_time) as avg_delivery_time FROM deliveries d JOIN couriers c ON d.courier_id = c.courier_id GROUP BY c.courier; | gretelai_synthetic_text_to_sql |
CREATE TABLE inspections_japan (id INT, restaurant_id INT, passed BOOLEAN); INSERT INTO inspections_japan (id, restaurant_id, passed) VALUES (1, 101, true), (2, 102, false); | What is the percentage of restaurants in Japan that passed their food safety inspections? | SELECT (COUNT(*) FILTER (WHERE passed = true) / COUNT(*)) * 100 AS percentage_passed FROM inspections_japan; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_protection (area VARCHAR(50), pollution_level FLOAT); INSERT INTO marine_protection VALUES ('Area A', 5.5), ('Area B', 6.6), ('Area C', 7.7); | What is the maximum pollution level in the marine protected areas, along with the area name? | SELECT area, MAX(pollution_level) as max_pollution FROM marine_protection GROUP BY area; | gretelai_synthetic_text_to_sql |
CREATE TABLE shared_scooters_canada (scooter_id INT, trip_duration INT, start_time TIMESTAMP, end_time TIMESTAMP, start_station TEXT, end_station TEXT, city TEXT, electric BOOLEAN); | What is the average waiting time for shared electric scooters in Vancouver, Canada? | SELECT AVG(EXTRACT(MINUTE FROM end_time - start_time)) FROM shared_scooters_canada WHERE city = 'Vancouver' AND electric = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE company (id INT, name VARCHAR(255), founder VARCHAR(255)); INSERT INTO company (id, name, founder) VALUES (1, 'Acme Inc', 'Mateo'), (2, 'Beta Corp', 'Jessica'), (3, 'Charlie Inc', 'David'), (4, 'Delta Corp', 'Xiao'); | List all companies founded by a person named "Mateo" or "Xiao" | SELECT name FROM company WHERE founder IN ('Mateo', 'Xiao'); | gretelai_synthetic_text_to_sql |
CREATE TABLE vehicles (vehicle_id INT, vehicle_type TEXT); INSERT INTO vehicles (vehicle_id, vehicle_type) VALUES (1, 'Tram'), (2, 'Bus'), (3, 'Train'); CREATE TABLE maintenance (maintenance_id INT, vehicle_id INT, maintenance_date DATE); INSERT INTO maintenance (maintenance_id, vehicle_id, maintenance_date) VALUES (1, 1, '2017-01-01'), (2, 1, '2018-01-01'), (3, 2, '2019-01-01'); | Delete all maintenance records for tram vehicles older than 5 years. | DELETE FROM maintenance WHERE vehicle_id IN (SELECT vehicle_id FROM vehicles WHERE vehicle_type = 'Tram') AND maintenance_date < DATE_SUB(CURRENT_DATE, INTERVAL 5 YEAR); | gretelai_synthetic_text_to_sql |
CREATE TABLE artists (artist_id INT, artist_name VARCHAR(50), continent VARCHAR(50)); CREATE TABLE awards (award_id INT, artist_id INT, award_year INT); | How many awards won by artists from each continent, joined with the "artists" and "awards" tables, between 2015 and 2020? | SELECT a.continent, COUNT(DISTINCT a.artist_id) as total_awards FROM artists a INNER JOIN awards aw ON a.artist_id = aw.artist_id WHERE aw.award_year BETWEEN 2015 AND 2020 GROUP BY a.continent; | gretelai_synthetic_text_to_sql |
CREATE TABLE ingredients (id INT, ingredient_name TEXT, unit_price DECIMAL, quantity INT); | What is the total cost of ingredients for vegan dishes, updated to reflect the current inventory levels? | SELECT SUM(unit_price * quantity) FROM ingredients WHERE ingredient_name IN (SELECT ingredient_name FROM menu_items WHERE is_vegan = TRUE); | gretelai_synthetic_text_to_sql |
CREATE TABLE regulatory_compliance (vessel_id INT, violation_date DATE, violation_type VARCHAR(255)); | Show the number of regulatory violations for each vessel in the 'regulatory_compliance' table | SELECT vessel_id, violation_type, COUNT(*) FROM regulatory_compliance GROUP BY vessel_id, violation_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE Members (MemberID INT, HasSmartwatch BOOLEAN); CREATE TABLE Workouts (WorkoutID INT, MemberID INT, WorkoutDate DATE); | What is the average number of workouts per week for members who have a smartwatch? | SELECT AVG(WorkoutsPerWeek) FROM (SELECT MemberID, COUNT(*)/7 AS WorkoutsPerWeek FROM Workouts INNER JOIN Members ON Workouts.MemberID = Members.MemberID WHERE Members.HasSmartwatch = TRUE GROUP BY MemberID) AS Subquery; | gretelai_synthetic_text_to_sql |
CREATE TABLE green_buildings (id INT, company_name TEXT, certification TEXT, region TEXT); INSERT INTO green_buildings (id, company_name, certification, region) VALUES (1, 'EcoBuild USA', 'LEED', 'North America'), (2, 'GreenTech Canada', 'Living Building Challenge', 'North America'); | What are the unique green building certifications held by companies in North America? | SELECT DISTINCT certification FROM green_buildings WHERE region = 'North America'; | gretelai_synthetic_text_to_sql |
CREATE TABLE destinations (id INT, name VARCHAR(255), sustainability_score INT); INSERT INTO destinations (id, name, sustainability_score) VALUES (1, 'Costa Rica', 90), (2, 'Norway', 85), (3, 'New Zealand', 80), (4, 'Iceland', 75), (5, 'Finland', 70); | What is the average sustainability score for all destinations? | SELECT AVG(sustainability_score) FROM destinations; | gretelai_synthetic_text_to_sql |
CREATE TABLE Events (ID INT, City VARCHAR(50), EventType VARCHAR(50), AttendeeCount INT, EventDate DATE); | Find the difference in attendee count between consecutive events for each event type. | SELECT City, EventType, AttendeeCount, LEAD(AttendeeCount) OVER(PARTITION BY EventType ORDER BY EventDate) - AttendeeCount AS Difference FROM Events; | gretelai_synthetic_text_to_sql |
CREATE TABLE company_info (id INT, name TEXT, sector TEXT, membership TEXT); INSERT INTO company_info (id, name, sector, membership) VALUES (1, 'Energia Verde', 'Energy', 'UN Global Compact'), (2, 'PowerTech', 'Technology', 'TechForGood'); | List companies in the energy sector with a UN Global Compact membership in South America. | SELECT * FROM company_info WHERE sector = 'Energy' AND membership = 'UN Global Compact' AND country LIKE 'South%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Topics (id INT PRIMARY KEY, topic VARCHAR(100)); INSERT INTO Topics (id, topic) VALUES (1, 'Politics'), (2, 'Sports'), (3, 'Entertainment'); CREATE TABLE ArticleTopics (article_id INT, topic_id INT, FOREIGN KEY (article_id) REFERENCES Articles(id), FOREIGN KEY (topic_id) REFERENCES Topics(id)); CREATE TABLE Articles (id INT PRIMARY KEY, author_id INT, FOREIGN KEY (author_id) REFERENCES Authors(id)); INSERT INTO ArticleTopics (article_id, topic_id) VALUES (1, 1), (1, 2), (2, 3), (3, 1); INSERT INTO Articles (id, author_id) VALUES (1, 1), (2, 2), (3, 1); | What is the distribution of articles by topic for a specific author? | SELECT t.topic, COUNT(at.article_id) as num_articles FROM ArticleTopics at JOIN Articles a ON at.article_id = a.id JOIN Topics t ON at.topic_id = t.id WHERE a.author_id = 1 GROUP BY t.topic; | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (id INT, name VARCHAR(255)); INSERT INTO donors (id, name) VALUES (1, 'Anonymous Donor'); CREATE TABLE donations (id INT, donor_id INT, organization_id INT, amount DECIMAL(10,2), donation_date DATE); INSERT INTO donations (id, donor_id, organization_id, amount, donation_date) VALUES (1, 1, 4, 7500, '2021-09-22'); CREATE TABLE organizations (id INT, name VARCHAR(255), focus VARCHAR(255)); INSERT INTO organizations (id, name, focus) VALUES (4, 'Climate Action Network', 'Climate Change'); | Which donors have contributed more than $10,000 in total to organizations focused on climate change? | SELECT donors.name FROM donors INNER JOIN (SELECT donor_id, SUM(amount) as total_donated FROM donations JOIN organizations ON donations.organization_id = organizations.id WHERE organizations.focus = 'Climate Change' GROUP BY donor_id) subquery ON donors.id = subquery.donor_id WHERE subquery.total_donated > 10000; | gretelai_synthetic_text_to_sql |
CREATE TABLE tourism_revenue (destination_id INT, year INT, revenue INT); CREATE VIEW revenue_summary AS SELECT destination_id, SUM(revenue) as total_revenue FROM tourism_revenue GROUP BY destination_id; | What are the top 2 destinations in Asia with the highest tourism revenue in the year 2020? | SELECT d.country, r.total_revenue FROM destinations d JOIN revenue_summary r ON d.id = r.destination_id WHERE d.region = 'Asia' AND r.year = 2020 GROUP BY d.id ORDER BY r.total_revenue DESC LIMIT 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE FoodSafetyRecords.SustainableSeafood (seafoodName TEXT, country TEXT, sustainable TEXT); | Update the FoodSafetyRecords.SustainableSeafood table to include a new record for a responsibly sourced salmon farm in Norway. | INSERT INTO FoodSafetyRecords.SustainableSeafood (seafoodName, country, sustainable) VALUES ('Salmon', 'Norway', 'Responsibly sourced and certified by MSC'); | gretelai_synthetic_text_to_sql |
CREATE TABLE aquaculture_farms (id INT, farm_name VARCHAR(50), biomass DECIMAL(10,2), carbon_footprint DECIMAL(10,2)); INSERT INTO aquaculture_farms (id, farm_name, biomass, carbon_footprint) VALUES (1, 'Farm A', 20000, 500); INSERT INTO aquaculture_farms (id, farm_name, biomass, carbon_footprint) VALUES (2, 'Farm B', 15000, 350); INSERT INTO aquaculture_farms (id, farm_name, biomass, carbon_footprint) VALUES (3, 'Farm C', 12000, 400); | Delete the farm record with ID 3 | DELETE FROM aquaculture_farms WHERE id = 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE RouteOptimization (id INT, route VARCHAR(50), cost INT, date DATE); INSERT INTO RouteOptimization (id, route, cost, date) VALUES (1, 'Route 1', 500, '2023-01-01'), (2, 'Route 4', 700, '2023-01-05'); | Display route optimization information for Route 1 and Route 4 | SELECT route, cost FROM RouteOptimization WHERE route IN ('Route 1', 'Route 4'); | gretelai_synthetic_text_to_sql |
CREATE TABLE public_services (category VARCHAR(255), name VARCHAR(255), location VARCHAR(255)); | List the unique categories of public services in the city, excluding 'Waste Management'. | SELECT DISTINCT category FROM public_services WHERE category != 'Waste Management'; | gretelai_synthetic_text_to_sql |
CREATE TABLE social_tech (id INT, project VARCHAR(50), technology VARCHAR(50), description TEXT, impact FLOAT, organization VARCHAR(50)); INSERT INTO social_tech (id, project, technology, description, impact, organization) VALUES (3, 'NLP for Mental Health', 'Natural Language Processing', 'A project using NLP to detect mental health issues through social media posts.', 0.85, 'MindTrack'); | What is the average impact of projects involving natural language processing? | SELECT technology, AVG(impact) as avg_impact FROM social_tech WHERE description LIKE '%Natural Language Processing%' GROUP BY technology; | gretelai_synthetic_text_to_sql |
CREATE TABLE Healthcare_Units (ID INT, Name TEXT, Type TEXT, State TEXT); INSERT INTO Healthcare_Units (ID, Name, Type, State) VALUES (1, 'Clinic X', 'Immunization Clinic', 'California'); INSERT INTO Healthcare_Units (ID, Name, Type, State) VALUES (2, 'Unit Y', 'Mobile Health Unit', 'New York'); | What is the total number of immunization clinics and mobile health units in each state? | SELECT State, COUNT(*) FROM Healthcare_Units WHERE Type IN ('Immunization Clinic', 'Mobile Health Unit') GROUP BY State; | gretelai_synthetic_text_to_sql |
CREATE TABLE pants_revenue(product VARCHAR(20), location VARCHAR(20), revenue INT); INSERT INTO pants_revenue VALUES('Pants', 'United Kingdom', 7000); | List the 'Revenue' for 'Pants' sold in 'United Kingdom'. | SELECT revenue FROM pants_revenue WHERE product = 'Pants' AND location = 'United Kingdom'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (Donor_ID int, Name varchar(50), Donation_Amount int, Country varchar(50)); INSERT INTO Donors (Donor_ID, Name, Donation_Amount, Country) VALUES (1, 'John Doe', 7000, 'USA'), (2, 'Jane Smith', 3000, 'Canada'), (3, 'Mike Johnson', 4000, 'USA'), (4, 'Emma Wilson', 8000, 'Canada'), (5, 'Raj Patel', 9000, 'India'), (6, 'Ana Sousa', 10000, 'Brazil'); | delete from Donors where Country not in ('USA', 'Canada') | DELETE FROM Donors WHERE Country NOT IN ('USA', 'Canada'); | gretelai_synthetic_text_to_sql |
CREATE TABLE ev_charging_station (id INT, country VARCHAR(20), name VARCHAR(50), year INT); INSERT INTO ev_charging_station (id, country, name, year) VALUES (1, 'France', 'Charging Station 1', 2022), (2, 'Italy', 'Charging Station 2', 2022), (3, 'France', 'Charging Station 3', 2021); | How many electric vehicle charging stations are there in France and Italy as of 2022? | SELECT COUNT(*) FROM ev_charging_station WHERE country IN ('France', 'Italy') AND year = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE threat_intel (id INT, source TEXT); INSERT INTO threat_intel (id, source) VALUES (1, 'Malware Exchange'); INSERT INTO threat_intel (id, source) VALUES (2, 'Open Threat Exchange'); INSERT INTO threat_intel (id, source) VALUES (3, 'ShadowServer'); INSERT INTO threat_intel (id, source) VALUES (4, 'AlienVault'); INSERT INTO threat_intel (id, source) VALUES (5, 'Cyber Threat Alliance'); | What are the unique threat intelligence sources and their respective counts? | SELECT source, COUNT(*) as count FROM threat_intel GROUP BY source; | gretelai_synthetic_text_to_sql |
CREATE TABLE expenses (expense_id INT, expense_date DATE, category VARCHAR(50), amount DECIMAL(10,2)); INSERT INTO expenses VALUES (1, '2022-07-01', 'Program Supplies', 300.00), (2, '2022-08-15', 'Office Supplies', 200.00), (3, '2022-10-01', 'Program Supplies', 400.00); | What was the total expense on program supplies in Q3 2022? | SELECT SUM(amount) FROM expenses WHERE expense_date BETWEEN '2022-07-01' AND '2022-09-30' AND category = 'Program Supplies'; | gretelai_synthetic_text_to_sql |
CREATE TABLE covid_cases (id INT, state TEXT, cases INT); INSERT INTO covid_cases (id, state, cases) VALUES (1, 'California', 1000); INSERT INTO covid_cases (id, state, cases) VALUES (2, 'New York', 2000); INSERT INTO covid_cases (id, state, cases) VALUES (3, 'Florida', 1500); | Find the top 3 states with the most COVID-19 cases. | SELECT state, cases FROM covid_cases ORDER BY cases DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE cb_agreements (agreement_id INT, industry TEXT, expiration_date DATE); INSERT INTO cb_agreements (agreement_id, industry, expiration_date) VALUES (1, 'service', '2023-07-15'), (2, 'retail', '2022-12-31'), (3, 'service', '2023-01-01'); | List all collective bargaining agreements in the 'service' industry with an expiration date in the next 12 months, ordered by expiration date. | SELECT * FROM cb_agreements WHERE industry = 'service' AND expiration_date BETWEEN CURDATE() AND DATE_ADD(CURDATE(), INTERVAL 12 MONTH) ORDER BY expiration_date; | gretelai_synthetic_text_to_sql |
CREATE TABLE solar_plants (id INT, name VARCHAR(50), location VARCHAR(50), efficiency FLOAT, capacity INT); INSERT INTO solar_plants (id, name, location, efficiency, capacity) VALUES (1, 'SolarPlant1', 'Africa', 0.27, 100), (2, 'SolarPlant2', 'Africa', 0.30, 150), (3, 'SolarPlant3', 'Africa', 0.35, 200); | What is the maximum installed capacity (in MW) of solar power plants in 'Africa' that have an efficiency rating above 25%? | SELECT MAX(capacity) FROM solar_plants WHERE location = 'Africa' AND efficiency > 0.25; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA agroecology;CREATE TABLE tools (id INT, name VARCHAR(50), category VARCHAR(50), cost FLOAT);INSERT INTO agroecology.tools (id, name, category, cost) VALUES (1, 'Tool A', 'Category A', 50.0), (2, 'Tool B', 'Category B', 60.0), (3, 'Tool C', 'Category A', 70.0), (4, 'Tool D', 'Category C', 80.0); | List all farming tools in the 'agroecology' schema along with their corresponding categories, and calculate the average cost of tools in each category. | SELECT category, AVG(cost) FROM agroecology.tools GROUP BY category; | gretelai_synthetic_text_to_sql |
CREATE TABLE articles (id INT, title VARCHAR(50), category VARCHAR(20), region VARCHAR(20)); INSERT INTO articles (id, title, category, region) VALUES (1, 'Article One', 'media ethics', 'Europe'), (2, 'Article Two', 'investigative journalism', 'North America'); | Which region has the highest total number of articles on 'media ethics' and 'investigative journalism'? | SELECT region, SUM(total_articles) AS total_articles FROM (SELECT region, COUNT(*) AS total_articles FROM articles WHERE category IN ('media ethics', 'investigative journalism') GROUP BY region) AS subquery GROUP BY region ORDER BY total_articles DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE students (id INT, visual_impairment BOOLEAN, department VARCHAR(255)); INSERT INTO students (id, visual_impairment, department) VALUES (1, true, 'science'), (2, false, 'engineering'), (3, true, 'science'), (4, true, 'mathematics'), (5, false, 'science'), (6, true, 'mathematics'); CREATE TABLE accommodations (id INT, student_id INT, year INT); INSERT INTO accommodations (id, student_id, year) VALUES (1, 1, 2018), (2, 1, 2019), (3, 3, 2018), (4, 3, 2019), (5, 3, 2020), (6, 4, 2020), (7, 5, 2018), (8, 5, 2019), (9, 5, 2020), (10, 5, 2021), (11, 6, 2020), (12, 6, 2021); | How many students with visual impairments have received accommodations in each department in 2020 or 2021? | SELECT s.department, COUNT(*) as accommodations FROM students s INNER JOIN accommodations a ON s.id = a.student_id WHERE s.visual_impairment = true AND a.year IN (2020, 2021) GROUP BY s.department; | gretelai_synthetic_text_to_sql |
CREATE TABLE artisan_workshops (workshop_id INT, workshop_name TEXT, city TEXT); INSERT INTO artisan_workshops (workshop_id, workshop_name, city) VALUES (1, 'Brooklyn Ceramics', 'New York City'), (2, 'Echo Park Guitars', 'Los Angeles'); | List all local artisan workshops in New York City and Los Angeles. | SELECT workshop_name, city FROM artisan_workshops WHERE city IN ('New York City', 'Los Angeles'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Volunteers (volunteer_id INT, program_id INT, volunteer_hours INT, volunteer_date DATE); INSERT INTO Volunteers (volunteer_id, program_id, volunteer_hours, volunteer_date) VALUES (1, 1, 5, '2021-06-05'), (2, 2, 8, '2021-04-12'), (3, 1, 3, '2021-06-05'), (1, 3, 6, '2021-12-25'); | Which program had the highest total volunteer hours in 2021? | SELECT program_id, SUM(volunteer_hours) as total_2021_volunteer_hours FROM Volunteers WHERE volunteer_date BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY program_id ORDER BY total_2021_volunteer_hours DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE PeacekeepingOperations (Operation VARCHAR(50), Year INT, Peacekeepers INT, Organization VARCHAR(50)); INSERT INTO PeacekeepingOperations (Operation, Year, Peacekeepers, Organization) VALUES ('Operation United Nations Assistance Mission in Somalia', 2015, 22000, 'United Nations'), ('Operation United Nations Mission in South Sudan', 2016, 16000, 'United Nations'), ('Operation United Nations Multidimensional Integrated Stabilization Mission in the Central African Republic', 2017, 12000, 'United Nations'), ('Operation United Nations Stabilization Mission in Haiti', 2018, 15000, 'United Nations'), ('Operation United Nations Mission in Liberia', 2019, 18000, 'United Nations'), ('Operation United Nations Mission in the Republic of South Sudan', 2020, 19000, 'United Nations'); | List the peacekeeping operations in which the United Nations participated and the number of peacekeepers deployed in each operation from 2015 to 2020. | SELECT Operation, Year, SUM(Peacekeepers) AS TotalPeacekeepers FROM PeacekeepingOperations WHERE Organization = 'United Nations' AND Year BETWEEN 2015 AND 2020 GROUP BY Operation, Year; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_farms (id INT, name TEXT, type TEXT, location TEXT, water_temp FLOAT); INSERT INTO marine_farms (id, name, type, location, water_temp) VALUES (1, 'Farm A', 'Finfish', 'Norway', 8.5), (2, 'Farm B', 'Finfish', 'Canada', 2.0); | What is the average water temperature for marine finfish farms in January? | SELECT AVG(water_temp) FROM marine_farms WHERE EXTRACT(MONTH FROM datetime('now', '-1 month')) = 1 AND type = 'Finnfish'; | gretelai_synthetic_text_to_sql |
CREATE TABLE StudentsWithPhysicalDisabilities (StudentID INT, Region VARCHAR(50), DisabilityType VARCHAR(50)); CREATE TABLE AccommodationsForStudentsWithPhysicalDisabilities (StudentID INT, Year INT); | What is the number of students with physical disabilities who received accommodations in each region in 2020? | SELECT Region, COUNT(StudentID) FROM StudentsWithPhysicalDisabilities s JOIN AccommodationsForStudentsWithPhysicalDisabilities a ON s.StudentID = a.StudentID WHERE s.DisabilityType = 'physical disability' AND a.Year = 2020 GROUP BY Region; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotels (id INT, name TEXT, country TEXT, virtual_tour BOOLEAN); INSERT INTO hotels (id, name, country, virtual_tour) VALUES (1, 'Hotel A', 'Australia', true), (2, 'Hotel B', 'Australia', false), (3, 'Hotel C', 'Australia', false); | Count the number of hotels without a virtual tour in Australia | SELECT COUNT(*) FROM hotels WHERE country = 'Australia' AND virtual_tour = false; | gretelai_synthetic_text_to_sql |
CREATE TABLE spacecrafts (id INT, name VARCHAR(50), max_altitude INT); INSERT INTO spacecrafts VALUES (1, 'Apollo', 400000); INSERT INTO spacecrafts VALUES (2, 'Soyuz', 367000); | What is the maximum altitude reached by each type of spacecraft? | SELECT name, max_altitude FROM spacecrafts; | gretelai_synthetic_text_to_sql |
CREATE TABLE incomes (id INT, rural BOOLEAN, income FLOAT); INSERT INTO incomes (id, rural, income) VALUES (1, true, 50000), (2, false, 70000), (3, true, 55000); | What is the average income for healthcare workers in rural areas? | SELECT AVG(income) FROM incomes WHERE rural = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE Companies (id INT, name VARCHAR(255)); CREATE TABLE DigitalAssets (id INT, company_id INT, value DECIMAL(10, 2), asset_date DATE); INSERT INTO Companies (id, name) VALUES (1, 'CompanyC'), (2, 'CompanyD'); INSERT INTO DigitalAssets (id, company_id, value, asset_date) VALUES (1, 1, 100, '2022-01-01'), (2, 1, 200, '2022-01-02'), (3, 2, 50, '2022-01-01'); | What is the total value of digital assets owned by the company with the name "CompanyC" as of 2022-01-01? | SELECT SUM(value) FROM DigitalAssets JOIN Companies ON DigitalAssets.company_id = Companies.id WHERE Companies.name = 'CompanyC' AND DigitalAssets.asset_date <= '2022-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE GreenValley (id INT, supplier VARCHAR(20), client VARCHAR(20), produce VARCHAR(20), quantity INT); INSERT INTO GreenValley (id, supplier, client, produce, quantity) VALUES (1, 'Green Valley', 'Eco Market', 'Broccoli', 100), (2, 'Green Valley', 'Eco Market', 'Cauliflower', 150); | How many times has 'Green Valley' supplied 'Eco Market' with organic vegetables? | SELECT SUM(quantity) FROM GreenValley WHERE supplier = 'Green Valley' AND client = 'Eco Market' AND produce LIKE '%vegetable%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species_research (id INT, species TEXT, location TEXT, year INT, population INT); INSERT INTO marine_species_research (id, species, location, year, population) VALUES (1, 'Whale Shark', 'Southern Ocean', 2010, 4000), (2, 'Dolphin', 'Southern Ocean', 2005, 7000), (3, 'Turtle', 'Southern Ocean', 2018, 10000); | What is the maximum population of any marine species researched in the Southern Ocean? | SELECT MAX(population) FROM marine_species_research WHERE location = 'Southern Ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE project (project_id INT, project_start_date DATE, project_end_date DATE, project_type VARCHAR(50), country_code CHAR(3), completed BOOLEAN, budget FLOAT); INSERT INTO project (project_id, project_start_date, project_end_date, project_type, country_code, completed, budget) VALUES (3, '2020-01-01', '2021-12-31', 'Bridge Construction', 'BRA', true, 2500000.0), (4, '2019-06-15', '2021-05-30', 'Power Generation', 'IND', false, 5000000.0); | What is the average budget of completed rural infrastructure projects by project type, for the past 3 years? | SELECT project_type, AVG(budget) as avg_budget FROM project WHERE completed = true AND project_end_date >= (CURRENT_DATE - INTERVAL '3 years') GROUP BY project_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE locations (location_name VARCHAR(50), revenue NUMERIC(10, 2)); INSERT INTO locations (location_name, revenue) VALUES ('San Francisco', 20000.00), ('New York', 30000.00), ('Los Angeles', 15000.00); | What is the total revenue for each location? | SELECT location_name, SUM(revenue) AS total_revenue FROM locations GROUP BY location_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE wastewater_treatment_plants (plant_id INT, region VARCHAR(20), water_recycled FLOAT, usage_date DATE); INSERT INTO wastewater_treatment_plants (plant_id, region, water_recycled, usage_date) VALUES (1, 'Mexico', 0.7, '2022-05-01'), (2, 'Mexico', 0.6, '2022-05-01'), (3, 'Mexico', 0.8, '2022-05-01'); | What is the percentage of water recycled in the wastewater treatment plants in Mexico in the month of May 2022? | SELECT 100.0 * AVG(water_recycled) FROM wastewater_treatment_plants WHERE region = 'Mexico' AND EXTRACT(MONTH FROM usage_date) = 5 AND EXTRACT(YEAR FROM usage_date) = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT, Gender VARCHAR(10), JobTitle VARCHAR(50), Department VARCHAR(50)); INSERT INTO Employees (EmployeeID, Gender, JobTitle, Department) VALUES (1, 'Female', 'Software Engineer', 'IT'), (2, 'Male', 'Project Manager', 'Marketing'), (3, 'Non-binary', 'Data Analyst', 'IT'), (4, 'Female', 'Software Engineer', 'IT'), (5, 'Male', 'Software Engineer', 'IT'), (6, 'Female', 'QA Engineer', 'IT'); CREATE TABLE MinorityStatus (EmployeeID INT, Minority VARCHAR(10)); INSERT INTO MinorityStatus (EmployeeID, Minority) VALUES (1, 'Yes'), (2, 'No'), (3, 'Yes'), (4, 'No'), (5, 'No'), (6, 'Yes'); | List all job titles and the number of employees who identify as a racial or ethnic minority, for jobs in the IT department. | SELECT e.JobTitle, COUNT(m.EmployeeID) as NumMinorityEmployees FROM Employees e INNER JOIN MinorityStatus m ON e.EmployeeID = m.EmployeeID WHERE e.Department = 'IT' AND m.Minority = 'Yes' GROUP BY e.JobTitle; | gretelai_synthetic_text_to_sql |
CREATE TABLE EcoFarms (id INT, supplier VARCHAR(20), client VARCHAR(20), produce VARCHAR(20), quantity INT); INSERT INTO EcoFarms (id, supplier, client, produce, quantity) VALUES (1, 'Eco Farms', 'Green Earth Market', 'Carrots', 100), (2, 'Eco Farms', 'Green Earth Market', 'Kale', 150); | How many times has 'Eco Farms' supplied 'Green Earth Market' with organic produce? | SELECT SUM(quantity) FROM EcoFarms WHERE supplier = 'Eco Farms' AND client = 'Green Earth Market'; | gretelai_synthetic_text_to_sql |
CREATE TABLE boroughs (borough_name VARCHAR(255)); INSERT INTO boroughs (borough_name) VALUES ('Brooklyn'), ('Manhattan'), ('Queens'), ('Bronx'), ('Staten Island'); CREATE TABLE crime_data (crime_date DATE, borough_name VARCHAR(255), crime_type VARCHAR(255), response_time INT); | What was the average response time for each crime type in each borough for the past month? | SELECT b.borough_name, ct.crime_type, AVG(cd.response_time) as avg_response_time FROM boroughs b JOIN crime_data cd ON b.borough_name = cd.borough_name JOIN (SELECT crime_type, borough_name, COUNT(*) as count FROM crime_data WHERE crime_date >= CURDATE() - INTERVAL 1 MONTH GROUP BY crime_type, borough_name) ct ON b.borough_name = ct.borough_name GROUP BY b.borough_name, ct.crime_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE Interviews (InterviewID int, InterviewDate date, CandidateName varchar(50), CandidateGender varchar(10), JobTitle varchar(50), City varchar(50)); INSERT INTO Interviews (InterviewID, InterviewDate, CandidateName, CandidateGender, JobTitle, City) VALUES (1, '2022-01-01', 'Alex Brown', 'Female', 'Software Engineer', 'New York'), (2, '2022-01-02', 'Taylor Green', 'Female', 'Data Analyst', 'Los Angeles'), (3, '2022-01-03', 'Jessica White', 'Female', 'Software Engineer', 'New York'), (4, '2022-01-04', 'Brittany Black', 'Female', 'Data Scientist', 'San Francisco'), (5, '2022-01-05', 'Kim Harris', 'Female', 'Software Engineer', 'Los Angeles'), (6, '2022-01-06', 'Amanda Wilson', 'Female', 'Data Analyst', 'Los Angeles'); | List the top 3 cities with the highest number of female candidates interviewed for a job in the past year, including their respective job titles and the number of candidates interviewed? | SELECT City, JobTitle, COUNT(*) AS num_candidates FROM Interviews WHERE CandidateGender = 'Female' AND InterviewDate >= DATEADD(year, -1, GETDATE()) GROUP BY City, JobTitle ORDER BY num_candidates DESC, City DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE ocean_acidification_2 (location VARCHAR(255), level FLOAT); | What is the maximum ocean acidification level in the Southern Hemisphere? | SELECT MAX(level) FROM ocean_acidification_2 WHERE location LIKE '%Southern Hemisphere%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE water_usage (region VARCHAR(20), sector VARCHAR(20), usage INT); INSERT INTO water_usage (region, sector, usage) VALUES ('North', 'Agriculture', 300), ('North', 'Domestic', 200), ('North', 'Industrial', 500), ('South', 'Agriculture', 400), ('South', 'Domestic', 250), ('South', 'Industrial', 600); | Which sectors have a higher water usage in the North region compared to the South region? | SELECT sector FROM water_usage WHERE (North.usage > South.usage) AND (region = 'North') | gretelai_synthetic_text_to_sql |
CREATE TABLE cases (case_id INT, category VARCHAR(20), billing_amount DECIMAL(5,2)); INSERT INTO cases (case_id, category, billing_amount) VALUES (1, 'Criminal Law', 1500.00), (2, 'Family Law', 2000.00); | What is the average billing amount for cases in the 'Criminal Law' category? | SELECT AVG(billing_amount) FROM cases WHERE category = 'Criminal Law'; | gretelai_synthetic_text_to_sql |
CREATE TABLE FishData (species VARCHAR(50), location VARCHAR(50), biomass FLOAT); INSERT INTO FishData (species, location, biomass) VALUES ('Atlantic Cod', 'Barents Sea', 1200000), ('Herring', 'Barents Sea', 800000); | What is the total biomass of cod in the Barents Sea? | SELECT location, SUM(biomass) FROM FishData WHERE species = 'Atlantic Cod' GROUP BY location; | gretelai_synthetic_text_to_sql |
CREATE TABLE member_details (member_id INT, gender VARCHAR(10), country VARCHAR(50), heart_rate INT); INSERT INTO member_details (member_id, gender, country, heart_rate) VALUES (1, 'Male', 'USA', 70), (2, 'Female', 'Canada', 80), (3, 'Male', 'Mexico', 65), (4, 'Female', 'Brazil', 75), (5, 'Male', 'Argentina', 78); | What is the average heart rate for male members from the USA? | SELECT AVG(heart_rate) FROM member_details WHERE gender = 'Male' AND country = 'USA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE lifelong_learning_registrations (id INT, event_id INT, name VARCHAR(50), registration_date DATE, enrollment INT); INSERT INTO lifelong_learning_registrations (id, event_id, name, registration_date, enrollment) VALUES (1, 1, 'Jane Doe', '2022-10-01', 250); | What is the ID and name of students who registered for lifelong learning events in the second half of 2022 and have an enrollment greater than 100? | SELECT id, name FROM lifelong_learning_registrations WHERE registration_date BETWEEN '2022-07-01' AND '2022-12-31' AND enrollment > 100; | gretelai_synthetic_text_to_sql |
CREATE TABLE dishes (dish_id INT PRIMARY KEY, dish_name VARCHAR(255), calories INT, cuisine_id INT, dietary_restrictions VARCHAR(255), FOREIGN KEY (cuisine_id) REFERENCES cuisine(cuisine_id)); | Determine the average calorie count of dishes with a 'Vegan' tag and their respective cuisine types. | SELECT c.cuisine_name, AVG(d.calories) FROM dishes d JOIN cuisine c ON d.cuisine_id = c.cuisine_id WHERE dietary_restrictions LIKE '%Vegan%' GROUP BY c.cuisine_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE recycling_centers (state VARCHAR(20), num_centers INT); | Create a view for recycling centers in each state. | CREATE VIEW state_recycling_centers AS SELECT state, COUNT(*) FROM recycling_centers GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE renewable_energy.building_energy_consumption (building VARCHAR(50), consumption FLOAT); INSERT INTO renewable_energy.building_energy_consumption (building, consumption) VALUES ('Solar Tower', 1234.5), ('Wind Farm', 2345.6), ('Hydro Plant', 3456.7); | What is the maximum energy consumption of a building in the 'renewable_energy' schema? | SELECT MAX(consumption) FROM renewable_energy.building_energy_consumption; | gretelai_synthetic_text_to_sql |
CREATE TABLE publications (id INT, title VARCHAR(50), journal VARCHAR(30)); INSERT INTO publications (id, title, journal) VALUES (1, 'A Study on Renewable Energy', 'Journal of Engineering'), (2, 'The Impact of Climate Change', 'Journal of Natural Sciences'); | Find the total number of publications in the 'Journal of Engineering' and 'Journal of Natural Sciences' | SELECT SUM(CASE WHEN journal IN ('Journal of Engineering', 'Journal of Natural Sciences') THEN 1 ELSE 0 END) FROM publications; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (id INT, name VARCHAR(255), price DECIMAL(10,2), is_organic BOOLEAN, supplier_id INT); | What is the average price of organic products supplied by each supplier? | SELECT supplier_id, AVG(price) FROM products WHERE is_organic = TRUE GROUP BY supplier_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artifact_Weights (id INT, artifact_name VARCHAR(50), artifact_type VARCHAR(50), weight INT); INSERT INTO Artifact_Weights (id, artifact_name, artifact_type, weight) VALUES (1, 'Artifact 1', 'Stone Tool', 100), (2, 'Artifact 2', 'Stone Tool', 150), (3, 'Artifact 3', 'Pottery', 50), (4, 'Artifact 4', 'Bone Tool', 25); | What is the total weight of all stone tools in the 'Artifact_Weights' table? | SELECT SUM(weight) FROM Artifact_Weights WHERE artifact_type = 'Stone Tool'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Concerts (id INT, country VARCHAR(50), revenue FLOAT); CREATE TABLE Streams (song_id INT, country VARCHAR(50), revenue FLOAT); | What is the total revenue for concerts and streams in France? | SELECT SUM(Concerts.revenue) + SUM(Streams.revenue) FROM Concerts INNER JOIN Streams ON Concerts.country = Streams.country WHERE Concerts.country = 'France'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Museums (id INT, name VARCHAR(50), type VARCHAR(50)); INSERT INTO Museums (id, name, type) VALUES (1, 'Metropolitan Museum', 'Art'), (2, 'Natural History Museum', 'Science'); CREATE TABLE ArtPieces (id INT, title VARCHAR(50), museumId INT, artType VARCHAR(50)); INSERT INTO ArtPieces (id, title, museumId, artType) VALUES (1, 'Mona Lisa', 1, 'Modern'), (2, 'Starry Night', 1, 'Modern'), (3, 'Dinosaur Fossil', 2, 'Ancient'); | Which museums have the highest number of modern art pieces? | SELECT Museums.name FROM Museums JOIN ArtPieces ON Museums.id = ArtPieces.museumId WHERE ArtPieces.artType = 'Modern' GROUP BY Museums.name ORDER BY COUNT(*) DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE fish_farms (id INT, name TEXT, location TEXT, dissolved_oxygen_level FLOAT); INSERT INTO fish_farms (id, name, location, dissolved_oxygen_level) VALUES (1, 'Farm A', 'Pacific Ocean', 6.5), (2, 'Farm B', 'Atlantic Ocean', 7.0), (3, 'Farm C', 'Atlantic Ocean', 7.5); | What is the maximum dissolved oxygen level (mg/L) for fish farms located in the Atlantic Ocean? | SELECT MAX(dissolved_oxygen_level) FROM fish_farms WHERE location = 'Atlantic Ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE network_investments(id INT, investment_date DATE, amount DECIMAL(10,2)); INSERT INTO network_investments(id, investment_date, amount) VALUES (1, '2020-01-01', 150000.00), (2, '2020-02-15', 120000.00), (3, '2020-04-01', 180000.00); | What is the total network investment in the first quarter of 2020? | SELECT SUM(amount) FROM network_investments WHERE investment_date BETWEEN '2020-01-01' AND '2020-03-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_health_workers (id INT, name VARCHAR(50), age INT, state VARCHAR(2)); INSERT INTO community_health_workers (id, name, age, state) VALUES (1, 'John Doe', 45, 'Texas'), (2, 'Jane Smith', 35, 'California'), (3, 'Alice Johnson', 60, 'California'), (4, 'Bob Brown', 50, 'New York'); | What is the name and age of the oldest community health worker in the database? | SELECT name, age FROM community_health_workers WHERE age = (SELECT MAX(age) FROM community_health_workers); | gretelai_synthetic_text_to_sql |
CREATE TABLE TeamStats (GameID INT, TeamID INT, HomeTeam VARCHAR(255), AwayTeam VARCHAR(255), HomeAttendance INT, AwayAttendance INT); INSERT INTO TeamStats (GameID, TeamID, HomeTeam, AwayTeam, HomeAttendance, AwayAttendance) VALUES (1, 1, 'Lakers', 'Celtics', 15000, 12000), (2, 2, 'Celtics', 'Bulls', 18000, 10000); | What are the average game attendance statistics for each team's home and away games? | SELECT ht.HomeTeam, AVG(HomeAttendance) as Avg_Home_Attendance, AVG(a.AwayAttendance) as Avg_Away_Attendance FROM TeamStats ht JOIN TeamStats a ON ht.AwayTeam = a.HomeTeam GROUP BY ht.HomeTeam; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_sequestration (id INT, forest_name VARCHAR(255), biome VARCHAR(255), managed_by_community BOOLEAN, total_carbon_tons FLOAT); | What is the total carbon sequestration, in metric tons, of all forests in the temperate biome that are managed by indigenous communities? | SELECT SUM(total_carbon_tons) FROM community_sequestration WHERE biome = 'temperate' AND managed_by_community = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE Customers (CustomerID INT, IsSustainablePurchaser BOOLEAN); INSERT INTO Customers (CustomerID, IsSustainablePurchaser) VALUES (1, TRUE), (2, FALSE), (3, TRUE), (4, TRUE), (5, FALSE); CREATE TABLE ClothingItems (ItemID INT, CustomerID INT, IsSustainable BOOLEAN); INSERT INTO ClothingItems (ItemID, CustomerID, IsSustainable) VALUES (101, 1, TRUE), (102, 1, TRUE), (103, 2, FALSE), (104, 3, TRUE), (105, 4, FALSE), (106, 5, FALSE), (107, 5, TRUE); | Find the number of unique customers who purchased sustainable and non-sustainable clothing items. | SELECT COUNT(DISTINCT CustomerID) FROM Customers C INNER JOIN ClothingItems I ON C.CustomerID = I.CustomerID; | gretelai_synthetic_text_to_sql |
CREATE TABLE Patients (PatientID INT, Age INT, Gender VARCHAR(10), Diagnosis VARCHAR(20), Location VARCHAR(20)); INSERT INTO Patients (PatientID, Age, Gender, Diagnosis, Location) VALUES (1, 35, 'Male', 'Asthma', 'Texas'); INSERT INTO Patients (PatientID, Age, Gender, Diagnosis, Location) VALUES (2, 42, 'Female', 'Asthma', 'Texas'); INSERT INTO Patients (PatientID, Age, Gender, Diagnosis, Location) VALUES (3, 50, 'Male', 'Diabetes', 'Urban'); INSERT INTO Patients (PatientID, Age, Gender, Diagnosis, Location) VALUES (4, 60, 'Female', 'Hypertension', 'Rural'); INSERT INTO Patients (PatientID, Age, Gender, Diagnosis, Location) VALUES (5, 70, 'Male', 'Arthritis', 'Urban'); | List the number of patients diagnosed with Arthritis by gender. | SELECT Gender, COUNT(*) FROM Patients WHERE Diagnosis = 'Arthritis' GROUP BY Gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE donations (id INT, donor_name TEXT, campaign TEXT, amount INT, donation_date DATE); INSERT INTO donations (id, donor_name, campaign, amount, donation_date) VALUES (1, 'John Doe', 'Healthcare for All', 50, '2021-01-01'); INSERT INTO donations (id, donor_name, campaign, amount, donation_date) VALUES (2, 'Jane Smith', 'Healthcare for All', 150, '2021-03-12'); | What is the maximum donation amount received for the 'Healthcare for All' campaign? | SELECT MAX(amount) FROM donations WHERE campaign = 'Healthcare for All'; | gretelai_synthetic_text_to_sql |
CREATE TABLE shariah_compliant_lending (bank_name TEXT, activity_name TEXT, activity_date DATE); INSERT INTO shariah_compliant_lending (bank_name, activity_name, activity_date) VALUES ('EthicalBank', 'Islamic Home Financing', '2021-02-15'), ('EthicalBank', 'Halal Business Loans', '2021-05-10'), ('EthicalBank', 'Islamic Car Financing', '2021-12-28'); | List all Shariah-compliant lending activities by EthicalBank in 2021. | SELECT * FROM shariah_compliant_lending WHERE bank_name = 'EthicalBank' AND activity_date BETWEEN '2021-01-01' AND '2021-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ProductTypes (ProductTypeID INT, ProductType VARCHAR(100)); CREATE TABLE DispensaryTransactions (TransactionID INT, ProductTypeID INT, QuantitySold INT, TransactionDate DATE, DispensaryID INT); | What is the total quantity of each product type sold by a specific dispensary in Colorado in March 2021? | SELECT PT.ProductType, SUM(DT.QuantitySold) as TotalQuantitySold FROM ProductTypes PT JOIN DispensaryTransactions DT ON PT.ProductTypeID = DT.ProductTypeID WHERE DT.TransactionDate BETWEEN '2021-03-01' AND '2021-03-31' AND DT.DispensaryID = 2001 GROUP BY PT.ProductType; | gretelai_synthetic_text_to_sql |
CREATE TABLE teams (team_id INT, team_name VARCHAR(255), sport VARCHAR(255)); INSERT INTO teams (team_id, team_name, sport) VALUES (1, 'Knicks', 'Basketball'), (2, 'Lakers', 'Basketball'), (3, 'Chelsea', 'Soccer'); CREATE TABLE games (team_id INT, sport VARCHAR(255), game_id INT); INSERT INTO games (team_id, sport, game_id) VALUES (1, 'Basketball', 101), (1, 'Basketball', 102), (2, 'Basketball', 103), (3, 'Soccer', 104); | What is the total number of basketball games played by each team? | SELECT t.team_name, COUNT(g.game_id) games_played FROM teams t JOIN games g ON t.team_id = g.team_id WHERE t.sport = 'Basketball' GROUP BY t.team_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE research_vessels ( id INT PRIMARY KEY, name VARCHAR(255), year INT, type VARCHAR(255), length REAL ); INSERT INTO research_vessels (id, name, year, type, length) VALUES (1, 'Oceania', 2010, 'Research', 120.5), (2, 'Neptune', 2016, 'Fishing', 80.3), (3, 'Poseidon', 2018, 'Research', 135.2); | What is the average length of research vessels purchased after 2015, grouped by type and excluding types with only one vessel? | SELECT type, AVG(length) FROM research_vessels WHERE year > 2015 GROUP BY type HAVING COUNT(*) > 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Deliveries (delivery_id INT, delivery_date DATE, item_id INT, quantity INT, country TEXT); CREATE TABLE Items (item_id INT, item_name TEXT); | Calculate the total number of items delivered to each country in Africa in 2022. | SELECT Deliveries.country, SUM(Deliveries.quantity) FROM Deliveries INNER JOIN (SELECT * FROM Regions WHERE Regions.region = 'Africa') AS Reg ON Deliveries.country = Reg.country_name GROUP BY Deliveries.country; | gretelai_synthetic_text_to_sql |
CREATE TABLE expenditures (destination_country VARCHAR(50), visitor_country VARCHAR(50), avg_daily_expenditure FLOAT); INSERT INTO expenditures (destination_country, visitor_country, avg_daily_expenditure) VALUES ('New Zealand', 'Europe', 150.0); | What is the average expenditure per day for tourists visiting New Zealand from Europe? | SELECT avg_daily_expenditure FROM expenditures WHERE destination_country = 'New Zealand' AND visitor_country = 'Europe'; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, product_name VARCHAR(50), price DECIMAL(5,2), country_of_manufacture VARCHAR(50), is_made_of_recycled_materials BOOLEAN); INSERT INTO products (product_id, product_name, price, country_of_manufacture, is_made_of_recycled_materials) VALUES (1, 'T-Shirt', 20.99, 'USA', TRUE), (2, 'Jeans', 55.99, 'USA', FALSE), (3, 'Sneakers', 79.99, 'China', FALSE), (4, 'Backpack', 49.99, 'USA', TRUE); | What is the average price of products manufactured in the US that are made of recycled materials? | SELECT AVG(price) FROM products WHERE country_of_manufacture = 'USA' AND is_made_of_recycled_materials = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE mining_operations (id INT, location VARCHAR(50)); INSERT INTO mining_operations (id, location) VALUES (1, 'United States - Mine A'), (2, 'United States - Mine B'), (3, 'United States - Mine C'); CREATE TABLE employees (id INT, age INT, position VARCHAR(50), operation_id INT); INSERT INTO employees (id, age, position, operation_id) VALUES (1, 35, 'Engineer', 1), (2, 42, 'Manager', 1), (3, 28, 'Operator', 2), (4, 31, 'Supervisor', 3); | How many employees work at each mining operation in the United States? | SELECT mo.location, COUNT(e.id) FROM employees e INNER JOIN mining_operations mo ON e.operation_id = mo.id GROUP BY mo.location; | gretelai_synthetic_text_to_sql |
CREATE TABLE countries (id INT, name VARCHAR(50)); INSERT INTO countries (id, name) VALUES (1, 'USA'), (2, 'Canada'), (3, 'Mexico'); | What is the total number of posts and users for each country in the social_media schema? | SELECT c.name AS country, COUNT(DISTINCT p.user_id) AS total_users, COUNT(p.id) AS total_posts FROM posts p JOIN countries c ON p.country_id = c.id GROUP BY c.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE accessible_health_tech (id INT, project_name VARCHAR(255), funding_quarter VARCHAR(10), budget DECIMAL(10,2)); INSERT INTO accessible_health_tech (id, project_name, funding_quarter, budget) VALUES (1, 'Telemedicine for Disabled', 'Q2 2022', 12000), (2, 'Accessible Health Apps', 'Q1 2022', 18000); | What is the total budget allocated for accessible health technology projects in Q2 2022? | SELECT SUM(budget) FROM accessible_health_tech WHERE funding_quarter = 'Q2 2022' AND project_name LIKE '%Accessible Health%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists countries (id INT PRIMARY KEY, name VARCHAR(50), continent VARCHAR(50)); INSERT INTO countries (id, name, continent) VALUES (1, 'Australia', 'Oceania'); INSERT INTO countries (id, name, continent) VALUES (2, 'New Zealand', 'Oceania'); CREATE TABLE if not exists refugee_camps (id INT PRIMARY KEY, name VARCHAR(50), country_id INT, num_refugees INT); INSERT INTO refugee_camps (id, name, country_id, num_refugees) VALUES (1, 'Camp A', 1, 500); INSERT INTO refugee_camps (id, name, country_id, num_refugees) VALUES (2, 'Camp B', 1, 700); INSERT INTO refugee_camps (id, name, country_id, num_refugees) VALUES (3, 'Camp C', 2, 900); | How many refugees are there in total for each country in Oceania? | SELECT c.name, SUM(rc.num_refugees) FROM countries c JOIN refugee_camps rc ON c.id = rc.country_id WHERE c.continent = 'Oceania' GROUP BY rc.country_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Volunteers (VolunteerID INT, VolunteerName TEXT, ServiceHours INT, City TEXT); INSERT INTO Volunteers (VolunteerID, VolunteerName, ServiceHours, City) VALUES (1, 'Alice Johnson', 50, 'Los Angeles'); INSERT INTO Volunteers (VolunteerID, VolunteerName, ServiceHours, City) VALUES (2, 'Bob Brown', 75, 'San Francisco'); | Which volunteer provided the most hours of service in the city of Los Angeles? | SELECT VolunteerName, MAX(ServiceHours) FROM Volunteers WHERE City = 'Los Angeles'; | gretelai_synthetic_text_to_sql |
CREATE TABLE brand_material_ratings (brand VARCHAR(50), material VARCHAR(50), rating INT); INSERT INTO brand_material_ratings (brand, material, rating) VALUES ('Brand A', 'organic cotton', 5), ('Brand A', 'recycled polyester', 4), ('Brand B', 'organic cotton', 5), ('Brand B', 'hemp', 3); | Update the ethical fashion database to change the rating for 'recycled polyester' to 5 for 'Brand C'. | UPDATE brand_material_ratings SET rating = 5 WHERE brand = 'Brand C' AND material = 'recycled polyester'; | gretelai_synthetic_text_to_sql |
CREATE TABLE vr_adopters (id INT, name VARCHAR(50), country VARCHAR(50), favorite_genre VARCHAR(50)); INSERT INTO vr_adopters (id, name, country, favorite_genre) VALUES (1, 'Alice Lee', 'South Korea', 'RPG'); INSERT INTO vr_adopters (id, name, country, favorite_genre) VALUES (2, 'Bob Brown', 'Japan', 'Shooter'); | List all virtual reality (VR) technology adopters from Asia and their favorite game genres. | SELECT vr_adopters.country, vr_adopters.favorite_genre FROM vr_adopters WHERE vr_adopters.country IN ('South Korea', 'Japan', 'China', 'India') AND vr_adopters.favorite_genre IS NOT NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE farmers (id INT, name VARCHAR(255), state VARCHAR(255), phone VARCHAR(255)); | Insert a new record into the 'farmers' table for a farmer named 'Jamila Jackson' from 'New York', with a phone number '555-123-4567'. | INSERT INTO farmers (name, state, phone) VALUES ('Jamila Jackson', 'New York', '555-123-4567'); | gretelai_synthetic_text_to_sql |
CREATE TABLE microfinance_institutions (id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255)); CREATE TABLE islamic_microfinance_institutions (id INT PRIMARY KEY, name VARCHAR(255), microfinance_institution_id INT, FOREIGN KEY (microfinance_institution_id) REFERENCES microfinance_institutions(id)) | What are the names of all Islamic microfinance institutions in Indonesia? | SELECT i.name FROM microfinance_institutions m INNER JOIN islamic_microfinance_institutions i ON m.id = i.microfinance_institution_id WHERE m.country = 'Indonesia' | gretelai_synthetic_text_to_sql |
CREATE TABLE habitats (id INT PRIMARY KEY, name VARCHAR(50), size INT); INSERT INTO habitats (id, name, size) VALUES (1, 'Africa', 100000), (2, 'Asia', 200000), (3, 'South America', 150000); | What is the maximum population in the 'habitats' table? | SELECT MAX(size) FROM habitats; | gretelai_synthetic_text_to_sql |
CREATE TABLE salaries (id INT, department VARCHAR(20), salary DECIMAL(10, 2)); INSERT INTO salaries (id, department, salary) VALUES (1, 'geology', 50000.00), (2, 'mining', 45000.00), (3, 'administration', 60000.00); | What is the minimum salary in the 'geology' department? | SELECT MIN(salary) FROM salaries WHERE department = 'geology'; | 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.