context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE school_districts (district_id INT, district_name TEXT, state TEXT, number_of_schools INT, budget INT); INSERT INTO school_districts (district_id, district_name, state, number_of_schools, budget) VALUES (1, 'Los Angeles Unified', 'California', 15, 2500000); INSERT INTO school_districts (district_id, distric... | What is the average budget allocated per school district in California, while only considering districts with more than 10 schools? | SELECT AVG(budget) FROM school_districts WHERE state = 'California' AND number_of_schools > 10; | gretelai_synthetic_text_to_sql |
CREATE TABLE CommunityEngagement (Event VARCHAR(255), Year INT, Country VARCHAR(255)); INSERT INTO CommunityEngagement (Event, Year, Country) VALUES ('Aboriginal Art Festival', 2020, 'Australia'), ('Aboriginal Art Festival', 2019, 'Australia'), ('Aboriginal Art Festival', 2018, 'Australia'), ('Indigenous Film Festival'... | What is the average number of community engagement events per year in each country? | SELECT Country, AVG(Num_Events) as Avg_Num_Events FROM (SELECT Country, Year, COUNT(Event) as Num_Events FROM CommunityEngagement GROUP BY Country, Year) as subquery GROUP BY Country; | gretelai_synthetic_text_to_sql |
CREATE TABLE Support_Programs (State VARCHAR(2), Program VARCHAR(50), Cost DECIMAL(5,2)); INSERT INTO Support_Programs VALUES ('CA', 'Mobility Training', 2000.00), ('CA', 'Assistive Technology', 2500.00), ('CA', 'Hearing Loop', 1800.00); | Identify support programs with a higher than average cost for disability accommodations in California? | SELECT * FROM Support_Programs WHERE Cost > (SELECT AVG(Cost) FROM Support_Programs WHERE State = 'CA'); | gretelai_synthetic_text_to_sql |
CREATE TABLE nba_games (team TEXT, won INT, lost INT); INSERT INTO nba_games (team, won, lost) VALUES ('Lakers', 33, 49), ('Clippers', 42, 40), ('Suns', 64, 18); | What is the percentage of games won by each team in the 2021-2022 NBA season? | SELECT team, (SUM(won) * 100.0 / (SUM(won) + SUM(lost))) as win_percentage FROM nba_games GROUP BY team; | gretelai_synthetic_text_to_sql |
CREATE TABLE startups(id INT, name TEXT, country TEXT, founder_gender TEXT); INSERT INTO startups VALUES (1, 'EcoInnovate', 'Canada', 'Female'); INSERT INTO startups VALUES (2, 'GreenTech', 'USA', 'Male'); INSERT INTO startups VALUES (3, 'TechVenture', 'UK', 'Male'); INSERT INTO startups VALUES (4, 'InnoVida', 'Brazil'... | Which country has the highest number of startups founded by women? | SELECT country, COUNT(*) AS count FROM startups WHERE founder_gender = 'Female' GROUP BY country ORDER BY count DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Vehicles (VehicleID int, VehicleType varchar(50), Accessibility bit); INSERT INTO Vehicles VALUES (1, 'Bus', 1), (2, 'Train', 0), (3, 'Tram', 1); CREATE TABLE MaintenanceTypes (MaintenanceTypeID int, MaintenanceType varchar(50)); INSERT INTO MaintenanceTypes VALUES (1, 'Oil Change'), (2, 'Tire Rotation'); ... | How many accessible vehicles are there for each maintenance type? | SELECT V.VehicleType, M.MaintenanceType, COUNT(VM.VehicleID) as AccessibleVehicleCount FROM Vehicles V INNER JOIN VehicleMaintenance VM ON V.VehicleID = VM.VehicleID INNER JOIN MaintenanceTypes M ON VM.MaintenanceTypeID = M.MaintenanceTypeID WHERE V.Accessibility = 1 GROUP BY V.VehicleType, M.MaintenanceType; | gretelai_synthetic_text_to_sql |
CREATE TABLE heritage_sites (id INT, name VARCHAR(255), region VARCHAR(255), description TEXT); INSERT INTO heritage_sites (id, name, region, description) VALUES (1, 'Brimstone Hill Fortress', 'Caribbean', 'A fortress located in St. Kitts and Nevis'), (2, 'Port Royal', 'Caribbean', 'A historic city located in Jamaica')... | What are the details of heritage sites in the 'heritage' schema from the Caribbean region? | SELECT * FROM heritage.heritage_sites WHERE region = 'Caribbean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE influencer_posts (post_id INT, post_date DATE, influencer_name VARCHAR(50), genre VARCHAR(50), likes INT); INSERT INTO influencer_posts VALUES (501, '2022-01-01', 'Influencer R', 'Fashion', 100), (502, '2022-01-03', 'Influencer S', 'Fashion', 150), (503, '2022-01-05', 'Influencer T', 'Fashion', 200), (504,... | What is the average number of likes per post for influencers in the fashion genre? | SELECT genre, AVG(likes) as avg_likes_per_post FROM (SELECT genre, influencer_name, AVG(likes) as likes FROM influencer_posts GROUP BY genre, influencer_name) AS subquery WHERE genre = 'Fashion'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Households (HouseholdID INTEGER, HouseholdMembers INTEGER, HouseholdIncome INTEGER, HouseholdState TEXT); | What is the average income of households with 4 members in the state of New York? | SELECT AVG(HouseholdIncome) FROM Households H WHERE H.HouseholdMembers = 4 AND H.HouseholdState = 'New York'; | gretelai_synthetic_text_to_sql |
CREATE TABLE fish_biomass (year INT, region VARCHAR(255), species VARCHAR(255), biomass FLOAT); INSERT INTO fish_biomass (year, region, species, biomass) VALUES (2020, 'Arctic Ocean', 'Cod', 1200), (2020, 'Arctic Ocean', 'Haddock', 800), (2021, 'Arctic Ocean', 'Cod', 1300); | What is the total biomass of fish species in the 'Arctic Ocean' per year? | SELECT year, SUM(biomass) AS total_biomass FROM fish_biomass WHERE region = 'Arctic Ocean' GROUP BY year; | gretelai_synthetic_text_to_sql |
CREATE TABLE Permits (PermitID INT, State CHAR(2)); INSERT INTO Permits (PermitID, State) VALUES (1, 'NY'), (2, 'NY'), (3, 'CA'); CREATE TABLE LaborHours (LaborHourID INT, PermitID INT, Hours DECIMAL(10,2)); INSERT INTO LaborHours (LaborHourID, PermitID, Hours) VALUES (1, 1, 250.00), (2, 1, 300.00), (3, 2, 150.00), (4,... | What is the maximum number of labor hours spent on a single permit in New York? | SELECT MAX(LaborHours.Hours) FROM LaborHours INNER JOIN Permits ON LaborHours.PermitID = Permits.PermitID WHERE Permits.State = 'NY'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Property (id INT, neighborhood VARCHAR(20), price FLOAT, property_type VARCHAR(20)); INSERT INTO Property (id, neighborhood, price, property_type) VALUES (1, 'GreenCommunity', 500000, 'Apartment'), (2, 'SolarVillage', 700000, 'House'); | What is the average property price in the "GreenCommunity" and "SolarVillage" neighborhoods, grouped by property type? | SELECT Property.property_type, AVG(Property.price) FROM Property WHERE Property.neighborhood IN ('GreenCommunity', 'SolarVillage') GROUP BY Property.property_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE Countries (country VARCHAR(255), num_articles INT, total_words INT); INSERT INTO Countries (country, num_articles, total_words) VALUES ('USA', 1200, 400000), ('India', 850, 250000), ('China', 1025, 350000); | Which country has the highest average word count in news articles? | SELECT country, AVG(total_words/num_articles) as avg_word_count FROM Countries GROUP BY country ORDER BY avg_word_count DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE articles (id INT, title TEXT, category TEXT, publish_date DATE, location TEXT); INSERT INTO articles (id, title, category, publish_date, location) VALUES (1, 'Climate Crisis Explained', 'climate_change', '2021-01-01', 'New York'), (2, 'Fintech Trends in Asia', 'technology', '2022-06-05', 'Singapore'); | Find the number of unique cities where articles about climate change were published in 2021. | SELECT COUNT(DISTINCT location) FROM articles WHERE category = 'climate_change' AND YEAR(publish_date) = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (sale_id INT, country VARCHAR(10), genre VARCHAR(10), platform VARCHAR(10), sales FLOAT); | Which country has the highest average sales in the jazz genre, across all platforms? | SELECT country, AVG(sales) FROM sales WHERE genre = 'jazz' GROUP BY country ORDER BY AVG(sales) DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE HumanitarianAssistance (ID INT, EventName TEXT, EventDate DATE, Country TEXT, Year INT); INSERT INTO HumanitarianAssistance VALUES (1, 'Event 1', '2013-01-01', 'Brazil', 2013); CREATE VIEW SouthAmerica AS SELECT Country FROM HumanitarianAssistance WHERE Country IN ('Brazil', 'Argentina', 'Colombia', 'Peru'... | What is the number of humanitarian assistance events in South America in the last decade, by country and year? | SELECT h.Country, h.Year, COUNT(*) as TotalEvents FROM HumanitarianAssistance h JOIN SouthAmerica sa ON h.Country = sa.Country WHERE h.Year BETWEEN DATEADD(year, -10, GETDATE()) AND GETDATE() GROUP BY h.Country, h.Year; | gretelai_synthetic_text_to_sql |
CREATE TABLE restaurant (id INT, name VARCHAR(255)); INSERT INTO restaurant (id, name) VALUES (1, 'Bistro'), (2, 'Grill'), (3, 'Cafe'); CREATE TABLE menu (id INT, item VARCHAR(255), price DECIMAL(5,2), daily_sales INT, restaurant_id INT); | Find the daily sales for the most expensive menu item in each restaurant | SELECT r.name, m.item, m.daily_sales FROM menu m JOIN (SELECT restaurant_id, MAX(price) as max_price FROM menu GROUP BY restaurant_id) mm ON m.restaurant_id = mm.restaurant_id AND m.price = mm.max_price JOIN restaurant r ON m.restaurant_id = r.id; | gretelai_synthetic_text_to_sql |
CREATE TABLE investment (id INT PRIMARY KEY, company_id INT, investor_id INT, investment_amount INT, investment_date DATE); INSERT INTO investment (id, company_id, investor_id, investment_amount, investment_date) VALUES (1, 1, 4, 50000, '2020-01-01'); INSERT INTO investment (id, company_id, investor_id, investment_amou... | List all investments made by investors from the 'Asia' region. | SELECT i.investment_date, i.investment_amount, j.name, j.location FROM investment AS i JOIN investor AS j ON i.investor_id = j.id WHERE j.location LIKE 'Asia%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_health_workers (worker_id INT, name VARCHAR(50), city VARCHAR(25)); INSERT INTO community_health_workers (worker_id, name, city) VALUES (1, 'John Doe', 'Los Angeles'); INSERT INTO community_health_workers (worker_id, name, city) VALUES (2, 'Jane Smith', 'New York City'); INSERT INTO community_hea... | How many community health workers are there in each city? | SELECT city, COUNT(*) FROM community_health_workers GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE tv_show_viewers(viewer_id INT, age_group VARCHAR(10), show_id INT); INSERT INTO tv_show_viewers(viewer_id, age_group, show_id) VALUES (1, '18-24', 1), (2, '18-24', 2), (3, '25-34', 2), (4, '35-44', 3), (5, '25-34', 1), (6, '45-54', 3), (7, '55-64', 1), (8, '18-24', 3); | What's the most common age group for TV show viewers? | SELECT age_group, COUNT(*) AS viewer_count FROM tv_show_viewers GROUP BY age_group ORDER BY viewer_count DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE budgets (budget_id INT, year INT, region_id INT, amount INT); INSERT INTO budgets (budget_id, year, region_id, amount) VALUES (1, 2019, 1, 500), (2, 2020, 1, 600), (3, 2021, 1, 700), (4, 2019, 2, 400), (5, 2020, 2, 450), (6, 2021, 2, 500); | Rank national security budgets for the last 3 years, partitioned by the region, in descending order of budget amount. | SELECT year, region_id, amount, RANK() OVER (PARTITION BY year, region_id ORDER BY amount DESC) as ranking FROM budgets ORDER BY year, region_id, ranking; | gretelai_synthetic_text_to_sql |
CREATE TABLE tv_shows (id INT, title VARCHAR(255), release_year INT, country VARCHAR(100), viewership INT); | What's the viewership trend for TV shows in the US over the last 5 years? | SELECT release_year, AVG(viewership) as avg_viewership FROM tv_shows WHERE country = 'US' GROUP BY release_year ORDER BY release_year DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE buildings (id INT, city VARCHAR, low_income BOOLEAN, property_tax DECIMAL); | What is the maximum property tax for buildings in low-income neighborhoods in New York City? | SELECT MAX(property_tax) FROM buildings WHERE city = 'New York City' AND low_income = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE fish_stock (species VARCHAR(50), is_sustainable BOOLEAN); | What is the percentage of fish in the fish_stock table that are from sustainable sources? | SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM fish_stock)) as sustainability_percentage FROM fish_stock WHERE is_sustainable = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE GameDesign (GameID INT, Studio VARCHAR(50)); INSERT INTO GameDesign (GameID, Studio) VALUES (1, 'Studio A'), (2, 'Studio B'), (3, 'Studio A'), (4, 'Studio C'), (5, 'Studio B'); | How many games have been designed by each game design studio? | SELECT Studio, COUNT(*) as GameCount FROM GameDesign GROUP BY Studio; | gretelai_synthetic_text_to_sql |
CREATE TABLE songs (id INT, title VARCHAR(255), duration INT, artist VARCHAR(255)); INSERT INTO songs (id, title, duration, artist) VALUES (1, 'Song 1', 180, 'Artist B'); | What is the total duration of all songs by 'Artist B'? | SELECT SUM(duration) FROM songs WHERE artist = 'Artist B'; | gretelai_synthetic_text_to_sql |
CREATE TABLE players (id INT, age INT, game_genre VARCHAR(20)); INSERT INTO players (id, age, game_genre) VALUES (1, 25, 'racing'), (2, 30, 'rpg'), (3, 22, 'racing'), (4, 35, 'strategy'); | What is the most popular game genre among players under 30? | SELECT game_genre, COUNT(*) as count FROM players WHERE age < 30 GROUP BY game_genre ORDER BY count DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE students (id INT PRIMARY KEY, name VARCHAR(50), country VARCHAR(50), registration_date DATE); | Delete the record for the student "Sofia Garcia" from the "students" table | DELETE FROM students WHERE name = 'Sofia Garcia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE solana_network (digital_asset_name TEXT, digital_asset_classification TEXT); | Identify the number of digital assets with a 'stablecoin' classification in the 'Solana' network. | SELECT digital_asset_classification, COUNT(*) as count FROM solana_network WHERE digital_asset_classification = 'stablecoin' GROUP BY digital_asset_classification; | gretelai_synthetic_text_to_sql |
CREATE TABLE virtual_tours (tour_id INT, country TEXT, bookings INT); INSERT INTO virtual_tours (tour_id, country, bookings) VALUES (1, 'France', 5000), (2, 'Germany', 7000); | What is the total number of virtual tours booked in France and Germany? | SELECT SUM(bookings) FROM virtual_tours WHERE country IN ('France', 'Germany'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Departments (DepartmentID INT PRIMARY KEY, DepartmentName VARCHAR(50)); CREATE TABLE UniversityDepartments (UniversityDepartmentID INT PRIMARY KEY, DepartmentID INT, BudgetForDisabilityAccommodations DECIMAL(10,2), NumberOfStudentsWithDisabilities INT, FOREIGN KEY (DepartmentID) REFERENCES Departments(Depa... | What is the total budget for disability accommodations in departments with more than 500 students with disabilities? | SELECT SUM(BudgetForDisabilityAccommodations) as TotalBudget FROM UniversityDepartments WHERE NumberOfStudentsWithDisabilities > 500; | gretelai_synthetic_text_to_sql |
CREATE TABLE wells (id INT, name VARCHAR(255), location VARCHAR(255), owner VARCHAR(255), production_quantity INT); INSERT INTO wells (id, name, location, owner, production_quantity) VALUES (1, 'Well A', 'North Sea', 'Acme Oil', 1000), (2, 'Well B', 'Gulf of Mexico', 'Big Oil', 2000), (3, 'Well C', 'North Sea', 'Acme O... | What is the maximum production quantity for wells located in the 'Gulf of Mexico' and owned by 'Other Oil'? | SELECT MAX(production_quantity) FROM wells WHERE location = 'Gulf of Mexico' AND owner = 'Other Oil'; | gretelai_synthetic_text_to_sql |
CREATE TABLE fishing_vessels (id INT, name VARCHAR(255), location VARCHAR(255), length FLOAT); INSERT INTO fishing_vessels (id, name, location, length) VALUES (1, 'Indian Ocean Tuna Fleet', 'Indian Ocean', 500); INSERT INTO fishing_vessels (id, name, location, length) VALUES (2, 'South Pacific Squid Fleet', 'Pacific Oc... | What is the total number of fishing vessels in the Indian, Pacific, and Southern Oceans? | SELECT SUM(length) FROM fishing_vessels WHERE location IN ('Indian Ocean', 'Pacific Ocean', 'Southern Ocean'); | gretelai_synthetic_text_to_sql |
CREATE TABLE mobile_customers (customer_id INT, data_usage FLOAT, state VARCHAR(20)); INSERT INTO mobile_customers (customer_id, data_usage, state) VALUES (1, 3.5, 'New York'), (2, 6.2, 'New York'), (3, 4.8, 'Texas'); | How many mobile customers have a data usage over 5GB in the state of New York? | SELECT COUNT(*) FROM mobile_customers WHERE data_usage > 5 AND state = 'New York'; | gretelai_synthetic_text_to_sql |
CREATE TABLE budget_allocation (department TEXT, year INT, allocation DECIMAL(10,2)); | Insert a new record of budget allocation for the 'Healthcare' department for the year 2024 | INSERT INTO budget_allocation (department, year, allocation) VALUES ('Healthcare', 2024, 700000.00); | gretelai_synthetic_text_to_sql |
CREATE TABLE habitat_preservation (id INT, animal_name VARCHAR(50), population INT, endangered_status VARCHAR(50)); | What is the difference in population between animals in the 'habitat_preservation' table that are endangered and those that are not? | SELECT SUM(CASE WHEN endangered_status = 'Endangered' THEN population ELSE 0 END) - SUM(CASE WHEN endangered_status != 'Endangered' THEN population ELSE 0 END) FROM habitat_preservation; | gretelai_synthetic_text_to_sql |
CREATE TABLE mobile_customers (customer_id INT, plan_type VARCHAR(10), data_usage FLOAT, region VARCHAR(20)); INSERT INTO mobile_customers (customer_id, plan_type, data_usage, region) VALUES (1, 'postpaid', 3.5, 'Chicago'), (2, 'prepaid', 2.0, 'Chicago'); CREATE TABLE regions (region VARCHAR(20), avg_data_usage FLOAT); | What is the average monthly data usage for postpaid mobile customers in the Chicago region? | SELECT AVG(m.data_usage) FROM mobile_customers m JOIN regions r ON m.region = r.region WHERE m.plan_type = 'postpaid' AND r.region = 'Chicago'; | gretelai_synthetic_text_to_sql |
CREATE TABLE military_equipment (id INT, name VARCHAR(50), status VARCHAR(50), region VARCHAR(50)); INSERT INTO military_equipment (id, name, status, region) VALUES (1, 'Tank A', 'To be maintained', 'Pacific'), (2, 'Helicopter B', 'Operational', 'Atlantic'); | What is the total number of military equipment items that need maintenance in the Pacific region? | SELECT SUM(CASE WHEN region = 'Pacific' AND status = 'To be maintained' THEN 1 ELSE 0 END) as total_maintenance_needed FROM military_equipment; | gretelai_synthetic_text_to_sql |
CREATE TABLE waste_generation (id INT, country VARCHAR(50), year INT, total_waste_gen FLOAT); | Get the total waste generation for 'South America' in 2018 and 2019 from the 'waste_generation' table | SELECT year, SUM(total_waste_gen) FROM waste_generation WHERE year IN (2018, 2019) AND country = 'South America' GROUP BY year; | gretelai_synthetic_text_to_sql |
CREATE TABLE Farmers (FarmerID INT, FarmerName TEXT, Location TEXT); INSERT INTO Farmers (FarmerID, FarmerName, Location) VALUES (2, 'Nguyen Van A', 'Mekong Delta'); CREATE TABLE Production (ProductID INT, FarmerID INT, Product TEXT, Quantity INT); INSERT INTO Production (ProductID, FarmerID, Product, Quantity) VALUES ... | What is the total production of 'Rice' by each farmer in 'Mekong Delta'? | SELECT Farmers.FarmerName, SUM(Production.Quantity) as TotalRiceProduction FROM Farmers INNER JOIN Production ON Farmers.FarmerID = Production.FarmerID WHERE Production.Product = 'Rice' AND Farmers.Location = 'Mekong Delta' GROUP BY Farmers.FarmerName; | gretelai_synthetic_text_to_sql |
CREATE TABLE CommunityDevelopment (InitiativeID INT, Name VARCHAR(50), Location VARCHAR(50), Budget DECIMAL(10,2)); INSERT INTO CommunityDevelopment (InitiativeID, Name, Location, Budget) VALUES (1, 'Clean Water Access', 'Andean Region', 50000); INSERT INTO CommunityDevelopment (InitiativeID, Name, Location, Budget) VA... | How many community development initiatives have been implemented in the Andean region, and what is the average budget for those initiatives? | SELECT COUNT(*), AVG(Budget) FROM CommunityDevelopment WHERE Location = 'Andean Region'; | gretelai_synthetic_text_to_sql |
CREATE TABLE on_co2_emission_reduction (id INT, program_id VARCHAR(255), province VARCHAR(255), target_reduction INT, actual_reduction INT); | What is the total CO2 emission reduction (in metric tons) for carbon offset programs in the province of Ontario that have a target reduction of at least 50,000 metric tons? | SELECT SUM(actual_reduction) FROM on_co2_emission_reduction WHERE province = 'Ontario' AND target_reduction >= 50000; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (DonationID int, Amount decimal(10,2), PaymentMethod varchar(50), DonationDate date, Category varchar(50)); INSERT INTO Donations (DonationID, Amount, PaymentMethod, DonationDate, Category) VALUES (1, 50.00, 'Credit Card', '2021-01-01', 'Education'); | Which categories received the most funding from donations in 2021? | SELECT Category, SUM(Amount) as TotalDonationAmount FROM Donations WHERE YEAR(DonationDate) = 2021 GROUP BY Category ORDER BY TotalDonationAmount DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE transaction (id INT, client_id INT, transaction_date DATE, amount DECIMAL(10, 2)); INSERT INTO transaction (id, client_id, transaction_date, amount) VALUES (1, 1, '2022-03-15', 500.00), (2, 3, '2022-03-16', 1000.00); | List all transactions made by clients in Tokyo on March 15, 2022. | SELECT * FROM transaction WHERE transaction_date = '2022-03-15' AND client_id IN (SELECT id FROM client WHERE address LIKE 'Tokyo%'); | gretelai_synthetic_text_to_sql |
CREATE TABLE crops (country VARCHAR(50), crop_yield INT); INSERT INTO crops (country, crop_yield) VALUES ('US', 5000), ('China', 8000), ('India', 7000), ('Brazil', 6000); | Find the top 2 countries with the highest total crop yield, along with the total yield for each. | SELECT country, SUM(crop_yield) OVER (PARTITION BY country) AS total_yield FROM crops ORDER BY total_yield DESC FETCH FIRST 2 ROWS ONLY; | gretelai_synthetic_text_to_sql |
CREATE TABLE PolicyAdvocacy (ProgramID INT, ProgramName VARCHAR(50), Year INT, Budget DECIMAL(10,2)); | What is the total budget spent on policy advocacy efforts for students with hearing impairments from 2018-2020? | SELECT SUM(Budget) FROM PolicyAdvocacy WHERE DisabilityType = 'hearing impairment' AND Year BETWEEN 2018 AND 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE regions (region_id INT, region_name VARCHAR(50), state_abbr CHAR(2)); INSERT INTO regions VALUES (1, 'Northeast', 'NY'), (2, 'Southwest', 'TX'); CREATE TABLE disease_reports (report_id INT, report_date DATE, region_id INT, disease_name VARCHAR(50), cases INT); INSERT INTO disease_reports VALUES (1, '2020-0... | How many infectious disease cases were reported in each region in 2020? | SELECT r.region_name, YEAR(dr.report_date) AS year, SUM(dr.cases) AS total_cases FROM regions r JOIN disease_reports dr ON r.region_id = dr.region_id WHERE YEAR(dr.report_date) = 2020 GROUP BY r.region_name; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists biosensor;CREATE TABLE if not exists biosensor.technologies (id INT, name VARCHAR(50), rd_investment DECIMAL(10, 2)); INSERT INTO biosensor.technologies (id, name, rd_investment) VALUES (1, 'BioSensor1', 3000000.00), (2, 'BioSensor2', 2500000.00), (3, 'BioSensor3', 2000000.00), (4, 'BioSenso... | List the top 2 biosensor technologies by R&D investment in ascending order. | SELECT * FROM biosensor.technologies ORDER BY rd_investment ASC LIMIT 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE veteran_employment (state TEXT, veteran_count INT, total_employees INT); INSERT INTO veteran_employment (state, veteran_count, total_employees) VALUES ('California', 15000, 50000), ('Texas', 12000, 40000), ('Florida', 10000, 35000), ('New York', 9000, 45000), ('Virginia', 18000, 55000); | Calculate the percentage of veteran employment in the defense industry by state | SELECT state, (veteran_count::FLOAT / total_employees) * 100 AS percentage FROM veteran_employment; | gretelai_synthetic_text_to_sql |
CREATE TABLE hospitals (name VARCHAR(50), year INT, beds INT); INSERT INTO hospitals (name, year, beds) VALUES ('Hospital A', 2018, 500); INSERT INTO hospitals (name, year, beds) VALUES ('Hospital B', 2018, 600); | List the names of all hospitals and their corresponding number of beds in the state of New York for the year 2018. | SELECT name, beds FROM hospitals WHERE year = 2018; | gretelai_synthetic_text_to_sql |
CREATE TABLE peacekeeping_operations (operation_id INT, country VARCHAR(50), num_personnel INT); INSERT INTO peacekeeping_operations (operation_id, country, num_personnel) VALUES (1, 'Brazil', 500), (2, 'Canada', 700), (3, 'Argentina', 350); CREATE TABLE countries (country VARCHAR(50), population INT); INSERT INTO coun... | What is the total number of military personnel involved in peacekeeping operations by country? | SELECT co.country, SUM(pko.num_personnel) as total_personnel FROM peacekeeping_operations pko JOIN countries co ON pko.country = co.country GROUP BY co.country; | gretelai_synthetic_text_to_sql |
CREATE TABLE incidents(id INT, region VARCHAR(255), incident_count INT, date DATE); INSERT INTO incidents(id, region, incident_count, date) VALUES (1, 'North', 20, '2021-09-01'), (2, 'South', 10, '2021-09-01'), (3, 'East', 15, '2021-09-01'), (4, 'North', 25, '2021-09-02'), (5, 'South', 12, '2021-09-02'), (6, 'East', 18... | How many security incidents were there per day in the last week for each region? | SELECT date, region, SUM(incident_count) as total_incidents FROM incidents WHERE date >= DATE_SUB(CURRENT_DATE(), INTERVAL 1 WEEK) GROUP BY date, region; | gretelai_synthetic_text_to_sql |
CREATE TABLE FDARecalls (id INT, recallId INT, item VARCHAR(50), recallDate DATE, containsAllergens BOOLEAN); | How many food recalls have been issued by the FDA in the past month for items containing allergens? | SELECT COUNT(*) FROM FDARecalls WHERE containsAllergens = TRUE AND recallDate >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE exhibitions (exhibition_id INT PRIMARY KEY, exhibition_name VARCHAR(255), city VARCHAR(255), visitor_count INT); | Delete the exhibition with the lowest number of visitors | DELETE FROM exhibitions WHERE exhibition_id IN (SELECT exhibition_id FROM (SELECT exhibition_id, MIN(visitor_count) as min_visitor_count FROM exhibitions GROUP BY exhibition_id) exhibition_visitor_count WHERE visitor_count = min_visitor_count); | gretelai_synthetic_text_to_sql |
CREATE TABLE Factories (id INT, location VARCHAR, workers INT); CREATE VIEW VulnerableRegions AS SELECT * FROM Regions WHERE risk_level > 3; | List the number of workers in factories located in vulnerable regions. | SELECT COUNT(Factories.workers) FROM Factories INNER JOIN VulnerableRegions ON Factories.location = VulnerableRegions.region; | gretelai_synthetic_text_to_sql |
CREATE TABLE public_transportation (project_name TEXT, project_type TEXT, project_state TEXT); INSERT INTO public_transportation (project_name, project_type, project_state) VALUES ('PTP1', 'Subway', 'New York'), ('PTP2', 'Bus', 'New York'), ('PTP3', 'Light Rail', 'New York'), ('PTP4', 'Ferry', 'New York'); | What is the total number of public transportation projects in New York? | SELECT COUNT(*) FROM public_transportation WHERE project_state = 'New York' AND project_type = 'Subway' AND project_type = 'Bus' AND project_type = 'Light Rail' AND project_type = 'Ferry'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Volunteers (VolunteerID INT, JoinDate DATE, Region VARCHAR(50)); | How many volunteers joined in the last 3 months by region? | SELECT COUNT(*) as NumVolunteers, v.Region FROM Volunteers v WHERE v.JoinDate >= DATE_SUB(CURDATE(), INTERVAL 3 MONTH) GROUP BY v.Region; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species_observations (id INT, species TEXT, observation_date DATE, region TEXT); INSERT INTO marine_species_observations (id, species, observation_date, region) VALUES (1, 'Whale Shark', '2021-03-04', 'Indian Ocean'), (2, 'Dolphin', '2021-06-17', 'Mediterranean Sea'), (3, 'Turtle', '2020-12-29', 'Ca... | Which marine species have been observed in the Indian Ocean? | SELECT DISTINCT species FROM marine_species_observations WHERE region = 'Indian Ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Nonprofits (NonprofitID INT, Name VARCHAR(50), City VARCHAR(50), State VARCHAR(2), Zip VARCHAR(10), MissionStatement TEXT); CREATE TABLE Grants (GrantID INT, DonorID INT, NonprofitID INT, GrantAmount DECIMAL(10,2), Date DATE); | How many grants were given in each state? | SELECT State, COUNT(*) FROM Nonprofits N INNER JOIN Grants G ON N.NonprofitID = G.NonprofitID GROUP BY State; | gretelai_synthetic_text_to_sql |
CREATE TABLE WasteGenerationAmericas (id INT, country VARCHAR(50), region VARCHAR(50), generation_rate FLOAT); INSERT INTO WasteGenerationAmericas (id, country, region, generation_rate) VALUES (1, 'USA', 'Americas', 35.1), (2, 'Mexico', 'Americas', 29.6), (3, 'Canada', 'Americas', 37.6); | Delete records of waste generation in the Americas with generation rate less than 30. | DELETE FROM WasteGenerationAmericas WHERE region = 'Americas' AND generation_rate < 30; | gretelai_synthetic_text_to_sql |
CREATE TABLE social_equity_trends (location VARCHAR(255), equity_index DECIMAL(4,2), date DATE); | Update the equity_index column in the social_equity_trends table for records where the location is 'Atlanta, GA' and the date is after '2022-01-01' to a value of '0.85' | WITH cte1 AS (UPDATE social_equity_trends SET equity_index = 0.85 WHERE location = 'Atlanta, GA' AND date > '2022-01-01') SELECT * FROM cte1; | gretelai_synthetic_text_to_sql |
CREATE TABLE south_america_tourists (id INT, country TEXT, museum_visits INT); INSERT INTO south_america_tourists VALUES (1, 'Brazil', 2000), (2, 'Argentina', 3000); CREATE TABLE north_america_tourists (id INT, country TEXT, museum_visits INT); INSERT INTO north_america_tourists VALUES (1, 'USA', 5000), (2, 'Canada', 4... | What is the percentage of international tourists visiting museums in South America compared to North America? | SELECT 100.0 * SUM(museum_visits) / (SELECT SUM(museum_visits) FROM north_america_tourists) FROM south_america_tourists | gretelai_synthetic_text_to_sql |
CREATE TABLE media_literacy_workshops (id INT, country VARCHAR(50), city VARCHAR(50), date DATE, attendance INT); | Insert new records of media literacy workshops in the USA. | INSERT INTO media_literacy_workshops (id, country, city, date, attendance) VALUES (1, 'USA', 'New York', '2022-06-01', 50), (2, 'USA', 'Los Angeles', '2022-06-15', 75); | gretelai_synthetic_text_to_sql |
CREATE TABLE threat_intelligence (threat_id INT, threat_level VARCHAR(50), report_date DATE); | Delete records in the threat_intelligence table where the 'threat_level' is 'High' and 'report_date' is older than 2020-12-31 | DELETE FROM threat_intelligence WHERE threat_level = 'High' AND report_date < '2020-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE physicians_rural (id INTEGER, specialty VARCHAR(255), location VARCHAR(255)); | What is the ratio of primary care physicians to specialists in rural areas? | SELECT (COUNT(*) FILTER (WHERE specialty = 'Primary Care')) / COUNT(*) AS ratio FROM physicians_rural WHERE location LIKE '%rural%'; | 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); INSERT INTO directors (id, name, gender) VALUES (1, 'Director1', 'Female'), (2, 'Director2', 'Male'), (3, 'Director3', 'Female'); INSERT INTO movies_directors (movie_id, director_id) VA... | How many female directors have created movies in the database? | SELECT COUNT(*) FROM directors WHERE gender = 'Female'; | gretelai_synthetic_text_to_sql |
CREATE TABLE SpacecraftManufacturing (manufacturer VARCHAR(255), spacecraft_name VARCHAR(255), mass FLOAT, launch_date DATE); INSERT INTO SpacecraftManufacturing (manufacturer, spacecraft_name, mass, launch_date) VALUES ('ISRO', 'Chandrayaan-1', 1380, '2008-10-22'), ('ISRO', 'Mangalyaan', 1350, '2013-11-05'), ('ISRO', ... | What is the heaviest spacecraft launched by ISRO? | SELECT spacecraft_name, mass FROM SpacecraftManufacturing WHERE manufacturer = 'ISRO' ORDER BY mass DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE customers (customer_id INT, name VARCHAR(50), geographic_area VARCHAR(20)); INSERT INTO customers (customer_id, name, geographic_area) VALUES (1, 'John Doe', 'rural'); CREATE TABLE mobile_data_usage (customer_id INT, month INT, data_usage INT); INSERT INTO mobile_data_usage (customer_id, month, data_usage)... | What is the average monthly mobile data usage for customers in the 'rural' geographic area? | SELECT AVG(data_usage) FROM mobile_data_usage JOIN customers ON mobile_data_usage.customer_id = customers.customer_id WHERE customers.geographic_area = 'rural'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Events (EventID INT, Name VARCHAR(100), Country VARCHAR(50), Participants INT); INSERT INTO Events (EventID, Name, Country, Participants) VALUES (1, 'Event1', 'USA', 500), (2, 'Event2', 'Canada', 400), (3, 'Event3', 'England', 600), (4, 'Event4', 'France', 300), (5, 'Event5', 'USA', 700); | Find the top 3 countries with the highest number of esports event participants. | SELECT Country, Participants FROM Events ORDER BY Participants DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE indian_ocean_fish_farm (date DATE, biomass FLOAT); | What is the maximum biomass of fish in the Indian Ocean Fish Farm for each month? | SELECT EXTRACT(MONTH FROM date) AS month, MAX(biomass) AS max_biomass FROM indian_ocean_fish_farm GROUP BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE GarmentMaterials (GarmentID INT, SupplierName TEXT, Material TEXT); INSERT INTO GarmentMaterials (GarmentID, SupplierName, Material) VALUES (201, 'FairTradeFashions', 'Cotton'), (202, 'FairTradeFashions', 'Silk'), (203, 'FairTradeFashions', 'Polyester'), (204, 'FairTradeFashions', 'Rayon'), (205, 'FairTrad... | How many garments in 'FairTradeFashions' collection are not made of synthetic materials? | SELECT COUNT(*) FROM GarmentMaterials WHERE SupplierName = 'FairTradeFashions' AND Material NOT IN ('Polyester', 'Rayon'); | gretelai_synthetic_text_to_sql |
CREATE TABLE weightlifting_records (athlete VARCHAR(50), performance FLOAT, best_date DATE); | List the names of athletes who have set a personal best in the weightlifting_records dataset, in descending order by best performance date. | SELECT athlete FROM weightlifting_records WHERE performance = (SELECT MAX(performance) FROM weightlifting_records GROUP BY athlete) ORDER BY best_date DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE exploitation_attempts (id INT, ip_address VARCHAR(255), vulnerability_id INT, attempts INT, success BOOLEAN); INSERT INTO exploitation_attempts (id, ip_address, vulnerability_id, attempts, success) VALUES (1, '192.168.1.1', 1, 5, true), (2, '192.168.1.1', 2, 3, false), (3, '192.168.2.1', 1, 10, true); | How many unique IP addresses attempted to exploit vulnerabilities in the last week for the IT department? | SELECT COUNT(DISTINCT ip_address) FROM exploitation_attempts WHERE exploitation_attempts.exploitation_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK) AND department = 'IT'; | gretelai_synthetic_text_to_sql |
CREATE TABLE unions (id INT, has_cba BOOLEAN); CREATE TABLE workers (id INT, union_id INT, salary DECIMAL(10,2)); | What is the minimum and maximum salary for workers in unions that have collective bargaining agreements? | SELECT MIN(workers.salary), MAX(workers.salary) FROM workers JOIN unions ON workers.union_id = unions.id WHERE unions.has_cba = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE news_articles (article_id INT, author_name VARCHAR(50), title VARCHAR(100), published_date DATE, topic_list VARCHAR(200)); | Show the number of unique news topics covered by articles in the 'news_articles' table | SELECT COUNT(DISTINCT trim(SPLIT_PART(topic_list, ',', n))) as unique_topics FROM news_articles, generate_series(1, ARRAY_LENGTH(string_to_array(topic_list, ','))) as n(n); | gretelai_synthetic_text_to_sql |
CREATE TABLE airports (id INT, name TEXT, location TEXT, length INT, type TEXT, year INT); INSERT INTO airports (id, name, location, length, type, year) VALUES (1, 'LAX', 'Los Angeles, CA', 12157, 'International', 1928); INSERT INTO airports (id, name, location, length, type, year) VALUES (2, 'SFO', 'San Francisco, CA'... | Which airports and their corresponding lengths are located in California and were constructed before 1970? | SELECT name, location, length FROM airports WHERE location LIKE '%CA%' AND type = 'International' AND year < 1970; | gretelai_synthetic_text_to_sql |
CREATE TABLE departments (id INT, name TEXT, manager TEXT, salary FLOAT); INSERT INTO departments (id, name, manager, salary) VALUES (1, 'manufacturing', 'John Doe', 60000.0), (2, 'engineering', 'Mike Johnson', NULL); CREATE TABLE employees (id INT, name TEXT, department TEXT, salary FLOAT); INSERT INTO employees (id, ... | Update the salary of the 'engineering' department manager to $70,000. | WITH cte AS (UPDATE departments SET salary = 70000.0 WHERE name = 'engineering' AND manager IS NOT NULL RETURNING manager) UPDATE employees SET salary = (SELECT salary FROM cte) WHERE name = (SELECT manager FROM cte); | gretelai_synthetic_text_to_sql |
CREATE TABLE EnvironmentalImpact (Site VARCHAR(255), CO2Emissions INT, WaterUsage INT, WasteGeneration INT, ReportDate DATE, Country VARCHAR(255)); | What is the maximum water usage per site for Indian mining operations in 2020? | SELECT Site, MAX(WaterUsage) as MaxWaterUsage FROM EnvironmentalImpact WHERE ReportDate BETWEEN '2020-01-01' AND '2020-12-31' AND Country = 'India' GROUP BY Site; | gretelai_synthetic_text_to_sql |
CREATE TABLE smart_contracts (contract_id INT, network VARCHAR(255), last_updated DATE); INSERT INTO smart_contracts (contract_id, network, last_updated) VALUES (1, 'cardano', '2022-01-01'), (2, 'solana', '2021-12-31'); | How many smart contracts were updated in the 'cardano' and 'solana' networks? | SELECT COUNT(*) FROM smart_contracts WHERE network IN ('cardano', 'solana'); | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT PRIMARY KEY, name VARCHAR(50), age INT, gender VARCHAR(10), location VARCHAR(50)); INSERT INTO users (id, name, age, gender, location) VALUES (1, 'Maria', 28, 'Female', 'Brazil'); INSERT INTO users (id, name, age, gender, location) VALUES (2, 'Joao', 35, 'Male', 'Brazil'); INSERT INTO users (... | How many users are there in each country? | SELECT users.location, COUNT(users.id) FROM users GROUP BY users.location; | gretelai_synthetic_text_to_sql |
CREATE TABLE engineers (id INT, name VARCHAR(50), specialty VARCHAR(50), location VARCHAR(50), years_of_experience INT); | Identify bioprocess engineers in specific locations. | SELECT name FROM engineers WHERE specialty = 'bioprocess' AND location IN ('San Francisco', 'Boston'); | gretelai_synthetic_text_to_sql |
CREATE TABLE mlb_players (player_name VARCHAR(100), country VARCHAR(50), home_runs INT); INSERT INTO mlb_players VALUES ('Hideki Matsui', 'Japan', 175), ('Ichiro Suzuki', 'Japan', 117), ('Masahiro Tanaka', 'Japan', 1), ('Shohei Ohtani', 'Japan', 71); | Who has the highest number of career home runs among players from Japan in Major League Baseball? | SELECT player_name, home_runs FROM mlb_players WHERE country = 'Japan' ORDER BY home_runs DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE hydro_plants (name VARCHAR(255), capacity FLOAT); INSERT INTO hydro_plants (name, capacity) VALUES ('Plant1', 1200.5), ('Plant2', 1800.2), ('Plant3', 2400.9); | What is the average capacity of hydroelectric power plants? | SELECT AVG(capacity) FROM hydro_plants; | gretelai_synthetic_text_to_sql |
CREATE TABLE cultivation (id INT, state TEXT, plant_count INT, plant_weight DECIMAL, cultivation_date DATE); | How many cannabis plants were cultivated in Oregon in the last quarter and what was their total weight? | SELECT state, SUM(plant_weight) as total_weight FROM cultivation WHERE state = 'Oregon' AND cultivation_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH) GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE daily_emergency_calls (date DATE, neighborhood VARCHAR(20), calls INT); INSERT INTO daily_emergency_calls (date, neighborhood, calls) VALUES ('2022-04-01', 'southeast', 40), ('2022-04-02', 'southeast', 45), ('2022-04-03', 'southeast', 50); INSERT INTO daily_emergency_calls (date, neighborhood, calls) VALUE... | What is the maximum number of emergency calls received in the "southeast" neighborhood in a single day? | SELECT MAX(calls) FROM daily_emergency_calls WHERE neighborhood = 'southeast'; | gretelai_synthetic_text_to_sql |
CREATE TABLE warehouse_management (item_id INT, warehouse_id INT, cost FLOAT, order_date DATE); | What is the average warehouse management cost per item for each warehouse in Q3 2021? | SELECT warehouse_id, AVG(cost/COUNT(*)) as avg_cost_per_item FROM warehouse_management WHERE EXTRACT(MONTH FROM order_date) BETWEEN 7 AND 9 GROUP BY warehouse_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE faculty (id INT, name TEXT);CREATE TABLE research_grant (id INT, faculty_id INT, amount INT, year INT); | What is the total amount of research grants awarded to faculty members in the last 2 years? | SELECT SUM(rg.amount) FROM research_grant rg WHERE rg.year BETWEEN YEAR(CURRENT_DATE) - 2 AND YEAR(CURRENT_DATE); | gretelai_synthetic_text_to_sql |
CREATE TABLE virtual_tours_top (id INT, engagement_rate FLOAT, engagement_time INT); INSERT INTO virtual_tours_top (id, engagement_rate, engagement_time) VALUES (1, 0.15, 700), (2, 0.13, 800); | What is the engagement rate and engagement time for the top 2 virtual tours? | SELECT id, engagement_rate, engagement_time FROM virtual_tours_top WHERE row_number() OVER (ORDER BY engagement_rate DESC) <= 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE concerts (city VARCHAR(50), revenue INT); INSERT INTO concerts (city, revenue) VALUES ('New York', 50000), ('Los Angeles', 75000), ('Chicago', 60000); | What was the total revenue for each concert by city? | SELECT city, SUM(revenue) FROM concerts GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE UrbanAgriProject (id INT, region VARCHAR(50)); INSERT INTO UrbanAgriProject (id, region) VALUES (1, 'Asia'); INSERT INTO UrbanAgriProject (id, region) VALUES (2, 'Oceania'); | Find the number of urban agriculture projects in Asia and Oceania, excluding any common projects between the two regions. | SELECT COUNT(DISTINCT CASE WHEN region = 'Asia' THEN id END) + COUNT(DISTINCT CASE WHEN region = 'Oceania' THEN id END) - COUNT(DISTINCT CASE WHEN region IN ('Asia', 'Oceania') THEN id END) FROM UrbanAgriProject; | gretelai_synthetic_text_to_sql |
CREATE TABLE factories (factory_id INT, factory_name TEXT, country TEXT); INSERT INTO factories (factory_id, factory_name, country) VALUES (1, 'Organic Textile Co', 'India'), (2, 'Eco-Friendly Fashion', 'India'); CREATE TABLE garments (garment_id INT, garment_name TEXT, production_cost FLOAT, factory_id INT); INSERT IN... | What is the average production cost of organic cotton garments across all factories in India? | SELECT AVG(g.production_cost) FROM garments g JOIN factories f ON g.factory_id = f.factory_id WHERE f.country = 'India' AND g.garment_name LIKE '%Organic Cotton%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE areas (name text, type text); INSERT INTO areas VALUES ('Urban', 'CityA'), ('Suburban', 'CityB'), ('Rural', 'CityC'), ('Rural', 'CityD'); CREATE TABLE schools (name text, area_type text); INSERT INTO schools VALUES ('School1', 'Urban'), ('School2', 'Rural'), ('School3', 'Suburban'); CREATE TABLE libraries ... | Identify the number of schools and libraries in rural areas, and calculate the ratio. | SELECT (SELECT COUNT(*) FROM schools WHERE area_type = 'Rural') / COUNT(DISTINCT area_type) AS rural_school_ratio, (SELECT COUNT(*) FROM libraries WHERE area_type = 'Rural') / COUNT(DISTINCT area_type) AS rural_library_ratio | gretelai_synthetic_text_to_sql |
CREATE TABLE reporters (id INT, name VARCHAR(50), gender VARCHAR(10), age INT, position VARCHAR(20), country VARCHAR(50)); INSERT INTO reporters (id, name, gender, age, position, country) VALUES (1, 'Anna Smith', 'Female', 35, 'News Reporter', 'USA'); INSERT INTO reporters (id, name, gender, age, position, country) VAL... | Which countries have more than 50 investigative journalists? | SELECT country, COUNT(*) FROM reporters WHERE position = 'Investigative Journalist' GROUP BY country HAVING COUNT(*) > 50; | gretelai_synthetic_text_to_sql |
CREATE TABLE waste_generation(city VARCHAR(20), material VARCHAR(20), quantity INT); INSERT INTO waste_generation VALUES('Sao Paulo', 'Plastic', 12000), ('Sao Paulo', 'Paper', 18000), ('Sao Paulo', 'Glass', 8000); | Find the total waste generation by material type in Sao Paulo in 2020. | SELECT material, SUM(quantity) as total_waste FROM waste_generation WHERE city = 'Sao Paulo' AND YEAR(event_date) = 2020 GROUP BY material; | gretelai_synthetic_text_to_sql |
CREATE TABLE student (id INT, name VARCHAR(50), program VARCHAR(50)); CREATE TABLE publication (id INT, title VARCHAR(100), journal_name VARCHAR(50), impact_factor DECIMAL(3,1)); | What are the names of graduate students who have published in journals with the highest impact factors? | SELECT s.name FROM student s JOIN publication p ON s.id IN (SELECT student_id FROM grant WHERE title IN (SELECT title FROM publication WHERE impact_factor = (SELECT MAX(impact_factor) FROM publication))); | gretelai_synthetic_text_to_sql |
CREATE TABLE menu_orders (id INT PRIMARY KEY, menu_item VARCHAR(255), order_count INT); | Create a view to show the number of times each menu item has been ordered | CREATE VIEW menu_orders_view AS SELECT menu_item, SUM(order_count) as total_orders FROM menu_orders GROUP BY menu_item; | gretelai_synthetic_text_to_sql |
CREATE TABLE waste_production (plant varchar(20), waste_amount int, date date); | Delete the records of waste production for the 'South' plant in January 2022. | DELETE FROM waste_production WHERE plant = 'South' AND date = '2022-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE digital_assets_binance (asset_id INT, asset_name VARCHAR(255), network VARCHAR(255)); INSERT INTO digital_assets_binance (asset_id, asset_name, network) VALUES (1, 'BNB', 'Binance Smart Chain'), (2, 'CAKE', 'Binance Smart Chain'); CREATE TABLE binance_transactions (transaction_id INT, asset_id INT, value D... | What is the maximum and minimum value of each digital asset on the Binance Smart Chain? | SELECT d.asset_name, MAX(t.value) as max_value, MIN(t.value) as min_value FROM digital_assets_binance d JOIN binance_transactions t ON d.asset_id = t.asset_id GROUP BY d.asset_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE ethics_violations (violation_id INT, story_id INT, description TEXT, violation_date DATE); | What is the total number of ethics violations in the 'ethics_violations' table? | SELECT COUNT(*) FROM ethics_violations; | gretelai_synthetic_text_to_sql |
CREATE TABLE menu_items (menu_item_id INT, name VARCHAR(255), description TEXT, price DECIMAL(5,2), category VARCHAR(255), sustainability_rating INT); | List all menu items with a price greater than $10.00 | SELECT * FROM menu_items WHERE price > 10.00; | gretelai_synthetic_text_to_sql |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.