context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE incidents (category VARCHAR(50), sector VARCHAR(20)); INSERT INTO incidents (category, sector) VALUES ('Malware', 'Technology'), ('Phishing', 'Technology'); | Find the number of security incidents and their corresponding categories for the technology sector, excluding incidents related to phishing. | SELECT category, COUNT(*) as incident_count FROM incidents WHERE sector = 'Technology' AND category != 'Phishing' GROUP BY category; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotels_tokyo (hotel_id INT, hotel_name TEXT, ai_adoption BOOLEAN); INSERT INTO hotels_tokyo (hotel_id, hotel_name, ai_adoption) VALUES (1, 'Hotel Splendid', true), (2, 'Hotel Excelsior', false), (3, 'Hotel Grande', true); | What is the market share of hotels in Tokyo that have adopted hospitality AI, by total number of hotels? | SELECT (COUNT(*) FILTER (WHERE ai_adoption = true)) * 100.0 / COUNT(*) FROM hotels_tokyo; | gretelai_synthetic_text_to_sql |
CREATE TABLE DispensarySales (id INT, state VARCHAR(50), year INT, revenue FLOAT); INSERT INTO DispensarySales (id, state, year, revenue) VALUES (1, 'California', 2020, 1200000.0), (2, 'California', 2019, 900000.0), (3, 'Colorado', 2020, 800000.0), (4, 'Colorado', 2019, 600000.0); | What was the total revenue for the state of California in the year 2020 from dispensary sales? | SELECT SUM(revenue) FROM DispensarySales WHERE state = 'California' AND year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE Museums (name VARCHAR(255), country VARCHAR(255), visitors_per_month DECIMAL(5,2)); | Find the average number of visitors per month for all museums in Canada. | SELECT AVG(visitors_per_month) FROM Museums WHERE country = 'Canada'; | gretelai_synthetic_text_to_sql |
CREATE TABLE drought_impact (location VARCHAR(255), year INT, severity VARCHAR(255)); | Update the drought_impact table to reflect the new drought severity | UPDATE drought_impact SET severity = 'Severe' WHERE location = 'City C' AND year = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotel (hotel_id INT, name TEXT, city TEXT, country TEXT, is_eco_friendly BOOLEAN); INSERT INTO hotel (hotel_id, name, city, country, is_eco_friendly) VALUES (1, 'Green Hotel London', 'London', 'England', true); | What is the total number of eco-friendly hotels in London? | SELECT COUNT(*) FROM hotel WHERE city = 'London' AND is_eco_friendly = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE therapists (therapist_id INT, state TEXT); INSERT INTO therapists (therapist_id, state) VALUES (1, 'New York'), (2, 'New York'), (3, 'Texas'); CREATE TABLE therapist_patients (therapist_id INT, patient_id INT); INSERT INTO therapist_patients (therapist_id, patient_id) VALUES (1, 1), (1, 2), (1, 3), (2, 4),... | How many patients were treated by each therapist in New York? | SELECT therapists.state, therapists.therapist_id, COUNT(therapist_patients.patient_id) AS patient_count FROM therapists JOIN therapist_patients ON therapists.therapist_id = therapist_patients.therapist_id WHERE therapists.state = 'New York' GROUP BY therapists.therapist_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Members (MemberID INT, Community VARCHAR(20), Region VARCHAR(20)); INSERT INTO Members (MemberID, Community, Region) VALUES (11, 'LGBTQ+', 'Northeast'); CREATE TABLE Transactions (TransactionID INT, MemberID INT, Service VARCHAR(20), Product VARCHAR(20), Amount DECIMAL(5,2)); INSERT INTO Transactions (Tran... | Show the total revenue generated by members from the LGBTQ+ community in the last month and their average spending on wellness products. | SELECT SUM(CASE WHEN Transactions.Product IS NOT NULL THEN Transactions.Amount ELSE 0 END) AS TotalRevenue, AVG(CASE WHEN Transactions.Product = 'Wellness Product' THEN Transactions.Amount ELSE 0 END) AS AverageSpending FROM Members INNER JOIN Transactions ON Members.MemberID = Transactions.MemberID WHERE Members.Commu... | gretelai_synthetic_text_to_sql |
CREATE TABLE Policies (policy_id INT, policy_name VARCHAR(50), policy_date DATE, policy_category VARCHAR(50)); | Which policies have been updated in the last month and are related to password complexity? | SELECT policy_id, policy_name FROM Policies WHERE policy_category = 'password complexity' AND policy_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) AND CURRENT_DATE; | gretelai_synthetic_text_to_sql |
CREATE TABLE authors (id INT, name VARCHAR(50), gender VARCHAR(10)); INSERT INTO authors (id, name, gender) VALUES (1, 'Alice', 'Female'), (2, 'Bob', 'Male'), (3, 'Alex', 'Non-binary'); | What is the most common author gender in the 'authors' table? | SELECT gender, COUNT(*) FROM authors GROUP BY gender ORDER BY COUNT(*) DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE carbon_offsets (project_id INT, project_name TEXT, offset_metric_tons FLOAT); INSERT INTO carbon_offsets (project_id, project_name, offset_metric_tons) VALUES (1, 'Smart City A', 1500), (2, 'Smart City B', 2000); | What is the average carbon offset (in metric tons) per smart city project? | SELECT AVG(offset_metric_tons) FROM carbon_offsets; | gretelai_synthetic_text_to_sql |
CREATE TABLE infectious_diseases (id INT, case_number INT, disease_type TEXT, state TEXT); INSERT INTO infectious_diseases (id, case_number, disease_type, state) VALUES (1, 123, 'Flu', 'Alaska'); INSERT INTO infectious_diseases (id, case_number, disease_type, state) VALUES (2, 456, 'COVID-19', 'Alaska'); | What is the most common type of infectious disease in Alaska? | SELECT disease_type, COUNT(*) FROM infectious_diseases WHERE state = 'Alaska' GROUP BY disease_type ORDER BY COUNT(*) DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE sustainable_sourcing (restaurant_id INT, organic_produce BOOLEAN); | Update the organic_produce to false for record with restaurant_id 123 in the sustainable_sourcing table | UPDATE sustainable_sourcing SET organic_produce = false WHERE restaurant_id = 123; | gretelai_synthetic_text_to_sql |
CREATE TABLE deep_sea_expeditions (org_name TEXT, expedition_id INTEGER); INSERT INTO deep_sea_expeditions (org_name, expedition_id) VALUES ('National Oceanic and Atmospheric Administration', 123), ('Woods Hole Oceanographic Institution', 456), ('National Geographic Society', 789); | What is the total number of deep-sea expeditions funded by each organization? | SELECT org_name, COUNT(expedition_id) as total_expeditions FROM deep_sea_expeditions GROUP BY org_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE TourismProviders (provider_id INT, provider_name TEXT, country TEXT); INSERT INTO TourismProviders (provider_id, provider_name, country) VALUES (1, 'Spain Virtual Tours', 'Spain'); INSERT INTO TourismProviders (provider_id, provider_name, country) VALUES (2, 'Global Spain Tours', 'Spain'); CREATE TABLE Vir... | What is the average annual revenue generated by virtual tourism providers in Spain? | SELECT AVG(annual_revenue) FROM TourismProviders JOIN VirtualTourRevenue ON TourismProviders.provider_id = VirtualTourRevenue.provider_id WHERE country = 'Spain'; | gretelai_synthetic_text_to_sql |
CREATE TABLE SmartCityTechnologyAdoption (id INT, city VARCHAR(50), technology VARCHAR(50)); | Which smart city technologies are adopted in 'CityA' in the 'SmartCityTechnologyAdoption' table? | SELECT technology FROM SmartCityTechnologyAdoption WHERE city = 'CityA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Garments(id INT, name VARCHAR(100), quantity INT, category VARCHAR(50)); INSERT INTO Garments(id, name, quantity, category) VALUES (1, 'Dress', 20, 'Women'); INSERT INTO Garments(id, name, quantity, category) VALUES (2, 'Shirt', 15, 'Men'); | Show the total quantity of unsold garments by category. | SELECT category, SUM(quantity) FROM Garments WHERE quantity > 0 GROUP BY category; | gretelai_synthetic_text_to_sql |
CREATE TABLE farmers (farmer_id INT PRIMARY KEY, name VARCHAR(255), age INT, location VARCHAR(255)); | What is the average age of farmers? | SELECT AVG(age) FROM farmers; | gretelai_synthetic_text_to_sql |
CREATE TABLE waste_generation (state VARCHAR(2), generation INT); INSERT INTO waste_generation (state, generation) VALUES ('CA', 5000000), ('NY', 4000000), ('NJ', 3000000); | What is the total waste generation in the state of New Jersey? | SELECT SUM(generation) FROM waste_generation WHERE state = 'NJ'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Maintenance (id INT, equipment VARCHAR(255), date DATE, labor INT, parts INT); INSERT INTO Maintenance (id, equipment, date, labor, parts) VALUES (1, 'Tank', '2020-01-05', 500, 200), (2, 'Humvee', '2020-01-10', 300, 150), (3, 'Helicopter', '2020-02-15', 700, 300), (4, 'Airplane', '2020-03-20', 800, 400); | Update the labor cost for Helicopter maintenance on Feb 15, 2020 to 750. | UPDATE Maintenance SET labor = 750 WHERE equipment = 'Helicopter' AND date = '2020-02-15'; | gretelai_synthetic_text_to_sql |
CREATE TABLE wastewater_treatment_india(id INT, city VARCHAR(50), treatment_type VARCHAR(50), capacity INT, efficiency FLOAT); INSERT INTO wastewater_treatment_india(id, city, treatment_type, capacity, efficiency) VALUES (1, 'Mumbai', 'Screening', 1200, 0.92); | What is the total wastewater treatment capacity for each city in India? | SELECT city, SUM(capacity) as total_capacity FROM wastewater_treatment_india GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE TechAccessibilitySpecs(role VARCHAR(255), region VARCHAR(255), salary DECIMAL(10,2));INSERT INTO TechAccessibilitySpecs(role, region, salary) VALUES('Tech Accessibility Specialist', 'North America', 80000.00), ('AI Ethics Expert', 'Europe', 90000.00), ('Tech Accessibility Specialist', 'Europe', 95000.00), ... | What is the average annual salary for tech accessibility specialists in North America and Europe? | SELECT AVG(salary) FROM TechAccessibilitySpecs WHERE role = 'Tech Accessibility Specialist' AND region IN ('North America', 'Europe'); | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (id INT, state VARCHAR(50), quarter INT, revenue FLOAT); INSERT INTO sales (id, state, quarter, revenue) VALUES (1, 'California', 1, 25000.0), (2, 'California', 2, 30000.0), (3, 'Colorado', 1, 20000.0), (4, 'Colorado', 2, 22000.0); | What was the maximum revenue for the state of California in the first quarter of 2022? | SELECT MAX(revenue) FROM sales WHERE state = 'California' AND quarter = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE property_prices (property_id INT, city VARCHAR(50), price INT); CREATE TABLE sustainable_urbanism (property_id INT, sustainable_project BOOLEAN); CREATE TABLE co_ownership (property_id INT, co_owner_count INT); INSERT INTO property_prices (property_id, city, price) VALUES (1, 'Boston', 800000), (2, 'Portla... | Find the minimum price of a property in a sustainable urbanism project in Boston with at least 2 co-owners. | SELECT MIN(price) FROM property_prices p JOIN sustainable_urbanism s ON p.property_id = s.property_id JOIN co_ownership c ON p.property_id = c.property_id WHERE p.city = 'Boston' AND c.co_owner_count > 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE inventory (inventory_id INT PRIMARY KEY, ingredient_name VARCHAR(255), quantity INT, reorder_threshold INT); CREATE TABLE menu_ingredients (menu_id INT, ingredient_name VARCHAR(255), quantity INT, PRIMARY KEY (menu_id, ingredient_name), FOREIGN KEY (ingredient_name) REFERENCES inventory(ingredient_name)); | Update inventory records for ingredients used in the 'Veggie Delight' menu item to decrease their quantity by 5 | UPDATE inventory SET quantity = quantity - 5 WHERE inventory.ingredient_name IN (SELECT menu_ingredients.ingredient_name FROM menu_ingredients WHERE menu_ingredients.menu_id = (SELECT menu_id FROM menu_items WHERE item_name = 'Veggie Delight')); | gretelai_synthetic_text_to_sql |
CREATE TABLE faculty_education (id INT, name VARCHAR(50), department VARCHAR(50), tenure_status VARCHAR(50), num_publications INT); INSERT INTO faculty_education (id, name, department, tenure_status, num_publications) VALUES (1, 'Dana', 'College of Education', 'Not Tenured', 7), (2, 'Ella', 'College of Education', 'Ten... | What is the maximum number of publications for faculty members in the College of Education who are not tenured? | SELECT MAX(num_publications) FROM faculty_education WHERE department = 'College of Education' AND tenure_status = 'Not Tenured'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Programs (id INT, program_name VARCHAR(50), total_volunteers INT); CREATE TABLE VolunteerEvents (id INT, program_id INT, event_date DATE, total_volunteers INT); | List the total number of volunteers for each program in 2023, ordered by the total number of volunteers in descending order. | SELECT Programs.program_name, SUM(VolunteerEvents.total_volunteers) AS total_volunteers_2023 FROM Programs INNER JOIN VolunteerEvents ON Programs.id = VolunteerEvents.program_id WHERE VolunteerEvents.event_date BETWEEN '2023-01-01' AND '2023-12-31' GROUP BY Programs.program_name ORDER BY total_volunteers_2023 DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE animal_population (id INT, animal_name VARCHAR(50), population INT); CREATE TABLE protected_species (id INT, species_name VARCHAR(50)); INSERT INTO animal_population VALUES (1, 'Elephant', 1000); | What are the names of animals in 'animal_population' table that are not present in 'protected_species' table? | SELECT DISTINCT ap.animal_name FROM animal_population ap LEFT JOIN protected_species ps ON ap.animal_name = ps.species_name WHERE ps.species_name IS NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE VehicleTypes (VehicleTypeID INT, VehicleType VARCHAR(50)); INSERT INTO VehicleTypes (VehicleTypeID, VehicleType) VALUES (1, 'Bus'), (2, 'Tram'), (3, 'Subway'); CREATE TABLE VehicleMaintenance (MaintenanceID INT, VehicleTypeID INT, Cost DECIMAL(5,2), MaintenanceDate DATE); INSERT INTO VehicleMaintenance (Ma... | What is the total cost of maintenance for each type of vehicle in the past month? | SELECT VehicleType, SUM(Cost) FROM VehicleMaintenance INNER JOIN VehicleTypes ON VehicleMaintenance.VehicleTypeID = VehicleTypes.VehicleTypeID WHERE MaintenanceDate >= DATEADD(month, -1, GETDATE()) GROUP BY VehicleType; | gretelai_synthetic_text_to_sql |
CREATE TABLE sustainability (id INT, vendor VARCHAR(50), recycling_program BOOLEAN, waste_reduction BOOLEAN); INSERT INTO sustainability (id, vendor, recycling_program, waste_reduction) VALUES (4, 'Local Produce', true, true), (5, 'Farm Fresh', false, true), (6, 'Organic Harvest', true, false); | Which vendors have a recycling program in place and are reducing waste? | SELECT vendor, CASE WHEN recycling_program THEN 'Yes' ELSE 'No' END as recycling_program, CASE WHEN waste_reduction THEN 'Yes' ELSE 'No' END as waste_reduction FROM sustainability WHERE recycling_program = 'True' AND waste_reduction = 'True'; | gretelai_synthetic_text_to_sql |
CREATE TABLE appliances (id INT, name VARCHAR(50), manufacturer VARCHAR(50), energy_rating FLOAT, created_at TIMESTAMP); | What are the energy efficiency ratings for appliances in the appliances table produced by a specific manufacturer? | SELECT name, energy_rating FROM appliances WHERE manufacturer = 'XYZ' ORDER BY energy_rating DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE DisabilitySupportPrograms (region VARCHAR(20), budget DECIMAL(5,2)); INSERT INTO DisabilitySupportPrograms (region, budget) VALUES ('East Coast', 150000.00), ('West Coast', 200000.00), ('Midwest', 120000.00), ('South', 180000.00); | What is the minimum budget allocated for disability support programs in the 'Midwest' region? | SELECT MIN(budget) FROM DisabilitySupportPrograms WHERE region = 'Midwest'; | gretelai_synthetic_text_to_sql |
CREATE TABLE pacific_ocean_mammals (id INT, date DATE, marine_mammals_spotted INT); | What is the maximum number of marine mammals spotted in a single day in the Pacific Ocean? | SELECT MAX(marine_mammals_spotted) FROM pacific_ocean_mammals; | gretelai_synthetic_text_to_sql |
CREATE TABLE state_certifications (state VARCHAR(20), certifications INT); INSERT INTO state_certifications (state, certifications) VALUES ('California', 500), ('Texas', 300), ('Florida', 400); | Show the top 2 states with the most green building certifications. | SELECT state, certifications FROM (SELECT state, certifications, RANK() OVER (ORDER BY certifications DESC) as rank FROM state_certifications) AS subquery WHERE rank <= 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE high_speed_trains (train_id INT, trip_start_time TIMESTAMP, trip_end_time TIMESTAMP, trip_distance FLOAT, country VARCHAR(50)); | What is the average speed of high-speed trains in Japan? | SELECT AVG(trip_distance / TIMESTAMP_DIFF(trip_end_time, trip_start_time, MINUTE)) as avg_speed FROM high_speed_trains WHERE country = 'Japan'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Universities (UniversityID int, UniversityName varchar(255)); CREATE TABLE ResearchGrants (GrantID int, UniversityID int, Amount int); | What is the total research grant amount awarded to each university, ordered from highest to lowest? | SELECT UniversityName, SUM(Amount) as TotalGrantAmount FROM ResearchGrants rg JOIN Universities u ON rg.UniversityID = u.UniversityID GROUP BY UniversityName ORDER BY TotalGrantAmount DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE fishing_vessels (name VARCHAR(50), region VARCHAR(20), age INTEGER); INSERT INTO fishing_vessels (name, region, age) VALUES ('Vessel A', 'Indian Ocean', 15), ('Vessel B', 'Indian Ocean', 25), ('Vessel C', 'Atlantic', 10); | What is the total number of fishing vessels in the 'Indian Ocean' that are over 20 years old?' | SELECT COUNT(*) FROM fishing_vessels WHERE region = 'Indian Ocean' AND age > 20; | gretelai_synthetic_text_to_sql |
CREATE TABLE wells (well_id INT, country VARCHAR(50)); INSERT INTO wells (well_id, country) VALUES (1, 'Canada'), (2, 'USA'), (3, 'Norway'); | Find the number of wells drilled in each country and the total. | SELECT country, COUNT(*) as num_wells FROM wells GROUP BY country UNION ALL SELECT 'Total', COUNT(*) FROM wells; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteers (id INT, name VARCHAR(50), volunteer_hours INT, volunteer_date DATE); INSERT INTO volunteers (id, name, volunteer_hours, volunteer_date) VALUES (1, 'John Doe', 10, '2022-01-05'), (2, 'Jane Smith', 15, '2022-01-05'), (3, 'Bob Johnson', 8, '2022-01-05'), (4, 'John Doe', 12, '2022-02-10'), (5, 'Jan... | Identify the top 5 volunteers with the most volunteer hours in 2022? | SELECT name, SUM(volunteer_hours) as total_hours FROM volunteers WHERE volunteer_date >= '2022-01-01' GROUP BY name ORDER BY total_hours DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE Digital_Divide (region VARCHAR(50), index INT); INSERT INTO Digital_Divide (region, index) VALUES ('Africa', 60), ('Asia', 50), ('South America', 40), ('Europe', 30), ('North America', 20); | What is the average digital divide index for each region? | SELECT region, AVG(index) as avg_index FROM Digital_Divide GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE public.infectious_diseases (id SERIAL PRIMARY KEY, country TEXT, disease TEXT, year INT, cases INT); INSERT INTO public.infectious_diseases (country, disease, year, cases) VALUES ('India', 'Measles', 2020, 3456), ('China', 'Hepatitis A', 2020, 5678), ('Indonesia', 'Measles', 2020, 789); | How many cases of Measles and Hepatitis A were reported in Asian countries in 2020? | SELECT country, disease, SUM(cases) FILTER (WHERE disease IN ('Measles', 'Hepatitis A') AND year = 2020) AS total_cases FROM public.infectious_diseases GROUP BY country, disease; | gretelai_synthetic_text_to_sql |
CREATE TABLE peacekeeping_operations (operation_id INT PRIMARY KEY, operation_name VARCHAR(50), country VARCHAR(50), operation_year INT); | Add a new record to the "peacekeeping_operations" table for "Operation Restore Hope" in Somalia during 1993 | INSERT INTO peacekeeping_operations (operation_id, operation_name, country, operation_year) VALUES (1, 'Operation Restore Hope', 'Somalia', 1993); | gretelai_synthetic_text_to_sql |
CREATE TABLE solar_energy (id INT, region VARCHAR(50), year INT, production FLOAT); | Update the solar energy production record for New South Wales in 2025 to 15000 MWh | UPDATE solar_energy SET production = 15000 WHERE region = 'New South Wales' AND year = 2025; | gretelai_synthetic_text_to_sql |
CREATE TABLE RetailSales (country VARCHAR(50), TotalSales DECIMAL(10,2)); INSERT INTO RetailSales (country, TotalSales) VALUES ('USA', 12500.00), ('Canada', 7000.00), ('USA', 3000.00), ('Brazil', 9000.00); | Calculate the total retail sales for each country, excluding any duplicates based on the 'country' column in the 'RetailSales' table. | SELECT country, SUM(TotalSales) FROM (SELECT DISTINCT country, TotalSales FROM RetailSales) AS A GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotels (hotel_id INT, hotel_name TEXT, region TEXT); CREATE TABLE ai_solutions (solution_id INT, hotel_id INT, implemented_date DATE); CREATE TABLE virtual_tours (tour_id INT, hotel_id INT, engagement_score INT); INSERT INTO hotels (hotel_id, hotel_name, region) VALUES (1, 'Luxury Resort', 'APAC'); INSERT ... | How many virtual tours have been engaged with for hotels that have implemented AI-powered solutions? | SELECT COUNT(DISTINCT vt.hotel_id) AS total_tours_engaged FROM virtual_tours vt INNER JOIN hotels h ON vt.hotel_id = h.hotel_id INNER JOIN ai_solutions ai ON h.hotel_id = ai.hotel_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (id INT, user_id INT, country VARCHAR(50), amount DECIMAL(10, 2), donation_date DATE); INSERT INTO Donations (id, user_id, country, amount, donation_date) VALUES (1, 101, 'United States', 50.00, '2022-01-02'); INSERT INTO Donations (id, user_id, country, amount, donation_date) VALUES (2, 102, 'Ca... | What was the total amount donated in Mexico in Q3 2021? | SELECT SUM(amount) FROM Donations WHERE country = 'Mexico' AND donation_date BETWEEN '2021-07-01' AND '2021-09-30'; | gretelai_synthetic_text_to_sql |
CREATE TABLE underwater_caves (cave_name TEXT, max_depth_m INT); INSERT INTO underwater_caves (cave_name, max_depth_m) VALUES ('Hranice Abyss', 4040), ('Wakulla Springs', 295), ('Nohoch Nah Chich', 134); | Identify the deepest underwater cave in the world. | SELECT cave_name FROM underwater_caves ORDER BY max_depth_m DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE facilities (id INT, name VARCHAR(50), location VARCHAR(20), type VARCHAR(20)); | How many mental health facilities are there in urban areas of the US? | SELECT COUNT(*) FROM facilities WHERE location LIKE '%US%' AND location LIKE '%urban%' AND type = 'mental health'; | gretelai_synthetic_text_to_sql |
CREATE TABLE restaurants (id INT, name TEXT, city TEXT, state TEXT, menu_price DECIMAL); INSERT INTO restaurants (id, name, city, state, menu_price) VALUES (1, 'Restaurant A', 'Chicago', 'IL', 40.00), (2, 'Restaurant B', 'Chicago', 'IL', 35.00), (3, 'Restaurant C', 'St. Louis', 'MO', 30.00); | What is the number of restaurants in Chicago with a menu price higher than $30? | SELECT COUNT(*) FROM restaurants WHERE city = 'Chicago' AND menu_price > 30; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT, Gender VARCHAR(10), Department VARCHAR(50)); INSERT INTO Employees (EmployeeID, Gender, Department) VALUES (1, 'Male', 'HR'), (2, 'Female', 'IT'), (3, 'Non-binary', 'IT'), (4, 'Transgender', 'HR'); | Calculate the percentage of employees who identify as LGBTQ+, by department. | SELECT Department, COUNT(CASE WHEN Gender IN ('Transgender', 'Non-binary') THEN 1 ELSE NULL END) * 100.0 / COUNT(*) AS Percentage_LGBTQ FROM Employees GROUP BY Department; | gretelai_synthetic_text_to_sql |
CREATE TABLE Players (PlayerID INT, Age INT, Gender VARCHAR(10), VRGamePlayer BOOLEAN); INSERT INTO Players (PlayerID, Age, Gender, VRGamePlayer) VALUES (1, 25, 'Male', true), (2, 30, 'Female', false), (3, 22, 'Male', true); | What is the total number of players who play VR games? | SELECT SUM(VRGamePlayer) FROM Players; | gretelai_synthetic_text_to_sql |
CREATE TABLE investigative_journalists (id INT, name VARCHAR(50), country VARCHAR(50), years_of_experience INT); INSERT INTO investigative_journalists (id, name, country, years_of_experience) VALUES (1, 'John Doe', 'USA', 10), (2, 'Jane Smith', 'Canada', 12), (3, 'Pedro Martinez', 'Mexico', 8); | How many investigative journalists in the "investigative_journalists" table are from the United States? | SELECT COUNT(*) FROM investigative_journalists WHERE country = 'USA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Players (PlayerID INT, Age INT, Gender VARCHAR(10), Location VARCHAR(50), LastLogin DATETIME); INSERT INTO Players (PlayerID, Age, Gender, Location, LastLogin) VALUES (3, 28, 'Non-binary', 'Toronto', '2021-06-03 13:45:00'); | What is the total number of players by gender and how many players have no gender specified? | SELECT COALESCE(Gender, 'Not specified') AS Gender, COUNT(*) FROM Players GROUP BY Gender WITH ROLLUP; | gretelai_synthetic_text_to_sql |
CREATE TABLE artist_performances (performance_id INT, artist_id INT, city_id INT, date DATE); | Identify artists who performed in the same city multiple times in 'artist_performances' table? | SELECT artist_id, city_id, COUNT(*) as performances_in_city FROM artist_performances GROUP BY artist_id, city_id HAVING COUNT(*) > 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE production (year INT, element VARCHAR(10), country VARCHAR(10), quantity INT); INSERT INTO production (year, element, country, quantity) VALUES (2016, 'Neodymium', 'Australia', 1200), (2017, 'Neodymium', 'Australia', 1400), (2018, 'Neodymium', 'Australia', 1600), (2019, 'Neodymium', 'Australia', 1800), (20... | What is the total production of Neodymium in Australia in the past 5 years? | SELECT SUM(quantity) FROM production WHERE element = 'Neodymium' AND country = 'Australia' AND year BETWEEN (SELECT YEAR(CURDATE()) - 5) AND YEAR(CURDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE project_timeline (project_id INT, state VARCHAR(2), type VARCHAR(20), timeline INT); INSERT INTO project_timeline (project_id, state, type, timeline) VALUES (1, 'TX', 'Residential', 180); | What is the minimum project timeline for residential building projects in Texas? | SELECT MIN(timeline) FROM project_timeline WHERE state = 'TX' AND type = 'Residential'; | gretelai_synthetic_text_to_sql |
CREATE TABLE sustainable_tourism_initiatives (country VARCHAR(255), year INT, num_initiatives INT); INSERT INTO sustainable_tourism_initiatives (country, year, num_initiatives) VALUES ('Egypt', 2020, 50), ('Kenya', 2020, 60), ('South Africa', 2020, 70); | How many sustainable tourism initiatives were implemented in Africa in 2020? | SELECT SUM(num_initiatives) FROM sustainable_tourism_initiatives WHERE country IN ('Egypt', 'Kenya', 'South Africa') AND year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteer_summary (vol_id INT, total_donations INT); INSERT INTO volunteer_summary (vol_id, total_donations) SELECT volunteer.vol_id, SUM(donation.donation_amount) FROM volunteer INNER JOIN donation ON volunteer.vol_id = donation.donor_id GROUP BY volunteer.vol_id; | Find the top 3 volunteers who have donated the most. | SELECT vol_id, total_donations FROM volunteer_summary ORDER BY total_donations DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE biosensor_funding (fund_id INT, sensor_type VARCHAR(50), fund_date DATE); INSERT INTO biosensor_funding (fund_id, sensor_type, fund_date) VALUES (1, 'Optical', '2018-12-01'), (2, 'Electrochemical', '2019-05-15'), (3, 'Piezoelectric', '2020-08-30'), (4, 'Thermal', '2021-01-20'); | Which biosensor types were funded in the last 3 years? | SELECT sensor_type FROM biosensor_funding WHERE fund_date >= DATE_SUB(CURDATE(), INTERVAL 3 YEAR); | gretelai_synthetic_text_to_sql |
CREATE TABLE games (id INT, name VARCHAR(255), genre VARCHAR(255), release_date DATE); INSERT INTO games (id, name, genre, release_date) VALUES (1, 'GameA', 'Action', '2021-06-01'); INSERT INTO games (id, name, genre, release_date) VALUES (2, 'GameB', 'Simulation', '2020-01-15'); INSERT INTO games (id, name, genre, rel... | What is the average score of players who joined after January 2022 from the 'Action' genre? | SELECT AVG(score) FROM players JOIN games ON players.game_id = games.id WHERE players.join_date > '2022-01-01' AND games.genre = 'Action'; | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_funding (id INT, initiative_type TEXT, allocation FLOAT, year INT); INSERT INTO climate_funding (id, initiative_type, allocation, year) VALUES (1, 'Mitigation', 500000.00, 2022), (2, 'Adaptation', 750000.00, 2022), (3, 'Communication', 300000.00, 2022); | What is the total funding allocated for climate communication initiatives in 2022? | SELECT SUM(allocation) FROM climate_funding WHERE initiative_type = 'Communication' AND year = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE AnimalPopulation (AnimalID int, AnimalName varchar(50), Population int, HabitatSize int); INSERT INTO AnimalPopulation (AnimalID, AnimalName, Population, HabitatSize) VALUES (1, 'Tiger', 2000, 300), (2, 'Elephant', 500, 400); CREATE TABLE HabitatPreservation (AnimalID int, HabitatSize int); INSERT INTO Hab... | What is the difference in 'HabitatSize' between the 'HabitatPreservation' table and the 'AnimalPopulation' table? | SELECT SUM(AnimalPopulation.HabitatSize) - SUM(HabitatPreservation.HabitatSize) FROM AnimalPopulation, HabitatPreservation; | gretelai_synthetic_text_to_sql |
CREATE TABLE refugee_camps (id INT, camp_name TEXT, country TEXT, total_donations DECIMAL(10,2)); INSERT INTO refugee_camps (id, camp_name, country, total_donations) VALUES (1, 'Kakuma', 'Kenya', 5000000.00), (2, 'Dadaab', 'Kenya', 7000000.00), (3, 'Zaatari', 'Jordan', 12000000.00), (4, 'Azraq', 'Jordan', 8000000.00); | What is the total amount of donations received by the top 10 refugee camps, ordered from highest to lowest, for the year 2021? | SELECT SUM(total_donations) as total_donations, camp_name FROM refugee_camps GROUP BY camp_name ORDER BY total_donations DESC LIMIT 10; | gretelai_synthetic_text_to_sql |
CREATE TABLE AutoShows (Id INT, Name VARCHAR(100), Location VARCHAR(100), StartDate DATE, EndDate DATE); CREATE TABLE Exhibits (Id INT, AutoShowId INT, VehicleId INT, SafetyRating FLOAT); CREATE TABLE Vehicles (Id INT, Name VARCHAR(100), Type VARCHAR(50)); INSERT INTO AutoShows (Id, Name, Location, StartDate, EndDate) ... | List all vehicles exhibited at the Tokyo Auto Show and their safety ratings. | SELECT Vehicles.Name, Exhibits.SafetyRating FROM Exhibits INNER JOIN Vehicles ON Exhibits.VehicleId = Vehicles.Id INNER JOIN AutoShows ON Exhibits.AutoShowId = AutoShows.Id WHERE AutoShows.Name = 'Tokyo Auto Show'; | gretelai_synthetic_text_to_sql |
CREATE TABLE theater_performances (performance_id INT, performance_name VARCHAR(50)); CREATE TABLE funding_sources (source_id INT, source_name VARCHAR(50)); CREATE TABLE performance_funding (performance_id INT, source_id INT, amount DECIMAL(5,2)); INSERT INTO theater_performances (performance_id, performance_name) VALU... | List all theater performances with their corresponding funding sources and amounts. | SELECT p.performance_name, f.source_name, f.amount FROM theater_performances p INNER JOIN performance_funding f ON p.performance_id = f.performance_id INNER JOIN funding_sources fs ON f.source_id = fs.source_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE states (state_id INT, state_name VARCHAR(50), parity_score DECIMAL(3,2)); INSERT INTO states (state_id, state_name, parity_score) VALUES (1, 'California', 85.2), (2, 'New York', 82.7), (3, 'Texas', 78.3), (4, 'Florida', 76.8), (5, 'Illinois', 74.5), (6, 'Ohio', 72.1), (7, 'Pennsylvania', 71.9), (8, 'Georgi... | List the top 5 states with the lowest mental health parity scores. | SELECT state_name, parity_score FROM states ORDER BY parity_score ASC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE resource_depletion (id INT, year INT, resource VARCHAR(50), quantity INT); INSERT INTO resource_depletion (id, year, resource, quantity) VALUES (1, 2021, 'Copper', 1000); INSERT INTO resource_depletion (id, year, resource, quantity) VALUES (2, 2021, 'Aluminum', 2000); INSERT INTO resource_depletion (id, ye... | What are the annual trends of resource depletion for copper and aluminum? | SELECT year, SUM(CASE WHEN resource = 'Copper' THEN quantity ELSE 0 END) as copper_quantity, SUM(CASE WHEN resource = 'Aluminum' THEN quantity ELSE 0 END) as aluminum_quantity FROM resource_depletion GROUP BY year; | gretelai_synthetic_text_to_sql |
CREATE TABLE Projects (Id INT, City VARCHAR(50), Type VARCHAR(50), Cost FLOAT, StartYear INT, EndYear INT); INSERT INTO Projects (Id, City, Type, Cost, StartYear, EndYear) VALUES (1, 'Chicago', 'Tunnel', 10000000, 2005, 2010); INSERT INTO Projects (Id, City, Type, Cost, StartYear, EndYear) VALUES (2, 'Seattle', 'Airpor... | What is the total cost, start year, and end year of infrastructure projects in Chicago and Seattle, grouped by project type? | SELECT City, Type, SUM(Cost) as Total_Cost, StartYear, EndYear FROM Projects GROUP BY City, Type, StartYear, EndYear; | gretelai_synthetic_text_to_sql |
CREATE TABLE customers (id INT, name VARCHAR(255), country VARCHAR(255)); INSERT INTO customers (id, name, country) VALUES (1, 'John Doe', 'USA'), (2, 'Jane Smith', 'Canada'), (3, 'Jim Brown', 'UK'), (4, 'Amit Patel', 'India'); CREATE TABLE transactions (id INT, customer_id INT, amount DECIMAL(10, 2)); INSERT INTO tran... | What is the minimum transaction amount for customers from India? | SELECT MIN(t.amount) FROM transactions t JOIN customers c ON t.customer_id = c.id WHERE c.country = 'India'; | gretelai_synthetic_text_to_sql |
CREATE TABLE streams (id INT, track_id INT, user_id INT, region VARCHAR(255), genre VARCHAR(255), revenue DECIMAL(10,2), timestamp TIMESTAMP); | What is the maximum revenue generated by a single stream in the genre of R&B in Canada? | SELECT MAX(revenue) FROM streams WHERE genre = 'R&B' AND region = 'Canada'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Menus (RestaurantID varchar(50), MenuItem varchar(50), Price decimal(10,2)); | Insert new records into the Menus table for restaurant G with menu items and their prices. | INSERT INTO Menus (RestaurantID, MenuItem, Price) VALUES ('G', 'Quinoa Salad', 12.99), ('G', 'Tofu Stir Fry', 14.99), ('G', 'Vegan Burger', 13.49), ('G', 'Chickpea Curry', 13.99); | gretelai_synthetic_text_to_sql |
CREATE TABLE attorneys (attorney_id INT, name TEXT, gender TEXT); INSERT INTO attorneys (attorney_id, name, gender) VALUES (1, 'Jane Smith', 'Female'), (2, 'Bob Johnson', 'Male'), (3, 'Alex Rodriguez', 'Male'); CREATE TABLE cases (case_id INT, attorney_id INT, billing_amount INT); INSERT INTO cases (case_id, attorney_i... | What is the average billing amount for cases handled by male attorneys? | SELECT AVG(billing_amount) FROM cases WHERE attorney_id IN (SELECT attorney_id FROM attorneys WHERE gender = 'Male') | gretelai_synthetic_text_to_sql |
CREATE TABLE wastewater_plants (id INT, name VARCHAR(100), state VARCHAR(20)); CREATE TABLE water_quality_issues (id INT, plant_id INT, issue_date DATE); | List all the wastewater treatment plants in Texas that have had issues with water quality in the past 5 years. | SELECT w.name FROM wastewater_plants w INNER JOIN water_quality_issues i ON w.id = i.plant_id WHERE w.state = 'Texas' AND i.issue_date >= DATE(YEAR(CURRENT_DATE) - 5); | gretelai_synthetic_text_to_sql |
CREATE TABLE companies (company_id INT, name TEXT);CREATE TABLE production (company_id INT, recycled_qty INT, total_qty INT); | What is the total quantity of recycled materials used in production by each company, and what percentage does it represent of their total production? | SELECT c.name, SUM(p.recycled_qty) AS total_recycled, (SUM(p.recycled_qty) / SUM(p.total_qty)) * 100 AS pct_of_total FROM companies c INNER JOIN production p ON c.company_id = p.company_id GROUP BY c.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Satellites (name TEXT, launch_date DATE, country TEXT); INSERT INTO Satellites (name, launch_date, country) VALUES ('GSAT-1', '2001-06-18', 'India'); INSERT INTO Satellites (name, launch_date, country) VALUES ('PSLV-C51', '2021-02-28', 'India'); | What is the earliest launch date of a satellite by India? | SELECT MIN(launch_date) FROM Satellites WHERE country = 'India'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Products (id INT, category VARCHAR, material VARCHAR, percentage DECIMAL); | What is the percentage of recycled materials used in each product category? | SELECT category, AVG(percentage) as avg_percentage FROM Products WHERE material LIKE '%recycled%' GROUP BY category; | gretelai_synthetic_text_to_sql |
CREATE TABLE Restaurants (RestaurantID int, RestaurantName varchar(50), City varchar(50)); INSERT INTO Restaurants (RestaurantID, RestaurantName, City) VALUES (1, 'Fresh Eats', 'New York'); INSERT INTO Restaurants (RestaurantID, RestaurantName, City) VALUES (2, 'Tasty Bites', 'New York'); CREATE TABLE Inspections (Insp... | Identify food safety violations in restaurants located in 'New York' and their respective violation counts. | SELECT R.RestaurantName, I.ViolationCount FROM Restaurants R JOIN Inspections I ON R.RestaurantID = I.RestaurantID WHERE R.City = 'New York'; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_protected_areas (area_name TEXT, longitude DECIMAL(11,8)); INSERT INTO marine_protected_areas (area_name, longitude) VALUES ('Great Barrier Reef', 147.75), ('Galapagos Islands', -90.81); | List all marine protected areas that are in the Eastern Hemisphere. | SELECT area_name FROM marine_protected_areas WHERE longitude > 0; | gretelai_synthetic_text_to_sql |
CREATE TABLE Production(id INT, country VARCHAR(50), year INT, certified BOOLEAN, quantity INT); INSERT INTO Production(id, country, year, certified, quantity) VALUES (1, 'US', 2019, TRUE, 30000), (2, 'US', 2020, TRUE, 35000), (3, 'US', 2021, TRUE, 40000), (4, 'US', 2019, FALSE, 25000), (5, 'US', 2020, FALSE, 28000), (... | What is the total organic certified farmed fish production in the last 3 years in the US? | SELECT SUM(quantity) FROM Production WHERE country = 'US' AND certified = TRUE AND year BETWEEN 2019 AND 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE emissions (id INT, year INT, country TEXT, co2_emissions INT); INSERT INTO emissions (id, year, country, co2_emissions) VALUES (1, 2020, 'US', 50000); | What is the total CO2 emissions of the food supply chain in the US? | SELECT SUM(co2_emissions) FROM emissions WHERE country = 'US' AND year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE VirtualTours (TourID int, TourName varchar(50), Location varchar(50), URL varchar(100)); INSERT INTO VirtualTours (TourID, TourName, Location, URL) VALUES (1, 'Statue of Liberty', 'New York', 'https://www.statueoflibertyvirtualtour.com'); INSERT INTO VirtualTours (TourID, TourName, Location, URL) VALUES (2... | List all virtual tours in the United States with their URLs, excluding those in New York. | SELECT TourName, URL FROM VirtualTours WHERE Location != 'New York' AND Country = 'USA' | gretelai_synthetic_text_to_sql |
CREATE TABLE hydroelectric_plants (id INT, name VARCHAR(100), capacity FLOAT, country VARCHAR(50)); INSERT INTO hydroelectric_plants (id, name, capacity, country) VALUES (1, 'Hydroelectric Plant 1', 1000.5, 'Norway'), (2, 'Hydroelectric Plant 2', 1500.3, 'Brazil'); | What is the name and capacity of the largest hydroelectric power plant in the database? | SELECT name, capacity FROM hydroelectric_plants ORDER BY capacity DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, vegan BOOLEAN, product_type TEXT); INSERT INTO products (product_id, vegan, product_type) VALUES (1, true, 'Makeup'), (2, false, 'Skincare'), (3, true, 'Makeup'); | What is the percentage of vegan makeup products? | SELECT (COUNT(*) FILTER (WHERE vegan = true)) * 100.0 / COUNT(*) FROM products WHERE product_type = 'Makeup'; | gretelai_synthetic_text_to_sql |
CREATE TABLE WhaleWatching (id INT, sighting_date DATE, species VARCHAR(20), location VARCHAR(50)); INSERT INTO WhaleWatching (id, sighting_date, species, location) VALUES (1, '2020-08-01', 'Blue Whale', 'Pacific Ocean'), (2, '2021-03-15', 'Humpback Whale', 'Atlantic Ocean'), (3, '2021-12-30', 'Orca', 'Arctic Ocean'); | Delete all records of whale sightings in 2021 from the WhaleWatching table. | DELETE FROM WhaleWatching WHERE sighting_date >= '2021-01-01' AND sighting_date <= '2021-12-31' AND species LIKE '%Whale%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE mobile_plans (id INT, plan_type VARCHAR(10), state VARCHAR(20), revenue DECIMAL(10,2)); | What is the total revenue generated from prepaid mobile plans in California for the year 2021? | SELECT SUM(revenue) FROM mobile_plans WHERE plan_type = 'prepaid' AND state = 'California' AND YEAR(order_date) = 2021; | gretelai_synthetic_text_to_sql |
CREATE VIEW Community_Education AS SELECT 'Future_Guardians' AS program, 14000 AS budget UNION SELECT 'Earth_Stewards', 16000; | What is the total budget for community education programs? | SELECT SUM(budget) FROM Community_Education; | gretelai_synthetic_text_to_sql |
CREATE TABLE transactions (id INT, contract_name TEXT, timestamp TIMESTAMP); INSERT INTO transactions (id, contract_name, timestamp) VALUES (1, 'Contract1', '2022-01-01 10:00:00'), (2, 'Contract1', '2022-01-01 12:00:00'), (3, 'Contract2', '2022-01-01 14:00:00'); CREATE TABLE smart_contracts (id INT, name TEXT); INSERT ... | What is the name of the smart contract with the most transactions? | SELECT name FROM smart_contracts JOIN transactions ON smart_contracts.name = transactions.contract_name GROUP BY name ORDER BY COUNT(*) DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE cases (case_id INT, case_month INT, billing_amount INT); | What is the maximum billing amount for cases in the month of April? | SELECT MAX(billing_amount) FROM cases WHERE case_month = 4; | gretelai_synthetic_text_to_sql |
CREATE TABLE Stations (StationID INT, StationName VARCHAR(50), City VARCHAR(50), DailyPassengers INT); INSERT INTO Stations (StationID, StationName, City, DailyPassengers) VALUES (1, 'StationX', 'CityA', 2000), (2, 'StationY', 'CityA', 3000), (3, 'StationZ', 'CityB', 1500); | What are the top 3 busiest stations in the city? | SELECT StationName, SUM(DailyPassengers) as TotalPassengers FROM Stations GROUP BY StationName ORDER BY TotalPassengers DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE Autonomous_Driving_Tests (id INT, vehicle_model VARCHAR(50), test_location VARCHAR(50), max_speed FLOAT); | What is the maximum speed reached during autonomous driving research in each country? | SELECT test_location, MAX(max_speed) FROM Autonomous_Driving_Tests GROUP BY test_location; | gretelai_synthetic_text_to_sql |
CREATE TABLE vulnerabilities (id INT, date DATE, vulnerability VARCHAR(50), frequency INT); | What is the maximum number of vulnerabilities reported in a single day? | SELECT date, MAX(frequency) FROM vulnerabilities GROUP BY date ORDER BY MAX(frequency) DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Events (id INT, name VARCHAR(20)); INSERT INTO Events (id, name) VALUES (1, 'Family Day'); CREATE TABLE Visitor_Events (visitor_id INT, event_id INT); ALTER TABLE Visitors ADD COLUMN age INT; | What is the average age of visitors who attended the family day event? | SELECT AVG(Visitors.age) FROM Visitors JOIN Visitor_Events ON Visitors.id = Visitor_Events.visitor_id JOIN Events ON Visitor_Events.event_id = Events.id WHERE Events.name = 'Family Day'; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotel_views (hotel_id INT, country TEXT, views INT); INSERT INTO hotel_views (hotel_id, country, views) VALUES (1, 'Australia', 200), (2, 'New Zealand', 300), (3, 'Australia', 400), (4, 'New Zealand', 150), (5, 'Australia', 50); | What is the average number of virtual tour views for hotels in 'Australia'? | SELECT AVG(views) FROM hotel_views WHERE country LIKE 'Australia%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE balances (id INT, risk_level VARCHAR(10), region VARCHAR(20), balance DECIMAL(15, 2)); INSERT INTO balances (id, risk_level, region, balance) VALUES (1, 'high', 'Africa', 200000.00), (2, 'medium', 'Europe', 150000.00), (3, 'low', 'North America', 100000.00), (4, 'high', 'Asia-Pacific', 300000.00); | What is the minimum balance for low-risk accounts in the Europe region? | SELECT MIN(balance) FROM balances WHERE risk_level = 'low' AND region = 'Europe'; | gretelai_synthetic_text_to_sql |
CREATE TABLE co2_emissions (id INT PRIMARY KEY, plant_name VARCHAR(255), chemical_name VARCHAR(255), co2_emission_per_ton_produced DECIMAL(5,2)); INSERT INTO co2_emissions (id, plant_name, chemical_name, co2_emission_per_ton_produced) VALUES (1, 'Plant A', 'Nitric Acid', 2.3); INSERT INTO co2_emissions (id, plant_name,... | Which plants have a CO2 emission rate higher than the average for all plants? | SELECT plant_name FROM co2_emissions GROUP BY plant_name HAVING AVG(co2_emission_per_ton_produced) > (SELECT AVG(co2_emission_per_ton_produced) FROM co2_emissions); | gretelai_synthetic_text_to_sql |
CREATE TABLE posts (id INT, user_id INT, timestamp DATETIME, content TEXT, hashtags TEXT); INSERT INTO posts (id, user_id, timestamp, content, hashtags) VALUES (1, 1, '2022-01-01 10:00:00', 'New song out now!', ''), (2, 2, '2022-02-01 15:00:00', '', ''); | Get the number of users who posted content in each month of 2022, for users in the 'music' network. | SELECT MONTH(timestamp) AS month, COUNT(DISTINCT user_id) AS user_count FROM posts WHERE network = 'music' AND YEAR(timestamp) = 2022 GROUP BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE Farm ( FarmID INT, FishSpecies VARCHAR(255), WaterTemperature DECIMAL(5,2) ); INSERT INTO Farm (FarmID, FishSpecies, WaterTemperature) VALUES (1, 'Tilapia', 28.5), (2, 'Salmon', 12.3), (3, 'Tilapia', 29.0), (4, 'Catfish', 24.2); | What is the average water temperature for each species of fish in the aquaculture farms? | SELECT FishSpecies, AVG(WaterTemperature) OVER (PARTITION BY FishSpecies) AS AvgWaterTemp FROM Farm; | gretelai_synthetic_text_to_sql |
CREATE TABLE States (id INT, name VARCHAR(50)); CREATE TABLE AutonomousVehiclesSales (id INT, state_id INT, vehicle_id INT, quantity INT, PRIMARY KEY (id), FOREIGN KEY (state_id) REFERENCES States(id)); CREATE TABLE AutonomousVehicles (id INT, make VARCHAR(50), model VARCHAR(50), PRIMARY KEY (id)); CREATE TABLE Autonom... | How many autonomous vehicles have been sold in each state in the autonomousvehiclesales schema? | SELECT s.name, SUM(avs.quantity) FROM AutonomousVehiclesSales avs JOIN States s ON avs.state_id = s.id JOIN AutonomousVehicleSales av ON avs.sales_id = av.id GROUP BY s.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Attorneys (ID INT, Name VARCHAR(255)); CREATE TABLE Cases (ID INT, AttorneyID INT, Date DATE, Outcome VARCHAR(255)); INSERT INTO Attorneys (ID, Name) VALUES (1, 'Alex Garcia'), (2, 'Fatima Nguyen'), (3, 'Ricardo Mendoza'); INSERT INTO Cases (ID, AttorneyID, Date, Outcome) VALUES (1, 1, '2022-01-01', 'Won')... | What is the total number of cases handled by each attorney in the last year, and their respective win rates? | SELECT AttorneyID, COUNT(*) as TotalCases, SUM(CASE WHEN Outcome = 'Won' THEN 1 ELSE 0 END) * 100.0 / COUNT(*) as WinRate FROM Cases WHERE Date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY AttorneyID; | gretelai_synthetic_text_to_sql |
CREATE TABLE international_visitors_2022 (id INT, country VARCHAR(50), num_visitors INT); INSERT INTO international_visitors_2022 (id, country, num_visitors) VALUES (1, 'France', 4000000), (2, 'Spain', 3500000), (3, 'Germany', 5000000); CREATE TABLE tourists_demographics (id INT, country VARCHAR(50), gender VARCHAR(50)... | List the number of tourists visiting each country in 2022 and the percentage of female tourists. | SELECT i2022.country, SUM(i2022.num_visitors) AS total_tourists, (SUM(t.female_tourists) / SUM(t.total_tourists)) * 100 AS female_percentage FROM international_visitors_2022 i2022 JOIN ( SELECT country, SUM(num_visitors) AS total_tourists, SUM(CASE WHEN gender = 'Female' THEN num_tourists ELSE 0 END) AS female_tourists... | 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.