context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE Accidents (AccidentID INT, Date DATE, Location VARCHAR(50), AircraftType VARCHAR(50), Description TEXT, Fatalities INT); INSERT INTO Accidents (AccidentID, Date, Location, AircraftType, Description, Fatalities) VALUES (13, '2019-08-18', 'Rio de Janeiro', 'Boeing 737', 'Flight control issues', 0), (14, '202... | Calculate the percentage of accidents involving each aircraft type. | SELECT AircraftType, 100.0 * COUNT(*) / (SELECT COUNT(*) FROM Accidents) AS AccidentPercentage FROM Accidents GROUP BY AircraftType; | gretelai_synthetic_text_to_sql |
CREATE TABLE Vessels (ID INT, Name TEXT, Speed FLOAT, Dangerous_Goods BOOLEAN, Prefix TEXT, Year INT);CREATE VIEW Pacific_Ocean_Vessels AS SELECT * FROM Vessels WHERE Region = 'Pacific Ocean'; | What is the maximum speed of vessels with 'YANG' prefix that carried dangerous goods in the Pacific Ocean in 2017? | SELECT MAX(Speed) FROM Pacific_Ocean_Vessels WHERE Prefix = 'YANG' AND Dangerous_Goods = 1 AND Year = 2017; | gretelai_synthetic_text_to_sql |
CREATE TABLE cosmetics_ingredients (product VARCHAR(255), ingredient VARCHAR(255), safety_rating INTEGER); CREATE TABLE cosmetics (product VARCHAR(255), product_category VARCHAR(255), organic BOOLEAN); CREATE TABLE countries (country VARCHAR(255), continent VARCHAR(255)); CREATE TABLE sale_records (product VARCHAR(255)... | What is the average safety rating of organic skincare products sold in Canada in 2022? | SELECT AVG(safety_rating) FROM cosmetics_ingredients JOIN organic_canada_sales ON cosmetics_ingredients.product = organic_canada_sales.product; | gretelai_synthetic_text_to_sql |
CREATE TABLE Claims (ClaimID INT, PolicyID INT, PolicyType VARCHAR(20), ClaimState VARCHAR(20)); INSERT INTO Claims (ClaimID, PolicyID, PolicyType, ClaimState) VALUES (4, 4, 'Auto', 'Michigan'), (5, 5, 'Home', 'Michigan'), (6, 6, 'Life', 'Michigan'); | How many claims were filed per policy type in 'Michigan'? | SELECT PolicyType, COUNT(*) as ClaimCount FROM Claims WHERE ClaimState = 'Michigan' GROUP BY PolicyType; | gretelai_synthetic_text_to_sql |
CREATE TABLE Habitat_Summary AS SELECT 'Habitat_G' AS name, 52 AS animal_count UNION SELECT 'Habitat_H', 57; | How many animals are there in total across all habitats? | SELECT SUM(animal_count) FROM Habitat_Summary; | gretelai_synthetic_text_to_sql |
CREATE TABLE network_investments (investment_id INT, investment_amount FLOAT, investment_date DATE, location TEXT); INSERT INTO network_investments (investment_id, investment_amount, investment_date, location) VALUES (1, 500000, '2021-02-14', 'Nairobi'); INSERT INTO network_investments (investment_id, investment_amount... | List all network investments made in the African region in the past year, including the investment amount and location. | SELECT * FROM network_investments WHERE investment_date >= DATEADD(year, -1, CURRENT_DATE) AND location LIKE 'Africa%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (id INT, name VARCHAR(255)); INSERT INTO donors (id, name) VALUES (1, 'John'), (2, 'Jane'), (3, 'Mike'), (4, 'Lucy'); CREATE TABLE donations (id INT, donor_id INT, amount DECIMAL(10,2), donation_date DATE); INSERT INTO donations (id, donor_id, amount, donation_date) VALUES (1, 1, 500, '2021-01-01'),... | List all donors who have donated in the last 6 months? | SELECT d.name FROM donors d JOIN donations don ON d.id = don.donor_id WHERE don.donation_date >= DATE_SUB(NOW(), INTERVAL 6 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE Dispensaries (DispensaryID INT, DispensaryName TEXT, State TEXT); INSERT INTO Dispensaries (DispensaryID, DispensaryName, State) VALUES (1, 'Green Earth', 'Colorado'); CREATE TABLE Inventory (InventoryID INT, DispensaryID INT, Strain TEXT); INSERT INTO Inventory (InventoryID, DispensaryID, Strain) VALUES (... | Show the number of unique strains available in each dispensary in states with legal recreational cannabis. | SELECT d.DispensaryName, COUNT(DISTINCT i.Strain) as UniqueStrains FROM Dispensaries d INNER JOIN Inventory i ON d.DispensaryID = i.DispensaryID INNER JOIN States s ON d.State = s.State WHERE s.Legalization = 'Recreational' GROUP BY d.DispensaryName; | gretelai_synthetic_text_to_sql |
CREATE TABLE members(id INT, join_date DATE); INSERT INTO members (id, join_date) VALUES (1, '2021-01-01'), (2, '2022-03-15'); CREATE TABLE weights(id INT, member_id INT, exercise VARCHAR(15), weight INT); INSERT INTO weights (id, member_id, exercise, weight) VALUES (1, 1, 'deadlift', 200), (2, 2, 'squat', 150); | What is the minimum weight lifted in the deadlift exercise by members who joined in 2021? | SELECT MIN(weight) FROM weights w JOIN members m ON w.member_id = m.id WHERE YEAR(m.join_date) = 2021 AND w.exercise = 'deadlift'; | gretelai_synthetic_text_to_sql |
CREATE TABLE mental_health_changes (student_id INT, year INT, score INT); INSERT INTO mental_health_changes (student_id, year, score) VALUES (1, 2018, 80), (1, 2019, 85), (2, 2018, 70), (2, 2019, 75), (3, 2018, 90), (3, 2019, 95); | What is the change in mental health score between consecutive school years for students with a mental health score above 80? | SELECT year, score, LAG(score, 1) OVER (PARTITION BY student_id ORDER BY year) AS previous_score, score - LAG(score, 1) OVER (PARTITION BY student_id ORDER BY year) AS score_change FROM mental_health_changes WHERE score > 80; | gretelai_synthetic_text_to_sql |
CREATE TABLE CivilCases (CaseID INT, CaseType VARCHAR(20), BillingAmount DECIMAL(10,2)); INSERT INTO CivilCases (CaseID, CaseType, BillingAmount) VALUES (1, 'Civil', 5000.00), (2, 'Civil', 3000.50); | What is the total billing amount for civil cases? | SELECT SUM(BillingAmount) FROM CivilCases WHERE CaseType = 'Civil'; | gretelai_synthetic_text_to_sql |
CREATE TABLE cultural_competency_training (id INT, provider_id INT, program_name VARCHAR(100), program_date DATE); INSERT INTO cultural_competency_training (id, provider_id, program_name, program_date) VALUES (3, 111, 'Cultural Competency 101', '2021-03-01'), (4, 111, 'Cultural Diversity Workshop', '2021-04-15'); CREAT... | List the unique cultural competency training programs offered by providers in Illinois and Michigan. | SELECT DISTINCT program_name FROM cultural_competency_training INNER JOIN healthcare_providers ON cultural_competency_training.provider_id = healthcare_providers.id WHERE healthcare_providers.region IN ('Illinois', 'Michigan'); | gretelai_synthetic_text_to_sql |
CREATE TABLE indigenous_communities (id INT, country VARCHAR, community_name VARCHAR, population INT); INSERT INTO indigenous_communities VALUES (1, 'Canada', 'First Nations', 637000); | What is the total population of indigenous communities in each country? | SELECT country, SUM(population) FROM indigenous_communities GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (id INT, name TEXT, total_donated_amount FLOAT); CREATE TABLE donations (id INT, donor_id INT, organization_id INT, donation_amount FLOAT); CREATE TABLE organizations (id INT, name TEXT, cause_area TEXT); | What's the sum of all donations made by the top 10 donors, categorized by cause area? | SELECT o.cause_area, SUM(donations.donation_amount) as total_donations FROM donations INNER JOIN organizations o ON donations.organization_id = o.id INNER JOIN (SELECT id, total_donated_amount FROM donors ORDER BY total_donated_amount DESC LIMIT 10) d ON donations.donor_id = d.id GROUP BY o.cause_area; | gretelai_synthetic_text_to_sql |
CREATE TABLE authors (id INT, name TEXT, gender TEXT, region TEXT); CREATE TABLE articles (id INT, title TEXT, author_id INT); INSERT INTO authors (id, name, gender, region) VALUES (1, 'Author1', 'Male', 'Europe'), (2, 'Author2', 'Female', 'Asia'), (3, 'Author3', 'Male', 'Europe'), (4, 'Author4', 'Female', 'Africa'); I... | Who are the top 3 most prolific male authors from Europe? | SELECT authors.name, COUNT(articles.id) as article_count FROM authors INNER JOIN articles ON authors.id = articles.author_id WHERE authors.gender = 'Male' AND authors.region = 'Europe' GROUP BY authors.name ORDER BY article_count DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE clients (client_id INT, name VARCHAR(50), primary_language VARCHAR(50), max_transaction_amount DECIMAL(10,2));CREATE TABLE transactions (transaction_id INT, client_id INT, transaction_date DATE, total_amount DECIMAL(10,2)); | What is the maximum transaction amount for clients with a primary language of Spanish in Q2 2023? | SELECT MAX(max_transaction_amount) FROM clients c INNER JOIN transactions t ON c.client_id = t.client_id WHERE c.primary_language = 'Spanish' AND t.transaction_date BETWEEN '2023-04-01' AND '2023-06-30' | gretelai_synthetic_text_to_sql |
CREATE TABLE investment_data (id INT, investment_amount FLOAT, strategy VARCHAR(50), region VARCHAR(50)); INSERT INTO investment_data (id, investment_amount, strategy, region) VALUES (1, 250000.00, 'Renewable energy', 'Americas'); INSERT INTO investment_data (id, investment_amount, strategy, region) VALUES (2, 500000.0... | Update the investment amount for the record with id 1 in the investment_data table to 300000.00. | UPDATE investment_data SET investment_amount = 300000.00 WHERE id = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE InvestmentsAmount (id INT, investor VARCHAR(255), sector VARCHAR(255), amount DECIMAL(10,2)); | Get the total 'amount' invested by 'EthicalVentures' in 'WasteManagement'. | SELECT SUM(amount) FROM InvestmentsAmount WHERE investor = 'EthicalVentures' AND sector = 'WasteManagement'; | gretelai_synthetic_text_to_sql |
CREATE TABLE articles (id INT, title TEXT, publication DATE, newspaper TEXT, word_count INT); INSERT INTO articles (id, title, publication, newspaper, word_count) VALUES (1, 'Article 1', '2022-01-01', 'The Washington Post', 1000); INSERT INTO articles (id, title, publication, newspaper, word_count) VALUES (2, 'Article ... | What is the total number of words in all articles published by "The Washington Post" in the last 3 months, excluding articles with less than 500 words? | SELECT SUM(word_count) FROM articles WHERE newspaper = 'The Washington Post' AND publication >= DATE_SUB(CURDATE(), INTERVAL 3 MONTH) AND word_count >= 500; | gretelai_synthetic_text_to_sql |
CREATE TABLE GalleryC (gallery_name VARCHAR(20), artwork_type VARCHAR(20), exhibition_duration INT); INSERT INTO GalleryC (gallery_name, artwork_type, exhibition_duration) VALUES ('GalleryC', 'Sculpture', 120), ('GalleryC', 'Sculpture', 90), ('GalleryC', 'Painting', 60); | What was the average exhibition duration for sculptures, partitioned by gallery? | SELECT gallery_name, AVG(exhibition_duration) as avg_duration FROM (SELECT gallery_name, artwork_type, exhibition_duration, ROW_NUMBER() OVER (PARTITION BY gallery_name, artwork_type ORDER BY exhibition_duration) as rn FROM GalleryC) tmp WHERE rn = 1 GROUP BY gallery_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE concert_revenue (venue VARCHAR(255), date DATE, location VARCHAR(255), tickets_sold INT, revenue INT); INSERT INTO concert_revenue (venue, date, location, tickets_sold, revenue) VALUES ('Auditorio Nacional', '2022-09-01', 'Mexico', 12000, 250000), ('Forum Mundo Imperial', '2022-10-15', 'Mexico', 8000, 1800... | What is the total revenue generated from concerts in Mexico? | SELECT SUM(revenue) as total_revenue FROM concert_revenue WHERE location = 'Mexico'; | gretelai_synthetic_text_to_sql |
CREATE TABLE wearables (member_id INT, device_type VARCHAR(50), heart_rate INT); | Update the device type for ID 103 to 'Apple Watch' | UPDATE wearables SET device_type = 'Apple Watch' WHERE member_id = 103; | gretelai_synthetic_text_to_sql |
CREATE TABLE schools (id INT, country VARCHAR(255), name VARCHAR(255), classrooms INT); INSERT INTO schools (id, country, name, classrooms) VALUES (1, 'Haiti', 'School 1', 5), (2, 'Haiti', 'School 2', 6); | What is the total number of schools rebuilt in Haiti and the number of classrooms in those schools? | SELECT country, SUM(classrooms) FROM schools GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (id INT, year INT, country VARCHAR(255), equipment_type VARCHAR(255), revenue FLOAT); | Insert a new record of military equipment sale | INSERT INTO sales (id, year, country, equipment_type, revenue) VALUES (2, 2021, 'Canada', 'Naval Vessels', 12000000); | gretelai_synthetic_text_to_sql |
CREATE TABLE mine (id INT, name TEXT, location TEXT); INSERT INTO mine (id, name, location) VALUES (1, 'Mine G', 'Country T'), (2, 'Mine H', 'Country S'); CREATE TABLE environmental_impact (mine_id INT, co2_emission INT, timestamp TIMESTAMP); INSERT INTO environmental_impact (mine_id, co2_emission, timestamp) VALUES (1... | What is the total CO2 emission for each mine in the last 6 months? | SELECT mine_id, SUM(co2_emission) as total_emission FROM environmental_impact WHERE timestamp >= DATEADD(month, -6, CURRENT_TIMESTAMP) GROUP BY mine_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Vessels (ID INT, Name VARCHAR(50), Type VARCHAR(50)); | Insert a new vessel 'Mystic Turtle' with type 'Cruise' into the Vessels table. | INSERT INTO Vessels (ID, Name, Type) VALUES (4, 'Mystic Turtle', 'Cruise'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Cuisines (CuisineID INT, CuisineType VARCHAR(50)); CREATE TABLE Meals (MealID INT, CuisineID INT, MealName VARCHAR(50), CalorieCount INT, IsVegetarian BIT); INSERT INTO Cuisines (CuisineID, CuisineType) VALUES (1, 'American'), (2, 'Italian'); INSERT INTO Meals (MealID, CuisineID, MealName, CalorieCount, Is... | What is the average calorie count per meal for vegetarian dishes? | SELECT CuisineType, AVG(CalorieCount) as avg_calories FROM Cuisines C JOIN Meals M ON C.CuisineID = M.CuisineID WHERE IsVegetarian = 1 GROUP BY CuisineType; | gretelai_synthetic_text_to_sql |
CREATE TABLE campaigns (campaign_id INT, launch_date DATE); INSERT INTO campaigns (campaign_id, launch_date) VALUES (1, '2019-01-01'), (2, '2020-05-15'), (3, '2018-12-31'), (4, '2021-03-20'); | How many public awareness campaigns were launched in each year in the 'campaigns' schema? | SELECT EXTRACT(YEAR FROM launch_date) AS year, COUNT(*) AS campaigns_launched FROM campaigns GROUP BY year; | gretelai_synthetic_text_to_sql |
CREATE TABLE mine (id INT, name TEXT, location TEXT, environmental_impact_score INT); INSERT INTO mine VALUES (1, 'Mine A', 'Country A', 60); INSERT INTO mine VALUES (2, 'Mine B', 'Country B', 75); INSERT INTO mine VALUES (3, 'Mine C', 'Country C', 45); | List all mines with their environmental impact score | SELECT name, environmental_impact_score FROM mine; | gretelai_synthetic_text_to_sql |
CREATE TABLE news_story (news_story_id INT, publication_date DATE, topic VARCHAR(50)); INSERT INTO news_story (news_story_id, publication_date, topic) VALUES (1, '2023-01-01', 'Climate Change'), (2, '2023-02-01', 'Politics'), (3, '2023-03-01', 'Climate Change'); | How many news stories were published about climate change in the last month? | SELECT COUNT(*) as num_stories FROM news_story WHERE topic = 'Climate Change' AND publication_date >= CURDATE() - INTERVAL 1 MONTH; | gretelai_synthetic_text_to_sql |
CREATE TABLE space_missions (mission_id INT, name VARCHAR(100), launch_date DATE); INSERT INTO space_missions (mission_id, name, launch_date) VALUES (1, 'Luna 1', '1959-01-02'), (2, 'Apollo 11', '1969-07-16'); CREATE TABLE satellites (satellite_id INT, name VARCHAR(100), owner_country VARCHAR(50)); INSERT INTO satellit... | Show the total number of space missions and total number of satellites? | SELECT (SELECT COUNT(*) FROM space_missions) AS total_missions, (SELECT COUNT(*) FROM satellites) AS total_satellites; | gretelai_synthetic_text_to_sql |
CREATE TABLE DefenseContracts (id INT, contractor VARCHAR(255), state VARCHAR(255), year INT, contract_value INT); INSERT INTO DefenseContracts (id, contractor, state, year, contract_value) VALUES (1, 'ABC Corp', 'California', 2018, 100000), (2, 'XYZ Inc', 'Texas', 2018, 200000), (3, 'DEF LLC', 'California', 2019, 3000... | What is the total number of defense contracts awarded to companies in California between 2018 and 2020? | SELECT contractor, SUM(contract_value) FROM DefenseContracts WHERE state = 'California' AND year BETWEEN 2018 AND 2020 GROUP BY contractor; | gretelai_synthetic_text_to_sql |
CREATE TABLE GreenBuildings (BuildingID INT, BuildingType VARCHAR(255), Region VARCHAR(255), EnergyEfficiencyRating FLOAT); INSERT INTO GreenBuildings (BuildingID, BuildingType, Region, EnergyEfficiencyRating) VALUES (1, 'Residential', 'Region J', 85.0); | What is the average energy efficiency rating of Green buildings in 'Region J' for each building type? | SELECT BuildingType, AVG(EnergyEfficiencyRating) FROM GreenBuildings WHERE Region = 'Region J' GROUP BY BuildingType; | gretelai_synthetic_text_to_sql |
CREATE TABLE Policy (PolicyNumber INT, CoverageType VARCHAR(50), SumInsured INT, EffectiveDate DATE); INSERT INTO Policy (PolicyNumber, CoverageType, SumInsured, EffectiveDate) VALUES (1, 'Home', 700000, '2020-01-01'); INSERT INTO Policy (PolicyNumber, CoverageType, SumInsured, EffectiveDate) VALUES (2, 'Auto', 300000,... | What is the policy number, coverage type, and effective date for policies with a sum insured greater than $500,000? | SELECT PolicyNumber, CoverageType, EffectiveDate FROM Policy WHERE SumInsured > 500000; | gretelai_synthetic_text_to_sql |
CREATE VIEW courier_performances AS SELECT courier_id, order_id, delivery_time, PERCENTILE_CONT(0.9) WITHIN GROUP (ORDER BY delivery_time) OVER (PARTITION BY courier_id) as pct_90 FROM orders; | What is the order ID and delivery time for the 90th percentile delivery time for each courier in the 'courier_performances' view, ordered by the 90th percentile delivery time? | SELECT courier_id, order_id, delivery_time FROM courier_performances WHERE pct_90 = delivery_time ORDER BY delivery_time; | gretelai_synthetic_text_to_sql |
CREATE TABLE CybersecurityIncidents (id INT, incident_name VARCHAR(255), incident_date DATE, country VARCHAR(255)); INSERT INTO CybersecurityIncidents (id, incident_name, incident_date, country) VALUES (1, 'Incident A', '2021-01-01', 'France'), (2, 'Incident B', '2021-02-15', 'Germany'), (3, 'Incident C', '2022-03-03',... | List all cybersecurity incidents in Europe and the corresponding incident response time in 2021 and 2022. | SELECT i.incident_name, i.country, r.response_time FROM CybersecurityIncidents i INNER JOIN ResponseTimes r ON i.id = r.incident_id WHERE i.country IN ('France', 'Germany', 'UK') AND i.incident_date BETWEEN '2021-01-01' AND '2022-12-31' ORDER BY i.incident_date; | gretelai_synthetic_text_to_sql |
CREATE TABLE military_equipment_sales (id INT, sale_date DATE, quantity INT); INSERT INTO military_equipment_sales (id, sale_date, quantity) VALUES (1, '2022-01-01', 500), (2, '2022-02-01', 600), (3, '2022-07-01', 700), (4, '2022-08-01', 800); | What is the total number of military equipment sales in the second half of the year 2022? | SELECT SUM(quantity) FROM military_equipment_sales WHERE sale_date BETWEEN '2022-07-01' AND '2022-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Restaurants (id INT, name VARCHAR(50), type VARCHAR(20), safety_rating INT); INSERT INTO Restaurants (id, name, type, safety_rating) VALUES (1, 'Green Garden', 'Vegan', 5); INSERT INTO Restaurants (id, name, type, safety_rating) VALUES (2, 'Bistro Bella', 'Italian', 4); INSERT INTO Restaurants (id, name, t... | What is the average safety rating for Mexican restaurants? | SELECT AVG(safety_rating) FROM Restaurants WHERE type LIKE '%Mexican%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Patients (PatientID INT, Gender TEXT, ChronicConditions TEXT, State TEXT); INSERT INTO Patients (PatientID, Gender, ChronicConditions, State) VALUES (1, 'Male', 'Diabetes', 'New York'); | How many male patients with chronic conditions live in New York? | SELECT COUNT(*) FROM Patients WHERE Gender = 'Male' AND ChronicConditions IS NOT NULL AND State = 'New York'; | gretelai_synthetic_text_to_sql |
CREATE TABLE aircraft_manufacturing (id INT, aircraft_name VARCHAR(255), manufacturer VARCHAR(255), manufacturing_date DATE, status VARCHAR(255)); | Update the aircraft_manufacturing table to set the status of all records with manufacturer 'Airbus' to 'In Production' | UPDATE aircraft_manufacturing SET status = 'In Production' WHERE manufacturer = 'Airbus'; | gretelai_synthetic_text_to_sql |
CREATE TABLE accounts (customer_id INT, account_type VARCHAR(20), branch VARCHAR(20), balance DECIMAL(10,2)); INSERT INTO accounts (customer_id, account_type, branch, balance) VALUES (1, 'Savings', 'New York', 5000.00), (2, 'Checking', 'New York', 7000.00), (3, 'Checking', 'Miami', 9000.00), (4, 'Savings', 'Miami', 400... | What is the maximum checking account balance in the Miami branch? | SELECT MAX(balance) FROM accounts WHERE account_type = 'Checking' AND branch = 'Miami'; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA sales;CREATE TABLE sales.drugs (id INT, name VARCHAR(50));CREATE TABLE sales.sales_data (drug_id INT, year INT, revenue DECIMAL(10, 2)); INSERT INTO sales.drugs (id, name) VALUES (1, 'DrugA'), (2, 'DrugB'), (3, 'DrugC'), (4, 'DrugD'); INSERT INTO sales.sales_data (drug_id, year, revenue) VALUES (1, 2020, ... | What was the total sales revenue for the top 3 drugs in 2020? | SELECT d.name, SUM(sd.revenue) FROM sales.sales_data sd JOIN sales.drugs d ON sd.drug_id = d.id WHERE sd.year = 2020 GROUP BY d.name ORDER BY SUM(sd.revenue) DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE universities (name VARCHAR(255), state VARCHAR(255)); INSERT INTO universities (name, state) VALUES ('University1', 'New York'), ('University2', 'New York'), ('University3', 'Texas'); | Find the difference in the number of public universities between New York and Texas. | SELECT (SELECT COUNT(*) FROM universities WHERE state = 'New York') - (SELECT COUNT(*) FROM universities WHERE state = 'Texas'); | gretelai_synthetic_text_to_sql |
CREATE TABLE cases (id INT, attorney_id INT, state VARCHAR(2)); INSERT INTO cases (id, attorney_id, state) VALUES (1, 1001, 'NY'), (2, 1001, 'CA'), (3, 1002, 'TX'); CREATE TABLE attorneys (id INT, name VARCHAR(50)); INSERT INTO attorneys (id, name) VALUES (1001, 'John Doe'), (1002, 'Jane Smith'); | Who are the attorneys with cases in New York? | SELECT a.name FROM attorneys a INNER JOIN cases c ON a.id = c.attorney_id WHERE c.state = 'NY'; | gretelai_synthetic_text_to_sql |
CREATE TABLE MobileInvestments (Area varchar(10), Investment int, Service varchar(10)); CREATE TABLE BroadbandInvestments (Area varchar(10), Investment int, Service varchar(10)); INSERT INTO MobileInvestments (Area, Investment, Service) VALUES ('North', 100000, 'mobile'), ('South', 120000, 'mobile'), ('rural', 85000, '... | Display the total network investments made in 'rural' areas for mobile and broadband networks separately, and the difference between the two. | SELECT SUM(CASE WHEN Area = 'rural' AND Service = 'mobile' THEN Investment ELSE 0 END) AS RuralMobile, SUM(CASE WHEN Area = 'rural' AND Service = 'broadband' THEN Investment ELSE 0 END) AS RuralBroadband, RuralMobile - RuralBroadband AS InvestmentDifference FROM MobileInvestments MI JOIN BroadbandInvestments BI ON 1=1 ... | gretelai_synthetic_text_to_sql |
CREATE TABLE transportation (area VARCHAR(20), service_type VARCHAR(50), budget_allocation FLOAT); INSERT INTO transportation (area, service_type, budget_allocation) VALUES ('urban', 'public_transportation', 2000000), ('rural', 'public_transportation', 1500000); | Update the budget allocation for public transportation services in urban areas by 10%. | UPDATE transportation SET budget_allocation = budget_allocation * 1.1 WHERE area = 'urban' AND service_type = 'public_transportation'; | gretelai_synthetic_text_to_sql |
CREATE TABLE faculty_members (id INT, faculty_name VARCHAR(50), faculty_department VARCHAR(50), faculty_gender VARCHAR(10)); INSERT INTO faculty_members (id, faculty_name, faculty_department, faculty_gender) VALUES (1, 'Jane Smith', 'Management', 'Female'), (2, 'John Doe', 'Marketing', 'Male'), (3, 'Bob Johnson', 'Fina... | What is the percentage of female faculty members in the School of Business? | SELECT (COUNT(*) FILTER (WHERE faculty_gender = 'Female')) * 100.0 / COUNT(*) FROM faculty_members WHERE faculty_department LIKE '%Business%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE teams (id INT, region VARCHAR(10), players INT); INSERT INTO teams (id, region, players) VALUES (1, 'Europe', 50); INSERT INTO teams (id, region, players) VALUES (2, 'Asia', 75); INSERT INTO teams (id, region, players) VALUES (3, 'America', 100); | List eSports teams with the highest number of players | SELECT id, region, players FROM teams ORDER BY players DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE neighborhoods (name VARCHAR(255), zip_code VARCHAR(10)); INSERT INTO neighborhoods (name, zip_code) VALUES ('Central Park', '10022'), ('Harlem', '10026'), ('Brooklyn Heights', '11201'); CREATE TABLE emergency_calls (id INT, neighborhood VARCHAR(255), call_time TIMESTAMP); INSERT INTO emergency_calls (id, n... | What is the total number of emergency calls in each neighborhood? | SELECT neighborhood, COUNT(*) as total_calls FROM emergency_calls GROUP BY neighborhood; | gretelai_synthetic_text_to_sql |
CREATE TABLE satellites (id INT, name VARCHAR(255), country_of_origin VARCHAR(255), avg_distance FLOAT); | Update the name of the satellite with ID 456 to "Hubble". | UPDATE satellites SET name = 'Hubble' WHERE id = 456; | gretelai_synthetic_text_to_sql |
CREATE TABLE non_profit (id INT, name TEXT); INSERT INTO non_profit (id, name) VALUES (1, 'Habitat for Humanity'), (2, 'American Red Cross'), (3, 'Doctors Without Borders'); CREATE TABLE capacity_building (id INT, non_profit_id INT, activity_date DATE); INSERT INTO capacity_building (id, non_profit_id, activity_date) V... | List the names of all non-profits and the number of capacity building activities they have conducted in the last year. | SELECT n.name, COUNT(cb.id) as num_activities FROM non_profit n INNER JOIN capacity_building cb ON n.id = cb.non_profit_id WHERE cb.activity_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY n.id; | gretelai_synthetic_text_to_sql |
CREATE TABLE wildlife (id INT, forest_id INT, species VARCHAR(50)); | How many animal species inhabit the forests in the 'wildlife' table? | SELECT COUNT(DISTINCT species) FROM wildlife; | gretelai_synthetic_text_to_sql |
CREATE TABLE Military_Innovation (Nation VARCHAR(50), Continent VARCHAR(50), Project VARCHAR(50), Budget DECIMAL(10,2)); INSERT INTO Military_Innovation (Nation, Continent, Project, Budget) VALUES ('USA', 'Americas', 'Stealth Drone Project', 15000000.00), ('Brazil', 'Americas', 'Cyber Defense System', 12000000.00); | What is the total number of military innovation projects in the Americas that have a budget over $10 million? | SELECT SUM(Budget) FROM Military_Innovation WHERE Continent = 'Americas' AND Budget > 10000000; | gretelai_synthetic_text_to_sql |
CREATE TABLE projects (id INT, name TEXT, category TEXT, location TEXT, num_refugees INT, start_date DATE, end_date DATE); INSERT INTO projects (id, name, category, location, num_refugees, start_date, end_date) VALUES (1, 'Refugee Support Project', 'Refugee', 'South America', 150, '2019-01-01', '2019-12-31'), (2, 'Disa... | What is the maximum number of refugees supported by a single refugee support project in South America? | SELECT MAX(num_refugees) FROM projects WHERE category = 'Refugee' AND location = 'South America'; | gretelai_synthetic_text_to_sql |
CREATE TABLE artist (artist_id INT, artist_name VARCHAR(50)); INSERT INTO artist (artist_id, artist_name) VALUES (1, 'Artist A'), (2, 'Artist B'); CREATE TABLE song (song_id INT, song_name VARCHAR(50), artist_id INT, platform VARCHAR(20), release_date DATE); INSERT INTO song (song_id, song_name, artist_id, platform, re... | What is the release date of the earliest song by artists who have released songs on both the 'indie_platform' and 'mainstream_platform' platforms? | SELECT MIN(s.release_date) FROM song s JOIN (SELECT artist_id FROM song WHERE platform = 'indie_platform' INTERSECT SELECT artist_id FROM song WHERE platform = 'mainstream_platform') sub ON s.artist_id = sub.artist_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (DonorID INT, DonationDate DATE, DonationAmount DECIMAL(10,2)); CREATE TABLE Donors (DonorID INT, DonorName VARCHAR(50)); | Which donors have donated the most in the last 6 months? | SELECT d.DonorName, SUM(d.DonationAmount) FROM Donations d JOIN Donors don ON d.DonorID = don.DonorID WHERE d.DonationDate >= DATEADD(month, -6, GETDATE()) GROUP BY d.DonorID, don.DonorName ORDER BY SUM(d.DonationAmount) DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE Boroughs (BoroughID INT, BoroughName VARCHAR(255)); CREATE TABLE Properties (PropertyID INT, BoroughID INT, SalePrice DECIMAL(10,2)); | What is the minimum sale price for properties in each borough? | SELECT B.BoroughName, MIN(P.SalePrice) as MinSalePrice FROM Boroughs B JOIN Properties P ON B.BoroughID = P.BoroughID GROUP BY B.BoroughName; | gretelai_synthetic_text_to_sql |
CREATE TABLE maritime_safety_incidents (id INT, vessels INT, year INT, region VARCHAR(255)); INSERT INTO maritime_safety_incidents (id, vessels, year, region) VALUES (1, 3, 2018, 'Atlantic'); INSERT INTO maritime_safety_incidents (id, vessels, year, region) VALUES (2, 5, 2018, 'Atlantic'); | How many vessels were involved in maritime safety incidents in the Atlantic Ocean in 2018? | SELECT SUM(vessels) FROM maritime_safety_incidents WHERE region = 'Atlantic' AND year = 2018; | gretelai_synthetic_text_to_sql |
CREATE TABLE daily_fare_collection (collection_id INT, collection_date DATE, fare_amount DECIMAL); INSERT INTO daily_fare_collection (collection_id, collection_date, fare_amount) VALUES (1, '2023-03-01', 12000.00), (2, '2023-03-02', 15000.00), (3, '2023-03-03', 11000.00); | What is the maximum fare collected on a single day? | SELECT collection_date, MAX(fare_amount) AS max_daily_fare FROM daily_fare_collection GROUP BY collection_date; | gretelai_synthetic_text_to_sql |
CREATE TABLE LifeExpectancy (Country VARCHAR(50), Continent VARCHAR(50), Year INT, LifeExp DECIMAL(3,1)); INSERT INTO LifeExpectancy (Country, Continent, Year, LifeExp) VALUES ('Thailand', 'Southeast Asia', 2022, 76.7), ('Vietnam', 'Southeast Asia', 2022, 75.9), ('Cambodia', 'Southeast Asia', 2022, 70.6); | What is the life expectancy in Southeast Asian countries in 2022? | SELECT LifeExp FROM LifeExpectancy WHERE Continent = 'Southeast Asia' AND Year = 2022; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA teacher_development; CREATE TABLE teacher_development.workshops (workshop_id INT, teacher_id INT); CREATE TABLE teacher_development.teachers (teacher_id INT, name VARCHAR(50)); INSERT INTO teacher_development.teachers (teacher_id, name) VALUES (1001, 'Alice Johnson'), (1002, 'Bob Williams'); INSERT INTO t... | List all teachers who have led a professional development workshop in the 'teacher_development' schema | SELECT name FROM teacher_development.teachers WHERE teacher_id IN (SELECT teacher_id FROM teacher_development.workshops); | gretelai_synthetic_text_to_sql |
CREATE TABLE Vessels (ID INT, Name TEXT, Cargo_Weight INT, Voyages INT, Prefix TEXT, Year INT);CREATE VIEW Atlantic_Ocean_Vessels AS SELECT * FROM Vessels WHERE Region = 'Atlantic Ocean'; | What is the minimum cargo weight and the number of voyages for vessels with 'OOCL' prefix in the Atlantic Ocean in 2018? | SELECT MIN(Cargo_Weight), SUM(Voyages) FROM Atlantic_Ocean_Vessels WHERE Prefix = 'OOCL' AND Year = 2018; | gretelai_synthetic_text_to_sql |
CREATE TABLE forests (id INT, country VARCHAR(50), year INT, volume FLOAT); INSERT INTO forests (id, country, year, volume) VALUES (1, 'Canada', 2020, 50.5), (2, 'USA', 2020, 40.3), (3, 'China', 2020, 35.7), (4, 'Russia', 2020, 30.1); | What is the total volume of timber harvested in each country in 2020, sorted in descending order by total volume? | SELECT country, SUM(volume) AS total_volume FROM forests WHERE year = 2020 GROUP BY country ORDER BY total_volume DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE port_operations (id INT, port VARCHAR(50), operation_type VARCHAR(50), container_count INT); INSERT INTO port_operations (id, port, operation_type, container_count) VALUES (1, 'LA', 'Load', 200), (2, 'LA', 'Unload', 150), (3, 'NY', 'Load', 300), (4, 'NY', 'Unload', 250); | What is the number of containers loaded and unloaded at port 'LA' in the 'port_operations' table? | SELECT SUM(container_count) FROM port_operations WHERE port = 'LA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE players (id INT, name VARCHAR(50), age INT, gender VARCHAR(10), sport VARCHAR(20));INSERT INTO players (id, name, age, gender, sport) VALUES (1, 'Alice', 25, 'Female', 'Soccer'); INSERT INTO players (id, name, age, gender, sport) VALUES (2, 'Bella', 30, 'Female', 'Soccer'); | What is the average age of female soccer players in the WPSL? | SELECT AVG(age) FROM players WHERE gender = 'Female' AND sport = 'Soccer'; | gretelai_synthetic_text_to_sql |
CREATE TABLE company_founding(id INT PRIMARY KEY, company_name VARCHAR(100), founder_gender VARCHAR(10)); CREATE TABLE investment_rounds(id INT PRIMARY KEY, company_id INT, round_type VARCHAR(50), funding_amount INT); INSERT INTO company_founding VALUES (1, 'Acme Inc', 'Female'); INSERT INTO company_founding VALUES (2,... | List all companies that have a female founder and have raised a Series A round | SELECT cf.company_name FROM company_founding cf INNER JOIN investment_rounds ir ON cf.id = ir.company_id WHERE ir.round_type = 'Series A' AND cf.founder_gender = 'Female'; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA city; CREATE SCHEMA state; CREATE TABLE city.civic_data (id INT, name VARCHAR(255), is_open BOOLEAN); CREATE TABLE state.civic_data (id INT, name VARCHAR(255), is_open BOOLEAN); INSERT INTO city.civic_data (id, name, is_open) VALUES (1, 'traffic', true), (2, 'crime', false); INSERT INTO state.civic_data (... | What is the total number of open civic data sets in 'city' and 'state' schemas? | SELECT COUNT(*) FROM ( (SELECT * FROM city.civic_data WHERE is_open = true) UNION (SELECT * FROM state.civic_data WHERE is_open = true) ) AS combined_civic_data; | gretelai_synthetic_text_to_sql |
CREATE TABLE museum_visitors (id INT, age INT, country VARCHAR(255)); INSERT INTO museum_visitors (id, age, country) VALUES (1, 8, 'France'), (2, 10, 'Germany'), (3, 6, 'France'); | How many primary school children visited the museum last year from France? | SELECT COUNT(*) FROM museum_visitors WHERE age BETWEEN 6 AND 11 AND country = 'France'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Port (PortID INT, PortName VARCHAR(100), City VARCHAR(100), Country VARCHAR(100)); INSERT INTO Port (PortID, PortName, City, Country) VALUES (1, 'Port of Los Angeles', 'Los Angeles', 'USA'); INSERT INTO Port (PortID, PortName, City, Country) VALUES (2, 'Port of Rotterdam', 'Rotterdam', 'Netherlands'); CREA... | What is the average gross tonnage of vessels per port, ordered by the highest average? | SELECT PortID, AVG(GrossTonnage) OVER(PARTITION BY PortID ORDER BY PortID) AS AvgGT FROM Vessel ORDER BY AvgGT DESC | gretelai_synthetic_text_to_sql |
CREATE TABLE spacecraft (spacecraft_id INT, name VARCHAR(50), manufacturing_country VARCHAR(50), launch_date DATE); | List all spacecraft with manufacturing country and launch date. | SELECT name, manufacturing_country, launch_date FROM spacecraft; | gretelai_synthetic_text_to_sql |
CREATE TABLE defense_contracts(id INT, company VARCHAR(50), amount INT, award_date DATE); | Identify the defense contracts awarded to companies located in New York and New Jersey with an amount between $250,000 and $750,000, and their respective award dates. | SELECT company, amount, award_date FROM defense_contracts WHERE state IN ('New York', 'New Jersey') AND amount BETWEEN 250000 AND 750000; | gretelai_synthetic_text_to_sql |
CREATE TABLE games (id INT, game_date DATE, team VARCHAR(20)); CREATE TABLE points (id INT, game_id INT, player VARCHAR(20), points INT); | What is the average number of points scored per game by each basketball player in the last season? | SELECT team, player, AVG(points) FROM points JOIN games ON points.game_id = games.id WHERE games.game_date >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR) AND games.team = 'Boston Celtics' GROUP BY team, player; | gretelai_synthetic_text_to_sql |
CREATE TABLE VehiclePrices (id INT PRIMARY KEY, manufacturer VARCHAR(50), vehicle_type VARCHAR(50), price DECIMAL(10,2)); INSERT INTO VehiclePrices (id, manufacturer, vehicle_type, price) VALUES (1, 'Lockheed Martin', 'F-35 Fighter Jet', 100000000.00), (2, 'General Dynamics', 'M1 Abrams Tank', 8000000.00), (3, 'Boeing'... | Which military vehicles have the highest and lowest average price by manufacturer? | SELECT manufacturer, vehicle_type, MAX(price) as max_price, MIN(price) as min_price FROM VehiclePrices GROUP BY manufacturer; | gretelai_synthetic_text_to_sql |
CREATE TABLE Inventory(item_id INT, item_name VARCHAR(50), is_non_gmo BOOLEAN, price DECIMAL(5,2)); INSERT INTO Inventory VALUES(1,'Apples',TRUE,0.99),(2,'Bananas',TRUE,1.49),(3,'Corn',FALSE,1.25); | Find the average price of non-GMO items in the inventory. | SELECT AVG(price) FROM Inventory WHERE is_non_gmo = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE articles (author VARCHAR(50), article_language VARCHAR(50), article_title VARCHAR(100), publication_date DATE); INSERT INTO articles (author, article_language, article_title, publication_date) VALUES ('Sofia Garcia', 'Spanish', 'Article 1', '2021-01-01'); INSERT INTO articles (author, article_language, art... | Which authors have published the most articles in a specific language? | SELECT author, COUNT(*) as article_count FROM articles WHERE article_language = 'Spanish' GROUP BY author ORDER BY article_count DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artists (ArtistID INT, Name VARCHAR(100), Nationality VARCHAR(50)); INSERT INTO Artists VALUES (1, 'Pablo Picasso', 'Spanish'); INSERT INTO Artists VALUES (2, 'Henri Matisse', 'French'); CREATE TABLE Artwork (ArtworkID INT, Title VARCHAR(100), Type VARCHAR(50), Price FLOAT, ArtistID INT); INSERT INTO Artwo... | What is the total value of artwork for each artist? | SELECT AR.Name, SUM(A.Price) FROM Artwork A JOIN Artists AR ON A.ArtistID = AR.ArtistID GROUP BY AR.Name; | gretelai_synthetic_text_to_sql |
CREATE TABLE socially_responsible_loans_2021 (region TEXT, num_loans INTEGER, loan_date DATE); INSERT INTO socially_responsible_loans_2021 (region, num_loans, loan_date) VALUES ('North', 200, '2021-04-01'), ('South', 300, '2021-02-15'), ('East', 150, '2021-06-20'); | How many socially responsible loans were issued by region in the country in 2021? | SELECT region, SUM(num_loans) FROM socially_responsible_loans_2021 GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE careers (player VARCHAR(100), team VARCHAR(100), goals INT); INSERT INTO careers (player, team, goals) VALUES ('Lionel Messi', 'Barcelona', 672), ('Cristiano Ronaldo', 'Real Madrid', 450); | What is the total number of goals scored by Messi and Ronaldo in their club careers? | SELECT SUM(goals) FROM careers WHERE player IN ('Lionel Messi', 'Cristiano Ronaldo'); | gretelai_synthetic_text_to_sql |
CREATE TABLE healthcare_workers (id INT, name VARCHAR(50), age INT, gender VARCHAR(10), location VARCHAR(50)); INSERT INTO healthcare_workers (id, name, age, gender, location) VALUES (1, 'John Doe', 35, 'Male', 'New York'); INSERT INTO healthcare_workers (id, name, age, gender, location) VALUES (2, 'Jane Smith', 32, 'F... | What is the average age of healthcare workers by location in the "healthcare_workers" table? | SELECT location, AVG(age) FROM healthcare_workers GROUP BY location; | gretelai_synthetic_text_to_sql |
CREATE TABLE materials (material_id INT, material_sustainable BOOLEAN, material_purchase_date DATE); | How many sustainable materials have been used in production since 2020? | SELECT COUNT(*) AS sustainable_material_count FROM materials WHERE material_sustainable = TRUE AND material_purchase_date >= '2020-01-01' | gretelai_synthetic_text_to_sql |
CREATE TABLE south_america_population (id INT, city VARCHAR(50), population INT, year INT); INSERT INTO south_america_population (id, city, population, year) VALUES (1, 'Lima', 10000000, 2020); INSERT INTO south_america_population (id, city, population, year) VALUES (2, 'Santiago', 8000000, 2020); CREATE TABLE south_am... | What is the average water consumption per capita in the cities of Lima and Santiago for the year 2020? | SELECT AVG(sawc.water_consumption / sap.population) FROM south_america_water_consumption sawc INNER JOIN south_america_population sap ON sawc.city = sap.city WHERE sawc.year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE reservoirs (reservoir_id INT, reservoir_name VARCHAR(255), field_name VARCHAR(255), oil_grade VARCHAR(255), gas_content FLOAT); | Show the average gas content for all reservoirs in field 'F-01' | SELECT AVG(gas_content) FROM reservoirs WHERE field_name = 'F-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE companies (company_id INT, name TEXT, industry TEXT, num_employees INT); INSERT INTO companies (company_id, name, industry, num_employees) VALUES (1, 'GreenTech', 'Manufacturing', 75), (2, 'EcoPlants', 'Manufacturing', 35), (3, 'BlueFactory', 'Retail', 200), (4, 'GreenBuild', 'Manufacturing', 60); CREATE T... | Display the number of employees and total salary expenses for companies with more than 50 employees in the manufacturing industry. | SELECT c.name, SUM(s.salary) AS total_salary_expense FROM companies c INNER JOIN salaries s ON c.company_id = s.company_id WHERE c.industry = 'Manufacturing' GROUP BY c.company_id HAVING COUNT(s.employee_id) > 50; | gretelai_synthetic_text_to_sql |
CREATE TABLE platforms (id INT, location VARCHAR(50), status VARCHAR(50)); INSERT INTO platforms (id, location, status) VALUES (1, 'South China Sea', 'Active'); | Count of active platforms in the South China Sea. | SELECT COUNT(*) FROM platforms WHERE location = 'South China Sea' AND status = 'Active'; | gretelai_synthetic_text_to_sql |
CREATE TABLE lgbtq_data (id INT, county TEXT, lgbtq INT, population INT); INSERT INTO lgbtq_data (id, county, lgbtq, population) VALUES (1, 'County A', 200, 10000), (2, 'County B', 300, 20000); | Find the percentage of people who identify as LGBTQ+ in each county, ordered from the highest to lowest? | SELECT county, (SUM(lgbtq) OVER (PARTITION BY county)) * 100.0 / SUM(population) OVER (PARTITION BY county) as pct_lgbtq FROM lgbtq_data ORDER BY pct_lgbtq DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE teacher_mental_health (teacher_id INT, state VARCHAR(50), score INT); INSERT INTO teacher_mental_health (teacher_id, state, score) VALUES (1, 'California', 75), (2, 'Texas', 80), (3, 'California', 70); | Which states have the highest and lowest average mental health scores for teachers? | SELECT state, AVG(score) as avg_score FROM teacher_mental_health GROUP BY state ORDER BY avg_score DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE hospitals (id INT, state CHAR(2), num_beds INT, rural_hospital BOOLEAN); INSERT INTO hospitals (id, state, num_beds, rural_hospital) VALUES (1, 'TX', 50, true), (2, 'CA', 100, false); | Find the top 3 states with the highest number of rural hospitals. | SELECT state, ROW_NUMBER() OVER (ORDER BY COUNT(*) DESC) as rank FROM hospitals WHERE rural_hospital = true GROUP BY state LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE ticket_sales_data (sport VARCHAR(20), ticket_sales INT); | Which sports have the highest average ticket sales and the lowest average ticket sales? | SELECT sport, AVG(ticket_sales) AS avg_sales FROM ticket_sales_data GROUP BY sport ORDER BY avg_sales DESC, sport LIMIT 2; SELECT sport, AVG(ticket_sales) AS avg_sales FROM ticket_sales_data GROUP BY sport ORDER BY avg_sales ASC, sport LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE consumer_preferences (id INT, consumer_id INT, product_id INT, preference_score INT, country VARCHAR(50)); INSERT INTO consumer_preferences (id, consumer_id, product_id, preference_score, country) VALUES (1, 1, 101, 8, 'Asia-Pacific'), (2, 2, 102, 9, 'Asia-Pacific'), (3, 3, 101, 7, 'Asia-Pacific'), (4, 4, ... | What is the total preference score for each product in the Europe region? | SELECT product_id, SUM(preference_score) as total_score FROM consumer_preferences WHERE country = 'Europe' GROUP BY product_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE rural_hospitals (id INT, name VARCHAR(50), beds INT, location VARCHAR(50)); | Update the number of beds to 75 in the record with the name 'Eureka Community Hospital' in the 'rural_hospitals' table | UPDATE rural_hospitals SET beds = 75 WHERE name = 'Eureka Community Hospital'; | gretelai_synthetic_text_to_sql |
CREATE TABLE customers (customer_id INT, name VARCHAR(255), state VARCHAR(255), financial_literacy_score INT); | What is the distribution of financial literacy scores for customers in Texas? | SELECT state, COUNT(*) as count, MIN(financial_literacy_score) as min_score, AVG(financial_literacy_score) as avg_score, MAX(financial_literacy_score) as max_score FROM customers WHERE state = 'Texas' GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE EsportsEvents (id INT, name VARCHAR(50), country VARCHAR(50), num_events INT); INSERT INTO EsportsEvents (id, name, country, num_events) VALUES (1, 'Event1', 'USA', 2), (2, 'Event2', 'Canada', 3), (3, 'Event3', 'USA', 5); | How many esports events have been held in each country, and what is the maximum number of events held in a country? | SELECT country, COUNT(*) AS num_events, MAX(num_events) AS max_events_per_country FROM EsportsEvents GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE memberships (user_id INT, membership_type VARCHAR(10)); CREATE TABLE workouts (workout_id INT, user_id INT, workout_type VARCHAR(20), heart_rate INT); | What is the average heart rate for users with a 'standard' membership type during their strength training workouts? | SELECT AVG(heart_rate) FROM workouts JOIN memberships ON workouts.user_id = memberships.user_id WHERE memberships.membership_type = 'standard' AND workout_type = 'strength training'; | gretelai_synthetic_text_to_sql |
CREATE TABLE posts (id INT, user_id INT, post_text TEXT); CREATE TABLE users (id INT, privacy_setting VARCHAR(20)); INSERT INTO users (id, privacy_setting) VALUES (1, 'medium'), (2, 'high'), (3, 'low'); INSERT INTO posts (id, user_id, post_text) VALUES (1, 1, 'Hello World!'), (2, 2, 'Goodbye World!'), (3, 3, 'This is a... | Delete all posts from users who have a privacy setting of 'low' | DELETE t1 FROM posts t1 JOIN users t2 ON t1.user_id = t2.id WHERE t2.privacy_setting = 'low'; | gretelai_synthetic_text_to_sql |
CREATE TABLE social_enterprises (id INT, category TEXT, ESG_rating FLOAT, risk_score FLOAT); | Add a new social enterprise in the 'Housing' category with an ESG rating of 9.0 and a risk score of 1.8 | INSERT INTO social_enterprises (id, category, ESG_rating, risk_score) VALUES (7, 'Housing', 9.0, 1.8); | gretelai_synthetic_text_to_sql |
CREATE TABLE Players (PlayerID INT PRIMARY KEY, Name VARCHAR(50), Age INT, Gender VARCHAR(10)); INSERT INTO Players (PlayerID, Name, Age, Gender) VALUES (1, 'John Doe', 25, 'Male'); INSERT INTO Players (PlayerID, Name, Age, Gender) VALUES (2, 'Jane Doe', 30, 'Female'); | Update the gender of a player with a given ID | UPDATE Players SET Gender = 'Non-binary' WHERE PlayerID = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE attorneys (attorney_id INT, name TEXT); INSERT INTO attorneys (attorney_id, name) VALUES (1, 'John Smith'), (2, 'Jane Smith'), (3, 'Bob Johnson'); CREATE TABLE cases (case_id INT, attorney_id INT, billing_amount INT); INSERT INTO cases (case_id, attorney_id, billing_amount) VALUES (1, 1, 5000), (2, 1, 7000... | What is the total billing amount for cases handled by attorneys named 'John Smith'? | SELECT SUM(billing_amount) FROM cases WHERE attorney_id IN (SELECT attorney_id FROM attorneys WHERE name = 'John Smith') | gretelai_synthetic_text_to_sql |
CREATE SCHEMA state; CREATE SCHEMA county; CREATE SCHEMA city; CREATE TABLE state.diversity_data (id INT, name VARCHAR(255), is_open BOOLEAN); CREATE TABLE county.diversity_data (id INT, name VARCHAR(255), is_open BOOLEAN); CREATE TABLE city.diversity_data (id INT, name VARCHAR(255), is_open BOOLEAN); INSERT INTO state... | Find the intersection of open data sets related to diversity in 'state', 'county', and 'city' schemas. | SELECT * FROM ( (SELECT * FROM state.diversity_data WHERE is_open = true) INTERSECT (SELECT * FROM county.diversity_data WHERE is_open = true) INTERSECT (SELECT * FROM city.diversity_data WHERE is_open = true) ) AS intersected_data; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (id INT, species_name TEXT, ocean_basin TEXT); | How many marine species are present in each ocean basin? | SELECT species_name, ocean_basin, COUNT(*) FROM marine_species GROUP BY ocean_basin; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists military_spending;CREATE TABLE if not exists military_spending_data(country text, military_spending integer, year integer);INSERT INTO military_spending_data(country, military_spending, year) VALUES('United States', 732, 2020), ('United Kingdom', 60, 2020), ('France', 50, 2020), ('Germany', ... | What was the total military spending by NATO countries in 2020? | SELECT SUM(military_spending) FROM military_spending_data WHERE country IN ('United States', 'United Kingdom', 'France', 'Germany', 'Italy', 'Canada') AND year = 2020; | 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.