context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE blocks (block_id INT, player_id INT, match_id INT, team_id INT, blocks INT); INSERT INTO blocks (block_id, player_id, match_id, team_id, blocks) VALUES (1, 9, 10, 601, 3); | Which volleyball player has the most blocks in the 'blocks' table? | SELECT player_id, MAX(blocks) FROM blocks; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (DonorID int, DonorType varchar(50), Country varchar(50), AmountDonated numeric(18,2), DonationDate date); INSERT INTO Donors (DonorID, DonorType, Country, AmountDonated, DonationDate) VALUES (1, 'Organization', 'Australia', 12000, '2022-01-01'), (2, 'Individual', 'New Zealand', 5000, '2022-02-01'),... | What is the number of donations made by organizations in Oceania in each quarter of 2022? | SELECT YEAR(DonationDate) as Year, QUARTER(DonationDate) as Quarter, COUNT(*) as NumberOfDonations FROM Donors WHERE DonorType = 'Organization' AND Country LIKE 'Oceania%' AND YEAR(DonationDate) = 2022 GROUP BY Year, Quarter; | gretelai_synthetic_text_to_sql |
CREATE TABLE players (player_id INT, name VARCHAR(50), age INT, position VARCHAR(50), team_id INT); INSERT INTO players (player_id, name, age, position, team_id) VALUES (1, 'Jane Smith', 30, 'Defenseman', 301); | Who is the oldest ice hockey player in the 'players' table? | SELECT name, age FROM players ORDER BY age DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE ai_safety_papers (year INT, num_papers INT); INSERT INTO ai_safety_papers (year, num_papers) VALUES ('2015', '50'); | What is the trend of AI safety research papers published by year? | SELECT year, num_papers, LAG(num_papers) OVER (ORDER BY year) as prev_year_num_papers FROM ai_safety_papers; | gretelai_synthetic_text_to_sql |
CREATE TABLE broadband_plans (plan_id INT, plan_name VARCHAR(50), download_speed INT, upload_speed INT, monthly_cost DECIMAL(5,2)); | Insert a new broadband plan into the broadband_plans table | INSERT INTO broadband_plans (plan_id, plan_name, download_speed, upload_speed, monthly_cost) VALUES (67890, 'Giga Home', 1000, 500, 79.99); | gretelai_synthetic_text_to_sql |
CREATE TABLE RareEarthMines (country VARCHAR(20), element VARCHAR(20)); INSERT INTO RareEarthMines (country, element) VALUES ('Australia', 'Neodymium'), ('Australia', 'Praseodymium'); | How many rare earth elements are mined in Australia? | SELECT COUNT(*) FROM RareEarthMines WHERE country = 'Australia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Conservation_Project (Id INT, Project_Name VARCHAR(50), Location VARCHAR(50), Budget DECIMAL(10, 2)); INSERT INTO Conservation_Project (Id, Project_Name, Location, Budget) VALUES (1, 'Tiger_Project_1', 'India', 75000); INSERT INTO Conservation_Project (Id, Project_Name, Location, Budget) VALUES (2, 'Tiger_... | What is the total budget for tiger conservation projects in India? | SELECT SUM(Budget) FROM Conservation_Project WHERE Location = 'India' AND Animal_Type = 'Tiger'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Warehouse (id INT, city VARCHAR, capacity INT, region VARCHAR); INSERT INTO Warehouse (id, city, capacity, region) VALUES (1, 'London', 5000, 'EMEA'); INSERT INTO Warehouse (id, city, capacity, region) VALUES (2, 'Paris', 7000, 'EMEA'); | What is the total capacity of warehouses in the EMEA region, ranked by capacity? | SELECT region, SUM(capacity) as total_capacity, ROW_NUMBER() OVER(ORDER BY SUM(capacity) DESC) as rank FROM Warehouse GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE infrastructure_projects (city VARCHAR(50), project VARCHAR(50), budget INT); INSERT INTO infrastructure_projects (city, project, budget) VALUES ('New York', 'Subway Extension', 6000000); INSERT INTO infrastructure_projects (city, project, budget) VALUES ('Los Angeles', 'Light Rail Expansion', 7000000); INS... | Which cities in the 'infrastructure_projects' table have a budget over 5 million dollars? | SELECT city FROM infrastructure_projects WHERE budget > 5000000; | gretelai_synthetic_text_to_sql |
CREATE TABLE foia_requests (request_id INT, request_date DATE, request_state VARCHAR(255)); | How many Freedom of Information Act (FOIA) requests were submitted per state in 'foia_requests' table? | SELECT request_state, COUNT(request_id) AS foia_requests_per_state FROM foia_requests GROUP BY request_state; | gretelai_synthetic_text_to_sql |
CREATE TABLE Spending (Country VARCHAR(50), Region VARCHAR(50), Spending NUMERIC(18,2)); INSERT INTO Spending (Country, Region, Spending) VALUES ('United States', 'North America', 770000), ('Brazil', 'South America', 30000), ('Canada', 'North America', 25000), ('Argentina', 'South America', 15000), ('Colombia', 'South ... | Who are the top 3 countries with the highest military spending in the Americas? | SELECT Country, Spending FROM Spending WHERE Region = 'North America' OR Region = 'South America' ORDER BY Spending DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE Festivals (FestivalID INT, FestivalName VARCHAR(100), Country VARCHAR(50), TicketSales DECIMAL(10,2)); INSERT INTO Festivals (FestivalID, FestivalName, Country, TicketSales) VALUES (1, 'Coachella', 'USA', 3000000.00), (2, 'Glastonbury', 'UK', 2500000.00), (3, 'Splendour in the Grass', 'Australia', 1000000.... | Which music festivals had the highest ticket sales in Australia? | SELECT FestivalName, TicketSales FROM Festivals WHERE Country = 'Australia' ORDER BY TicketSales DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE ExhibitionDigitalEngagementTokyo (exhibition_id INT, city VARCHAR(50), digital_engagement INT); INSERT INTO ExhibitionDigitalEngagementTokyo (exhibition_id, city, digital_engagement) VALUES (1, 'Tokyo', 5000), (2, 'Tokyo', 7000), (3, 'Tokyo', 9000); | What is the maximum digital engagement for exhibitions in Tokyo? | SELECT MAX(digital_engagement) FROM ExhibitionDigitalEngagementTokyo; | gretelai_synthetic_text_to_sql |
CREATE TABLE workforce (id INT, name VARCHAR(50), gender VARCHAR(50), position VARCHAR(50), department VARCHAR(50)); INSERT INTO workforce (id, name, gender, position, department) VALUES (1, 'John Doe', 'Male', 'Engineer', 'Mining'), (2, 'Jane Smith', 'Female', 'Technician', 'Environment'), (3, 'Alice Johnson', 'Female... | What is the percentage of female employees in the mining industry? | SELECT (COUNT(CASE WHEN gender = 'Female' THEN 1 END) * 100.0 / COUNT(*)) as female_percentage FROM workforce; | gretelai_synthetic_text_to_sql |
CREATE TABLE cases (case_id INT, case_closed BOOLEAN); CREATE TABLE office (office_id INT, office_name VARCHAR(20)); INSERT INTO office (office_id, office_name) VALUES (1, 'boston'), (2, 'new_york'), (3, 'los_angeles'); | What is the percentage of cases closed in 'los_angeles'? | SELECT 100.0 * COUNT(*) / (SELECT COUNT(*) FROM cases JOIN attorney ON cases.attorney_id = attorney.attorney_id JOIN office ON attorney.office_id = office.office_id WHERE office.office_name = 'los_angeles') AS percentage_closed FROM cases JOIN attorney ON cases.attorney_id = attorney.attorney_id JOIN office ON attorney... | gretelai_synthetic_text_to_sql |
CREATE TABLE DonorCauses (DonorID int, Cause varchar(30)); INSERT INTO DonorCauses (DonorID, Cause) VALUES (1, 'Education'), (2, 'Health'), (3, 'Education'); | Which causes have the most number of donors? | SELECT Cause, COUNT(DonorID) AS DonorCount FROM DonorCauses GROUP BY Cause ORDER BY DonorCount DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE user_calories (user_id INT, date DATE, calories INT, avg_heart_rate INT); INSERT INTO user_calories (user_id, date, calories, avg_heart_rate) VALUES (1, '2022-03-15', 500, 120), (1, '2022-03-16', 600, 130), (1, '2022-03-17', 700, 140), (2, '2022-03-15', 800, 150), (2, '2022-03-16', 900, 160), (2, '2022-03-... | Find the top 3 users who have burned the most calories in the last week, and calculate their average heart rate during those workouts. | SELECT user_id, AVG(avg_heart_rate) as avg_heart_rate FROM (SELECT user_id, date, SUM(calories) as calories, AVG(avg_heart_rate) as avg_heart_rate FROM user_calories WHERE date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK) GROUP BY user_id, date ORDER BY calories DESC LIMIT 3) as temp; | gretelai_synthetic_text_to_sql |
CREATE TABLE articles_by_hour (id INT PRIMARY KEY, article_id INT, hour INT, date DATE, FOREIGN KEY (article_id) REFERENCES articles(id)); | What is the distribution of articles by hour for a specific day? | SELECT hour, COUNT(*) as total_articles FROM articles_by_hour WHERE date = '2022-01-01' GROUP BY hour; | gretelai_synthetic_text_to_sql |
CREATE TABLE manufacturers (id INT, name VARCHAR(255), eia_score FLOAT); INSERT INTO manufacturers (id, name, eia_score) VALUES (1, 'ABC Chemicals', 85.6), (2, 'XYZ Chemicals', 92.3), (3, 'DEF Chemicals', 78.9), (4, 'LMN Chemicals', 90.1), (5, 'PQR Chemicals', 80.5); | List the top 5 chemical manufacturers based on their environmental impact assessment scores. | SELECT name, eia_score FROM manufacturers ORDER BY eia_score DESC LIMIT 5 | gretelai_synthetic_text_to_sql |
CREATE TABLE chemical_table (chemical_id INT, chemical_name VARCHAR(50), safety_rating INT); | Insert a new record for a chemical named 'Ethyl Acetate' with a safety_rating of 5 | INSERT INTO chemical_table (chemical_name, safety_rating) VALUES ('Ethyl Acetate', 5); | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists 'disease_data' (id INT, state TEXT, disease TEXT, prevalence INT, PRIMARY KEY(id)); | Add a new disease to 'disease_data' | INSERT INTO 'disease_data' (id, state, disease, prevalence) VALUES (1, 'California', 'New Disease', 100); | gretelai_synthetic_text_to_sql |
CREATE TABLE Satellites (SatelliteID INT, Name VARCHAR(50), Manufacturer VARCHAR(50), LaunchDate DATE, Orbit VARCHAR(50), Altitude INT, Status VARCHAR(50)); INSERT INTO Satellites (SatelliteID, Name, Manufacturer, LaunchDate, Orbit, Altitude, Status) VALUES (26, 'Cartosat-3', 'ISRO', '2019-11-27', 'POLAR', 505, 'Active... | What is the average altitude of satellites launched by Indian Space Research Organisation (ISRO)? | SELECT AVG(Altitude) AS AvgAltitude FROM Satellites WHERE Manufacturer = 'ISRO'; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists ocean_shipping;CREATE TABLE if not exists ocean_shipping.captains (id INT PRIMARY KEY, name VARCHAR(100));CREATE TABLE if not exists ocean_shipping.trips (id INT PRIMARY KEY, captain_id INT, port VARCHAR(100));INSERT INTO ocean_shipping.captains (id, name) VALUES (1, 'Captain A'), (2, 'Capta... | Which captains have sailed to the Port of New York? | SELECT captains.name FROM ocean_shipping.captains INNER JOIN ocean_shipping.trips ON captains.id = trips.captain_id WHERE trips.port = 'Port of New York'; | gretelai_synthetic_text_to_sql |
CREATE TABLE virtual_tour_visitors (id INT, race_ethnicity VARCHAR(20), visited_virtual_tour BOOLEAN); INSERT INTO virtual_tour_visitors (id, race_ethnicity, visited_virtual_tour) VALUES (1, 'white', false); INSERT INTO virtual_tour_visitors (id, race_ethnicity, visited_virtual_tour) VALUES (2, 'Black', true); | How many visitors identified as BIPOC have attended our virtual tours in the last 6 months? | SELECT COUNT(*) FROM virtual_tour_visitors WHERE visited_virtual_tour = true AND race_ethnicity IN ('BIPOC', 'Black', 'African American', 'Asian', 'Hispanic', 'Latinx', 'Native American', 'Pacific Islander', 'South Asian', 'Middle Eastern'); | gretelai_synthetic_text_to_sql |
CREATE TABLE supplier_sales (supplier_id int, product_id int, is_ethical boolean, sales_quantity int, sale_date date); | Find the top 10 suppliers with the highest number of ethical product sales in the past year, ranked by sales quantity. | SELECT supplier_id, is_ethical, SUM(sales_quantity) AS total_sales, ROW_NUMBER() OVER (PARTITION BY is_ethical ORDER BY SUM(sales_quantity) DESC) as rank FROM supplier_sales WHERE sale_date >= DATEADD(year, -1, GETDATE()) GROUP BY supplier_id, is_ethical HAVING is_ethical = true FETCH FIRST 10 ROWS ONLY; | gretelai_synthetic_text_to_sql |
CREATE TABLE inspections (restaurant_id INT, score INT); INSERT INTO inspections (restaurant_id, score) VALUES (1, 95), (1, 90), (2, 85), (2, 88), (3, 92), (3, 97); | What is the average food safety score for each restaurant? | SELECT restaurant_id, AVG(score) FROM inspections GROUP BY restaurant_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE market_share (market_share_id INT, drug_id INT, region TEXT, market_share FLOAT); INSERT INTO market_share (market_share_id, drug_id, region, market_share) VALUES (1, 1001, 'North America', 0.35), (2, 1002, 'North America', 0.45), (3, 1003, 'North America', 0.20), (4, 1001, 'Europe', 0.40), (5, 1002, 'Euro... | What is the market share of a drug compared to its competitors in a specific region? | SELECT drug_id, region, AVG(market_share) as average_market_share FROM market_share WHERE drug_id = 1001 GROUP BY drug_id, region; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA AI_Safety;CREATE TABLE Algorithms (algo_id INT, fairness_score FLOAT); INSERT INTO AI_Safety.Algorithms (algo_id, fairness_score) VALUES (1, 0.75), (2, 0.9), (3, 0.6);CREATE SCHEMA AI_Research;CREATE TABLE Safety_Papers (paper_id INT, publication_year INT, algo_id INT); INSERT INTO AI_Research.Safety_Pape... | Display the average fairness score of algorithms in the 'AI_Safety' schema grouped by the publication year of their corresponding safety research papers. | SELECT AVG(fairness_score), publication_year FROM AI_Safety.Algorithms INNER JOIN AI_Research.Safety_Papers ON AI_Safety.Algorithms.algo_id = AI_Research.Safety_Papers.algo_id GROUP BY publication_year; | gretelai_synthetic_text_to_sql |
CREATE TABLE SafetyTests (Id INT PRIMARY KEY, Vehicle VARCHAR(100), Year INT, Country VARCHAR(50), Passed BOOLEAN); INSERT INTO SafetyTests (Id, Vehicle, Year, Country, Passed) VALUES (1, 'Ford Fiesta', 2018, 'UK', 1), (2, 'Ford Fiesta', 2018, 'UK', 1), (3, 'Ford Fiesta', 2018, 'UK', 1), (4, 'Ford Fiesta', 2019, 'UK', ... | How many safety tests did the Ford Fiesta pass in the UK in 2019? | SELECT COUNT(*) FROM SafetyTests WHERE Vehicle = 'Ford Fiesta' AND Year = 2019 AND Country = 'UK' AND Passed = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE species (id INT, name VARCHAR(255), conservation_status VARCHAR(255)); INSERT INTO species (id, name, conservation_status) VALUES (1, 'Blue Whale', 'Endangered'); | Number of endangered species in the Indian Ocean | SELECT COUNT(*) FROM species WHERE conservation_status = 'Endangered' AND location = 'Indian Ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE mining (year INT, element VARCHAR(10), quantity INT); INSERT INTO mining VALUES (2018, 'Terbium', 1300); CREATE TABLE recycling (year INT, element VARCHAR(10), quantity INT); INSERT INTO recycling VALUES (2018, 'Terbium', 1100); | What is the maximum production quantity of Terbium in 2018 from the 'mining' and 'recycling' sources? | SELECT MAX(total_quantity) FROM (SELECT SUM(quantity) AS total_quantity FROM mining WHERE element = 'Terbium' AND year = 2018 UNION ALL SELECT SUM(quantity) FROM recycling WHERE element = 'Terbium' AND year = 2018) AS total; | gretelai_synthetic_text_to_sql |
CREATE TABLE Exploration_Data.field_info (id INT, field_name VARCHAR(255)); INSERT INTO Exploration_Data.field_info (id, field_name) VALUES (1, 'Field_1'); INSERT INTO Exploration_Data.field_info (id, field_name) VALUES (2, 'Field_2'); | Get the names of all fields in the Exploration_Data schema | SELECT field_name FROM Exploration_Data.field_info; | gretelai_synthetic_text_to_sql |
CREATE TABLE RuralClinicC (patient_id INT, age INT, gender VARCHAR(10)); INSERT INTO RuralClinicC (patient_id, age, gender) VALUES (5, 55, 'Male'), (6, 45, 'Female'), (7, 35, 'Male'); | Delete all records for male patients in 'RuralClinicC' that are older than 50 | DELETE FROM RuralClinicC WHERE gender = 'Male' AND age > 50; | gretelai_synthetic_text_to_sql |
CREATE TABLE TV_Shows (show_id INT, title VARCHAR(100), genre VARCHAR(50), viewership INT); INSERT INTO TV_Shows (show_id, title, genre, viewership) VALUES (1, 'ShowC', 'Drama', 10000000); INSERT INTO TV_Shows (show_id, title, genre, viewership) VALUES (2, 'ShowD', 'Comedy', 8000000); INSERT INTO TV_Shows (show_id, tit... | Which TV shows have the highest viewership in the Drama genre? | SELECT title, MAX(viewership) FROM TV_Shows WHERE genre = 'Drama' GROUP BY title; | gretelai_synthetic_text_to_sql |
CREATE TABLE finance.loans (loan_id INT, is_shariah_compliant BOOLEAN); INSERT INTO finance.loans (loan_id, is_shariah_compliant) VALUES (1, true), (2, false), (3, true), (4, true), (5, false); | Determine the percentage of Shariah-compliant loans in the 'finance' schema's 'loans' table. | SELECT 100.0 * COUNT(*) FILTER (WHERE is_shariah_compliant = true) / COUNT(*) FROM finance.loans; | gretelai_synthetic_text_to_sql |
CREATE TABLE RuralHealthFacilities (FacilityID INT, Name VARCHAR(50), Address VARCHAR(100), TotalBeds INT, NumberOfDoctors INT); INSERT INTO RuralHealthFacilities (FacilityID, Name, Address, TotalBeds, NumberOfDoctors) VALUES (1, 'Rural Community Hospital', '1234 Rural Rd', 50, 30), (2, 'Small Rural Clinic', '8899 Smal... | How many doctors work in the facilities that have more than 50 total beds? | SELECT COUNT(*) FROM RuralHealthFacilities WHERE TotalBeds > 50 AND NumberOfDoctors > 0; | gretelai_synthetic_text_to_sql |
CREATE TABLE Cargo (CargoID INT, CargoName VARCHAR(100), VesselType VARCHAR(100), Volume INT); INSERT INTO Cargo (CargoID, CargoName, VesselType, Volume) VALUES (1, 'Container 1', 'Container Ship', 5000); INSERT INTO Cargo (CargoID, CargoName, VesselType, Volume) VALUES (2, 'Container 2', 'Container Ship', 5500); INSER... | What is the total volume of cargo per vessel type, ranked from highest to lowest? | SELECT VesselType, SUM(Volume) OVER(PARTITION BY VesselType ORDER BY VesselType) AS TotalVolume, RANK() OVER(ORDER BY TotalVolume DESC) as Rank FROM Cargo | gretelai_synthetic_text_to_sql |
CREATE TABLE chemical_production_6 (site VARCHAR(10), chemical VARCHAR(10), quantity INT); INSERT INTO chemical_production_6 VALUES ('H', 'A', 500), ('H', 'B', 600), ('H', 'C', 700), ('I', 'D', 800), ('I', 'E', 900); | What is the maximum production quantity for each site? | SELECT site, MAX(quantity) FROM chemical_production_6 GROUP BY site; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, product_name VARCHAR(100), is_cruelty_free BOOLEAN); INSERT INTO products (product_id, product_name, is_cruelty_free) VALUES (1, 'Lipstick', true), (2, 'Mascara', false); CREATE TABLE purchases (purchase_id INT, product_id INT, purchase_date DATE); INSERT INTO purchases (purchase_... | Which cruelty-free certified products were purchased in the last month? | SELECT products.product_name FROM products INNER JOIN purchases ON products.product_id = purchases.product_id WHERE products.is_cruelty_free = true AND purchases.purchase_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) AND CURRENT_DATE; | gretelai_synthetic_text_to_sql |
CREATE TABLE posts (post_id INT, user_id INT, followers INT, post_date DATE, content TEXT); | What is the number of posts related to veganism in the United Kingdom, published by users with more than 10,000 followers, in the past week? | SELECT COUNT(*) FROM posts p WHERE p.followers > 10000 AND p.content LIKE '%vegan%' AND p.post_date >= DATEADD(day, -7, GETDATE()) AND p.country = 'United Kingdom'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Programs (program_id INT, state VARCHAR(50), focus_area VARCHAR(50), policy_advocacy_history TEXT); CREATE TABLE Regions (region VARCHAR(50), state VARCHAR(50)); | What is the policy advocacy history for programs with a focus on cognitive disabilities in the South and the West? | SELECT * FROM Programs P INNER JOIN Regions R ON P.state = R.state WHERE R.region IN ('South', 'West') AND P.focus_area = 'cognitive disabilities'; | gretelai_synthetic_text_to_sql |
CREATE TABLE FoodSales (SaleID INT, SaleDate DATE, IsOrganic BOOLEAN); INSERT INTO FoodSales (SaleID, SaleDate, IsOrganic) VALUES (1, '2021-01-01', TRUE), (2, '2021-01-05', FALSE), (3, '2021-02-10', TRUE), (4, '2021-03-20', FALSE), (5, '2021-03-30', TRUE); | What is the percentage of organic food sales in 2021? | SELECT ROUND(100.0 * SUM(CASE WHEN IsOrganic THEN 1 ELSE 0 END) / COUNT(*), 2) AS PercentageOfOrganicSales FROM FoodSales WHERE SaleDate BETWEEN '2021-01-01' AND '2021-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE events (id INT, type VARCHAR(20)); INSERT INTO events (id, type) VALUES (1, 'Theater'), (2, 'Dance'), (3, 'Workshop'); CREATE TABLE attendees (id INT, event_id INT, is_repeat BOOLEAN); INSERT INTO attendees (id, event_id, is_repeat) VALUES (1, 1, true), (2, 1, false), (3, 2, true), (1, 3, true), (4, 2, fal... | What is the percentage of repeat attendees for each type of event? | SELECT e.type, AVG(CASE WHEN a.is_repeat THEN 1.0 ELSE 0.0 END) * 100.0 AS repeat_percentage FROM events e JOIN attendees a ON e.id = a.event_id GROUP BY e.type; | gretelai_synthetic_text_to_sql |
CREATE TABLE SupplyChainWorkers (wage DECIMAL(10,2), country VARCHAR(255), year INT); CREATE VIEW LivingWage AS SELECT country, 10.00 AS living_wage; | How many workers in the supply chain were paid a living wage or higher in 2019, by each country? | SELECT country, COUNT(*) FROM SupplyChainWorkers JOIN LivingWage ON 1=1 WHERE wage >= living_wage AND year = 2019 GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE green_buildings_ext (building_id INT, city_id INT, country_id INT); INSERT INTO green_buildings_ext VALUES (1, 1, 1), (2, 1, 1), (3, 2, 2), (4, 3, 3); | How many green buildings are there in each country? | SELECT gbe.country_id, COUNT(*) as num_buildings FROM green_buildings_ext gbe GROUP BY gbe.country_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE defense_diplomacy (country VARCHAR(50), year INT, partner VARCHAR(50)); INSERT INTO defense_diplomacy (country, year, partner) VALUES ('India', 2018, 'France'), ('India', 2018, 'Russia'), ('India', 2018, 'USA'), ('India', 2018, 'Israel'), ('India', 2018, 'Japan'), ('India', 2018, 'Australia'); | Who were the defense diplomacy partners of India in 2018? | SELECT DISTINCT partner FROM defense_diplomacy WHERE country = 'India' AND year = 2018; | gretelai_synthetic_text_to_sql |
CREATE TABLE teacher_pd (teacher_id INT, course_id INT, completed_date DATE); CREATE TABLE courses (course_id INT, course_name VARCHAR(255), subject_area VARCHAR(255)); | How many professional development courses have been completed by teachers, in total? | SELECT COUNT(t.course_id) FROM teacher_pd t; | gretelai_synthetic_text_to_sql |
CREATE TABLE rd_expenditure (drug_name TEXT, quarter TEXT, year INTEGER, expenditure INTEGER); | What was the R&D expenditure on drug 'ABC-456' in Q2 2022? | SELECT expenditure FROM rd_expenditure WHERE drug_name = 'ABC-456' AND quarter = 'Q2' AND year = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE properties (property_id INT, price FLOAT, owner_id INT); CREATE TABLE owners (owner_id INT, name VARCHAR(255), gender VARCHAR(6)); INSERT INTO properties (property_id, price, owner_id) VALUES (1, 500000, 101), (2, 600000, 102), (3, 700000, 101); INSERT INTO owners (owner_id, name, gender) VALUES (101, 'Ali... | What is the average property price for each gender of owner? | SELECT owners.gender, AVG(properties.price) FROM properties INNER JOIN owners ON properties.owner_id = owners.owner_id GROUP BY owners.gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE research (id INT, name VARCHAR(255), region VARCHAR(255), budget DECIMAL(10,2), focus VARCHAR(255)); INSERT INTO research (id, name, region, budget, focus) VALUES (1, 'Study A', 'European Union', 2000000.00, 'Accessible Technology'), (2, 'Study B', 'United States', 3000000.00, 'Ethical AI'), (3, 'Study C',... | What is the total budget allocated for accessible technology research for people with disabilities in the European Union? | SELECT SUM(budget) FROM research WHERE region = 'European Union' AND focus = 'Accessible Technology'; | gretelai_synthetic_text_to_sql |
CREATE TABLE subscribers (id INT, type VARCHAR(10), region VARCHAR(10), unlimited BOOLEAN); INSERT INTO subscribers (id, type, region, unlimited) VALUES (1, 'postpaid', 'coastal', FALSE), (2, 'postpaid', 'coastal', TRUE); CREATE TABLE usage (subscriber_id INT, month INT, data_usage INT); INSERT INTO usage (subscriber_i... | What is the average monthly data usage for postpaid mobile customers in the "coastal" region, excluding those with unlimited plans? | SELECT AVG(data_usage) FROM usage JOIN subscribers ON usage.subscriber_id = subscribers.id WHERE subscribers.type = 'postpaid' AND subscribers.region = 'coastal' AND subscribers.unlimited = FALSE; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteers_japan (id INT, volunteer_name TEXT, country TEXT, join_date DATE); INSERT INTO volunteers_japan (id, volunteer_name, country, join_date) VALUES (1, 'Taro Yamada', 'Japan', '2020-03-05'); INSERT INTO volunteers_japan (id, volunteer_name, country, join_date) VALUES (2, 'Hana Mori', 'Japan', '2020-... | How many volunteers have joined non-profit organizations in Japan in 2020? | SELECT COUNT(*) FROM volunteers_japan WHERE country = 'Japan' AND YEAR(join_date) = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE Forests (id INT, name VARCHAR(255), hectares FLOAT, country VARCHAR(255), carbon_sequestration_tonnes INT, timber_production_tonnes INT); INSERT INTO Forests (id, name, hectares, country, carbon_sequestration_tonnes, timber_production_tonnes) VALUES (1, 'Amazon Rainforest', 55000000.0, 'Brazil', 120000000,... | What is the total carbon sequestered by forests in a specific country, and the total timber production in those forests? | SELECT country, SUM(carbon_sequestration_tonnes) as total_carbon_sequestration, SUM(timber_production_tonnes) as total_timber_production FROM Forests GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE ArtMovements (MovementID int, Name varchar(50)); CREATE TABLE ArtPieces (ArtPieceID int, Title varchar(50), YearCreated int, MovementID int, AverageRating decimal(3,2)); | What is the average rating of Impressionist artworks? | SELECT AVG(ArtPieces.AverageRating) AS AverageImpressionistArtworksRating FROM ArtPieces INNER JOIN ArtMovements ON ArtPieces.MovementID = ArtMovements.MovementID WHERE ArtMovements.Name = 'Impressionism'; | gretelai_synthetic_text_to_sql |
CREATE TABLE clients (id INT PRIMARY KEY, name VARCHAR(255), age INT, city VARCHAR(255)); INSERT INTO clients (id, name, age, city) VALUES (1001, 'Jacob Smith', 34, 'New York'), (1002, 'Sophia Johnson', 45, 'Los Angeles'), (1003, 'Ethan Williams', 29, 'Chicago'), (1005, 'Aaliyah Brown', 31, 'Houston'), (1006, 'Mateo Da... | Identify the number of clients who have made a 'Deposit' or 'Withdrawal' in 'Miami'. | SELECT COUNT(DISTINCT c.id) FROM clients c INNER JOIN transactions t ON c.id = t.client_id WHERE t.type IN ('Deposit', 'Withdrawal') AND c.city = 'Miami'; | gretelai_synthetic_text_to_sql |
CREATE TABLE recycled_textile_sales (customer_id INT, customer_name VARCHAR(50), total_spending INT); INSERT INTO recycled_textile_sales (customer_id, customer_name, total_spending) VALUES (1, 'Green Retailer', 200000), (2, 'Sustainable Store', 300000), (3, 'Eco-Friendly Outlet', 150000), (4, 'Natural Market', 250000),... | Who are the top 3 customers of recycled textile products by total spending? | SELECT customer_name, SUM(total_spending) FROM recycled_textile_sales GROUP BY customer_name ORDER BY SUM(total_spending) DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE ai_algorithms (algorithm_id INT, algorithm_name VARCHAR(50), country VARCHAR(50), region VARCHAR(50)); INSERT INTO ai_algorithms (algorithm_id, algorithm_name, country, region) VALUES (1, 'AlgoS', 'India', 'Asia'), (2, 'AlgoT', 'China', 'Asia'), (3, 'AlgoU', 'Japan', 'Asia'), (4, 'AlgoV', 'India', 'Asia'),... | List the unique countries and the number of AI algorithms evaluated for fairness in each country in the Asian region. | SELECT country, region, COUNT(DISTINCT algorithm_id) AS fairness_evaluations_count FROM ai_algorithms WHERE region = 'Asia' GROUP BY country, region; | gretelai_synthetic_text_to_sql |
CREATE TABLE supplier_circular_chains (supplier_id INT, product_id INT, quantity INT, FOREIGN KEY (supplier_id) REFERENCES suppliers(id), FOREIGN KEY (product_id) REFERENCES circular_supply_chains(product_id)); | What is the average quantity of products manufactured by each supplier in a circular supply chain? | SELECT supplier_id, AVG(quantity) FROM supplier_circular_chains GROUP BY supplier_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE regions (id INT, region_name VARCHAR(255)); INSERT INTO regions (id, region_name) VALUES (1, 'Asia'), (2, 'Africa'), (3, 'North America'); CREATE TABLE animal_location (id INT, animal_id INT, region_id INT); INSERT INTO animal_location (id, animal_id, region_id) VALUES (1, 1, 1), (2, 2, 2), (3, 3, 3); CREA... | Find the total number of animals in each region | SELECT r.region_name, COUNT(a.id) as animal_count FROM regions r INNER JOIN animal_location al ON r.id = al.region_id INNER JOIN animals a ON al.animal_id = a.id GROUP BY r.region_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE dapps (dapp_id INT PRIMARY KEY, name VARCHAR(50), category VARCHAR(50), platform VARCHAR(50), launch_date DATE); | Add a new decentralized application to the 'dapps' table | INSERT INTO dapps (dapp_id, name, category, platform, launch_date) VALUES (1, 'BlockchainArt', 'Art', 'Ethereum', '2023-03-15'); | gretelai_synthetic_text_to_sql |
CREATE TABLE cities (id INT, name VARCHAR(50), population INT, public_transportation_cost DECIMAL(5,2)); INSERT INTO cities (id, name, population, public_transportation_cost) VALUES (1, 'New York', 8500000, 2.50), (2, 'Los Angeles', 4000000, 1.75), (3, 'Chicago', 2700000, 2.25); | What is the average cost of public transportation in cities with a population of over 1 million? | SELECT AVG(public_transportation_cost) FROM cities WHERE population > 1000000; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA state; CREATE SCHEMA nation; CREATE TABLE state.participation_data (id INT, name VARCHAR(255), is_public BOOLEAN); CREATE TABLE nation.participation_data (id INT, name VARCHAR(255), is_public BOOLEAN); INSERT INTO state.participation_data (id, name, is_public) VALUES (1, 'voting', true), (2, 'protests', f... | Identify public participation datasets that exist in 'state' schema but not in 'nation'. | SELECT * FROM ( (SELECT * FROM state.participation_data WHERE is_public = true) EXCEPT (SELECT * FROM nation.participation_data WHERE is_public = true) ) AS excepted_data; | gretelai_synthetic_text_to_sql |
CREATE TABLE species_data (species_id INT, species_name VARCHAR(255), biomass FLOAT); INSERT INTO species_data (species_id, species_name, biomass) VALUES (1, 'polar_bear', 800.0), (2, 'arctic_fox', 15.0), (3, 'caribou', 220.0), (4, 'lemming', 5.0); | Calculate the average biomass for species in the 'species_data' table, partitioned by the first letter of the species_name. | SELECT species_name[1] AS first_letter, AVG(biomass) AS avg_biomass FROM species_data GROUP BY species_name[1] ORDER BY avg_biomass DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE employees (id INT, name VARCHAR(50), department VARCHAR(50), role VARCHAR(50)); INSERT INTO employees (id, name, department, role) VALUES (1, 'John Doe', 'hr', 'employee'); INSERT INTO employees (id, name, department, role) VALUES (2, 'Jane Smith', 'hr', 'manager'); INSERT INTO employees (id, name, departm... | Delete all employees from the 'marketing' department. | DELETE FROM employees WHERE department = 'marketing'; | gretelai_synthetic_text_to_sql |
CREATE TABLE permit_renewable (permit_id INT, state VARCHAR(50), project_type VARCHAR(50), issue_date DATE); INSERT INTO permit_renewable (permit_id, state, project_type, issue_date) VALUES (1, 'California', 'Renewable', '2020-01-01'); | How many permits were issued in each state for renewable energy projects in 2020? | SELECT state, COUNT(*) AS permit_count FROM permit_renewable WHERE project_type = 'Renewable' AND issue_date BETWEEN '2020-01-01' AND '2020-12-31' GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE City (id INT, name VARCHAR(255), population INT); INSERT INTO City (id, name, population) VALUES (1, 'New York', 8500000); INSERT INTO City (id, name, population) VALUES (2, 'Los Angeles', 4000000); INSERT INTO City (id, name, population) VALUES (3, 'Chicago', 2700000); CREATE TABLE Agency (id INT, city_id... | What is the total budget of agencies in cities with a population greater than 1 million? | SELECT SUM(Agency.budget) FROM Agency JOIN City ON Agency.city_id = City.id WHERE City.population > 1000000; | gretelai_synthetic_text_to_sql |
CREATE TABLE inventory (fertilizer_id INT, crop_id INT, cost DECIMAL(5,2), usage_date DATE); INSERT INTO inventory (fertilizer_id, crop_id, cost, usage_date) VALUES (1, 1, 15.99, '2021-01-01'), (2, 2, 12.49, '2021-01-02'), (3, 1, 18.35, '2021-01-03'); | Calculate the total cost of fertilizers used for the 'Genetically Modified Corn' category between January 1, 2021 and January 31, 2021. | SELECT SUM(cost) FROM inventory WHERE crop_id IN (SELECT crop_id FROM crops WHERE category = 'Genetically Modified Corn') AND usage_date BETWEEN '2021-01-01' AND '2021-01-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE vulnerabilities (id INT, name TEXT, category TEXT, severity TEXT, date_discovered DATE); INSERT INTO vulnerabilities (id, name, category, severity, date_discovered) VALUES (1, 'SQL Injection', 'Application', 'Low', '2021-02-01'), (2, 'Remote Code Execution', 'Network', 'Critical', '2022-03-01'); | What is the average number of vulnerabilities per month in 2021 and 2022? | SELECT DATE_FORMAT(date_discovered, '%Y-%m') as month, COUNT(*) as count FROM vulnerabilities WHERE date_discovered >= '2021-01-01' AND date_discovered < '2023-01-01' GROUP BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE incidents(id INT, incident_date DATE, location VARCHAR(255), incident_type VARCHAR(255)); INSERT INTO incidents(id, incident_date, location, incident_type) VALUES ('1', '2022-01-01', 'USA', 'Fire'); | What is the number of unique incident types in the 'incidents' table for '2022'? | SELECT COUNT(DISTINCT incident_type) FROM incidents WHERE YEAR(incident_date) = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE ElectricVehicles (VehicleID INT, Make TEXT, Model TEXT, Year INT, Horsepower FLOAT); INSERT INTO ElectricVehicles (VehicleID, Make, Model, Year, Horsepower) VALUES (1, 'Tesla', 'Model S', 2022, 762.0), (2, 'Rivian', 'R1T', 2022, 835.0); | What is the average horsepower of electric vehicles released in 2022? | SELECT AVG(Horsepower) FROM ElectricVehicles WHERE Year = 2022 AND Make = 'Tesla' OR Make = 'Rivian'; | gretelai_synthetic_text_to_sql |
CREATE TABLE menu_sales (restaurant_id INT, menu_item_name TEXT, revenue INT); INSERT INTO menu_sales (restaurant_id, menu_item_name, revenue) VALUES (1, 'Cheeseburger', 500), (1, 'Fries', 300), (1, 'Salad', 250), (2, 'Pad Thai', 700), (2, 'Spring Rolls', 400), (3, 'BBQ Burger', 600), (3, 'Onion Rings', 200); | Find the top 3 menu items by revenue across all restaurants, displaying the menu item name and total revenue. Use data from the menu_sales table. | SELECT menu_item_name, SUM(revenue) as total_revenue FROM menu_sales GROUP BY menu_item_name ORDER BY total_revenue DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE organic_farms (id INT, crop VARCHAR(255), temperature DECIMAL(5,2), humidity DECIMAL(5,2)); | What is the average temperature and humidity for all crops in the 'organic_farms' table? | SELECT AVG(temperature) as avg_temperature, AVG(humidity) as avg_humidity FROM organic_farms; | gretelai_synthetic_text_to_sql |
CREATE TABLE social_good (initiative_id INT, initiative_region VARCHAR(15), budget DECIMAL(10, 2), publish_date DATE);INSERT INTO social_good (initiative_id, initiative_region, budget, publish_date) VALUES (1, 'South America', 50000, '2021-01-01'), (2, 'Asia', 75000, '2020-05-05'), (3, 'Africa', 35000, '2021-12-31'); | Show the total budget for technology for social good initiatives in 2021 in South America, Africa, and the Middle East. | SELECT SUM(budget) FROM social_good WHERE initiative_region IN ('South America', 'Africa', 'Middle East') AND publish_date BETWEEN '2021-01-01' AND '2021-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (DonorID INT, DonorName TEXT, DonorType TEXT, Country TEXT); INSERT INTO Donors (DonorID, DonorName, DonorType, Country) VALUES (1, 'Bill & Melinda Gates Foundation', 'Organization', 'United States'), (2, 'Oxfam', 'Organization', 'UK'); CREATE TABLE Donations (DonationID INT, DonorID INT, DonationAm... | How many donations were made by organizations based in the UK with a donation amount greater than $1000? | SELECT COUNT(*) FROM Donations JOIN Donors ON Donations.DonorID = Donors.DonorID WHERE Donors.DonorType = 'Organization' AND Donors.Country = 'UK' HAVING DonationAmount > 1000; | gretelai_synthetic_text_to_sql |
CREATE TABLE plots (id INT, size_ha FLOAT, type TEXT); INSERT INTO plots (id, size_ha, type) VALUES (1, 2.5, 'Urban'); INSERT INTO plots (id, size_ha, type) VALUES (2, 1.8, 'Agroecological'); | What is the average size (in hectares) of all plots in the 'plots' table, where the plot is used for agroecology? | SELECT AVG(size_ha) FROM plots WHERE type = 'Agroecological'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (id INT, donation_amount DECIMAL(10,2), donation_date DATE); | What was the total donation amount per month in 2021? | SELECT DATE_FORMAT(donation_date, '%Y-%m') AS Month, SUM(donation_amount) AS total_donations FROM Donations WHERE donation_date BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY Month ORDER BY Month; | gretelai_synthetic_text_to_sql |
CREATE TABLE loans (id INT, organization_name VARCHAR(50), country VARCHAR(50), amount DECIMAL(10,2), is_socially_responsible BOOLEAN); INSERT INTO loans (id, organization_name, country, amount, is_socially_responsible) VALUES (1, 'ABC Microfinance', 'India', 5000.00, true), (2, 'XYZ Microfinance', 'Bangladesh', 7000.0... | Display the total balance of socially responsible loans made to microfinance organizations in each country, ordered by the total balance in descending order. | SELECT country, SUM(amount) as total_balance FROM loans WHERE is_socially_responsible = true GROUP BY country ORDER BY total_balance DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE fares (id INT, city VARCHAR(50), fare DECIMAL(5,2)); INSERT INTO fares (id, city, fare) VALUES (1, 'New York', 2.50), (2, 'New York', 3.00), (3, 'New York', 4.00), (4, 'Tokyo', 5.00); | What is the total fare collected for public transportation in New York? | SELECT SUM(fare) FROM fares WHERE city = 'New York'; | gretelai_synthetic_text_to_sql |
CREATE TABLE protected_forests_3 (id INT, name VARCHAR(50), area FLOAT); INSERT INTO protected_forests_3 (id, name, area) VALUES (1, 'Green Forest', 500.0), (2, 'Nature Reserve', 800.0); | List all protected forests with an area larger than 500. | SELECT name FROM protected_forests_3 WHERE area > 500; | gretelai_synthetic_text_to_sql |
CREATE TABLE VesselEmissions (VesselID INT, Compliance BOOLEAN, EmissionDate DATE); INSERT INTO VesselEmissions (VesselID, Compliance, EmissionDate) VALUES (1, TRUE, '2021-05-15'), (2, FALSE, '2021-06-20'), (3, TRUE, '2021-07-05'); CREATE TABLE CargoTransport (TransportID INT, VesselID INT, CargoWeight INT); INSERT INT... | What is the total cargo weight transported by vessels that have complied with emission standards in the last month? | SELECT SUM(CargoWeight) FROM CargoTransport CT JOIN VesselEmissions VE ON CT.VesselID = VE.VesselID WHERE VE.Compliance = TRUE AND VE.EmissionDate >= DATEADD(month, -1, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE energy_efficiency (country VARCHAR(50), score INT); INSERT INTO energy_efficiency (country, score) VALUES ('China', 65), ('India', 55), ('Japan', 75), ('South Korea', 70); | Delete energy efficiency data for China and India from the database. | DELETE FROM energy_efficiency WHERE country IN ('China', 'India'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Policies (PolicyID INT, PolicyName VARCHAR(50)); INSERT INTO Policies (PolicyID, PolicyName) VALUES (1, 'Policy A'); INSERT INTO Policies (PolicyID, PolicyName) VALUES (2, 'Policy B'); CREATE TABLE AdvocacyGroups (AdvocacyGroupID INT, AdvocacyGroupName VARCHAR(50)); INSERT INTO AdvocacyGroups (AdvocacyGrou... | List all policies with their corresponding advocacy group. | SELECT p.PolicyName, ag.AdvocacyGroupName FROM Policies p INNER JOIN PolicyAdvocacy pa ON p.PolicyID = pa.PolicyID INNER JOIN AdvocacyGroups ag ON pa.AdvocacyGroupID = ag.AdvocacyGroupID; | gretelai_synthetic_text_to_sql |
CREATE TABLE indigenous_knowledge (id INT PRIMARY KEY, community VARCHAR(255), knowledge VARCHAR(255), passed_down BOOLEAN, timestamp TIMESTAMP); INSERT INTO indigenous_knowledge (id, community, knowledge, passed_down, timestamp) VALUES (1, 'Samis', 'Reindeer herding', true, '2022-01-02 12:00:00'), (2, 'Inuit', 'Ice fi... | What is the total number of indigenous knowledge entries passed down in each community since '2022-01-02'? | SELECT community, SUM(passed_down) FROM indigenous_knowledge WHERE passed_down = true AND timestamp >= '2022-01-02' GROUP BY community; | gretelai_synthetic_text_to_sql |
CREATE TABLE accessible_tech_3 (project_id INT, region VARCHAR(20), budget DECIMAL(10,2)); INSERT INTO accessible_tech_3 (project_id, region, budget) VALUES (1, 'Asia', 30000.00), (2, 'Oceania', 40000.00), (3, 'Asia', 50000.00), (4, 'Oceania', 25000.00); | Identify the minimum budget required for accessible technology projects in Asia and Oceania. | SELECT MIN(budget) FROM accessible_tech_3 WHERE region IN ('Asia', 'Oceania'); | gretelai_synthetic_text_to_sql |
CREATE TABLE returns (id INT, country TEXT, return_weight FLOAT, return_date DATE); | Which countries have experienced an increase in returns in the last quarter compared to the same quarter of the previous year, and what is the percentage change for each country? | SELECT r.country, ((SUM(r.return_weight) - (SELECT SUM(r.return_weight) FROM returns r WHERE r.return_date >= DATEADD(year, -2, GETDATE()) AND r.return_date < DATEADD(year, -1, GETDATE()) AND r.country = c.country)) / (SELECT SUM(r.return_weight) FROM returns r WHERE r.return_date >= DATEADD(year, -2, GETDATE()) AND r.... | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT, HireDate DATE); INSERT INTO Employees (EmployeeID, HireDate) VALUES (1, '2018-01-01'), (2, '2019-01-01'), (3, '2020-01-01'), (4, '2021-01-01'), (5, '2022-01-01'); | Count the number of employees hired in each year. | SELECT YEAR(HireDate) AS Year, COUNT(*) AS NumberOfEmployees FROM Employees GROUP BY Year; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, name VARCHAR(255), price DECIMAL(5,2)); | Insert a new record into the 'products' table with product_id 101, name 'Pre-rolls', and price 15 | INSERT INTO products (product_id, name, price) VALUES (101, 'Pre-rolls', 15); | gretelai_synthetic_text_to_sql |
CREATE TABLE CommunityPolicing (id INT, state VARCHAR(20)); | What is the average number of community policing programs per state? | SELECT AVG(COUNT(*)) FROM CommunityPolicing GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE mine (id INT, name TEXT, location TEXT); CREATE TABLE worker (id INT, name TEXT, birthdate DATE, mine_id INT); | What is the average age of workers in the 'Gold' and 'Platinum' mines? | SELECT AVG(YEAR(CURRENT_DATE) - YEAR(worker.birthdate)) as average_age FROM worker WHERE worker.mine_id IN (SELECT id FROM mine WHERE name IN ('Gold', 'Platinum')); | gretelai_synthetic_text_to_sql |
CREATE TABLE satellite_data (satellite_id INT, name VARCHAR(255), launch_date DATE); INSERT INTO satellite_data (satellite_id, name, launch_date) VALUES (1, 'Sputnik 1', '1957-10-04'), (2, 'Explorer 1', '1958-01-31'); | Update the name of satellite with id 1 to 'New Name' in the satellite_data table | UPDATE satellite_data SET name = 'New Name' WHERE satellite_id = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE rti_requests (id INT, response_time INT, country TEXT); INSERT INTO rti_requests (id, response_time, country) VALUES (1, 30, 'India'), (2, 45, 'India'), (3, 20, 'USA'); | What is the average response time for Right to Information Act (RTI) requests in India? | SELECT AVG(response_time) FROM rti_requests WHERE country = 'India'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Marine_Conservation(id INT, year INT, region VARCHAR(50), protected_area VARCHAR(50), size INT, conservation_status VARCHAR(50)); | What is the average size of protected areas in the Pacific region? | SELECT AVG(size) AS Average_Protected_Area_Size FROM Marine_Conservation WHERE region = 'Pacific'; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT, country VARCHAR(2), data_sharing BOOLEAN); INSERT INTO users (id, country, data_sharing) VALUES (1, 'DE', false), (2, 'DE', true), (3, 'ES', false), (4, 'ES', false); | How many users have opted out of data sharing in Germany and Spain? | SELECT country, SUM(CASE WHEN data_sharing = false THEN 1 ELSE 0 END) as num_users FROM users WHERE country IN ('DE', 'ES') GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE graduate_programs (program_id INT, program_name VARCHAR(50), discipline VARCHAR(50)); INSERT INTO graduate_programs (program_id, program_name, discipline) VALUES (1, 'Electrical Engineering', 'engineering'), (2, 'Mechanical Engineering', 'engineering'); CREATE TABLE research_grants (grant_id INT, program_i... | What is the average number of research grants awarded per year to graduate programs in the 'engineering' discipline? | SELECT discipline, AVG(grant_amount / DATEDIFF(year, grant_date, LEAD(grant_date) OVER (PARTITION BY program_id ORDER BY grant_date))) as avg_grants_per_year FROM graduate_programs JOIN research_grants ON graduate_programs.program_id = research_grants.program_id WHERE discipline = 'engineering' GROUP BY discipline; | gretelai_synthetic_text_to_sql |
CREATE TABLE Attorneys ( AttorneyID INT, Name VARCHAR(100), Community VARCHAR(50) ); INSERT INTO Attorneys (AttorneyID, Name, Community) VALUES (9, 'Jackson', 'African American'), (10, 'Lee', 'Asian'), (11, 'Hernandez', 'Hispanic'), (12, 'Chang', 'Asian'), (13, 'Gonzalez', 'Hispanic'), (14, 'Nguyen', 'Asian'); | How many cases were handled by attorneys from underrepresented communities? | SELECT Community, COUNT(*) AS Cases_Handled FROM Attorneys WHERE Community IN ('African American', 'Hispanic', 'Asian') GROUP BY Community; | gretelai_synthetic_text_to_sql |
CREATE TABLE investor_activities (investor VARCHAR(20), cause VARCHAR(30)); INSERT INTO investor_activities (investor, cause) VALUES ('XYZ', 'climate change'), ('XYZ', 'poverty reduction'), ('ABC', 'climate change'); | List all the unique social causes supported by impact investor XYZ? | SELECT DISTINCT cause FROM investor_activities WHERE investor = 'XYZ'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Companies (CompanyID INT, CompanyName VARCHAR(50), Country VARCHAR(50)); INSERT INTO Companies (CompanyID, CompanyName, Country) VALUES (1, 'ABC Mining', 'Canada'), (2, 'XYZ Excavations', 'USA'), (3, 'MNO Drilling', 'Mexico'); | Which mining companies have operations in Canada? | SELECT CompanyName FROM Companies WHERE Country = 'Canada'; | gretelai_synthetic_text_to_sql |
CREATE TABLE patients (id INT, name VARCHAR(50), age INT, gender VARCHAR(10), race VARCHAR(20), ethnicity VARCHAR(30)); INSERT INTO patients (id, name, age, gender, race, ethnicity) VALUES (1, 'John Doe', 35, 'Male', 'Caucasian', 'Non-Hispanic'), (2, 'Jane Smith', 40, 'Female', 'African American', 'African American'), ... | Retrieve the number of patients by race in the patients table. | SELECT race, COUNT(*) as count FROM patients GROUP BY race; | gretelai_synthetic_text_to_sql |
CREATE TABLE military_exercises (exercise_id INT PRIMARY KEY, exercise_year INT, country VARCHAR(50)); INSERT INTO military_exercises (exercise_id, exercise_year, country) VALUES (1, 2017, 'USA'), (2, 2018, 'Germany'), (3, 2019, 'France'); | Update the "military_exercises" table, setting the "country" to 'United States' for records where the "exercise_year" is 2019 | UPDATE military_exercises SET country = 'United States' WHERE exercise_year = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE Port_Operations (id INT, port VARCHAR(255), operation VARCHAR(255), start_time DATETIME, end_time DATETIME, handled_quantity INT); | What is the average quantity of cargo handled at each port? | SELECT port, AVG(handled_quantity) FROM Port_Operations GROUP BY port; | 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.