context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE Art (ArtID INT, ArtistID INT, ArtCategory VARCHAR(50)); INSERT INTO Art (ArtID, ArtistID, ArtCategory) VALUES (1, 1, 'Oil'), (2, 1, 'Watercolor'), (3, 2, 'Bronze'), (4, 2, 'Marble'), (5, 3, 'Oil'), (6, 3, 'Watercolor'), (7, 4, 'Bronze'), (8, 4, 'Marble'), (9, 5, 'Oil'), (10, 5, 'Bronze'), (11, 6, 'Watercol... | Who are the artists that created artworks in more than one category? | SELECT ArtistID, ArtCategory FROM (SELECT ArtistID, ArtCategory, COUNT(*) OVER (PARTITION BY ArtistID) as ArtworksPerArtist, ROW_NUMBER() OVER (PARTITION BY ArtistID ORDER BY ArtCategory) as RowNum FROM Art) AS Subquery WHERE ArtworksPerArtist > 1 AND RowNum = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE menu (menu_id INT, name VARCHAR(50), category VARCHAR(50), ingredients TEXT); INSERT INTO menu (menu_id, name, category, ingredients) VALUES (1, 'Chicken Alfredo', 'Entree', 'Chicken, Pasta, Cream, Garlic'), (2, 'Chicken Parmesan', 'Entree', 'Chicken, Tomato Sauce, Cheese, Bread Crumbs'), (3, 'Vegetable St... | What is the total quantity of dishes sold in the 'Entree' category that contain chicken? | SELECT SUM(orders.quantity) FROM orders JOIN menu ON orders.menu_id = menu.menu_id WHERE menu.category = 'Entree' AND menu.ingredients LIKE '%Chicken%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE vessels (id INT, name TEXT, region TEXT, cargo_weight INT); INSERT INTO vessels (id, name, region, cargo_weight) VALUES (1, 'VesselA', 'Red Sea', 30000); INSERT INTO vessels (id, name, region, cargo_weight) VALUES (2, 'VesselB', 'Red Sea', 35000); INSERT INTO vessels (id, name, region, cargo_weight) VALUES... | How many vessels are there in the 'Red Sea', and what is their total cargo weight? | SELECT COUNT(*), SUM(cargo_weight) FROM vessels WHERE region = 'Red Sea' | gretelai_synthetic_text_to_sql |
CREATE TABLE Exhibitions (id INT, city VARCHAR(50), year INT, visitor_age INT); INSERT INTO Exhibitions (id, city, year, visitor_age) VALUES (1, 'Paris', 2021, 32); | What is the average age of visitors who attended exhibitions in Paris in 2021? | SELECT AVG(visitor_age) FROM Exhibitions WHERE city = 'Paris' AND year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE artists (id INT, name TEXT, birthyear INT); INSERT INTO artists (id, name, birthyear) VALUES (1, 'Artist A', 1955), (2, 'Artist B', 1970), (3, 'Artist C', 1988); | What is the average age of artists in the database? | SELECT AVG(YEAR(CURRENT_DATE) - birthyear) FROM artists; | gretelai_synthetic_text_to_sql |
CREATE TABLE atlanta_police_responses (id INT, response_time INT, location VARCHAR(20)); INSERT INTO atlanta_police_responses (id, response_time, location) VALUES (1, 150, 'Atlanta'), (2, 120, 'Atlanta'); | What is the average response time for police stations in Atlanta? | SELECT AVG(response_time) FROM atlanta_police_responses WHERE location = 'Atlanta'; | gretelai_synthetic_text_to_sql |
CREATE TABLE orders (customer_id INT, order_date DATE, size VARCHAR(10), quantity INT); INSERT INTO orders (customer_id, order_date, size, quantity) VALUES (1, '2022-01-01', 'large', 100), (2, '2022-01-02', 'large', 200), (3, '2022-01-03', 'medium', 150), (4, '2022-01-04', 'large', 120), (4, '2022-01-05', 'large', 130)... | What is the total quantity of orders in the 'large' size category for each customer? | SELECT customer_id, SUM(quantity) as total_quantity FROM orders WHERE size = 'large' GROUP BY customer_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE concerts (id INT, artist VARCHAR(255), city VARCHAR(255), revenue FLOAT); INSERT INTO concerts (id, artist, city, revenue) VALUES (1, 'Taylor Swift', 'Los Angeles', 500000.00); | What is the total revenue generated from concert ticket sales in the city of 'Los Angeles'? | SELECT SUM(revenue) FROM concerts WHERE city = 'Los Angeles'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Activities (id INT, user_id INT, minutes INT, activity TEXT); INSERT INTO Activities (id, user_id, minutes, activity) VALUES (1, 1, 60, 'yoga'), (2, 2, 90, 'meditation'); | What is the total number of minutes spent doing a specific activity? | SELECT SUM(minutes) FROM Activities WHERE activity = 'yoga'; | gretelai_synthetic_text_to_sql |
CREATE TABLE tourists (id INT, country VARCHAR(50), visitors INT, year INT); INSERT INTO tourists (id, country, visitors, year) VALUES (1, 'France', 4500, 2019), (2, 'Spain', 3200, 2019); | How many more tourists visited France than Spain in 2019? | SELECT t1.visitors - t2.visitors FROM tourists t1 INNER JOIN tourists t2 ON t1.year = t2.year WHERE t1.country = 'France' AND t2.country = 'Spain'; | gretelai_synthetic_text_to_sql |
CREATE TABLE legal_aid_clients (client_id INT, identifies_as_lgbtq BOOLEAN, city VARCHAR(50), state VARCHAR(20)); INSERT INTO legal_aid_clients (client_id, identifies_as_lgbtq, city, state) VALUES (1, true, 'Chicago', 'Illinois'), (2, false, 'Chicago', 'Illinois'); | What is the percentage of legal aid clients in Chicago who identify as LGBTQ+? | SELECT (SUM(identifies_as_lgbtq) * 100.0 / COUNT(*)) AS percentage FROM legal_aid_clients WHERE city = 'Chicago'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Restaurants (RestaurantID int, RestaurantName varchar(255), Region varchar(255)); CREATE TABLE MenuItems (MenuID int, MenuName varchar(255), RestaurantID int, Sales int); CREATE TABLE AdditionalCharges (ChargeID int, ChargeName varchar(255), RestaurantID int, ChargeAmt int); | What is the total revenue for each region, including the sum of sales for all menu items and additional charges? | SELECT R.Region, SUM(M.Sales + AC.ChargeAmt) as TotalRevenue FROM Restaurants R INNER JOIN MenuItems M ON R.RestaurantID = M.RestaurantID INNER JOIN AdditionalCharges AC ON R.RestaurantID = AC.RestaurantID GROUP BY R.Region; | gretelai_synthetic_text_to_sql |
CREATE TABLE customer (customer_id INT, first_name VARCHAR(255), last_name VARCHAR(255), size INT, last_purchase_date DATE); INSERT INTO customer (customer_id, first_name, last_name, size, last_purchase_date) VALUES (1, 'Avery', 'Smith', 16, '2022-01-15'), (2, 'Bella', 'Johnson', 12, '2022-02-20'), (3, 'Charlie', 'Brow... | How many size 16 customers have made a purchase from our store in the past year? | SELECT COUNT(*) FROM customer WHERE size = 16 AND last_purchase_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR); | gretelai_synthetic_text_to_sql |
CREATE TABLE utilities_projects (project VARCHAR(50), budget INT); INSERT INTO utilities_projects (project, budget) VALUES ('Water Main Replacement', 900000); INSERT INTO utilities_projects (project, budget) VALUES ('Sewer Line Upgrade', 1300000); INSERT INTO utilities_projects (project, budget) VALUES ('Power Grid Mod... | What are the names of all projects in the 'utilities_projects' table with a budget under 1 million dollars? | SELECT project FROM utilities_projects WHERE budget < 1000000; | gretelai_synthetic_text_to_sql |
CREATE TABLE Cosmetics (id INT, name TEXT, price DECIMAL(5,2), is_vegan BOOLEAN); INSERT INTO Cosmetics (id, name, price, is_vegan) VALUES (1, 'Shampoo', 15.99, true), (2, 'Lipstick', 9.99, false); | What is the average price of vegan cosmetics per country? | SELECT country, AVG(price) FROM Cosmetics JOIN Country_Info ON Cosmetics.id = Country_Info.cosmetic_id WHERE is_vegan = true GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE public_services (id INT PRIMARY KEY, service VARCHAR(255), location VARCHAR(255), budget DECIMAL(10, 2), provider VARCHAR(255)); | Display the number of public services and the total budget allocation for each city. | SELECT location, COUNT(*) as num_services, SUM(budget) as total_budget FROM public_services GROUP BY location; | gretelai_synthetic_text_to_sql |
CREATE TABLE projects (id INT PRIMARY KEY, project_name TEXT, project_category TEXT, cost FLOAT); INSERT INTO projects (id, project_name, project_category, cost) VALUES (1, 'Rebuilding Homes', 'Disaster Response', 500000); | What's the total cost of all projects in the disaster response category? | SELECT SUM(cost) as total_cost FROM projects WHERE project_category = 'Disaster Response'; | gretelai_synthetic_text_to_sql |
CREATE TABLE TextileSourcing (country VARCHAR(20), material VARCHAR(20), price DECIMAL(5,2)); INSERT INTO TextileSourcing VALUES ('France', 'Linen', 3.25), ('Belgium', 'Linen', 3.50), ('Italy', 'Silk', 4.00); | What is the average price of linen textiles sourced from France and Belgium? | SELECT AVG(price) FROM TextileSourcing WHERE country IN ('France', 'Belgium') AND material = 'Linen'; | gretelai_synthetic_text_to_sql |
CREATE TABLE military_suppliers (id INT, supplier_id VARCHAR(50), supplier_name VARCHAR(100), country VARCHAR(50)); CREATE TABLE military_contracts (id INT, contract_id VARCHAR(50), supplier_id VARCHAR(50), contract_amount DECIMAL(10,2)); | Identify the common suppliers for the Canadian and Australian military? | SELECT s.supplier_name FROM military_suppliers s INNER JOIN (SELECT supplier_id FROM military_contracts WHERE country IN ('Canada', 'Australia') GROUP BY supplier_id HAVING COUNT(DISTINCT country) = 2) c ON s.supplier_id = c.supplier_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE agricultural_innovation_projects (id INT, country VARCHAR(50), funds FLOAT, year INT); INSERT INTO agricultural_innovation_projects (id, country, funds, year) VALUES (1, 'Kenya', 500000.00, 2020), (2, 'Uganda', 600000.00, 2021), (3, 'Rwanda', 400000.00, 2019); | What was the total amount of funds allocated for agricultural innovation projects in Rwanda in 2019? | SELECT SUM(funds) FROM agricultural_innovation_projects WHERE country = 'Rwanda' AND year = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE Underwriting (PolicyID INT, Name VARCHAR(50), Age INT, Gender VARCHAR(10)); | Insert a new underwriting record for 'Sophia Gonzales' with age 28 and gender 'Female'. | INSERT INTO Underwriting (PolicyID, Name, Age, Gender) VALUES (3, 'Sophia Gonzales', 28, 'Female'); SELECT * FROM Underwriting WHERE PolicyID = 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE MiningSites(id INT, name VARCHAR(30), location VARCHAR(30)); CREATE TABLE ResourceExtraction(site_id INT, date DATE, resources_extracted INT); | What is the total amount of resources extracted by each mining site in the last quarter? | SELECT m.name, SUM(re.resources_extracted) FROM MiningSites m JOIN ResourceExtraction re ON m.id = re.site_id WHERE date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH) GROUP BY m.id; | gretelai_synthetic_text_to_sql |
CREATE TABLE attorneys (attorney_id INT, performance_rating VARCHAR(10)); INSERT INTO attorneys (attorney_id, performance_rating) VALUES (1, 'Excellent'), (2, 'Good'); | How many cases were handled by attorneys with 'Excellent' performance ratings? | SELECT COUNT(*) FROM cases JOIN attorneys ON cases.attorney_id = attorneys.attorney_id WHERE attorneys.performance_rating = 'Excellent'; | gretelai_synthetic_text_to_sql |
CREATE TABLE new_donors (id INT, name TEXT, donation_date DATE); CREATE TABLE donations (id INT, donor TEXT, amount DECIMAL, donation_date DATE); | What was the total amount donated by new donors in H1 2022? | SELECT SUM(amount) as total_donated FROM donations d JOIN new_donors nd ON d.donor = nd.name WHERE d.donation_date >= '2022-01-01' AND d.donation_date < '2022-07-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE CommunityService (CSID INT, State VARCHAR(10), Hours INT); INSERT INTO CommunityService (CSID, State, Hours) VALUES (1, 'CA', 20), (2, 'NY', 30), (3, 'CA', 15); | What is the total number of hours spent in community service by offenders in each state? | SELECT State, SUM(Hours) FROM CommunityService GROUP BY State; | gretelai_synthetic_text_to_sql |
CREATE TABLE regions (id INT, name TEXT); INSERT INTO regions (id, name) VALUES (1, 'North America'), (2, 'South America'), (3, 'Europe'), (4, 'Middle East'), (5, 'Asia'), (6, 'Africa'), (7, 'Pacific'); CREATE TABLE assessments (id INT, region_id INT, product_id INT, type TEXT); INSERT INTO assessments (id, region_id, ... | Insert a new environmental impact assessment for 'Product H' in the 'Pacific' region. | INSERT INTO assessments (id, region_id, product_id, type) VALUES ((SELECT MAX(id) FROM assessments) + 1, (SELECT id FROM regions WHERE name = 'Pacific'), (SELECT id FROM chemical_products WHERE name = 'Product H'), 'Environmental'); | gretelai_synthetic_text_to_sql |
CREATE TABLE order_fact (order_id INT, sale_id INT, supplier_id INT, order_date DATE); | Show the total sales for each supplier country, from the sales_fact table, grouped by supplier_country. | SELECT s.supplier_country, SUM(sf.sale_quantity * sf.sale_price) as total_sales FROM sales_fact sf JOIN order_fact o ON sf.sale_id = o.sale_id JOIN supplier_dim s ON o.supplier_id = s.supplier_id GROUP BY s.supplier_country; | gretelai_synthetic_text_to_sql |
CREATE TABLE MakeupProducts(productId INT, productName VARCHAR(100), isNatural BOOLEAN, country VARCHAR(50), price DECIMAL(5,2)); INSERT INTO MakeupProducts(productId, productName, isNatural, country, price) VALUES (1, 'Mineral Foundation', true, 'Germany', 34.99), (2, 'Shea Butter Mascara', true, 'Germany', 19.99); | What is the maximum price of natural makeup products sold in Germany? | SELECT MAX(price) FROM MakeupProducts WHERE isNatural = true AND country = 'Germany'; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_policing (id INT PRIMARY KEY, program_name VARCHAR(50), start_date DATE, end_date DATE, average_response_time INT); | What is the average response time for each community policing program? | SELECT program_name, AVG(average_response_time) as avg_response_time FROM community_policing GROUP BY program_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE labor_unions (id INT, union_name VARCHAR(50), members INT); CREATE TABLE safety_records (id INT, union_id INT, safety_score INT); CREATE TABLE employees (id INT, union_id INT, name VARCHAR(50), position VARCHAR(50)); | List unions and their members count with a safety record over 90 from 'labor_unions', 'safety_records', and 'employees' tables | SELECT l.union_name, COUNT(e.id) AS member_count FROM labor_unions l JOIN safety_records s ON l.id = s.union_id JOIN employees e ON l.id = e.union_id WHERE s.safety_score > 90 GROUP BY l.union_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE economic_diversification_efforts (id INT, country VARCHAR(20), success BOOLEAN, start_year INT, end_year INT); INSERT INTO economic_diversification_efforts (id, country, success, start_year, end_year) VALUES (1, 'India', true, 2017, 2019), (2, 'India', false, 2016, 2018); | How many economic diversification efforts were successful in India between 2017 and 2019? | SELECT COUNT(*) FROM economic_diversification_efforts WHERE country = 'India' AND start_year >= 2017 AND end_year <= 2019 AND success = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE customer_preferences (customer_id INT, natural_ingredient_purchase BOOLEAN); INSERT INTO customer_preferences (customer_id, natural_ingredient_purchase) VALUES (1, true), (2, false), (3, true), (4, true), (5, false), (6, true), (7, false); | Find the percentage of customers who have purchased a product with natural ingredients. | SELECT (COUNT(*) FILTER (WHERE natural_ingredient_purchase))::float / COUNT(*) as percentage FROM customer_preferences; | gretelai_synthetic_text_to_sql |
CREATE TABLE open_data_initiatives (initiative_id INT, launch_year INT, location VARCHAR(50)); INSERT INTO open_data_initiatives (initiative_id, launch_year, location) VALUES (1, 2017, 'European Union'), (2, 2016, 'United States'), (3, 2015, 'European Union'), (4, 2018, 'United Kingdom'), (5, 2017, 'Canada'), (6, 2020,... | How many open data initiatives were launched in the European Union in the last 5 years? | SELECT COUNT(*) FROM open_data_initiatives WHERE launch_year >= 2016 AND location = 'European Union'; | gretelai_synthetic_text_to_sql |
CREATE TABLE contract_negotiators (id INT, name VARCHAR(255), region VARCHAR(255)); INSERT INTO contract_negotiators (id, name, region) VALUES (1, 'Sophia Nguyen', 'Europe'), (2, 'James Lee', 'Asia'), (3, 'Marieke Janssen', 'Americas'), (4, 'Ali Al-Said', 'Middle East'), (5, 'Snežana Petrović', 'Europe'), (6, 'Pedro Go... | Who are the contract negotiators for defense projects in Europe? | SELECT name FROM contract_negotiators WHERE region = 'Europe'; | gretelai_synthetic_text_to_sql |
CREATE TABLE consumer_info (consumer_id INT, age INT, cruelty_free_preference BOOLEAN); INSERT INTO consumer_info (consumer_id, age, cruelty_free_preference) VALUES (1, 25, true), (2, 35, false), (3, 45, true), (4, 55, false), (5, 65, true); CREATE TABLE age_group (age INT, group_name VARCHAR(20)); INSERT INTO age_grou... | What percentage of consumers prefer cruelty-free products by age group? | SELECT age_group.group_name, 100.0 * AVG(CASE WHEN consumer_info.cruelty_free_preference THEN 1.0 ELSE 0.0 END) as cruelty_free_percentage FROM consumer_info JOIN age_group ON consumer_info.age = age_group.age GROUP BY age_group.group_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT, Department VARCHAR(255), Salary FLOAT); INSERT INTO Employees (EmployeeID, Department, Salary) VALUES (1, 'IT', 70000), (2, 'HR', 60000), (3, 'HR', 65000); | What is the average salary of employees in the HR department? | SELECT AVG(Salary) FROM Employees WHERE Department = 'HR'; | gretelai_synthetic_text_to_sql |
CREATE TABLE marineshrimp (country VARCHAR(20), temperature DECIMAL(5,2)); INSERT INTO marineshrimp (country, temperature) VALUES ('Thailand', 29.2), ('Indonesia', 28.7), ('Vietnam', 28.5), ('Norway', 13.0); | List the top 3 countries with the highest water temperature for marine shrimp farms. | SELECT country, temperature FROM (SELECT country, temperature, ROW_NUMBER() OVER (ORDER BY temperature DESC) as row FROM marineshrimp) AS sub WHERE row <= 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE technology_accessibility_stats (id INT PRIMARY KEY, country VARCHAR(255), internet_users INT, broadband_penetration DECIMAL(5,2), mobile_users INT, disabled_population INT); | Create a view for the top 3 countries with the highest broadband penetration | CREATE VIEW top_3_broadband_countries AS SELECT country, broadband_penetration FROM technology_accessibility_stats ORDER BY broadband_penetration DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE workplace_safety (safety_rating INT, workplace_id INT); | What is the total number of workplaces with a safety rating above 85 in the 'workplace_safety' table? | SELECT COUNT(*) FROM workplace_safety WHERE safety_rating > 85; | gretelai_synthetic_text_to_sql |
CREATE TABLE ClimateFinance (Country TEXT, Sector TEXT, Investment_Amount NUMERIC); INSERT INTO ClimateFinance (Country, Sector, Investment_Amount) VALUES ('South Africa', 'Renewable Energy', 5000000), ('Kenya', 'Renewable Energy', 2000000), ('Nigeria', 'Renewable Energy', 7000000); | What is the total amount of climate finance invested in renewable energy in Africa? | SELECT SUM(Investment_Amount) FROM ClimateFinance WHERE Country IN ('South Africa', 'Kenya', 'Nigeria') AND Sector = 'Renewable Energy'; | gretelai_synthetic_text_to_sql |
CREATE TABLE energy_efficiency_inspections (id INT, building_id INT, inspection_date DATE); CREATE TABLE buildings (id INT, construction_year INT); INSERT INTO energy_efficiency_inspections (id, building_id, inspection_date) VALUES (1, 1, '2001-01-01'), (2, 2, '1999-12-31'), (3, 3, '2020-01-01'); INSERT INTO buildings ... | What is the total number of energy efficiency inspections conducted in the 'energy_efficiency' schema for buildings constructed before '2000'? | SELECT COUNT(*) FROM energy_efficiency_inspections INNER JOIN buildings ON energy_efficiency_inspections.building_id = buildings.id WHERE construction_year < 2000; | gretelai_synthetic_text_to_sql |
CREATE TABLE stadiums (id INT, name TEXT, capacity INT); CREATE TABLE games (id INT, stadium_id INT, home_team_id INT, away_team_id INT, home_team_score INT, away_team_score INT, game_date DATE); CREATE TABLE attendance (game_id INT, team_id INT, fans_attended INT); | What are the names and average attendance of all stadiums that have hosted a game in the last 5 years? | SELECT s.name, AVG(a.fans_attended) FROM stadiums s INNER JOIN games g ON s.id = g.stadium_id INNER JOIN attendance a ON g.id = a.game_id WHERE g.game_date >= DATE_SUB(CURRENT_DATE, INTERVAL 5 YEAR) GROUP BY s.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE station (station_id INT, name TEXT, num_bikes_available INT, last_reported_date DATE); INSERT INTO station VALUES (1, 'Station A', 10, '2021-12-31'); INSERT INTO station VALUES (2, 'Station B', 5, '2021-12-31'); INSERT INTO station VALUES (3, 'Station C', 15, '2021-12-31'); | Find the number of bicycles available in each station as of January 1, 2022 | SELECT name, num_bikes_available FROM station WHERE last_reported_date = (SELECT MAX(last_reported_date) FROM station) AND num_bikes_available > 0; | gretelai_synthetic_text_to_sql |
CREATE TABLE wind_energy (country VARCHAR(20), energy_generated INT, measurement_date DATE); INSERT INTO wind_energy (country, energy_generated, measurement_date) VALUES ('Germany', 1500, '2020-01-01'), ('Germany', 1700, '2020-01-02'); CREATE TABLE solar_energy (country VARCHAR(20), energy_generated INT, measurement_da... | What is the total energy generated by wind and solar sources in Germany in the first quarter of 2020? | SELECT SUM(energy_generated) FROM (SELECT energy_generated FROM wind_energy WHERE country = 'Germany' AND measurement_date BETWEEN '2020-01-01' AND '2020-03-31' UNION ALL SELECT energy_generated FROM solar_energy WHERE country = 'Germany' AND measurement_date BETWEEN '2020-01-01' AND '2020-03-31') AS total; | gretelai_synthetic_text_to_sql |
CREATE TABLE incident_resolution_times (id INT, incident_type VARCHAR(255), resolution_time FLOAT, region VARCHAR(255), occurrence_date DATE); INSERT INTO incident_resolution_times (id, incident_type, resolution_time, region, occurrence_date) VALUES (1, 'Phishing', 4.5, 'LATAM', '2021-02-03'); | What was the average time to resolve incidents for each incident type in the LATAM region in 2021? | SELECT incident_type, AVG(resolution_time) AS avg_resolution_time FROM incident_resolution_times WHERE region = 'LATAM' AND occurrence_date >= '2021-01-01' AND occurrence_date < '2022-01-01' GROUP BY incident_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE tunnels (id INT, name VARCHAR(255), category VARCHAR(255), length FLOAT); INSERT INTO tunnels (id, name, category, length) VALUES (1, 'Sample Tunnel', 'Railway', 5000); | Find the number of tunnels in 'Railway' category. | SELECT COUNT(*) FROM tunnels WHERE category = 'Railway'; | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_adaptation (project_id INTEGER, project_name TEXT, location TEXT, budget INTEGER); INSERT INTO climate_adaptation (project_id, project_name, location, budget) VALUES (1, 'Project M', 'South America', 700000), (2, 'Project N', 'North America', 500000); | What is the total budget for climate adaptation projects in 'South America'? | SELECT SUM(budget) FROM climate_adaptation WHERE location = 'South America'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Agency (id INT, name VARCHAR(50), city_id INT, type VARCHAR(50)); INSERT INTO Agency (id, name, city_id, type) VALUES (1, 'Seattle PD', 1, 'Police'); INSERT INTO Agency (id, name, city_id, type) VALUES (2, 'Portland PD', 2, 'Police'); INSERT INTO Agency (id, name, city_id, type) VALUES (3, 'Seattle Fire', ... | What is the total budget for all agencies in 2022? | SELECT SUM(Budget.amount) FROM Budget WHERE Budget.year = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE companies (company_id INT, company_name TEXT, industry TEXT, founding_year INT, founder_age INT); INSERT INTO companies (company_id, company_name, industry, founding_year, founder_age) VALUES (1, 'YouthHealth', 'Healthtech', 2020, 28); CREATE TABLE funding_records (funding_id INT, company_id INT, amount IN... | What is the average funding amount for series A rounds for companies in the healthtech sector founded by entrepreneurs under 30? | SELECT AVG(fr.amount) FROM companies c JOIN funding_records fr ON c.company_id = fr.company_id WHERE c.industry = 'Healthtech' AND c.founder_age < 30 AND fr.round_number = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE microfinance_loans (loan_id INT, region VARCHAR(255), loan_value DECIMAL); INSERT INTO microfinance_loans (loan_id, region, loan_value) VALUES (1, 'Africa', 1000), (2, 'Asia', 2000), (3, 'South America', 1500); | What is the total value of microfinance loans issued in a specific region? | SELECT SUM(loan_value) FROM microfinance_loans WHERE region = 'Africa'; | gretelai_synthetic_text_to_sql |
CREATE TABLE vulnerabilities (id INT, product VARCHAR(255), severity INT, discovered_at DATETIME); | What is the average severity of vulnerabilities for each software product in the past year? | SELECT product, AVG(severity) as avg_severity FROM vulnerabilities WHERE discovered_at >= DATE_SUB(NOW(), INTERVAL 1 YEAR) GROUP BY product; | gretelai_synthetic_text_to_sql |
CREATE TABLE fish_stocks (id INT, name TEXT, location TEXT, sustainability_rating TEXT, harvested_quantity INT); INSERT INTO fish_stocks (id, name, location, sustainability_rating, harvested_quantity) VALUES (1, 'Pacific Salmon', 'Canada', 'sustainable', 5000), (2, 'Tuna', 'Philippines', 'unsustainable', 3000), (3, 'Pa... | How many fish were harvested from sustainable fish stocks in 2020? | SELECT SUM(harvested_quantity) FROM fish_stocks WHERE sustainability_rating = 'sustainable' AND EXTRACT(YEAR FROM date) = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE destinations (destination_id INT, destination_name VARCHAR(50), continent VARCHAR(50)); INSERT INTO destinations (destination_id, destination_name, continent) VALUES (1, 'Cairo', 'Africa'), (2, 'Marrakech', 'Africa'), (3, 'Victoria Falls', 'Africa'); CREATE TABLE tourists (tourist_id INT, destination_id IN... | Delete all records of tourists who visited African destinations in 2018. | DELETE t FROM tourists t JOIN destinations d ON t.destination_id = d.destination_id WHERE d.continent = 'Africa' AND t.year = 2018; | gretelai_synthetic_text_to_sql |
CREATE TABLE categories (id INT PRIMARY KEY, name TEXT NOT NULL); CREATE TABLE news_views (category_id INT, view_count INT); | List all news categories with their respective total views, ordered by the highest number of views first | SELECT categories.name, SUM(news_views.view_count) as total_views FROM categories INNER JOIN news_views ON categories.id = news_views.category_id GROUP BY categories.name ORDER BY total_views DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE fish_farms (id INT, name TEXT, species TEXT, country TEXT, latitude DECIMAL(9,6), longitude DECIMAL(9,6)); INSERT INTO fish_farms (id, name, species, country, latitude, longitude) VALUES (1, 'Trout Farm 1', 'Rainbow Trout', 'UK', 51.123456, -1.123456), (2, 'Salmon Farm 1', 'Atlantic Salmon', 'UK', 52.12345... | List all fish species being farmed in the UK with their respective farm locations | SELECT species, name, latitude, longitude FROM fish_farms WHERE country = 'UK'; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA mental_health; CREATE TABLE mental_health.courses (course_id INT, student_id INT, topic VARCHAR(50)); INSERT INTO mental_health.courses (course_id, student_id, topic) VALUES (301, 1, 'Mindfulness'), (302, 3, 'Stress Management'), (303, 2, 'Physical Education'); INSERT INTO mental_health.courses (course_id... | Get the number of students who have ever taken a course related to mental health | SELECT COUNT(DISTINCT student_id) FROM mental_health.courses WHERE topic LIKE '%mental%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE TransactionValues (TransactionID int, TransactionDate date, Value float); INSERT INTO TransactionValues (TransactionID, TransactionDate, Value) VALUES (1, '2021-01-02', 100.5), (2, '2021-02-15', 250.7), (3, '2021-05-03', 75.3), (4, '2021-12-30', 1500.0); | What is the total value of smart contract transactions per month? | SELECT EXTRACT(MONTH FROM TransactionDate) as Month, SUM(Value) as TotalValue FROM TransactionValues GROUP BY Month; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (species_name VARCHAR(50), status VARCHAR(20)); INSERT INTO marine_species (species_name, status) VALUES ('Blue Whale', 'endangered'), ('Green Sea Turtle', 'vulnerable'); | List all marine species in 'endangered' status. | SELECT species_name FROM marine_species WHERE status = 'endangered'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Menus (RestaurantID varchar(50), MenuItem varchar(50), Price decimal(10,2)); | Update the menu item prices for restaurant D by increasing them by 10% in the Menus table. | UPDATE Menus SET Price = Price * 1.10 WHERE RestaurantID = 'D'; | gretelai_synthetic_text_to_sql |
CREATE TABLE graduate_students (student_id INT, name VARCHAR(50), country VARCHAR(50)); INSERT INTO graduate_students (student_id, name, country) VALUES (1, 'Alice', 'USA'), (2, 'Bob', 'Canada'); CREATE TABLE research_grants (grant_id INT, student_id INT, amount INT); INSERT INTO research_grants (grant_id, student_id, ... | What is the total number of research grants awarded to graduate students from the United States? | SELECT SUM(rg.amount) FROM research_grants rg JOIN graduate_students gs ON rg.student_id = gs.student_id WHERE gs.country = 'USA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE production (year INT, element TEXT, volume INT); INSERT INTO production (year, element, volume) VALUES (2021, 'yttrium', 6000), (2021, 'lutetium', 2000); | What is the total production volume of yttrium and lutetium in 2021? | SELECT SUM(volume) FROM production WHERE element IN ('yttrium', 'lutetium') AND year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE EsportsEvents (EventID INT, EventName VARCHAR(20), PrizeMoney INT); INSERT INTO EsportsEvents (EventID, EventName, PrizeMoney) VALUES (1, 'ESWC', 200000), (2, 'EVO', 300000), (3, 'BlizzCon', 500000), (4, 'The International', 8000000), (5, 'MLG', 100000); | List the names of esports events with the highest total prize money and the corresponding prize money. | SELECT EventName, PrizeMoney FROM EsportsEvents ORDER BY PrizeMoney DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE customers (customer_id INT, name VARCHAR(50), age INT, gender VARCHAR(10), risk_score INT, portfolio_value DECIMAL(10,2)); | Calculate the 90th percentile of the portfolio value for customers in each age group (e.g., 18-24, 25-34, 35-44, etc.). | SELECT AVG(portfolio_value) as avg_portfolio_value, FLOOR((age-1)/10)*10 as age_group FROM customers GROUP BY age_group ORDER BY age_group; WITH portfolio_values AS (SELECT customer_id, portfolio_value FROM customers) SELECT age_group, PERCENTILE_CONT(0.9) WITHIN GROUP (ORDER BY pv.portfolio_value) as pct_90 FROM custo... | gretelai_synthetic_text_to_sql |
CREATE TABLE Factories (factory_id INT, factory_name TEXT, region TEXT, sustainable_practices BOOLEAN); | What is the number of factories with sustainable practices in the North America region? | SELECT COUNT(*) FROM Factories WHERE region = 'North America' AND sustainable_practices = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE Regions (id INT, region_name VARCHAR(255)); CREATE TABLE CommunityPolicing (id INT, region_id INT, policing_score INT, policing_date DATE); INSERT INTO Regions (id, region_name) VALUES (1, 'North'), (2, 'South'), (3, 'East'), (4, 'West'); INSERT INTO CommunityPolicing (id, region_id, policing_score, polici... | Find the average community policing score by region and month for the past year, ranked in descending order. | SELECT region_id, AVG(policing_score) as avg_score, EXTRACT(MONTH FROM policing_date) as month FROM CommunityPolicing WHERE policing_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) AND CURRENT_DATE GROUP BY region_id, month ORDER BY avg_score DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE excavation_sites (id INT, name VARCHAR(255), country VARCHAR(255)); INSERT INTO excavation_sites (id, name, country) VALUES (1, 'Site X', 'USA'), (2, 'Site Y', 'Mexico'); | How many artifacts were recovered from each country? | SELECT country, COUNT(*) FROM excavation_sites GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE CollectiveBargaining (AgreementID INT, Sector VARCHAR(20), SignDate DATE); INSERT INTO CollectiveBargaining (AgreementID, Sector, SignDate) VALUES (1, 'Education', '2015-05-01'), (2, 'Education', '2016-09-15'), (3, 'Healthcare', '2017-03-25'); | How many collective bargaining agreements were signed in the 'Education' sector between 2015 and 2018? | SELECT COUNT(*) FROM CollectiveBargaining WHERE Sector = 'Education' AND SignDate BETWEEN '2015-01-01' AND '2018-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ingredients (id INT, ingredient_name TEXT, unit_price DECIMAL, quantity INT); | What is the total cost of ingredients for vegetarian dishes, updated to reflect the current inventory levels? | SELECT SUM(unit_price * quantity) FROM ingredients WHERE ingredient_name IN (SELECT ingredient_name FROM menu_items WHERE is_vegetarian = TRUE); | gretelai_synthetic_text_to_sql |
CREATE TABLE Healthcare(Year INT, Amount INT); INSERT INTO Healthcare VALUES (2018, 10000), (2019, 12000), (2020, 14000); | What was the total budget allocated for healthcare in 2019 and 2020? | SELECT SUM(Amount) FROM Healthcare WHERE Year IN (2019, 2020); | gretelai_synthetic_text_to_sql |
CREATE TABLE mining_site (id INT, name TEXT, location TEXT); INSERT INTO mining_site (id, name, location) VALUES (1, 'Uranium Mine', 'Australia'), (2, 'Copper Mine', 'Chile'); CREATE TABLE water_usage (id INT, mine_id INT, date DATE, usage REAL); INSERT INTO water_usage (id, mine_id, date, usage) VALUES (1, 1, '2022-01... | What is the average water usage per month for each mining site? | SELECT mine_id, AVG(usage) as avg_water_usage FROM water_usage GROUP BY mine_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE InfrastructureProjects (id INT, category VARCHAR(20), cost FLOAT); INSERT INTO InfrastructureProjects (id, category, cost) VALUES (1, 'Roads', 500000), (2, 'Bridges', 750000), (3, 'Buildings', 900000), (4, 'Roads', 600000); | How many projects are there in total for the 'Bridges' category? | SELECT COUNT(*) FROM InfrastructureProjects WHERE category = 'Bridges'; | gretelai_synthetic_text_to_sql |
CREATE TABLE regions (id INT, name TEXT); INSERT INTO regions (id, name) VALUES (1, 'North America'), (2, 'South America'), (3, 'Europe'), (4, 'Middle East'), (5, 'Asia'); CREATE TABLE assessments (id INT, region_id INT, type TEXT); INSERT INTO assessments (id, region_id, type) VALUES (1, 1, 'Safety'), (2, 4, 'Environm... | How many environmental impact assessments have been conducted in the 'Middle East' region? | SELECT COUNT(assessments.id) FROM assessments JOIN regions ON assessments.region_id = regions.id WHERE regions.name = 'Middle East'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Submarines (ID INT, Name VARCHAR(50), NumWeapons INT); | What are the names and number of weapons for each submarine? | SELECT Name, NumWeapons FROM Submarines; | gretelai_synthetic_text_to_sql |
CREATE TABLE emergency_calls (id INT, date DATE, response_time INT, city VARCHAR(20), state VARCHAR(20)); INSERT INTO emergency_calls (id, date, response_time, city, state) VALUES (1, '2022-01-01', 10, 'Miami', 'FL'), (2, '2022-01-02', 20, 'Miami', 'FL'); CREATE TABLE fire_incidents (id INT, date DATE, response_time IN... | What is the maximum response time for emergency calls and fire incidents in the last month in Miami, FL? | SELECT 'emergency calls' AS type, MAX(response_time) FROM emergency_calls WHERE date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) AND city = 'Miami' AND state = 'FL' UNION ALL SELECT 'fire incidents' AS type, MAX(response_time) FROM fire_incidents WHERE date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) AND city = 'Miami'... | gretelai_synthetic_text_to_sql |
CREATE TABLE safety_incidents (id INT, ai_application VARCHAR(50), country VARCHAR(50), incident_count INT); INSERT INTO safety_incidents (id, ai_application, country, incident_count) VALUES (1, 'Autonomous Vehicles', 'USA', 3), (2, 'Healthcare', 'Canada', 2), (3, 'Finance', 'Mexico', 1); | What is the distribution of safety incidents for AI applications across various countries? | SELECT country, ai_application, AVG(incident_count) as avg_incidents FROM safety_incidents GROUP BY country, ai_application; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT, country VARCHAR(255)); INSERT INTO users (id, country) VALUES (1, 'United States'), (2, 'Canada'); CREATE TABLE posts (id INT, user_id INT, timestamp TIMESTAMP); INSERT INTO posts (id, user_id, timestamp) VALUES (1, 1, '2022-01-01 12:00:00'), (2, 1, '2022-01-02 13:00:00'), (3, 2, '2022-01-03... | What is the total number of posts made by users who have made more than 10 posts? | SELECT COUNT(*) FROM (SELECT user_id, COUNT(*) as post_count FROM posts GROUP BY user_id HAVING post_count > 10); | gretelai_synthetic_text_to_sql |
CREATE TABLE Properties (PropertyID int, Price int, SustainabilityRating int, Borough varchar(255)); INSERT INTO Properties (PropertyID, Price, SustainabilityRating, Borough) VALUES (1, 500000, 3, 'Manhattan'); | What is the average property price in each borough for sustainable buildings? | SELECT Borough, AVG(Price) as AvgPrice FROM Properties WHERE SustainabilityRating >= 3 GROUP BY Borough; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_protected_areas (area_name VARCHAR(255), has_coral_reefs BOOLEAN); INSERT INTO marine_protected_areas (area_name, has_coral_reefs) VALUES ('Galapagos Marine Reserve', TRUE), ('Great Barrier Reef', TRUE), ('Sargasso Sea', FALSE); | Display the names of marine protected areas with coral reefs. | SELECT area_name FROM marine_protected_areas WHERE has_coral_reefs = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE MilitaryTech (TechID int, TechName varchar(100), Category varchar(50)); INSERT INTO MilitaryTech (TechID, TechName, Category) VALUES (1, 'F-35', 'Fighter Jet'), (2, 'M1 Abrams', 'Tank'), (3, 'Tomahawk', 'Missile'); | Identify military technology by their respective categories, ranked by the number of technologies in descending order. | SELECT Category, COUNT(*) as TechCount, ROW_NUMBER() OVER (ORDER BY COUNT(*) DESC) as Rank FROM MilitaryTech GROUP BY Category; | gretelai_synthetic_text_to_sql |
CREATE TABLE Manufacturing (ProductID INT, ManufacturingCountry VARCHAR(50)); INSERT INTO Manufacturing (ProductID, ManufacturingCountry) VALUES (1, 'USA'), (2, 'China'), (3, 'Japan'); | For each country, what is the percentage of garments sold that were manufactured in that country? | SELECT Country, (SUM(CASE WHEN ManufacturingCountry = Country THEN QuantitySold ELSE 0 END) * 100.0 / SUM(QuantitySold)) AS PercentageOfLocalManufacturing FROM Sales JOIN Manufacturing ON Sales.ProductID = Manufacturing.ProductID GROUP BY Country; | gretelai_synthetic_text_to_sql |
CREATE TABLE stadiums (stadium_id INT, stadium_name VARCHAR(255), capacity INT); | List all the unique stadiums along with their capacities from the stadiums table. | SELECT DISTINCT stadium_name, capacity FROM stadiums; | gretelai_synthetic_text_to_sql |
CREATE TABLE rescue_center_animals (animal_id INT, animal_name VARCHAR(50), region VARCHAR(50)); | Insert a new record of a 'Kiwi' animal in the rescue center from the 'New Zealand Islands' region. | INSERT INTO rescue_center_animals (animal_id, animal_name, region) VALUES (3, 'Kiwi', 'New Zealand Islands'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Parks (Name VARCHAR(255), Size INT); INSERT INTO Parks (Name, Size) VALUES ('Central Park', 843), ('Golden Gate Park', 1017), ('Balboa Park', 1200); | Add a new record to the "Parks" table with the name "City Park" and the size of 75 acres | INSERT INTO Parks (Name, Size) VALUES ('City Park', 75); | gretelai_synthetic_text_to_sql |
CREATE TABLE incidents(id INT, vessel_id INT, incident_date DATE); INSERT INTO incidents VALUES (1, 2, '2021-09-15'), (2, 2, '2022-02-03'), (3, 5, '2022-01-20'); | What is the earliest incident date for VesselB? | SELECT MIN(incident_date) FROM incidents WHERE vessel_id = 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE Tours (id INT, name TEXT, country TEXT, type TEXT, revenue INT); INSERT INTO Tours (id, name, country, type, revenue) VALUES (1, 'Nature Walk', 'Brazil', 'Eco', 2500); | What is the total revenue generated by eco-friendly tours in South America? | SELECT SUM(revenue) FROM Tours WHERE EXTRACT(CONTINENT FROM country) = 'South America' AND type = 'Eco'; | gretelai_synthetic_text_to_sql |
CREATE TABLE industry_employment (id INT, name VARCHAR(50), industry VARCHAR(20), num_employees INT); | Calculate the total number of employees in the 'healthtech' industry. | SELECT SUM(num_employees) FROM industry_employment WHERE industry = 'healthtech'; | gretelai_synthetic_text_to_sql |
CREATE TABLE military_personnel (id INT, name VARCHAR(50), branch VARCHAR(50), rank VARCHAR(50), experience INT); INSERT INTO military_personnel (id, name, branch, rank, experience) VALUES (1, 'John Doe', 'army', 'Captain', 10); INSERT INTO military_personnel (id, name, branch, rank, experience) VALUES (2, 'Jane Smith'... | Which military personnel have more than 10 years of experience? | SELECT * FROM military_personnel WHERE experience > 10; | gretelai_synthetic_text_to_sql |
CREATE TABLE renewable_projects (project_id INT, project_name TEXT, project_type TEXT, installed_capacity FLOAT); | What is the total installed capacity (in MW) of 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 clinics (id INT, name TEXT, type TEXT, location TEXT, state TEXT); INSERT INTO clinics (id, name, type, location, state) VALUES (1, 'Sunshine Clinic', 'Primary Care', 'Rural, Florida', 'Florida'); INSERT INTO clinics (id, name, type, location, state) VALUES (2, 'Seaside Clinic', 'Mental Health', 'Rural, Ge... | Count the number of clinics in rural areas of each state, excluding duplicates. | SELECT state, COUNT(DISTINCT location) as number_of_clinics FROM clinics WHERE location LIKE 'Rural%' GROUP BY state | gretelai_synthetic_text_to_sql |
CREATE TABLE directors (id INT, name VARCHAR(255), gender VARCHAR(10)); CREATE TABLE movies_directors (movie_id INT, director_id INT); CREATE TABLE actors (id INT, name VARCHAR(255), gender VARCHAR(10)); CREATE TABLE movies_actors (movie_id INT, actor_id INT); INSERT INTO directors (id, name, gender) VALUES (1, 'Direct... | Who are the directors that have never worked with a female actor? | SELECT d.name FROM directors d LEFT JOIN (SELECT movie_id FROM movies_actors ma JOIN actors a ON ma.actor_id = a.id WHERE a.gender = 'Female') fem_actors ON d.id = (SELECT movie_id FROM movies_directors md WHERE md.director_id = d.id) WHERE fem_actors.movie_id IS NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE EsportsWinners (EventID INT, PlayerID INT, Wins INT); INSERT INTO EsportsWinners (EventID, PlayerID, Wins) VALUES (1, 1, 3), (2, 2, 2), (3, 1, 1), (4, 3, 4); | What is the average number of wins by players in esports events? | SELECT AVG(Wins) FROM EsportsWinners; | gretelai_synthetic_text_to_sql |
CREATE TABLE healthcare_providers (id INT, name TEXT, type TEXT, patient_satisfaction FLOAT); | Identify the rural healthcare providers with the lowest patient satisfaction ratings, grouped by provider type. | SELECT type, MIN(patient_satisfaction) FROM healthcare_providers WHERE type = 'Rural' GROUP BY type; | gretelai_synthetic_text_to_sql |
CREATE TABLE menu (menu_id INT, restaurant_id INT, food_category TEXT, price DECIMAL(5,2)); CREATE TABLE restaurant (restaurant_id INT, name TEXT); INSERT INTO restaurant (restaurant_id, name) VALUES (1, 'Restaurant A'), (2, 'Restaurant B'), (3, 'Restaurant C'); INSERT INTO menu (menu_id, restaurant_id, food_category) ... | Identify the number of unique menu items offered by each restaurant, sorted by the number of items in descending order. | SELECT r.name, COUNT(DISTINCT m.menu_id) AS unique_menu_items FROM menu m JOIN restaurant r ON m.restaurant_id = r.restaurant_id GROUP BY r.name ORDER BY unique_menu_items DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE species (id INT PRIMARY KEY, name VARCHAR(255), population INT, conservation_status VARCHAR(255)); | Insert records into 'species' | INSERT INTO species (id, name, population, conservation_status) VALUES (1, 'Blue Whale', 10000, 'Endangered'); | gretelai_synthetic_text_to_sql |
CREATE TABLE inclusive_housing (borough VARCHAR(20), units INT); INSERT INTO inclusive_housing (borough, units) VALUES ('Manhattan', 500), ('Brooklyn', 700), ('Queens', 800), ('Bronx', 600), ('Staten Island', 400); | Show the number of inclusive housing units in each borough of New York. | SELECT borough, units, COUNT(units) OVER (PARTITION BY borough) AS total_units FROM inclusive_housing; | gretelai_synthetic_text_to_sql |
CREATE TABLE carbon_programs (id INT, launch_date DATE, location TEXT); INSERT INTO carbon_programs (id, launch_date, location) VALUES (1, '2021-01-01', 'US'), (2, '2020-12-31', 'US'); | How many carbon offset programs were launched in the US in 2021? | SELECT COUNT(*) FROM carbon_programs WHERE EXTRACT(YEAR FROM launch_date) = 2021 AND location = 'US'; | gretelai_synthetic_text_to_sql |
CREATE TABLE materials (material_id INT, name VARCHAR(50), is_organic BOOLEAN); INSERT INTO materials (material_id, name, is_organic) VALUES (1, 'Organic Cotton', true), (2, 'Conventional Cotton', false), (3, 'Organic Hemp', true); CREATE TABLE products_materials (product_id INT, material_id INT); INSERT INTO products_... | What is the total number of products made from organic materials? | SELECT COUNT(DISTINCT products_materials.product_id) FROM products_materials JOIN materials ON products_materials.material_id = materials.material_id WHERE materials.is_organic = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE students (id INT, country TEXT, mental_health_score INT); | What is the minimum mental health score of students in each country? | SELECT country, MIN(mental_health_score) FROM students GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE canadian_accommodations (id INT, country VARCHAR(20), eco_friendly BOOLEAN); INSERT INTO canadian_accommodations (id, country, eco_friendly) VALUES (1, 'Canada', true), (2, 'Canada', false), (3, 'Canada', true), (4, 'Canada', false); | What is the percentage of eco-friendly accommodations in Canada? | SELECT COUNT(*) * 100.0 / (SELECT COUNT(*) FROM canadian_accommodations) as percentage FROM canadian_accommodations WHERE eco_friendly = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE feed_additives (id INT, name VARCHAR(255), manufacturer_id INT, usage_volume FLOAT); INSERT INTO feed_additives (id, name, manufacturer_id, usage_volume) VALUES (1, 'Aquaculture', 1, 3500.0), (2, 'Aquafeed Colorant', 2, 2800.0), (3, 'Aquafeed Preservative', 3, 4200.0), (4, 'Aquafeed Attractant', 1, 3000.0)... | Identify the feed additive with the highest usage volume. | SELECT name, usage_volume FROM feed_additives WHERE usage_volume = (SELECT MAX(usage_volume) FROM feed_additives); | 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.