context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE Employees (EmployeeID INT, Gender VARCHAR(10), JobTitle VARCHAR(50), Salary INT); INSERT INTO Employees (EmployeeID, Gender, JobTitle, Salary) VALUES (1, 'Male', 'Manager', 70000), (2, 'Female', 'Manager', 65000), (3, 'Male', 'Developer', 60000), (4, 'Female', 'Developer', 62000); | What is the average salary of male and female employees, partitioned by job title? | SELECT JobTitle, AVG(CASE WHEN Gender = 'Male' THEN Salary ELSE NULL END) AS Avg_Male_Salary, AVG(CASE WHEN Gender = 'Female' THEN Salary ELSE NULL END) AS Avg_Female_Salary FROM Employees GROUP BY JobTitle; | gretelai_synthetic_text_to_sql |
CREATE TABLE sports_team_a_fans (fan_id INT, age INT, gender VARCHAR(10), favorite_player VARCHAR(20)); INSERT INTO sports_team_a_fans (fan_id, age, gender, favorite_player) VALUES (1, 25, 'Female', 'Player A'), (2, 35, 'Male', 'Player B'), (3, 45, 'Non-binary', 'Player C'); CREATE TABLE sports_team_b_fans (fan_id INT,... | Show the UNION of 'sports_team_a_fans' and 'sports_team_b_fans' tables | SELECT * FROM sports_team_a_fans UNION SELECT * FROM sports_team_b_fans; | gretelai_synthetic_text_to_sql |
CREATE TABLE posts (post_id INT, user_id INT, followers INT, post_date DATE, content TEXT); CREATE TABLE comments (comment_id INT, post_id INT, user_id INT, comment_date DATE, comment_text TEXT); | What is the total number of comments on posts related to mental health, published by users in Japan, in the month of February 2022? | SELECT SUM(c.comments) FROM posts p JOIN comments c ON p.post_id = c.post_id WHERE p.content LIKE '%mental health%' AND p.country = 'Japan' AND p.post_date >= '2022-02-01' AND p.post_date < '2022-03-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Suicide (ID INT, Country VARCHAR(100), Year INT, SuicideRate FLOAT); INSERT INTO Suicide (ID, Country, Year, SuicideRate) VALUES (1, 'New Zealand', 2020, 12); | What is the suicide rate in New Zealand? | SELECT SuicideRate FROM Suicide WHERE Country = 'New Zealand' AND Year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE waste_generation (city VARCHAR(255), material VARCHAR(255), year INT, quantity INT); INSERT INTO waste_generation (city, material, year, quantity) VALUES ('New York City', 'Plastic', 2020, 15000), ('New York City', 'Paper', 2020, 20000), ('New York City', 'Glass', 2020, 10000), ('New York City', 'Metal', 2... | What was the total waste generation by material type in 2020 for New York City? | SELECT material, SUM(quantity) FROM waste_generation WHERE city = 'New York City' AND year = 2020 GROUP BY material; | gretelai_synthetic_text_to_sql |
CREATE TABLE delays (route_id INT, delay DECIMAL(3,2), date DATE); INSERT INTO delays (route_id, delay, date) VALUES (1, 3.1, '2022-02-01'), (1, 4.2, '2022-02-02'), (2, 2.9, '2022-02-01'), (2, 3.0, '2022-02-02'); CREATE TABLE subway_routes (id INT, name VARCHAR(50), type VARCHAR(10)); INSERT INTO subway_routes (id, nam... | What is the average daily delay for each subway line? | SELECT r.name, AVG(d.delay) AS avg_delay FROM delays d JOIN subway_routes r ON d.route_id = r.id GROUP BY r.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE program_donations (donation_id INT, program_id INT, donor_id INT, donation_amount FLOAT, donation_date DATE); INSERT INTO program_donations (donation_id, program_id, donor_id, donation_amount, donation_date) VALUES (1, 1, 1, 200, '2021-07-01'); INSERT INTO program_donations (donation_id, program_id, donor_... | Which programs had the highest and lowest donation amounts in H2 2021? | SELECT program_id, donation_amount FROM (SELECT program_id, donation_amount, ROW_NUMBER() OVER (ORDER BY donation_amount DESC) AS high_donation, ROW_NUMBER() OVER (ORDER BY donation_amount ASC) AS low_donation FROM program_donations WHERE EXTRACT(YEAR FROM donation_date) = 2021 AND EXTRACT(MONTH FROM donation_date) BET... | gretelai_synthetic_text_to_sql |
CREATE TABLE IF NOT EXISTS public.tunnels (id SERIAL PRIMARY KEY, name TEXT, length REAL, material TEXT); INSERT INTO public.tunnels (name, length, material) SELECT 'Tunnel001', 500.0, 'Concrete' FROM generate_series(1, 10); INSERT INTO public.tunnels (name, length, material) SELECT 'Tunnel002', 700.0, 'Steel' FROM gen... | What is the average length of all tunnels in the "tunnels" table, grouped by the type of tunnel material? | SELECT material, AVG(length) FROM public.tunnels GROUP BY material; | gretelai_synthetic_text_to_sql |
CREATE TABLE vessels (id INT, name TEXT, type TEXT, safety_record TEXT); INSERT INTO vessels (id, name, type, safety_record) VALUES (1, 'Vessel E', 'Cargo', 'Good'); INSERT INTO vessels (id, name, type, safety_record) VALUES (2, 'Vessel F', 'Tanker', 'Excellent'); CREATE TABLE incidents (id INT, vessel_id INT, location... | Update the safety records of all vessels that have been involved in accidents in the South China Sea. | UPDATE vessels SET safety_record = 'Poor' WHERE id IN (SELECT vessel_id FROM incidents WHERE location = 'South China Sea'); | gretelai_synthetic_text_to_sql |
CREATE TABLE cultural_competency_trainings (training_id INT, year INT, location VARCHAR(50)); INSERT INTO cultural_competency_trainings (training_id, year, location) VALUES (1, 2022, 'NYC'); INSERT INTO cultural_competency_trainings (training_id, year, location) VALUES (2, 2021, 'LA'); | How many cultural competency trainings were conducted in 2022 in the cultural_competency schema? | SELECT COUNT(*) FROM cultural_competency.cultural_competency_trainings WHERE year = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE daily_sales (sale_date DATE, product_id INT, quantity INT, ethical_source BOOLEAN); INSERT INTO daily_sales VALUES ('2022-06-01', 1, 50, true), ('2022-06-01', 2, 30, false), ('2022-06-02', 1, 75, true), ('2022-06-02', 2, 40, false), ('2022-06-03', 1, 80, true), ('2022-06-03', 2, 35, false), ('2022-06-04', ... | What is the change in the quantity of each ethically sourced product sold, compared to the previous day, for the last 14 days? | SELECT sale_date, product_id, quantity, LAG(quantity, 1) OVER (PARTITION BY product_id, ethical_source ORDER BY sale_date) as prev_quantity, quantity - LAG(quantity, 1) OVER (PARTITION BY product_id, ethical_source ORDER BY sale_date) as quantity_change FROM daily_sales WHERE sale_date >= DATE_SUB(CURRENT_DATE, INTERVA... | gretelai_synthetic_text_to_sql |
CREATE TABLE justice_legal_aid (id INT, case_id INT, case_type TEXT, duration INT, resolution_date DATE); INSERT INTO justice_legal_aid (id, case_id, case_type, duration, resolution_date) VALUES (1, 1, 'Civil', 6, '2021-05-01'), (2, 2, 'Criminal', 12, '2020-01-01'), (3, 3, 'Civil', 3, '2021-03-15'); | What is the average duration of legal aid cases in 'justice_legal_aid' table, for 'Civil' cases, in the last 6 months? | SELECT AVG(duration/30.0) FROM justice_legal_aid WHERE case_type = 'Civil' AND resolution_date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE wastewater_treatment (household_id INT, city VARCHAR(30), year INT, waste_amount FLOAT); | What is the average water waste per household in each city in 2021? | SELECT city, AVG(waste_amount) FROM wastewater_treatment WHERE year=2021 GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE Languages (Language VARCHAR(50), Status VARCHAR(50)); | Insert new records for the languages 'Mapudungun' and 'Guarani' into the Languages table. | INSERT INTO Languages (Language, Status) VALUES ('Mapudungun', 'Vulnerable'), ('Guarani', 'Vulnerable'); | gretelai_synthetic_text_to_sql |
CREATE TABLE audience (id INT, gender VARCHAR(10), region VARCHAR(20)); CREATE TABLE interests (id INT, category VARCHAR(20)); INSERT INTO audience VALUES (1, 'female', 'Northeast'); INSERT INTO interests VALUES (1, 'politics'); | What percentage of the audience is female and prefers articles about politics in the Northeast region? | SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM audience)) as percentage FROM audience INNER JOIN interests ON audience.id = interests.id WHERE audience.region = 'Northeast' AND interests.category = 'politics' AND audience.gender = 'female'; | gretelai_synthetic_text_to_sql |
CREATE TABLE water_treatment_plants (id INT, name VARCHAR(50), location VARCHAR(50), design_life INT); INSERT INTO water_treatment_plants (id, name, location, design_life) VALUES (1, 'Central Water Treatment Plant', 'Texas', 40); | Calculate the average design life of water treatment plants in 'Texas' | SELECT AVG(design_life) FROM water_treatment_plants WHERE location = 'Texas'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ports (port_id INT, port_name TEXT, country TEXT);CREATE TABLE shipments (shipment_id INT, shipment_weight INT, ship_date DATE, port_id INT); INSERT INTO ports VALUES (1, 'Port of Tanjung Pelepas', 'Malaysia'), (2, 'Port of Johor Bahru', 'Malaysia'); INSERT INTO shipments VALUES (1, 1500, '2020-07-01', 1),... | What is the minimum weight of containers shipped from the Port of Tanjung Pelepas to Malaysia in Q3 of 2020? | SELECT MIN(shipment_weight) FROM shipments JOIN ports ON shipments.port_id = ports.port_id WHERE ports.country = 'Malaysia' AND ports.port_name IN ('Port of Tanjung Pelepas', 'Port of Johor Bahru') AND ship_date BETWEEN '2020-07-01' AND '2020-09-30'; | gretelai_synthetic_text_to_sql |
CREATE TABLE policy (policy_id INT, issue_date DATE, zip_code INT); CREATE TABLE claim (claim_id INT, policy_id INT, claim_amount INT); | What is the average claim amount for policies issued in the last quarter in California? | SELECT AVG(claim_amount) FROM claim JOIN policy ON claim.policy_id = policy.policy_id WHERE policy.issue_date >= DATEADD(QUARTER, -1, GETDATE()) AND zip_code = (SELECT zip_code FROM zip_codes WHERE state = 'CA' AND city = 'Los Angeles'); | gretelai_synthetic_text_to_sql |
CREATE TABLE media_contents (content_id INTEGER, title VARCHAR(255), duration INTEGER, production_country VARCHAR(100)); INSERT INTO media_contents (content_id, title, duration, production_country) VALUES (1, 'Content1', 120, 'USA'), (2, 'Content2', 90, 'Canada'), (3, 'Content3', 150, 'USA'); | What is the average duration of media contents produced in the USA? | SELECT AVG(duration) FROM media_contents WHERE production_country = 'USA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE conservation_initiatives (id INT, initiative VARCHAR(255), species VARCHAR(255), region VARCHAR(255)); INSERT INTO conservation_initiatives (id, initiative, species, region) VALUES (1, 'Ice Cap Mapping', 'Polar Bear', 'Arctic'), (2, 'Beach Cleanup', 'Dolphin', 'Pacific'), (3, 'Coral Restoration', 'Clownfis... | Which conservation initiatives are specific to the Arctic region and do not involve the Dolphin species? | SELECT initiative FROM conservation_initiatives WHERE region = 'Arctic' AND species != 'Dolphin'; | gretelai_synthetic_text_to_sql |
CREATE TABLE job_categories (id INT, name VARCHAR(255)); INSERT INTO job_categories (id, name) VALUES (1, 'Manager'), (2, 'Engineer'), (3, 'Sales'); CREATE TABLE employees (id INT, name VARCHAR(255), job_category_id INT); INSERT INTO employees (id, name, job_category_id) VALUES (1, 'Jane Doe', 1), (2, 'Alice Smith', 2)... | What is the total number of employees by job category? | SELECT job_categories.name, COUNT(employees.id) as total FROM job_categories JOIN employees ON job_categories.id = employees.job_category_id GROUP BY job_categories.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE case_data(case_id INT, region VARCHAR(10), case_type VARCHAR(10), case_status VARCHAR(10)); INSERT INTO case_data(case_id, region, case_type, case_status) VALUES (101, 'East', 'civil', 'open'), (102, 'West', 'criminal', 'closed'), (103, 'West', 'civil', 'open'), (104, 'East', 'divorce', 'closed'), (105, 'W... | List all unique case types in the 'West' region with a count of cases for each type. | SELECT case_type, COUNT(*) FROM case_data WHERE region = 'West' GROUP BY case_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE VolunteerHours (HourID INT, VolunteerID INT, EventID INT, Hours INT, HourDate DATE); INSERT INTO VolunteerHours (HourID, VolunteerID, EventID, Hours, HourDate) VALUES (1, 1, 1, 5, '2022-01-01'), (2, 2, 1, 6, '2022-01-01'); | What is the maximum volunteer hours recorded in a single day? | SELECT MAX(Hours) FROM VolunteerHours WHERE VolunteerHours.HourDate = (SELECT MAX(HourDate) FROM VolunteerHours); | gretelai_synthetic_text_to_sql |
CREATE TABLE funding_records (id INT PRIMARY KEY, startup_id INT, amount DECIMAL(10, 2), funding_date DATE); | List startups that received funding in January 2018 | SELECT startup_id FROM funding_records WHERE funding_date BETWEEN '2018-01-01' AND '2018-01-31' GROUP BY startup_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE trend_forecasting(id INT PRIMARY KEY, region VARCHAR(50), product_category VARCHAR(50), forecast_date DATE, forecast_units INT); | Delete records from the trend_forecasting table that are older than 6 months. | DELETE FROM trend_forecasting WHERE forecast_date < DATE_SUB(CURDATE(), INTERVAL 6 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE Neighborhoods (NeighborhoodID INT, NeighborhoodName VARCHAR(255)); CREATE TABLE Properties (PropertyID INT, NeighborhoodID INT, Size INT, Sustainable BOOLEAN); | Find the number of sustainable properties in each neighborhood, ordered from lowest to highest. | SELECT NeighborhoodName, COUNT(*) AS SustainablePropertiesCount FROM Properties JOIN Neighborhoods ON Properties.NeighborhoodID = Neighborhoods.NeighborhoodID WHERE Sustainable = 1 GROUP BY NeighborhoodName ORDER BY SustainablePropertiesCount ASC; | gretelai_synthetic_text_to_sql |
CREATE TABLE healthcare_providers (provider_id INT, name TEXT, state TEXT); INSERT INTO healthcare_providers (provider_id, name, state) VALUES (1, 'Ms. Jessica Thompson', 'NY'), (2, 'Mr. Ryan Adams', 'NY'); CREATE TABLE mental_health_parity (provider_id INT, score INT); | Determine if there are healthcare providers with no mental health parity scores. | SELECT h.name FROM healthcare_providers h LEFT JOIN mental_health_parity m ON h.provider_id = m.provider_id WHERE m.score IS NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE programs (id INT PRIMARY KEY, program_name VARCHAR(255), region_id INT, is_financial_wellbeing BOOLEAN); CREATE TABLE regions (id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255)); CREATE VIEW program_views AS SELECT programs.id, programs.program_name, programs.region_id, programs.is_financial_well... | Count the number of financial wellbeing programs in Asia by region. | SELECT regions.country AS region, COUNT(programs.id) AS num_of_programs FROM program_views INNER JOIN regions ON program_views.region_id = regions.id WHERE program_views.is_financial_wellbeing = TRUE GROUP BY regions.country; | gretelai_synthetic_text_to_sql |
CREATE TABLE ytterbium_mines (mine_name VARCHAR(50), country VARCHAR(20)); INSERT INTO ytterbium_mines (mine_name, country) VALUES ('Y1 Mine', 'USA'), ('Y2 Mine', 'Canada'), ('Y3 Mine', 'Mexico'); | What are the names and locations of all Ytterbium mines in North America? | SELECT mine_name, country FROM ytterbium_mines WHERE country IN ('USA', 'Canada', 'Mexico'); | gretelai_synthetic_text_to_sql |
CREATE TABLE movie (id INT, title VARCHAR(100), genre VARCHAR(20), production_budget INT, release_year INT, IMDb_rating DECIMAL(3,1)); INSERT INTO movie (id, title, genre, production_budget, release_year, IMDb_rating) VALUES (1, 'Die Hard', 'Action', 200000000, 1988, 7.2); | What's the average production budget for action movies released between 2000 and 2010, and their respective IMDb ratings? | SELECT AVG(production_budget), AVG(IMDb_rating) FROM movie WHERE genre = 'Action' AND release_year BETWEEN 2000 AND 2010; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotels (id INT, name TEXT, country TEXT, revenue FLOAT, virtual_tours BOOLEAN); | What is the average revenue of hotels in the US that offer virtual tours? | SELECT AVG(revenue) FROM hotels WHERE country = 'United States' AND virtual_tours = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE tennis_matches (id INT, player1 VARCHAR(50), player2 VARCHAR(50), location VARCHAR(50), date DATE, time_taken INT); INSERT INTO tennis_matches (id, player1, player2, location, date, time_taken) VALUES (1, 'Novak Djokovic', 'Rafael Nadal', 'Melbourne', '2022-01-15', 240); INSERT INTO tennis_matches (id, pla... | What is the average time taken for a tennis match to finish in the 'tennis_matches' table? | SELECT AVG(time_taken) FROM tennis_matches; | gretelai_synthetic_text_to_sql |
CREATE TABLE product_sales (sale_id INT, product_id INT, revenue DECIMAL(10,2), carbon_footprint INT); INSERT INTO product_sales VALUES (1, 1, 100.00, 50), (2, 1, 200.00, 50), (3, 2, 300.00, 70), (4, 2, 400.00, 70), (5, 3, 500.00, 80), (6, 3, 600.00, 80); | Find the top 5 products with the highest revenue and the lowest carbon footprint, and their corresponding revenues and carbon footprints. | SELECT product_id, SUM(revenue) as total_revenue, MIN(carbon_footprint) as min_carbon_footprint FROM product_sales GROUP BY product_id ORDER BY total_revenue DESC, min_carbon_footprint ASC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE ArtistGenre (ArtistID INT, Genre VARCHAR(20), Revenue FLOAT); INSERT INTO ArtistGenre (ArtistID, Genre, Revenue) VALUES (1, 'Pop', '2500000'), (2, 'Rock', '4000000'), (3, 'Jazz', '3000000'), (4, 'Hip Hop', '6500000'); | List the music genres that have more than 3000000 in revenue and the number of artists associated with those genres. | SELECT Genre, SUM(Revenue), COUNT(DISTINCT ArtistID) FROM ArtistGenre WHERE Revenue > 3000000 GROUP BY Genre; | gretelai_synthetic_text_to_sql |
CREATE TABLE patients_therapy (patient_id INT, therapy_attended CHAR(1), region VARCHAR(20)); INSERT INTO patients_therapy (patient_id, therapy_attended, region) VALUES (1, 'Y', 'Asia'), (2, 'Y', 'Europe'), (3, 'Y', 'America'), (4, 'N', 'Asia'); | Number of unique patients who attended therapy sessions per region? | SELECT region, COUNT(DISTINCT patient_id) as unique_patients_attended FROM patients_therapy WHERE therapy_attended = 'Y' GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE auto_show_information (show_id INT, show_name VARCHAR(50), show_date DATE, show_location VARCHAR(50)); | Add a new record for an auto show with a specific date and location to the auto_show_information table. | INSERT INTO auto_show_information (show_id, show_name, show_date, show_location) VALUES (456, 'New York Auto Show', '2023-04-14', 'New York City'); | gretelai_synthetic_text_to_sql |
CREATE TABLE vulnerabilities (vulnerability_id INT PRIMARY KEY, vulnerability_name VARCHAR(100), department VARCHAR(50)); INSERT INTO vulnerabilities (vulnerability_id, vulnerability_name, department) VALUES (1, 'Cross-site scripting', 'Network'), (2, 'SQL injection', 'Network'), (3, 'Buffer overflow', 'Network'), (4, ... | What are the top 5 most common vulnerabilities found in the 'Network' department? | SELECT vulnerability_name, COUNT(*) FROM vulnerabilities WHERE department = 'Network' GROUP BY vulnerability_name ORDER BY COUNT(*) DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE Cosmetics (product_id INT, product_name VARCHAR(100), rating FLOAT, country_of_origin VARCHAR(50)); INSERT INTO Cosmetics (product_id, product_name, rating, country_of_origin) VALUES (1, 'Lipstick A', 4.2, 'USA'), (2, 'Lipstick B', 3.9, 'France'), (3, 'Lipstick C', 4.5, 'USA'); | What is the average rating of lipsticks produced in the USA? | SELECT AVG(rating) as avg_rating FROM Cosmetics WHERE country_of_origin = 'USA' AND product_name LIKE '%lipstick%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Museums_Artists (museum VARCHAR(30), artist VARCHAR(30), country VARCHAR(20)); INSERT INTO Museums_Artists (museum, artist, country) VALUES ('Tokyo Museum', 'Hokusai', 'Japanese'), ('Tokyo Museum', 'Yayoi', 'Japanese'), ('Tokyo Museum', 'Van Gogh', 'Dutch'), ('Tokyo Gallery', 'Monet', 'French'), ('Tokyo Ga... | What are the top 2 countries with the most artists represented in museums in Tokyo? | SELECT country, COUNT(*) as count FROM Museums_Artists WHERE museum = 'Tokyo Museum' OR museum = 'Tokyo Gallery' GROUP BY country ORDER BY count DESC LIMIT 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE program_donations (id INT, program TEXT, donation_date DATE, donation_amount DECIMAL); INSERT INTO program_donations (id, program, donation_date, donation_amount) VALUES (1, 'Education', '2021-12-31', 1200.00); INSERT INTO program_donations (id, program, donation_date, donation_amount) VALUES (2, 'Healthca... | What is the total donation amount for each program in '2021'? | SELECT program, SUM(donation_amount) FROM program_donations WHERE YEAR(donation_date) = 2021 GROUP BY program; | gretelai_synthetic_text_to_sql |
CREATE TABLE Distributors (DistributorID varchar(10), DistributorName varchar(20)); INSERT INTO Distributors VALUES ('C', 'Distributor C'); CREATE TABLE Deliveries (DeliveryID int, DeliveryDate date, ProduceID varchar(10), StoreID int, DistributorID varchar(10), Weight int); INSERT INTO Deliveries VALUES (1, '2022-01-0... | What is the total weight of all products delivered by distributor C after 2022-01-01? | SELECT SUM(Weight) FROM Deliveries WHERE DistributorID = 'C' AND DeliveryDate > '2022-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE suppliers (id INT, name VARCHAR(50), country VARCHAR(50)); CREATE TABLE deliveries (id INT, supplier_id INT, delivery_date DATE, delivery_status VARCHAR(50)); | Identify which suppliers have had deliveries delayed by more than a week in the last month, and the number of times this has occurred. | SELECT suppliers.name, COUNT(*) AS delivery_delays FROM suppliers JOIN deliveries ON suppliers.id = deliveries.supplier_id WHERE deliveries.delivery_date < DATE(NOW()) - INTERVAL 1 MONTH AND deliveries.delivery_status = 'Delayed' GROUP BY suppliers.name HAVING delivery_delays > 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_protected_areas (id INT, name VARCHAR(255), coral_reefs INT, seagrasses INT); INSERT INTO marine_protected_areas (id, name, coral_reefs, seagrasses) VALUES (1, 'Galapagos', 5, 3); | What is the ratio of coral reefs to seagrasses in marine protected areas? | SELECT (SUM(coral_reefs) * 1.0 / SUM(seagrasses)) FROM marine_protected_areas | gretelai_synthetic_text_to_sql |
CREATE TABLE dubai_buses(id INT, bus_number INT, line VARCHAR(20), autonomous BOOLEAN); | What is the percentage of autonomous buses in the Dubai public transportation system? | SELECT 100.0 * COUNT(*) / (SELECT COUNT(*) FROM dubai_buses) AS percentage FROM dubai_buses WHERE autonomous = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE Bridges (ID INT, Name VARCHAR(50), Location VARCHAR(50), DateAdded DATE); INSERT INTO Bridges (ID, Name, Location, DateAdded) VALUES (1, 'Golden Gate Bridge', 'San Francisco, CA', '1937-05-27'); INSERT INTO Bridges (ID, Name, Location, DateAdded) VALUES (2, 'George Washington Bridge', 'New York, NY', '1931... | What is the total number of bridges in the 'Bridges' table built before 2000? | SELECT COUNT(*) FROM Bridges WHERE DateAdded < '2000-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (user_id INT, age INT, gender VARCHAR(10)); INSERT INTO users (user_id, age, gender) VALUES (1, 25, 'Female'), (2, 35, 'Male'), (3, 22, 'Female'); CREATE TABLE post_likes (like_id INT, user_id INT, post_id INT, category VARCHAR(20)); INSERT INTO post_likes (like_id, user_id, post_id, category) VALUES... | What is the average age of users who liked post 12345 in the music category? | SELECT AVG(users.age) FROM users INNER JOIN post_likes ON users.user_id = post_likes.user_id WHERE post_likes.post_id = 12345 AND post_likes.category = 'music'; | gretelai_synthetic_text_to_sql |
CREATE TABLE AircraftIncidents (IncidentID INT, ManufacturerID INT, IncidentType VARCHAR(50));CREATE TABLE AircraftManufacturers (ManufacturerID INT, ManufacturerName VARCHAR(50)); | How many aircraft incidents occurred by incident type and manufacturer? | SELECT IncidentType, ManufacturerName, COUNT(*) AS IncidentCount FROM AircraftIncidents AI INNER JOIN AircraftManufacturers AM ON AI.ManufacturerID = AM.ManufacturerID GROUP BY IncidentType, ManufacturerName; | gretelai_synthetic_text_to_sql |
CREATE TABLE trains (id INT, route_id INT, clean_date DATE); INSERT INTO trains (id, route_id, clean_date) VALUES (1, 101, '2022-01-01'), (2, 102, '2022-01-02'), (3, 103, '2022-01-03'); | What is the average time between train cleanings for each route in the city of Tokyo? | SELECT route_id, AVG(DATEDIFF('day', LAG(clean_date) OVER (PARTITION BY route_id ORDER BY clean_date), clean_date)) FROM trains WHERE city = 'Tokyo' GROUP BY route_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE WasteMaterial (SiteID INT, Date DATE, Material VARCHAR(255), Weight INT); INSERT INTO WasteMaterial (SiteID, Date, Material, Weight) VALUES (1, '2021-01-01', 'Rock', 500), (1, '2021-02-01', 'Soil', 300), (1, '2021-03-01', 'Rock', 400), (1, '2021-04-01', 'Soil', 200), (1, '2021-05-01', 'Rock', 600), (1, '20... | Rank the mining sites by the percentage of waste material reused in the past year. | SELECT SiteID, SUM(CASE WHEN Material = 'Rock' THEN Weight ELSE 0 END) / SUM(Weight) OVER (PARTITION BY SiteID) as Percentage_Reused FROM WasteMaterial WHERE Date >= DATEADD(YEAR, -1, GETDATE()) GROUP BY SiteID, Material, Date; | gretelai_synthetic_text_to_sql |
CREATE TABLE co2_emissions (initiative_id INT, initiative_name VARCHAR(50), region VARCHAR(50), co2_emissions_reduction DECIMAL(5, 2)); INSERT INTO co2_emissions (initiative_id, initiative_name, region, co2_emissions_reduction) VALUES (1, 'Climate Adaptation Fund', 'Europe', 12.50), (2, 'Green Cities', 'Europe', 15.00)... | Find the average CO2 emissions reduction achieved by climate adaptation initiatives in Europe. | SELECT AVG(co2_emissions_reduction) FROM co2_emissions WHERE region = 'Europe' AND initiative_name IN ('Climate Adaptation Fund', 'Green Cities', 'Resilient Infrastructure'); | gretelai_synthetic_text_to_sql |
CREATE TABLE countries (country_id INT, country TEXT); INSERT INTO countries (country_id, country) VALUES (1, 'India'); CREATE TABLE years (year_id INT, year TEXT); INSERT INTO years (year_id, year) VALUES (1, '2022'); CREATE TABLE tourism (tourist_id INT, country_id INT, year_id INT, site_type TEXT); INSERT INTO touri... | What is the total number of tourists who visited cultural heritage sites in India last year? | SELECT COUNT(*) FROM tourism WHERE country_id = (SELECT country_id FROM countries WHERE country = 'India') AND year_id = (SELECT year_id FROM years WHERE year = '2022') AND site_type = 'cultural_heritage'; | gretelai_synthetic_text_to_sql |
CREATE TABLE emergency_calls (id INT, precinct VARCHAR(20), response_time INT, call_date DATE); INSERT INTO emergency_calls (id, precinct, response_time, call_date) VALUES (1, 'harbor', 15, '2022-01-01'); | Find the daily maximum response time for emergency calls in the 'harbor' precinct in January 2022. | SELECT precinct, call_date, MAX(response_time) FROM emergency_calls WHERE precinct = 'harbor' AND call_date BETWEEN '2022-01-01' AND '2022-01-31' GROUP BY precinct, call_date; | gretelai_synthetic_text_to_sql |
CREATE TABLE Freight (id INT, warehouse_id INT, forward_date DATE, volume FLOAT); INSERT INTO Freight (id, warehouse_id, forward_date, volume) VALUES (1, 4, '2022-03-15', 150.2), (2, 4, '2022-03-27', 120.8), (3, 5, '2022-03-04', 180.5); CREATE TABLE Warehouses (id INT, name TEXT, city TEXT, state TEXT); INSERT INTO War... | What is the total volume of freight forwarded from the Tokyo warehouse in March 2022? | SELECT SUM(volume) FROM Freight JOIN Warehouses ON Freight.warehouse_id = Warehouses.id WHERE Warehouses.name = 'Tokyo Warehouse' AND EXTRACT(MONTH FROM forward_date) = 3 AND EXTRACT(YEAR FROM forward_date) = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE aircraft (id INT PRIMARY KEY, model VARCHAR(50), engine VARCHAR(50)); | Insert a new aircraft model 'A380' with engine 'Engine Alliance GP7200' | INSERT INTO aircraft (id, model, engine) VALUES (106, 'A380', 'Engine Alliance GP7200'); | gretelai_synthetic_text_to_sql |
CREATE TABLE infrastructure_projects (id INT, project_name VARCHAR(50), location VARCHAR(50), total_cost INT); INSERT INTO infrastructure_projects (id, project_name, location, total_cost) VALUES (1, 'Road Widening', 'City A', 500000), (2, 'Coastal Protection', 'City B', 700000); | What is the 'total_cost' for the project with the name 'Coastal Protection'? | SELECT total_cost FROM infrastructure_projects WHERE project_name = 'Coastal Protection'; | gretelai_synthetic_text_to_sql |
CREATE TABLE projects(id INT, project_name VARCHAR(50), project_type VARCHAR(50), country VARCHAR(50));CREATE TABLE project_capacity(project_id INT, capacity_mw FLOAT); | Which countries have renewable energy projects with a combined capacity of at least 500 MW in the projects and project_capacity tables? | SELECT p.country FROM projects p INNER JOIN project_capacity pc ON p.id = pc.project_id GROUP BY p.country HAVING SUM(pc.capacity_mw) >= 500; | gretelai_synthetic_text_to_sql |
CREATE TABLE Regulation (id INT PRIMARY KEY, name VARCHAR(50), description VARCHAR(50)); CREATE TABLE Vessel_Regulation (vessel_id INT, regulation_id INT, PRIMARY KEY (vessel_id, regulation_id), FOREIGN KEY (vessel_id) REFERENCES Vessel(id), FOREIGN KEY (regulation_id) REFERENCES Regulation(id)); CREATE TABLE Port (id ... | List all regulations for vessels operating in the port of Rotterdam? | SELECT R.name FROM Regulation R JOIN Vessel_Regulation VR ON R.id = VR.regulation_id JOIN Vessel V ON VR.vessel_id = V.id JOIN Port P ON V.port_id = P.id WHERE P.name = 'Rotterdam'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Volunteer_Hours (id INT, program VARCHAR(50), hours DECIMAL(5,2), hour_date DATE); INSERT INTO Volunteer_Hours (id, program, hours, hour_date) VALUES (1, 'Refugee Support', 12.5, '2022-01-03'), (2, 'Food Bank', 17.0, '2022-01-05'), (3, 'Refugee Support', 18.5, '2022-01-10'), (4, 'Food Bank', 20.0, '2022-01... | What was the total number of volunteer hours for each program in Q1 2022? | SELECT program, DATE_FORMAT(hour_date, '%Y-%m') as quarter, SUM(hours) as total_hours FROM Volunteer_Hours WHERE hour_date BETWEEN '2022-01-01' AND '2022-03-31' GROUP BY program, quarter; | gretelai_synthetic_text_to_sql |
CREATE TABLE lending_initiatives (id INT, initiative_type VARCHAR(255), value DECIMAL(10,2)); | Insert a new socially responsible lending initiative. | INSERT INTO lending_initiatives (initiative_type, value) VALUES ('Socially Responsible', 12000.00); | gretelai_synthetic_text_to_sql |
CREATE TABLE non_organic_categories (id INT, category VARCHAR(255), total_value DECIMAL(5,2)); INSERT INTO non_organic_categories (id, category, total_value) VALUES (1, 'Proteins', 199.00), (2, 'Grains', 74.25); | Which menu category has the highest inventory value for non-organic items? | SELECT category, total_value FROM non_organic_categories ORDER BY total_value DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE criminal_cases (case_id INT, case_number VARCHAR(20), case_type VARCHAR(30), court_location VARCHAR(30), processing_date DATE); | What is the total number of criminal cases processed by court location in the 'criminal_cases' table? | CREATE VIEW case_counts AS SELECT court_location, COUNT(*) AS case_count FROM criminal_cases GROUP BY court_location; | gretelai_synthetic_text_to_sql |
CREATE TABLE MilitaryBases (ID INT, BaseName VARCHAR(50), Country VARCHAR(50), Personnel INT); INSERT INTO MilitaryBases (ID, BaseName, Country, Personnel) VALUES (1, 'Base1', 'Europe', 500); INSERT INTO MilitaryBases (ID, BaseName, Country, Personnel) VALUES (2, 'Base2', 'Europe', 700); | What is the average number of military personnel per base in 'Europe'? | SELECT AVG(Personnel) FROM MilitaryBases WHERE Country = 'Europe'; | gretelai_synthetic_text_to_sql |
CREATE TABLE DefenseProjectTimelines (id INT PRIMARY KEY, contractor VARCHAR(50), project_start_date DATE, project_end_date DATE, project_status VARCHAR(50)); INSERT INTO DefenseProjectTimelines (id, contractor, project_start_date, project_end_date, project_status) VALUES (4, 'Thales Group', '2019-01-01', '2021-12-31',... | What is the total number of contracts negotiated by each contractor in the defense project timelines table? | SELECT DefenseProjectTimelines.contractor, COUNT(DefenseProjectTimelines.id) FROM DefenseProjectTimelines GROUP BY DefenseProjectTimelines.contractor; | gretelai_synthetic_text_to_sql |
CREATE TABLE Vehicles (id INT, make VARCHAR(50), model VARCHAR(50), horsepower INT, country VARCHAR(50)); INSERT INTO Vehicles (id, make, model, horsepower, country) VALUES (1, 'Toyota', 'Corolla', 139, 'Japan'); | What is the average horsepower of vehicles manufactured in Japan? | SELECT AVG(horsepower) FROM Vehicles WHERE country = 'Japan'; | gretelai_synthetic_text_to_sql |
CREATE TABLE user_game_activity (user_id INT, game_id INT, played_at TIMESTAMP); INSERT INTO user_game_activity (user_id, game_id, played_at) VALUES (1, 1, '2021-01-01 10:00:00'), (2, 1, '2021-01-02 11:00:00'), (3, 2, '2021-01-03 12:00:00'), (4, 2, '2021-01-04 13:00:00'), (5, 3, '2021-01-05 14:00:00'), (6, 1, '2021-01-... | What is the average number of games played per day by users in the 'gaming' database? | SELECT COUNT(DISTINCT user_id, game_id) as games_played, EXTRACT(DAY FROM played_at) as day FROM user_game_activity GROUP BY day | gretelai_synthetic_text_to_sql |
CREATE TABLE sandwiches (id INT, name VARCHAR(255), qty_sold INT); INSERT INTO sandwiches (id, name, qty_sold) VALUES (1, 'Veggie Wrap', 300), (2, 'Chicken Salad Sandwich', 250), (3, 'Turkey Club', 200); CREATE TABLE date (id INT, date DATE); INSERT INTO date (id, date) VALUES (1, '2022-03-21'), (2, '2022-03-22'), (3, ... | What is the total quantity of 'Veggie Wrap' sold last week? | SELECT SUM(qty_sold) AS total_qty_sold FROM sandwiches WHERE name = 'Veggie Wrap' AND date IN (SELECT date FROM date WHERE date BETWEEN DATE_SUB(NOW(), INTERVAL 1 WEEK) AND NOW()); | gretelai_synthetic_text_to_sql |
CREATE TABLE ratings_animal_testing (id INT, product VARCHAR(255), not_tested_on_animals BOOLEAN, rating FLOAT, country VARCHAR(255)); INSERT INTO ratings_animal_testing (id, product, not_tested_on_animals, rating, country) VALUES (1, 'Shampoo', true, 4.5, 'Australia'), (2, 'Conditioner', false, 3.0, 'Australia'), (3, ... | What is the minimum rating of beauty products that are not tested on animals and were sold in Australia? | SELECT MIN(rating) FROM ratings_animal_testing WHERE not_tested_on_animals = true AND country = 'Australia'; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists genetics;CREATE TABLE if not exists genetics.experiments (id INT, experiment_name VARCHAR(255), temperature_delta INT); INSERT INTO genetics.experiments (id, experiment_name, temperature_delta) VALUES (1, 'CRISPR-Cas9', 15), (2, 'Gene Editing', 22), (3, 'Genetic Fusion', 18); | Which genetic research experiments resulted in the highest temperature increase? | SELECT experiment_name, temperature_delta FROM (SELECT experiment_name, temperature_delta, RANK() OVER (ORDER BY temperature_delta DESC) AS rank FROM genetics.experiments) ranked_experiments WHERE rank = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Sites (SiteID INT, SiteName VARCHAR(50), PublicOutreachDate DATE); INSERT INTO Sites (SiteID, SiteName, PublicOutreachDate) VALUES (1, 'Site A', '2011-05-01'), (2, 'Site B', '2009-03-15'), (3, 'Site C', '2013-07-22'); | What is the latest public outreach date for each site? | SELECT SiteName, MAX(PublicOutreachDate) OVER (PARTITION BY SiteID) AS LatestPublicOutreachDate FROM Sites; | gretelai_synthetic_text_to_sql |
CREATE TABLE orders (order_id INT, order_date DATE, product_category VARCHAR(50), revenue FLOAT); INSERT INTO orders (order_id, order_date, product_category, revenue) VALUES (1, '2022-01-01', 'Clothing', 25.5), (2, '2022-01-02', 'Electronics', 30), (3, '2022-01-03', 'Furniture', 15); | What is the total revenue for each product category in 2022? | SELECT product_category, SUM(revenue) FROM orders WHERE EXTRACT(YEAR FROM order_date) = 2022 GROUP BY product_category; | gretelai_synthetic_text_to_sql |
CREATE TABLE shared_scooters (company VARCHAR(20), date DATE, num_scooters INT); INSERT INTO shared_scooters (company, date, num_scooters) VALUES ('Company A', '2022-01-01', 500), ('Company A', '2022-01-02', 550), ('Company B', '2022-01-01', 400), ('Company B', '2022-01-02', 450); | What is the maximum number of shared scooters available in a single day for each company in the shared_scooters table? | SELECT company, MAX(num_scooters) FROM shared_scooters GROUP BY company; | gretelai_synthetic_text_to_sql |
CREATE TABLE members (id INT, country VARCHAR(50)); INSERT INTO members (id, country) VALUES (1, 'Germany'); CREATE TABLE workouts (id INT, member_id INT, date DATE, duration INT); INSERT INTO workouts (id, member_id, date, duration) VALUES (1, 1, '2022-01-01', 30); | What is the total workout duration per member from Germany in 2022, grouped by month? | SELECT DATE_TRUNC('month', workouts.date) AS month, members.id, SUM(duration) AS total_duration FROM members JOIN workouts ON members.id = workouts.member_id WHERE members.country = 'Germany' AND YEAR(workouts.date) = 2022 GROUP BY month, members.id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Dates (id INT PRIMARY KEY, date DATE); INSERT INTO Dates (id, date) VALUES (1, '2022-01-01'), (2, '2022-02-01'), (3, '2022-03-01'); CREATE TABLE Articles (id INT PRIMARY KEY, title TEXT, language_id INT, date_id INT, FOREIGN KEY (language_id) REFERENCES Languages(id), FOREIGN KEY (date_id) REFERENCES Dates... | What is the total number of articles published per month in a specific language, grouped by day? | SELECT l.language, DATE_FORMAT(d.date, '%Y-%m-%d') as date, COUNT(a.id) as num_articles FROM Articles a JOIN Languages l ON a.language_id = l.id JOIN Dates d ON a.date_id = d.id GROUP BY l.language, date; | gretelai_synthetic_text_to_sql |
CREATE TABLE Volunteers (VolunteerID INT, Name TEXT, Hours FLOAT); INSERT INTO Volunteers (VolunteerID, Name, Hours) VALUES (1, 'Alice', 7.0), (2, 'Bob', 4.0), (3, 'Charlie', 6.0); | Insert a new record for a volunteer with ID 4 who served 8 hours. | INSERT INTO Volunteers (VolunteerID, Hours) VALUES (4, 8.0); | gretelai_synthetic_text_to_sql |
CREATE TABLE Arctic_Research_Station_2 (id INT, species TEXT, population INT); CREATE TABLE Arctic_Research_Station_3 (id INT, species TEXT, population INT); | What is the total number of polar bears in the Arctic Research Station 2 and 3? | SELECT SUM(population) FROM Arctic_Research_Station_2 WHERE species = 'Polar Bear'; SELECT SUM(population) FROM Arctic_Research_Station_3 WHERE species = 'Polar Bear'; SELECT SUM(population) FROM (SELECT * FROM Arctic_Research_Station_2 WHERE species = 'Polar Bear' UNION ALL SELECT * FROM Arctic_Research_Station_3 WHER... | gretelai_synthetic_text_to_sql |
CREATE TABLE GraduateStudents(Id INT, Name VARCHAR(100), Program VARCHAR(50), Publications INT); INSERT INTO GraduateStudents(Id, Name, Program, Publications) VALUES (1, 'Charlie', 'Physics', 3), (2, 'David', 'Mathematics', 10); | How many graduate students are enrolled in STEM programs who have published more than 5 papers? | SELECT COUNT(*) FROM GraduateStudents WHERE Program LIKE 'STEM%' HAVING Publications > 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE sectors (sector_id INT, sector_name VARCHAR(20)); CREATE TABLE investments (investment_id INT, investor_id INT, sector_id INT, investment_amount FLOAT); | What's the maximum investment amount made in the 'renewable energy' sector? | SELECT MAX(i.investment_amount) FROM investments i INNER JOIN sectors s ON i.sector_id = s.sector_id WHERE s.sector_name = 'renewable energy'; | gretelai_synthetic_text_to_sql |
CREATE TABLE mine_workforce (mine_id INT, mine_name TEXT, location TEXT, num_employees INT); INSERT INTO mine_workforce (mine_id, mine_name, location, num_employees) VALUES (1, 'Emerald Enterprise', 'Wyoming, USA', 500), (2, 'Ruby Republic', 'Montana, USA', 450), (3, 'Sapphire Syndicate', 'Idaho, USA', 400), (4, 'Garne... | Show the number of employees for each mine, grouped by the mine's location. | SELECT location, SUM(num_employees) as total_employees FROM mine_workforce GROUP BY location; | gretelai_synthetic_text_to_sql |
CREATE TABLE renewable_projects (project_id INT, project_name VARCHAR(100), project_type VARCHAR(50), installed_capacity FLOAT); INSERT INTO renewable_projects (project_id, project_name, project_type, installed_capacity) VALUES (1, 'Wind Farm A', 'Wind', 50.0), (2, 'Solar Farm B', 'Solar', 75.0); | What is the total installed capacity (in MW) for all wind projects in the 'renewable_projects' table? | SELECT SUM(installed_capacity) FROM renewable_projects WHERE project_type = 'Wind'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ai_model (id INT, name VARCHAR, type VARCHAR, domain VARCHAR, accuracy FLOAT); INSERT INTO ai_model (id, name, type, domain, accuracy) VALUES (7, 'ModelG', 'Reinforcement', 'Fairness', 0.91); INSERT INTO ai_model (id, name, type, domain, accuracy) VALUES (8, 'ModelH', 'Semi-supervised', 'Safety', 0.98); | What is the total number of models in each type? | SELECT type, COUNT(*) as total FROM ai_model GROUP BY type; | gretelai_synthetic_text_to_sql |
CREATE TABLE vessels_port_visits (vessel_id INT, port_id INT, visit_date DATE); INSERT INTO vessels_port_visits VALUES (1, 1, '2022-01-01'), (1, 2, '2022-01-02'), (2, 3, '2022-01-03'); CREATE TABLE ports_region (port_id INT, region TEXT); INSERT INTO ports_region VALUES (1, 'Asia Pacific'), (2, 'Americas'), (3, 'Europe... | What are the names of vessels that have not visited any ports in the European region? | SELECT vessels.vessel_name FROM vessels WHERE vessels.vessel_id NOT IN (SELECT vessels_port_visits.vessel_id FROM vessels_port_visits INNER JOIN ports_region ON vessels_port_visits.port_id = ports_region.port_id WHERE ports_region.region = 'Europe'); | gretelai_synthetic_text_to_sql |
CREATE TABLE mine_sites (id INT, country VARCHAR(255), mineral VARCHAR(255), quantity INT); INSERT INTO mine_sites (id, country, mineral, quantity) VALUES (1, 'Canada', 'Gold', 500), (2, 'Mexico', 'Gold', 700), (3, 'Australia', 'Gold', 1200); | What is the total quantity of gold extracted per country? | SELECT country, SUM(quantity) as total_gold_extracted FROM mine_sites WHERE mineral = 'Gold' GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE genetic_data (id INT, sample_id VARCHAR(20), gene_sequence TEXT); CREATE TABLE startup_funding (id INT, sample_id VARCHAR(20), funding_amount FLOAT); INSERT INTO genetic_data (id, sample_id, gene_sequence) VALUES (1, 'GD001', 'ATGCGA...'), (2, 'GD002', 'ATGCGC...'); INSERT INTO startup_funding (id, sample_... | What is the genetic sequence of samples with startup funding over 500000? | SELECT gd.gene_sequence FROM genetic_data gd INNER JOIN startup_funding sf ON gd.sample_id = sf.sample_id WHERE sf.funding_amount > 500000; | gretelai_synthetic_text_to_sql |
CREATE TABLE city (id INT, name VARCHAR(255)); INSERT INTO city (id, name) VALUES (1, 'CityA'), (2, 'CityB'); CREATE TABLE property (id INT, co_ownership_price DECIMAL(10,2), city_id INT, category VARCHAR(255)); INSERT INTO property (id, co_ownership_price, city_id, category) VALUES (1, 500000, 1, 'sustainable urbanism... | What is the average co-ownership price for sustainable urbanism properties in CityA? | SELECT AVG(p.co_ownership_price) AS avg_price FROM property p WHERE p.city_id = 1 AND p.category = 'sustainable urbanism'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Trains (id INT, type VARCHAR(255), wheelchair_accessible BOOLEAN); | List the train types with wheelchair accessibility. | SELECT type FROM Trains WHERE wheelchair_accessible = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE inventory (ingredient VARCHAR(255), quantity INT, unit_price DECIMAL(10,2)); INSERT INTO inventory VALUES ('Garlic', 500, 0.5); INSERT INTO inventory VALUES ('Tomatoes', 2000, 1.0); | What is the total inventory value for each ingredient? | SELECT ingredient, SUM(quantity * unit_price) AS total_inventory_value FROM inventory GROUP BY ingredient; | gretelai_synthetic_text_to_sql |
CREATE TABLE approvals (drug_name TEXT, approval_date DATE); INSERT INTO approvals (drug_name, approval_date) VALUES ('DrugI', '2015-07-01'); INSERT INTO approvals (drug_name, approval_date) VALUES ('DrugJ', '2016-03-30'); | Which drugs were approved between Q2 2015 and Q1 2016? | SELECT drug_name FROM approvals WHERE EXTRACT(QUARTER FROM approval_date) BETWEEN 2 AND 1 AND EXTRACT(YEAR FROM approval_date) BETWEEN 2015 AND 2016; | gretelai_synthetic_text_to_sql |
CREATE TABLE articles (id INT, title TEXT, content TEXT, publication_date DATE, newspaper TEXT); CREATE TABLE words (id INT, article_id INT, word TEXT); | What is the most common word in the titles of articles published by "The New Yorker" in 2021? | SELECT word, COUNT(*) AS word_count FROM words w INNER JOIN articles a ON w.article_id = a.id WHERE a.newspaper = 'The New Yorker' AND a.publication_date BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY word ORDER BY word_count DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE offenses_by_practice (practice_id INT, offense_id INT); CREATE TABLE offenses (offense_id INT, offense VARCHAR(255)); | Identify which offenses have no restorative practices associated with them in the 'offenses_by_practice' table? | SELECT offense FROM offenses WHERE offense_id NOT IN (SELECT offense_id FROM offenses_by_practice); | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT, name VARCHAR(50), gender VARCHAR(10), age INT, city VARCHAR(50)); INSERT INTO users (id, name, gender, age, city) VALUES (1, 'David', 'Male', 20, 'New York'); INSERT INTO users (id, name, gender, age, city) VALUES (2, 'Eva', 'Female', 25, 'Los Angeles'); INSERT INTO users (id, name, gender, ... | What is the total number of users by gender? | SELECT gender, COUNT(*) as total_users FROM users GROUP BY gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE smart_contracts (id INT, gas_price DECIMAL(10, 2)); INSERT INTO smart_contracts (id, gas_price) VALUES (1, 20.5), (2, 25.0), (3, 18.7), (4, 30.2), (5, 22.9); | What's the average gas price for smart contracts? | SELECT AVG(gas_price) FROM smart_contracts; | gretelai_synthetic_text_to_sql |
CREATE TABLE Volunteers (VolunteerID int, VolunteerName varchar(50), HoursDonated int, VolunteerYear int); INSERT INTO Volunteers (VolunteerID, VolunteerName, HoursDonated, VolunteerYear) VALUES (1, 'Samantha Green', 30, 2018), (2, 'Taylor White', 20, 2018), (3, 'Uma Black', 15, 2018), (4, 'Victor Red', 25, 2018); | What is the total number of volunteers and total hours donated by them in '2018'? | SELECT COUNT(VolunteerName) as TotalVolunteers, SUM(HoursDonated) as TotalHours FROM Volunteers WHERE VolunteerYear = 2018; | gretelai_synthetic_text_to_sql |
CREATE TABLE exoplanets (id INT, name VARCHAR(255), discovery_mission VARCHAR(255), discovery_date DATE); INSERT INTO exoplanets (id, name, discovery_mission, discovery_date) VALUES (1, 'K2-18b', 'K2', '2015-05-01'); INSERT INTO exoplanets (id, name, discovery_mission, discovery_date) VALUES (2, 'PLATO-1b', 'PLATO', '2... | Find the number of exoplanet discoveries made by the K2 and PLATO missions. | SELECT COUNT(*) as num_discoveries FROM exoplanets e INNER JOIN k2_exoplanets k ON e.id = k.id INNER JOIN plato_exoplanets p ON e.id = p.id; | gretelai_synthetic_text_to_sql |
CREATE TABLE manufacturing (manufacturing_id INT, manufacturer VARCHAR(50), lead_time INT); | What is the average lead time for each garment manufacturer? | SELECT manufacturer, AVG(lead_time) as avg_lead_time FROM manufacturing GROUP BY manufacturer; | gretelai_synthetic_text_to_sql |
CREATE TABLE startups(id INT, name TEXT, industry TEXT, total_funding FLOAT); INSERT INTO startups VALUES(1, 'StartupA', 'Healthcare', 15000000); INSERT INTO startups VALUES(2, 'StartupB', 'Tech', 20000000); INSERT INTO startups VALUES(3, 'StartupC', 'Healthcare', 12000000); INSERT INTO startups VALUES(4, 'StartupD', '... | What is the total funding received by startups founded by women in the Healthcare sector? | SELECT SUM(total_funding) FROM startups WHERE industry = 'Healthcare' AND founder = 'Woman'; | gretelai_synthetic_text_to_sql |
CREATE TABLE menu (id INT, category VARCHAR(255), item VARCHAR(255)); INSERT INTO menu (id, category, item) VALUES (1, 'breakfast', 'Pancakes'), (2, 'breakfast', 'Tofu Scramble'), (3, 'lunch', 'Quinoa Salad'); | Delete 'Tofu Scramble' from the breakfast menu. | DELETE FROM menu WHERE category = 'breakfast' AND item = 'Tofu Scramble'; | gretelai_synthetic_text_to_sql |
CREATE TABLE drought_impact (id INT PRIMARY KEY, region VARCHAR(50), drought_duration INT); | Show drought duration by region | SELECT region, drought_duration FROM drought_impact; | gretelai_synthetic_text_to_sql |
CREATE TABLE Public_Services( service_id INT PRIMARY KEY, service_name VARCHAR(255), location VARCHAR(255), budget FLOAT, created_date DATE); INSERT INTO Public_Services (service_id, service_name, location, budget, created_date) VALUES (1, 'Road Maintenance', 'NYC', 5000000.00, '2022-01-01'), (2, 'Waste Management', '... | Find all records where the budget allocated for a public service is greater than 6000000 | SELECT * FROM Public_Services WHERE budget > 6000000; | gretelai_synthetic_text_to_sql |
CREATE TABLE Investments (id INT, company_id INT, investment_amount INT, investment_date DATE); INSERT INTO Investments (id, company_id, investment_amount, investment_date) VALUES (1, 1, 1000000, '2022-01-01'); INSERT INTO Investments (id, company_id, investment_amount, investment_date) VALUES (2, 2, 2000000, '2022-02-... | Delete an investment from the Investments table. | DELETE FROM Investments WHERE id = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE farmers (id SERIAL PRIMARY KEY, name TEXT, region TEXT, annual_income INT); INSERT INTO farmers (name, region, annual_income) VALUES ('John', 'North America', 40000), ('Jane', 'Asia', 50000), ('Bob', 'Europe', 60000); | Update the annual income of the farmer with id 1 in the "farmers" table | UPDATE farmers SET annual_income = 45000 WHERE id = 1; | 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.