context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28 values |
|---|---|---|---|
CREATE TABLE Employees (EmployeeID INT, Department VARCHAR(20), Position VARCHAR(20), Salary INT, Ethnicity VARCHAR(20), IsFullTime BOOLEAN); | What is the number of employees by ethnicity and their average salary in the Mining department? | SELECT Ethnicity, AVG(Salary) FROM Employees WHERE Department = 'Mining' AND IsFullTime = TRUE GROUP BY Ethnicity; | gretelai_synthetic_text_to_sql |
CREATE TABLE water_infrastructure (id INT, project_name VARCHAR(50), location VARCHAR(50), cost FLOAT); INSERT INTO water_infrastructure (id, project_name, location, cost) VALUES (1, 'Water Treatment Plant', 'San Francisco', 5000000); INSERT INTO water_infrastructure (id, project_name, location, cost) VALUES (2, 'Dam', 'New York', 8000000); | How many projects are there in the 'water_infrastructure' table? | SELECT COUNT(*) FROM water_infrastructure; | gretelai_synthetic_text_to_sql |
CREATE TABLE cities (id INT PRIMARY KEY, city_name VARCHAR(255), state VARCHAR(255), country VARCHAR(255)); | Find the average number of charging stations per city in the ev_charging_stations table | SELECT city, AVG(num_chargers) FROM (SELECT city, COUNT(*) as num_chargers FROM ev_charging_stations JOIN cities ON ev_charging_stations.location LIKE CONCAT('%', cities.city_name, '%') GROUP BY city) AS charging_stations; | gretelai_synthetic_text_to_sql |
CREATE TABLE union_members (member_id INT, gender VARCHAR(6), state VARCHAR(2)); INSERT INTO union_members (member_id, gender, state) VALUES (1, 'Female', 'NY'), (2, 'Male', 'CA'), (3, 'Female', 'IL'); | Which states have the most female union members? | SELECT state, COUNT(*) as num_female_members FROM union_members WHERE gender = 'Female' GROUP BY state ORDER BY num_female_members DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE museums (id INT, city VARCHAR(20), art_pieces INT); INSERT INTO museums (id, city, art_pieces) VALUES (1, 'Tokyo', 5000), (2, 'Tokyo', 7000), (3, 'Paris', 8000); | Which museums in 'Tokyo' have the highest and lowest number of art pieces? | SELECT city, MAX(art_pieces) AS max_art_pieces, MIN(art_pieces) AS min_art_pieces FROM museums WHERE city = 'Tokyo'; | gretelai_synthetic_text_to_sql |
CREATE TABLE nutrition_data (product_id INT, product_name VARCHAR(50), calorie_count INT); INSERT INTO nutrition_data (product_id, product_name, calorie_count) VALUES (1, 'Apple', 95), (2, 'Carrot', 50), (3, 'Celery', 18); | List the top 5 products with the lowest calorie count in the nutrition_data table. | SELECT product_id, product_name, calorie_count FROM (SELECT product_id, product_name, calorie_count, ROW_NUMBER() OVER (ORDER BY calorie_count ASC) AS rank FROM nutrition_data) WHERE rank <= 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE production (year INT, element TEXT, quantity INT); INSERT INTO production (year, element, quantity) VALUES (2015, 'Dysprosium', 100), (2016, 'Dysprosium', 150), (2017, 'Dysprosium', 200), (2018, 'Dysprosium', 250), (2019, 'Dysprosium', 300), (2020, 'Dysprosium', 350), (2015, 'Neodymium', 500), (2016, 'Neodymium', 600), (2017, 'Neodymium', 700), (2018, 'Neodymium', 800), (2019, 'Neodymium', 900), (2020, 'Neodymium', 1000); | Which REEs were produced in 2017? | SELECT DISTINCT element FROM production WHERE year = 2017; | gretelai_synthetic_text_to_sql |
CREATE TABLE chemicals_manufactured (id INT, chemical_name VARCHAR(255), region VARCHAR(255), production_rate FLOAT); INSERT INTO chemicals_manufactured (id, chemical_name, region, production_rate) VALUES (1, 'Acetone', 'North America', 500.0), (2, 'Methanol', 'North America', 700.0); | What is the average production rate of chemicals in the North America region? | SELECT AVG(production_rate) FROM chemicals_manufactured WHERE region = 'North America'; | gretelai_synthetic_text_to_sql |
CREATE TABLE pets (policyholder_id INT, pet_type VARCHAR(10)); INSERT INTO pets (policyholder_id, pet_type) VALUES (1, 'Dog'), (2, 'Cat'), (3, 'Bird'); CREATE TABLE claims (claim_id INT, policyholder_id INT, amount DECIMAL(10, 2)); INSERT INTO claims (claim_id, policyholder_id, amount) VALUES (1, 1, 500), (2, 3, 100), (3, 2, 300), (4, 1, 700); | What is the average claim amount for policyholders with dogs? | SELECT AVG(c.amount) as avg_claim_amount FROM claims c JOIN pets p ON c.policyholder_id = p.policyholder_id WHERE p.pet_type = 'Dog'; | gretelai_synthetic_text_to_sql |
CREATE TABLE temperature_data (id INT, farm_id INT, temperature FLOAT, measurement_date DATE); | Delete all temperature data for farm_id 678 | DELETE FROM temperature_data WHERE farm_id = 678; | gretelai_synthetic_text_to_sql |
CREATE TABLE Restaurants (RestaurantID int, Name varchar(50)); INSERT INTO Restaurants (RestaurantID, Name) VALUES (1, 'Asian Fusion'), (2, 'Bistro Bella Vita'), (3, 'Cocina del Sol'); CREATE TABLE MenuItems (MenuItemID int, RestaurantID int, Name varchar(50), Revenue decimal(5,2)); INSERT INTO MenuItems (MenuItemID, RestaurantID, Name, Revenue) VALUES (1, 1, 'Egg Roll', 100.00), (2, 1, 'Wonton Soup', 75.00), (3, 2, 'Margherita Pizza', 150.00), (4, 2, 'Caprese Salad', 120.00), (5, 3, 'Tacos', 175.00), (6, 3, 'Guacamole', 100.00); | Identify the top 3 menu items with the highest revenue for each restaurant, and calculate the total revenue for those items. | SELECT R.Name, MI.Name, SUM(MI.Revenue) AS TotalRevenue FROM Restaurants R JOIN (SELECT RestaurantID, Name, Revenue, ROW_NUMBER() OVER (PARTITION BY RestaurantID ORDER BY Revenue DESC) AS Ranking FROM MenuItems) MI ON R.RestaurantID = MI.RestaurantID WHERE MI.Ranking <= 3 GROUP BY R.Name, MI.Name ORDER BY TotalRevenue DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE heritage_sites (id INT, name VARCHAR); INSERT INTO heritage_sites (id, name) VALUES (1, 'Heritage Site A'), (2, 'Heritage Site B'); CREATE TABLE traditional_arts (id INT, site_id INT, art_type VARCHAR); INSERT INTO traditional_arts (id, site_id) VALUES (1, 1), (2, 2); | List all heritage sites and their associated traditional arts. | SELECT heritage_sites.name, traditional_arts.art_type FROM heritage_sites INNER JOIN traditional_arts ON heritage_sites.id = traditional_arts.site_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE q2_program_category (id INT, program_category VARCHAR(50), program VARCHAR(50), volunteer_hours INT); INSERT INTO q2_program_category (id, program_category, program, volunteer_hours) VALUES (1, 'Education', 'Mentorship', 10), (2, 'Health', 'Tutoring', 15), (3, 'Education', 'Mentorship', 12); | What is the total number of volunteer hours per program category in Q2 2022? | SELECT program_category, SUM(volunteer_hours) as total_volunteer_hours FROM q2_program_category WHERE volunteer_date BETWEEN '2022-04-01' AND '2022-06-30' GROUP BY program_category; | gretelai_synthetic_text_to_sql |
CREATE TABLE species_count (id INT, species_name VARCHAR, biome VARCHAR, animal_count INT); | List the species with the highest and lowest sighting counts in the Arctic. | SELECT species_name, animal_count FROM (SELECT species_name, biome, animal_count, RANK() OVER (PARTITION BY biome ORDER BY animal_count DESC, species_name ASC) as rank FROM species_count WHERE biome = 'Arctic') as subquery WHERE rank IN (1, (SELECT COUNT(DISTINCT species_name) FROM species_count WHERE biome = 'Arctic')); | gretelai_synthetic_text_to_sql |
CREATE TABLE hotels (id INT, name TEXT, country TEXT, continent TEXT, reviews INT); INSERT INTO hotels (id, name, country, continent, reviews) VALUES (1, 'Eco-Hotel', 'Germany', 'Europe', 180), (2, 'Green-Lodge', 'Germany', 'Europe', 120), (3, 'Nature-Resort', 'Italy', 'Europe', 200), (4, 'Bio-Hotel', 'Brazil', 'South America', 150); | List the number of sustainable hotels with more than 100 reviews in each continent. | SELECT continent, COUNT(*) as hotel_count FROM hotels WHERE reviews > 100 GROUP BY continent; | gretelai_synthetic_text_to_sql |
CREATE TABLE sites (site_id INT, site_name TEXT, country TEXT); CREATE TABLE bookings (booking_id INT, site_id INT, revenue INT); INSERT INTO sites (site_id, site_name, country) VALUES (1, 'Angkor Wat', 'Cambodia'); INSERT INTO bookings (booking_id, site_id, revenue) VALUES (1, 1, 5000); | Which cultural heritage sites have the most bookings? | SELECT sites.site_name, SUM(bookings.revenue) FROM sites JOIN bookings ON sites.site_id = bookings.site_id GROUP BY sites.site_id ORDER BY SUM(bookings.revenue) DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE ports (port_id INT, port_name TEXT, country TEXT); INSERT INTO ports (port_id, port_name, country) VALUES (1, 'Port A', 'USA'), (2, 'Port B', 'Canada'), (3, 'Port C', 'USA'); CREATE TABLE visits (visit_id INT, vessel_id INT, port_id INT); INSERT INTO visits (visit_id, vessel_id, port_id) VALUES (1, 1, 1), (2, 2, 1), (3, 3, 2), (4, 1, 3); | How many unique vessels visited each country? | SELECT countries, COUNT(DISTINCT vessels.vessel_id) FROM ports JOIN visits ON ports.port_id = visits.port_id JOIN (SELECT DISTINCT vessel_id, port_id FROM visits) AS vessels ON visits.vessel_id = vessels.vessel_id GROUP BY countries; | gretelai_synthetic_text_to_sql |
CREATE TABLE Cultural_Heritage_Sites (id INT, name VARCHAR(255), location VARCHAR(255), year_established INT, PRIMARY KEY(id)); INSERT INTO Cultural_Heritage_Sites (id, name, location, year_established) VALUES (1, 'Todai-ji Temple', 'Nara, Japan', 745); | What are the names and annual revenues of all cultural heritage sites located in Tokyo, Japan? | SELECT c.name, c.annual_revenue FROM Cultural_Heritage_Sites c WHERE c.location = 'Tokyo, Japan'; | gretelai_synthetic_text_to_sql |
CREATE TABLE exit (id INT, company_id INT, exit_year INT, exit_quarter TEXT, exit_type TEXT); | Show exits in Q1 2020 | SELECT * FROM exit WHERE exit_year = 2020 AND exit_quarter = 'Q1'; | gretelai_synthetic_text_to_sql |
CREATE TABLE menu (menu_id INT, name VARCHAR(50), category VARCHAR(50), price DECIMAL(5,2)); INSERT INTO menu (menu_id, name, category, price) VALUES (1, 'Chicken Alfredo', 'Pasta', 12.99), (2, 'Chicken Parmesan', 'Entree', 16.99); CREATE TABLE orders (order_id INT, order_date DATE, menu_id INT, quantity INT); INSERT INTO orders (order_id, order_date, menu_id, quantity) VALUES (1, '2022-01-03', 1, 3), (2, '2022-01-03', 2, 2), (3, '2022-01-05', 1, 1); | What is the total quantity of chicken dishes sold in the month of January 2022? | SELECT SUM(quantity) FROM orders JOIN menu ON orders.menu_id = menu.menu_id WHERE menu.category = 'Pasta' AND orders.order_date BETWEEN '2022-01-01' AND '2022-01-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, product_name VARCHAR(50), country VARCHAR(50), accessibility_rating FLOAT); INSERT INTO products (product_id, product_name, country, accessibility_rating) VALUES (1, 'Screen Reader Software', 'Canada', 4.5), (2, 'Adaptive Mouse', 'United States', 4.7); | What is the total number of accessible technology products for people with disabilities in Canada and the United States? | SELECT SUM(accessibility_rating) FROM products WHERE country IN ('Canada', 'United States') AND accessibility_rating IS NOT NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE dams (id INT, name VARCHAR(255), location VARCHAR(255), elevation INT, height INT, reservoir VARCHAR(255)); INSERT INTO dams (id, name, location, elevation, height, reservoir) VALUES (1, 'Hoover Dam', 'Nevada, Arizona', 530, 221, 'Lake Mead'); | Which dams in Texas have a higher elevation than the Hoover Dam? | SELECT name, elevation FROM dams WHERE elevation > (SELECT elevation FROM dams WHERE name = 'Hoover Dam') AND location LIKE '%TX%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE socially_responsible_lending_data (lending_id INT, amount DECIMAL(15, 2), country VARCHAR(50)); INSERT INTO socially_responsible_lending_data (lending_id, amount, country) VALUES (1, 5000000, 'Brazil'), (2, 7000000, 'India'), (3, 6000000, 'South Africa'), (4, 8000000, 'Indonesia'), (5, 9000000, 'China'); CREATE VIEW socially_responsible_lending_view AS SELECT country, SUM(amount) as total_lending FROM socially_responsible_lending_data GROUP BY country; | What is the total socially responsible lending for each country? | SELECT country, total_lending FROM socially_responsible_lending_view; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT, country VARCHAR(255)); CREATE TABLE posts (id INT, user_id INT, content TEXT); INSERT INTO users (id, country) VALUES (1, 'India'), (2, 'India'), (3, 'India'), (4, 'USA'), (5, 'Canada'); INSERT INTO posts (id, user_id, content) VALUES (1, 1, 'Hello'), (2, 1, 'World'), (3, 2, 'AI'), (4, 2, 'Data'), (5, 3, 'Science'); | Who are the top 5 users in India by number of posts? | SELECT users.id, users.country, COUNT(posts.id) AS post_count FROM users JOIN posts ON users.id = posts.user_id WHERE users.country = 'India' GROUP BY users.id ORDER BY post_count DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE Visitors (VisitorID INT, Age INT, Country VARCHAR(50)); INSERT INTO Visitors (VisitorID, Age, Country) VALUES (1, 35, 'Brazil'), (2, 45, 'Argentina'); | What is the average arrival age of visitors from 'Brazil' and 'Argentina' in the first half of '2022'? | SELECT AVG(Age) FROM Visitors WHERE Country IN ('Brazil', 'Argentina') AND ArrivalDate BETWEEN '2022-01-01' AND '2022-06-30'; | gretelai_synthetic_text_to_sql |
CREATE TABLE violations (platform VARCHAR(255), violation_count INT); INSERT INTO violations (platform, violation_count) VALUES ('Binance', 50); INSERT INTO violations (platform, violation_count) VALUES ('Kraken', 25); | Delete all regulatory violations related to the Binance platform. | DELETE FROM violations WHERE platform = 'Binance'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Vehicles (VehicleID int, VehicleType varchar(50), LastMaintenanceDate date); INSERT INTO Vehicles VALUES (1, 'Bus', '2022-03-20'); INSERT INTO Vehicles VALUES (2, 'Tram', '2022-03-15'); INSERT INTO Vehicles VALUES (3, 'Train', '2022-04-01'); | Which vehicles are due for maintenance this week? | SELECT * FROM Vehicles WHERE LastMaintenanceDate <= DATE_SUB(CURDATE(), INTERVAL 7 DAY); | gretelai_synthetic_text_to_sql |
CREATE TABLE Consumption(id INT, consumer_id INT, material VARCHAR(50), quantity INT); INSERT INTO Consumption(id, consumer_id, material, quantity) VALUES (1, 1, 'Bamboo Fabric', 50), (2, 2, 'Organic Silk', 75), (3, 3, 'Tencel', 60); | What is the total quantity of sustainable material consumed by consumers? | SELECT SUM(quantity) FROM Consumption; | gretelai_synthetic_text_to_sql |
CREATE TABLE poolhotels (id INT, name VARCHAR(255), region VARCHAR(255), revenue FLOAT, has_pool BOOLEAN); INSERT INTO poolhotels (id, name, region, revenue, has_pool) VALUES (1, 'Pool Hotel', 'North America', 35000, 1); INSERT INTO poolhotels (id, name, region, revenue, has_pool) VALUES (2, 'No-Pool Hotel', 'North America', 25000, 0); | Calculate the total revenue for hotels with a 'pool' in the 'North America' region. | SELECT SUM(revenue) FROM poolhotels WHERE region = 'North America' AND has_pool = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE emergencies (id INT, emergency_type VARCHAR(20), neighborhood VARCHAR(20), response_time FLOAT); INSERT INTO emergencies (id, emergency_type, neighborhood, response_time) VALUES (1, 'medical', 'Little Italy', 10.5), (2, 'fire', 'Little Italy', 7.3), (3, 'fire', 'Downtown', 9.1), (4, 'fire', 'Little Italy', 8.8), (5, 'medical', 'Little Italy', 11.9); | What is the average response time for fire emergencies in 'Little Italy'? | SELECT AVG(response_time) FROM emergencies WHERE emergency_type = 'fire' AND neighborhood = 'Little Italy'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ticket_sales_by_month (sale_id INT, sale_date DATE, price DECIMAL(5,2)); INSERT INTO ticket_sales_by_month (sale_id, sale_date, price) VALUES (1, '2022-01-01', 75), (2, '2022-02-01', 80), (3, '2022-03-01', 85), (4, '2022-04-01', 90); | What are the total ticket sales for each month in 2022? | SELECT EXTRACT(MONTH FROM sale_date) as month, SUM(price) as total_sales FROM ticket_sales_by_month GROUP BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (id INT, category VARCHAR(50), circular_supply_chain BOOLEAN, co2_emission_reduction INT); | What is the average CO2 emission reduction, in kg, for products with a circular supply chain, by category, in the past year? | SELECT category, AVG(co2_emission_reduction) as avg_co2_reduction FROM products WHERE circular_supply_chain = TRUE AND date >= DATEADD(year, -1, GETDATE()) GROUP BY category; | gretelai_synthetic_text_to_sql |
CREATE TABLE PoliciesBroker (PolicyID INT, IssueDate DATE, Broker VARCHAR(20)); INSERT INTO PoliciesBroker (PolicyID, IssueDate, Broker) VALUES (1, '2022-01-01', 'BrokerSmith'), (2, '2022-02-01', 'BrokerJones'); | Display the earliest issue date for policies handled by 'BrokerSmith'. | SELECT MIN(IssueDate) FROM PoliciesBroker WHERE Broker = 'BrokerSmith'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Customers (CustomerID INT, TransactionDate DATE, TransactionAmount DECIMAL(10,2)); | Calculate the average transaction amount for each customer in the "Customers" table. | SELECT CustomerID, AVG(TransactionAmount) as AvgTransactionAmount FROM Customers GROUP BY CustomerID; | gretelai_synthetic_text_to_sql |
CREATE TABLE peacekeeping (country VARCHAR(50), year INT, operation VARCHAR(50)); INSERT INTO peacekeeping (country, year, operation) VALUES ('Egypt', 2021, 'MINUSCA'); INSERT INTO peacekeeping (country, year, operation) VALUES ('Mexico', 2021, 'MONUSCO'); INSERT INTO peacekeeping (country, year, operation) VALUES ('Nepal', 2021, 'MINUSMA'); INSERT INTO peacekeeping (country, year, operation) VALUES ('South Korea', 2021, 'UNMISS'); | Which countries participated in peacekeeping operations in 2021? | SELECT DISTINCT country FROM peacekeeping WHERE year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE rural_infrastructure (id INT, project_name VARCHAR(50), location VARCHAR(50), budget DECIMAL(10,2)); INSERT INTO rural_infrastructure (id, project_name, location, budget) VALUES (1, 'Water Supply', 'Village A', 25000.00), (2, 'Road Construction', 'Village B', 50000.00), (3, 'Electricity Supply', 'Village A', 30000.00); | What is the average budget for rural infrastructure projects in each location in the 'rural_infrastructure' table? | SELECT location, AVG(budget) as avg_budget FROM rural_infrastructure GROUP BY location; | gretelai_synthetic_text_to_sql |
CREATE TABLE spacecraft (id INT, name VARCHAR(255), destination VARCHAR(255), launch_date DATE); INSERT INTO spacecraft (id, name, destination, launch_date) VALUES (1, 'Cassini', 'Jupiter', '1997-10-15'); INSERT INTO spacecraft (id, name, destination, launch_date) VALUES (2, 'Juno', 'Jupiter', '2011-08-05'); | What is the earliest launch date for a spacecraft to Jupiter? | SELECT launch_date FROM spacecraft WHERE destination = 'Jupiter' ORDER BY launch_date ASC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE CulturalHeritage (venue_id INT PRIMARY KEY, cultural_significance VARCHAR(255), last_audit DATETIME, FOREIGN KEY (venue_id) REFERENCES Venues(id)); INSERT INTO CulturalHeritage (venue_id, cultural_significance, last_audit) VALUES (1, 'UNESCO World Heritage Site', '2022-01-01'); CREATE TABLE Revenue (venue_id INT PRIMARY KEY, revenue_generated DECIMAL(10, 2), last_audit DATETIME, FOREIGN KEY (venue_id) REFERENCES Venues(id)); INSERT INTO Revenue (venue_id, revenue_generated, last_audit) VALUES (1, 5000000.00, '2022-04-01'); | Create a view that displays the venue name, cultural significance, and revenue generated for venues in India. | CREATE VIEW VenueInfo AS SELECT v.name, c.cultural_significance, r.revenue_generated FROM Venues v INNER JOIN CulturalHeritage c ON v.id = c.venue_id INNER JOIN Revenue r ON v.id = r.venue_id WHERE v.country = 'India'; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, name TEXT, category TEXT, price FLOAT); INSERT INTO products (product_id, name, category, price) VALUES (1, 'Dress', 'Fair Trade', 80.0); INSERT INTO products (product_id, name, category, price) VALUES (2, 'Shirt', 'Fair Trade', 60.0); | What is the most expensive product in the 'Fair Trade' category? | SELECT name, price FROM products WHERE category = 'Fair Trade' ORDER BY price DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE public_schools (id INT, name VARCHAR(100), type VARCHAR(20), location VARCHAR(50)); INSERT INTO public_schools VALUES (1, 'School A', 'Public', 'California'); INSERT INTO public_schools VALUES (2, 'School B', 'Public', 'California'); CREATE TABLE private_schools (id INT, name VARCHAR(100), type VARCHAR(20), location VARCHAR(50)); INSERT INTO private_schools VALUES (1, 'School C', 'Private', 'California'); INSERT INTO private_schools VALUES (2, 'School D', 'Private', 'California'); | What is the total number of public schools and private schools in the state of California, grouped by school type? | SELECT COUNT(ps.id) AS public_school_count, COUNT(pr.id) AS private_school_count FROM public_schools ps JOIN private_schools pr ON ps.location = pr.location WHERE ps.location = 'California'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Products (ProductID int, ProductName varchar(50), Category varchar(50), Rating float, Country varchar(50)); INSERT INTO Products (ProductID, ProductName, Category, Rating, Country) VALUES (1, 'Lipstick A', 'Lipstick', 4.2, 'USA'), (2, 'Lipstick B', 'Lipstick', 4.5, 'Canada'), (3, 'Lipstick C', 'Lipstick', 4.7, 'Mexico'); | Which country has the highest average rating for lipsticks? | SELECT Country, AVG(Rating) as AvgRating FROM Products WHERE Category = 'Lipstick' GROUP BY Country ORDER BY AvgRating DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE legal_aid_practices (provider_id INT, practice_id INT); CREATE TABLE restorative_practices (practice_id INT, practice VARCHAR(255)); | Which restorative practices are available across all legal aid providers in the 'legal_aid_practices' table? | SELECT practice FROM restorative_practices WHERE practice_id IN (SELECT practice_id FROM legal_aid_practices GROUP BY practice_id HAVING COUNT(DISTINCT provider_id) = (SELECT COUNT(DISTINCT provider_id) FROM legal_aid_practices)); | gretelai_synthetic_text_to_sql |
CREATE TABLE recycling_rates (id INT, region VARCHAR(50), year INT, recycling_rate DECIMAL(5,2)); INSERT INTO recycling_rates (id, region, year, recycling_rate) VALUES (1, 'North', 2020, 0.63), (2, 'South', 2020, 0.59), (3, 'East', 2020, 0.46), (4, 'West', 2020, 0.71), (5, 'North', 2019, 0.60), (6, 'South', 2019, 0.57), (7, 'East', 2019, 0.44), (8, 'West', 2019, 0.69); | Update recycling rates for the North region to 65% for 2022. | UPDATE recycling_rates SET recycling_rate = 0.65 WHERE region = 'North' AND year = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists wells (well_id int, region varchar(50), production_year int, oil_production int, gas_production int);INSERT INTO wells (well_id, region, production_year, oil_production, gas_production) VALUES (1, 'Niobrara', 2020, 100000, 450000), (2, 'Niobrara', 2019, 90000, 400000), (3, 'Niobrara', 2018, 80000, 350000); | List all the wells in the Niobrara region with their respective production figures for 2020 | SELECT * FROM wells WHERE region = 'Niobrara' AND production_year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE mining_operations (id INT, name VARCHAR(50), region VARCHAR(50)); CREATE TABLE environmental_impact (operation_id INT, score INT); INSERT INTO mining_operations (id, name, region) VALUES (1, 'Mine A', 'Southern'), (2, 'Mine B', 'Northern'); INSERT INTO environmental_impact (operation_id, score) VALUES (1, 75), (1, 80), (2, 60); | List all mining operations in the Northern region with their associated environmental impact scores, if any. | SELECT mo.name, ei.score FROM mining_operations mo LEFT JOIN environmental_impact ei ON mo.id = ei.operation_id WHERE mo.region = 'Northern'; | gretelai_synthetic_text_to_sql |
CREATE TABLE energy_storage (country VARCHAR(20), installed_capacity INT); INSERT INTO energy_storage (country, installed_capacity) VALUES ('China', 120000), ('India', 35000), ('Japan', 28000); | What is the total installed capacity of energy storage in China, India, and Japan? | SELECT SUM(installed_capacity) FROM energy_storage WHERE country IN ('China', 'India', 'Japan'); | gretelai_synthetic_text_to_sql |
CREATE TABLE customers (id INT, name VARCHAR(50), region VARCHAR(20), assets DECIMAL(10,2)); INSERT INTO customers (id, name, region, assets) VALUES (1, 'John Doe', 'Southwest', 50000.00), (2, 'Jane Smith', 'Northeast', 75000.00), (3, 'Kofi Anan', 'Africa', 80000.00), (4, 'Ngozi Okonjo-Iweala', 'Africa', 90000.00); | What is the total assets value for customers in 'Africa'? | SELECT SUM(assets) FROM customers WHERE region = 'Africa'; | gretelai_synthetic_text_to_sql |
CREATE TABLE students (id INT, name VARCHAR(50), mental_health_score INT, grade INT); INSERT INTO students (id, name, mental_health_score, grade) VALUES (1, 'John Doe', 65, 6); | Students with average mental health and low grades | SELECT name FROM students WHERE mental_health_score BETWEEN 60 AND 79 INTERSECT SELECT name FROM students WHERE grade < 7; | gretelai_synthetic_text_to_sql |
CREATE TABLE regions (region_id INT PRIMARY KEY, region_name VARCHAR(50)); CREATE TABLE frauds (fraud_id INT PRIMARY KEY, region_id INT, amount DECIMAL(10, 2)); | Identify top 3 regions with highest credit card fraud amounts | SELECT r.region_name, SUM(f.amount) AS total_fraud_amount FROM regions r JOIN frauds f ON r.region_id = f.region_id GROUP BY r.region_id ORDER BY total_fraud_amount DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE Claims (PolicyID INT, ClaimAmount DECIMAL(10, 2), City VARCHAR(20)); INSERT INTO Claims (PolicyID, ClaimAmount, City) VALUES (1, 500.00, 'CityX'), (2, 1000.00, 'CityY'); | Show all claims for policyholders living in 'CityX' and 'CityY'. | SELECT * FROM Claims WHERE City IN ('CityX', 'CityY'); | gretelai_synthetic_text_to_sql |
CREATE TABLE TalentAcquisition (ApplicantID INT PRIMARY KEY, JobTitle VARCHAR(30), Department VARCHAR(20), ApplicationDate DATE); | Insert records into the TalentAcquisition table | INSERT INTO TalentAcquisition (ApplicantID, JobTitle, Department, ApplicationDate) VALUES (1, 'Software Engineer', 'Engineering', '2022-01-01'), (2, 'Data Analyst', 'Marketing', '2022-02-15'), (3, 'Project Manager', 'Operations', '2022-03-05'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Infections (InfectionID INT, Age INT, Gender VARCHAR(10), City VARCHAR(20), Disease VARCHAR(20)); INSERT INTO Infections (InfectionID, Age, Gender, City, Disease) VALUES (1, 30, 'Male', 'Los Angeles', 'Tuberculosis'); | List the top 5 cities with the highest Tuberculosis infection rate. | SELECT City, COUNT(*) as InfectionCount, (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM Infections)) as Rate FROM Infections WHERE Disease = 'Tuberculosis' GROUP BY City ORDER BY Rate DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE movies (id INT, title VARCHAR(100), release_year INT, production_budget INT, country VARCHAR(50)); INSERT INTO movies (id, title, release_year, production_budget, country) VALUES (1, 'MovieA', 2010, 20000000, 'France'); INSERT INTO movies (id, title, release_year, production_budget, country) VALUES (2, 'MovieB', 2012, 25000000, 'Germany'); | What's the average production budget for movies released in France and Germany between 2010 and 2015? | SELECT AVG(production_budget) FROM movies WHERE release_year BETWEEN 2010 AND 2015 AND country IN ('France', 'Germany'); | gretelai_synthetic_text_to_sql |
CREATE TABLE virtual_tour_emissions (id INT, name TEXT, continent TEXT, co2_emissions INT, tour_date DATE); INSERT INTO virtual_tour_emissions (id, name, continent, co2_emissions, tour_date) VALUES (1, 'European Capitals', 'Europe', 120, '2021-04-12'), (2, 'Asian Wonders', 'Asia', 150, '2021-09-23'), (3, 'American Landmarks', 'North America', 180, '2021-12-31'); | Calculate the total CO2 emissions by virtual tours for each continent in 2021. | SELECT continent, SUM(co2_emissions) as total_emissions FROM virtual_tour_emissions WHERE YEAR(tour_date) = 2021 GROUP BY continent; | gretelai_synthetic_text_to_sql |
CREATE TABLE Music_Artists (id INT, name VARCHAR(100), genre VARCHAR(50), country VARCHAR(50)); INSERT INTO Music_Artists (id, name, genre, country) VALUES (1, 'Talyor Swift', 'Country', 'United States'); INSERT INTO Music_Artists (id, name, genre, country) VALUES (2, 'BTS', 'K-Pop', 'South Korea'); | Delete all records from the 'Music_Artists' table with a country of 'United States'. | DELETE FROM Music_Artists WHERE country = 'United States'; | gretelai_synthetic_text_to_sql |
CREATE TABLE songs (id INT, title TEXT, duration FLOAT, genre TEXT); INSERT INTO songs (id, title, duration, genre) VALUES (1, 'Song 1', 3.5, 'Pop'), (2, 'Song 2', 4.2, 'Rock'), (3, 'Song 3', 2.9, 'Pop'); | What is the average duration of pop songs? | SELECT AVG(duration) FROM songs WHERE genre = 'Pop'; | gretelai_synthetic_text_to_sql |
CREATE TABLE cases (case_id INT, category VARCHAR(50), billing_amount INT); INSERT INTO cases (case_id, category, billing_amount) VALUES (1, 'Personal Injury', 5000), (2, 'Civil Litigation', 7000), (3, 'Personal Injury', 6000), (4, 'Civil Litigation', 8000); | Count the number of cases in the 'Personal Injury' and 'Civil Litigation' categories | SELECT COUNT(*), category FROM cases WHERE category IN ('Personal Injury', 'Civil Litigation') GROUP BY category; | gretelai_synthetic_text_to_sql |
CREATE TABLE regulatory_compliance (compliance_id INT, regulation_name VARCHAR(50), compliance_status VARCHAR(50), compliance_date DATE); | Remove a record from the regulatory_compliance table | DELETE FROM regulatory_compliance WHERE compliance_id = 22222; | gretelai_synthetic_text_to_sql |
CREATE TABLE safety_incidents (id INT, plant_location VARCHAR(50), incident_date DATE); CREATE TABLE plant_locations (id INT, name VARCHAR(50), country VARCHAR(50)); | How many safety incidents were recorded in the chemical manufacturing plant located in Texas in the past year? | SELECT COUNT(*) FROM safety_incidents JOIN plant_locations ON safety_incidents.plant_location = plant_locations.name WHERE plant_locations.country = 'Texas' AND incident_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR); | gretelai_synthetic_text_to_sql |
CREATE TABLE broadband_speeds (speed_test_id INT, city VARCHAR(20), median_speed INT); | Which cities have the slowest median broadband speeds? | SELECT city, AVG(median_speed) AS avg_median_speed FROM broadband_speeds GROUP BY city ORDER BY avg_median_speed ASC; | gretelai_synthetic_text_to_sql |
CREATE TABLE cases (case_id INT, attorney_name TEXT); INSERT INTO cases (case_id, attorney_name) VALUES (1, 'Alice Smith'), (2, 'Bob Johnson'), (3, 'Bob Johnson'), (4, 'Charlie Brown'); | What is the total number of cases handled by attorney 'Bob Johnson'? | SELECT COUNT(*) FROM cases WHERE attorney_name = 'Bob Johnson'; | gretelai_synthetic_text_to_sql |
CREATE TABLE shipments (id INT, shipment_type VARCHAR(10), revenue DECIMAL(10,2)); INSERT INTO shipments (id, shipment_type, revenue) VALUES (1, 'domestic', 500.00), (2, 'international', 800.00); | What is the total revenue generated from domestic shipments? | SELECT SUM(revenue) FROM shipments WHERE shipment_type = 'domestic'; | gretelai_synthetic_text_to_sql |
CREATE TABLE projects (project_id INT, project_name VARCHAR(255), completion_year INT, region VARCHAR(255)); INSERT INTO projects (project_id, project_name, completion_year, region) VALUES (1, 'Solar Farm', 2021, 'Asia'), (2, 'Water Purification Plant', 2021, 'Africa'), (3, 'Education Center', 2021, 'South America'); | How many projects were successfully completed per region in 2021? | SELECT region, COUNT(project_id) as completed_projects FROM projects WHERE completion_year = 2021 AND completion_status = 'Successful' GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE inclusive_housing_policies (policy_id INT); INSERT INTO inclusive_housing_policies (policy_id) VALUES (1), (2), (3), (4); | How many inclusive housing policies are there in total? | SELECT COUNT(*) FROM inclusive_housing_policies; | gretelai_synthetic_text_to_sql |
CREATE TABLE dance_performances (id INT, event_name VARCHAR(255), attendee_age INT); CREATE TABLE age_groups (id INT, age_range VARCHAR(255), lower_limit INT, upper_limit INT); | What is the total number of attendees for dance performances by age group? | SELECT age_groups.age_range, COUNT(dance_performances.attendee_age) as total_attendees FROM dance_performances INNER JOIN age_groups ON dance_performances.attendee_age BETWEEN age_groups.lower_limit AND age_groups.upper_limit GROUP BY age_groups.age_range; | gretelai_synthetic_text_to_sql |
CREATE TABLE emergency_incidents (id INT, incident_type VARCHAR(255), latitude FLOAT, longitude FLOAT, report_date DATE, location VARCHAR(255)); INSERT INTO emergency_incidents (id, incident_type, latitude, longitude, report_date, location) VALUES (1, 'Medical Emergency', 37.7749, -122.4194, '2020-01-01', 'Downtown San Francisco'); | What is the total number of emergency incidents reported in the downtown area of San Francisco in the year 2020? | SELECT COUNT(*) FROM emergency_incidents JOIN location_data ON emergency_incidents.location = location_data.id WHERE location_data.name = 'Downtown San Francisco' AND YEAR(report_date) = 2020 AND incident_type = 'Emergency'; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_health_centers (country VARCHAR(20), num_centers INT); INSERT INTO community_health_centers (country, num_centers) VALUES ('Nigeria', 500), ('South Africa', 400); | What is the total number of community health centers in Nigeria and South Africa? | SELECT SUM(num_centers) FROM community_health_centers WHERE country IN ('Nigeria', 'South Africa'); | gretelai_synthetic_text_to_sql |
CREATE TABLE sustainable_practices (employee_id INT, first_name VARCHAR(50), last_name VARCHAR(50), gender VARCHAR(10), position VARCHAR(50), hours_worked INT); INSERT INTO sustainable_practices (employee_id, first_name, last_name, gender, position, hours_worked) VALUES (3, 'Alice', 'Johnson', 'Female', 'Analyst', 30); INSERT INTO sustainable_practices (employee_id, first_name, last_name, gender, position, hours_worked) VALUES (4, 'Bob', 'Williams', 'Male', 'Technician', 35); INSERT INTO sustainable_practices (employee_id, first_name, last_name, gender, position, hours_worked) VALUES (8, 'Olga', 'Ivanova', 'Female', 'Technician', 40); INSERT INTO sustainable_practices (employee_id, first_name, last_name, gender, position, hours_worked) VALUES (9, 'Sara', 'Lopez', 'Female', 'Analyst', 35); | How many female employees work in the 'sustainable_practices' table? | SELECT COUNT(*) FROM sustainable_practices WHERE gender = 'Female'; | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists conservation_efforts (id INT, name TEXT, location TEXT); | How many conservation efforts exist in 'Mediterranean Sea'? | SELECT COUNT(*) FROM conservation_efforts WHERE location = 'Mediterranean Sea'; | gretelai_synthetic_text_to_sql |
CREATE TABLE mining_impact (id INT PRIMARY KEY, location VARCHAR(255), water_usage INT, air_pollution INT, land_degradation INT); | Get the total water usage for mining in 'Baotou' | SELECT SUM(water_usage) FROM mining_impact WHERE location = 'Baotou'; | gretelai_synthetic_text_to_sql |
CREATE TABLE businesses(business_id INT, business_name VARCHAR(50), country VARCHAR(50), has_virtual_tours BOOLEAN); CREATE VIEW local_businesses AS SELECT business_id, business_name, country FROM businesses WHERE business_name LIKE '%local%'; | What is the percentage of local businesses in Brazil that have implemented virtual tourism? | SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM local_businesses)) AS percentage FROM local_businesses WHERE has_virtual_tours = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE biodiversity (id INT, species VARCHAR(255), population INT); INSERT INTO biodiversity (id, species, population) VALUES (1, 'Polar Bear', 5000), (2, 'Arctic Fox', 10000), (3, 'Caribou', 20000); | What is the maximum population of species in the 'biodiversity' table for those with a population greater than 10000? | SELECT MAX(population) FROM biodiversity WHERE population > 10000; | gretelai_synthetic_text_to_sql |
CREATE TABLE Mines (MineID INT, MineName TEXT, Location TEXT, Employees INT); CREATE TABLE ExtractionData (ExtractionDataID INT, MineID INT, Date DATE, Mineral TEXT, Quantity INT); | What is the average labor productivity (measured in units of mineral extracted per employee) for each mine? | SELECT Mines.MineName, AVG(Quantity/Employees) FROM Mines INNER JOIN ExtractionData ON Mines.MineID = ExtractionData.MineID GROUP BY Mines.MineName; | gretelai_synthetic_text_to_sql |
CREATE TABLE donations (donation_id INT, donation_amount DECIMAL, donation_date DATE, donor_country TEXT); INSERT INTO donations VALUES (1, 500, '2020-01-05', 'USA'); INSERT INTO donations VALUES (2, 600, '2020-02-10', 'Canada'); INSERT INTO donations VALUES (3, 700, '2020-03-15', 'USA'); INSERT INTO donations VALUES (4, 800, '2020-04-20', 'Mexico'); INSERT INTO donations VALUES (5, 900, '2020-05-25', 'Brazil'); | What is the total donation amount per country in 2020? | SELECT donor_country, SUM(donation_amount) as total_donation FROM donations WHERE donation_date >= '2020-01-01' AND donation_date < '2021-01-01' GROUP BY donor_country; | gretelai_synthetic_text_to_sql |
CREATE TABLE CybersecurityIncidents (IncidentID INT, IncidentName VARCHAR(255), IncidentDate DATE);CREATE TABLE AgencyIncidents (AgencyID INT, IncidentID INT, AgencyName VARCHAR(255));CREATE TABLE Agencies (AgencyID INT, AgencyName VARCHAR(255), Country VARCHAR(255)); | What is the total number of cybersecurity incidents and the corresponding number of countries involved for each year in the past 5 years? | SELECT EXTRACT(YEAR FROM IncidentDate) as Year, COUNT(DISTINCT IncidentID) as IncidentCount, COUNT(DISTINCT A.Country) as CountryCount FROM CybersecurityIncidents CI INNER JOIN AgencyIncidents AI ON CI.IncidentID = AI.IncidentID INNER JOIN Agencies A ON AI.AgencyID = A.AgencyID WHERE IncidentDate BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 5 YEAR) AND CURRENT_DATE GROUP BY Year; | gretelai_synthetic_text_to_sql |
CREATE TABLE crypto_transactions (transaction_id INT, digital_asset VARCHAR(20), transaction_amount DECIMAL(10,2), transaction_time DATETIME); | What is the total transaction amount for each digital asset in the 'crypto_transactions' table, ordered by the total transaction amount in descending order? | SELECT digital_asset, SUM(transaction_amount) as total_transaction_amount FROM crypto_transactions GROUP BY digital_asset ORDER BY total_transaction_amount DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_finance (id INT PRIMARY KEY, source VARCHAR(255), recipient VARCHAR(255), amount FLOAT, date DATE); | Insert a new climate finance record for the African Development Bank providing 8 million dollars to South Africa in 2022. | INSERT INTO climate_finance (id, source, recipient, amount, date) VALUES (1, 'African Development Bank', 'South Africa', 8000000, '2022-01-01'); | gretelai_synthetic_text_to_sql |
CREATE TABLE departments (id INT, name VARCHAR(255), head_count INT); INSERT INTO departments (id, name, head_count) VALUES (1, 'Engineering', 250), (2, 'Marketing', 180), (3, 'Sales', 120); CREATE TABLE employees (id INT, name VARCHAR(255), gender VARCHAR(10), department_id INT); INSERT INTO employees (id, name, gender, department_id) VALUES (1, 'John Doe', 'Male', 1), (2, 'Jane Smith', 'Female', 1), (3, 'Mike Johnson', 'Male', 2), (4, 'Alice Williams', 'Female', 2), (5, 'Bob Brown', 'Male', 3), (6, 'Claire Johnson', 'Female', 3); | Find the number of male and female employees in each department | SELECT department_id AS id, gender, COUNT(*) as head_count FROM employees GROUP BY department_id, gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE RecyclingRates (country VARCHAR(50), year INT, paper_recycling_rate FLOAT); | What is the minimum recycling rate for paper waste in Brazil and Argentina? | SELECT MIN(paper_recycling_rate) FROM RecyclingRates WHERE country IN ('Brazil', 'Argentina'); | gretelai_synthetic_text_to_sql |
CREATE TABLE spacecraft (craft_name VARCHAR(50), manufacturer VARCHAR(50), first_flight DATE, mass_kg FLOAT, manufacturer_location VARCHAR(50)); | What is the average mass of spacecraft manufactured by companies based in Asia? | SELECT AVG(mass_kg) AS avg_mass FROM spacecraft WHERE manufacturer_location LIKE '%Asia%'; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists funding; USE funding; CREATE TABLE if not exists research_funding (id INT, project_id INT, year INT, funding DECIMAL(10, 2)); INSERT INTO research_funding (id, project_id, year, funding) VALUES (1, 1, 2021, 5000000.00), (2, 2, 2020, 3000000.00), (3, 3, 2021, 6000000.00), (4, 4, 2020, 4000000.00); | What is the total funding for genetic research projects in 2021? | SELECT SUM(funding) FROM funding.research_funding WHERE year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE monitoring_stations (station_id INT, station_name VARCHAR(50), country VARCHAR(50), operational_cost FLOAT); INSERT INTO monitoring_stations (station_id, station_name, country, operational_cost) VALUES (1, 'Station A', 'Australia', 50000.0), (2, 'Station B', 'New Zealand', 60000.0), (3, 'Station C', 'Australia', 55000.0); | What is the average operational cost of monitoring stations in the 'monitoring_stations' table, grouped by country? | SELECT country, AVG(operational_cost) FROM monitoring_stations GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE projects (id INT PRIMARY KEY, name VARCHAR(50), location VARCHAR(50), budget FLOAT); INSERT INTO projects (id, name, location, budget) VALUES (1, 'Solar Farm Construction', 'Brazil', 900000.00); INSERT INTO projects (id, name, location, budget) VALUES (2, 'Wind Turbine Installation', 'Canada', 750000.00); | What are the names and locations of projects with a budget greater than 800000.00 and less than 1000000.00? | SELECT projects.name, projects.location, projects.budget FROM projects WHERE projects.budget > 800000.00 AND projects.budget < 1000000.00; | gretelai_synthetic_text_to_sql |
CREATE TABLE wells (id INT, name VARCHAR(255), location VARCHAR(255), production_quantity INT); INSERT INTO wells (id, name, location, production_quantity) VALUES (1, 'Well A', 'North Sea', 1000), (2, 'Well B', 'Gulf of Mexico', 2000), (3, 'Well C', 'North Sea', 1500); | What is the minimum production quantity for wells located in the 'Gulf of Mexico'? | SELECT MIN(production_quantity) FROM wells WHERE location = 'Gulf of Mexico'; | gretelai_synthetic_text_to_sql |
CREATE TABLE daily_security_incidents (id INT, sector VARCHAR(255), incident_date DATE); INSERT INTO daily_security_incidents (id, sector, incident_date) VALUES (1, 'technology', '2021-01-01'); | What is the maximum number of security incidents that occurred in a single day in the technology sector in the last quarter? | SELECT MAX(counts) FROM (SELECT COUNT(*) AS counts FROM daily_security_incidents WHERE sector = 'technology' AND incident_date >= DATE_SUB(CURDATE(), INTERVAL 3 MONTH) GROUP BY incident_date) AS subquery; | gretelai_synthetic_text_to_sql |
CREATE TABLE health_centers (id INT, name TEXT, location TEXT, capacity INT); INSERT INTO health_centers (id, name, location, capacity) VALUES (1, 'Health Center A', 'Rural Palau', 50); INSERT INTO health_centers (id, name, location, capacity) VALUES (7, 'Health Center H', 'Rural Palau', 60); | What is the capacity of rural health centers in Palau? | SELECT capacity FROM health_centers WHERE location = 'Rural Palau'; | gretelai_synthetic_text_to_sql |
CREATE TABLE graduate_students (id INT, name VARCHAR(50), department VARCHAR(50)); INSERT INTO graduate_students (id, name, department) VALUES (1, 'Charlie', 'Computer Science'); INSERT INTO graduate_students (id, name, department) VALUES (2, 'Dana', 'Electrical Engineering'); CREATE TABLE publications (id INT, graduate_student_id INT, title VARCHAR(100), citations INT); INSERT INTO publications (id, graduate_student_id, title, citations) VALUES (1, 1, 'Paper1', 1200); INSERT INTO publications (id, graduate_student_id, title, citations) VALUES (2, 2, 'Paper2', 800); | Count the number of publications by graduate students in the Computer Science department with more than 1000 citations. | SELECT COUNT(*) FROM publications p JOIN graduate_students gs ON p.graduate_student_id = gs.id WHERE gs.department = 'Computer Science' AND p.citations > 1000; | gretelai_synthetic_text_to_sql |
CREATE TABLE deliveries (delivery_id INT, delivery_date DATE, warehouse_id INT); INSERT INTO deliveries (delivery_id, delivery_date, warehouse_id) VALUES (1, '2021-11-01', 3), (2, '2021-11-03', 3), (3, '2021-11-05', 1); | What is the earliest delivery date for shipments from warehouse 3? | SELECT MIN(delivery_date) FROM deliveries WHERE warehouse_id = 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE daily_sales (menu_item VARCHAR(255), sales DECIMAL(10,2), date DATE); INSERT INTO daily_sales (menu_item, sales, date) VALUES ('Bruschetta', 200.00, '2022-01-01'), ('Spaghetti Bolognese', 350.00, '2022-01-01'), ('Cheesecake', 150.00, '2022-01-01'); | What is the average daily sales for each menu item? | SELECT menu_item, AVG(sales) FROM daily_sales GROUP BY menu_item; | gretelai_synthetic_text_to_sql |
CREATE TABLE excavation_sites (id INT, site_name VARCHAR(50), num_artifacts INT, total_funding DECIMAL(10,2)); | How many artifacts were excavated in total, per site? | SELECT site_name, SUM(num_artifacts) as total_artifacts FROM excavation_sites GROUP BY site_name | gretelai_synthetic_text_to_sql |
CREATE TABLE MilitaryTech (id INT PRIMARY KEY, name VARCHAR(255), description TEXT, year_developed INT, developer_country VARCHAR(255)); INSERT INTO MilitaryTech (id, name, description, year_developed, developer_country) VALUES (1, 'F-15', '...', 1976, 'USA'); | Identify military technologies developed before 1990 and their developers | SELECT m.name, m.year_developed, m.developer_country, c.country_name FROM MilitaryTech m INNER JOIN Country c ON m.developer_country = c.country_code WHERE m.year_developed < 1990; | gretelai_synthetic_text_to_sql |
CREATE TABLE organization (org_id INT PRIMARY KEY, org_name VARCHAR(255), country VARCHAR(50)); CREATE TABLE model (model_id INT PRIMARY KEY, org_id INT, safety_score INT); INSERT INTO organization (org_id, org_name, country) VALUES (1, 'OrgA', 'USA'), (2, 'OrgB', 'Canada'), (3, 'OrgC', 'Mexico'), (4, 'OrgD', 'Brazil'), (5, 'OrgE', 'Argentina'); INSERT INTO model (model_id, org_id, safety_score) VALUES (101, 1, 85), (102, 1, 90), (201, 2, 70), (202, 2, 75), (203, 2, 80), (301, 3, 95), (302, 3, 92), (401, 4, 75), (402, 4, 85), (501, 5, 90), (502, 5, 95); | Find the number of models developed and average safety score for each country? | SELECT o.country, COUNT(m.model_id) as num_models, AVG(m.safety_score) as avg_safety_score FROM organization o JOIN model m ON o.org_id = m.org_id GROUP BY o.country; | gretelai_synthetic_text_to_sql |
CREATE TABLE movie_budgets (title VARCHAR(255), genre VARCHAR(50), budget DECIMAL(10,2)); INSERT INTO movie_budgets (title, genre, budget) VALUES ('Movie7', 'Horror', 2000000.00), ('Movie8', 'Sci-Fi', 3000000.00), ('Movie9', 'Horror', 2500000.00); | What is the total production budget for horror and sci-fi movies? | SELECT SUM(budget) as total_budget FROM movie_budgets WHERE genre IN ('Horror', 'Sci-Fi'); | gretelai_synthetic_text_to_sql |
CREATE TABLE auto_show_information (show_id INT, show_name VARCHAR(50), show_date DATE, show_location VARCHAR(50)); | Update the date of an existing auto show record in the auto_show_information table. | UPDATE auto_show_information SET show_date = '2023-04-15' WHERE show_id = 456; | gretelai_synthetic_text_to_sql |
CREATE TABLE teacher_certifications (teacher_id INT, certification_name VARCHAR(50)); | Update the 'teacher_certifications' table to add a new certification for a teacher with 'teacher_id' 123. | UPDATE teacher_certifications SET certification_name = 'New Certification' WHERE teacher_id = 123; | gretelai_synthetic_text_to_sql |
CREATE TABLE initiatives (id INT, name VARCHAR(255), launch_date DATE, type VARCHAR(255)); INSERT INTO initiatives (id, name, launch_date, type) VALUES (1, 'Project A', '2020-01-01', 'Social Good'), (2, 'Project B', '2019-12-01', 'Social Good'), (3, 'Project C', '2021-03-15', 'Social Good'), (4, 'Project D', '2020-06-20', 'Social Good'); | How many technology initiatives were launched in the year 2020 that are related to social good? | SELECT COUNT(*) FROM initiatives WHERE EXTRACT(YEAR FROM launch_date) = 2020 AND type = 'Social Good'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Garments(id INT, store VARCHAR(20), retail_price DECIMAL(5,2)); INSERT INTO Garments(id, store, retail_price) VALUES (1, 'Sustainable_Outlet', 120.00), (2, 'Sustainable_Outlet', 75.00), (3, 'Eco_Friendly', 50.00); | Update the retail price of garments in the 'Sustainable_Outlet' store to 10% lower than the current price. | UPDATE Garments SET retail_price = retail_price * 0.9 WHERE store = 'Sustainable_Outlet'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ethics_violations (id INT, violation VARCHAR(50), continent VARCHAR(50), date DATE); INSERT INTO ethics_violations (id, violation, continent, date) VALUES (1, 'Plagiarism', 'Africa', '2022-01-01'); INSERT INTO ethics_violations (id, violation, continent, date) VALUES (2, 'Libel', 'Asia', '2022-01-02'); | What is the total number of media ethics violations in Africa and Asia? | SELECT continent, COUNT(*) FROM ethics_violations WHERE continent IN ('Africa', 'Asia') GROUP BY continent; | gretelai_synthetic_text_to_sql |
CREATE TABLE production (element VARCHAR(10), country VARCHAR(20), quantity INT, year INT); INSERT INTO production (element, country, quantity, year) VALUES ('Gadolinium', 'Canada', 2500, 2016), ('Gadolinium', 'Canada', 2700, 2017), ('Gadolinium', 'Canada', 2900, 2018), ('Gadolinium', 'Canada', 3100, 2019), ('Gadolinium', 'Canada', 3300, 2020), ('Gadolinium', 'Canada', 3500, 2021), ('Gadolinium', 'India', 1500, 2016), ('Gadolinium', 'India', 1700, 2017), ('Gadolinium', 'India', 1900, 2018), ('Gadolinium', 'India', 2100, 2019), ('Gadolinium', 'India', 2300, 2020), ('Gadolinium', 'India', 2500, 2021); | What is the average quantity of 'Gadolinium' produced annually by 'Canada' and 'India'? | SELECT AVG(quantity) FROM production WHERE (element = 'Gadolinium' AND country = 'Canada') OR (element = 'Gadolinium' AND country = 'India') GROUP BY year; | gretelai_synthetic_text_to_sql |
CREATE TABLE user_interactions (user_id INT, interaction_type VARCHAR(50), user_age INT, user_gender VARCHAR(50), user_location VARCHAR(50)); INSERT INTO user_interactions (user_id, interaction_type, user_age, user_gender, user_location) VALUES (1, 'engaged_content', 30, 'female', 'London'), (2, 'clicked_ad', 25, 'male', 'Paris'), (3, 'engaged_content', 35, 'non-binary', 'Berlin'), (4, 'clicked_ad', 40, 'male', 'Madrid'), (5, 'engaged_content', 28, 'female', 'Rome'), (6, 'clicked_ad', 32, 'non-binary', 'Dublin'); | Determine the age, gender, and location of users who have engaged with content about climate change but have not clicked on any ads about fast fashion. | SELECT user_age, user_gender, user_location FROM user_interactions WHERE interaction_type = 'engaged_content' AND user_id NOT IN (SELECT user_id FROM user_interactions WHERE interaction_type = 'clicked_ad' AND clicked_ads = 'fast fashion'); | 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.