context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28 values |
|---|---|---|---|
CREATE TABLE financial_wellbeing (id INT, customer_name VARCHAR(50), region VARCHAR(50), score INT, year INT); INSERT INTO financial_wellbeing (id, customer_name, region, score, year) VALUES (1, 'Marco', 'Europe', 6, 2022), (2, 'Elena', 'Europe', 7, 2022); | What is the average financial wellbeing score for customers in Europe in 2022? | SELECT AVG(score) FROM financial_wellbeing WHERE region = 'Europe' AND year = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE Flights (FlightID INT, FlightNumber VARCHAR(50), Departure VARCHAR(50), Arrival VARCHAR(50), DepartureDate DATE, ArrivalDate DATE); INSERT INTO Flights (FlightID, FlightNumber, Departure, Arrival, DepartureDate, ArrivalDate) VALUES (1, 'FL101', 'NYC', 'LAX', '2022-02-01', '2022-02-04'); | Identify flights that have a delay of more than 24 hours. | SELECT FlightID, FlightNumber, Departure, Arrival, DepartureDate, (CASE WHEN DATEDIFF(ArrivalDate, DepartureDate) > 2 THEN 'Late' ELSE 'On-Time' END) AS DelayStatus FROM Flights; | gretelai_synthetic_text_to_sql |
CREATE TABLE ConstructionPermits (PermitID INT, City TEXT, IssueDate DATE); INSERT INTO ConstructionPermits (PermitID, City, IssueDate) VALUES (101, 'Seattle', '2023-01-01'), (102, 'Portland', '2023-01-02'), (103, 'Seattle', '2023-01-03'); | What is the total number of construction permits issued in the city of Seattle, WA? | SELECT COUNT(PermitID) FROM ConstructionPermits WHERE City = 'Seattle'; | gretelai_synthetic_text_to_sql |
CREATE TABLE CountryScores (country_id INT, region VARCHAR(20), year INT, score INT); INSERT INTO CountryScores (country_id, region, year, score) VALUES (1, 'Africa', 2018, 70); INSERT INTO CountryScores (country_id, region, year, score) VALUES (2, 'Africa', 2018, 80); INSERT INTO CountryScores (country_id, region, year, score) VALUES (3, 'Asia', 2018, 60); INSERT INTO CountryScores (country_id, region, year, score) VALUES (4, 'Asia', 2018, 65); INSERT INTO CountryScores (country_id, region, year, score) VALUES (5, 'Africa', 2020, 75); INSERT INTO CountryScores (country_id, region, year, score) VALUES (6, 'Africa', 2020, 80); INSERT INTO CountryScores (country_id, region, year, score) VALUES (7, 'Asia', 2020, 63); INSERT INTO CountryScores (country_id, region, year, score) VALUES (8, 'Asia', 2020, 68); | What is the average sustainable tourism score for African countries in 2020? | SELECT AVG(score) FROM CountryScores WHERE region = 'Africa' AND year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE trips_data (id INT, trip_type VARCHAR(20), trip_count INT); | What is the percentage of trips made using multimodal transportation in 'trips_data' table? | SELECT 100.0 * SUM(CASE WHEN trip_type = 'Multimodal' THEN trip_count ELSE 0 END) / SUM(trip_count) FROM trips_data; | gretelai_synthetic_text_to_sql |
CREATE TABLE environmental_impact (id INT, mine_id INT, year INT, co2_emissions INT, water_usage INT); INSERT INTO environmental_impact (id, mine_id, year, co2_emissions, water_usage) VALUES (5, 5, 2019, 30000, 700000); INSERT INTO environmental_impact (id, mine_id, year, co2_emissions, water_usage) VALUES (6, 6, 2020, 35000, 800000); | What is the total water usage for each year in the coal mining industry? | SELECT YEAR(e.year) AS year, SUM(e.water_usage) AS total_water_usage FROM environmental_impact e JOIN mines m ON e.mine_id = m.id WHERE m.mineral = 'Coal' GROUP BY YEAR(e.year); | gretelai_synthetic_text_to_sql |
CREATE TABLE subscribers(id INT, plan_type VARCHAR(10), region VARCHAR(10)); INSERT INTO subscribers VALUES (1, 'unlimited', 'Southeastern'); INSERT INTO subscribers VALUES (2, 'limited', 'Northern'); INSERT INTO subscribers VALUES (3, 'unlimited', 'Northern'); CREATE TABLE plans(plan_type VARCHAR(10), price DECIMAL(5,2)); INSERT INTO plans VALUES ('unlimited', 60.00); INSERT INTO plans VALUES ('limited', 40.00); CREATE TABLE transactions(subscriber_id INT, transaction_date DATE, plan_id INT); INSERT INTO transactions VALUES (1, '2022-07-01', 1); INSERT INTO transactions VALUES (2, '2022-07-01', 2); INSERT INTO transactions VALUES (3, '2022-07-01', 1); | What is the total revenue generated from the mobile subscribers with unlimited data plans in the Southeastern region for the month of July 2022? | SELECT SUM(plans.price) FROM subscribers INNER JOIN transactions ON subscribers.id = transactions.subscriber_id INNER JOIN plans ON subscribers.plan_type = plans.plan_type WHERE subscribers.region = 'Southeastern' AND subscribers.plan_type = 'unlimited' AND MONTH(transactions.transaction_date) = 7 AND YEAR(transactions.transaction_date) = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE restaurants (id INT, name VARCHAR(255), organic BOOLEAN); INSERT INTO restaurants (id, name, organic) VALUES (1, 'Restaurant A', TRUE), (2, 'Restaurant B', FALSE), (3, 'Organic Garden', TRUE); CREATE TABLE dishes (id INT, name VARCHAR(255), type VARCHAR(255), restaurant_id INT); INSERT INTO dishes (id, name, type, restaurant_id) VALUES (1, 'Quinoa Salad', 'vegetarian', 1), (2, 'Chickpea Curry', 'vegetarian', 1), (3, 'Cheeseburger', 'non-vegetarian', 1), (4, 'Pizza Margherita', 'vegetarian', 2), (5, 'Fish and Chips', 'non-vegetarian', 2), (6, 'Vegan Pizza', 'vegetarian', 3); | Identify the unique vegetarian dishes served at organic restaurants. | SELECT d.name FROM dishes d JOIN restaurants r ON d.restaurant_id = r.id WHERE d.type = 'vegetarian' AND r.organic = TRUE GROUP BY d.name; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA arts; CREATE TABLE events (event_id INT, category VARCHAR(255), revenue DECIMAL(10,2), event_date DATE); INSERT INTO events (event_id, category, revenue, event_date) VALUES (1, 'Music', 5000, '2022-01-01'), (2, 'Theater', 7000, '2022-02-15'), (3, 'Dance', 3000, '2022-03-05'); | What is the total revenue by event category in the last quarter? | SELECT category, SUM(revenue) as total_revenue FROM events WHERE event_date >= DATEADD(quarter, -1, GETDATE()) GROUP BY category; | gretelai_synthetic_text_to_sql |
CREATE TABLE security_incidents (id INT, incident_type VARCHAR(50), resolution_time INT); INSERT INTO security_incidents (id, incident_type, resolution_time) VALUES (1, 'Malware', 120), (2, 'Phishing', 180); | What is the average time to resolve a security incident for each incident type? | SELECT incident_type, AVG(resolution_time) as avg_resolution_time FROM security_incidents GROUP BY incident_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE water_consumption(country VARCHAR(20), year INT, operation VARCHAR(20), water_consumption FLOAT); INSERT INTO water_consumption VALUES ('Canada', 2018, 'mining', 25000.5), ('Canada', 2019, 'mining', 26000.3), ('Canada', 2020, 'mining', 27000.2), ('Australia', 2018, 'mining', 30000.0), ('Australia', 2019, 'mining', 31000.0), ('Australia', 2020, 'mining', 32000.0); | Compute the average water consumption per mining operation in Canada and Australia | SELECT country, AVG(water_consumption) FROM water_consumption WHERE country IN ('Canada', 'Australia') AND operation = 'mining' GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE supplier_data (id INT PRIMARY KEY, supplier_name VARCHAR(20)); | How many unique suppliers are there in the 'supplier_data' table? | SELECT COUNT(DISTINCT supplier_name) FROM supplier_data; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artworks (id INT, title VARCHAR(255), artist_name VARCHAR(255), is_sold BOOLEAN); | Delete records for works that were not sold. | DELETE FROM Artworks WHERE is_sold = FALSE; | gretelai_synthetic_text_to_sql |
CREATE TABLE eco_hotels (hotel_id INT, country VARCHAR(20), revenue FLOAT); INSERT INTO eco_hotels (hotel_id, country, revenue) VALUES (1, 'Germany', 7000.2), (2, 'Germany', 8000.1), (3, 'France', 4000.2); CREATE TABLE museum_visits (visit_id INT, country VARCHAR(20), amount FLOAT); INSERT INTO museum_visits (visit_id, country, amount) VALUES (1, 'Germany', 3000), (2, 'Germany', 4000), (3, 'Spain', 2000); | What is the total revenue from eco-friendly hotels and museum visits in Germany? | SELECT SUM(revenue) FROM eco_hotels WHERE country = 'Germany' UNION ALL SELECT SUM(amount) FROM museum_visits WHERE country = 'Germany'; | gretelai_synthetic_text_to_sql |
CREATE TABLE donations (id INT, donor_id INT, program_id INT, amount INT); CREATE TABLE donors (id INT, name TEXT, age INT); CREATE TABLE programs (id INT, name TEXT, location TEXT); INSERT INTO donations VALUES (1, 1, 1, 500), (2, 2, 2, 300), (3, 3, 1, 700), (4, 4, 2, 600); INSERT INTO donors VALUES (1, 'Abdul Rauf', 35), (2, 'Siddique Khan', 40), (3, 'Mohammad Hashim', 45), (4, 'Hamid Karzai', 50); INSERT INTO programs VALUES (1, 'Orphan Support', 'Afghanistan'), (2, 'Refugee Assistance', 'Pakistan'); | What's the total donation amount given to the Orphan Support program in Afghanistan and the Refugee Assistance program in Pakistan? | SELECT SUM(d.amount) FROM donations d INNER JOIN programs p ON d.program_id = p.id WHERE p.name IN ('Orphan Support', 'Refugee Assistance') AND p.location IN ('Afghanistan', 'Pakistan'); | gretelai_synthetic_text_to_sql |
CREATE TABLE AssetAllocation (AssetAllocationID INT, AssetID INT, AssetName VARCHAR(100), AllocationType VARCHAR(50), AllocationValue FLOAT); INSERT INTO AssetAllocation (AssetAllocationID, AssetID, AssetName, AllocationType, AllocationValue) VALUES (5, 3, 'Asset3', 'Security', 0.6), (6, 3, 'Asset3', 'Commodity', 0.4), (7, 4, 'Asset4', 'Security', 0.4), (8, 4, 'Asset4', 'Currency', 0.6); ALTER TABLE AssetAllocation ADD COLUMN AssetID INT; | What is the distribution of digital assets by type, for companies based in Africa? | SELECT AssetType, SUM(AllocationValue) as TotalValue FROM AssetAllocation INNER JOIN DigitalAsset ON AssetAllocation.AssetID = DigitalAsset.AssetID WHERE IssuerLocation = 'Africa' GROUP BY AssetType; | gretelai_synthetic_text_to_sql |
CREATE TABLE mining_sites (id INT, site_name VARCHAR(50), location VARCHAR(50), environmental_score FLOAT); INSERT INTO mining_sites (id, site_name, location, environmental_score) VALUES (1, 'Site A', 'Australia', 82.50); | List the mining sites in the 'Asia-Pacific' region with environmental impact scores above 85. | SELECT site_name, environmental_score FROM mining_sites WHERE location LIKE 'Asia-Pacific' AND environmental_score > 85.00; | gretelai_synthetic_text_to_sql |
CREATE TABLE energy_consumption (id INT, plant_location VARCHAR(50), consumption_date DATE, amount_consumed FLOAT); | What is the total amount of energy consumed by the chemical manufacturing plant located in Ontario in the past month? | SELECT SUM(amount_consumed) FROM energy_consumption WHERE plant_location = 'Ontario' AND consumption_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE teacher_training_subject (teacher_id INT, teacher_name TEXT, subject TEXT, num_workshops INT); | Which teachers have attended the most professional development workshops in each subject area? | SELECT subject, teacher_name, num_workshops, RANK() OVER (PARTITION BY subject ORDER BY num_workshops DESC) as rank FROM teacher_training_subject; | gretelai_synthetic_text_to_sql |
CREATE TABLE EnergySavingsBuilding (building_id INT, city VARCHAR(50), energy_savings INT); | What is the average energy savings per building, in 'EnergySavingsBuilding' table, grouped by city? | SELECT city, AVG(energy_savings) as avg_energy_savings FROM EnergySavingsBuilding GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE ethereum_transactions (transaction_id INT, token_type VARCHAR(255), transaction_value FLOAT, transaction_time DATETIME); | What is the total number of transactions and their respective values for the Ethereum network, grouped by token type, for the last week? | SELECT token_type, SUM(transaction_value) as total_value, COUNT(transaction_id) as total_transactions FROM ethereum_transactions WHERE transaction_time > DATE_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 WEEK) GROUP BY token_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE appetizers (appetizer_name TEXT, category TEXT, quantity_sold INTEGER); INSERT INTO appetizers (appetizer_name, category, quantity_sold) VALUES ('Bruschetta', 'Organic', 25); INSERT INTO appetizers (appetizer_name, category, quantity_sold) VALUES ('Hummus Plate', 'Organic', 30); | What is the most popular appetizer in the 'Organic' category? | SELECT appetizer_name, MAX(quantity_sold) FROM appetizers WHERE category = 'Organic' GROUP BY appetizer_name ORDER BY quantity_sold DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (DonationID INT, DonorID INT, DonationAmount DECIMAL, Sector TEXT); | What is the average amount donated to each sector? | SELECT Sector, AVG(DonationAmount) AS AvgDonation FROM Donations GROUP BY Sector; | gretelai_synthetic_text_to_sql |
CREATE TABLE exports (id INT, cargo_weight INT, country VARCHAR(20), shipment_date DATE); INSERT INTO exports (id, cargo_weight, country, shipment_date) VALUES (1, 12000, 'Mexico', '2021-04-03'); INSERT INTO exports (id, cargo_weight, country, shipment_date) VALUES (2, 8000, 'Mexico', '2021-04-05'); INSERT INTO exports (id, cargo_weight, country, shipment_date) VALUES (3, 15000, 'Japan', '2021-04-07'); | List the countries with more than 10000 kg of exported cargo in April 2021. | SELECT country FROM exports WHERE shipment_date >= '2021-04-01' AND shipment_date < '2021-05-01' GROUP BY country HAVING SUM(cargo_weight) > 10000; | gretelai_synthetic_text_to_sql |
CREATE TABLE vessel_position (id INT, vessel_name VARCHAR(50), position_lat DECIMAL(9,6), position_lon DECIMAL(9,6), timestamp TIMESTAMP); | List the vessels and their last known positions in the 'vessel_position' table. | SELECT vessel_name, position_lat, position_lon FROM vessel_position ORDER BY timestamp DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteers (id INT, name TEXT, last_volunteer_date DATE); INSERT INTO volunteers (id, name, last_volunteer_date) VALUES (1, 'Jim Brown', '2022-01-01'), (2, 'Mary Green', '2022-05-01'); | Delete volunteers who have not volunteered in the last 6 months. | DELETE FROM volunteers WHERE last_volunteer_date < NOW() - INTERVAL '6 months'; | gretelai_synthetic_text_to_sql |
CREATE TABLE regions (id INT PRIMARY KEY, name VARCHAR(255)); INSERT INTO regions (id, name) VALUES (1, 'Europe'); INSERT INTO regions (id, name) VALUES (2, 'North America'); CREATE TABLE species (id INT PRIMARY KEY, name VARCHAR(255)); INSERT INTO species (id, name) VALUES (1, 'Spruce'); INSERT INTO species (id, name) VALUES (2, 'Pine'); INSERT INTO species (id, name) VALUES (3, 'Redwood'); CREATE TABLE carbon_sequestration (region_id INT, species_id INT, sequestration INT); INSERT INTO carbon_sequestration (region_id, species_id, sequestration) VALUES (2, 3, 12000000); | Update the carbon sequestration of 'Redwood' species in North America to 15,000,000. | UPDATE carbon_sequestration SET sequestration = 15000000 WHERE region_id = 2 AND species_id = 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE Threat_Intelligence (id INT PRIMARY KEY, indicator_type VARCHAR(255), indicator VARCHAR(255), date DATE, threat_level VARCHAR(50), patching_delay INT); INSERT INTO Threat_Intelligence (id, indicator_type, indicator, date, threat_level, patching_delay) VALUES (2, 'Software', 'Firefox 80.0', '2021-08-01', 'High', 7); | What is the maximum patching delay for high-risk threat indicators? | SELECT MAX(patching_delay) FROM Threat_Intelligence WHERE threat_level = 'High'; | gretelai_synthetic_text_to_sql |
CREATE TABLE building_permits (permit_id INT, status VARCHAR(20)); | List all building permits with a status of 'pending' | SELECT * FROM building_permits WHERE status = 'pending'; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT); CREATE TABLE posts (id INT, user_id INT, hashtags TEXT); | How many users have interacted with content related to the hashtag "#climatechange" in the last year? | SELECT COUNT(DISTINCT users.id) FROM users INNER JOIN posts ON users.id = posts.user_id WHERE FIND_IN_SET('climatechange', posts.hashtags) > 0 AND posts.created_at >= DATE_SUB(NOW(), INTERVAL 1 YEAR); | gretelai_synthetic_text_to_sql |
CREATE TABLE agri_projects (project_id INT, district_id INT, budget FLOAT, project_category VARCHAR(50)); INSERT INTO agri_projects (project_id, district_id, budget, project_category) VALUES (1, 14, 120000, 'Crop Research'), (2, 14, 80000, 'Livestock Research'), (3, 15, 180000, 'Farm Machinery'); | Update the budget for the 'Crop Research' project in district 14 to 130000. | UPDATE agri_projects SET budget = 130000 WHERE project_id = 1 AND district_id = 14; | gretelai_synthetic_text_to_sql |
CREATE TABLE platforms (id INT PRIMARY KEY, name VARCHAR(255)); CREATE TABLE users (id INT PRIMARY KEY, name VARCHAR(255), platform_id INT, country VARCHAR(255)); INSERT INTO platforms (id, name) VALUES (1, 'Spotify'); INSERT INTO users (id, name, platform_id, country) VALUES (1, 'Alice', 1, 'Japan'); INSERT INTO users (id, name, platform_id, country) VALUES (2, 'Bob', 2, 'China'); | How many users are there per platform in Asia? | SELECT p.name, COUNT(u.id) as user_count FROM platforms p INNER JOIN users u ON p.id = u.platform_id WHERE u.country LIKE 'Asia%' GROUP BY p.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE water_usage (usage_id INT, city VARCHAR(20), usage FLOAT, date DATE); INSERT INTO water_usage (usage_id, city, usage, date) VALUES (1, 'Los Angeles', 100000.0, '2022-01-01'), (2, 'Los Angeles', 110000.0, '2022-02-01'), (3, 'Los Angeles', 120000.0, '2021-03-01'); | What is the maximum daily water consumption for the city of Los Angeles in the past year? | SELECT MAX(usage) FROM water_usage WHERE city = 'Los Angeles' AND date > DATE_SUB(CURDATE(), INTERVAL 1 YEAR); | gretelai_synthetic_text_to_sql |
CREATE TABLE wells (well_id varchar(10), field varchar(10), datetime date); INSERT INTO wells (well_id, field, datetime) VALUES ('W009', 'FieldH', '2018-01-01'), ('W010', 'FieldH', '2019-01-01'); | How many wells were drilled in 'FieldH' between 2017 and 2019? | SELECT COUNT(DISTINCT well_id) FROM wells WHERE field = 'FieldH' AND datetime BETWEEN '2017-01-01' AND '2019-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE attorney_title (case_id INT, attorney_title VARCHAR(50)); INSERT INTO attorney_title (case_id, attorney_title) VALUES (1, 'partner'), (2, 'associate'), (3, 'partner'); | What is the average billing amount for cases handled by attorneys with 'partner' title? | SELECT AVG(billing_amount) FROM billing_info WHERE case_id IN (SELECT case_id FROM attorney_title WHERE attorney_title = 'partner'); | gretelai_synthetic_text_to_sql |
CREATE TABLE production(year INT, region VARCHAR(20), element VARCHAR(10), quantity INT); INSERT INTO production VALUES(2020, 'Asia', 'Terbium', 1200), (2020, 'Europe', 'Terbium', 800), (2020, 'Africa', 'Terbium', 400); | What is the percentage of Terbium production that comes from the 'Asia' region in 2020? | SELECT (SUM(CASE WHEN region = 'Asia' THEN quantity ELSE 0 END) / SUM(quantity)) * 100.0 FROM production WHERE element = 'Terbium' AND year = 2020 | gretelai_synthetic_text_to_sql |
CREATE TABLE Games (GameID INT, Name VARCHAR(50), ReleaseYear INT); INSERT INTO Games (GameID, Name, ReleaseYear) VALUES (1, 'Game1', 2019); INSERT INTO Games (GameID, Name, ReleaseYear) VALUES (2, 'Game2', 2020); CREATE TABLE VRGames (VRGameID INT, GameID INT); INSERT INTO VRGames (VRGameID, GameID) VALUES (1, 1); INSERT INTO VRGames (VRGameID, GameID) VALUES (2, 2); | Which VR games were released in 2020? | SELECT Games.Name FROM Games INNER JOIN VRGames ON Games.GameID = VRGames.GameID WHERE Games.ReleaseYear = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE resource_depletion (metric_id INT, metric_name VARCHAR(30), year INT, value INT); INSERT INTO resource_depletion (metric_id, metric_name, year, value) VALUES (1, 'Water Consumption', 2019, 25000), (2, 'Energy Usage', 2019, 30000), (3, 'Water Consumption', 2020, 26000), (4, 'Energy Usage', 2020, 32000), (5, 'Water Consumption', 2021, 27000), (6, 'Energy Usage', 2021, 34000); | Show resource depletion metrics for the past 3 years. | SELECT year, metric_name, value FROM resource_depletion WHERE year BETWEEN YEAR(CURRENT_DATE) - 3 AND YEAR(CURRENT_DATE) | gretelai_synthetic_text_to_sql |
CREATE TABLE harvest (year INT, region VARCHAR(255), timber_type VARCHAR(255), volume FLOAT); | update the harvest table to reflect a timber volume of 1200 cubic meters for pine in the region 'North' for the year 2020 | UPDATE harvest SET volume = 1200 WHERE year = 2020 AND region = 'North' AND timber_type = 'Pine'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Bridges (id INT, name TEXT, region TEXT, length FLOAT); INSERT INTO Bridges (id, name, region, length) VALUES (1, 'BridgeX', 'Northeast', 2500.00), (2, 'BridgeY', 'Midwest', 3100.50), (3, 'BridgeZ', 'Midwest', 1800.25); | Identify the total number of bridges in 'Northeast' and 'Midwest' regions. | SELECT COUNT(*) FROM Bridges WHERE region IN ('Northeast', 'Midwest'); | gretelai_synthetic_text_to_sql |
CREATE TABLE RiskAssessments (AssessmentID INT, Contractor VARCHAR(255), Country VARCHAR(255), Quarter VARCHAR(10), Year INT); INSERT INTO RiskAssessments (AssessmentID, Contractor, Country, Quarter, Year) VALUES (1, 'Contractor P', 'Country D', 'Q2', 2021); | Identify the geopolitical risk assessments that occurred between Contractor P and Country D. | SELECT * FROM RiskAssessments WHERE Contractor = 'Contractor P' AND Country = 'Country D'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ProductShipping (product_id INT, shipping_cost DECIMAL(10,2), supplier_country VARCHAR(50)); CREATE TABLE FairTradeSuppliers (supplier_id INT, supplier_country VARCHAR(50)); | What is the average shipping cost for products from fair trade suppliers in Europe? | SELECT AVG(ps.shipping_cost) FROM ProductShipping ps INNER JOIN FairTradeSuppliers fs ON ps.product_id = fs.supplier_id WHERE fs.supplier_country = 'Europe'; | gretelai_synthetic_text_to_sql |
CREATE TABLE sensor (id INT, location VARCHAR(50)); INSERT INTO sensor (id, location) VALUES (1, '45.234, 12.345'), (2, '32.542, 76.890'), (3, '16.892, 34.564'); | List all the unique sensor IDs and their corresponding locations. | SELECT id, location FROM sensor; | gretelai_synthetic_text_to_sql |
CREATE TABLE spacecraft (id INT PRIMARY KEY, name VARCHAR(50), engine VARCHAR(50), status VARCHAR(10)); | What are the spacecraft engines that have been decommissioned? | SELECT engine FROM spacecraft WHERE status = 'decommissioned'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Water_Consumption_Records (Mine_Name VARCHAR(50), Water_Consumption FLOAT, Year INT); INSERT INTO Water_Consumption_Records (Mine_Name, Water_Consumption, Year) VALUES ('Amethyst Ascent', 25000.0, 2019), ('Turquoise Terrace', 27000.1, 2019), ('Topaz Tops', 23000.5, 2019); | Select the name of the mine with the lowest water consumption in the most recent year. | SELECT Mine_Name FROM Water_Consumption_Records WHERE Water_Consumption = (SELECT MIN(Water_Consumption) FROM Water_Consumption_Records) AND Year = (SELECT MAX(Year) FROM Water_Consumption_Records); | gretelai_synthetic_text_to_sql |
CREATE TABLE ride_hailing_companies (id INT, name VARCHAR(50)); CREATE TABLE electric_vehicles (id INT, company_id INT, manufacturer VARCHAR(50), vehicle_count INT); INSERT INTO ride_hailing_companies (id, name) VALUES (1, 'Company A'), (2, 'Company B'), (3, 'Company C'); INSERT INTO electric_vehicles (id, company_id, manufacturer, vehicle_count) VALUES (1, 1, 'Tesla', 50000), (2, 2, 'Nissan', 40000), (3, 3, 'Chevrolet', 30000); | What is the market share of electric vehicles by manufacturer in the ride-hailing industry? | SELECT rhc.name, (EV.electric_vehicle_count / SUM(EV.electric_vehicle_count)) * 100 AS market_share FROM ride_hailing_companies rhc CROSS JOIN (SELECT SUM(vehicle_count) AS electric_vehicle_count FROM electric_vehicles ev WHERE ev.manufacturer = rhc.name) EV GROUP BY rhc.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (id INT, species_name VARCHAR(50), ocean VARCHAR(50), region VARCHAR(50)); | What are the names of the marine species that are found in the same regions as the 'shark' species in the 'marine_species' table? | SELECT ms.species_name FROM marine_species ms JOIN marine_species shark ON ms.region = shark.region WHERE shark.species_name = 'shark'; | gretelai_synthetic_text_to_sql |
CREATE TABLE athlete_wellbeing (athlete_id INT, wellbeing_program VARCHAR(20)); INSERT INTO athlete_wellbeing (athlete_id, wellbeing_program) VALUES (1, 'Yoga'), (2, 'Meditation'), (3, 'Stretching'); | Insert a new record into the 'athlete_wellbeing' table with athlete_id 4 and wellbeing_program 'Pilates' | INSERT INTO athlete_wellbeing (athlete_id, wellbeing_program) VALUES (4, 'Pilates'); | gretelai_synthetic_text_to_sql |
CREATE TABLE mining_operations (id INT, first_name VARCHAR(50), last_name VARCHAR(50), job_title VARCHAR(50), department VARCHAR(50), PRIMARY KEY (id)); INSERT INTO mining_operations (id, first_name, last_name, job_title, department, salary) VALUES (1, 'John', 'Doe', 'Engineer', 'Mining', 80000.00), (2, 'Jane', 'Doe', 'Operator', 'Mining', 60000.00), (3, 'Mike', 'Johnson', 'Manager', 'Environment', 95000.00), (4, 'Sara', 'Smith', 'Technician', 'Environment', 70000.00); | Delete all records from the 'mining_operations' table where the department is 'Environment' and the employee's salary is greater than $90,000? | DELETE FROM mining_operations WHERE department = 'Environment' AND salary > 90000.00; | gretelai_synthetic_text_to_sql |
CREATE TABLE energy_storage (name TEXT, state TEXT, capacity FLOAT); INSERT INTO energy_storage (name, state, capacity) VALUES ('Moss Landing', 'California', 1500.0), ('Battery Storage Project', 'California', 1000.0); | What is the maximum energy storage capacity (MWh) in California? | SELECT MAX(capacity) FROM energy_storage WHERE state = 'California'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Budget(Year INT, Category VARCHAR(20), City VARCHAR(20), Amount INT); INSERT INTO Budget VALUES (2018, 'Education', 'CityA', 5000), (2018, 'Education', 'CityB', 7000), (2019, 'Education', 'CityA', 5500), (2019, 'Education', 'CityB', 7500), (2020, 'Education', 'CityA', 6000), (2020, 'Education', 'CityB', 8000); | What was the total budget allocated for education in 2020 across all cities? | SELECT SUM(Amount) FROM Budget WHERE Year = 2020 AND Category = 'Education'; | gretelai_synthetic_text_to_sql |
CREATE TABLE properties (property_id INT, name VARCHAR(255), address VARCHAR(255), city VARCHAR(255), housing_affordability_score INT, sold_date DATE); INSERT INTO properties (property_id, name, address, city, housing_affordability_score, sold_date) VALUES (1, 'The Affordable Apartment', '123 Main St', 'San Francisco', 85, '2022-01-15'), (2, 'The Expensive Estate', '456 Oak St', 'San Francisco', 60, '2022-02-01'), (3, 'The Moderate Manor', '789 Pine St', 'San Francisco', 75, NULL); | List the names and addresses of properties in the city of San Francisco with a housing affordability score above 80 that have been sold in the past month. | SELECT name, address FROM properties WHERE city = 'San Francisco' AND housing_affordability_score > 80 AND sold_date >= DATEADD(month, -1, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE astronauts (id INT, name VARCHAR(50), medical_record_id INT);CREATE TABLE missions (id INT, destination VARCHAR(50));CREATE TABLE medical_records (id INT, astronaut_id INT, medical_issues INT); INSERT INTO astronauts VALUES (1, 'Melissa Lewis', 101); INSERT INTO missions VALUES (1, 'Mars'); INSERT INTO medical_records VALUES (101, 1, 2); | How many medical issues have been recorded for each astronaut during missions to Mars? | SELECT astronauts.name, COUNT(medical_records.medical_issues) as mars_medical_issues FROM astronauts INNER JOIN medical_records ON astronauts.medical_record_id = medical_records.id INNER JOIN missions ON astronauts.id = missions.id WHERE missions.destination = 'Mars' GROUP BY astronauts.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE unions (id INT, name TEXT, state TEXT, members INT); INSERT INTO unions (id, name, state, members) VALUES (1, 'Union A', 'Texas', 700), (2, 'Union B', 'Texas', 800), (3, 'Union C', 'California', 300); | What is the maximum number of members in a union based in Texas? | SELECT MAX(members) FROM unions WHERE state = 'Texas'; | gretelai_synthetic_text_to_sql |
CREATE TABLE SustainableClothing (clothing_id INT, clothing_name VARCHAR(50), price DECIMAL(5,2), quantity INT); CREATE TABLE ClothingSales (sale_id INT, clothing_id INT, sale_country VARCHAR(50)); INSERT INTO SustainableClothing (clothing_id, clothing_name, price, quantity) VALUES (1, 'Organic Cotton Shirt', 25.00, 100), (2, 'Recycled Polyester Pants', 30.00, 75), (3, 'Tencel Jacket', 40.00, 50); INSERT INTO ClothingSales (sale_id, clothing_id, sale_country) VALUES (1, 1, 'France'), (2, 2, 'Germany'), (3, 3, 'Italy'); | What is the total revenue generated from sustainable clothing sales in Europe? | SELECT SUM(s.price * s.quantity) FROM SustainableClothing s INNER JOIN ClothingSales cs ON s.clothing_id = cs.clothing_id WHERE cs.sale_country = 'Europe'; | gretelai_synthetic_text_to_sql |
CREATE TABLE CarbonOffsets (id INT, program_name TEXT, region TEXT, start_date DATE, end_date DATE); | How many carbon offset programs are there in 'CarbonOffsets' table, by region? | SELECT region, COUNT(*) FROM CarbonOffsets GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE VehicleSpecs (VehicleID INT, Model TEXT, Year INT, Range INT); | What is the average electric vehicle range for models released in 2021 and 2022? | SELECT AVG(Range) FROM VehicleSpecs WHERE Year IN (2021, 2022) AND Model LIKE '%electric%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE students(id INT, program VARCHAR(255), gpa DECIMAL(3,2)); INSERT INTO students VALUES (1, 'mental health', 3.7), (2, 'mental health', 2.8), (3, 'physical health', 3.9), (4, 'mental health', 4.0); | How many students in the mental health program have a GPA greater than or equal to 3.5? | SELECT COUNT(*) FROM students WHERE program = 'mental health' AND gpa >= 3.5; | gretelai_synthetic_text_to_sql |
CREATE TABLE MusicSales (SaleID INT, AlbumName VARCHAR(20), Genre VARCHAR(10), SalesAmount DECIMAL(10,2)); INSERT INTO MusicSales (SaleID, AlbumName, Genre, SalesAmount) VALUES (1, 'Ella Fitzgerald Sings the Song Books', 'Jazz', 12.99), (2, 'The Beatles 1962-1966', 'Rock', 15.00), (3, 'Sweetener', 'Pop', 7.45), (4, 'thank u, next', 'Pop', 12.04); | Who are the top 3 albums with the highest revenue from digital music sales? | SELECT AlbumName, SUM(SalesAmount) as TotalRevenue FROM MusicSales GROUP BY AlbumName ORDER BY TotalRevenue DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE transportation.vehicle_details (vehicle_type VARCHAR(20), autonomous_vehicle BOOLEAN, electric_vehicle BOOLEAN); | What is the total number of autonomous and electric vehicles in the 'vehicle_details' table? | SELECT SUM(CASE WHEN autonomous_vehicle = TRUE THEN 1 ELSE 0 END) + SUM(CASE WHEN electric_vehicle = TRUE THEN 1 ELSE 0 END) FROM transportation.vehicle_details; | gretelai_synthetic_text_to_sql |
CREATE TABLE taxi_fleet (fleet_id INT, city VARCHAR(255), vehicle_type VARCHAR(255)); INSERT INTO taxi_fleet (fleet_id, city, vehicle_type) VALUES (1, 'NYC', 'Sedan'), (2, 'LA', 'Wheelchair van'), (3, 'Chicago', 'Sedan'), (4, 'Houston', 'Minivan'); | How many accessible vehicles are available in the taxi fleet? | SELECT COUNT(*) FROM taxi_fleet WHERE vehicle_type IN ('Wheelchair van', 'Accessible minivan'); | gretelai_synthetic_text_to_sql |
CREATE TABLE south_china_sea (id INT, well_name VARCHAR(255), drill_date DATE, production_oil INT); | What is the total number of wells that were drilled in the South China Sea before 2015, and what is the total amount of oil they produced? | SELECT COUNT(*) as total_wells, SUM(production_oil) as total_oil_produced FROM south_china_sea WHERE drill_date < '2015-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE first_satellites (satellite_name TEXT, launch_date DATE); INSERT INTO first_satellites (satellite_name, launch_date) VALUES ('Sputnik 1', '1957-10-04'), ('Explorer 1', '1958-01-31'); | What is the name of the first satellite launched into space? | SELECT satellite_name FROM first_satellites ORDER BY launch_date LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE investments (id INT, sector VARCHAR(20), amount DECIMAL(10,2)); INSERT INTO investments (id, sector, amount) VALUES (1, 'poverty reduction', 15000.00), (2, 'poverty reduction', 18000.00), (3, 'education', 22000.00); | What is the minimum investment made in the poverty reduction sector? | SELECT MIN(amount) FROM investments WHERE sector = 'poverty reduction'; | gretelai_synthetic_text_to_sql |
CREATE TABLE arctic_biodiversity (id INTEGER, species_name TEXT, biomass FLOAT, animal_class TEXT); | What is the total biomass of mammals and birds in the 'arctic_biodiversity' table? | SELECT animal_class, SUM(biomass) as total_biomass FROM arctic_biodiversity WHERE animal_class IN ('mammals', 'birds') GROUP BY animal_class; | gretelai_synthetic_text_to_sql |
CREATE TABLE patient (patient_id INT, age INT, gender TEXT, ethnicity TEXT, condition TEXT); INSERT INTO patient (patient_id, age, gender, ethnicity, condition) VALUES (1, 35, 'Female', 'Hispanic', 'Anxiety Disorder'); INSERT INTO patient (patient_id, age, gender, ethnicity, condition) VALUES (2, 42, 'Male', 'African American', 'Anxiety Disorder'); | What are the patient demographics for those diagnosed with anxiety disorders? | SELECT age, gender, ethnicity FROM patient WHERE condition = 'Anxiety Disorder'; | gretelai_synthetic_text_to_sql |
CREATE TABLE habitat_preservation (id INT, animal_id INT, location VARCHAR(50), acres FLOAT);INSERT INTO habitat_preservation (id, animal_id, location, acres) VALUES (1, 1, 'Asia', 10000), (2, 2, 'Africa', 15000);CREATE TABLE animal_population (id INT, species VARCHAR(50), population INT);INSERT INTO animal_population (id, species, population) VALUES (1, 'Tiger', 250), (2, 'Elephant', 500); | What is the average acres of habitat preserved per animal species? | SELECT AVG(h.acres) FROM habitat_preservation h JOIN animal_population ap ON h.animal_id = ap.id; | gretelai_synthetic_text_to_sql |
CREATE TABLE devices (id INT, price FLOAT, disability_access BOOLEAN); INSERT INTO devices (id, price, disability_access) VALUES (1, 500.00, true), (2, 300.00, false), (3, 600.00, true); | What is the average price of devices for users with disabilities? | SELECT AVG(price) FROM devices WHERE disability_access = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE Shipment (shipment_id INT, container_id INT, port_id INT, shipping_date DATE, arrival_date DATE); CREATE TABLE Container (container_id INT, weight FLOAT); | What is the number of containers that were delayed for more than 7 days in the past month from the Port of Valparaíso to Chile? | SELECT COUNT(*) FROM Container c JOIN Shipment s ON c.container_id = s.container_id WHERE s.arrival_date >= NOW() - INTERVAL '1 month' AND s.port_id = (SELECT port_id FROM Port WHERE port_name = 'Port of Valparaíso') AND s.arrival_date - s.shipping_date > 7 AND (SELECT country FROM Port WHERE port_id = s.port_id) = 'Chile'; | gretelai_synthetic_text_to_sql |
CREATE TABLE virtual_tours (tour_id INT, booking_date DATE); INSERT INTO virtual_tours (tour_id, booking_date) VALUES (1, '2022-01-01'), (2, '2022-01-02'), (3, '2022-01-03'), (4, '2022-01-04'), (5, '2022-01-05'), (6, '2022-01-06'), (7, '2022-01-07'), (8, '2022-01-08'), (9, '2022-01-09'), (10, '2022-01-10'); | Find the average virtual tour bookings per day? | SELECT AVG(total_days) FROM (SELECT COUNT(DISTINCT booking_date) AS total_days FROM virtual_tours); | gretelai_synthetic_text_to_sql |
CREATE TABLE traditional_arts_centers_city (id INT, center_name VARCHAR(100), size INT, city VARCHAR(50)); INSERT INTO traditional_arts_centers_city (id, center_name, size, city) VALUES (1, 'Folk Arts Center', 2000, 'Boston'), (2, 'Western Arts Center', 3000, 'Chicago'); | What is the average size of traditional arts centers by city? | SELECT city, AVG(size) as avg_size FROM traditional_arts_centers_city GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE Unions (UnionID INT, UnionName TEXT); CREATE TABLE Accidents (AccidentID INT, UnionID INT, AccidentDate DATE); | What is the average number of workplace accidents per year for each union? | SELECT u.UnionName, AVG(YEAR(a.AccidentDate)) AS AvgYear, AVG(NumberOfAccidents) AS AvgAccidentsPerYear FROM Unions u INNER JOIN Accidents a ON u.UnionID = a.UnionID GROUP BY u.UnionName; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists mining;CREATE TABLE mining.plant (id INT, name STRING, location STRING, num_employees INT);INSERT INTO mining.plant (id, name, location, num_employees) VALUES (1, 'processing_plant', 'Canada', 200), (2, 'refinery', 'Canada', 150), (3, 'refinery', 'USA', 100), (4, 'processing_plant', 'USA', 250); | Present the total number of employees in each location. | SELECT location, SUM(num_employees) FROM mining.plant GROUP BY location; | gretelai_synthetic_text_to_sql |
CREATE TABLE cargo_handling (port_id INT, port_name VARCHAR(50), teu_count INT, handling_date DATE); INSERT INTO cargo_handling (port_id, port_name, teu_count, handling_date) VALUES (1, 'Port_A', 2000, '2022-01-03'), (2, 'Port_B', 3000, '2022-01-02'), (3, 'Port_C', 1000, '2022-01-01'); | What is the total TEU handling for each port in the cargo_handling table, ordered by handling date in descending order? | SELECT port_name, SUM(teu_count) OVER (PARTITION BY port_name ORDER BY handling_date DESC) as total_teu FROM cargo_handling; | gretelai_synthetic_text_to_sql |
CREATE TABLE water_usage_metrics (year INT, month INT, sector VARCHAR(20), usage FLOAT); INSERT INTO water_usage_metrics (year, month, sector, usage) VALUES (2021, 1, 'residential', 15000); | What is the total water usage in MWh for residential sector in January 2021? | SELECT SUM(usage) FROM water_usage_metrics WHERE year = 2021 AND month = 1 AND sector = 'residential'; | gretelai_synthetic_text_to_sql |
CREATE TABLE artworks (id INT, title TEXT, year INT, artist_id INT); INSERT INTO artworks (id, title, year, artist_id) VALUES (1, 'Artwork 1', 1901, 1), (2, 'Artwork 2', 1950, 2), (3, 'Artwork 3', 1985, 3); | How many artworks were created in the 20th century? | SELECT COUNT(*) FROM artworks WHERE year BETWEEN 1901 AND 2000; | gretelai_synthetic_text_to_sql |
CREATE TABLE languages (id INT PRIMARY KEY, name VARCHAR(255), region VARCHAR(255), status VARCHAR(255)); | Insert a new language into the 'languages' table | INSERT INTO languages (id, name, region, status) VALUES (1, 'Quechua', 'Andes', 'Vulnerable'); | gretelai_synthetic_text_to_sql |
CREATE TABLE movies (title VARCHAR(255), genre VARCHAR(50), budget INT, release_year INT); CREATE TABLE tv_shows (title VARCHAR(255), genre VARCHAR(50), budget INT, release_year INT); INSERT INTO movies (title, genre, budget, release_year) VALUES ('Movie4', 'Comedy', 25000000, 2018), ('Movie5', 'Drama', 30000000, 2020), ('Movie6', 'Action', 40000000, 2022); INSERT INTO tv_shows (title, genre, budget, release_year) VALUES ('Show7', 'Comedy', 15000000, 2019), ('Show8', 'Drama', 20000000, 2021), ('Show9', 'Action', 25000000, 2022); | Find the average budget for TV shows and movies released in the last 5 years | SELECT AVG(budget) FROM (SELECT budget FROM movies WHERE release_year >= (SELECT YEAR(CURRENT_DATE()) - 5) UNION ALL SELECT budget FROM tv_shows WHERE release_year >= (SELECT YEAR(CURRENT_DATE()) - 5)) as combined; | gretelai_synthetic_text_to_sql |
CREATE TABLE graduate_students (id INT, name VARCHAR(50), department VARCHAR(50), enrollment_date DATE); CREATE TABLE publications (id INT, student_id INT, title VARCHAR(100), publication_date DATE); | What is the total number of publications for each graduate student in the Physics department? | SELECT student_id, COUNT(*) FROM publications WHERE student_id IN (SELECT id FROM graduate_students WHERE department = 'Physics') GROUP BY student_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE content_trends (content_id INT, user_country VARCHAR(50), user_engagement INT); | Find the top 3 countries with the most user engagement in 'content_trends' table? | SELECT user_country, SUM(user_engagement) FROM content_trends GROUP BY user_country ORDER BY SUM(user_engagement) DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE primary_care (patient_id INT, patient_gender VARCHAR(10), age_group INT, service_date DATE); INSERT INTO primary_care (patient_id, patient_gender, age_group, service_date) VALUES (1, 'Male', 0, '2020-01-01'), (2, 'Female', 1, '2020-01-02'), (3, 'Male', 2, '2020-01-03'); | What is the number of males and females who accessed primary care services by age group? | SELECT age_group, patient_gender, COUNT(*) as patient_count FROM primary_care GROUP BY age_group, patient_gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE posts (id INT, content TEXT, user_id INT, created_at TIMESTAMP); CREATE TABLE comments (id INT, post_id INT, user_id INT, comment TEXT, created_at TIMESTAMP); | What is the average response time for posts with more than 100 comments? | SELECT AVG(DATEDIFF(hour, comments.created_at, posts.created_at)) as average_response_time FROM posts JOIN comments ON posts.id = comments.post_id GROUP BY posts.id HAVING COUNT(comments.id) > 100 ORDER BY average_response_time DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE faculties (faculty_id INT, name VARCHAR(50), department VARCHAR(20)); INSERT INTO faculties (faculty_id, name, department) VALUES (1, 'Jose Hernandez', 'Mathematics'), (2, 'Sofia Rodriguez', 'Mathematics'), (3, 'Ali Al-Sayed', 'Physics'); CREATE TABLE research_grants (grant_id INT, title VARCHAR(50), amount DECIMAL(10,2), principal_investigator VARCHAR(50), faculty_id INT, start_date DATE, end_date DATE); INSERT INTO research_grants (grant_id, title, amount, principal_investigator, faculty_id, start_date, end_date) VALUES (1, 'Project C', 50000, 'Jose Hernandez', 1, '2022-01-01', '2024-12-31'), (2, 'Project D', 100000, 'Sofia Rodriguez', 2, '2021-07-01', '2023-06-30'); | What is the average number of research grants awarded per faculty member in the "Mathematics" department? | SELECT AVG(rg.amount) FROM research_grants rg JOIN faculties f ON rg.faculty_id = f.faculty_id WHERE f.department = 'Mathematics'; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (id INT, species VARCHAR(255)); INSERT INTO marine_species (id, species) VALUES (1, 'Dolphin'), (2, 'Shark'), (3, 'Turtle'); CREATE TABLE pollution_control (id INT, species_id INT, initiative VARCHAR(255)); INSERT INTO pollution_control (id, species_id, initiative) VALUES (1, 1, 'Beach Cleanup'), (2, 1, 'Ocean Floor Mapping'), (3, 2, 'Beach Cleanup'), (4, 3, 'Beach Cleanup'), (5, 3, 'Ocean Floor Mapping'); | List all unique pollution control initiatives and their corresponding marine species. | SELECT pollution_control.initiative, marine_species.species FROM pollution_control INNER JOIN marine_species ON pollution_control.species_id = marine_species.id GROUP BY pollution_control.initiative, marine_species.species; | gretelai_synthetic_text_to_sql |
CREATE TABLE courses (course_id INT, course_name TEXT); CREATE TABLE enrollments (enrollment_id INT, student_id INT, course_id INT, enrollment_date DATE); INSERT INTO courses VALUES (1, 'Algebra I'), (2, 'Geometry'), (3, 'Algebra II'); INSERT INTO enrollments VALUES (1, 1, 1, '2021-08-01'), (2, 2, 1, '2021-08-01'), (3, 3, 2, '2021-08-01'), (4, 4, 2, '2021-08-01'), (5, 5, 3, '2021-08-01'); | What is the total number of students who have ever enrolled in each course? | SELECT c.course_name, COUNT(DISTINCT e.student_id) FROM courses c INNER JOIN enrollments e ON c.course_id = e.course_id GROUP BY c.course_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Exhibitions (exhibition_id INT, location VARCHAR(20)); INSERT INTO Exhibitions (exhibition_id, location) VALUES (1, 'Rio de Janeiro'), (2, 'Sao Paulo'); CREATE TABLE Visitors (visitor_id INT, exhibition_id INT, age INT); INSERT INTO Visitors (visitor_id, exhibition_id, age) VALUES (1, 1, 25), (2, 1, 30), (3, 2, 20), (4, 2, 22); | What is the minimum age of visitors who attended exhibitions in Rio de Janeiro? | SELECT MIN(age) FROM Visitors v JOIN Exhibitions e ON v.exhibition_id = e.exhibition_id WHERE e.location = 'Rio de Janeiro'; | gretelai_synthetic_text_to_sql |
CREATE TABLE waste_generation ( id INT PRIMARY KEY, region VARCHAR(50), year INT, metric DECIMAL(5,2)); | Insert data into the table 'waste_generation' | INSERT INTO waste_generation (id, region, year, metric) VALUES (1, 'Mumbai', 2018, 5678.90), (2, 'Mumbai', 2019, 6001.12), (3, 'Tokyo', 2018, 3456.78), (4, 'Tokyo', 2019, 3501.09); | gretelai_synthetic_text_to_sql |
CREATE TABLE delete_environment_cause (cause_id INT, cause_name VARCHAR(50), donation_amount DECIMAL(10, 2)); INSERT INTO delete_environment_cause (cause_id, cause_name, donation_amount) VALUES (3, 'Environment', 15000.00); | Delete the 'Environment' cause. | DELETE FROM delete_environment_cause WHERE cause_id = 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE CitizenFeedback (ID INT, PoliceStationID INT, Feedback TEXT, Timestamp DATETIME); | Delete a record from the "CitizenFeedback" table based on the provided criteria | WITH feedback_to_delete AS (DELETE FROM CitizenFeedback WHERE ID = 1001 AND PoliceStationID = 5001 AND Timestamp < '2022-01-01 00:00:00' RETURNING ID, PoliceStationID, Feedback, Timestamp) SELECT * FROM feedback_to_delete; | gretelai_synthetic_text_to_sql |
CREATE TABLE GreenBuildings (id INT, building_name VARCHAR(100), certification_level VARCHAR(50), city VARCHAR(50), state VARCHAR(50), country VARCHAR(50), carbon_offset INT); | Show the average carbon offset of buildings in 'NY' state | SELECT AVG(carbon_offset) FROM GreenBuildings WHERE state = 'NY'; | gretelai_synthetic_text_to_sql |
CREATE TABLE digital_assets (asset_id INT, name VARCHAR(20), sector VARCHAR(20)); INSERT INTO digital_assets (asset_id, name, sector) VALUES (1, 'Eversmart', 'Payment'); | Update the sector of digital asset 'Eversmart' to 'Supply Chain | UPDATE digital_assets SET sector = 'Supply Chain' WHERE name = 'Eversmart'; | gretelai_synthetic_text_to_sql |
CREATE TABLE biosensors (id INT, name VARCHAR(50), target VARCHAR(50)); INSERT INTO biosensors VALUES (1, 'BioSensorG', 'Neuropeptide Y'); INSERT INTO biosensors VALUES (2, 'BioSensorH', 'Insulin'); INSERT INTO biosensors VALUES (3, 'BioSensorI', 'Glucose'); | Delete all biosensors that are not designed for monitoring Neuropeptide Y. | DELETE FROM biosensors WHERE target != 'Neuropeptide Y'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ai_use_cases (use_case_id INT, use_case TEXT); INSERT INTO ai_use_cases (use_case_id, use_case) VALUES (1, 'Chatbots'), (2, 'Predictive Maintenance'), (3, 'Personalized Recommendations'), (4, 'Automated Check-in'), (5, 'Voice Assistants'); CREATE TABLE hospitality_companies (company_id INT, company_name TEXT, ai_use_case_id INT); INSERT INTO hospitality_companies (company_id, company_name, ai_use_case_id) VALUES (1, 'Company A', 1), (2, 'Company B', 2), (3, 'Company C', 3), (4, 'Company D', 4), (5, 'Company E', 5); | What are the most common AI use cases in the hospitality industry? | SELECT use_case FROM ai_use_cases INNER JOIN hospitality_companies ON ai_use_cases.use_case_id = hospitality_companies.ai_use_case_id GROUP BY use_case ORDER BY COUNT(*) DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE consumer_feedback(feedback_id INT, product_id INT, feedback VARCHAR(100), feedback_date DATE); | Which cosmetics products received the most positive consumer feedback in the past month? | SELECT product_id, COUNT(*) as positive_feedback_count FROM consumer_feedback WHERE feedback IN ('very satisfied', 'satisfied') AND feedback_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY product_id ORDER BY positive_feedback_count DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE infectious_disease_reporting (id INT, city TEXT, year INT, num_cases INT); INSERT INTO infectious_disease_reporting (id, city, year, num_cases) VALUES (1, 'New York City', 2021, 5000), (2, 'New York City', 2020, 3000), (3, 'Los Angeles', 2021, 4000), (4, 'Los Angeles', 2020, 2500); | How many infectious disease cases were reported in New York City in 2021? | SELECT SUM(num_cases) FROM infectious_disease_reporting WHERE city = 'New York City' AND year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE art_exhibitions (exhibition_id INT, exhibition_name VARCHAR(50), visitor_count INT, age_group VARCHAR(20)); | What is the total number of visitors by age group for all art exhibitions? | SELECT age_group, SUM(visitor_count) as total_visitors FROM art_exhibitions GROUP BY age_group; | gretelai_synthetic_text_to_sql |
CREATE TABLE RDExpenses (Department varchar(50), Expenditure decimal(18,2)); INSERT INTO RDExpenses (Department, Expenditure) VALUES ('Research', 5000000.00), ('Development', 6000000.00), ('ClinicalTrials', 7000000.00), ('Regulatory', 4000000.00); | What is the total R&D expenditure for each department, ranked by total R&D expenditure? | SELECT Department, Expenditure, ROW_NUMBER() OVER (ORDER BY Expenditure DESC) as ExpenseRank FROM RDExpenses; | gretelai_synthetic_text_to_sql |
CREATE TABLE donations (id INT, cause TEXT, donor TEXT, donation_amount DECIMAL(10,2)); INSERT INTO donations (id, cause, donor, donation_amount) VALUES (1, 'Cause A', 'Donor 1', 50.00), (2, 'Cause B', 'Donor 2', 100.00), (3, 'Cause A', 'Donor 3', 25.00); | What is the total donation amount for each cause, for causes that have received donations from at least 100 unique donors? | SELECT cause, SUM(donation_amount) as total_donations FROM donations GROUP BY cause HAVING COUNT(DISTINCT donor) > 100; | gretelai_synthetic_text_to_sql |
CREATE TABLE materials (material_id INT, material_name VARCHAR(255), co2_emission INT); INSERT INTO materials (material_id, material_name, co2_emission) VALUES (1, 'Organic cotton', 5), (2, 'Conventional cotton', 10), (3, 'Recycled polyester', 8); | What is the total CO2 emission of each material type, sorted by the highest emission first? | SELECT material_name, SUM(co2_emission) as total_emission FROM materials GROUP BY material_name ORDER BY total_emission DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE DrillingRigs (RigName TEXT, Location TEXT, ActiveDays INT, Date DATE); INSERT INTO DrillingRigs (RigName, Location, ActiveDays, Date) VALUES ('Rig1', 'North Sea', 25, '2019-01-01'), ('Rig2', 'North Sea', 28, '2019-02-01'); | How many drilling rigs were active in the North Sea in each month of 2019? | SELECT COUNT(*) AS ActiveRigs, EXTRACT(MONTH FROM Date) AS Month FROM DrillingRigs WHERE Location = 'North Sea' GROUP BY Month; | 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.