context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28 values |
|---|---|---|---|
CREATE TABLE Players (PlayerID INT, Age INT, VRUser CHAR(1), Day BIT); INSERT INTO Players (PlayerID, Age, VRUser, Day) VALUES (1, 25, 'Y', 1), (2, 30, 'N', 0), (3, 22, 'Y', 1), (4, 35, 'N', 1); | What is the average age of players who use VR technology and play games on weekends? | SELECT AVG(Players.Age) FROM Players WHERE Players.VRUser = 'Y' AND Players.Day = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE ingredient_source (ingredient_id INT, country VARCHAR(30)); INSERT INTO ingredient_source (ingredient_id, country) VALUES (1, 'Canada'), (2, 'Mexico'), (3, 'Brazil'), (4, 'Argentina'), (5, 'Australia'); CREATE TABLE ingredient (ingredient_id INT, ingredient_name VARCHAR(30)); INSERT INTO ingredient (ingredient_id, ingredient_name) VALUES (1, 'Beeswax'), (2, 'Aloe Vera'), (3, 'Shea Butter'), (4, 'Coconut Oil'), (5, 'Jojoba Oil'); | List all ingredients sourced from countries with fair trade agreements? | SELECT ingredient_name FROM ingredient JOIN ingredient_source ON ingredient.ingredient_id = ingredient_source.ingredient_id WHERE country IN ('Canada', 'Mexico'); | gretelai_synthetic_text_to_sql |
CREATE TABLE dispensary_sales (id INT, customer_name VARCHAR(50), state VARCHAR(20), purchase_date DATE); INSERT INTO dispensary_sales (id, customer_name, state, purchase_date) VALUES (1, 'John Doe', 'Colorado', '2022-01-01'); INSERT INTO dispensary_sales (id, customer_name, state, purchase_date) VALUES (2, 'Jane Smith', 'California', '2022-01-02'); | Update the 'purchase_date' of the customer with id 1 in the 'dispensary_sales' table to '2022-02-01' | UPDATE dispensary_sales SET purchase_date = '2022-02-01' WHERE id = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotel_ratings (hotel_id INT, name TEXT, category TEXT, rating FLOAT); INSERT INTO hotel_ratings (hotel_id, name, category, rating) VALUES (1, 'Hotel X', 'luxury', 4.5), (2, 'Hotel Y', 'budget', 3.2), (3, 'Hotel Z', 'leisure', 4.7); | What is the name of the hotel with the highest rating in the 'leisure' category? | SELECT name FROM hotel_ratings WHERE category = 'leisure' AND rating = (SELECT MAX(rating) FROM hotel_ratings WHERE category = 'leisure'); | gretelai_synthetic_text_to_sql |
CREATE TABLE military_equipment (equipment_id INT, equipment_name VARCHAR(50), last_maintenance_date DATE, next_maintenance_date DATE);INSERT INTO military_equipment (equipment_id, equipment_name, last_maintenance_date, next_maintenance_date) VALUES (2, 'F-35 Fighter Jet', '2020-12-01', '2022-08-01'); | List all military equipment that needs maintenance in the next 7 days | SELECT equipment_name FROM military_equipment WHERE last_maintenance_date < CURDATE() AND next_maintenance_date BETWEEN CURDATE() AND CURDATE() + INTERVAL 7 DAY; | gretelai_synthetic_text_to_sql |
CREATE TABLE viewers (id INT, name VARCHAR(255), region VARCHAR(255), age INT); INSERT INTO viewers (id, name, region, age) VALUES (1, 'John Doe', 'Northeast', 25), (2, 'Jane Smith', 'Southeast', 30); | What is the average age of viewers in the 'Southeast' region? | SELECT AVG(age) FROM viewers WHERE region = 'Southeast'; | gretelai_synthetic_text_to_sql |
CREATE TABLE infrastructure_projects (id INT, name TEXT, location TEXT); INSERT INTO infrastructure_projects (id, name, location) VALUES (1, 'Brooklyn Bridge', 'USA'); INSERT INTO infrastructure_projects (id, name, location) VALUES (2, 'Chunnel', 'UK'); INSERT INTO infrastructure_projects (id, name, location) VALUES (3, 'Tokyo Tower', 'Tokyo'); | Update the location of the Tokyo Tower to Japan | UPDATE infrastructure_projects SET location = 'Japan' WHERE name = 'Tokyo Tower'; | gretelai_synthetic_text_to_sql |
CREATE TABLE family_cases (case_id INT, billing_amount DECIMAL(10,2)); INSERT INTO family_cases (case_id, billing_amount) VALUES (1, 4000.00), (2, 2500.00), (3, 1800.50); | What is the total billing amount for family law cases? | SELECT SUM(billing_amount) FROM family_cases WHERE case_id IN (SELECT case_id FROM case_outcomes WHERE case_type = 'Family Law'); | gretelai_synthetic_text_to_sql |
CREATE TABLE policies (policy_id INT, policy_name VARCHAR(255), system_count INT, policy_expiration_date DATE); INSERT INTO policies (policy_id, policy_name, system_count, policy_expiration_date) VALUES (1, 'Endpoint Protection', 500, '2023-01-01'), (2, 'Network Security', 200, '2022-12-31'), (3, 'Email Security', 300, '2023-03-31'), (4, 'Cloud Security', 100, '2022-11-30'), (5, 'Data Security', 400, '2023-02-28'); | List all cybersecurity policies and their respective expiration dates, along with the number of systems covered by each policy. | SELECT policy_name, policy_expiration_date, system_count FROM policies; | gretelai_synthetic_text_to_sql |
CREATE TABLE properties (id INT, neighborhood VARCHAR(20), co_ownership INT); INSERT INTO properties (id, neighborhood, co_ownership) VALUES (1, 'Neighborhood X', 3), (2, 'Neighborhood Y', 1), (3, 'Neighborhood X', 2), (4, 'Neighborhood Z', 5); | List all the properties in neighborhoods with the highest property co-ownership. | SELECT neighborhood, co_ownership FROM properties WHERE co_ownership = (SELECT MAX(co_ownership) FROM properties); | gretelai_synthetic_text_to_sql |
CREATE TABLE Assistive_Technology (Student_ID INT, Student_Name TEXT, Disability_Type TEXT, Assistive_Tech_Item TEXT); INSERT INTO Assistive_Technology (Student_ID, Student_Name, Disability_Type, Assistive_Tech_Item) VALUES (1, 'John Doe', 'Visual Impairment', 'Screen Reader'), (2, 'Jane Smith', 'Visual Impairment', 'Screen Magnifier'), (3, 'Michael Brown', 'ADHD', 'None'); | What is the total number of assistive technology items provided to students with visual impairments? | SELECT SUM(CASE WHEN Disability_Type = 'Visual Impairment' THEN 1 ELSE 0 END) FROM Assistive_Technology WHERE Assistive_Tech_Item IS NOT NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE environmental_impact (chemical VARCHAR(10), score INT); INSERT INTO environmental_impact VALUES ('D', 25), ('D', 30), ('D', 20), ('E', 35), ('E', 40); | What is the average environmental impact score for chemical 'D'? | SELECT AVG(score) FROM environmental_impact WHERE chemical = 'D'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Product_Safety (ProductID INT, Vegan BOOLEAN, Country VARCHAR(50)); INSERT INTO Product_Safety (ProductID, Vegan, Country) VALUES (3001, TRUE, 'Germany'), (3002, FALSE, 'Germany'), (3003, TRUE, 'Germany'), (3004, TRUE, 'Germany'), (3005, FALSE, 'Germany'); | What percentage of vegan cosmetic products are available in Germany? | SELECT (COUNT(ProductID) FILTER (WHERE Vegan = TRUE AND Country = 'Germany') * 100.0 / COUNT(ProductID)) as Percentage FROM Product_Safety WHERE Country = 'Germany'; | gretelai_synthetic_text_to_sql |
CREATE TABLE geopolitical_risk (id INT, region VARCHAR(20), half INT, year INT, assessment TEXT); INSERT INTO geopolitical_risk (id, region, half, year, assessment) VALUES (1, 'Indo-Pacific', 1, 2023, 'Stable'); | List all geopolitical risk assessments for the Indo-Pacific region in H1 2023. | SELECT region, assessment FROM geopolitical_risk WHERE region = 'Indo-Pacific' AND half = 1 AND year = 2023; | gretelai_synthetic_text_to_sql |
CREATE TABLE tour_types(tour_id INT, tour_type TEXT); CREATE TABLE tour_revenue(revenue_id INT, tour_id INT, revenue DECIMAL); | What was the total revenue for each type of tour in Africa? | SELECT tour_type, SUM(revenue) FROM tour_revenue JOIN tour_types ON tour_revenue.tour_id = tour_types.tour_id JOIN hotels ON tour_types.hotel_id = hotels.hotel_id WHERE hotels.location = 'Africa' GROUP BY tour_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE mining_operations (id INT, name VARCHAR(50), type VARCHAR(20), location VARCHAR(50)); INSERT INTO mining_operations (id, name, type, location) VALUES (1, 'Mining Operation 1', 'Coal', 'Colombia'), (2, 'Mining Operation 2', 'Gold', 'Colombia'); | Find the number of coal and gold mining operations in Colombia? | SELECT type, COUNT(*) FROM mining_operations WHERE location = 'Colombia' GROUP BY type; | gretelai_synthetic_text_to_sql |
CREATE TABLE manufacturers (manufacturer_id INT, manufacturer_name VARCHAR(50), country VARCHAR(50)); INSERT INTO manufacturers (manufacturer_id, manufacturer_name, country) VALUES (1, 'ChemCo Mexico', 'Mexico'), (2, 'Canadian Chemicals', 'Canada'); CREATE TABLE chemicals (chemical_id INT, chemical_type VARCHAR(50), manufacturer_id INT, weight FLOAT); INSERT INTO chemicals (chemical_id, chemical_type, manufacturer_id, weight) VALUES (1, 'Acid', 1, 150.5), (2, 'Alkali', 1, 200.3), (3, 'Solvent', 2, 120.7), (4, 'Solute', 2, 180.5); | Calculate the average weight of chemicals by type, for manufacturers based in Mexico, ordered from highest to lowest average weight | SELECT chemical_type, AVG(weight) as avg_weight FROM chemicals JOIN manufacturers ON chemicals.manufacturer_id = manufacturers.manufacturer_id WHERE country = 'Mexico' GROUP BY chemical_type ORDER BY avg_weight DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_communication_funding(project_id INT, year INT, amount FLOAT); INSERT INTO climate_communication_funding (project_id, year, amount) VALUES (7, 2021, 80000.0), (8, 2020, 90000.0); | What is the total funding allocated for climate communication in 2021, if any? | SELECT COALESCE(SUM(amount), 0) FROM climate_communication_funding WHERE year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE installation_date (id INT, solar_panel_id INT, installation_date DATE, country VARCHAR(50)); | How many solar_panels were installed in India before 2015? | SELECT COUNT(*) AS panels_installed FROM solar_panels sp JOIN installation_date id ON sp.id = id.solar_panel_id WHERE id.installation_date < '2015-01-01' AND sp.country = 'India'; | gretelai_synthetic_text_to_sql |
CREATE TABLE locations (location_id INT PRIMARY KEY, location_name VARCHAR(50), country VARCHAR(50)); | Insert a new record into the 'locations' table with the following details: 'location_id' as 5, 'location_name' as 'Rainforest', 'country' as 'Brazil' | INSERT INTO locations (location_id, location_name, country) VALUES (5, 'Rainforest', 'Brazil'); | gretelai_synthetic_text_to_sql |
CREATE TABLE manufacturing_sites (id INT, name TEXT, country TEXT); INSERT INTO manufacturing_sites (id, name, country) VALUES (1, 'Site A', 'India'), (2, 'Site B', 'China'), (3, 'Site C', 'Germany'); CREATE TABLE emissions (site_id INT, emission_date DATE, co2_emission INT); INSERT INTO emissions (site_id, emission_date, co2_emission) VALUES (1, '2022-01-01', 150), (1, '2022-01-02', 145), (1, '2022-01-03', 155), (2, '2022-01-01', 200), (2, '2022-01-02', 195), (2, '2022-01-03', 210), (3, '2022-01-01', 100), (3, '2022-01-02', 105), (3, '2022-01-03', 95); | What was the average daily CO2 emission for each manufacturing site in Q1 2022? | SELECT site_id, AVG(co2_emission) as avg_daily_co2_emission FROM emissions WHERE emission_date BETWEEN '2022-01-01' AND '2022-03-31' GROUP BY site_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE startups (id INT, name TEXT, founding_year INT, founder_ethnicity TEXT); INSERT INTO startups (id, name, founding_year, founder_ethnicity) VALUES (1, 'DiverseStartupA', 2018, 'Latinx'), (2, 'DiverseStartupB', 2020, 'Black'), (3, 'NonDiverseStartup', 2016, 'White'); | Find the total funding raised by startups founded by Latinx or Black individuals in the past 5 years. | SELECT SUM(r.funding_amount) FROM startups s INNER JOIN investment_rounds r ON s.id = r.startup_id WHERE s.founder_ethnicity IN ('Latinx', 'Black') AND s.founding_year >= YEAR(CURRENT_DATE) - 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE budget (state VARCHAR(20), service VARCHAR(20), amount INT); INSERT INTO budget (state, service, amount) VALUES ('California', 'Education', 50000), ('California', 'Healthcare', 70000), ('New York', 'Education', 60000), ('New York', 'Healthcare', 40000); | Find the difference in budget allocated for education between 'California' and 'New York'. | SELECT b1.amount - b2.amount FROM budget b1 JOIN budget b2 ON b1.service = b2.service WHERE b1.state = 'California' AND b2.state = 'New York' AND b1.service = 'Education'; | gretelai_synthetic_text_to_sql |
CREATE TABLE restaurant_sales (date DATE, menu_category VARCHAR(255), sales FLOAT); INSERT INTO restaurant_sales (date, menu_category, sales) VALUES ('2020-01-01', 'Appetizers', 1200), ('2020-01-01', 'Entrees', 3500), ('2020-01-01', 'Desserts', 1800), ('2020-01-02', 'Appetizers', 1400), ('2020-01-02', 'Entrees', 3000), ('2020-01-02', 'Desserts', 1600); | What are the total sales for each menu category in January 2020? | SELECT menu_category, SUM(sales) as total_sales FROM restaurant_sales WHERE date BETWEEN '2020-01-01' AND '2020-01-31' GROUP BY menu_category; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotel_carbon(id INT, hotel_name TEXT, country TEXT, guests INT, carbon_footprint INT); INSERT INTO hotel_carbon (id, hotel_name, country, guests, carbon_footprint) VALUES (1, 'Hotel 1', 'India', 50, 12000), (2, 'Hotel 2', 'India', 75, 15000), (3, 'Hotel 3', 'India', 100, 20000); | What is the average carbon footprint of hotels in India per guest? | SELECT AVG(carbon_footprint / guests) FROM hotel_carbon WHERE country = 'India'; | gretelai_synthetic_text_to_sql |
CREATE TABLE program_impact (id INT, region VARCHAR(50), impact INT); INSERT INTO program_impact (id, region, impact) VALUES (1, 'North', 100), (2, 'South', 150), (3, 'East', 75), (4, 'West', 200); | What was the average program impact per region in 2021? | SELECT region, AVG(impact) AS avg_impact FROM program_impact WHERE YEAR(region) = 2021 GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE mining_operations (id INT, name VARCHAR(50), num_employees INT, environmental_impact_score INT); | Find the mining operations that have a low environmental impact score and also a high number of employees. | SELECT name FROM mining_operations WHERE num_employees > (SELECT AVG(num_employees) FROM mining_operations) AND environmental_impact_score < (SELECT AVG(environmental_impact_score) FROM mining_operations); | gretelai_synthetic_text_to_sql |
CREATE TABLE offenders (offender_id INT, age INT, city VARCHAR(20), charge VARCHAR(20)); INSERT INTO offenders (offender_id, age, city, charge) VALUES (1, 25, 'Toronto', 'Drug possession'); INSERT INTO offenders (offender_id, age, city, charge) VALUES (2, 30, 'Toronto', 'Drug trafficking'); | What is the minimum age of offenders in the justice system in Toronto who have been charged with a crime related to drugs? | SELECT MIN(age) FROM offenders WHERE city = 'Toronto' AND charge LIKE '%Drug%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE virtual_tourism_impact (city TEXT, local_impact DECIMAL(5,2)); INSERT INTO virtual_tourism_impact (city, local_impact) VALUES ('Barcelona', 1.25); | What is the local economic impact of virtual tourism in Barcelona? | SELECT local_impact FROM virtual_tourism_impact WHERE city = 'Barcelona'; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotels (id INT, name TEXT, region TEXT, rating FLOAT); INSERT INTO hotels (id, name, region, rating) VALUES (1, 'Hotel S', 'Asia-Pacific', 4.6), (2, 'Hotel T', 'Asia-Pacific', 4.3), (3, 'Hotel U', 'Americas', 4.8); | What is the average rating of hotels in the 'Asia-Pacific' region? | SELECT AVG(rating) FROM hotels WHERE region = 'Asia-Pacific'; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (id INT, product_name VARCHAR(50), category VARCHAR(50), size VARCHAR(10), price DECIMAL(10,2), price_date DATE); INSERT INTO products (id, product_name, category, size, price, price_date) VALUES (3, 'Green Shirt', 'Tops', 'M', 60, '2022-01-03'), (4, 'Blue Jeans', 'Bottoms', '32', 100, '2022-02-04'); | Which products have had a price decrease, and what was the previous price? | SELECT product_name, category, size, price, price_date, LEAD(price) OVER (PARTITION BY product_name ORDER BY price_date ASC) as next_price FROM products WHERE price < next_price OR next_price IS NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE training_programs (id INT, name VARCHAR(255), country VARCHAR(255), enrollment INT); | Insert a new record into the 'training_programs' table with id 401, name 'Robotics Fundamentals', country 'Brazil', and enrollment 25 | INSERT INTO training_programs (id, name, country, enrollment) VALUES (401, 'Robotics Fundamentals', 'Brazil', 25); | gretelai_synthetic_text_to_sql |
CREATE TABLE immunizations (id INT, region VARCHAR(255), year INT); INSERT INTO immunizations VALUES (1, 'RegionA', 2019), (2, 'RegionB', 2019), (3, 'RegionA', 2019); | How many immunizations were administered by region in 2019? | SELECT region, COUNT(*) AS immunizations FROM immunizations WHERE year = 2019 GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE startups (startup_id INT, founder_ethnicity VARCHAR(50), funding_amount INT); INSERT INTO startups VALUES (1, 'Latinx', 1500000), (2, 'Asian', 750000), (3, 'Caucasian', 300000); | What is the total funding received by Latinx-founded startups? | SELECT founder_ethnicity, SUM(funding_amount) as total_funding FROM startups WHERE founder_ethnicity = 'Latinx' GROUP BY founder_ethnicity; | gretelai_synthetic_text_to_sql |
CREATE TABLE ocean_floors (floor_name VARCHAR(255), location VARCHAR(255), max_depth DECIMAL(6,2)); INSERT INTO ocean_floors (floor_name, location, max_depth) VALUES ('Milwaukee Deep', 'Atlantic Ocean', 8380.00), ('Puerto Rico Trench', 'Atlantic Ocean', 8605.00), ('South Sandwich Trench', 'Atlantic Ocean', 8428.00); | What is the average depth of the deepest points in the Atlantic Ocean? | SELECT AVG(max_depth) FROM (SELECT max_depth FROM ocean_floors WHERE location = 'Atlantic Ocean' ORDER BY max_depth DESC LIMIT 1) AS subquery; | gretelai_synthetic_text_to_sql |
CREATE TABLE regions (region_id INT, region_name VARCHAR(255)); CREATE TABLE hospitals (hospital_id INT, hospital_name VARCHAR(255), hospital_type VARCHAR(255), region_id INT); INSERT INTO regions (region_id, region_name) VALUES (1, 'North'), (2, 'South'), (3, 'East'), (4, 'West'); INSERT INTO hospitals (hospital_id, hospital_name, hospital_type, region_id) VALUES (1, 'Hospital A', 'Public', 1), (2, 'Hospital B', 'Private', 2), (3, 'Hospital C', 'Public', 3), (4, 'Hospital D', 'Private', 4); | What is the number of hospitals in each region, grouped by type? | SELECT region_name, hospital_type, COUNT(*) as hospital_count FROM hospitals h JOIN regions r ON h.region_id = r.region_id GROUP BY region_name, hospital_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE social_enterprises (enterprise_id INT, sector VARCHAR(20), investment_received FLOAT); INSERT INTO social_enterprises (enterprise_id, sector, investment_received) VALUES (1, 'renewable energy', 120000), (2, 'education', 80000), (3, 'renewable energy', 180000); | Which social enterprises are in the 'renewable energy' sector and have received investments over $100,000? | SELECT enterprise_id, sector, investment_received FROM social_enterprises WHERE sector = 'renewable energy' AND investment_received > 100000; | gretelai_synthetic_text_to_sql |
CREATE TABLE recycling_rates_state_v2 (sector VARCHAR(20), state VARCHAR(20), material VARCHAR(20), recycling_rate DECIMAL(5,2)); INSERT INTO recycling_rates_state_v2 (sector, state, material, recycling_rate) VALUES ('residential', 'California', 'plastic', 0.20), ('commercial', 'California', 'plastic', 0.35), ('residential', 'Texas', 'paper', 0.50), ('commercial', 'Texas', 'plastic', 0.30); | What is the plastic recycling rate in the commercial sector in Texas? | SELECT recycling_rate FROM recycling_rates_state_v2 WHERE sector = 'commercial' AND material = 'plastic' AND state = 'Texas'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ExcavationSites (SiteID INT, SiteName TEXT, Country TEXT, StartDate DATE, EndDate DATE);CREATE TABLE Artifacts (ArtifactID INT, SiteID INT, ArtifactName TEXT, ArtifactType TEXT);CREATE VIEW ArtifactTypePerSite AS SELECT SiteID, ArtifactType FROM Artifacts GROUP BY SiteID, ArtifactType; | List all excavation sites and their artifact types | SELECT e.SiteName, at.ArtifactType FROM ExcavationSites e JOIN ArtifactTypePerSite at ON e.SiteID = at.SiteID; | gretelai_synthetic_text_to_sql |
CREATE TABLE investors(id INT, name TEXT, type TEXT); CREATE VIEW angel_investors AS SELECT * FROM investors WHERE type = 'Angel Investor'; CREATE TABLE investments(id INT, investor_id INT, startup_id INT, investment_amount FLOAT); INSERT INTO investors (id, name, type) VALUES (1, 'John Doe', 'Angel Investor'); INSERT INTO investors (id, name, type) VALUES (2, 'Jane Smith', 'VC'); INSERT INTO investors (id, name, type) VALUES (3, 'Jim Brown', 'Angel Investor'); INSERT INTO investments (id, investor_id, startup_id, investment_amount) VALUES (1, 1, 1, 500000); INSERT INTO investments (id, investor_id, startup_id, investment_amount) VALUES (2, 2, 3, 2000000); INSERT INTO investments (id, investor_id, startup_id, investment_amount) VALUES (3, 3, 2, 750000); | Show the average investment amount made by angel investors | SELECT AVG(investment_amount) FROM investments i JOIN angel_investors a ON i.investor_id = a.id; | gretelai_synthetic_text_to_sql |
CREATE TABLE threat_intelligence (id INT, threat_type VARCHAR(50), threat_level VARCHAR(50), region VARCHAR(50)); INSERT INTO threat_intelligence (id, threat_type, threat_level, region) VALUES (1, 'Cyber', 'Medium', 'Asia'), (2, 'Physical', 'Low', 'Middle East'); | Update the threat level of all records in the Middle East region to 'High'? | UPDATE threat_intelligence SET threat_level = 'High' WHERE region = 'Middle East'; | gretelai_synthetic_text_to_sql |
CREATE TABLE patients (id INT, name TEXT, age INT, treatment TEXT, treatment_year INT); INSERT INTO patients (id, name, age, treatment, treatment_year) VALUES (1, 'John Doe', 35, 'CBT, Medication', 2022), (2, 'Jane Smith', 40, 'DBT', 2021); | What is the average age of patients who received a combination of therapy and medication in 2022? | SELECT AVG(age) FROM patients WHERE treatment LIKE '%CBT%' AND treatment LIKE '%Medication%' AND treatment_year = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE user_data (user_id INT, age INT, gender VARCHAR(50), heart_rate INT, activity_date DATE); INSERT INTO user_data (user_id, age, gender, heart_rate, activity_date) VALUES (1, 25, 'Male', 80, '2022-09-01'), (2, 35, 'Female', 90, '2022-09-02'), (3, 45, 'Male', 75, '2022-09-03'); | What is the average heart rate of users grouped by age and gender for the last week? | SELECT gender, age, AVG(heart_rate) as avg_heart_rate FROM user_data WHERE activity_date >= DATEADD(week, -1, CURRENT_DATE) GROUP BY gender, age; | gretelai_synthetic_text_to_sql |
CREATE TABLE resources (id INT, subject_area VARCHAR(20), open_pedagogy BOOLEAN); INSERT INTO resources (id, subject_area, open_pedagogy) VALUES (1, 'Science', TRUE), (2, 'Math', FALSE), (3, 'English', TRUE), (4, 'History', FALSE); | What is the distribution of open pedagogy resources by subject area? | SELECT subject_area, COUNT(*) FROM resources WHERE open_pedagogy = TRUE GROUP BY subject_area; | gretelai_synthetic_text_to_sql |
CREATE TABLE financial_capability (client_id INT, name TEXT, score INT); INSERT INTO financial_capability (client_id, name, score) VALUES (8, 'Aisha', 75), (9, 'Khalid', 80), (10, 'Zainab', 70); | What is the average financial capability score for clients in the financial capability database? | SELECT AVG(score) FROM financial_capability; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_code TEXT, product_name TEXT, manufacturing_date DATE); CREATE TABLE raw_materials (raw_material_id INT, product_code TEXT, source_country TEXT); INSERT INTO products (product_code, product_name, manufacturing_date) VALUES ('P1', 'Product A', '2022-03-15'), ('P2', 'Product B', '2021-12-21'); INSERT INTO raw_materials (raw_material_id, product_code, source_country) VALUES (1, 'P1', 'Brazil'), (2, 'P2', 'Canada'); | List the product codes, names, and manufacturing dates for products that were manufactured using raw materials sourced from Brazil and Canada. | SELECT products.product_code, products.product_name, products.manufacturing_date FROM products INNER JOIN raw_materials ON products.product_code = raw_materials.product_code WHERE raw_materials.source_country IN ('Brazil', 'Canada'); | gretelai_synthetic_text_to_sql |
CREATE TABLE RenewableProjects (id INT, project_name TEXT, location TEXT, project_type TEXT, capacity INT); | How many renewable energy projects are in 'RenewableProjects' table, by project type? | SELECT project_type, COUNT(*) FROM RenewableProjects GROUP BY project_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE patients (patient_id INT, age INT, gender TEXT, treatment TEXT, state TEXT); INSERT INTO patients (patient_id, age, gender, treatment, state) VALUES (1, 30, 'Female', 'CBT', 'Texas'); INSERT INTO patients (patient_id, age, gender, treatment, state) VALUES (2, 45, 'Male', 'DBT', 'California'); INSERT INTO patients (patient_id, age, gender, treatment, state) VALUES (3, 25, 'Non-binary', 'Therapy', 'Washington'); INSERT INTO patients (patient_id, age, gender, treatment, state) VALUES (4, 19, 'Female', 'Therapy', 'India'); | What is the minimum age of patients who received therapy in India? | SELECT MIN(age) FROM patients WHERE treatment = 'Therapy' AND state = 'India'; | gretelai_synthetic_text_to_sql |
CREATE TABLE factories (id INT, name VARCHAR(255), country VARCHAR(255), ethical_manufacturing BOOLEAN); INSERT INTO factories (id, name, country, ethical_manufacturing) VALUES (1, 'Eco-friendly Goods Inc', 'Germany', TRUE); INSERT INTO factories (id, name, country, ethical_manufacturing) VALUES (2, 'Green Energy Inc', 'France', TRUE); | How many factories in Germany and France are involved in ethical manufacturing? | SELECT country, SUM(ethical_manufacturing) as total_ethical_manufacturing FROM factories WHERE country IN ('Germany', 'France') GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE AppetizerMenu(menu_item VARCHAR(50), ingredients TEXT, price DECIMAL(5,2)); INSERT INTO AppetizerMenu VALUES('Hummus Plate', 'organic chickpeas 100g, local tahini 50g', 7.99), ('Bruschetta', 'local tomatoes 150g, imported basil 10g', 8.99); | What is the total revenue generated from sustainable ingredients in the appetizer menu? | SELECT SUM(price) FROM AppetizerMenu WHERE ingredients LIKE '%organic%' OR ingredients LIKE '%local%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Vessels (VesselID INT, Name TEXT, Type TEXT, MaxCapacity INT); CREATE TABLE Trips (TripID INT, VesselID INT, Date DATE, CargoWeight INT); INSERT INTO Vessels VALUES (1, 'Tanker 1', 'Oil Tanker', 150000); INSERT INTO Trips VALUES (1, 1, '2022-01-01', 100000), (2, 1, '2022-01-02', 120000); | What is the maximum cargo weight transported by a vessel on a single day? | SELECT MAX(Trips.CargoWeight) FROM Trips WHERE Trips.Date = (SELECT MAX(Date) FROM Trips); | gretelai_synthetic_text_to_sql |
CREATE TABLE patient_record (patient_id INT, patient_name VARCHAR(50), treatment_center VARCHAR(50), improvement_status VARCHAR(50)); INSERT INTO patient_record (patient_id, patient_name, treatment_center, improvement_status) VALUES (4, 'Jane Smith', 'clinic_e', 'No Improvement'); | What are the names of patients who received treatment in 'clinic_e' but did not show improvement? | SELECT patient_name FROM patient_record WHERE treatment_center = 'clinic_e' AND improvement_status = 'No Improvement'; | gretelai_synthetic_text_to_sql |
CREATE TABLE soil_moisture (id INT, farm_id INT, moisture_level FLOAT, measurement_date DATE); | Insert new soil moisture data for farm_id 987 | INSERT INTO soil_moisture (id, farm_id, moisture_level, measurement_date) VALUES (5, 987, 45.6, '2022-06-01'); | gretelai_synthetic_text_to_sql |
CREATE TABLE user_profiles (id INT, user_id INT, ethnicity VARCHAR, media_literacy_score INT); INSERT INTO user_profiles (id, user_id, ethnicity, media_literacy_score) VALUES (1, 1, 'Asian American', 85); INSERT INTO user_profiles (id, user_id, ethnicity, media_literacy_score) VALUES (2, 2, 'African American', 75); | What is the average media literacy score for users from a specific ethnic background? | SELECT ethnicity, AVG(media_literacy_score) as avg_score FROM user_profiles WHERE ethnicity IN ('Asian American', 'African American', 'Hispanic American') GROUP BY ethnicity; | gretelai_synthetic_text_to_sql |
CREATE TABLE mars_missions_status (mission VARCHAR(50), year INTEGER, status VARCHAR(50)); INSERT INTO mars_missions_status (mission, year, status) VALUES ('Mars Pathfinder', 1997, 'Completed'), ('Mars Global Surveyor', 1997, 'Completed'), ('Nozomi', 1998, 'Failed'), ('Mars Climate Orbiter', 1999, 'Failed'), ('Mars Polar Lander', 1999, 'Failed'), ('Mars Odyssey', 2001, 'Operational'), ('Mars Express', 2003, 'Operational'), ('Beagle 2', 2003, 'Failed'), ('Mars Reconnaissance Orbiter', 2006, 'Operational'), ('Phoenix', 2008, 'Completed'), ('Mars Science Laboratory', 2012, 'Operational'), ('Mars Atmosphere and Volatile Evolution', 2013, 'Operational'), ('MAVEN', 2014, 'Operational'), ('ExoMars Trace Gas Orbiter', 2016, 'Operational'), ('InSight', 2018, 'Operational'), ('Hope Mars Mission', 2021, 'Operational'), ('Tianwen-1', 2021, 'Operational'); | What are the names of all Mars missions that failed? | SELECT mission FROM mars_missions_status WHERE status = 'Failed'; | gretelai_synthetic_text_to_sql |
CREATE TABLE publications (id INT, title VARCHAR(50), journal VARCHAR(30)); INSERT INTO publications (id, title, journal) VALUES (1, 'A Study on Renewable Energy', 'Journal of Engineering'), (2, 'The Impact of Climate Change', 'Journal of Natural Sciences'); | Calculate the number of publications in each journal | SELECT journal, COUNT(*) FROM publications GROUP BY journal; | gretelai_synthetic_text_to_sql |
CREATE TABLE storage_utilization (year INT, location TEXT, country TEXT, utilization FLOAT); INSERT INTO storage_utilization (year, location, country, utilization) VALUES (2018, 'Seoul', 'South Korea', 85.0), (2019, 'Seoul', 'South Korea', 88.0), (2020, 'Busan', 'South Korea', 90.0), (2021, 'Incheon', 'South Korea', 92.0); | What is the maximum energy storage utilization (%) in South Korea for each year between 2018 and 2021? | SELECT year, MAX(utilization) FROM storage_utilization WHERE country = 'South Korea' AND year BETWEEN 2018 AND 2021 GROUP BY year; | gretelai_synthetic_text_to_sql |
CREATE TABLE Customers (CustomerID INT, SizeRange TEXT); CREATE TABLE GarmentSales (SaleID INT, CustomerID INT, GarmentID INT, PurchaseDate DATE); CREATE TABLE Garments (GarmentID INT, GarmentName TEXT, IsSustainable BOOLEAN); INSERT INTO Customers VALUES (1, 'XS'), (2, 'S'), (3, 'M'); INSERT INTO GarmentSales VALUES (1, 1, 1, '2022-01-01'), (2, 2, 2, '2022-02-01'), (3, 3, 3, '2022-03-01'); INSERT INTO Garments VALUES (1, 'Garment1', TRUE), (2, 'Garment2', FALSE), (3, 'Garment3', TRUE); | How many customers in each size range purchased sustainable garments in the last 6 months? | SELECT SizeRange, COUNT(*) FROM Customers c JOIN GarmentSales s ON c.CustomerID = s.CustomerID JOIN Garments g ON s.GarmentID = g.GarmentID WHERE IsSustainable = TRUE AND PurchaseDate >= DATEADD(MONTH, -6, CURRENT_DATE) GROUP BY SizeRange; | gretelai_synthetic_text_to_sql |
CREATE TABLE social_good (org VARCHAR(255), year INT, method VARCHAR(255), social_impact FLOAT); INSERT INTO social_good (org, year, method, social_impact) VALUES ('Barefoot College', 2011, 'Training', 0.75), ('Alaveteli', 2013, 'Transparency', 0.82), ('Janastu', 2015, 'Community Network', 0.78); | Update social_good table record where org is 'Alaveteli' and year is 2013 | UPDATE social_good SET method = 'Advocacy', social_impact = 0.85 WHERE org = 'Alaveteli' AND year = 2013; | gretelai_synthetic_text_to_sql |
CREATE TABLE unions (id INT, industry TEXT, country TEXT, num_members INT, total_workforce INT); INSERT INTO unions (id, industry, country, num_members, total_workforce) VALUES (1, 'technology', 'Australia', 1000, 50000), (2, 'manufacturing', 'Australia', 3000, 100000), (3, 'retail', 'Australia', 2000, 80000); | What is the average union membership rate in Australia, rounded to the nearest whole number? | SELECT ROUND(AVG(100.0 * num_members / total_workforce), 0) as avg_union_membership_rate FROM unions WHERE country = 'Australia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE italian_teams (team_id INT, team_name VARCHAR(50)); INSERT INTO italian_teams (team_id, team_name) VALUES (1, 'Juventus'), (2, 'Inter Milan'), (3, 'AC Milan'); CREATE TABLE italian_matches (match_id INT, home_team_id INT, away_team_id INT, home_team_corners INT, away_team_corners INT); INSERT INTO italian_matches (match_id, home_team_id, away_team_id, home_team_corners, away_team_corners) VALUES (1, 1, 2, 7, 5), (2, 2, 3, 4, 6), (3, 3, 1, 6, 7); | What is the maximum number of corners won by a team in a single Serie A season? | SELECT MAX(home_team_corners + away_team_corners) AS max_corners FROM italian_matches; | gretelai_synthetic_text_to_sql |
CREATE TABLE Refugees (id INT, disaster_id INT, name VARCHAR(50), age INT, gender VARCHAR(10), nationality VARCHAR(50)); INSERT INTO Refugees (id, disaster_id, name, age, gender, nationality) VALUES (2, 2, 'Jane Doe', 25, 'Female', 'Country Y'); CREATE TABLE Disaster (id INT, name VARCHAR(50), location VARCHAR(50), type VARCHAR(50), start_date DATE, end_date DATE); INSERT INTO Disaster (id, name, location, type, start_date, end_date) VALUES (2, 'Hurricane', 'Region A', 'Water', '2021-07-01', '2021-07-15'); | How many refugees are there by gender for disasters in 'Region A'? | SELECT Refugees.gender, COUNT(*) FROM Refugees WHERE Refugees.disaster_id IN (SELECT Disaster.id FROM Disaster WHERE Disaster.location = 'Region A') GROUP BY Refugees.gender | gretelai_synthetic_text_to_sql |
CREATE TABLE ai_models (model_id INT, model_name TEXT, explainability_score DECIMAL(3,2), domain TEXT, country TEXT); INSERT INTO ai_models (model_id, model_name, explainability_score, domain, country) VALUES (1, 'ExplainableBoosting', 4.65, 'Healthcare', 'USA'), (2, 'XGBoost', 4.35, 'Finance', 'USA'), (3, 'TabTransformer', 4.55, 'Healthcare', 'USA'); | What is the minimum explainability score for AI models used in finance in the USA? | SELECT MIN(explainability_score) as min_explainability_score FROM ai_models WHERE domain = 'Finance' AND country = 'USA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE AdvocacyEvents (event_id INT, event_organizer VARCHAR(50), event_year INT, event_location VARCHAR(50)); INSERT INTO AdvocacyEvents (event_id, event_organizer, event_year, event_location) VALUES (1, 'Non-Profit A', 2018, 'United States'), (2, 'Non-Profit A', 2019, 'Canada'), (3, 'Non-Profit B', 2018, 'United States'); | How many advocacy events were organized by Non-Profit A in total? | SELECT COUNT(*) FROM AdvocacyEvents WHERE event_organizer = 'Non-Profit A'; | gretelai_synthetic_text_to_sql |
CREATE TABLE rural_infrastructure_country (project_id INT, country VARCHAR(50), project_name VARCHAR(50), completed BOOLEAN); INSERT INTO rural_infrastructure_country (project_id, country, project_name, completed) VALUES (1, 'Mexico', 'Irrigation System', true); | How many rural infrastructure projects were completed in each country in the 'rural_development' database, grouped by country? | SELECT country, COUNT(*) FROM rural_infrastructure_country WHERE completed = true GROUP BY country; | 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-35', '...', 2005, 'USA'), (2, 'Type 45', '...', 2006, 'UK'); | Identify military technologies developed in the last 10 years 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 >= (SELECT YEAR(CURRENT_DATE) - 10); | gretelai_synthetic_text_to_sql |
CREATE TABLE bookings (id INT, tourist_id INT, site_id INT, date DATE, type TEXT); INSERT INTO bookings (id, tourist_id, site_id, date, type) VALUES (1, 101, 1, '2022-01-01', 'virtual'), (2, 102, 2, '2022-01-10', 'on-site'); | What is the total number of tourists who have participated in virtual tours in France? | SELECT COUNT(DISTINCT tourist_id) FROM bookings WHERE country = 'France' AND type = 'virtual'; | gretelai_synthetic_text_to_sql |
CREATE TABLE BudgetAllocations (ID INT, Category TEXT, Quarter INT, Amount FLOAT); INSERT INTO BudgetAllocations (ID, Category, Quarter, Amount) VALUES (1, 'Accessibility Services', 1, 10000.00), (2, 'Policy Advocacy', 2, 15000.00), (3, 'Accessibility Services', 3, 8000.00); | Find the total budget allocated to 'Accessibility Services' in the first three quarters of the fiscal year. | SELECT SUM(Amount) FROM BudgetAllocations WHERE Category = 'Accessibility Services' AND Quarter IN (1, 2, 3); | gretelai_synthetic_text_to_sql |
CREATE TABLE defense_projects (id INT PRIMARY KEY, project_name VARCHAR(255), status VARCHAR(255), planned_start_date DATE); CREATE TABLE military_sales (id INT PRIMARY KEY, project_name VARCHAR(255), seller VARCHAR(255), buyer VARCHAR(255), equipment_type VARCHAR(255), quantity INT); | List all defense projects and their associated military equipment sales, if any, ordered by the defense project name in ascending order. | SELECT defense_projects.project_name, military_sales.* FROM defense_projects LEFT JOIN military_sales ON defense_projects.project_name = military_sales.project_name ORDER BY defense_projects.project_name ASC; | gretelai_synthetic_text_to_sql |
CREATE TABLE Articles (id INT, publication_date DATE, language VARCHAR(255), newspaper VARCHAR(255), word_count INT); INSERT INTO Articles (id, publication_date, language, newspaper, word_count) VALUES (1, '2021-01-01', 'Spanish', 'El País', 800), (2, '2021-02-02', 'English', 'The New York Times', 500), (3, '2021-03-03', 'Spanish', 'El País', 600), (4, '2021-04-04', 'French', 'Le Monde', 700); | How many articles were published in Spanish by the 'El País' newspaper in 2021? | SELECT COUNT(*) FROM Articles WHERE language = 'Spanish' AND newspaper = 'El País' AND YEAR(publication_date) = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE Brands (brand_id INT, brand_name VARCHAR(50), country VARCHAR(50), vegan_certified BOOLEAN); INSERT INTO Brands (brand_id, brand_name, country, vegan_certified) VALUES (1, 'EcoFabric', 'USA', true), (2, 'GreenThreads', 'Canada', true), (3, 'SustainableStyle', 'Australia', true), (4, 'FairFashion', 'Germany', true), (5, 'BambooBrand', 'China', false); | What are the top 5 countries with the most vegan brands? | SELECT country, COUNT(*) as num_vegan_brands FROM Brands WHERE vegan_certified = true GROUP BY country ORDER BY num_vegan_brands DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE SeaLevelData (location VARCHAR(50), year INT, sea_level_rise FLOAT); | What is the average sea level rise in the Pacific region between 1993 and 2021, and how does it compare to the global average sea level rise during the same period? | SELECT w1.sea_level_rise - w2.sea_level_rise AS sea_level_diff FROM (SELECT AVG(sea_level_rise) FROM SeaLevelData WHERE location LIKE 'Pacific%' AND year BETWEEN 1993 AND 2021) w1, (SELECT AVG(sea_level_rise) FROM SeaLevelData WHERE year BETWEEN 1993 AND 2021) w2; | gretelai_synthetic_text_to_sql |
CREATE TABLE Retail (id INT PRIMARY KEY, item_type VARCHAR(20), price DECIMAL(5,2)); INSERT INTO Retail (id, item_type, price) VALUES (1, 'Women_Scarf', 30.00), (2, 'Women_Handbag', 150.00); | Find the maximum and minimum retail prices of women's accessories. | SELECT MAX(price), MIN(price) FROM Retail WHERE item_type LIKE 'Women%' AND item_type LIKE '%Accessory'; | gretelai_synthetic_text_to_sql |
CREATE TABLE players (id INT, name VARCHAR(50), age INT, game VARCHAR(50)); INSERT INTO players (id, name, age, game) VALUES (1, 'John Doe', 25, 'CS:GO'); CREATE TABLE tournaments (id INT, player_id INT, game VARCHAR(50), title VARCHAR(50)); INSERT INTO tournaments (id, player_id, game, title) VALUES (1, 1, 'CS:GO', 'DreamHack'); | What is the average age of players who have participated in CS:GO tournaments? | SELECT AVG(players.age) AS avg_age FROM players JOIN tournaments ON players.id = tournaments.player_id WHERE players.game = 'CS:GO'; | gretelai_synthetic_text_to_sql |
CREATE TABLE multimodal_trips (id INT, cost FLOAT, city VARCHAR(50)); | Find the top 3 most expensive multimodal trips in Sydney? | SELECT cost, id FROM multimodal_trips WHERE city = 'Sydney' ORDER BY cost DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE publications (id INT, title VARCHAR(100), department VARCHAR(50), num_authors INT); | Find the total number of publications and average number of authors per publication for the Physics department. | SELECT COUNT(*) AS total_publications, AVG(num_authors) AS avg_authors_per_publication FROM publications WHERE department = 'Physics'; | gretelai_synthetic_text_to_sql |
CREATE TABLE vehicle_maintenance (maintenance_id INT, vehicle_id INT, maintenance_cost DECIMAL, maintenance_date DATE); CREATE TABLE vehicles (vehicle_id INT, vehicle_type TEXT); INSERT INTO vehicles (vehicle_id, vehicle_type) VALUES (1, 'Bus'), (2, 'Train'), (3, 'Subway Car'); INSERT INTO vehicle_maintenance (maintenance_id, vehicle_id, maintenance_cost, maintenance_date) VALUES (1, 1, 100.00, '2023-03-01'), (2, 1, 120.00, '2023-03-03'), (3, 2, 500.00, '2023-03-02'), (4, 3, 300.00, '2023-03-01'); | What are the average daily maintenance costs for each vehicle? | SELECT v.vehicle_id, v.vehicle_type, AVG(vm.maintenance_cost) AS avg_daily_cost FROM vehicle_maintenance vm JOIN vehicles v ON vm.vehicle_id = v.vehicle_id GROUP BY v.vehicle_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE train_maintenance (maintenance_id INT, region VARCHAR(255), task VARCHAR(255), date DATE); INSERT INTO train_maintenance (maintenance_id, region, task, date) VALUES (1, 'Northeast', 'Wheel replacement', '2022-01-05'), (2, 'Southeast', 'Brake adjustment', '2022-01-10'), (3, 'Midwest', 'Engine tune-up', '2022-01-15'); | Which train maintenance tasks were performed cross-regionally in the last month? | SELECT region, task FROM train_maintenance WHERE date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY region, task HAVING COUNT(DISTINCT region) > 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE mlb_players (player_id INT, name VARCHAR(50), team VARCHAR(50), position VARCHAR(20), jersey_number INT); INSERT INTO mlb_players (player_id, name, team, position, jersey_number) VALUES (1, 'Mike Trout', 'Los Angeles Angels', 'Center Field', 27); INSERT INTO mlb_players (player_id, name, team, position, jersey_number) VALUES (2, 'Mookie Betts', 'Los Angeles Dodgers', 'Right Field', 50); | What is the most common jersey number in the MLB? | SELECT jersey_number FROM mlb_players GROUP BY jersey_number ORDER BY COUNT(*) DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE uranium_mines (id INT, name TEXT, location TEXT, depth FLOAT); INSERT INTO uranium_mines (id, name, location, depth) VALUES (1, 'Mine F', 'Country X', 600.1); INSERT INTO uranium_mines (id, name, location, depth) VALUES (2, 'Mine G', 'Country X', 700.2); INSERT INTO uranium_mines (id, name, location, depth) VALUES (3, 'Mine H', 'Country Y', 500.3); | What is the maximum depth of all uranium mines in 'Country X'? | SELECT MAX(depth) FROM uranium_mines WHERE location = 'Country X'; | gretelai_synthetic_text_to_sql |
CREATE TABLE emergency_calls_q1_2021 (id INT, call_date DATE, call_type VARCHAR(20)); INSERT INTO emergency_calls_q1_2021 (id, call_date, call_type) VALUES (1, '2021-01-01', 'Medical'), (2, '2021-01-02', 'Fire'), (3, '2021-01-03', 'Police'), (4, '2021-02-01', 'Medical'), (5, '2021-02-02', 'Medical'), (6, '2021-03-01', 'Fire'); | List the number of emergency calls for each type in the first quarter of 2021, sorted by type | SELECT call_type, COUNT(*) as total_calls FROM emergency_calls_q1_2021 WHERE call_date BETWEEN '2021-01-01' AND '2021-03-31' GROUP BY call_type ORDER BY total_calls DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE plants (id INT, name VARCHAR(50), country VARCHAR(50), ethical INT); | What is the total number of manufacturing plants in the United Kingdom that have implemented ethical labor practices? | SELECT COUNT(*) FROM plants WHERE country = 'United Kingdom' AND ethical = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE years (year_id INT, year TEXT); INSERT INTO years (year_id, year) VALUES (1, '2022'), (2, '2023'); CREATE TABLE historical_sites (site_id INT, site_name TEXT, country TEXT); INSERT INTO historical_sites (site_id, site_name, country) VALUES (1, 'Colosseum', 'Italy'), (2, 'Leaning Tower of Pisa', 'Italy'); CREATE TABLE tourists (tourist_id INT, site_id INT, year_id INT, tourists INT); INSERT INTO tourists (tourist_id, site_id, year_id) VALUES (1, 1, 1), (2, 1, 1), (3, 2, 1), (4, 1, 2), (5, 2, 2); | How many tourists visited historical sites in Italy last year? | SELECT SUM(tourists) FROM tourists INNER JOIN historical_sites ON tourists.site_id = historical_sites.site_id INNER JOIN years ON tourists.year_id = years.year_id WHERE historical_sites.country = 'Italy' AND years.year = '2022'; | gretelai_synthetic_text_to_sql |
CREATE TABLE investments(id INT, sector VARCHAR(20), esg_score INT); INSERT INTO investments VALUES(1, 'Tech', 85), (2, 'Healthcare', 75), (3, 'Tech', 82); | What is the total number of investments in the Tech sector, excluding investments with an ESG score below 70? | SELECT COUNT(*) as total_investments FROM investments WHERE sector = 'Tech' AND esg_score >= 70; | gretelai_synthetic_text_to_sql |
CREATE TABLE Rainfall (field VARCHAR(50), date DATE, rainfall FLOAT); INSERT INTO Rainfall (field, date, rainfall) VALUES ('Field E', '2022-01-01', 23.6), ('Field E', '2022-02-01', 12.8), ('Field E', '2022-03-01', 18.9); | What is the total rainfall in field E this year? | SELECT SUM(rainfall) FROM Rainfall WHERE field = 'Field E' AND date BETWEEN '2022-01-01' AND CURRENT_DATE; | gretelai_synthetic_text_to_sql |
CREATE TABLE SALES_BY_SIZE(city VARCHAR(20), size VARCHAR(5), quantity INT); INSERT INTO SALES_BY_SIZE(city, size, quantity) VALUES('New York', 'S', 50), ('New York', 'M', 75), ('New York', 'L', 40), ('London', 'S', 45), ('London', 'M', 60), ('London', 'L', 55); | What is the most common size of clothing sold in New York and London? | SELECT size FROM (SELECT size, ROW_NUMBER() OVER (ORDER BY quantity DESC) AS rn FROM (SELECT size, SUM(quantity) AS quantity FROM SALES_BY_SIZE WHERE city IN ('New York', 'London') GROUP BY size) x) y WHERE rn = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE product_origin (product_name TEXT, source_country TEXT); INSERT INTO product_origin (product_name, source_country) VALUES ('Product 11', 'US'), ('Product 12', 'MX'), ('Product 13', 'CA'), ('Product 14', 'US'), ('Product 15', 'DE'); CREATE TABLE product_sales (product_name TEXT, unit_sales INTEGER); INSERT INTO product_sales (product_name, unit_sales) VALUES ('Product 11', 500), ('Product 12', 300), ('Product 13', 400), ('Product 14', 700), ('Product 15', 200); CREATE TABLE ingredients_sourcing (product_name TEXT, has_ingredient_from_CN BOOLEAN); INSERT INTO ingredients_sourcing (product_name, has_ingredient_from_CN) VALUES ('Product 11', false), ('Product 12', true), ('Product 13', false), ('Product 14', false), ('Product 15', false); | How many cosmetics products are sourced from each country, and what is the total unit sales for each country, excluding products that contain ingredients from China? | SELECT source_country, COUNT(*) AS num_products, SUM(unit_sales) AS total_unit_sales FROM product_origin JOIN product_sales ON product_origin.product_name = product_sales.product_name JOIN ingredients_sourcing ON product_sales.product_name = ingredients_sourcing.product_name WHERE ingredients_sourcing.has_ingredient_from_CN = false GROUP BY source_country; | gretelai_synthetic_text_to_sql |
CREATE TABLE students (student_id INT, student_name VARCHAR(255), disability_type VARCHAR(255)); CREATE TABLE accommodations (accommodation_id INT, student_id INT, accommodation_date DATE); | Show the number of accommodations provided for students with different types of disabilities, and the percentage of total accommodations for each disability type? | SELECT s.disability_type, COUNT(a.accommodation_id) as accommodations_count, ROUND(COUNT(a.accommodation_id) * 100.0 / (SELECT COUNT(*) FROM accommodations) , 2) as percentage_of_total FROM students s JOIN accommodations a ON s.student_id = a.student_id GROUP BY s.disability_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE regions (region_id INT, name VARCHAR(255)); INSERT INTO regions VALUES (1, 'Europe'); INSERT INTO regions VALUES (2, 'Asia'); CREATE TABLE factories (factory_id INT, name VARCHAR(255), location VARCHAR(255), country_id INT, labor_rating INT, region_id INT); INSERT INTO factories VALUES (1, 'Ethical Factory Z', 'Paris, France', 1, 90, 1); INSERT INTO factories VALUES (2, 'Fast Fashion Factory A', 'Delhi, India', 2, 70, 2); | List the factories in the 'Europe' region with labor ratings higher than 85. | SELECT factories.name FROM factories JOIN regions ON factories.region_id = regions.region_id WHERE regions.name = 'Europe' AND factories.labor_rating > 85; | gretelai_synthetic_text_to_sql |
CREATE TABLE traditional_dances (id INT PRIMARY KEY, name TEXT, description TEXT, country TEXT); | What are the traditional dances in Guatemala? | SELECT name FROM traditional_dances WHERE country = 'Guatemala'; | gretelai_synthetic_text_to_sql |
CREATE TABLE policyholder (policyholder_id INT, name VARCHAR(50), age INT, gender VARCHAR(10), zip_code INT); CREATE TABLE zip_codes (zip_code INT, median_home_value INT, state VARCHAR(20), city VARCHAR(50)); | What is the name, age, and gender of policyholders who live in a ZIP code with a median home value above the national average, grouped by coverage type? | SELECT coverage_type, AVG(policyholder.age) as average_age, COUNT(DISTINCT policyholder.policyholder_id) as policyholder_count, policyholder.gender FROM policyholder JOIN policy ON policyholder.policy_number = policy.policy_number JOIN zip_codes ON policyholder.zip_code = zip_codes.zip_code WHERE zip_codes.median_home_value > (SELECT AVG(median_home_value) FROM zip_codes) GROUP BY coverage_type, policyholder.gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE security_incidents (sector VARCHAR(255), year INT, time_to_detect FLOAT); INSERT INTO security_incidents (sector, year, time_to_detect) VALUES ('Education', 2022, 4.2), ('Education', 2022, 5.6), ('Education', 2022, 3.9), ('Education', 2022, 6.1), ('Education', 2022, 4.5); | What is the average time to detect a security incident in the education sector in 2022? | SELECT AVG(time_to_detect) FROM security_incidents WHERE sector = 'Education' AND year = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE Environmental_Impact_Assessments (Assessment_Date DATE, Impact_Score INT); INSERT INTO Environmental_Impact_Assessments (Assessment_Date, Impact_Score) VALUES ('2021-01-01', 100), ('2021-02-01', 110), ('2021-03-01', 120), ('2021-04-01', 130); | Find the percentage change in environmental impact assessments for each month compared to the previous month. | SELECT Assessment_Date, (LAG(Impact_Score) OVER (ORDER BY Assessment_Date) - Impact_Score) * 100.0 / LAG(Impact_Score) OVER (ORDER BY Assessment_Date) as Percentage_Change FROM Environmental_Impact_Assessments; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donor (id INT PRIMARY KEY, name VARCHAR(50), country VARCHAR(50)); INSERT INTO Donor (id, name, country) VALUES (1, 'USAID', 'USA'); INSERT INTO Donor (id, name, country) VALUES (2, 'DFID', 'UK'); INSERT INTO Donor (id, name, country) VALUES (3, 'JICA', 'Japan'); | How many donors are there from each country? | SELECT d.country, COUNT(d.id) as num_donors FROM Donor d GROUP BY d.country; | gretelai_synthetic_text_to_sql |
CREATE TABLE Investors (InvestorID INT, InvestorName VARCHAR(50)); CREATE TABLE Investments (InvestmentID INT, InvestorID INT, CompanyID INT, InvestmentAmount DECIMAL(10, 2)); | What is the total number of investments made by each investor? | SELECT I.InvestorName, COUNT(I.InvestmentID) AS TotalInvestments FROM Investments I JOIN Investors ON I.InvestorID = Investors.InvestorID GROUP BY I.InvestorName; | gretelai_synthetic_text_to_sql |
CREATE TABLE Suppliers (ID INT, Name VARCHAR(50), Country VARCHAR(20)); CREATE TABLE Factories (ID INT, Supplier_ID INT, Industry_4_0 BOOLEAN); INSERT INTO Suppliers (ID, Name, Country) VALUES (1, 'Supplier 1', 'Country A'); INSERT INTO Suppliers (ID, Name, Country) VALUES (2, 'Supplier 2', 'Country B'); INSERT INTO Factories (ID, Supplier_ID, Industry_4_0) VALUES (1, 1, TRUE); INSERT INTO Factories (ID, Supplier_ID, Industry_4_0) VALUES (2, 1, FALSE); INSERT INTO Factories (ID, Supplier_ID, Industry_4_0) VALUES (3, 2, TRUE); | List all suppliers from 'Country A' who supply parts to factories that have implemented Industry 4.0 practices, ordered alphabetically by supplier name. | SELECT Suppliers.Name FROM Suppliers INNER JOIN Factories ON Suppliers.ID = Factories.Supplier_ID WHERE Suppliers.Country = 'Country A' AND Factories.Industry_4_0 = TRUE ORDER BY Suppliers.Name; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists bioprocess;CREATE TABLE if not exists bioprocess.companies (id INT PRIMARY KEY, name VARCHAR(100), country VARCHAR(50), expenditure FLOAT, expenditure_date DATE); | What was the total bioprocess engineering expenditure in Q2 2019 for European companies? | SELECT SUM(expenditure) FROM bioprocess.companies WHERE country IN ('Europe') AND expenditure_date BETWEEN '2019-04-01' AND '2019-06-30'; | gretelai_synthetic_text_to_sql |
CREATE TABLE therapy_sessions (id INT, session_name TEXT, duration_mins INT, country TEXT); | What is the average duration of psychodynamic therapy sessions in Italy? | SELECT AVG(duration_mins) FROM therapy_sessions WHERE session_name = 'Psychodynamic Therapy' AND country = 'Italy'; | gretelai_synthetic_text_to_sql |
CREATE TABLE companies (id INT, name TEXT, founder TEXT, funding INT); INSERT INTO companies (id, name, founder, funding) VALUES (1, 'Kappa Corp', 'Jane', 6000000), (2, 'Lambda Ltd', 'John', 8000000); | What is the total funding amount for companies with female founders? | SELECT SUM(funding) FROM companies WHERE founder = 'Jane'; | gretelai_synthetic_text_to_sql |
CREATE TABLE menu_items (item_id INT, item_name TEXT, price DECIMAL(5,2)); INSERT INTO menu_items (item_id, item_name, price) VALUES (1, 'Burger', 9.99), (2, 'Lobster', 34.99), (3, 'Salad', 15.50), (4, 'Fries', 2.50), (5, 'Soda', 2.50), (6, 'Steak', 29.99); | Get the names of all menu items that have a price greater than 10 dollars and less than 25 dollars | SELECT item_name FROM menu_items WHERE price > 10.00 AND price < 25.00; | 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.