context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE ev_charging_stations (id INT, station_name VARCHAR(255), state VARCHAR(255), station_type VARCHAR(255), num_stalls INT); | What is the total number of electric vehicle charging stations in the state of California, grouped by station type? | SELECT station_type, COUNT(station_name) FROM ev_charging_stations WHERE state = 'California' GROUP BY station_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE DonationAmounts (DonationID INT, DonorID INT, DonationDate DATE, DonationAmount DECIMAL(10,2)); | Find the total donation amount for each donor | SELECT DonorID, SUM(DonationAmount) FROM DonationAmounts GROUP BY DonorID; | gretelai_synthetic_text_to_sql |
CREATE TABLE Budget (BudgetID int, ProgramName varchar(50), BudgetYear int, BudgetAmount int); INSERT INTO Budget (BudgetID, ProgramName, BudgetYear, BudgetAmount) VALUES (1, 'Education', 2021, 50000), (2, 'Healthcare', 2021, 75000), (3, 'Education', 2022, 60000); | What is the total budget allocated for each program in 2021, grouped by program name? | SELECT ProgramName, SUM(BudgetAmount) as TotalBudget FROM Budget WHERE BudgetYear = 2021 GROUP BY ProgramName; | gretelai_synthetic_text_to_sql |
CREATE TABLE visitors_engagement (visitor_id INT, birth_date DATE, engaged BOOLEAN); INSERT INTO visitors_engagement (visitor_id, birth_date, engaged) VALUES (1, '1990-01-01', TRUE), (2, '2000-01-01', FALSE); | What was the age distribution of visitors who engaged with digital installations? | SELECT FLOOR(DATEDIFF(y, birth_date, GETDATE()) / 10) * 10 AS age_decade, COUNT(*) AS num_visitors FROM visitors_engagement WHERE engaged = TRUE GROUP BY FLOOR(DATEDIFF(y, birth_date, GETDATE()) / 10) * 10; | gretelai_synthetic_text_to_sql |
CREATE TABLE trends (trend_id INT PRIMARY KEY, name VARCHAR(255), popularity_score INT); CREATE TABLE garments (garment_id INT PRIMARY KEY, name VARCHAR(255), trend_id INT, FOREIGN KEY (trend_id) REFERENCES trends(trend_id)); | What is the average popularity score of trends associated with more than 3 garments? | SELECT trends.name, AVG(trends.popularity_score) FROM trends JOIN garments ON trends.trend_id = garments.trend_id GROUP BY trends.name HAVING COUNT(garments.garment_id) > 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE hospitals (name TEXT, budget INTEGER, beds INTEGER, state TEXT); INSERT INTO hospitals (name, budget, beds, state) VALUES ('HospitalA', 1000000, 75, 'Washington'), ('HospitalB', 1200000, 60, 'Washington'), ('HospitalC', 800000, 50, 'Washington'), ('HospitalD', 900000, 80, 'Washington'), ('HospitalE', 11000... | What is the average budget and number of hospitals in Washington with more than 50 beds? | SELECT AVG(budget) as avg_budget, COUNT(*) as num_hospitals FROM hospitals WHERE state = 'Washington' AND beds > 50; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (id INT, date DATE, product VARCHAR(50), category VARCHAR(50), store VARCHAR(50), quantity INT); CREATE TABLE stores (id INT, name VARCHAR(50), location VARCHAR(50)); | What is the total number of products sold, by category, for each store in the past week? | SELECT store, category, SUM(quantity) as total_sold FROM sales JOIN stores ON sales.store = stores.name WHERE date >= DATEADD(week, -1, GETDATE()) GROUP BY store, category; | gretelai_synthetic_text_to_sql |
CREATE TABLE artworks (id INT, artist VARCHAR(100), collection VARCHAR(50), gender VARCHAR(10)); INSERT INTO artworks (id, artist, collection, gender) VALUES (1, 'Nandi', 'African', 'Female'), (2, 'John', 'European', 'Male'), (3, 'Amina', 'African', 'Female'); | How many artworks are there in the collection by female artists from Africa? | SELECT COUNT(*) FROM artworks WHERE collection = 'African' AND gender = 'Female'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Crops (id INT, country VARCHAR(255), crop VARCHAR(255), water_footprint INT); INSERT INTO Crops (id, country, crop, water_footprint) VALUES (1, 'Morocco', 'Oranges', 300), (2, 'Morocco', 'Olives', 150), (3, 'Algeria', 'Dates', 400), (4, 'Algeria', 'Grapes', 200); | What is the average water footprint for crops grown in Morocco and Algeria? | SELECT AVG(water_footprint) FROM Crops WHERE country IN ('Morocco', 'Algeria') GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE employees (id INT, first_name VARCHAR(50), last_name VARCHAR(50), department VARCHAR(50), hire_date DATE); | Insert a new employee record into the "employees" table | INSERT INTO employees (id, first_name, last_name, department, hire_date) VALUES (101, 'Jamal', 'Johnson', 'IT', '2022-06-01'); | gretelai_synthetic_text_to_sql |
CREATE TABLE communication_satellites (id INT PRIMARY KEY, name VARCHAR(255), manufacturer VARCHAR(255), type VARCHAR(255), launch_date DATE, lifespan INT); | What is the maximum lifespan of a communication satellite in geostationary orbit? | SELECT MAX(lifespan) FROM communication_satellites WHERE orbit_type = 'Geostationary'; | gretelai_synthetic_text_to_sql |
CREATE TABLE daily_revenue (id INT, hotel_id INT, region TEXT, calendar DATE, revenue FLOAT); | What is the average daily revenue for hotels in the 'EMEA' region for the year 2022? | SELECT region, AVG(revenue) FROM daily_revenue WHERE region = 'EMEA' AND YEAR(calendar) = 2022 GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE crop_yield (id INT, farm_id INT, crop_id INT, yield INT); INSERT INTO crop_yield (id, farm_id, crop_id, yield) VALUES (1, 1, 1, 100), (2, 2, 2, 50); | What is the total yield of organic crops in France? | SELECT crops.name, SUM(crop_yield.yield) FROM crop_yield JOIN farms ON crop_yield.farm_id = farms.id JOIN crops ON crop_yield.crop_id = crops.id JOIN provinces ON farms.id = provinces.id JOIN farm_certifications ON farms.id = farm_certifications.farm_id WHERE provinces.country = 'France' AND farm_certifications.certifi... | gretelai_synthetic_text_to_sql |
CREATE TABLE vessels (id INT, name VARCHAR(255)); INSERT INTO vessels (id, name) VALUES (1, 'Tanker Carrier'), (2, 'Bulk Carrier'), (3, 'Container Ship'), (4, 'Passenger Carrier'); CREATE TABLE accidents (id INT, vessel_id INT, date DATE); INSERT INTO accidents (id, vessel_id, date) VALUES (1, 1, '2021-04-12'), (2, 1, ... | How many accidents were reported for vessels with the word 'Carrier' in their name in April 2021? | SELECT COUNT(a.vessel_id) as accidents_count FROM accidents a JOIN vessels v ON a.vessel_id = v.id WHERE v.name LIKE '%Carrier%' AND date_format(a.date, '%Y-%m') = '2021-04'; | gretelai_synthetic_text_to_sql |
CREATE TABLE investments (id INT, sector VARCHAR(20)) | How many 'social_impact' investments have been made? | SELECT COUNT(*) FROM investments WHERE sector = 'social_impact' | gretelai_synthetic_text_to_sql |
CREATE TABLE Support_Programs (program_name TEXT, enrollment INT); CREATE VIEW Max_Enrollment AS SELECT program_name, enrollment FROM Support_Programs WHERE enrollment = (SELECT MAX(enrollment) FROM Support_Programs); CREATE VIEW Min_Enrollment AS SELECT program_name, enrollment FROM Support_Programs WHERE enrollment =... | Which support programs have the highest and lowest enrollment? | SELECT * FROM Max_Enrollment UNION SELECT * FROM Min_Enrollment; | gretelai_synthetic_text_to_sql |
CREATE TABLE agricultural_innovation_metrics (id INT PRIMARY KEY, region VARCHAR(50), metric_name VARCHAR(50), value DECIMAL(10, 2), measurement_date DATE); | What was the average agricultural innovation metric per region for the last quarter? | SELECT region, AVG(value) as avg_metric FROM agricultural_innovation_metrics WHERE measurement_date >= DATE_SUB(CURDATE(), INTERVAL 3 MONTH) GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE inventory (item_id INT, item_name TEXT, quantity INT, cost_per_unit DECIMAL(5,2), region TEXT); INSERT INTO inventory (item_id, item_name, quantity, cost_per_unit, region) VALUES (1, 'Veggie Burger', 50, 2.50, 'NY'), (2, 'Chicken Caesar Salad', 30, 3.50, 'NY'), (3, 'BBQ Ribs', 20, 5.00, 'NY'); | What is the total inventory cost for the NY region? | SELECT SUM(quantity * cost_per_unit) as total_inventory_cost FROM inventory WHERE region = 'NY'; | gretelai_synthetic_text_to_sql |
CREATE TABLE menu_items (id INT, name VARCHAR(50), cuisine VARCHAR(50), price DECIMAL(5,2)); INSERT INTO menu_items (id, name, cuisine, price) VALUES (1, 'Pad Thai', 'asian', 12.99); INSERT INTO menu_items (id, name, cuisine, price) VALUES (2, 'Sushi Roll', 'asian', 15.99); | Which menu items have had their prices increased by more than 10% in the 'asian' cuisine category? | SELECT name, cuisine, price, (price - LAG(price) OVER (PARTITION BY cuisine ORDER BY name))/LAG(price) OVER (PARTITION BY cuisine ORDER BY name) as price_increase_percentage FROM menu_items WHERE cuisine = 'asian' AND (price - LAG(price) OVER (PARTITION BY cuisine ORDER BY name))/LAG(price) OVER (PARTITION BY cuisine O... | gretelai_synthetic_text_to_sql |
CREATE TABLE countries (country_id INT, country_name VARCHAR(255)); INSERT INTO countries VALUES (1, 'United States'), (2, 'Canada'), (3, 'Mexico'); CREATE TABLE ad_impressions (ad_id INT, country_id INT, impressions INT); CREATE TABLE ad_revenue (ad_id INT, revenue DECIMAL(10,2)); | Show the total number of ads served and the total revenue generated per country, for countries with more than 100,000 ad impressions. | SELECT co.country_name, SUM(ai.impressions) as total_impressions, SUM(ar.revenue) as total_revenue FROM countries co INNER JOIN ad_impressions ai ON co.country_id = ai.country_id INNER JOIN ad_revenue ar ON ai.ad_id = ar.ad_id GROUP BY co.country_name HAVING total_impressions > 100000; | gretelai_synthetic_text_to_sql |
CREATE TABLE Vehicles (Id INT, Make VARCHAR(255), Model VARCHAR(255), Year INT, Fuel_Type VARCHAR(255)); INSERT INTO Vehicles (Id, Make, Model, Year, Fuel_Type) VALUES (1, 'Tesla', 'Model 3', 2020, 'Electric'); INSERT INTO Vehicles (Id, Make, Model, Year, Fuel_Type) VALUES (2, 'Toyota', 'Prius', 2020, 'Hybrid'); INSERT... | List all electric vehicles in the database. | SELECT Make, Model FROM Vehicles WHERE Fuel_Type = 'Electric'; | gretelai_synthetic_text_to_sql |
CREATE TABLE solar_panels (id INT, name VARCHAR(255), efficiency FLOAT); INSERT INTO solar_panels (id, name, efficiency) VALUES (1, 'SolarPanel A', 18.5), (2, 'SolarPanel B', 20.3), (3, 'SolarPanel C', 19.1); | What is the name and efficiency of the solar panel with the lowest efficiency? | SELECT name, MIN(efficiency) FROM solar_panels; | gretelai_synthetic_text_to_sql |
CREATE TABLE subway_trips (trip_id INT, day_of_week VARCHAR(10), city VARCHAR(50)); INSERT INTO subway_trips (trip_id, day_of_week, city) VALUES (1, 'Monday', 'Seoul'), (2, 'Tuesday', 'Seoul'), (3, 'Sunday', 'Seoul'); | What is the total number of subway trips in Seoul on a Sunday? | SELECT COUNT(*) FROM subway_trips WHERE day_of_week = 'Sunday' AND city = 'Seoul'; | gretelai_synthetic_text_to_sql |
CREATE TABLE shipping_lines (shipping_line_id INT, shipping_line_name VARCHAR(100)); CREATE TABLE containers (container_id INT, container_weight INT, shipping_line_id INT, shipped_date DATE); INSERT INTO shipping_lines VALUES (1, 'Maersk Line'); INSERT INTO shipping_lines VALUES (2, 'MSC Mediterranean Shipping Company'... | What is the total cargo weight transported by each shipping line in the last month, and what is the average weight per container for those shipments? | SELECT shipping_lines.shipping_line_name, SUM(containers.container_weight) as total_weight, AVG(containers.container_weight) as avg_weight_per_container FROM shipping_lines INNER JOIN containers ON shipping_lines.shipping_line_id = containers.shipping_line_id WHERE containers.shipped_date > DATE_SUB(CURRENT_DATE, INTER... | gretelai_synthetic_text_to_sql |
CREATE TABLE company (id INT, name TEXT, exit_strategy TEXT); INSERT INTO company (id, name, exit_strategy) VALUES (1, 'Delta Inc', 'IPO'); INSERT INTO company (id, name, exit_strategy) VALUES (2, 'Epsilon Corp', 'Acquisition'); INSERT INTO company (id, name, exit_strategy) VALUES (3, 'Zeta Inc', NULL); INSERT INTO com... | List all companies that have had an exit strategy through an IPO | SELECT id, name FROM company WHERE exit_strategy = 'IPO'; | gretelai_synthetic_text_to_sql |
CREATE TABLE landfill_capacity (id INT PRIMARY KEY, location VARCHAR(255), capacity INT, date DATE); | Delete records in landfill_capacity table where location is 'Texas' | DELETE FROM landfill_capacity WHERE location = 'Texas'; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists music_schema;CREATE TABLE if not exists concerts (id INT, name VARCHAR, city VARCHAR, revenue FLOAT);INSERT INTO concerts (id, name, city, revenue) VALUES (1, 'Music Festival', 'New York', 200000.00), (2, 'Rock Concert', 'Chicago', 75000.00), (3, 'Jazz Festival', 'Los Angeles', 125000.00); | What is the total revenue for each concert in descending order, for concerts with more than 5000 attendees? | SELECT name, SUM(revenue) as total_revenue FROM music_schema.concerts WHERE attendees > 5000 GROUP BY name ORDER BY total_revenue DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE drought_impact (id INT PRIMARY KEY, region VARCHAR(50), drought_duration INT); | Create a table named 'drought_impact' | CREATE TABLE drought_impact (id INT PRIMARY KEY, region VARCHAR(50), drought_duration INT); | gretelai_synthetic_text_to_sql |
CREATE TABLE green_buildings.green_buildings_data (city VARCHAR(20), co2_emission_reduction_tons INT); | What is the total number of green buildings in the 'green_buildings' schema, by city, that have achieved a CO2 emission reduction (in metric tons) greater than 1000? | SELECT city, COUNT(*) FROM green_buildings.green_buildings_data WHERE co2_emission_reduction_tons > 1000 GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (id INT, equipment_type VARCHAR(255), sale_date DATE, quantity INT, country VARCHAR(255)); INSERT INTO sales (id, equipment_type, sale_date, quantity, country) VALUES (1, 'tank', '2019-07-15', 5, 'US'); INSERT INTO sales (id, equipment_type, sale_date, quantity, country) VALUES (2, 'fighter_jet', '20... | Find the number of military equipment sales in 2020 from the 'sales' table | SELECT SUM(quantity) FROM sales WHERE YEAR(sale_date) = 2020 AND equipment_type IN ('military_equipment'); | gretelai_synthetic_text_to_sql |
CREATE TABLE SmartContracts (ContractId INT, ContractName VARCHAR(50), DeveloperId INT); CREATE TABLE Developers (DeveloperId INT, DeveloperName VARCHAR(50), ExperienceYears INT); INSERT INTO SmartContracts (ContractId, ContractName, DeveloperId) VALUES (1, 'Contract1', 1); INSERT INTO SmartContracts (ContractId, Contr... | List all smart contracts and their respective developers who have more than 5 years of experience. | SELECT s.ContractName, d.DeveloperName FROM SmartContracts s INNER JOIN Developers d ON s.DeveloperId = d.DeveloperId WHERE d.ExperienceYears > 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_finance_projects (country VARCHAR(50), finance_amount NUMERIC(10, 2), project_type VARCHAR(50)); INSERT INTO climate_finance_projects (country, finance_amount, project_type) VALUES ('USA', 5000000, 'climate mitigation'), ('China', 4000000, 'climate mitigation'), ('India', 3000000, 'climate mitigati... | What is the minimum amount of climate finance provided by a single country for a climate mitigation project? | SELECT country, MIN(finance_amount) FROM climate_finance_projects WHERE project_type = 'climate mitigation' GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE policyholders (id INT, policy_type VARCHAR(20), policy_id INT); INSERT INTO policyholders (id, policy_type, policy_id) VALUES (1, 'health insurance', 1), (2, 'life insurance', 2), (3, 'health insurance', 3); CREATE TABLE claims (id INT, policy_id INT, claim_amount INT); INSERT INTO claims (id, policy_id, c... | What is the total number of 'health insurance' policies and the percentage of those policies that have a claim amount greater than 2000? | SELECT COUNT(DISTINCT policyholders.id) FILTER (WHERE policy_type = 'health insurance') AS health_insurance_policies, COUNT(DISTINCT claims.policy_id) FILTER (WHERE claim_amount > 2000) * 100.0 / COUNT(DISTINCT policyholders.id) FILTER (WHERE policy_type = 'health insurance') AS high_claim_percentage FROM policyholders... | gretelai_synthetic_text_to_sql |
CREATE TABLE Members (MemberID INT, JoinDate DATE, Age INT, HasSmartwatch BOOLEAN); | What is the average age of members who joined in 2020 and own a smartwatch? | SELECT AVG(Age) FROM Members WHERE JoinDate BETWEEN '2020-01-01' AND '2020-12-31' AND HasSmartwatch = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE Library (library_id INT, library_name VARCHAR(50), district_location INT, book_count INT, opened_date DATE); INSERT INTO Library (library_id, library_name, district_location, book_count, opened_date) VALUES (3, 'Downtown Library', 2, 700000, '1895-09-21'); CREATE TABLE School (school_id INT, school_name VA... | What is the name and district location of the library with the most books, and the school with the highest student count in that district? | SELECT l.library_name, s.school_name FROM Library l JOIN School s ON l.district_location = s.district_served WHERE l.book_count = (SELECT MAX(l2.book_count) FROM Library l2) AND s.student_count = (SELECT MAX(s2.student_count) FROM School s2 WHERE s2.district_served = s.district_served); | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (donor_id INT, donor_name VARCHAR(255), donation_amount DECIMAL, donation_date DATE, project_category VARCHAR(255)); INSERT INTO donors (donor_id, donor_name, donation_amount, donation_date, project_category) VALUES (1, 'John Smith', 500, '2021-06-15', 'Arts & Culture'), (2, 'Jane Doe', 750, '2021-0... | Identify the top 3 donors who contributed the most to the 'Arts & Culture' project category in 2021. | SELECT donor_name, SUM(donation_amount) as total_donation FROM donors WHERE donation_date BETWEEN '2021-01-01' AND '2021-12-31' AND project_category = 'Arts & Culture' GROUP BY donor_name ORDER BY total_donation DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE restaurants (id INT, name VARCHAR(255)); INSERT INTO restaurants (id, name) VALUES (1, 'Restaurant A'), (2, 'Restaurant B'); CREATE TABLE revenue (restaurant_id INT, revenue DECIMAL(10, 2), date DATE); INSERT INTO revenue (restaurant_id, revenue, date) VALUES (1, 5000, '2021-01-01'), (1, 6000, '2021-01-02'... | Find the total revenue for each restaurant in the month of January 2021 | SELECT r.name, SUM(r.revenue) as total_revenue FROM revenue r JOIN restaurants res ON r.restaurant_id = res.id WHERE EXTRACT(MONTH FROM r.date) = 1 AND EXTRACT(YEAR FROM r.date) = 2021 GROUP BY r.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE initiatives (id INT, name TEXT, location TEXT, type TEXT); INSERT INTO initiatives (id, name, location, type) VALUES (1, 'Green Safari', 'Kenya', 'Sustainable'), (2, 'Eco-Lodge', 'Morocco', 'Sustainable'), (3, 'Sustainable Winery', 'Spain', 'Sustainable'); | What is the total number of sustainable tourism initiatives worldwide? | SELECT COUNT(*) FROM initiatives WHERE type = 'Sustainable'; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, product_name TEXT, sales FLOAT, country TEXT, certified TEXT); INSERT INTO products (product_id, product_name, sales, country, certified) VALUES (1, 'Lipstick A', 5000, 'USA', 'organic'), (2, 'Eye Shadow B', 3500, 'Canada', 'vegan'), (3, 'Mascara C', 4200, 'Germany', 'organic'), (... | What are the sales figures for organic cosmetic products in Japan? | SELECT p.sales FROM products p WHERE p.certified = 'organic' AND p.country = 'Japan'; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteers (volunteer_id int, hours_served int, country varchar(50)); INSERT INTO volunteers (volunteer_id, hours_served, country) VALUES (1, 10, 'Japan'), (2, 2, 'Japan'), (3, 15, 'Japan'); | What is the average number of hours served per volunteer in Japan, for volunteers who have served more than 5 hours? | SELECT AVG(hours_served) FROM volunteers WHERE country = 'Japan' GROUP BY volunteer_id HAVING COUNT(volunteer_id) > 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE investment (id INT, company_id INT, vc_firm TEXT, investment_year INT); CREATE TABLE company (id INT, name TEXT, location TEXT); INSERT INTO investment (id, company_id, vc_firm, investment_year) VALUES (1, 1, 'Global Capital', 2018); INSERT INTO company (id, name, location) VALUES (1, 'Acme Inc', 'Nigeria'... | Which venture capital firms have invested in companies based in Africa? | SELECT DISTINCT vc_firm FROM investment JOIN company ON investment.company_id = company.id WHERE company.location = 'Nigeria'; | gretelai_synthetic_text_to_sql |
CREATE TABLE urban_agriculture (crop_id INT, crop_name TEXT, yield FLOAT); INSERT INTO urban_agriculture (crop_id, crop_name, yield) VALUES (1, 'Tomatoes', 2.3), (2, 'Lettuce', 1.9), (3, 'Cucumbers', 3.1); | What is the maximum reported yield (in tons) of a single crop in urban agriculture? | SELECT MAX(yield) FROM urban_agriculture; | gretelai_synthetic_text_to_sql |
CREATE TABLE Inventory (ItemID int, ItemName varchar(50), Quantity int); INSERT INTO Inventory VALUES (1, 'Item 1', 5), (2, 'Item 2', 0), (3, 'Item 3', 10), (4, 'Item 4', 0); | Delete all records from the Inventory table that have a quantity of 0. | DELETE FROM Inventory WHERE Quantity = 0; | gretelai_synthetic_text_to_sql |
CREATE TABLE LandfillCapacity (ID INT PRIMARY KEY, Landfill VARCHAR(50), City VARCHAR(50), Year INT, Capacity INT); INSERT INTO LandfillCapacity (ID, Landfill, City, Year, Capacity) VALUES (1, 'North Disposal Site', 'Denver', 2018, 1000000); | What was the capacity of the landfill 'North Disposal Site' in the year 2018? | SELECT Capacity FROM LandfillCapacity WHERE Landfill = 'North Disposal Site' AND Year = 2018; | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (id INT, name TEXT, gender TEXT, donation_amount FLOAT, donation_date DATE); | What is the average donation amount by gender, for donors who made a donation in the last month? | SELECT gender, AVG(donation_amount) as avg_donation FROM donors WHERE donation_date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH) GROUP BY gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE farm (id INT, name VARCHAR(255), type VARCHAR(255), sustainability VARCHAR(255), region VARCHAR(255)); INSERT INTO farm (id, name, type, sustainability, region) VALUES (1, 'Smith Farm', 'organic', 'sustainable', 'Midwest'), (2, 'Johnson Farm', 'conventional', 'non-sustainable', 'South'), (3, 'Brown Farm', ... | List the names and types of all sustainable farms in the 'farming' database that are located in the 'Northeast' region, sorted by name in ascending order. | SELECT name, type FROM farm WHERE sustainability = 'sustainable' AND region = 'Northeast' ORDER BY name ASC; | gretelai_synthetic_text_to_sql |
CREATE TABLE Satellites (SatelliteID INT, Name VARCHAR(50), Manufacturer VARCHAR(50), LaunchDate DATE, Orbit VARCHAR(50), Status VARCHAR(50)); INSERT INTO Satellites (SatelliteID, Name, Manufacturer, LaunchDate, Orbit, Status) VALUES (7, 'Galileo I', 'Thales Alenia Space', '2011-10-21', 'GEO', 'Active'), (8, 'Galileo I... | Identify the top 3 manufacturers with the most successful satellite launches since 2010. | SELECT Manufacturer, COUNT(*) AS SuccessfulLaunches FROM Satellites WHERE LaunchDate >= '2010-01-01' GROUP BY Manufacturer ORDER BY SuccessfulLaunches DESC FETCH FIRST 3 ROWS ONLY; | gretelai_synthetic_text_to_sql |
CREATE TABLE judge_precedents (judge_id INT, precedent_id INT); CREATE TABLE precedents (precedent_id INT, description TEXT); | List all legal precedents for a specific judge ID. | SELECT p.description FROM judge_precedents jp JOIN precedents p ON jp.precedent_id = p.precedent_id WHERE jp.judge_id = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE CulturalCompetency (ID INT PRIMARY KEY, HealthWorkerName VARCHAR(100), CulturalCompetencyScore INT); CREATE TABLE MentalHealthParity (ID INT PRIMARY KEY, HealthWorkerName VARCHAR(100), MentalHealthParityScore INT); | Add Mental Health Parity scores for each Health Worker | ALTER TABLE MentalHealthParity ADD HealthWorkerName VARCHAR(100); INSERT INTO MentalHealthParity (ID, HealthWorkerName, MentalHealthParityScore) VALUES (1, 'John Doe', 75), (2, 'Jane Smith', 80), (3, 'Alice Johnson', 85); | gretelai_synthetic_text_to_sql |
CREATE TABLE membership (member_id INT, membership_type VARCHAR(20)); INSERT INTO membership (member_id, membership_type) VALUES (1, 'Platinum'), (2, 'Gold'), (3, 'Platinum'); CREATE TABLE workout_data (member_id INT, duration INT, timestamp TIMESTAMP); INSERT INTO workout_data (member_id, duration, timestamp) VALUES (... | How many minutes did members with a platinum membership spend working out in the last week? | SELECT SUM(duration)/60 as total_minutes FROM workout_data w JOIN membership m ON w.member_id = m.member_id WHERE membership_type = 'Platinum' AND timestamp BETWEEN '2022-01-01 00:00:00' AND '2022-01-08 23:59:59'; | gretelai_synthetic_text_to_sql |
CREATE TABLE public_schools (school_name VARCHAR(255), school_type VARCHAR(50), state VARCHAR(50)); INSERT INTO public_schools (school_name, school_type, state) VALUES ('School A', 'Public', 'NY'), ('School B', 'Public', 'NY'), ('School C', 'Private', 'NY'); | What is the total number of public schools and private schools in the state of New York? | SELECT SUM(CASE WHEN school_type = 'Public' THEN 1 ELSE 0 END) as total_public_schools, SUM(CASE WHEN school_type = 'Private' THEN 1 ELSE 0 END) as total_private_schools FROM public_schools; | gretelai_synthetic_text_to_sql |
CREATE TABLE Dispensaries (id INT, name TEXT, state TEXT); INSERT INTO Dispensaries (id, name, state) VALUES (1, 'Dispensary C', 'Washington'); INSERT INTO Dispensaries (id, name, state) VALUES (2, 'Dispensary D', 'Washington'); CREATE TABLE Sales (dispensary_id INT, sale_date DATE, revenue DECIMAL(10,2)); INSERT INTO ... | What was the average daily revenue for each dispensary in Washington in Q2 2021? | SELECT d.name, AVG(s.revenue) as avg_daily_revenue FROM Dispensaries d JOIN Sales s ON d.id = s.dispensary_id WHERE s.sale_date BETWEEN '2021-04-01' AND '2021-06-30' GROUP BY d.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE OCEAN_PH (LOCATION VARCHAR(20), MEASUREMENT_DATE DATE, PH FLOAT); INSERT INTO OCEAN_PH (LOCATION, MEASUREMENT_DATE, PH) VALUES ('Mariana Trench', '2022-01-01', 7.8), ('Mariana Trench', '2022-01-07', 7.7), ('Mariana Trench', '2022-01-14', 7.6), ('Mariana Trench', '2022-01-21', 7.5), ('Mariana Trench', '2022... | Show the change in ocean pH levels for the Mariana Trench over time, with weekly intervals. | SELECT LOCATION, MEASUREMENT_DATE, PH, LEAD(PH, 1) OVER (PARTITION BY LOCATION ORDER BY MEASUREMENT_DATE) AS NEXT_PH FROM OCEAN_PH WHERE LOCATION = 'Mariana Trench' ORDER BY MEASUREMENT_DATE; | gretelai_synthetic_text_to_sql |
CREATE TABLE asia_tourists (id INT, country VARCHAR(20), tourists INT); INSERT INTO asia_tourists (id, country, tourists) VALUES (1, 'China', 60000000), (2, 'Japan', 20000000), (3, 'India', 35000000), (4, 'Indonesia', 15000000), (5, 'Thailand', 25000000); | Find the top 3 countries with the most tourists in Asia, excluding China and Japan. | SELECT country, tourists FROM (SELECT country, tourists, ROW_NUMBER() OVER (ORDER BY tourists DESC) AS rank FROM asia_tourists WHERE country NOT IN ('China', 'Japan') ) AS top_asia_countries WHERE rank <= 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE donations (id INT, donor_id INT, category VARCHAR(255), amount DECIMAL(10, 2)); INSERT INTO donations (id, donor_id, category, amount) VALUES (1, 1, 'healthcare', 1000), (2, 1, 'education', 2000), (3, 2, 'healthcare', 500), (4, 2, 'healthcare', 1500), (5, 3, 'education', 3000); | How many unique donors are there for each category, sorted alphabetically? | SELECT category, COUNT(DISTINCT donor_id) AS unique_donors FROM donations GROUP BY category ORDER BY category ASC; | gretelai_synthetic_text_to_sql |
CREATE TABLE Lanthanum_Production (year INT, production FLOAT); INSERT INTO Lanthanum_Production (year, production) VALUES (2015, 1500), (2016, 1600), (2017, 1700), (2018, 1800), (2019, 1900), (2020, 2000); CREATE TABLE Cerium_Production (year INT, production FLOAT); INSERT INTO Cerium_Production (year, production) VAL... | What is the ratio of Lanthanum to Cerium production in 2019? | SELECT production[year=2019]/(SELECT production FROM Cerium_Production WHERE year = 2019) FROM Lanthanum_Production WHERE year = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE suppliers (id INT, name VARCHAR(255), material VARCHAR(255)); INSERT INTO suppliers (id, name, material) VALUES (1, 'Supplier A', 'Plastic'), (2, 'Supplier B', 'Glass'), (3, 'Supplier C', 'Recycled Plastic'), (4, 'Supplier D', 'Metal'); | List all suppliers that provide recycled materials for manufacturing. | SELECT s.name FROM suppliers s WHERE s.material = 'Recycled Plastic' OR s.material = 'Recycled Glass'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ProgramOutcomes (ProgramID INT, ProgramName TEXT, SuccessRate DECIMAL(5,2)); CREATE TABLE Programs (ProgramID INT, ProgramName TEXT, HasYouth INTEGER); | What is the success rate of programs that have 'Youth' in their name? | SELECT AVG(ProgramOutcomes.SuccessRate) AS AverageSuccessRate FROM ProgramOutcomes INNER JOIN Programs ON ProgramOutcomes.ProgramID = Programs.ProgramID WHERE Programs.HasYouth = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE companies (id INT, name VARCHAR(50), type VARCHAR(50), location VARCHAR(50), investment FLOAT); INSERT INTO companies (id, name, type, location, investment) VALUES (1, 'BioTex', 'Bioprocess', 'Texas', 5000000); INSERT INTO companies (id, name, type, location, investment) VALUES (2, 'ProBioLabs', 'Genetic R... | What is the total investment for bioprocess engineering companies in Texas? | SELECT SUM(investment) FROM companies WHERE type = 'Bioprocess' AND location = 'Texas'; | gretelai_synthetic_text_to_sql |
CREATE TABLE attacks (id INT, sector VARCHAR(20), type VARCHAR(50)); INSERT INTO attacks (id, sector, type) VALUES (1, 'Energy', 'Cyber Attack'), (2, 'Healthcare', 'Phishing'), (3, 'Financial', 'Ransomware'); | How many times has the energy sector been targeted by cyber attacks? | SELECT COUNT(*) FROM attacks WHERE sector = 'Energy' AND type = 'Cyber Attack'; | gretelai_synthetic_text_to_sql |
CREATE TABLE JobOpenings (OpeningID INT, JobCategory VARCHAR(20), OpeningDate DATE, CloseDate DATE); INSERT INTO JobOpenings (OpeningID, JobCategory, OpeningDate, CloseDate) VALUES (1, 'Marketing', '2022-01-01', '2022-02-15'), (2, 'IT', '2022-03-01', '2022-04-10'); | What is the average time to fill open positions, segmented by job category? | SELECT JobCategory, AVG(DATEDIFF(CloseDate, OpeningDate)) FROM JobOpenings GROUP BY JobCategory; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT, HireDate DATE); CREATE TABLE UnderrepresentedCommunities (CommunityID INT, CommunityName VARCHAR(50)); CREATE TABLE EmployeeCommunities (EmployeeID INT, CommunityID INT); | What is the total number of employees hired from underrepresented communities, by year? | SELECT YEAR(e.HireDate) AS Year, COUNT(DISTINCT e.EmployeeID) FROM Employees e INNER JOIN EmployeeCommunities ec ON e.EmployeeID = ec.EmployeeID INNER JOIN UnderrepresentedCommunities uc ON ec.CommunityID = uc.CommunityID GROUP BY YEAR(e.HireDate); | gretelai_synthetic_text_to_sql |
CREATE TABLE Freight (id INT PRIMARY KEY, shipment_id INT, origin VARCHAR(50), destination VARCHAR(50), distance INT, cost FLOAT); INSERT INTO Freight (id, shipment_id, origin, destination, distance, cost) VALUES (1, 1, 'Mumbai', 'Delhi', 1400, 7200.5), (2, 2, 'Tokyo', 'Seoul', 2100, 1050.3), (3, 3, 'São Paulo', 'Bueno... | Calculate the average distance of freight for each city of origin. | SELECT origin, AVG(distance) FROM Freight GROUP BY origin; | gretelai_synthetic_text_to_sql |
CREATE TABLE Impressionist_Art(artist VARCHAR(20), artwork VARCHAR(20), movement VARCHAR(20)); INSERT INTO Impressionist_Art VALUES ('Monet', 'Water Lilies', 'Impressionism'), ('Renoir', 'Dance at Le Moulin de la Galette', 'Impressionism'), ('Degas', 'Ballet Rehearsal', 'Impressionism'), ('Morisot', 'The Cradle', 'Imp... | List the Impressionist artists and their artworks. | SELECT artist, artwork FROM Impressionist_Art WHERE movement = 'Impressionism'; | gretelai_synthetic_text_to_sql |
CREATE TABLE vulnerabilities (id INT, detection_date DATE, software_vendor VARCHAR(255), risk_score INT); INSERT INTO vulnerabilities (id, detection_date, software_vendor, risk_score) VALUES (1, '2022-01-01', 'VendorA', 9), (2, '2022-01-05', 'VendorB', 7), (3, '2022-01-10', 'VendorC', 8); | Identify the top 3 most vulnerable software vendors, ranked by the total number of high risk vulnerabilities, in the past year. | SELECT software_vendor, SUM(CASE WHEN risk_score >= 8 THEN 1 ELSE 0 END) as high_risk_vulnerabilities, RANK() OVER (ORDER BY SUM(CASE WHEN risk_score >= 8 THEN 1 ELSE 0 END) DESC) as rank FROM vulnerabilities WHERE detection_date >= DATE(NOW()) - INTERVAL '1 year' GROUP BY software_vendor HAVING rank <= 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE driver (driver_id INT, driver_name TEXT);CREATE TABLE fare (fare_id INT, driver_id INT, fare_amount DECIMAL, collection_date DATE); INSERT INTO driver (driver_id, driver_name) VALUES (1, 'Driver1'), (2, 'Driver2'), (3, 'Driver3'), (4, 'Driver4'), (5, 'Driver5'); INSERT INTO fare (fare_id, driver_id, fare_a... | List the drivers who have collected the highest total fare in the past month. | SELECT d.driver_name, SUM(f.fare_amount) as total_fare FROM driver d JOIN fare f ON d.driver_id = f.driver_id WHERE f.collection_date BETWEEN DATEADD(month, -1, GETDATE()) AND GETDATE() GROUP BY d.driver_id ORDER BY total_fare DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE food_nutrition_info (food_id INT, food_name VARCHAR(255), sodium_content DECIMAL(5,2)); | Display the names and nutrient information of all food items that are low in sodium (<=140mg) in the food_nutrition_info table. | SELECT food_name, sodium_content FROM food_nutrition_info WHERE sodium_content <= 140.0; | gretelai_synthetic_text_to_sql |
CREATE TABLE workers (id INT, name TEXT, skill TEXT, location TEXT); INSERT INTO workers (id, name, skill, location) VALUES (1, 'John', 'skilled', 'Germany'), (2, 'Jane', 'unskilled', 'Germany'), (3, 'Mark', 'skilled', 'France'); | What is the total number of 'skilled' workers in 'Germany'? | SELECT COUNT(*) FROM workers WHERE skill = 'skilled' AND location = 'Germany'; | gretelai_synthetic_text_to_sql |
CREATE TABLE policy_trends_developed (country VARCHAR(255), trend VARCHAR(255)); INSERT INTO policy_trends_developed (country, trend) VALUES ('US', 'Renewable Energy'), ('UK', 'Carbon Pricing'), ('Germany', 'Energy Efficiency'); CREATE TABLE policy_trends_developing (country VARCHAR(255), trend VARCHAR(255)); INSERT IN... | What is the distribution of clean energy policy trends in developed and developing countries? | SELECT country, COUNT(trend) AS num_trends, 100.0 * COUNT(trend) / (SELECT COUNT(*) FROM policy_trends_developed) AS percent FROM policy_trends_developed GROUP BY country UNION ALL SELECT country, COUNT(trend) AS num_trends, 100.0 * COUNT(trend) / (SELECT COUNT(*) FROM policy_trends_developing) AS percent FROM policy_t... | gretelai_synthetic_text_to_sql |
CREATE TABLE lunar_rovers (id INT, name VARCHAR(255), deployment_date DATE, deploying_country VARCHAR(255)); INSERT INTO lunar_rovers (id, name, deployment_date, deploying_country) VALUES (1, 'Yutu', '2013-12-14', 'China'); INSERT INTO lunar_rovers (id, name, deployment_date, deploying_country) VALUES (2, 'Pragyan', '2... | List all lunar rovers deployed by China and India on the Moon. | SELECT * FROM lunar_rovers l INNER JOIN lunar_rovers_china c ON l.id = c.id INNER JOIN lunar_rovers_india i ON l.id = i.id; | gretelai_synthetic_text_to_sql |
CREATE TABLE animal_population (animal_id INT, animal_name VARCHAR(50), program VARCHAR(50), added_date DATE); INSERT INTO animal_population (animal_id, animal_name, program, added_date) VALUES (1, 'Grizzly Bear', 'habitat_preservation', '2022-01-01'), (2, 'Gray Wolf', 'community_education', '2022-02-01'), (3, 'Bald Ea... | Calculate the number of animals in the 'habitat_preservation' program that were added in the last month | SELECT COUNT(*) FROM animal_population WHERE program = 'habitat_preservation' AND added_date >= DATEADD(MONTH, -1, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE movie_runtime (title VARCHAR(255), runtime INT, release_year INT); INSERT INTO movie_runtime (title, runtime, release_year) VALUES ('Pulp Fiction', 154, 1994), ('The Matrix', 136, 1999); | What is the average runtime of movies by release year? | SELECT release_year, AVG(runtime) FROM movie_runtime GROUP BY release_year; | gretelai_synthetic_text_to_sql |
CREATE TABLE CountrySustainableTravel (country_id INT, year INT, pct_sustainable_travel FLOAT); INSERT INTO CountrySustainableTravel (country_id, year, pct_sustainable_travel) VALUES (1, 2019, 0.5); INSERT INTO CountrySustainableTravel (country_id, year, pct_sustainable_travel) VALUES (2, 2019, 0.7); INSERT INTO Countr... | Rank countries by the percentage of international visitors who travel sustainably in 2019. | SELECT country_id, RANK() OVER (ORDER BY pct_sustainable_travel DESC) as rank FROM CountrySustainableTravel WHERE year = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE wildlife_habitat (id INT, name VARCHAR(255), area FLOAT); INSERT INTO wildlife_habitat (id, name, area) VALUES (1, 'Habitat1', 50.3), (2, 'Habitat2', 32.7), (3, 'Habitat3', 86.9), (4, 'Habitat4', 45.6); | Update the 'area' value for the record with id 3 in the 'wildlife_habitat' table to 95.8 square kilometers. | UPDATE wildlife_habitat SET area = 95.8 WHERE id = 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE departments (id INT, name TEXT); CREATE TABLE inclusion_expenses (id INT, department_id INT, amount INT); INSERT INTO departments (id, name) VALUES (1, 'Dept A'), (2, 'Dept B'); INSERT INTO inclusion_expenses (id, department_id, amount) VALUES (1, 1, 1000), (2, 1, 2000), (3, 2, 1500); | What is the total expenditure on inclusion efforts for each department, ordered from highest to lowest? | SELECT departments.name, SUM(inclusion_expenses.amount) FROM departments INNER JOIN inclusion_expenses ON departments.id = inclusion_expenses.department_id GROUP BY departments.name ORDER BY SUM(inclusion_expenses.amount) DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE platforms (id INT, platform TEXT); | Add a new platform to the 'platforms' table with the platform name 'New Platform' | INSERT INTO platforms (id, platform) VALUES (null, 'New Platform'); | gretelai_synthetic_text_to_sql |
CREATE TABLE ai_safety_incidents (incident_id INT, incident_date DATE, ai_subfield TEXT, incident_description TEXT); INSERT INTO ai_safety_incidents (incident_id, incident_date, ai_subfield, incident_description) VALUES (1, '2020-07-01', 'Explainable AI', 'Model failed to provide clear explanations'); INSERT INTO ai_sa... | How many AI safety incidents were reported for each AI subfield in the second half of 2020 and the first half of 2021, and which subfield had the most incidents in this period? | SELECT ai_subfield, SUM(CASE WHEN incident_date BETWEEN '2020-07-01' AND '2021-06-30' THEN 1 ELSE 0 END) as incidents FROM ai_safety_incidents GROUP BY ai_subfield ORDER BY incidents DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Manufacturing(id INT, material_name VARCHAR(50), manufacturing_time INT, production_country VARCHAR(50), is_sustainable BOOLEAN); INSERT INTO Manufacturing(id, material_name, manufacturing_time, production_country, is_sustainable) VALUES (1, 'Organic Cotton', 10, 'Germany', true); INSERT INTO Manufacturing... | Get the average manufacturing time for sustainable materials in Germany. | SELECT AVG(manufacturing_time) FROM Manufacturing WHERE is_sustainable = true AND production_country = 'Germany'; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists engineering; CREATE TABLE if not exists engineering.jobs( job_id INT PRIMARY KEY, title VARCHAR(100), location VARCHAR(50), salary DECIMAL(10,2)); INSERT INTO engineering.jobs (job_id, title, location, salary) VALUES (1, 'Bioprocess Engineer', 'Canada', 80000); INSERT INTO engineering.jobs (... | How many bioprocess engineering jobs are available in Canada? | SELECT COUNT(*) FROM engineering.jobs WHERE title = 'Bioprocess Engineer' AND location = 'Canada'; | gretelai_synthetic_text_to_sql |
CREATE TABLE threat_intelligence (id INT, source VARCHAR(10), ip_address VARCHAR(15), domain VARCHAR(25)); INSERT INTO threat_intelligence (id, source, ip_address, domain) VALUES (1, 'TI1', '192.168.1.1', 'example1.com'), (2, 'TI2', '192.168.1.2', 'example2.com'), (3, 'TI3', '192.168.1.3', 'example3.com'), (4, 'TI4', '... | List the number of unique IP addresses and domains found in threat intelligence data | SELECT source, COUNT(DISTINCT ip_address) as unique_ips, COUNT(DISTINCT domain) as unique_domains FROM threat_intelligence GROUP BY source; | gretelai_synthetic_text_to_sql |
CREATE TABLE ambulances (ambulance_id INT, name TEXT, rural BOOLEAN); CREATE TABLE counties (county_code TEXT, county_name TEXT); INSERT INTO ambulances (ambulance_id, name, rural) VALUES (1, 'Rural Ambulance Service', TRUE), (2, 'Urban Ambulance Service', FALSE); INSERT INTO counties (county_code, county_name) VALUES ... | What is the number of rural ambulance services in each county, ordered by county name. | SELECT 'Ambulance' as type, counties.county_name, COUNT(ambulances.ambulance_id) as count FROM ambulances INNER JOIN counties ON TRUE WHERE ambulances.rural = TRUE GROUP BY counties.county_name ORDER BY counties.county_name; | gretelai_synthetic_text_to_sql |
species (species_id, common_name, scientific_name, family) | Update the species name for species_id 123 | UPDATE species SET common_name = 'New Name' WHERE species_id = 123 | gretelai_synthetic_text_to_sql |
CREATE TABLE properties (id INT, city VARCHAR(50), listing_price DECIMAL(10, 2), has_inclusive_policy BOOLEAN); INSERT INTO properties (id, city, listing_price, has_inclusive_policy) VALUES (1, 'Denver', 1000000.00, TRUE), (2, 'Denver', 800000.00, FALSE), (3, 'Denver', 900000.00, TRUE); | What is the most expensive property in Denver with an inclusive housing policy? | SELECT * FROM properties WHERE city = 'Denver' AND has_inclusive_policy = TRUE ORDER BY listing_price DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE emergency_calls (call_id INT, call_time TIMESTAMP, city TEXT, response_time INT); INSERT INTO emergency_calls (call_id, call_time, city, response_time) VALUES (1, '2022-01-01 01:23:45', 'Miami', 15); INSERT INTO emergency_calls (call_id, call_time, city, response_time) VALUES (2, '2022-01-01 00:12:34', 'Mi... | What is the average response time for emergency calls in Miami, considering only incidents that occurred after midnight? | SELECT AVG(response_time) FROM emergency_calls WHERE city = 'Miami' AND EXTRACT(HOUR FROM call_time) > 0; | gretelai_synthetic_text_to_sql |
CREATE TABLE Citizen_Complaints(District VARCHAR(255), Complaint VARCHAR(255)); INSERT INTO Citizen_Complaints VALUES ('District 1', 'Potholes'), ('District 1', 'Garbage'), ('District 2', 'Potholes'), ('District 3', 'Graffiti'), ('District 3', 'Potholes'); | What is the number of citizen complaints received in each district, ordered from the most to least complaints? | SELECT District, COUNT(Complaint) as Num_Complaints FROM Citizen_Complaints GROUP BY District ORDER BY Num_Complaints DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE Projects (project_id INT, contractor_id INT, start_date DATE, end_date DATE); | List all projects with a start date on or after "2022-01-01" from the "Projects" table. | SELECT * FROM Projects WHERE start_date >= '2022-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE energy_production (energy_source VARCHAR(255), year INT, monthly_production FLOAT); INSERT INTO energy_production VALUES ('Wind', 2022, 2000), ('Solar', 2022, 3000), ('Hydro', 2022, 4000), ('Wind', 2022, 2500), ('Solar', 2022, 3500), ('Hydro', 2022, 4500); | Determine the percentage of total energy production for each energy source (wind, solar, hydro) in a given year. | SELECT energy_source, SUM(monthly_production) / SUM(SUM(monthly_production)) OVER () AS percentage_of_total FROM energy_production WHERE year = 2022 GROUP BY energy_source; | gretelai_synthetic_text_to_sql |
CREATE TABLE Education (city VARCHAR(20), region VARCHAR(20), year INT, program_count INT); INSERT INTO Education (city, region, year, program_count) VALUES ('Los Angeles', 'Southern', 2021, 50), ('San Diego', 'Southern', 2021, 40), ('Santa Monica', 'Southern', 2021, 30), ('Los Angeles', 'Southern', 2022, 60), ('San Di... | List all unique cities and the total number of arts education programs in 'Southern' region for 2021 and 2022, sorted by the total number of programs in descending order. | SELECT city, SUM(program_count) FROM Education WHERE region = 'Southern' AND year IN (2021, 2022) GROUP BY city ORDER BY SUM(program_count) DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE Patients (ID INT, Disease VARCHAR(20), DiagnosisDate DATE, Region VARCHAR(20)); INSERT INTO Patients (ID, Disease, DiagnosisDate, Region) VALUES (1, 'Dengue Fever', '2022-01-01', 'Central'), (2, 'Dengue Fever', '2022-06-15', 'Central'); | How many patients have been diagnosed with Dengue Fever in the last 6 months in each region? | SELECT Region, COUNT(*) AS CountPerRegion FROM Patients WHERE Disease = 'Dengue Fever' AND DiagnosisDate >= DATEADD(MONTH, -6, GETDATE()) GROUP BY Region; | gretelai_synthetic_text_to_sql |
CREATE TABLE accommodations (accommodation_id INT, name VARCHAR(50), country VARCHAR(50), is_eco_friendly BOOLEAN); | What is the total number of eco-friendly accommodations in Canada and the United States? | SELECT COUNT(*) FROM accommodations WHERE (country = 'Canada' OR country = 'United States') AND is_eco_friendly = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE renewable_energy_sources (id INT, country VARCHAR(255), source VARCHAR(255), installed_capacity INT); INSERT INTO renewable_energy_sources (id, country, source, installed_capacity) VALUES (1, 'Germany', 'Solar', 500), (2, 'France', 'Wind', 600), (3, 'Spain', 'Hydro', 700), (4, 'Italy', 'Geothermal', 800), ... | What is the total installed capacity of renewable energy sources in each country? | SELECT country, SUM(installed_capacity) FROM renewable_energy_sources GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE EthicalAI (country VARCHAR(20), num_principles INT); INSERT INTO EthicalAI (country, num_principles) VALUES ('USA', 5), ('China', 3), ('India', 4), ('Brazil', 6), ('Russia', 2); | What are the top 2 countries with the least number of ethical AI principles? | SELECT country, num_principles FROM (SELECT country, num_principles FROM EthicalAI ORDER BY num_principles LIMIT 2) AS subquery ORDER BY num_principles DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE ImpactInvestments (InvestmentID INT, InvestmentAmount DECIMAL(10,2), Sector VARCHAR(30)); INSERT INTO ImpactInvestments (InvestmentID, InvestmentAmount, Sector) VALUES (1, 5000, 'Education'), (2, 10000, 'Healthcare'), (3, 7500, 'Education'); | What is the maximum amount invested in the 'Education' sector? | SELECT MAX(InvestmentAmount) FROM ImpactInvestments WHERE Sector = 'Education'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Products (productID int, productName varchar(255), ethicallySourced varchar(5), price decimal(10,2)); INSERT INTO Products VALUES (1, 'ProductA', 'Y', 19.99); CREATE TABLE Suppliers (supplierID int, supplierName varchar(255), country varchar(255)); INSERT INTO Suppliers VALUES (1, 'SupplierA', 'Canada'); C... | What is the total quantity of ethically sourced products sold in Canada in Q1 2022? | SELECT SUM(S.quantity) as total_quantity FROM Sales S INNER JOIN Products P ON S.productID = P.productID INNER JOIN Suppliers Supp ON P.supplierID = Supp.supplierID WHERE P.ethicallySourced = 'Y' AND Supp.country = 'Canada' AND YEAR(S.date) = 2022 AND QUARTER(S.date) = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE RecyclingRates (id INT, district VARCHAR(20), recycling_rate DECIMAL(5,2)); INSERT INTO RecyclingRates (id, district, recycling_rate) VALUES (1, 'DistrictA', 0.65), (2, 'DistrictB', 0.70), (3, 'DistrictC', 0.55); | Which districts have a recycling rate higher than the average recycling rate? | SELECT district FROM RecyclingRates WHERE recycling_rate > (SELECT AVG(recycling_rate) FROM RecyclingRates); | gretelai_synthetic_text_to_sql |
CREATE TABLE Streaming (id INT, artist VARCHAR(50), streams INT, country VARCHAR(50)); INSERT INTO Streaming (id, artist, streams, country) VALUES (1, 'Sia', 1000000, 'Australia'), (2, 'Taylor Swift', 2000000, 'USA'), (3, 'Ed Sheeran', 1200000, 'UK'); | What is the minimum number of streams for any artist from the UK? | SELECT MIN(streams) FROM Streaming WHERE country = 'UK'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ProtectedSpecies(species_id INT, species_name TEXT, region TEXT); INSERT INTO ProtectedSpecies (species_id, species_name, region) VALUES (101, 'Lynx', 'Region C'), (102, 'Seal', 'Region D'), (103, 'Otter', 'Region C'); | Show the names and regions of all protected species with an ID greater than 100. | SELECT species_name, region FROM ProtectedSpecies WHERE species_id > 100; | gretelai_synthetic_text_to_sql |
CREATE TABLE AICreativity (id INT, incident_sector VARCHAR(50), incident_type VARCHAR(50)); INSERT INTO AICreativity (id, incident_sector, incident_type) VALUES (1, 'Arts', 'Artistic Freedom'), (2, 'Arts', 'Artistic Expression'), (3, 'Finance', 'Financial Loss'), (4, 'Arts', 'Censorship'), (5, 'Arts', 'Artistic Integri... | What is the total number of AI creativity incidents reported in the arts sector, and what is the minimum number of incidents reported for a single incident type? | SELECT incident_sector, COUNT(incident_type) as incident_count FROM AICreativity WHERE incident_sector = 'Arts' GROUP BY incident_sector; SELECT MIN(incident_count) as min_incidents FROM (SELECT incident_sector, COUNT(incident_type) as incident_count FROM AICreativity WHERE incident_sector = 'Arts' GROUP BY incident_se... | gretelai_synthetic_text_to_sql |
CREATE TABLE species (species_id INT, species_name VARCHAR(255)); INSERT INTO species (species_id, species_name) VALUES (1, 'SpeciesA'), (2, 'SpeciesB'); CREATE TABLE temperature (year INT, species_id INT, temp FLOAT); INSERT INTO temperature (year, species_id, temp) VALUES (2000, 1, 15), (2000, 2, 22), (2001, 1, 18), ... | What is the maximum temperature per year for each species? | SELECT species_id, MAX(temp) as max_temp FROM temperature GROUP BY species_id, YEAR(year) | gretelai_synthetic_text_to_sql |
CREATE TABLE rural_infrastructure (id INT, project_name VARCHAR(255), budget FLOAT, department VARCHAR(50)); INSERT INTO rural_infrastructure (id, project_name, budget, department) VALUES (1, 'Road Maintenance', 95000.00, 'Antioquia'), (2, 'Water Supply System', 120000.00, 'Antioquia'), (3, 'Sanitation Services', 11000... | What is the maximum budget for rural infrastructure projects in Colombia's Antioquia department? | SELECT MAX(budget) FROM rural_infrastructure WHERE department = 'Antioquia' | 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.