context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28 values |
|---|---|---|---|
CREATE TABLE waste_generation (country VARCHAR(50), region VARCHAR(50), waste_generated FLOAT, year INT); INSERT INTO waste_generation (country, region, waste_generated, year) VALUES ('France', 'Europe', 1.5, 2018), ('Germany', 'Europe', 2.1, 2018), ('Spain', 'Europe', 1.3, 2018), ('France', 'Europe', 1.6, 2019), ('Germany', 'Europe', 2.2, 2019), ('Spain', 'Europe', 1.4, 2019); | What was the total waste generated in Europe in 2018 and 2019?' | SELECT SUM(waste_generated) FROM waste_generation WHERE region = 'Europe' AND year IN (2018, 2019); | gretelai_synthetic_text_to_sql |
CREATE TABLE healthcare_access (id INT, county TEXT, uninsured_count INT, total_population INT); | Find the number of uninsured individuals in each county in Florida | SELECT county, uninsured_count FROM healthcare_access WHERE state = 'Florida'; | gretelai_synthetic_text_to_sql |
CREATE TABLE startups(id INT, name TEXT, founder TEXT, exit_strategy_valuation FLOAT, country TEXT); INSERT INTO startups(id, name, founder, exit_strategy_valuation, country) VALUES (1, 'Acme Inc', 'Alex Garcia', 50000000.00, 'US'), (2, 'Beta Corp', 'Jamie Brown', 75000000.00, 'CA'), (3, 'Gamma Startup', 'Sophia Lee', 100000000.00, 'SG'), (4, 'Delta Tech', 'Rajesh Patel', 12000000.00, 'IN'), (5, 'Epsilon Enterprises', 'Kim Taylor', 80000000.00, 'AU'); | Identify the top 3 countries with the highest average exit strategy valuation for startups founded by LGBTQ+ entrepreneurs. | SELECT country, AVG(exit_strategy_valuation) as avg_valuation FROM startups WHERE founder IN ('Alex Garcia', 'Jamie Brown', 'Sophia Lee', 'Kim Taylor') GROUP BY country ORDER BY avg_valuation DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE members (member_id INT, name VARCHAR(50), gender VARCHAR(10), dob DATE); INSERT INTO members (member_id, name, gender, dob) VALUES (1, 'Amina Diop', 'Female', '2000-08-27'); INSERT INTO members (member_id, name, gender, dob) VALUES (2, 'Brock Wilson', 'Male', '1998-02-03'); CREATE TABLE workout_sessions (session_id INT, member_id INT, session_date DATE); INSERT INTO workout_sessions (session_id, member_id, session_date) VALUES (1, 1, '2023-02-02'); INSERT INTO workout_sessions (session_id, member_id, session_date) VALUES (2, 1, '2023-02-10'); INSERT INTO workout_sessions (session_id, member_id, session_date) VALUES (3, 2, '2023-02-15'); INSERT INTO workout_sessions (session_id, member_id, session_date) VALUES (4, 1, '2023-02-25'); | How many workout sessions did each member have in February 2023? | SELECT member_id, COUNT(*) AS sessions_in_feb_2023 FROM workout_sessions WHERE MONTH(session_date) = 2 AND YEAR(session_date) = 2023 GROUP BY member_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Programs (program_id INT, program_name VARCHAR(255), location VARCHAR(255), num_participants INT, impact_assessment DECIMAL(3,2)); | Insert a new record of a program with impact assessment results. | INSERT INTO Programs (program_id, program_name, location, num_participants, impact_assessment) VALUES (1, 'Community Arts Workshop', 'Oakland', 30, 4.25); | gretelai_synthetic_text_to_sql |
CREATE TABLE NaturalProducts (product VARCHAR(255), country VARCHAR(255), price DECIMAL(10,2)); INSERT INTO NaturalProducts (product, country, price) VALUES ('Cleanser', 'Italy', 20), ('Toner', 'Italy', 25), ('Moisturizer', 'Italy', 30), ('Serum', 'Italy', 35); | What is the minimum price of natural skincare products in Italy? | SELECT MIN(price) FROM NaturalProducts WHERE country = 'Italy'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ny_projects (id INT, state VARCHAR(20), year INT, budget FLOAT, renewable BOOLEAN); INSERT INTO ny_projects (id, state, year, budget, renewable) VALUES (1, 'New York', 2016, 10000000, true), (2, 'New York', 2017, 12000000, true), (3, 'New York', 2018, 8000000, false); | What is the minimum budget for renewable energy projects in the state of New York, completed between 2017 and 2019? | SELECT MIN(budget) FROM ny_projects WHERE state = 'New York' AND year BETWEEN 2017 AND 2019 AND renewable = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE peacekeeping_operations (id INT, country VARCHAR(255), year INT, operations INT); INSERT INTO peacekeeping_operations (id, country, year, operations) VALUES (1, 'Brazil', 2020, 15), (2, 'China', 2020, 10), (3, 'Canada', 2020, 20); | How many peacekeeping operations were conducted by country in 2020? | SELECT country, SUM(operations) as total_operations FROM peacekeeping_operations WHERE year = 2020 GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE tech_accessibility (country VARCHAR(50), initiative_count INT); INSERT INTO tech_accessibility (country, initiative_count) VALUES ('India', 120), ('South Africa', 80), ('Brazil', 95); | Which countries have the most technology accessibility initiatives? | SELECT country, initiative_count FROM tech_accessibility ORDER BY initiative_count DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE Routes (id INT, origin_city VARCHAR(255), destination_city VARCHAR(255), distance INT, etd DATE, eta DATE); | What is the average delivery time for shipments from India to the United States? | SELECT AVG(DATEDIFF(day, etd, eta)) as avg_delivery_time FROM Routes WHERE origin_city IN (SELECT city FROM Warehouse WHERE country = 'India') AND destination_city IN (SELECT city FROM Warehouse WHERE country = 'United States'); | gretelai_synthetic_text_to_sql |
CREATE TABLE menu_items (item_name VARCHAR(50), menu_category VARCHAR(50), is_gluten_free BOOLEAN); INSERT INTO menu_items (item_name, menu_category, is_gluten_free) VALUES ('Garden Salad', 'Appetizers', true), ('Margherita Pizza', 'Entrees', true), ('Cheeseburger', 'Entrees', false); | How many items in each menu category are gluten-free? | SELECT menu_category, COUNT(*) FROM menu_items WHERE is_gluten_free = true GROUP BY menu_category; | gretelai_synthetic_text_to_sql |
CREATE TABLE graduate_programs (id INT, name TEXT, department TEXT); INSERT INTO graduate_programs (id, name, department) VALUES (1, 'MS in Computer Science', 'Computer Science'), (2, 'PhD in Physics', 'Physics'), (3, 'MA in History', 'History'), (4, 'MS in Mechanical Engineering', 'Mechanical Engineering'), (5, 'MA in Mathematics', 'Mathematics'); CREATE TABLE students (id INT, program_id INT, country TEXT); INSERT INTO students (id, program_id, country) VALUES (1, 1, 'USA'), (2, 1, 'India'), (3, 1, 'Canada'), (4, 2, 'Germany'), (5, 2, 'USA'), (6, 3, 'USA'), (7, 3, 'Mexico'), (8, 4, 'China'), (9, 4, 'USA'), (10, 4, 'Canada'), (11, 5, 'France'), (12, 5, 'Germany'), (13, 5, 'USA'); | List the top 3 graduate programs with the highest number of international students, excluding any programs with less than 5 international students. | SELECT graduate_programs.name, COUNT(students.id) as num_international_students FROM graduate_programs INNER JOIN students ON graduate_programs.id = students.program_id WHERE students.country NOT IN ('USA') GROUP BY graduate_programs.name HAVING num_international_students >= 5 ORDER BY num_international_students DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE consumer_awareness (id INT PRIMARY KEY, country VARCHAR(50), awareness DECIMAL(3,2)); INSERT INTO consumer_awareness (id, country, awareness) VALUES (1, 'Germany', 0.85), (2, 'Italy', 0.70), (3, 'France', 0.80); | Delete consumer awareness for Italy | DELETE FROM consumer_awareness WHERE country = 'Italy'; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (id INT, species_name VARCHAR(50), common_name VARCHAR(50), region VARCHAR(20), conservation_status VARCHAR(20));INSERT INTO marine_species (id, species_name, common_name, region, conservation_status) VALUES (1, 'Orcinus_orca', 'Killer Whale', 'Arctic', 'Least Concern');INSERT INTO marine_species (id, species_name, common_name, region, conservation_status) VALUES (2, 'Balaenoptera_bonaerensis', 'Antarctic Minke Whale', 'Antarctic', 'Vulnerable'); | Find the total number of marine species in each region that are threatened or endangered. | SELECT region, conservation_status, COUNT(*) FROM marine_species GROUP BY region, conservation_status HAVING conservation_status IN ('Threatened', 'Endangered'); | gretelai_synthetic_text_to_sql |
CREATE TABLE WorkplaceSafety (id INT PRIMARY KEY, union_member BOOLEAN, incident_date DATE, incident_type VARCHAR(20), severity INT); CREATE TABLE UnionMembers (id INT PRIMARY KEY, name VARCHAR(50), state VARCHAR(2), union_id INT, FOREIGN KEY (union_id) REFERENCES UnionNegotiations(union_id)); CREATE TABLE UnionNegotiations (id INT PRIMARY KEY, union_id INT); | List all work-related injuries among non-union workers in California over the past year, ordered by date. | SELECT * FROM WorkplaceSafety WHERE union_member = FALSE AND incident_date >= DATE(NOW()) - INTERVAL 1 YEAR ORDER BY incident_date; | gretelai_synthetic_text_to_sql |
CREATE TABLE traffic_violations (id INT, date DATE, state VARCHAR(255)); INSERT INTO traffic_violations (id, date, state) VALUES (1, '2021-01-01', 'Texas'), (2, '2021-01-15', 'Texas'), (3, '2021-02-01', 'Texas'); | How many traffic violations were issued in the state of Texas in the last year? | SELECT COUNT(*) FROM traffic_violations WHERE state = 'Texas' AND date > DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR); | gretelai_synthetic_text_to_sql |
CREATE VIEW oceania_hotels AS SELECT * FROM hotels WHERE continent = 'Oceania'; CREATE VIEW ai_adopters AS SELECT hotel_id FROM ai_tech WHERE adoption_date IS NOT NULL; | What is the percentage of hotels in the 'oceania_hotels' view that have adopted AI technology? | SELECT COUNT(*) * 100.0 / (SELECT COUNT(*) FROM oceania_hotels) as percentage FROM ai_adopters; | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists Projects (id INT, name VARCHAR(50), type VARCHAR(50), budget DECIMAL(10,2), start_date DATE); INSERT INTO Projects (id, name, type, budget, start_date) VALUES (1, 'Seawall', 'Resilience', 5000000.00, '2022-01-01'), (2, 'Floodgate', 'Resilience', 3000000.00, '2022-02-01'), (3, 'Bridge', 'Transportation', 8000000.00, '2021-12-01'), (4, 'Highway', 'Transportation', 12000000.00, '2022-03-15'), (7, 'Tunnel', 'Transportation', 10000000.00, '2023-01-01'); CREATE TABLE if not exists States (id INT, name VARCHAR(50)); INSERT INTO States (id, name) VALUES (1, 'California'), (2, 'Texas'), (3, 'New York'); | List all transportation projects in the state of New York, along with their budgets and start dates. | SELECT name, budget, start_date FROM Projects INNER JOIN States ON Projects.id = 3 AND States.name = 'New York' WHERE type = 'Transportation'; | gretelai_synthetic_text_to_sql |
CREATE TABLE renewable_energy_projects (id INT, project_name TEXT, country TEXT, technology TEXT, installed_capacity FLOAT); INSERT INTO renewable_energy_projects (id, project_name, country, technology, installed_capacity) VALUES (1, 'Project A', 'country1', 'solar', 200.0), (2, 'Project B', 'country2', 'wind', 150.0), (3, 'Project C', 'country1', 'wind', 300.0); | What is the total installed capacity of solar and wind projects in 'country1'? | SELECT SUM(installed_capacity) FROM renewable_energy_projects WHERE country = 'country1' AND technology IN ('solar', 'wind'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Hospitals (hospital_id INT, hospital_name TEXT);CREATE TABLE ParityViolations (violation_id INT, violation_hospital INT); | What is the number of mental health parity violations per hospital? | SELECT h.hospital_name, COUNT(*) as num_violations FROM ParityViolations pv JOIN Hospitals h ON pv.violation_hospital = h.hospital_id GROUP BY h.hospital_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE carbon_prices (id INT, country TEXT, price FLOAT, date DATE); | What is the average carbon price in the EU in Q2 2020? | SELECT AVG(price) FROM carbon_prices WHERE country LIKE 'EU%' AND QUARTER(date) = 2 AND YEAR(date) = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE artifact_analysis (id INT, artifact_name VARCHAR(50), material VARCHAR(50), weight INT); INSERT INTO artifact_analysis (id, artifact_name, material, weight) VALUES (1, 'copper_ring', 'copper', 50); | What is the total weight of all copper artifacts in the 'artifact_analysis' table? | SELECT SUM(weight) FROM artifact_analysis WHERE material = 'copper'; | gretelai_synthetic_text_to_sql |
CREATE TABLE defense_diplomacy (id INT, event_name VARCHAR(50), date DATE, location VARCHAR(50)); INSERT INTO defense_diplomacy (id, event_name, date, location) VALUES (1, 'Defense Symposium', '2022-06-01', 'Asia'); INSERT INTO defense_diplomacy (id, event_name, date, location) VALUES (2, 'Military Diplomacy Conference', '2022-05-15', 'Europe'); INSERT INTO defense_diplomacy (id, event_name, date, location) VALUES (3, 'Defense Dialogue', '2022-03-01', 'South America'); | How many defense diplomacy events took place in 'South America' in the year 2022? | SELECT COUNT(*) FROM defense_diplomacy WHERE location = 'South America' AND YEAR(date) = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE Policy (PolicyID INT, PolicyType VARCHAR(50)); INSERT INTO Policy VALUES (1, 'Auto'), (2, 'Home'), (3, 'Life'), (4, 'Travel'), (5, 'Health'); CREATE TABLE RiskAssessment (AssessmentID INT, PolicyID INT, Model VARCHAR(50)); | Add a new risk assessment model for policy type 'Health'. | INSERT INTO RiskAssessment (AssessmentID, PolicyID, Model) VALUES (1, 5, 'GeneralHealth'); | gretelai_synthetic_text_to_sql |
CREATE TABLE species (id INT, name VARCHAR(255), max_depth FLOAT); | Find the maximum depth that any marine species can be found at | SELECT MAX(max_depth) FROM species; | gretelai_synthetic_text_to_sql |
CREATE TABLE habitat (id INT PRIMARY KEY, name VARCHAR(50), location VARCHAR(50), size FLOAT, status VARCHAR(50)); | Delete a habitat preservation project from the 'habitat' table | DELETE FROM habitat WHERE name = 'Coral Reef Restoration'; | gretelai_synthetic_text_to_sql |
CREATE TABLE CaseHandling (CaseHandlingID INT, AttorneyID INT, PracticeArea VARCHAR(50)); INSERT INTO CaseHandling (CaseHandlingID, AttorneyID, PracticeArea) VALUES (1, 1, 'Civil Law'), (2, 1, 'Civil Law'), (3, 2, 'Criminal Law'); | Display the number of cases handled by each attorney, grouped by their respective practice areas. | SELECT p.PracticeArea, COUNT(ch.AttorneyID) AS NumberOfCases FROM CaseHandling ch JOIN Attorneys p ON ch.AttorneyID = p.AttorneyID GROUP BY p.PracticeArea; | gretelai_synthetic_text_to_sql |
CREATE TABLE travel_advisories (id INT, country TEXT, year INT, advisory_level INT); INSERT INTO travel_advisories (id, country, year, advisory_level) VALUES (1, 'Egypt', 2023, 2), (2, 'Egypt', 2023, 2), (3, 'Egypt', 2023, 3); | What is the minimum advisory level for travel to Egypt in 2023? | SELECT MIN(advisory_level) FROM travel_advisories WHERE country = 'Egypt' AND year = 2023; | gretelai_synthetic_text_to_sql |
CREATE TABLE mental_health_providers (provider_id INT, age INT, county VARCHAR(255)); INSERT INTO mental_health_providers (provider_id, age, county) VALUES (1, 45, 'Orange County'); INSERT INTO mental_health_providers (provider_id, age, county) VALUES (2, 50, 'Los Angeles County'); INSERT INTO mental_health_providers (provider_id, age, county) VALUES (3, 35, 'Orange County'); | What is the average age of mental health providers by county? | SELECT county, AVG(age) as avg_age FROM mental_health_providers GROUP BY county; | gretelai_synthetic_text_to_sql |
CREATE TABLE Chemical_Plant (plant_name VARCHAR(255), location VARCHAR(255), chemical VARCHAR(255), quantity INT);INSERT INTO Chemical_Plant (plant_name, location, chemical, quantity) VALUES ('Chemical Plant F', 'California', 'Sulfuric Acid', 900), ('Chemical Plant G', 'California', 'Sulfuric Acid', 1100), ('Chemical Plant H', 'Oregon', 'Sulfuric Acid', 1300); | What are the total quantities of 'Sulfuric Acid' produced in 'California' and 'Oregon'? | SELECT SUM(quantity) FROM Chemical_Plant WHERE (location = 'California' OR location = 'Oregon') AND chemical = 'Sulfuric Acid'; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_development (id INT PRIMARY KEY, name TEXT, country TEXT, budget INT); INSERT INTO community_development (id, name, country, budget) VALUES (1, 'Youth Skills Training', 'USA', 2000000); INSERT INTO community_development (id, name, country, budget) VALUES (2, 'Women Empowerment Program', 'Mexico', 1500000); INSERT INTO community_development (id, name, country, budget) VALUES (3, 'Elderly Care Center', 'Canada', 1000000); | What is the total budget allocated for community development initiatives in each country in the 'rural_development' database? | SELECT country, SUM(budget) as total_budget FROM community_development GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE space_exploration (id INT, mission_name VARCHAR(255), mission_status VARCHAR(255), agency VARCHAR(255), launch_date DATE); | Show all records in the space_exploration table where the mission_status is 'Completed' or agency is 'ESA' | SELECT * FROM space_exploration WHERE mission_status = 'Completed' OR agency = 'ESA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE green_buildings (id INT, name VARCHAR(50), city VARCHAR(50), country VARCHAR(50), certification VARCHAR(50)); INSERT INTO green_buildings (id, name, city, country, certification) VALUES (1, 'GreenHeights', 'San Francisco', 'USA', 'LEED Platinum'); CREATE TABLE smart_cities (id INT, city VARCHAR(50), country VARCHAR(50), population INT, technology VARCHAR(50)); INSERT INTO smart_cities (id, city, country, population, technology) VALUES (1, 'San Francisco', 'USA', 864000, 'smart grid'); CREATE TABLE carbon_offsets (id INT, initiative_name VARCHAR(50), city VARCHAR(50), country VARCHAR(50), offset_amount INT); INSERT INTO carbon_offsets (id, initiative_name, city, country, offset_amount) VALUES (1, 'TreesForAll', 'London', 'UK', 5000); | Show the names of smart cities that have both a carbon offset initiative and a LEED certified building in the same city. | SELECT s.name FROM smart_cities s INNER JOIN green_buildings g ON s.city = g.city INNER JOIN carbon_offsets c ON s.city = c.city WHERE g.certification = 'LEED'; | gretelai_synthetic_text_to_sql |
CREATE TABLE plans (id INT PRIMARY KEY, name VARCHAR(50), monthly_cost DECIMAL(5,2)); CREATE TABLE subscribers (id INT PRIMARY KEY, name VARCHAR(50), technology VARCHAR(20)); CREATE TABLE infrastructure (tech_type VARCHAR(20) PRIMARY KEY, num_towers INT); INSERT INTO plans (id, name, monthly_cost) VALUES (1, 'Basic', 20.00), (2, 'Premium', 50.00); INSERT INTO subscribers (id, name, technology) VALUES (1, 'Alice', 'Mobile'), (2, 'Bob', 'Broadband'), (3, 'Charlie', 'Mobile'); INSERT INTO infrastructure (tech_type, num_towers) VALUES ('Mobile', 20), ('Broadband', 15); | Find the average monthly cost of mobile plans and the average number of towers for each technology type in the "plans", "subscribers", and "infrastructure" tables. | SELECT i.tech_type, AVG(plans.monthly_cost) AS avg_monthly_cost, AVG(infrastructure.num_towers) AS avg_num_towers FROM plans INNER JOIN subscribers ON plans.id = (SELECT plan_id FROM regional_sales WHERE regional_sales.id = subscribers.id) INNER JOIN infrastructure ON subscribers.technology = infrastructure.tech_type GROUP BY i.tech_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_districts (cd_number INT, community_name VARCHAR(255)); INSERT INTO community_districts (cd_number, community_name) VALUES (1, 'East Harlem'), (2, 'Harlem'), (3, 'Washington Heights'); CREATE TABLE arrest_data (arrest_date DATE, cd_number INT, arrest_count INT); | What was the total number of arrests made in each community district for the past year? | SELECT cd.community_name, SUM(ad.arrest_count) as total_arrests FROM community_districts cd JOIN arrest_data ad ON cd.cd_number = ad.cd_number WHERE ad.arrest_date >= CURDATE() - INTERVAL 1 YEAR GROUP BY cd.community_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE positions (id INT, name VARCHAR(50), position VARCHAR(50), age INT); INSERT INTO positions (id, name, position, age) VALUES (1, 'John Doe', 'Mining Engineer', 35), (2, 'Jane Smith', 'Supervisor', 45), (3, 'Alice Johnson', 'Mining Engineer', 38); | What is the average age of mining engineers and supervisors? | SELECT AVG(age) AS avg_age FROM positions WHERE position IN ('Mining Engineer', 'Supervisor'); | gretelai_synthetic_text_to_sql |
CREATE TABLE water_usage (year INT, usage FLOAT); INSERT INTO water_usage (year, usage) VALUES (2018, 1234.56), (2019, 2345.67), (2020, 3456.78), (2021, 4567.89); | Identify the year with the highest water usage | SELECT year FROM water_usage WHERE usage = (SELECT MAX(usage) FROM water_usage); | gretelai_synthetic_text_to_sql |
CREATE TABLE CulturalCompetency (LevelID INT, Level VARCHAR(50)); CREATE TABLE MentalHealthScores (MH_ID INT, LevelID INT, MentalHealthScore INT); INSERT INTO CulturalCompetency (LevelID, Level) VALUES (1, 'Basic'), (2, 'Intermediate'), (3, 'Advanced'); INSERT INTO MentalHealthScores (MH_ID, LevelID, MentalHealthScore) VALUES (1, 1, 70), (2, 1, 75), (3, 2, 80), (4, 2, 85), (5, 3, 90), (6, 3, 95); | What is the minimum mental health score by community health worker's cultural competency level? | SELECT c.Level, MIN(mhs.MentalHealthScore) as Min_Score FROM MentalHealthScores mhs JOIN CulturalCompetency c ON mhs.LevelID = c.LevelID GROUP BY c.Level; | gretelai_synthetic_text_to_sql |
CREATE TABLE contract_negotiations (negotiation_id INT, vendor_1 VARCHAR(255), vendor_2 VARCHAR(255), negotiation_date DATE); INSERT INTO contract_negotiations (negotiation_id, vendor_1, vendor_2, negotiation_date) VALUES (1, 'Acme Corp', 'Global Defence Corp', '2021-01-01'); | List all contract negotiations involving both Acme Corp and Global Defence Corp. | SELECT vendor_1, vendor_2 FROM contract_negotiations WHERE (vendor_1 = 'Acme Corp' AND vendor_2 = 'Global Defence Corp') OR (vendor_1 = 'Global Defence Corp' AND vendor_2 = 'Acme Corp'); | gretelai_synthetic_text_to_sql |
CREATE TABLE students (student_id INT, program_name VARCHAR(255), is_international BOOLEAN); INSERT INTO students (student_id, program_name, is_international) VALUES (1, 'Computer_Science', TRUE), (2, 'Physics', FALSE), (3, 'English', TRUE); | Count the number of students in each graduate program. | SELECT program_name, COUNT(*) FROM students GROUP BY program_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE tv_shows (id INT, title VARCHAR(255), season INT, emmy_awards INT); INSERT INTO tv_shows (id, title, season, emmy_awards) VALUES (1, 'The Crown', 1, 3), (2, 'The Crown', 2, 4); | How many Emmy Awards did 'The Crown' receive in its first season? | SELECT emmy_awards FROM tv_shows WHERE title = 'The Crown' AND season = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE network_upgrades (upgrade_id INT, upgrade_type TEXT, upgrade_date DATE, country TEXT); INSERT INTO network_upgrades (upgrade_id, upgrade_type, upgrade_date, country) VALUES (1, 'Fiber Optics', '2022-04-10', 'Nigeria'); | List all network infrastructure upgrades made in African countries in the last 3 months, including the upgrade type and date. | SELECT * FROM network_upgrades WHERE upgrade_date >= DATEADD(month, -3, CURRENT_DATE) AND country LIKE 'Africa%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE wells (well_id INT, field VARCHAR(50), region VARCHAR(50), production_oil FLOAT, production_gas FLOAT, production_date DATE); INSERT INTO wells (well_id, field, region, production_oil, production_gas, production_date) VALUES (1, 'Ekofisk', 'North Sea', 10000.0, 5000.0, '2020-01-01'), (2, 'Statfjord', 'North Sea', 7000.0, 3000.0, '2020-02-01'); | What was the daily average production of gas in 'North Sea' in 2020? | SELECT AVG(production_gas) FROM wells WHERE region = 'North Sea' AND YEAR(production_date) = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE Country (name VARCHAR(50), smoking_rate FLOAT); INSERT INTO Country (name, smoking_rate) VALUES ('Germany', 23.1), ('United Kingdom', 16.5); | What is the rate of smoking in Europe? | SELECT AVG(smoking_rate) FROM Country WHERE name IN ('Germany', 'United Kingdom'); | gretelai_synthetic_text_to_sql |
CREATE TABLE legal_representation (id INT, lawyer VARCHAR(50), hours_worked INT, representation_date DATE); CREATE TABLE lawyers (id INT, years_of_experience INT, lawyer VARCHAR(50)); | What is the total number of hours of legal representation, by lawyer's years of experience, in the past month? | SELECT l.years_of_experience, SUM(hours_worked) FROM legal_representation r JOIN lawyers l ON r.lawyer = l.lawyer WHERE representation_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY l.years_of_experience; | gretelai_synthetic_text_to_sql |
CREATE TABLE energy_storage (id INT, country VARCHAR(255), technology VARCHAR(255), capacity FLOAT); | What is the total energy storage capacity in Germany, and how does it break down by technology? | SELECT technology, SUM(capacity) FROM energy_storage WHERE country = 'Germany' GROUP BY technology; | gretelai_synthetic_text_to_sql |
CREATE TABLE shipments (shipment_id INT, warehouse_id INT, shipped_date DATE, shipped_weight INT); INSERT INTO shipments (shipment_id, warehouse_id, shipped_date, shipped_weight) VALUES (1, 1, '2021-01-03', 500), (2, 2, '2021-02-10', 800), (3, 3, '2021-03-15', 1000); | What is the total weight of items shipped by sea from 'Mumbai' in the month of 'January'? | SELECT SUM(shipped_weight) FROM shipments WHERE shipped_date BETWEEN '2021-01-01' AND '2021-01-31' AND warehouse_id IN (SELECT warehouse_id FROM warehouses WHERE city = 'Mumbai'); | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_finance (year INT, region VARCHAR(50), amount FLOAT); INSERT INTO climate_finance (year, region, amount) VALUES (2015, 'Africa', 1000000), (2016, 'Africa', 1500000), (2017, 'Africa', 1200000), (2018, 'Africa', 1800000), (2019, 'Africa', 2000000), (2020, 'Africa', 2500000); | What is the total amount of climate finance provided to projects in Africa between 2015 and 2020? | SELECT SUM(amount) FROM climate_finance WHERE year BETWEEN 2015 AND 2020 AND region = 'Africa'; | gretelai_synthetic_text_to_sql |
CREATE TABLE wages (id INT, factory_id INT, region VARCHAR(50), hourly_wage DECIMAL(5,2), certified BOOLEAN); | What is the average hourly wage in fair-trade certified factories per region? | SELECT region, AVG(hourly_wage) AS avg_hourly_wage FROM wages WHERE certified = TRUE GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE space_missions (id INT, mission_name VARCHAR(255), astronaut_name VARCHAR(255), astronaut_gender VARCHAR(10), duration INT); INSERT INTO space_missions (id, mission_name, astronaut_name, astronaut_gender, duration) VALUES (1, 'Apollo 11', 'Neil Armstrong', 'Male', 195), (2, 'Apollo 12', 'Jane Foster', 'Female', 244), (3, 'Ares 3', 'Mark Watney', 'Male', 568), (4, 'Apollo 18', 'Anna Mitchell', 'Female', 205), (5, 'Mars Mission 1', 'Alexei Leonov', 'Male', 350), (6, 'Mars Mission 2', 'Melissa Lewis', 'Female', 315); | Who are the female astronauts that have participated in space missions longer than 300 days? | SELECT astronaut_name FROM space_missions WHERE astronaut_gender = 'Female' AND duration > 300; | gretelai_synthetic_text_to_sql |
CREATE TABLE companies (company_id INT, department VARCHAR(20)); INSERT INTO companies (company_id, department) VALUES (1, 'manufacturing'), (2, 'HR'), (3, 'manufacturing'); | What is the total number of employees working in the 'manufacturing' department across all companies? | SELECT COUNT(*) FROM companies WHERE department = 'manufacturing'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Dates (DateID INT, MinDate DATE, MaxDate DATE); INSERT INTO Dates (DateID, MinDate, MaxDate) VALUES (1, '2010-05-01', '2010-06-15'); | Which artifacts were found between two specific dates? | SELECT A.ArtifactID, A.SiteID, A.ArtifactType, A.DateFound FROM Artifacts A INNER JOIN Dates D ON A.DateFound BETWEEN D.MinDate AND D.MaxDate; | gretelai_synthetic_text_to_sql |
CREATE TABLE precinct (id INT, name VARCHAR(50)); INSERT INTO precinct (id, name) VALUES (1, 'Southside'); CREATE TABLE community_program (id INT, precinct_id INT, program_name VARCHAR(50), last_update TIMESTAMP); | Which community policing programs were updated in the last month in the 'Southside' precinct? | SELECT * FROM community_program WHERE precinct_id = 1 AND last_update >= DATEADD(month, -1, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE TeacherAccess (TeacherID INT, Resource VARCHAR(100), AccessDate DATE, District VARCHAR(50)); INSERT INTO TeacherAccess (TeacherID, Resource, AccessDate, District) VALUES (1, 'Open Source Textbook', '2022-02-15', 'Rural Education'); | Which open pedagogy resources are most popular among teachers in the "Rural Education" district? | SELECT Resource, COUNT(*) FROM TeacherAccess WHERE District = 'Rural Education' GROUP BY Resource ORDER BY COUNT(*) DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE Players (PlayerID INT, Age INT, Country VARCHAR(50), VRUser BOOLEAN); INSERT INTO Players (PlayerID, Age, Country, VRUser) VALUES (1, 25, 'USA', true), (2, 30, 'Canada', false), (3, 22, 'Mexico', true); | What is the average age of players who use VR technology, grouped by their country? | SELECT Country, AVG(Age) as AvgAge FROM Players WHERE VRUser = true GROUP BY Country; | gretelai_synthetic_text_to_sql |
CREATE TABLE DonorVolunteers (DonorID INT, VolunteerID INT); INSERT INTO DonorVolunteers (DonorID, VolunteerID) VALUES (1, 101), (2, 102), (3, 103), (4, 101); CREATE TABLE Donations (DonationID INT, ProgramID INT, DonorID INT); INSERT INTO Donations (DonationID, ProgramID, DonorID) VALUES (1, 101, 1), (2, 102, 2), (3, 103, 3), (4, 101, 4); | List the program outcomes for programs that received donations from donors who are also volunteers? | SELECT ProgramID FROM DonorVolunteers INNER JOIN Donations ON DonorVolunteers.DonorID = Donations.DonorID GROUP BY ProgramID; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_research_projects (id INT, name VARCHAR(255), location VARCHAR(255), budget DECIMAL(10,2)); INSERT INTO marine_research_projects (id, name, location, budget) VALUES (1, 'Coral Reef Study', 'Indian Ocean', 250000.00), (2, 'Ocean Current Analysis', 'Atlantic Ocean', 350000.00); | Find the marine research projects with a budget below the average budget for all projects. | SELECT name, budget FROM marine_research_projects WHERE budget < (SELECT AVG(budget) FROM marine_research_projects); | gretelai_synthetic_text_to_sql |
CREATE TABLE dish_ingredients (id INT, name VARCHAR(50), dish_id INT); CREATE TABLE ingredient_sales (ingredient_id INT, revenue INT); | Identify the top 3 ingredients by sales across all dishes | SELECT dish_ingredients.name, SUM(ingredient_sales.revenue) as total_sales FROM ingredient_sales JOIN dish_ingredredients ON ingredient_sales.ingredient_id = dish_ingredients.id GROUP BY dish_ingredients.name ORDER BY total_sales DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE user_profile (user_id INT, region VARCHAR(20), PRIMARY KEY (user_id)); CREATE TABLE weight_log (log_date DATE, user_id INT, weight_lbs INT, PRIMARY KEY (log_date, user_id)); INSERT INTO user_profile (user_id, region) VALUES (1, 'South'), (2, 'North'), (3, 'East'); INSERT INTO weight_log (log_date, user_id, weight_lbs) VALUES ('2022-01-01', 1, 180), ('2022-01-01', 2, 170), ('2022-02-01', 1, 170), ('2022-02-01', 3, 160), ('2022-03-01', 1, 160), ('2022-03-01', 2, 150); | Calculate the total weight loss (in pounds) for users in the "South" region, for the first quarter of 2022, who have lost 5 or more pounds in a month, grouped by month. | SELECT DATE_FORMAT(log_date, '%Y-%m') as month, SUM(weight_lbs) as total_weight_loss FROM weight_log JOIN user_profile ON weight_log.user_id = user_profile.user_id WHERE user_profile.region = 'South' AND weight_lbs >= 5 AND log_date >= '2022-01-01' AND log_date < '2022-04-01' GROUP BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE cases (case_id INT, department VARCHAR(50), open_date DATE, close_date DATE); INSERT INTO cases (case_id, department, open_date, close_date) VALUES (1, 'alternative_dispute_resolution', '2021-01-01', '2021-01-15'); INSERT INTO cases (case_id, department, open_date, close_date) VALUES (2, 'alternative_dispute_resolution', '2021-02-01', '2021-02-28'); INSERT INTO cases (case_id, department, open_date, close_date) VALUES (3, 'alternative_dispute_resolution', '2021-03-01', NULL); | How many cases were opened and closed in each month of 2021 for the "alternative_dispute_resolution" department? | SELECT department, DATE_TRUNC('month', open_date) as month, COUNT(*) FILTER (WHERE close_date IS NOT NULL) as closed_cases, COUNT(*) FILTER (WHERE close_date IS NULL) as open_cases FROM cases WHERE department = 'alternative_dispute_resolution' AND open_date >= '2021-01-01' GROUP BY department, month; | gretelai_synthetic_text_to_sql |
CREATE TABLE transport (id INT, vessel_name VARCHAR(50), type VARCHAR(50), region VARCHAR(50), date DATE, cargo_weight INT); | What is the total cargo weight transported by each vessel type in the Caribbean, in the month of June? | SELECT type, SUM(cargo_weight) FROM transport WHERE region = 'Caribbean' AND MONTH(date) = 6 GROUP BY type; | gretelai_synthetic_text_to_sql |
CREATE TABLE CommunityLeaders (LeaderID INT, Name TEXT, Country TEXT); INSERT INTO CommunityLeaders (LeaderID, Name, Country) VALUES (1, 'Rajan Shankar', 'India'); INSERT INTO CommunityLeaders (LeaderID, Name, Country) VALUES (2, 'Sheetal Patel', 'India'); | Who are the community leaders in India? | SELECT Name FROM CommunityLeaders WHERE Country = 'India'; | gretelai_synthetic_text_to_sql |
CREATE TABLE crop_farmers (farmer_id INT, crop VARCHAR(50), region VARCHAR(50)); INSERT INTO crop_farmers (farmer_id, crop, region) VALUES (1, 'Wheat', 'Great Plains'), (2, 'Corn', 'Midwest'), (3, 'Soybean', 'Midwest'), (4, 'Rice', 'Southeast'), (5, 'Rice', 'Southeast'); | How many farmers grow 'Rice' by region in the 'crop_farmers' table? | SELECT region, COUNT(farmer_id) as num_rice_farmers FROM crop_farmers WHERE crop = 'Rice' GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE athletes (athlete_id INT, name VARCHAR(30), team VARCHAR(20)); INSERT INTO athletes VALUES (1, 'Messi', 'Barcelona'); INSERT INTO athletes VALUES (2, 'Ronaldo', 'Manchester United'); CREATE TABLE wellbeing_programs (program_id INT, athlete_id INT, program_name VARCHAR(30)); INSERT INTO wellbeing_programs VALUES (1, 1, 'Yoga'); INSERT INTO wellbeing_programs VALUES (2, 2, 'Meditation'); | List all athletes in the soccer team who participated in wellbeing programs and their corresponding program names. | SELECT athletes.name, wellbeing_programs.program_name FROM athletes INNER JOIN wellbeing_programs ON athletes.athlete_id = wellbeing_programs.athlete_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE vehicle_test_data (id INT, make VARCHAR(20), model VARCHAR(20), range DECIMAL(5,2)); INSERT INTO vehicle_test_data (id, make, model, range) VALUES (1, 'Tesla', 'Model 3', 322.3), (2, 'Ford', 'Mustang Mach-E', 230.8), (3, 'Chevrolet', 'Bolt', 259.0); | What is the average range of electric vehicles in the vehicle_test_data table for each make? | SELECT make, AVG(range) FROM vehicle_test_data GROUP BY make; | gretelai_synthetic_text_to_sql |
CREATE TABLE Paris_Neighborhoods (Neighborhood_Name TEXT, Affordability BOOLEAN); INSERT INTO Paris_Neighborhoods (Neighborhood_Name, Affordability) VALUES ('Marais', false), ('Saint Germain', false), ('Latin Quarter', true), ('Bastille', true), ('Montmartre', false); CREATE TABLE Paris_Properties (Neighborhood_Name TEXT, Co_Ownership BOOLEAN); INSERT INTO Paris_Properties (Neighborhood_Name, Co_Ownership) VALUES ('Marais', true), ('Saint Germain', false), ('Latin Quarter', true), ('Bastille', true), ('Montmartre', false); | What is the total number of co-owned properties in affordable neighborhoods in Paris? | SELECT COUNT(Paris_Properties.Co_Ownership) FROM Paris_Properties INNER JOIN Paris_Neighborhoods ON Paris_Properties.Neighborhood_Name = Paris_Neighborhoods.Neighborhood_Name WHERE Paris_Neighborhoods.Affordability = true AND Paris_Properties.Co_Ownership = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE mineral_extraction (extraction_id INT, mine_site_id INT, extraction_date DATE, mineral VARCHAR(50), quantity INT, price FLOAT); INSERT INTO mineral_extraction (extraction_id, mine_site_id, extraction_date, mineral, quantity, price) VALUES (1, 1, '2020-01-01', 'Gold', 50, 1500), (2, 2, '2020-03-15', 'Silver', 75, 25), (3, 3, '2019-12-31', 'Copper', 100, 3); | What is the total quantity of each mineral extracted? | SELECT mineral, SUM(quantity) FROM mineral_extraction GROUP BY mineral; | gretelai_synthetic_text_to_sql |
CREATE TABLE client (client_id INT, client_name VARCHAR(50), region VARCHAR(50)); INSERT INTO client (client_id, client_name, region) VALUES (1, 'ABC Corp', 'Asia-Pacific'), (2, 'XYZ Bank', 'Americas'); CREATE TABLE transaction (transaction_id INT, client_id INT, sector VARCHAR(50), amount DECIMAL(10,2)); INSERT INTO transaction (transaction_id, client_id, sector, amount) VALUES (1, 1, 'Retail', 5000), (2, 1, 'Real Estate', 7000), (3, 2, 'Banking', 10000), (4, 1, 'Technology', 8000); | What is the total transaction volume for all clients in the Asia-Pacific region, excluding transactions from the banking sector? | SELECT SUM(amount) FROM transaction WHERE client_id IN (SELECT client_id FROM client WHERE region = 'Asia-Pacific') AND sector != 'Banking'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ships (id INT, name TEXT, type TEXT, year_built INT, decommission_year INT); INSERT INTO ships (id, name, type, year_built, decommission_year) VALUES (1, 'Seabourn Pride', 'Passenger', 1988, 2011), (2, 'Containership One', 'Container', 1995, 2003), (3, 'Boxship XL', 'Container', 2000, 2006); | How many container ships were decommissioned in the years 2000-2005? | SELECT COUNT(*) FROM ships WHERE type = 'Container' AND decommission_year BETWEEN 2000 AND 2005; | gretelai_synthetic_text_to_sql |
CREATE TABLE rice_production (farm_id INT, country VARCHAR(50), production INT, is_organic BOOLEAN); INSERT INTO rice_production (farm_id, country, production, is_organic) VALUES (1, 'Indonesia', 500, true), (2, 'Indonesia', 800, false), (3, 'India', 1000, true); | What is the total production of organic rice in Indonesia? | SELECT SUM(production) FROM rice_production WHERE country = 'Indonesia' AND is_organic = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE Temp_Crops (date DATE, temperature INT, crop_type VARCHAR(20)); | What is the minimum temperature for each crop type in the past year? | SELECT crop_type, MIN(temperature) OVER(PARTITION BY crop_type) as min_temp FROM Temp_Crops WHERE date >= DATEADD(year, -1, CURRENT_DATE); | gretelai_synthetic_text_to_sql |
CREATE TABLE readers (id INT, name VARCHAR(50), age INT, preference VARCHAR(50)); INSERT INTO readers (id, name, age, preference) VALUES (1, 'John Doe', 30, 'technology'), (2, 'Jane Smith', 45, 'sports'), (3, 'Bob Johnson', 28, 'politics'); | What is the average age of readers who prefer sports news? | SELECT AVG(age) FROM readers WHERE preference = 'sports'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artworks (artwork_name VARCHAR(255), creation_date DATE, movement VARCHAR(255)); INSERT INTO Artworks (artwork_name, creation_date, movement) VALUES ('The Night Watch', '1642-02-01', 'Baroque'), ('Girl with a Pearl Earring', '1665-06-22', 'Dutch Golden Age'), ('The Birth of Venus', '1485-01-01', 'Renaissance'); | What is the earliest creation date in the 'Renaissance' period? | SELECT MIN(creation_date) FROM Artworks WHERE movement = 'Renaissance'; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, material VARCHAR(20), price DECIMAL(5,2)); INSERT INTO products (product_id, material, price) VALUES (1, 'organic cotton', 25.99), (2, 'conventional cotton', 19.99), (3, 'hemp', 39.99); | What is the average price of garments made with organic cotton? | SELECT AVG(price) FROM products WHERE material = 'organic cotton'; | gretelai_synthetic_text_to_sql |
CREATE TABLE posts (id INT, user_id INT, brand_mentioned VARCHAR(255), post_time DATETIME); | What is the total number of unique users who have interacted with posts mentioning the brand "Nike" in the sports industry, in the United States, in the past month? | SELECT COUNT(DISTINCT user_id) FROM posts WHERE brand_mentioned = 'Nike' AND industry = 'sports' AND country = 'United States' AND post_time > DATE_SUB(NOW(), INTERVAL 1 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE accessibility_data (name TEXT, budget INTEGER, organization_type TEXT, launch_year INTEGER); INSERT INTO accessibility_data (name, budget, organization_type, launch_year) VALUES ('AccInit1', 400000, 'non-profit', 2021), ('AccInit2', 500000, 'non-profit', 2021), ('AccInit3', 600000, 'for-profit', 2022); | What is the total budget for technology accessibility initiatives by non-profit organizations in 2021? | SELECT SUM(budget) FROM accessibility_data WHERE organization_type = 'non-profit' AND launch_year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE JerseyChanges (ChangeID INT, AthleteID INT, OldJerseyNumber INT, NewJerseyNumber INT, ChangeDate DATE); CREATE TABLE Athletes (AthleteID INT, AthleteName VARCHAR(100), JerseyNumber INT); | Update the jerseyNumber of athletes who have changed their jersey numbers in the last week in the Athletes table. | UPDATE Athletes SET JerseyNumber = jc.NewJerseyNumber FROM Athletes a JOIN JerseyChanges jc ON a.AthleteID = jc.AthleteID WHERE jc.ChangeDate > DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK); | gretelai_synthetic_text_to_sql |
CREATE TABLE restaurants (name TEXT, revenue FLOAT); INSERT INTO restaurants (name, revenue) VALUES ('Pizzeria Spumoni', 15000.0), ('Pizzeria Yum', 18000.0); | What is the average revenue per restaurant? | SELECT AVG(revenue) FROM restaurants; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (DonationID int, DonorID int, Amount decimal(10,2), DonationDate date); INSERT INTO Donations (DonationID, DonorID, Amount, DonationDate) VALUES (1, 1, 500.00, '2022-01-01'), (2, 2, 350.00, '2022-02-01'), (3, 3, 200.00, '2022-03-01'); | List the top 5 donors by total donation amount, along with their email and the date of their largest donation. | SELECT D.Name, D.Email, MAX(D.Amount) as LargestDonation, MAX(D.DonationDate) as LatestDonation FROM Donors D JOIN Donations DD ON D.DonorID = DD.DonorID GROUP BY D.DonorID, D.Name, D.Email ORDER BY MAX(D.Amount) DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE crops (id INT PRIMARY KEY, name VARCHAR(50), yield INT, country VARCHAR(50)); INSERT INTO crops (id, name, yield, country) VALUES (1, 'Sorghum', 1500, 'Nigeria'), (2, 'Cassava', 2800, 'DRC'), (3, 'Millet', 900, 'Mali'); CREATE TABLE land (id INT PRIMARY KEY, farm_id INT, acres FLOAT, country VARCHAR(50)); INSERT INTO land (id, farm_id, acres, country) VALUES (1, 1, 120.5, 'Nigeria'), (2, 2, 200.2, 'DRC'), (3, 3, 180.8, 'Mali'); CREATE TABLE production (id INT PRIMARY KEY, land_id INT, crop VARCHAR(50), yield INT); INSERT INTO production (id, land_id, crop, yield) VALUES (1, 1, 'Sorghum', 900), (2, 2, 'Sorghum', 600), (3, 3, 'Sorghum', 750), (4, 1, 'Millet', 400); | What is the total 'Yield' of 'Sorghum' in 'Africa'? | SELECT SUM(p.yield) as total_yield FROM crops c JOIN production p ON c.name = p.crop JOIN land l ON p.land_id = l.id WHERE c.name = 'Sorghum' AND l.country = 'Africa'; | gretelai_synthetic_text_to_sql |
CREATE TABLE mining_operations (id INT, location VARCHAR(50), water_consumption FLOAT); INSERT INTO mining_operations (id, location, water_consumption) VALUES (1, 'USA', 10000), (2, 'Canada', 15000); | What are the total amounts of water consumed by mining operations in the USA and Canada? | SELECT SUM(water_consumption) FROM mining_operations WHERE location IN ('USA', 'Canada'); | gretelai_synthetic_text_to_sql |
CREATE TABLE satellites (id INT, name VARCHAR(255), country_of_origin VARCHAR(255), avg_distance FLOAT); | Insert new data for the satellite "Galileo" launched by Italy in 2011 with an average distance of 23000 km. | INSERT INTO satellites (name, country_of_origin, avg_distance) VALUES ('Galileo', 'Italy', 23000); | gretelai_synthetic_text_to_sql |
CREATE TABLE suppliers (supplier_id INT, restaurant_id INT, sustainable_ingredients_percentage DECIMAL(5,2)); INSERT INTO suppliers (supplier_id, restaurant_id, sustainable_ingredients_percentage) VALUES (1, 1, 60), (2, 1, 40), (3, 2, 55), (4, 2, 45); | Which suppliers provide more than 50% of the sustainable ingredients for a given restaurant? | SELECT supplier_id, restaurant_id FROM suppliers WHERE sustainable_ingredients_percentage > 50; | gretelai_synthetic_text_to_sql |
CREATE TABLE fairness_incidents (incident_id INT, incident_date DATE, region TEXT); INSERT INTO fairness_incidents (incident_id, incident_date, region) VALUES (1, '2021-10-01', 'Africa'), (2, '2022-02-15', 'Europe'), (3, '2021-12-31', 'Africa'); | How many algorithmic fairness incidents were reported in Africa in the last year? | SELECT COUNT(*) FROM fairness_incidents WHERE region = 'Africa' AND incident_date >= '2021-01-01' AND incident_date < '2022-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE museums (id INT, name TEXT, location TEXT); CREATE TABLE revenue (museum_id INT, quarter INT, revenue INT); INSERT INTO museums (id, name, location) VALUES (1, 'Metropolitan Museum of Art', 'New York, USA'), (2, 'British Museum', 'London, UK'), (3, 'Louvre Museum', 'Paris, France'); INSERT INTO revenue (museum_id, quarter, revenue) VALUES (1, 1, 7000000), (2, 1, 5600000), (3, 1, 8000000), (1, 2, 7200000), (2, 2, 5800000), (3, 2, 8200000), (1, 3, 6800000), (2, 3, 5400000), (3, 3, 7800000); | What is the total revenue generated by each museum in the last quarter? | SELECT museums.name, SUM(revenue) AS total_revenue FROM museums JOIN revenue ON museums.id = revenue.museum_id WHERE quarter BETWEEN 1 AND 3 GROUP BY museums.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Sales(region VARCHAR(20), product VARCHAR(20), quantity INT); INSERT INTO Sales(region, product, quantity) VALUES('North', 'Organic Apples', 50), ('South', 'Organic Apples', 75), ('North', 'Bananas', 30); | How many units of each product were sold in the "North" region? | SELECT region, product, SUM(quantity) as total_quantity FROM Sales GROUP BY region, product HAVING region = 'North'; | gretelai_synthetic_text_to_sql |
CREATE TABLE opioid_prescriptions (state VARCHAR(2), prescriptions_per_100 INT); INSERT INTO opioid_prescriptions (state, prescriptions_per_100) VALUES ('NY', 55), ('NJ', 60), ('CA', 45), ('FL', 70), ('TX', 75); | What is the number of opioid prescriptions per 100 people, by state? | SELECT state, AVG(prescriptions_per_100) as avg_prescriptions_per_100 FROM opioid_prescriptions GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE faculty (faculty_id INT, faculty_name VARCHAR(50), dept_name VARCHAR(50), salary INT, is_tenured BOOLEAN); CREATE TABLE publications (publication_id INT, faculty_id INT, pub_date DATE); | What is the average salary of tenured and non-tenured faculty members who have published in academic journals in the past year, and how does this compare to the average salary of all tenured and non-tenured faculty members? | SELECT AVG(f.salary) as avg_salary_publishing_tenured, (SELECT AVG(f2.salary) FROM faculty f2 WHERE f2.is_tenured = TRUE) as avg_salary_all_tenured, AVG(CASE WHEN f.is_tenured = FALSE THEN f.salary ELSE NULL END) as avg_salary_publishing_non_tenured, (SELECT AVG(f3.salary) FROM faculty f3 WHERE f3.is_tenured = FALSE) as avg_salary_all_non_tenured FROM faculty f INNER JOIN publications p ON f.faculty_id = p.faculty_id WHERE p.pub_date >= DATE_SUB(CURRENT_DATE(), INTERVAL 1 YEAR) AND f.is_tenured IN (TRUE, FALSE); | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (id INT, department VARCHAR(20), amount FLOAT); INSERT INTO Donations (id, department, amount) VALUES (1, 'Animals', 500.00), (2, 'Education', 300.00); | What are the total donations for each department in the 'Donations' table? | SELECT department, SUM(amount) FROM Donations GROUP BY department | gretelai_synthetic_text_to_sql |
CREATE TABLE Building_Permits (Permit_ID INT, Value FLOAT, Company TEXT, Issue_Date DATE); INSERT INTO Building_Permits (Permit_ID, Value, Company, Issue_Date) VALUES (1, 1500000, 'XYZ Construction', '2022-01-01'), (2, 2000000, 'ABC Construction', '2022-02-15'), (3, 1200000, 'Smith & Sons', '2022-03-03'); | List all building permits issued in New York City that have a value over $1,000,000, along with the name of the company that applied for the permit and the issue date. | SELECT bp.Company, bp.Value, bp.Issue_Date FROM Building_Permits bp WHERE bp.Value > 1000000 AND bp.City = 'New York City'; | gretelai_synthetic_text_to_sql |
CREATE TABLE organic_cotton_manufacturers (manufacturer VARCHAR(50), quantity INT, sales DECIMAL(10,2), date DATE); | What is the total quantity of organic cotton garments produced by each manufacturer and their total sales in Q1 2023? | SELECT manufacturer, SUM(quantity) AS total_quantity, SUM(sales) AS total_sales FROM organic_cotton_manufacturers WHERE date >= '2023-01-01' AND date < '2023-04-01' GROUP BY manufacturer; | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_finance (country VARCHAR(50), finance_amount NUMERIC(10, 2), project_type VARCHAR(50)); INSERT INTO climate_finance (country, finance_amount, project_type) VALUES ('USA', 5000000, 'climate mitigation'), ('China', 7000000, 'climate mitigation'), ('India', 4000000, 'climate mitigation'), ('Brazil', 3000000, 'climate mitigation'); | What is the total amount of climate finance provided by the top 3 contributing countries for climate mitigation projects? | SELECT country, SUM(finance_amount) FROM climate_finance WHERE project_type = 'climate mitigation' GROUP BY country ORDER BY SUM(finance_amount) DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE equipment (id INT, category TEXT, maintenance_cost DECIMAL(10,2)); INSERT INTO equipment (id, category, maintenance_cost) VALUES (1, 'Ground', 500.00), (2, 'Air', 1500.00); | Identify the average maintenance cost for military equipment in the 'Ground' category for the last 6 months. | SELECT AVG(maintenance_cost) FROM equipment WHERE category = 'Ground' AND maintenance_date >= DATEADD(month, -6, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE Vehicle_Releases (Id INT, Name VARCHAR(50), Release_Date DATE, Origin_Country VARCHAR(50), Safety_Test_Result VARCHAR(50)); | What percentage of safety tests passed for vehicles released in Japan since 2015? | SELECT (COUNT(CASE WHEN Safety_Test_Result = 'Pass' THEN 1 END) * 100.0 / COUNT(*)) FROM Vehicle_Releases WHERE Origin_Country = 'Japan' AND YEAR(Release_Date) >= 2015; | gretelai_synthetic_text_to_sql |
CREATE TABLE conservation_efforts (id INT, species VARCHAR(50), year INT, amount DECIMAL(10,2)); INSERT INTO conservation_efforts (id, species, year, amount) VALUES (1, 'Hawaiian Monk Seal', 2020, 350000.00); | What is the total amount spent on conservation efforts for the Hawaiian Monk Seal? | SELECT SUM(amount) FROM conservation_efforts WHERE species = 'Hawaiian Monk Seal'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ClimateFinance (year INT, country VARCHAR(255), recipient VARCHAR(255), amount DECIMAL(10,2)); INSERT INTO ClimateFinance (year, country, recipient, amount) VALUES (2016, 'Africa', 'International Organizations', 5000000), (2017, 'Africa', 'International Organizations', 5500000), (2018, 'Africa', 'International Organizations', 6000000), (2019, 'Africa', 'International Organizations', 6500000), (2020, 'Africa', 'International Organizations', 7000000); | What is the total amount of climate finance provided to developing countries in Africa by international organizations each year since 2016? | SELECT year, SUM(amount) AS total_climate_finance FROM ClimateFinance WHERE country = 'Africa' AND recipient = 'International Organizations' GROUP BY year; | gretelai_synthetic_text_to_sql |
CREATE TABLE CustomerSpendingMX (CustomerID INT, Country TEXT, AvgSpending DECIMAL(5,2)); INSERT INTO CustomerSpendingMX (CustomerID, Country, AvgSpending) VALUES (1, 'Mexico', 120.50), (2, 'Mexico', 110.50), (3, 'Mexico', 130.50), (4, 'Mexico', 90.50); CREATE TABLE CustomerSpendingAR (CustomerID INT, Country TEXT, AvgSpending DECIMAL(5,2)); INSERT INTO CustomerSpendingAR (CustomerID, Country, AvgSpending) VALUES (1, 'Argentina', 105.00), (2, 'Argentina', 115.00), (3, 'Argentina', 125.00), (4, 'Argentina', 135.00); | What is the difference in average customer spending between customers in Mexico and Argentina? | SELECT AVG(CSMX.AvgSpending) - AVG(CSA.AvgSpending) FROM CustomerSpendingMX CSMX, CustomerSpendingAR CSA WHERE CSMX.Country = 'Mexico' AND CSA.Country = 'Argentina'; | gretelai_synthetic_text_to_sql |
CREATE TABLE suppliers (id INT, name VARCHAR(50), location VARCHAR(50)); INSERT INTO suppliers (id, name, location) VALUES (1, 'Supplier C', 'Toronto'); INSERT INTO suppliers (id, name, location) VALUES (2, 'Supplier D', 'Vancouver');CREATE TABLE deliveries (id INT, supplier_id INT, delivering_supplier_id INT, order_date DATETIME); INSERT INTO deliveries (id, supplier_id, delivering_supplier_id, order_date) VALUES (1, 1, 2, '2022-01-02 10:00:00'); INSERT INTO deliveries (id, supplier_id, delivering_supplier_id, order_date) VALUES (2, 2, 1, '2022-01-03 11:00:00'); | What is the name of the supplier and delivering supplier for orders made in Toronto, assuming orders were made after 2021-12-01? | SELECT s1.name AS supplier_name, s2.name AS delivering_supplier_name FROM deliveries d INNER JOIN suppliers s1 ON d.supplier_id = s1.id INNER JOIN suppliers s2 ON d.delivering_supplier_id = s2.id WHERE s1.location = 'Toronto' AND d.order_date >= '2021-12-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE space_missions (mission_name VARCHAR(100) PRIMARY KEY, start_date DATE, end_date DATE, mission_type VARCHAR(50)); | List all missions that started before 2010 from the space_missions table | SELECT * FROM space_missions WHERE start_date < '2010-01-01'; | gretelai_synthetic_text_to_sql |
VESSEL(vessel_id, voyage_id, max_speed); TRIP(voyage_id, avg_speed) | Find the average speed of vessels per trip | SELECT v.vessel_id, AVG(t.avg_speed) AS avg_speed_per_vessel FROM VESSEL v JOIN TRIP t ON v.voyage_id = t.voyage_id GROUP BY v.vessel_id; | 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.