context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE garment_info (garment_id INT, sustainability_rating DECIMAL(3, 2)); INSERT INTO garment_info (garment_id, sustainability_rating) VALUES (1001, 4.2), (1002, 3.5), (1003, 4.8), (1004, 2.9), (1005, 4.5), (1006, 3.7); CREATE TABLE garment_manufacturing (manufacturing_id INT, garment_id INT, country VARCHAR(255... | What is the average sustainability rating for garments manufactured in Asia? | SELECT AVG(g.sustainability_rating) AS avg_sustainability_rating FROM garment_info g INNER JOIN garment_manufacturing m ON g.garment_id = m.garment_id WHERE m.country IN ('India', 'Vietnam', 'China', 'Bangladesh', 'Indonesia'); | gretelai_synthetic_text_to_sql |
CREATE TABLE companies (id INT, name TEXT, industry TEXT, founding_date DATE, founder_race TEXT);CREATE TABLE company_founders (company_id INT, founder_id INT);CREATE TABLE founders (id INT, race TEXT); | Identify the number of unique companies founded by a person who identifies as a person of color in the cleantech industry. | SELECT COUNT(DISTINCT companies.id) FROM companies INNER JOIN company_founders ON companies.id = company_founders.company_id INNER JOIN founders ON company_founders.founder_id = founders.id WHERE companies.industry = 'cleantech' AND founders.race = 'person of color'; | gretelai_synthetic_text_to_sql |
CREATE TABLE green_blogs (id INT, title TEXT, content TEXT, likes INT); | Get the average number of likes for posts containing the word "sustainability" in the "green_blogs" table. | SELECT AVG(likes) FROM green_blogs WHERE content LIKE '%sustainability%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE creators (id INT, underrepresented BOOLEAN, hours_of_content FLOAT); INSERT INTO creators (id, underrepresented, hours_of_content) VALUES (1, TRUE, 10.5), (2, FALSE, 15.2), (3, TRUE, 8.9); | What's the total number of hours of content produced by creators from underrepresented communities? | SELECT SUM(hours_of_content) FROM creators WHERE underrepresented = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE Sales (salesperson_id INT, salesperson_name TEXT, virtual_tours INT); INSERT INTO Sales (salesperson_id, salesperson_name, virtual_tours) VALUES (1, 'Samira Rodriguez', 12), (2, 'Hiroshi Nakamura', 17); | What is the average number of virtual tours per salesperson in the 'Sales' table? | SELECT AVG(virtual_tours) FROM Sales; | gretelai_synthetic_text_to_sql |
CREATE TABLE world_heritage_sites (site_id INT, name TEXT, location TEXT, rating FLOAT); INSERT INTO world_heritage_sites (site_id, name, location, rating) VALUES (1, 'Mount Fuji', 'Japan', 4.3), (2, 'Himeji Castle', 'Japan', 4.8); | Which UNESCO World Heritage sites in Japan have a rating higher than 4.5? | SELECT name FROM world_heritage_sites WHERE location = 'Japan' AND rating > 4.5; | gretelai_synthetic_text_to_sql |
CREATE TABLE fish_biomass (id INT, farm_id INT, species TEXT, biomass INT, country TEXT, water_type TEXT); INSERT INTO fish_biomass (id, farm_id, species, biomass, country, water_type) VALUES (1, 1, 'Seabass', 2000, 'Greece', 'Marine'); INSERT INTO fish_biomass (id, farm_id, species, biomass, country, water_type) VALUE... | What is the total biomass of fish in marine cages in Greece? | SELECT SUM(biomass) FROM fish_biomass WHERE country = 'Greece' AND water_type = 'Marine'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ad_funding (id INT, project VARCHAR(50), region VARCHAR(50), funding FLOAT); INSERT INTO ad_funding VALUES (1, 'Project Gamma', 'Europe', 6000000); INSERT INTO ad_funding VALUES (2, 'Project Delta', 'Asia', 5500000); | Get total funding for autonomous driving research projects in Europe | SELECT SUM(funding) FROM ad_funding WHERE region = 'Europe'; | gretelai_synthetic_text_to_sql |
CREATE TABLE agents (agent_id INT, region VARCHAR(20)); CREATE TABLE policyholders (policyholder_id INT, region VARCHAR(20)); CREATE TABLE policies (policy_id INT, agent_id INT, policyholder_id INT, issue_date DATE); INSERT INTO agents (agent_id, region) VALUES (1, 'Southeast'), (2, 'Southeast'), (3, 'Northwest'), (4, ... | Insert a new policy record for agent 4, for a policyholder in the Northern region, for the month of March 2022, with a policy_id of 6. | INSERT INTO policies (policy_id, agent_id, policyholder_id, issue_date) VALUES (6, 4, 4, '2022-03-01'); | gretelai_synthetic_text_to_sql |
CREATE TABLE supply_chain (supplier_id INT, supplier_name TEXT); CREATE TABLE supplier_regions (region_id INT, supplier_id INT, region_name TEXT); | Show the number of suppliers in each region from the supply_chain and supplier_regions tables. | SELECT supplier_regions.region_name, COUNT(supply_chain.supplier_id) FROM supply_chain INNER JOIN supplier_regions ON supply_chain.supplier_id = supplier_regions.supplier_id GROUP BY supplier_regions.region_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT, Department VARCHAR(20), Salary DECIMAL(10,2)); INSERT INTO Employees (EmployeeID, Department, Salary) VALUES (1, 'IT', 70000.00), (2, 'Marketing', 55000.00), (3, 'Marketing', 58000.00), (4, 'HR', 60000.00), (5, 'HR', 62000.00), (6, 'Diversity & Inclusion', 75000.00); | Update the department of employee with ID 3 to 'Learning & Development'. | UPDATE Employees SET Department = 'Learning & Development' WHERE EmployeeID = 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE fiscal_years (year_id INT, year_start DATE, year_end DATE); INSERT INTO fiscal_years (year_id, year_start, year_end) VALUES (1, '2019-01-01', '2019-12-31'), (2, '2020-01-01', '2020-12-31'), (3, '2021-01-01', '2021-12-31'); CREATE TABLE budget_allocations (budget_id INT, district_id INT, department VARCHAR(... | What is the total budget allocated for public transportation in rural areas in the last 3 years? | SELECT SUM(amount) FROM budget_allocations WHERE department = 'Public Transportation' AND area_type = 'Rural' AND year_id IN (SELECT year_id FROM fiscal_years WHERE year_start >= DATEADD(year, -3, GETDATE())); | gretelai_synthetic_text_to_sql |
CREATE TABLE MentalHealthParity (Region VARCHAR(50), PayerType VARCHAR(50), Score DECIMAL(3,2)); INSERT INTO MentalHealthParity (Region, PayerType, Score) VALUES ('Northeast', 'Medicare', 0.75), ('Northeast', 'Medicaid', 0.78), ('Northeast', 'Private', 0.82), ('Midwest', 'Medicare', 0.72), ('Midwest', 'Medicaid', 0.76)... | Identify the top 3 regions with the highest mental health parity scores, partitioned by payer type and ordered by the highest mental health parity score within each payer type. | SELECT Region, PayerType, Score, RANK() OVER (PARTITION BY PayerType ORDER BY Score DESC) as Rank FROM MentalHealthParity WHERE Rank <= 3 ORDER BY PayerType, Score DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE departments (id INT, name VARCHAR(50)); CREATE TABLE grants (id INT, department_id INT, amount INT); INSERT INTO departments VALUES (1, 'Psychology'), (2, 'Sociology'), (3, 'Anthropology'); INSERT INTO grants VALUES (1, 1, 5000), (2, 1, 7000), (3, 2, 6000), (4, 3, 4000); | Find the number of grants awarded to each department in the College of Social Sciences. | SELECT department_id, COUNT(*) AS grant_count FROM grants GROUP BY department_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artworks (artwork_id INT, title TEXT, creation_year INT, art_movement TEXT); INSERT INTO Artworks (artwork_id, title, creation_year, art_movement) VALUES (1, 'Impression, Sunrise', 1872, 'Impressionism'), (2, 'Water Lilies', 1900, 'Impressionism'); | What are the titles and creation years of all artworks with 'impressionism' in the title? | SELECT title, creation_year FROM Artworks WHERE art_movement LIKE '%impressionism%'; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA peace_operations;CREATE TABLE african_union_operations (operation_name VARCHAR(50), year INT, organization VARCHAR(50));INSERT INTO african_union_operations (operation_name, year, organization) VALUES ('Mali I', 2015, 'African Union'), ('Somalia II', 2016, 'African Union'), ('Darfur', 2017, 'African Union... | How many peacekeeping operations were conducted by the African Union between 2015 and 2020? | SELECT COUNT(*) FROM peace_operations.african_union_operations WHERE organization = 'African Union' AND year BETWEEN 2015 AND 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE investments (id INT, esg_factor VARCHAR(20)); INSERT INTO investments (id, esg_factor) VALUES (1, 'Carbon Emissions'), (2, 'Water Usage'); | Insert a new ESG factor for the given investment id. | INSERT INTO investments (id, esg_factor) VALUES (3, 'Biodiversity Impact'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Cases (CaseID int, ClientID int, Category varchar(50)); INSERT INTO Cases (CaseID, ClientID, Category) VALUES (201, 2, 'Family'); CREATE TABLE Clients (ClientID int, Age int, Gender varchar(10)); INSERT INTO Clients (ClientID, Age, Gender) VALUES (2, 32, 'Female'); | What is the average age of clients who won cases in the 'family' category? | SELECT AVG(C.Age) as AvgAge FROM Clients C INNER JOIN Cases CA ON C.ClientID = CA.ClientID INNER JOIN CaseOutcomes CO ON CA.CaseID = CO.CaseID WHERE CA.Category = 'Family' AND CO.Outcome = 'Won'; | gretelai_synthetic_text_to_sql |
CREATE TABLE EsportsEvents (EventID INT, Game VARCHAR(20), Spectators INT); INSERT INTO EsportsEvents (EventID, Game, Spectators) VALUES (1, 'Fighting', 5000); | What is the average number of spectators in fighting game esports events? | SELECT AVG(Spectators) FROM EsportsEvents WHERE Game = 'Fighting'; | gretelai_synthetic_text_to_sql |
CREATE TABLE member_demographics (member_id INT, age INT, gender VARCHAR(10), heart_rate INT); INSERT INTO member_demographics (member_id, age, gender, heart_rate) VALUES (1, 27, 'Female', 80), (2, 31, 'Male', 75), (3, 25, 'Male', 90), (4, 28, 'Female', 70), (5, 30, 'Male', 85); | How many male and female members are there in total? | SELECT gender, COUNT(*) FROM member_demographics GROUP BY gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteer_hours (id INT, volunteer_id INT, category VARCHAR(20), hours INT, hour_date DATE); INSERT INTO volunteer_hours (id, volunteer_id, category, hours, hour_date) VALUES (1, 1, 'Education', 5, '2021-01-05'), (2, 2, 'Health', 7, '2021-01-10'), (3, 3, 'Education', 6, '2021-02-15'), (4, 4, 'Arts & Cultur... | What was the total number of volunteer hours in the 'Education' category in 2021? | SELECT SUM(hours) as total_volunteer_hours FROM volunteer_hours WHERE category = 'Education' AND YEAR(hour_date) = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE Eagle_Ford_Shale (well_id INT, company VARCHAR(255), production_bopd FLOAT); INSERT INTO Eagle_Ford_Shale (well_id, company, production_bopd) VALUES (1, 'Company X', 250), (2, 'Company Y', 300), (3, 'Company X', 350), (4, 'Company Z', 150); | What is the total production for wells in the Eagle Ford Shale owned by Company X? | SELECT SUM(production_bopd) FROM Eagle_Ford_Shale WHERE company = 'Company X'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (donor_id INT, donation_amount DECIMAL(10,2), donor_region VARCHAR(255), donation_date DATE); INSERT INTO Donors (donor_id, donation_amount, donor_region, donation_date) VALUES (1, 500, 'North', '2022-01-01'), (2, 350, 'South', '2022-02-01'), (3, 700, 'East', '2022-03-01'), (4, 280, 'West', '2022-04... | What was the average donation amount per donor by region for 2022? | SELECT donor_region, AVG(donation_amount) as avg_donation FROM Donors WHERE donation_date BETWEEN '2022-01-01' AND '2022-12-31' GROUP BY donor_region; | gretelai_synthetic_text_to_sql |
CREATE TABLE cultural_heritage (id INT, name TEXT, location TEXT, virtual_tour_id INT, rating INT); INSERT INTO cultural_heritage (id, name, location, virtual_tour_id, rating) VALUES (1, 'Acropolis', 'Greece', 1, 4); INSERT INTO cultural_heritage (id, name, location, virtual_tour_id, rating) VALUES (2, 'Machu Picchu', ... | What is the average virtual tour rating for each cultural heritage site? | SELECT virtual_tour_id, AVG(rating) as avg_rating FROM cultural_heritage GROUP BY virtual_tour_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE open_data_initiatives (initiative VARCHAR(50), num_datasets INT); INSERT INTO open_data_initiatives (initiative, num_datasets) VALUES ('Initiative A', 200), ('Initiative B', 150), ('Initiative C', 250); | What is the maximum number of datasets released in a single open data initiative? | SELECT MAX(num_datasets) FROM open_data_initiatives; | gretelai_synthetic_text_to_sql |
CREATE TABLE lifelong_learners (student_id INT, gender VARCHAR(10), enrolled_in_course BOOLEAN); INSERT INTO lifelong_learners (student_id, gender, enrolled_in_course) VALUES (1, 'Female', true), (2, 'Male', false), (3, 'Female', true), (4, 'Non-binary', true), (5, 'Male', true), (6, 'Female', false); | What is the percentage of lifelong learners by gender? | SELECT gender, (SUM(enrolled_in_course) * 100.0 / COUNT(*)) AS percentage FROM lifelong_learners GROUP BY gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE fish_stock (species VARCHAR(255), harvest_date DATE, quantity INT); | What is the total quantity of fish harvested per species in 2022? | SELECT species, SUM(quantity) AS total_quantity FROM fish_stock WHERE harvest_date BETWEEN '2022-01-01' AND '2022-12-31' GROUP BY species; | gretelai_synthetic_text_to_sql |
CREATE TABLE SalesByWeek (SaleID INT, ProductCategory VARCHAR(255), SaleDate DATE); CREATE TABLE QuantitySold (QuantitySoldID INT, SaleID INT, Quantity INT); INSERT INTO SalesByWeek (SaleID, ProductCategory, SaleDate) VALUES (1, 'Flower', '2022-01-01'), (2, 'Concentrates', '2022-01-05'), (3, 'Edibles', '2022-01-10'); I... | What is the total quantity of each product category sold in the last week? | SELECT ProductCategory, SUM(Quantity) AS TotalQuantitySold FROM SalesByWeek JOIN QuantitySold ON SalesByWeek.SaleID = QuantitySold.SaleID WHERE SaleDate >= DATEADD(WEEK, -1, GETDATE()) GROUP BY ProductCategory; | gretelai_synthetic_text_to_sql |
CREATE TABLE suppliers (id INT, name TEXT, country TEXT); INSERT INTO suppliers (id, name, country) VALUES (1, 'Supplier A', 'USA'), (2, 'Supplier B', 'Germany'), (3, 'Supplier C', 'France'), (4, 'Supplier D', 'Italy'); CREATE TABLE supplier_products (supplier_id INT, product TEXT); INSERT INTO supplier_products (suppl... | List the names of all suppliers that provide products to retailers located in both the US and Europe. | SELECT DISTINCT suppliers.name FROM suppliers INNER JOIN supplier_products ON suppliers.id = supplier_products.supplier_id INNER JOIN retailer_products ON supplier_products.product = retailer_products.product INNER JOIN retailers ON retailer_products.retailer_id = retailers.id WHERE retailers.country IN ('USA', 'German... | gretelai_synthetic_text_to_sql |
CREATE TABLE projects (id INT, country VARCHAR(50), start_date DATE, end_date DATE, cost FLOAT); INSERT INTO projects (id, country, start_date, end_date, cost) VALUES (1, 'Colombia', '2015-01-01', '2017-12-31', 600000), (2, 'Colombia', '2016-01-01', '2018-12-31', 700000), (3, 'Colombia', '2018-01-01', '2019-12-31', 800... | What is the total number of rural infrastructure projects in Colombia that were completed before 2018? | SELECT COUNT(*) FROM projects WHERE country = 'Colombia' AND (YEAR(end_date) < 2018 OR end_date IS NULL); | gretelai_synthetic_text_to_sql |
CREATE TABLE painters (name VARCHAR(255), paintings INT); INSERT INTO painters (name, paintings) VALUES ('Leonardo da Vinci', 7), ('Pablo Picasso', 5), ('Vincent van Gogh', 4); | What is the name of the artist who painted the most famous painting? | SELECT name FROM painters WHERE paintings = (SELECT MAX(paintings) FROM painters); | gretelai_synthetic_text_to_sql |
CREATE TABLE patients (id INT, age INT, gender TEXT, state TEXT, condition TEXT); INSERT INTO patients (id, age, gender, state, condition) VALUES (1, 45, 'Male', 'New York', 'Depression'); INSERT INTO patients (id, age, gender, state, condition) VALUES (2, 50, 'Female', 'California', 'Anxiety'); | What is the average age of patients diagnosed with depression in New York? | SELECT AVG(age) FROM patients WHERE state = 'New York' AND condition = 'Depression'; | gretelai_synthetic_text_to_sql |
CREATE TABLE EmissionsData (Country VARCHAR(50), Year INT, CO2Emission DECIMAL(5,2), Population INT); INSERT INTO EmissionsData (Country, Year, CO2Emission, Population) VALUES ('China', 2020, 10.3, 1411000000), ('China', 2019, 9.6, 1409000000), ('India', 2020, 2.1, 1366000000), ('India', 2019, 1.9, 1352000000); | Find the average CO2 emission per capita for each country in 2020, and rank them. | SELECT Country, AVG(CO2Emission/Population) as AvgCO2PerCapita, RANK() OVER (ORDER BY AVG(CO2Emission/Population) DESC) as Rank FROM EmissionsData WHERE Year = 2020 GROUP BY Country HAVING COUNT(*) > 1 ORDER BY Rank; | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (id INT, name TEXT, state TEXT, donation_amount DECIMAL(10, 2), donation_date DATE); INSERT INTO donors (id, name, state, donation_amount, donation_date) VALUES (1, 'John Doe', 'California', 500.00, '2022-01-01'), (2, 'Jane Smith', 'Texas', 350.00, '2022-02-15'); | What is the total amount donated by each donor's state in the United States, summed up quarterly? | SELECT state, DATE_TRUNC('quarter', donation_date) AS donation_quarter, SUM(donation_amount) AS total_donation FROM donors GROUP BY state, donation_quarter; | gretelai_synthetic_text_to_sql |
CREATE TABLE mining_workforce (employee_id INT, country TEXT, gender TEXT); INSERT INTO mining_workforce (employee_id, country, gender) VALUES (1, 'Canada', 'Male'), (2, 'Canada', 'Female'), (3, 'Mexico', 'Male'), (4, 'Mexico', 'Male'), (5, 'Brazil', 'Female'), (6, 'Brazil', 'Male'), (7, 'USA', 'Female'), (8, 'USA', 'M... | What is the percentage of female workers in the mining industry by country, in descending order? | SELECT country, PERCENTAGE_RANK() OVER (ORDER BY COUNT(CASE WHEN gender = 'Female' THEN 1 END) DESC) AS female_percentage_rank FROM mining_workforce GROUP BY country ORDER BY female_percentage_rank DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE WasteTypes (waste_type_id INT PRIMARY KEY, name VARCHAR, description VARCHAR); CREATE TABLE Facilities (facility_id INT PRIMARY KEY, name VARCHAR, location VARCHAR, capacity INT, waste_type_id INT, FOREIGN KEY (waste_type_id) REFERENCES WasteTypes(waste_type_id)); | Add a new facility to the 'Facilities' table with the following details: facility_id = 1, name = 'Recycling Center 1', location = 'City A', capacity = 500, waste_type_id = 1 | INSERT INTO Facilities (facility_id, name, location, capacity, waste_type_id) VALUES (1, 'Recycling Center 1', 'City A', 500, 1); | gretelai_synthetic_text_to_sql |
CREATE TABLE songs (id INT, title VARCHAR(255), length FLOAT, genre VARCHAR(255), release_year INT); INSERT INTO songs (id, title, length, genre, release_year) VALUES (1, 'Song1', 200.5, 'Pop', 2011), (2, 'Song2', 180.3, 'Rock', 2008), (3, 'Song3', 220.0, 'Jazz', 1989), (4, 'Song4', 150.0, 'Jazz', 1920), (5, 'PopSong',... | What is the minimum length of a pop song released after 2010? | SELECT MIN(length) FROM songs WHERE genre = 'Pop' AND release_year > 2010; | gretelai_synthetic_text_to_sql |
CREATE TABLE vessels (id INT, name VARCHAR(255)); CREATE TABLE cargo (vessel_id INT, weight INT, timestamp TIMESTAMP); INSERT INTO vessels VALUES (1, 'Vessel A'), (2, 'Vessel B'), (3, 'Vessel C'); INSERT INTO cargo VALUES (1, 10000, '2021-01-01 10:00:00'), (1, 12000, '2021-01-15 12:00:00'), (3, 15000, '2020-01-03 08:00... | Delete vessels with no cargo tracking records in the last year. | DELETE FROM vessels v WHERE id NOT IN (SELECT c.vessel_id FROM cargo c WHERE c.timestamp >= DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 1 YEAR)); | gretelai_synthetic_text_to_sql |
CREATE TABLE ports_cargo_region (port_id INT, port_name TEXT, region TEXT, cargo_quantity INT); INSERT INTO ports_cargo_region VALUES (1, 'Port I', 'Africa', 2000), (2, 'Port J', 'Europe', 1800), (3, 'Port K', 'Asia Pacific', 2200); | What is the total quantity of cargo handled by ports in each region, excluding the African region? | SELECT ports_cargo_region.region, SUM(ports_cargo_region.cargo_quantity) FROM ports_cargo_region WHERE ports_cargo_region.region != 'Africa' GROUP BY ports_cargo_region.region; | gretelai_synthetic_text_to_sql |
CREATE TABLE clients (id INT, name TEXT, category TEXT, region TEXT); CREATE TABLE investments (id INT, client_id INT, product_code TEXT); INSERT INTO clients (id, name, category, region) VALUES (1, 'John Doe', 'Medium-Risk', 'East'), (2, 'Jane Smith', 'Low-Risk', 'West'), (3, 'Alice Johnson', 'High-Risk', 'North'), (4... | What is the number of investment products owned by clients in the 'Medium-Risk' category who live in the 'East' region? | SELECT COUNT(*) FROM clients c JOIN investments i ON c.id = i.client_id WHERE c.category = 'Medium-Risk' AND c.region = 'East'; | gretelai_synthetic_text_to_sql |
CREATE TABLE personnel (region VARCHAR(255), deployment_date DATE, personnel_count INT, personnel_type VARCHAR(255)); | What was the total number of peacekeeping personnel deployed in each region in the past year? | SELECT region, SUM(personnel_count) as total_personnel FROM personnel WHERE deployment_date BETWEEN DATE_SUB(CURDATE(), INTERVAL 1 YEAR) AND CURDATE() AND personnel_type = 'Peacekeeping' GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE sensor_data (sensor_id INTEGER, sensor_type TEXT, measurement_date DATE, measurement_value INTEGER);CREATE VIEW sensor_counts AS SELECT sensor_type, COUNT(*) as sensor_count FROM sensor_data WHERE measurement_date = CURRENT_DATE GROUP BY sensor_type; | How many sensors of each type are currently installed in the fields? | SELECT * FROM sensor_counts; | gretelai_synthetic_text_to_sql |
CREATE TABLE wages (worker_id INT, industry VARCHAR(20), wage DECIMAL(10,2));CREATE TABLE textile_industry (industry VARCHAR(20)); INSERT INTO textile_industry (industry) VALUES ('Textile - Apparel'), ('Textile - Home Furnishings'); | What is the average wage for workers in the textile industry in South America? | SELECT AVG(wage) FROM wages WHERE industry IN (SELECT industry FROM textile_industry) AND country IN (SELECT country FROM south_america); | gretelai_synthetic_text_to_sql |
CREATE TABLE faculty (id INT, name VARCHAR(50), department VARCHAR(50)); INSERT INTO faculty (id, name, department) VALUES (1, 'Alice', 'Computer Science'); INSERT INTO faculty (id, name, department) VALUES (2, 'Bob', 'Mathematics'); CREATE TABLE authorships (id INT, faculty_id INT, publication_id INT); INSERT INTO aut... | What is the average number of publications per faculty member in the past year? | SELECT AVG(p.count) FROM (SELECT f.id, COUNT(a.id) AS count FROM authorships a JOIN faculty f ON a.faculty_id = f.id JOIN publications p ON a.publication_id = p.id WHERE p.year = 2021 GROUP BY f.id) p; | gretelai_synthetic_text_to_sql |
CREATE TABLE patients (id INT, department VARCHAR(255)); CREATE TABLE physicians (id INT, department VARCHAR(255)); INSERT INTO patients (id, department) VALUES (1, 'Department X'), (2, 'Department Y'); INSERT INTO physicians (id, department) VALUES (1, 'Department X'), (3, 'Department X'); | List the total number of patients and the number of unique physicians for each rural health department. | SELECT department, COUNT(DISTINCT id) AS unique_physicians, COUNT(p.id) AS total_patients FROM patients p JOIN physicians ph ON p.department = ph.department GROUP BY department; | gretelai_synthetic_text_to_sql |
CREATE TABLE RenewableGeneration (id INT, country VARCHAR(50), capacity FLOAT); INSERT INTO RenewableGeneration (id, country, capacity) VALUES (1, 'India', 180.5), (2, 'India', 195.2), (3, 'India', 210.7); | What is the total renewable energy generation capacity in India? | SELECT SUM(capacity) FROM RenewableGeneration WHERE country = 'India'; | gretelai_synthetic_text_to_sql |
CREATE TABLE games (id INT, name VARCHAR(50), genre VARCHAR(50), revenue FLOAT); INSERT INTO games (id, name, genre, revenue) VALUES (1, 'Game1', 'Gaming', 5000000), (2, 'Game2', 'Gaming', 7000000), (3, 'Game3', 'Simulation', 3000000); | What is the total revenue for each game in the 'gaming' category, ordered by revenue in descending order? | SELECT name, revenue FROM (SELECT name, revenue, ROW_NUMBER() OVER (ORDER BY revenue DESC) as rn FROM games WHERE genre = 'Gaming') sub WHERE rn != 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE patients (id INT, age INT, diagnosis VARCHAR(20), residence VARCHAR(10)); INSERT INTO patients (id, age, diagnosis, residence) VALUES (1, 6, 'asthma', 'rural'), (2, 12, 'asthma', 'urban'), (3, 8, 'diabetes', 'rural'); | What is the prevalence of asthma among children in rural areas compared to urban areas? | SELECT (SELECT COUNT(*) FROM patients WHERE diagnosis = 'asthma' AND residence = 'rural') / (SELECT COUNT(*) FROM patients WHERE residence = 'rural') AS rural_asthma_prevalence, (SELECT COUNT(*) FROM patients WHERE diagnosis = 'asthma' AND residence = 'urban') / (SELECT COUNT(*) FROM patients WHERE residence = 'urban')... | gretelai_synthetic_text_to_sql |
CREATE TABLE farmers_new (id INT, name VARCHAR(50), gender VARCHAR(50), location VARCHAR(50)); INSERT INTO farmers_new (id, name, gender, location) VALUES (1, 'Juana Garcia', 'Female', 'Veracruz'); INSERT INTO farmers_new (id, name, gender, location) VALUES (2, 'Carlos Hernandez', 'Male', 'Veracruz'); INSERT INTO farme... | What is the total number of female and male farmers in the 'farmers_new' table? | SELECT SUM(CASE WHEN gender = 'Male' THEN 1 ELSE 0 END) AS total_males, SUM(CASE WHEN gender = 'Female' THEN 1 ELSE 0 END) AS total_females FROM farmers_new; | gretelai_synthetic_text_to_sql |
CREATE TABLE carbon_pricing_annual (region VARCHAR(255), year INT, revenue FLOAT); | What is the total carbon pricing revenue (in USD) for each region from 2018 to 2020? | SELECT region, SUM(revenue) FROM carbon_pricing_annual WHERE year BETWEEN 2018 AND 2020 GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE CommunityCourts (CourtID INT, District VARCHAR(20)); CREATE TABLE CommunityCourtHearings (HearingID INT, CourtID INT, HearingDate DATE); INSERT INTO CommunityCourts (CourtID, District) VALUES (1, 'Downtown'), (2, 'Uptown'), (3, 'Midtown'); INSERT INTO CommunityCourtHearings (HearingID, CourtID, HearingDate... | What is the earliest HearingDate for each CommunityCourt in descending order? | SELECT CourtID, MIN(HearingDate) as EarliestHearingDate FROM CommunityCourtHearings GROUP BY CourtID ORDER BY EarliestHearingDate DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE Branches (branch_id INT, branch_name VARCHAR(255));CREATE TABLE Menu (dish_name VARCHAR(255), branch_id INT, dish_type VARCHAR(255), price DECIMAL(5,2));CREATE TABLE Sales (sale_date DATE, dish_name VARCHAR(255), quantity INT); | What is the total quantity of dishes sold by category in branch 7? | SELECT dish_type, SUM(quantity) as total_sales FROM Sales JOIN Menu ON Sales.dish_name = Menu.dish_name WHERE branch_id = 7 GROUP BY dish_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE Chemicals (ChemicalID INT PRIMARY KEY, ChemicalName VARCHAR(50), Department VARCHAR(50), QuantityInStock INT, ReorderLevel INT); INSERT INTO Chemicals (ChemicalID, ChemicalName, Department, QuantityInStock, ReorderLevel) VALUES (3, 'Benzene', 'Manufacturing', 250, 300); INSERT INTO Chemicals (ChemicalID, C... | Which chemicals in the Manufacturing department have a quantity in stock below the reorder level? | SELECT Chemicals.ChemicalName, Chemicals.Department, Chemicals.QuantityInStock, Chemicals.ReorderLevel FROM Chemicals WHERE Chemicals.Department = 'Manufacturing' AND Chemicals.QuantityInStock < Chemicals.ReorderLevel; | gretelai_synthetic_text_to_sql |
CREATE TABLE rural_development (country VARCHAR(255), year INT, num_projects INT); INSERT INTO rural_development (country, year, num_projects) VALUES ('Nepal', 2018, 10), ('Nepal', 2019, 12), ('Nepal', 2020, 15), ('Nepal', 2021, 18); | Delete all rural development projects in Nepal in 2018. | DELETE FROM rural_development WHERE country = 'Nepal' AND year = 2018; | gretelai_synthetic_text_to_sql |
CREATE TABLE regions (name VARCHAR(255)); INSERT INTO regions (name) VALUES ('West'), ('Midwest'); CREATE TABLE disaster_preparedness_kits (id INT, region VARCHAR(255), quantity INT, distributed INT); INSERT INTO disaster_preparedness_kits (id, region, quantity, distributed) VALUES (1, 'West', 500, 300), (2, 'Midwest',... | What is the total number of disaster preparedness kits remaining in each region? | SELECT region, SUM(quantity - distributed) as total_kits_remaining FROM disaster_preparedness_kits GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE explainability_scores (id INT, model_id INT, score FLOAT); INSERT INTO explainability_scores (id, model_id, score) VALUES (1, 1, 0.75), (2, 2, 0.91), (3, 3, 0.68); CREATE TABLE models (id INT, name TEXT, country TEXT); INSERT INTO models (id, name, country) VALUES (1, 'ModelA', 'Africa'), (2, 'ModelB', 'Ca... | What is the minimum explainability score for models developed in Africa? | SELECT MIN(score) FROM explainability_scores JOIN models ON explainability_scores.model_id = models.id WHERE country = 'Africa'; | gretelai_synthetic_text_to_sql |
CREATE TABLE space_missions (id INT, mission_name VARCHAR(50), launch_date DATE, scheduled_date DATE); INSERT INTO space_missions VALUES (1, 'Artemis I', '2022-08-29', '2022-06-29'); INSERT INTO space_missions VALUES (2, 'Mars Science Laboratory', '2011-11-26', '2011-08-05'); | Which space missions had a launch delay of more than 60 days in the space_missions table? | SELECT mission_name, launch_date, scheduled_date, DATEDIFF(day, scheduled_date, launch_date) as delay_days FROM space_missions WHERE DATEDIFF(day, scheduled_date, launch_date) > 60; | gretelai_synthetic_text_to_sql |
CREATE TABLE FarmG (country VARCHAR(20), species VARCHAR(20), biomass FLOAT); INSERT INTO FarmG (country, species, biomass) VALUES ('Norway', 'Salmon', 450000); INSERT INTO FarmG (country, species, biomass) VALUES ('Norway', 'Trout', 120000); INSERT INTO FarmG (country, species, biomass) VALUES ('Scotland', 'Salmon', 3... | Which countries have a total biomass of farmed salmon greater than 400,000? | SELECT country FROM FarmG WHERE species='Salmon' GROUP BY country HAVING SUM(biomass) > 400000; | gretelai_synthetic_text_to_sql |
CREATE TABLE sensor_details (sensor_id INT, sensor_location VARCHAR(50), operation_status VARCHAR(10)); | Get the number of IoT sensors in operation in California | SELECT COUNT(sensor_id) FROM sensor_details WHERE sensor_location = 'California'; | gretelai_synthetic_text_to_sql |
CREATE TABLE readers (id INT, name VARCHAR(50), age INT, country VARCHAR(50), news_preference VARCHAR(50)); INSERT INTO readers (id, name, age, country, news_preference) VALUES (1, 'John Doe', 35, 'Canada', 'Sports'), (2, 'Jane Smith', 28, 'Canada', 'Politics'), (3, 'Jim Brown', 45, 'United States', 'Sports'); | What is the total number of readers in each country, grouped by news preference? | SELECT country, news_preference, COUNT(*) AS total FROM readers GROUP BY country, news_preference; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (DonorID INT PRIMARY KEY, Age INT, Gender VARCHAR(50), Location VARCHAR(50)); | What is the total donation amount per organization located in South America for donors aged between 30 and 50? | SELECT O.OrgName, SUM(D.DonationAmount) as TotalDonationAmount FROM Donors D INNER JOIN Donations DON ON D.DonorID = DON.DonorID INNER JOIN Organizations O ON DON.OrgID = O.OrgID WHERE D.Age BETWEEN 30 AND 50 AND O.Location = 'South America' GROUP BY O.OrgName; | gretelai_synthetic_text_to_sql |
CREATE TABLE satellites (id INT, country VARCHAR(50), launch_date DATE, satellite_name VARCHAR(50)); | What is the total number of satellites launched by India and China? | SELECT SUM(country IN ('India', 'China')) FROM satellites; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA fitness; CREATE TABLE workouts (id INT, user_id INT, workout_type VARCHAR(50), duration INT, workout_date DATE); INSERT INTO workouts (id, user_id, workout_type, duration, workout_date) VALUES (1, 1, 'Strength Training', 90, '2022-09-20'); | What is the maximum duration of a single 'Strength Training' workout in the 'Australia' region? | SELECT MAX(duration) FROM fitness.workouts WHERE workout_type = 'Strength Training' AND region = 'Australia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE freight_forwarding (id INT, source_country VARCHAR(50), destination_country VARCHAR(50), delivery_time INT, ship_date DATE); INSERT INTO freight_forwarding (id, source_country, destination_country, delivery_time, ship_date) VALUES (4, 'South Korea', 'Germany', 10, '2023-01-02'); INSERT INTO freight_forward... | What is the maximum delivery time for freight forwarding shipments from South Korea to Germany in January 2023? | SELECT MAX(delivery_time) FROM freight_forwarding WHERE source_country = 'South Korea' AND destination_country = 'Germany' AND ship_date >= '2023-01-01' AND ship_date < '2023-02-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE vehicles (id INT, city VARCHAR(20), type VARCHAR(20), is_electric BOOLEAN, daily_distance INT); INSERT INTO vehicles VALUES (1, 'paris', 'sedan', true, 55); INSERT INTO vehicles VALUES (2, 'paris', 'suv', true, 65); INSERT INTO vehicles VALUES (3, 'london', 'truck', false, 75); | What is the average distance traveled per day by electric vehicles in 'paris'? | SELECT AVG(daily_distance) FROM vehicles WHERE city = 'paris' AND is_electric = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE provider_service_areas (subscriber_id INT, provider VARCHAR(25)); | How many mobile customers are there in each network provider's service area? | SELECT provider, COUNT(*) FROM provider_service_areas GROUP BY provider; | gretelai_synthetic_text_to_sql |
CREATE TABLE ProjectCosts (ProjectID INT, Location VARCHAR(20), Year INT, Cost FLOAT); INSERT INTO ProjectCosts (ProjectID, Location, Year, Cost) VALUES (1, 'Alaska', 2021, 2000000); | What is the total cost of public works projects in Alaska that were completed in 2021? | SELECT SUM(Cost) FROM ProjectCosts WHERE Location = 'Alaska' AND Year = 2021 AND Completed = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE item_inventory (item_id INT, item_name VARCHAR(50), quantity INT, warehouse_id INT); | Delete records with a quantity of 0 from the item_inventory table | DELETE FROM item_inventory WHERE quantity = 0; | gretelai_synthetic_text_to_sql |
CREATE TABLE astrophysics_research (research_id INT, topic VARCHAR(50), expenses INT); | What are the total research expenses for each astrophysics research topic? | SELECT topic, SUM(expenses) FROM astrophysics_research GROUP BY topic; | gretelai_synthetic_text_to_sql |
CREATE TABLE Farm (FarmID INT, FishSpecies VARCHAR(50), Capacity INT, Location VARCHAR(50)); INSERT INTO Farm (FarmID, FishSpecies, Capacity, Location) VALUES (1, 'Salmon', 5000, 'Norway'), (2, 'Tilapia', 3000, 'Indonesia'), (3, 'Carp', 4000, 'Canada'); CREATE TABLE Fish (FishID INT, FishSpecies VARCHAR(50), AvgWeight ... | What fish species are not being farmed in Canada? | SELECT Fish.FishSpecies FROM Fish LEFT JOIN Farm ON Fish.FishSpecies = Farm.FishSpecies WHERE Farm.Location IS NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE autonomous_vehicle_services (service_id INT, service_name TEXT, type TEXT, city TEXT, country TEXT); | Add a new autonomous shuttle service in the city of Tokyo | INSERT INTO autonomous_vehicle_services (service_id, service_name, type, city, country) VALUES (2001, 'Tokyo Sky Shuttle', 'autonomous shuttle', 'Tokyo', 'Japan'); | gretelai_synthetic_text_to_sql |
CREATE TABLE patients (id INT, name VARCHAR(50), age INT, diagnosis_date DATE, country VARCHAR(30)); CREATE VIEW covid19_patients AS SELECT * FROM patients WHERE diagnosis = 'COVID-19'; | What is the average age of patients diagnosed with COVID-19 in 2021 in India? | SELECT AVG(age) FROM covid19_patients WHERE country = 'India' AND YEAR(diagnosis_date) = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE properties(id INT, city TEXT, affordability_rating INT); INSERT INTO properties(id, city, affordability_rating) VALUES (1, 'San Francisco', NULL); | Delete properties in San Francisco with no affordability ratings. | DELETE FROM properties WHERE city = 'San Francisco' AND affordability_rating IS NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_dev_indonesia (initiative VARCHAR(50), budget FLOAT, start_year INT); INSERT INTO community_dev_indonesia (initiative, budget, start_year) VALUES ('Microfinance Program', 2000000, 2010), ('Rural Healthcare Program', 5000000, 2010); | Identify the community development initiatives that have been implemented in Indonesia since 2010, and their respective budgets. | SELECT initiative, budget FROM community_dev_indonesia WHERE start_year <= 2010; | gretelai_synthetic_text_to_sql |
CREATE TABLE food_safety_inspections (restaurant_id INT, inspection_date DATE, violation_count INT); | Update the food_safety_inspections table, setting the violation_count to 0 where the inspection_date is '2023-01-18' | UPDATE food_safety_inspections SET violation_count = 0 WHERE inspection_date = '2023-01-18'; | gretelai_synthetic_text_to_sql |
CREATE TABLE urban_waste (waste_type TEXT, amount INTEGER, year INTEGER);CREATE TABLE rural_waste (waste_type TEXT, amount INTEGER, year INTEGER); | What are the total waste generation figures for urban and rural areas combined, for the year 2020? | SELECT SUM(amount) FROM urban_waste WHERE year = 2020 UNION ALL SELECT SUM(amount) FROM rural_waste WHERE year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE trips (id INT, city TEXT, year INT, trips INT); INSERT INTO trips (id, city, year, trips) VALUES (1, 'Sydney', 2019, 1000), (2, 'London', 2020, 1500), (3, 'Sydney', 2021, 800), (4, 'Paris', 2022, 1200); | What is the minimum number of public transportation trips taken in Sydney in the year 2021? | SELECT MIN(trips) FROM trips WHERE city = 'Sydney' AND year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE production (id INT, element TEXT, location TEXT, year INT, quantity INT); INSERT INTO production (id, element, location, year, quantity) VALUES (1, 'dysprosium', 'South America', 2021, 300), (2, 'dysprosium', 'North America', 2021, 700); | What is the market share of dysprosium produced in South America in 2021? | SELECT (quantity / (SELECT SUM(quantity) FROM production WHERE element = 'dysprosium' AND year = 2021) * 100) AS market_share FROM production WHERE element = 'dysprosium' AND location = 'South America' AND year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE aircraft_plants (plant_id INT, plant_name TEXT, country TEXT); INSERT INTO aircraft_plants (plant_id, plant_name, country) VALUES (1, 'Boeing Everett Factory', 'USA'), (2, 'Boeing Renton Factory', 'USA'), (3, 'Airbus Toulouse Factory', 'France'), (4, 'Comac Shanghai Factory', 'China'), (5, 'Irkut Kazan Fac... | Which are the top 5 countries with the most aircraft manufacturing plants? | SELECT country, COUNT(*) as plant_count FROM aircraft_plants GROUP BY country ORDER BY plant_count DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE high_scores (player_id INT, game_id INT, score INT); INSERT INTO high_scores (player_id, game_id, score) VALUES (1, 1, 550), (2, 2, 480), (3, 1, 500); | List all players who achieved a high score of 500 or more in 'racing_game'. | SELECT player_id, game_id FROM high_scores WHERE score >= 500 AND game_id = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE deep_sea_expeditions (expedition_name VARCHAR(255), ocean VARCHAR(255)); INSERT INTO deep_sea_expeditions (expedition_name, ocean) VALUES ('Expedition 1', 'Atlantic Ocean'), ('Expedition 2', 'Pacific Ocean'); | What is the total number of deep-sea expeditions in each ocean? | SELECT ocean, COUNT(*) as count FROM deep_sea_expeditions GROUP BY ocean; | gretelai_synthetic_text_to_sql |
CREATE VIEW field_rainfall AS SELECT fields.field_name, rainfall_data.rainfall, rainfall_data.measurement_date FROM fields JOIN rainfall_data ON fields.id = rainfall_data.field_id; | What is the total rainfall for each field in the 'field_rainfall' view for the year 2021? | SELECT field_name, SUM(rainfall) FROM field_rainfall WHERE YEAR(measurement_date) = 2021 GROUP BY field_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE movie_studios (id INT, name TEXT); CREATE TABLE movies (id INT, title TEXT, genre TEXT, studio_id INT, budget INT); INSERT INTO movie_studios (id, name) VALUES (1, 'Studio 1'), (2, 'Studio 2'), (3, 'Studio 3'), (4, 'Studio 4'); INSERT INTO movies (id, title, genre, studio_id, budget) VALUES (1, 'Movie A', ... | What is the total budget for all horror movies produced by Studio 4? | SELECT SUM(movies.budget) FROM movies JOIN movie_studios ON movies.studio_id = movie_studios.id WHERE movies.genre = 'Horror' AND movie_studios.name = 'Studio 4'; | gretelai_synthetic_text_to_sql |
CREATE TABLE organization (org_id INT, org_name VARCHAR(255)); CREATE TABLE donation (don_id INT, donor_id INT, org_id INT, donation_date DATE); | Determine the number of days between the earliest and latest donation date for each organization. | SELECT org_id, DATEDIFF(MAX(donation_date), MIN(donation_date)) AS days_between_earliest_and_latest_donation FROM donation GROUP BY org_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE events (event_id INT, event_type VARCHAR(50)); INSERT INTO events (event_id, event_type) VALUES (1, 'Dance'), (2, 'Theater'), (3, 'Music'); CREATE TABLE attendees (attendee_id INT, event_id INT, age INT); INSERT INTO attendees (attendee_id, event_id, age) VALUES (1, 1, 25), (2, 1, 30), (3, 2, 22), (4, 2, 2... | What is the average age of attendees for music events? | SELECT AVG(age) FROM attendees JOIN events ON attendees.event_id = events.event_id WHERE events.event_type = 'Music'; | gretelai_synthetic_text_to_sql |
CREATE TABLE player_demographics (player_id INT, player_name TEXT, age INT, country TEXT, game_type TEXT); INSERT INTO player_demographics (player_id, player_name, age, country, game_type) VALUES (1, 'John Doe', 25, 'United States', 'Single-Player'), (2, 'Jane Doe', 28, 'Canada', 'Multiplayer'), (3, 'Jim Smith', 31, 'U... | What is the percentage of players who prefer single-player games, by country? | SELECT countries.country, (COUNT(player_demographics.player_id) FILTER (WHERE player_demographics.game_type = 'Single-Player') * 100.0 / COUNT(player_demographics.player_id)) AS percentage FROM player_demographics JOIN countries ON player_demographics.country = countries.country GROUP BY countries.country; | gretelai_synthetic_text_to_sql |
CREATE TABLE member_data (member_id INT, age INT, gender VARCHAR(10)); CREATE TABLE workout_data (workout_id INT, member_id INT, workout_type VARCHAR(20), workout_date DATE); | Find the average age of members who did yoga workouts and zumba workouts. | SELECT AVG(member_data.age) as avg_age FROM member_data JOIN workout_data ON member_data.member_id = workout_data.member_id WHERE workout_data.workout_type IN ('yoga', 'zumba'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Contracts (id INT, contract_name VARCHAR(50), negotiation_date DATE); INSERT INTO Contracts (id, contract_name, negotiation_date) VALUES (1, 'Contract A', NULL), (2, 'Contract B', '2020-03-15'), (3, 'Contract C', NULL); | What are the names of all contracts that have not been negotiated yet? | SELECT contract_name FROM Contracts WHERE negotiation_date IS NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE subscribers (subscriber_id INT, data_usage FLOAT, region VARCHAR(20)); INSERT INTO subscribers (subscriber_id, data_usage, region) VALUES (1, 25.6, 'Northern'), (2, 32.8, 'Northeast'), (3, 18.9, 'Northern'); CREATE TABLE minimum_usage (min_usage FLOAT); INSERT INTO minimum_usage (min_usage) VALUES (50.0); | What is the minimum monthly data usage for broadband subscribers in the Northern region? | SELECT MIN(data_usage) FROM subscribers WHERE region = 'Northern'; | gretelai_synthetic_text_to_sql |
CREATE TABLE visitor_exhibition (visitor_id INT, exhibition_id INT, visit_date DATE); CREATE TABLE visitors (id INT, age INT, gender TEXT, country TEXT); CREATE TABLE exhibitions (id INT, name TEXT, start_date DATE, end_date DATE); | Delete records of visitors who have not visited any exhibition from the visitors table | DELETE FROM visitors WHERE id NOT IN (SELECT visitor_id FROM visitor_exhibition); | gretelai_synthetic_text_to_sql |
CREATE TABLE Crimes (id INT, city VARCHAR(20), date DATE, number_of_crimes INT); | What is the maximum number of crimes committed in a single day in New York City? | SELECT MAX(number_of_crimes) FROM Crimes WHERE city = 'New York City'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Game_Design (id INT PRIMARY KEY, game_id INT, genre VARCHAR(255), release_year INT, developer VARCHAR(255), platform VARCHAR(255)); INSERT INTO Game_Design (id, game_id, genre, release_year, developer) VALUES (1, 1001, 'RPG', 2018, 'CompanyA'); | Update the 'platform' for game with ID 1001 to 'PC' | UPDATE Game_Design SET platform = 'PC' WHERE id = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE menu_items (item_id INT, item_name VARCHAR(50), west_coast_sales INT, east_coast_sales INT); INSERT INTO menu_items (item_id, item_name, west_coast_sales, east_coast_sales) VALUES (1, 'Cheeseburger', 300, 200), (2, 'Fried Chicken', 250, 270), (3, 'Veggie Burger', 180, 350); | Which menu items have higher sales in the West coast compared to the East coast? | SELECT item_name, west_coast_sales, east_coast_sales, (west_coast_sales - east_coast_sales) as sales_difference FROM menu_items ORDER BY sales_difference DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE PRODUCT ( id INT PRIMARY KEY, name TEXT, material TEXT, quantity INT, country TEXT, certifications TEXT ); INSERT INTO PRODUCT (id, name, material, quantity, country, certifications) VALUES (1, 'Organic Cotton Shirt', 'Organic Cotton', 30, 'USA', 'GOTS, Fair Trade'); INSERT INTO PRODUCT (id, name, material... | How many unique ethical certifications are there for all products in the PRODUCT table? | SELECT DISTINCT certifications FROM PRODUCT; | gretelai_synthetic_text_to_sql |
CREATE TABLE cricket_matches (team VARCHAR(50), match_date DATE, result VARCHAR(50)); | Display the number of days between the first and last matches for each team, and the difference between the total wins and losses, in the cricket_matches dataset. | SELECT team, DATEDIFF(MAX(match_date), MIN(match_date)) as days_between, SUM(CASE WHEN result = 'win' THEN 1 ELSE 0 END) - SUM(CASE WHEN result = 'loss' THEN 1 ELSE 0 END) as wins_minus_losses FROM cricket_matches GROUP BY team; | gretelai_synthetic_text_to_sql |
CREATE TABLE songs (song_id INT, title VARCHAR(255), genre VARCHAR(50), release_year INT, length FLOAT); INSERT INTO songs (song_id, title, genre, release_year, length) VALUES (1, 'Song1', 'Classical', 1995, 120.5), (2, 'Song2', 'Jazz', 1998, 210.3), (3, 'Song3', 'Rock', 1992, 180.7), (4, 'Song4', 'Classical', 1999, 20... | How many unique genres of songs were released before 2000? | SELECT COUNT(DISTINCT genre) FROM songs WHERE release_year < 2000; | gretelai_synthetic_text_to_sql |
CREATE TABLE Athletes (athlete_id INT, athlete_name VARCHAR(255), age INT, team VARCHAR(255)); CREATE VIEW WellbeingPrograms AS SELECT athlete_id, team FROM Programs WHERE program_type IN ('NBA', 'NFL'); | Which athletes in 'NBA' and 'NFL' wellbeing programs have the highest age? | SELECT Athletes.athlete_name, Athletes.age FROM Athletes INNER JOIN WellbeingPrograms ON Athletes.athlete_id = WellbeingPrograms.athlete_id WHERE (Athletes.team = 'NBA' OR Athletes.team = 'NFL') GROUP BY Athletes.athlete_name ORDER BY Athletes.age DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Players (PlayerID INT, PlayerRegion VARCHAR(10), Wins INT, GameName VARCHAR(20)); INSERT INTO Players (PlayerID, PlayerRegion, Wins, GameName) VALUES (1, 'Europe', 25, 'Galactic Conquest'), (2, 'Asia', 30, 'Galactic Conquest'), (3, 'Europe', 35, 'Galactic Conquest'); | What is the maximum number of wins achieved by players from Europe who have played "Galactic Conquest"? | SELECT MAX(Wins) FROM Players WHERE PlayerRegion = 'Europe' AND GameName = 'Galactic Conquest'; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species_ocean (species_name VARCHAR(50), ocean_name VARCHAR(50)); INSERT INTO marine_species_ocean (species_name, ocean_name) VALUES ('Salmon', 'Pacific'), ('Sea Otter', 'Pacific'), ('Bluefin Tuna', 'Atlantic'); | What are the names of the marine species that inhabit both the Atlantic and Pacific Oceans? | SELECT species_name FROM marine_species_ocean WHERE ocean_name IN ('Atlantic', 'Pacific') GROUP BY species_name HAVING COUNT(DISTINCT ocean_name) = 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE policyholder_age (policyholder_id INT, policyholder_age INT); CREATE TABLE claims (claim_id INT, policy_id INT, claim_amount DECIMAL(10,2)); INSERT INTO policyholder_age VALUES (1, 35); INSERT INTO claims VALUES (1, 1, 500.00); | What is the average claim amount by policyholder age? | SELECT AVG(claim_amount) as avg_claim_amount FROM claims JOIN policies ON claims.policy_id = policies.policy_id JOIN policyholder_age ON policies.policyholder_id = policyholder_age.policyholder_id; | 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.