context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE rural_clinic_7 (patient_id INT, procedure VARCHAR(20)); INSERT INTO rural_clinic_7 (patient_id, procedure) VALUES (1, 'Dental Checkup'), (2, 'General Health Checkup'), (3, 'Physiotherapy'), (4, 'Dental Filling'), (5, 'General Health Checkup'), (6, 'Physiotherapy'), (7, 'Dental Checkup'); | How many dental procedures were performed in 'rural_clinic_7'? | SELECT COUNT(*) FROM rural_clinic_7 WHERE procedure LIKE '%Dental%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE co_ownership (owner_id INT, property_id INT, name VARCHAR(255)); INSERT INTO co_ownership (owner_id, property_id, name) VALUES (1, 3, 'Alice Johnson'), (2, 3, 'Bob Smith'), (3, 4, 'Eva Brown'); | Find the number of co-owners for each property in the co_ownership table. | SELECT property_id, COUNT(DISTINCT owner_id) FROM co_ownership GROUP BY property_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE circular_economy (city VARCHAR(20), initiatives VARCHAR(50)); | Create a view for circular economy initiatives in select Asian cities. | CREATE VIEW asian_city_initiatives AS SELECT city, initiatives FROM circular_economy WHERE city IN ('Tokyo', 'Seoul', 'Beijing'); | gretelai_synthetic_text_to_sql |
CREATE TABLE SustainableMaterials (Material VARCHAR(50), Price FLOAT, Country VARCHAR(50)); INSERT INTO SustainableMaterials (Material, Price, Country) VALUES ('Organic Cotton', 2.5, 'USA'), ('Hemp', 3.2, 'USA'), ('Recycled Polyester', 4.1, 'USA'); | What is the average price of sustainable materials in the USA? | SELECT AVG(Price) FROM SustainableMaterials WHERE Country = 'USA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Region (Id INT, Name VARCHAR(50)); INSERT INTO Region (Id, Name) VALUES (1, 'Region A'), (2, 'Region B'), (3, 'Region C'); CREATE TABLE AdvocacyEvents (Id INT, RegionId INT, EventDate DATE); INSERT INTO AdvocacyEvents (Id, RegionId, EventDate) VALUES (1, 1, '2020-01-01'), (2, 1, '2020-02-15'), (3, 2, '2020... | What is the total number of labor rights advocacy events in each region for the year 2020? | SELECT R.Name, YEAR(AE.EventDate) as Year, COUNT(*) as TotalEvents FROM Region R JOIN AdvocacyEvents AE ON R.Id = AE.RegionId GROUP BY R.Name, Year HAVING Year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists mobility_data (mobility_type varchar(20), city varchar(20), date date); INSERT INTO mobility_data (mobility_type, city, date) VALUES ('multimodal', 'são paulo', '2021-12-30'), ('multimodal', 'são paulo', '2021-12-31'), ('multimodal', 'são paulo', '2022-01-01'); | Delete all multimodal mobility records for 'são paulo' after 2021-12-31 | DELETE FROM mobility_data WHERE mobility_type = 'multimodal' AND city = 'são paulo' AND date > '2021-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE smart_cities.projects (project_name VARCHAR(30), budget INT); CREATE VIEW smart_cities.high_budget_projects AS SELECT * FROM smart_cities.projects WHERE budget > 5000000; | List the top 3 smart city projects with the highest budget in the 'smart_cities' schema. | SELECT project_name FROM smart_cities.high_budget_projects ORDER BY budget DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE IntelligenceOperations (ID INT, Country VARCHAR(20), Operation VARCHAR(50), Year INT); INSERT INTO IntelligenceOperations (ID, Country, Operation, Year) VALUES (1, 'South Africa', 'Project Spear', 2016); | What are the intelligence operations undertaken by South Africa since 2016? | SELECT Operation, Year FROM IntelligenceOperations WHERE Country = 'South Africa' AND Year >= 2016; | gretelai_synthetic_text_to_sql |
CREATE TABLE vessels ( id INT, type VARCHAR(255), speed FLOAT, longitude FLOAT, latitude FLOAT ); INSERT INTO vessels (id, type, speed, longitude, latitude) VALUES (1, 'Tanker', 15.3, 139.6917, 35.6895); INSERT INTO vessels (id, type, speed, longitude, latitude) VALUES (2, 'Cargo', 20.1, 141.3571, 41.1044); | What is the average speed of all vessels near the coast of Japan, grouped by their type? | SELECT type, AVG(speed) as avg_speed FROM vessels WHERE latitude BETWEEN 20 AND 46 AND longitude BETWEEN 120 AND 154 GROUP BY type; | gretelai_synthetic_text_to_sql |
CREATE TABLE IntelligenceOperations (id INT, operation_name TEXT, year INT, region TEXT, success_rate FLOAT); INSERT INTO IntelligenceOperations (id, operation_name, year, region, success_rate) VALUES (1, 'Operation A', 2021, 'AP', 0.8); | Identify the number of intelligence operations conducted in the Asia-Pacific region in the last 5 years and their respective success rates. | SELECT COUNT(IntelligenceOperations.operation_name) as total_operations, AVG(IntelligenceOperations.success_rate) as avg_success_rate FROM IntelligenceOperations WHERE IntelligenceOperations.year BETWEEN 2017 AND 2022 AND IntelligenceOperations.region = 'AP'; | gretelai_synthetic_text_to_sql |
CREATE TABLE energy_production (country VARCHAR(50), production FLOAT); INSERT INTO energy_production (country, production) VALUES ('Germany', 2000.5), ('France', 2500.0), ('Spain', 3000.2); | What is the total energy production for each country, ranked by production amount? | SELECT country, SUM(production) as total_production, RANK() OVER (ORDER BY SUM(production) DESC) as production_rank FROM energy_production GROUP BY country ORDER BY total_production DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE recycling_rates (city VARCHAR(50), population INT, continent VARCHAR(50), recycling_rate FLOAT); INSERT INTO recycling_rates (city, population, continent, recycling_rate) VALUES ('Sydney', 5000000, 'Oceania', 50), ('Melbourne', 4000000, 'Oceania', 45), ('Brisbane', 2500000, 'Oceania', 40); | What is the average recycling rate in percentage for cities in Oceania with a population greater than 1 million? | SELECT AVG(recycling_rate) FROM recycling_rates WHERE population > 1000000 AND continent = 'Oceania'; | gretelai_synthetic_text_to_sql |
CREATE TABLE movies (title VARCHAR(255), genre VARCHAR(50), budget INT, release_year INT, rating INT); INSERT INTO movies (title, genre, budget, release_year, rating) VALUES ('Movie1', 'Comedy', 20000000, 2010, 8), ('Movie2', 'Comedy', 30000000, 2012, 7), ('Movie3', 'Drama', 40000000, 2015, 9); | Update the ratings of all movies released in 2010 to be 1 point higher | UPDATE movies SET rating = rating + 1 WHERE release_year = 2010; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_protected_areas (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), size_sq_km FLOAT, start_date DATE, end_date DATE); | Add a new record to the marine_protected_areas table for an area in the Mediterranean Sea | INSERT INTO marine_protected_areas (id, name, location, size_sq_km, start_date, end_date) VALUES (34, 'Mediterranean Marine Haven', 'Mediterranean Sea', 1250.3, '2023-04-01', '2028-03-31'); | gretelai_synthetic_text_to_sql |
CREATE TABLE gym_memberships (id INT, member_name VARCHAR(50), start_date DATE, end_date DATE, membership_type VARCHAR(50), price DECIMAL(5,2), state VARCHAR(50)); | What is the number of members who have a premium membership in each state? | SELECT state, COUNT(DISTINCT member_name) AS premium_members FROM gym_memberships WHERE membership_type = 'Premium' GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE manufacturing_countries (country VARCHAR(50), manufacturing_sector VARCHAR(50), total_emissions INT); | Create a table named 'manufacturing_countries' | CREATE TABLE manufacturing_countries (country VARCHAR(50), manufacturing_sector VARCHAR(50), total_emissions INT); | gretelai_synthetic_text_to_sql |
CREATE TABLE Veteran_Employment (employment_id INT, industry TEXT, state TEXT, employment_rate FLOAT, quarter INT, year INT); INSERT INTO Veteran_Employment (employment_id, industry, state, employment_rate, quarter, year) VALUES (1, 'Defense', 'California', 0.15, 1, 2022), (2, 'Defense', 'Texas', 0.14, 1, 2022); | Which states have the highest veteran employment rates in the defense industry in Q1 2022? | SELECT state, AVG(employment_rate) as avg_rate FROM Veteran_Employment WHERE industry = 'Defense' AND quarter = 1 AND year = 2022 GROUP BY state ORDER BY avg_rate DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE broadband_subscribers (subscriber_id INT, broadband_speed FLOAT, region VARCHAR(20)); INSERT INTO broadband_subscribers (subscriber_id, broadband_speed, region) VALUES (1, 2.5, 'Midwest'), (2, 3.7, 'Northeast'), (3, 4.9, 'Southwest'), (4, 5.1, 'Midwest'); | Insert new records for broadband_subscribers with the highest speed in each region. | INSERT INTO broadband_subscribers (subscriber_id, broadband_speed, region) SELECT subscriber_id, MAX(broadband_speed) AS broadband_speed, region FROM broadband_subscribers GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE sectors (sector_id INT, sector VARCHAR(20)); INSERT INTO sectors (sector_id, sector) VALUES (1, 'Renewable Energy'), (2, 'Oil & Gas'), (3, 'Technology'); CREATE TABLE investments (investment_id INT, client_id INT, sector_id INT); INSERT INTO investments (investment_id, client_id, sector_id) VALUES (1, 1, 1... | List the clients and their total investments in the Oil & Gas sector, grouped by region. | SELECT clients.region, SUM(value) AS total_investment FROM clients JOIN assets ON clients.client_id = assets.client_id JOIN investments ON clients.client_id = investments.client_id JOIN sectors ON investments.sector_id = sectors.sector_id WHERE sectors.sector = 'Oil & Gas' GROUP BY clients.region; | gretelai_synthetic_text_to_sql |
CREATE TABLE waste_generation (country VARCHAR(50), year INT, total_waste INT); INSERT INTO waste_generation (country, year, total_waste) VALUES ('China', 2020, 220000), ('India', 2020, 150000), ('Indonesia', 2020, 120000); | What is the total waste generation for each country in Asia in 2020? | SELECT country, SUM(total_waste) FROM waste_generation WHERE year = 2020 AND country IN ('China', 'India', 'Indonesia', 'Pakistan', 'Japan') GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE movies (id INT, title VARCHAR(255), release_year INT, rating DECIMAL(3,2), genre VARCHAR(255), country VARCHAR(255)); INSERT INTO movies (id, title, release_year, rating, genre, country) VALUES (1, 'Movie1', 2015, 7.8, 'Action', 'USA'); INSERT INTO movies (id, title, release_year, rating, genre, country) V... | What is the average rating of movies produced in the US and released between 2015 and 2020, grouped by genre? | SELECT genre, AVG(rating) FROM movies WHERE release_year BETWEEN 2015 AND 2020 AND country = 'USA' GROUP BY genre; | gretelai_synthetic_text_to_sql |
CREATE TABLE west_public_transportation (id INT, city_id INT, system_type VARCHAR(20), fleet_size INT); INSERT INTO west_public_transportation (id, city_id, system_type, fleet_size) VALUES (1, 1, 'bus', 200), (2, 1, 'light_rail', 150), (3, 2, 'bus', 300), (4, 2, 'tram', 250), (5, 3, 'bus', 400), (6, 3, 'trolleybus', 10... | Show the total number of public transportation systems and their fleet sizes in the West | SELECT COUNT(DISTINCT city_id), system_type, fleet_size FROM west_public_transportation GROUP BY system_type, fleet_size; | gretelai_synthetic_text_to_sql |
CREATE TABLE artists (id INT, name TEXT); INSERT INTO artists (id, name) VALUES (1, 'Ariana Grande'); | Number of concerts per month for artist 'Ariana Grande' | SELECT MONTH(concert_date) AS month, COUNT(*) AS concerts_count FROM concerts JOIN artists ON concerts.artist_id = artists.id WHERE artists.name = 'Ariana Grande' GROUP BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE vulnerabilities (id INT, name TEXT, category TEXT, severity TEXT, date_discovered DATE); INSERT INTO vulnerabilities (id, name, category, severity, date_discovered) VALUES (1, 'SQL Injection', 'Application', 'Low', '2022-03-01'); | What is the minimum severity of vulnerabilities in the 'Application' category? | SELECT MIN(severity) as min_severity FROM vulnerabilities WHERE category = 'Application'; | gretelai_synthetic_text_to_sql |
CREATE TABLE shipments (id INT, source_airport VARCHAR(5), destination_airport VARCHAR(5), shipped_date DATE); INSERT INTO shipments (id, source_airport, destination_airport, shipped_date) VALUES (1, 'LAX', 'JFK', '2022-01-02'), (2, 'LAX', 'JFK', '2022-01-10'), (3, 'JFK', 'LAX', '2022-01-15'); | How many parcels were shipped from 'LAX' to 'JFK' in January 2022? | SELECT COUNT(*) FROM shipments WHERE source_airport = 'LAX' AND destination_airport = 'JFK' AND shipped_date BETWEEN '2022-01-01' AND '2022-01-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE companies (id INT, sector VARCHAR(20), ESG_rating FLOAT); INSERT INTO companies (id, sector, ESG_rating) VALUES (1, 'technology', 8.5), (2, 'finance', 7.3), (3, 'technology', 8.7); | What is the minimum ESG rating for companies in the 'finance' sector? | SELECT MIN(ESG_rating) FROM companies WHERE sector = 'finance'; | gretelai_synthetic_text_to_sql |
CREATE TABLE vuln_assessments (id INT, severity VARCHAR(10), description TEXT); INSERT INTO vuln_assessments (id, severity, description) VALUES (1, 'high', 'SQL Injection'), (2, 'medium', 'Cross-Site Scripting'), (3, 'high', 'Privilege Escalation'), (4, 'medium', 'Code Injection'), (5, 'high', 'Path Traversal'); | What is the number of high and medium severity vulnerabilities in the 'vuln_assessments' table? | SELECT severity, COUNT(*) FROM vuln_assessments WHERE severity IN ('high', 'medium') GROUP BY severity; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (id INT, name VARCHAR(50), department VARCHAR(50)); | Find the number of employees working in the 'Chemical Manufacturing' department | SELECT COUNT(*) FROM Employees WHERE department = 'Chemical Manufacturing'; | gretelai_synthetic_text_to_sql |
CREATE TABLE open_pedagogy (resource_id INT, rating INT, user_id INT, region_id INT); INSERT INTO open_pedagogy (resource_id, rating, user_id, region_id) VALUES (1, 5, 100, 1), (2, 4, 100, 1), (3, 3, 101, 1), (4, 5, 102, 2); CREATE TABLE regions (region_id INT, name VARCHAR(20)); INSERT INTO regions (region_id, name) V... | Which open pedagogy resources have been rated highly by users in the same region? | SELECT op.resource_id, op.rating, op.user_id, op.region_id, r.name as region_name FROM open_pedagogy op JOIN regions r ON op.region_id = r.region_id WHERE op.rating >= 4 GROUP BY op.resource_id, op.rating, op.user_id, op.region_id, r.name HAVING COUNT(*) > 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE cases (case_id INT, case_type VARCHAR(10), billing_amount DECIMAL(10,2), attorney_id INT); INSERT INTO cases (case_id, case_type, billing_amount, attorney_id) VALUES (1, 'Civil', 500.00, 101), (2, 'Criminal', 750.00, 102), (3, 'Civil', 1000.00, 103); CREATE TABLE attorneys (attorney_id INT, attorney_name V... | Display the total billing amount for cases with a 'Criminal' case type and an attorney from the 'New York' office. | SELECT SUM(billing_amount) FROM cases c JOIN attorneys a ON c.attorney_id = a.attorney_id JOIN offices o ON a.office_id = o.office_id WHERE c.case_type = 'Criminal' AND o.office_name = 'New York'; | gretelai_synthetic_text_to_sql |
CREATE TABLE energy_consumption (country text, source text, year integer, consumption integer); | What was the total energy consumption of the top 3 renewable energy sources, by country, in 2019? | SELECT country, source, SUM(consumption) as total_consumption FROM energy_consumption WHERE year = 2019 AND source IN (SELECT source FROM energy_consumption WHERE year = 2019 GROUP BY source ORDER BY SUM(consumption) DESC LIMIT 3) GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE revenue (id INT, region VARCHAR(255), year INT, amount INT); INSERT INTO revenue (id, region, year, amount) VALUES (1, 'South Korea', 2016, 7000000); | What is the total revenue generated by K-pop music in South Korea since 2016? | SELECT SUM(amount) FROM revenue WHERE region = 'South Korea' AND genre = 'K-pop' AND year >= 2016; | gretelai_synthetic_text_to_sql |
CREATE TABLE renewable_energy (id INT, project_name VARCHAR(50), location VARCHAR(50), investment FLOAT); INSERT INTO renewable_energy (id, project_name, location, investment) VALUES (1, 'Solar Farm', 'Arizona', 12000000), (2, 'Wind Turbines', 'Texas', 8000000); | What is the maximum investment in renewable energy projects in the 'renewable_energy' schema? | SELECT MAX(investment) FROM renewable_energy; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotel_reviews (hotel_id INT, hotel_name TEXT, hotel_region TEXT, review_count INT); INSERT INTO hotel_reviews (hotel_id, hotel_name, hotel_region, review_count) VALUES (1, 'Hotel Asia', 'APAC', 200), (2, 'Hotel Europe', 'EMEA', 250), (3, 'Hotel Americas', 'Americas', 300), (4, 'Hotel APAC', 'APAC', 150), (... | What is the maximum number of reviews for a hotel in the APAC region? | SELECT MAX(review_count) FROM hotel_reviews WHERE hotel_region = 'APAC'; | gretelai_synthetic_text_to_sql |
CREATE TABLE financial_sector (year INT, incidents INT); INSERT INTO financial_sector (year, incidents) VALUES (2022, 75), (2021, 100), (2020, 125), (2019, 150), (2018, 175); | What are the total number of security incidents reported in the financial sector by year? | SELECT year, SUM(incidents) FROM financial_sector GROUP BY year; | gretelai_synthetic_text_to_sql |
CREATE TABLE travel_advisory (destination VARCHAR(50), advisory_level VARCHAR(20)); INSERT INTO travel_advisory (destination, advisory_level) VALUES ('Paris', 'Level 1'), ('Rome', 'Level 2'), ('Tokyo', 'Level 0'); | List all destinations with advisory level from 'travel_advisory' table. | SELECT destination FROM travel_advisory; | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists renewable_energy_projects (project_id integer, project_date date, project_location varchar(255)); INSERT INTO renewable_energy_projects (project_id, project_date, project_location) VALUES (1, '2010-01-01', 'Morocco'), (2, '2011-02-15', 'South Africa'), (3, '2012-07-01', 'Egypt'), (4, '2013-12... | What is the total number of renewable energy projects implemented in Africa since 2010? | SELECT COUNT(*) as total_projects FROM renewable_energy_projects WHERE project_date <= CURDATE() AND project_location LIKE 'Africa%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_finance (year INT, developed_country TEXT, developing_country TEXT, amount INT); INSERT INTO climate_finance (year, developed_country, developing_country, amount) VALUES (2019, 'USA', 'Bangladesh', 5000000), (2019, 'Germany', 'India', 7000000), (2019, 'France', 'Morocco', 3000000), (2019, 'Japan', ... | What is the total climate finance provided by developed countries to developing countries in 2019? | SELECT SUM(amount) FROM climate_finance WHERE year = 2019 AND developed_country IN ('USA', 'Germany', 'France', 'Japan', 'Canada') AND developing_country NOT IN ('USA', 'Germany', 'France', 'Japan', 'Canada'); | gretelai_synthetic_text_to_sql |
CREATE TABLE environmental_impact (mine_id INT, mine_ownership VARCHAR(50), year INT, methane_emissions INT); INSERT INTO environmental_impact (mine_id, mine_ownership, year, methane_emissions) VALUES (1, 'Company A', 2020, 2000); INSERT INTO environmental_impact (mine_id, mine_ownership, year, methane_emissions) VALUE... | What is the total methane emission per mine, grouped by mine ownership in the 'environmental_impact' table? | SELECT mine_ownership, SUM(methane_emissions) FROM environmental_impact GROUP BY mine_ownership; | gretelai_synthetic_text_to_sql |
CREATE TABLE Cosmetics (product_id INT, product_name VARCHAR(255), cruelty_free BOOLEAN, rating DECIMAL(3,1)); INSERT INTO Cosmetics (product_id, product_name, cruelty_free, rating) VALUES (1, 'Cosmetic 1', TRUE, 4.6), (2, 'Cosmetic 2', FALSE, 4.8), (3, 'Cosmetic 3', TRUE, 4.2); | List all cruelty-free cosmetics with a rating above 4.5. | SELECT * FROM Cosmetics WHERE cruelty_free = TRUE AND rating > 4.5; | gretelai_synthetic_text_to_sql |
CREATE TABLE pollution_control_initiatives (id INT, name VARCHAR(255), region VARCHAR(255)); CREATE TABLE marine_life_research_stations (id INT, name VARCHAR(255), region VARCHAR(255)); | What is the total number of pollution control initiatives and marine life research stations in the Arctic region? | SELECT SUM(cnt) FROM (SELECT COUNT(*) cnt FROM pollution_control_initiatives WHERE region = 'Arctic' UNION ALL SELECT COUNT(*) FROM marine_life_research_stations WHERE region = 'Arctic') x; | gretelai_synthetic_text_to_sql |
CREATE TABLE TRADITIONAL_ARTS (id INT PRIMARY KEY, name VARCHAR(255), region VARCHAR(255), budget FLOAT); INSERT INTO TRADITIONAL_ARTS (id, name, region, budget) VALUES (1, 'Aboriginal Art Program', 'Oceania', 30000); | What is the average budget allocated for traditional art programs in Oceania? | SELECT AVG(budget) FROM TRADITIONAL_ARTS WHERE region = 'Oceania'; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists state; CREATE TABLE if not exists state.crime_stats (id INT, crime_type VARCHAR(255), crime_count INT); INSERT INTO state.crime_stats (id, crime_type, crime_count) VALUES (1, 'Murder', 25), (2, 'Robbery', 45), (3, 'Murder', 32); | What is the total crime count for each type in the 'state' schema? | SELECT crime_type, SUM(crime_count) FROM state.crime_stats GROUP BY crime_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE Buildings (BuildingID INT, BuildingType VARCHAR(50), EnergyConsumption FLOAT, SquareFootage FLOAT); INSERT INTO Buildings (BuildingID, BuildingType, EnergyConsumption, SquareFootage) VALUES (1, 'Residential', 12000, 2000), (2, 'Commercial', 25000, 5000); | What is the average energy consumption per square foot for each building type? | SELECT BuildingType, AVG(EnergyConsumption / SquareFootage) AS Avg_Energy_Consumption_Per_Sqft FROM Buildings GROUP BY BuildingType; | gretelai_synthetic_text_to_sql |
CREATE TABLE engineering_projects(id INT, name TEXT, type TEXT, partners TEXT); INSERT INTO engineering_projects VALUES(1, 'Bioprocess 1.0', 'Bioprocess Engineering', 'University of Sao Paulo, Brazil'); INSERT INTO engineering_projects VALUES(2, 'Bioprocess 2.0', 'Bioprocess Engineering', 'University of Buenos Aires, A... | Which bioprocess engineering projects have been conducted in collaboration with research institutions in South America? | SELECT name FROM engineering_projects WHERE type = 'Bioprocess Engineering' AND partners LIKE '%South America%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE farms (id INT, name VARCHAR(255)); INSERT INTO farms (id, name) VALUES (1, 'Farm 1'), (2, 'Farm 2'); CREATE TABLE sensors (id INT, farm_id INT, type VARCHAR(255), timestamp TIMESTAMP); INSERT INTO sensors (id, farm_id, type, timestamp) VALUES (1, 1, 'Temperature', '2022-01-01 00:00:00'), (2, 1, 'Humidity',... | List all the farms and their corresponding IoT sensors in the precision_farming database, and the latest timestamp for each sensor. | SELECT f.name, s.type, MAX(s.timestamp) FROM farms f INNER JOIN sensors s ON f.id = s.farm_id GROUP BY f.name, s.type; | gretelai_synthetic_text_to_sql |
CREATE TABLE EsportsEventsYearly (EventYear INT, Region VARCHAR(10), EventCount INT); INSERT INTO EsportsEventsYearly (EventYear, Region, EventCount) VALUES (2022, 'EU', 6); INSERT INTO EsportsEventsYearly (EventYear, Region, EventCount) VALUES (2021, 'NA', 5); | What is the total number of esports events held in the EU region in 2022? | SELECT SUM(EventCount) FROM EsportsEventsYearly WHERE Region = 'EU' AND EventYear = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE wells (well_id varchar(10), region varchar(20), production_figures int); INSERT INTO wells (well_id, region, production_figures) VALUES ('W007', 'Beaufort Sea', 1800), ('W008', 'Beaufort Sea', 2200); | Which wells are located in the Beaufort Sea and have a production figure less than 2000? | SELECT well_id, production_figures FROM wells WHERE region = 'Beaufort Sea' AND production_figures < 2000; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (id INT, species_name VARCHAR(255), ocean VARCHAR(255), depth INT); INSERT INTO marine_species (id, species_name, ocean, depth) VALUES (1, 'Southern Ocean Blenny', 'Southern', 1000); INSERT INTO marine_species (id, species_name, ocean, depth) VALUES (2, 'Southern Ocean Squid', 'Southern', 30... | How many marine species were observed in the Southern ocean? | SELECT COUNT(*) FROM marine_species WHERE ocean = 'Southern'; | gretelai_synthetic_text_to_sql |
CREATE TABLE farmers (name VARCHAR(255), tribe VARCHAR(255), age INT); INSERT INTO farmers (name, tribe, age) VALUES ('Mariama Diallo', 'Mandinka', 45), ('Amadou Cissé', 'Mandinka', 50), ('Fatoumata Keita', 'Mandinka', 48), ('Ibrahima Sow', 'Mandinka', 52); | What is the average age of farmers in the Mandinka community? | SELECT AVG(age) FROM farmers WHERE tribe = 'Mandinka'; | gretelai_synthetic_text_to_sql |
CREATE TABLE food_aid_europe (id INT, delivery_id INT, destination_country VARCHAR(255), delivery_quantity INT, delivery_date DATE); INSERT INTO food_aid_europe (id, delivery_id, destination_country, delivery_quantity, delivery_date) VALUES (1, 8001, 'France', 500, '2021-07-01'); INSERT INTO food_aid_europe (id, delive... | What is the average amount of food aid delivered to "Europe" in Q3 2021? | SELECT AVG(delivery_quantity) FROM food_aid_europe WHERE destination_country = 'Europe' AND QUARTER(delivery_date) = 3 AND YEAR(delivery_date) = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE arctic_biodiversity (species_id INT, species_name VARCHAR(255), population INT, region VARCHAR(255)); CREATE TABLE iucn_redlist (species_id INT, conservation_status VARCHAR(255)); | List the species and their conservation status from the 'arctic_biodiversity' and 'iucn_redlist' tables, excluding species with a population of less than 100. | SELECT a.species_name, r.conservation_status FROM arctic_biodiversity a INNER JOIN iucn_redlist r ON a.species_id = r.species_id WHERE a.population >= 100; | gretelai_synthetic_text_to_sql |
CREATE TABLE podcasts (id INT, title TEXT, length INT, category TEXT, release_date DATE); INSERT INTO podcasts (id, title, length, category, release_date) VALUES (1, 'Podcast1', 45, 'technology', '2021-01-01'), (2, 'Podcast2', 25, 'business', '2021-01-02'); | Find the average length of podcasts in the 'technology' category that are longer than 30 minutes. | SELECT AVG(length) FROM podcasts WHERE length > 30 AND category = 'technology'; | gretelai_synthetic_text_to_sql |
CREATE TABLE grades (grade_id INT, grade_level INT, student_id INT, mental_health_score INT); INSERT INTO grades (grade_id, grade_level, student_id, mental_health_score) VALUES (1, 9, 1, 75), (2, 10, 2, 85), (3, 11, 3, 80), (4, 12, 4, 70), (5, 9, 5, 85); | What is the distribution of mental health scores by grade level? | SELECT grade_level, AVG(mental_health_score) as avg_score FROM grades GROUP BY grade_level; | gretelai_synthetic_text_to_sql |
CREATE TABLE food_safety_inspections (restaurant_location VARCHAR(255), violation_count INT); INSERT INTO food_safety_inspections (restaurant_location, violation_count) VALUES ('Location 1', '2'), ('Location 2', '3'), ('Location 3', '1'), ('Location 4', '5'); | Identify food safety violations by restaurant location | SELECT restaurant_location, violation_count FROM food_safety_inspections ORDER BY violation_count DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE biotech_patents (id INT, country VARCHAR(50), field VARCHAR(50), num_patents INT); INSERT INTO biotech_patents (id, country, field, num_patents) VALUES (1, 'USA', 'gene editing', 500); INSERT INTO biotech_patents (id, country, field, num_patents) VALUES (2, 'China', 'gene editing', 350); INSERT INTO biotec... | List the top 3 countries with the highest number of biotech patents in the field of gene editing. | SELECT country, SUM(num_patents) FROM biotech_patents WHERE field = 'gene editing' GROUP BY country ORDER BY SUM(num_patents) DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE PlayerStats (PlayerID INT, Game VARCHAR(50), Kills INT, Deaths INT, Assists INT); INSERT INTO PlayerStats (PlayerID, Game, Kills, Deaths, Assists) VALUES (1, 'FPS Game', 50, 30, 15); INSERT INTO PlayerStats (PlayerID, Game, Kills, Deaths, Assists) VALUES (2, 'RPG Game', 20, 10, 30); | What is the average number of effective kills for players in the 'FPS Game'? | SELECT AVG((Kills + Assists) - Deaths) AS AvgEffectiveKills FROM PlayerStats WHERE Game = 'FPS Game'; | gretelai_synthetic_text_to_sql |
CREATE TABLE DonorLocations (DonorID INT, Location TEXT); INSERT INTO DonorLocations (DonorID, Location) VALUES (1, 'United States'), (2, 'Canada'); | What's the average donation amount by donors from the United States? | SELECT AVG(donations.Amount) AS AverageDonation FROM Donors donors INNER JOIN DonorLocations ON donors.DonorID = DonorLocations.DonorID INNER JOIN Donations donations ON donors.DonorID = donations.DonorID WHERE DonorLocations.Location = 'United States'; | gretelai_synthetic_text_to_sql |
CREATE TABLE work_injuries (id INT, union_id INT, injury_type VARCHAR(255), injury_date DATE, total_injuries INT); INSERT INTO work_injuries (id, union_id, injury_type, injury_date, total_injuries) VALUES (1, 1, 'Cuts', '2021-01-01', 5); | What is the total number of work-related injuries per union, ordered by the most injuries? | SELECT injury_type, injury_date, total_injuries, RANK() OVER (PARTITION BY union_id ORDER BY total_injuries DESC) as injury_rank FROM work_injuries; | gretelai_synthetic_text_to_sql |
CREATE TABLE therapists (id INT, name TEXT, specialization TEXT, experience INT, patients INT); INSERT INTO therapists (id, name, specialization, experience, patients) VALUES (1, 'Dr. Jane Smith', 'CBT', 10, 20); INSERT INTO therapists (id, name, specialization, experience, patients) VALUES (2, 'Dr. John Doe', 'DBT', 1... | List all therapists in California who have treated more than 15 patients | SELECT name FROM therapists WHERE patients > 15 AND state = 'California'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (id INT PRIMARY KEY, donor_name VARCHAR(255), email VARCHAR(255)); INSERT INTO Donors (id, donor_name, email) VALUES (1, 'John Doe', 'john.doe@example.com'), (2, 'Jane Smith', 'jane.smith@example.com'); | Update the email address for the donor named 'Jane Smith' in the 'Donors' table | UPDATE Donors SET email = 'jane.smith@newemail.com' WHERE donor_name = 'Jane Smith'; | gretelai_synthetic_text_to_sql |
CREATE TABLE social_media (user_id INT, posts_count INT); | What is the total number of users in the 'social_media' table? | SELECT COUNT(user_id) FROM social_media; | gretelai_synthetic_text_to_sql |
CREATE TABLE Customers (id INT, country VARCHAR(255), total_spent DECIMAL(5,2)); | Get the total spending of customers from the United States. | SELECT SUM(total_spent) as total_us_spending FROM Customers WHERE country = 'United States'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Spacecraft (SpacecraftID INT, Manufacturer VARCHAR(50), Model VARCHAR(50), Mass FLOAT); | What is the distribution of spacecraft manufacturers? | SELECT Manufacturer, COUNT(*) FROM Spacecraft GROUP BY Manufacturer; | gretelai_synthetic_text_to_sql |
CREATE TABLE clients (client_id INT, name TEXT, dob DATE, branch TEXT);CREATE TABLE accounts (account_id INT, client_id INT, account_type TEXT, balance DECIMAL);INSERT INTO clients VALUES (6, 'Olivia Wilson', '1978-11-12', 'New York');INSERT INTO accounts VALUES (106, 6, 'Savings', 2000); | What is the minimum balance for clients with savings accounts in the New York branch? | SELECT MIN(accounts.balance) FROM clients INNER JOIN accounts ON clients.client_id = accounts.client_id WHERE accounts.account_type = 'Savings' AND clients.branch = 'New York'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Claims (Claim_Amount NUMERIC, Risk_Level TEXT); INSERT INTO Claims (Claim_Amount, Risk_Level) VALUES (2500, 'High'), (3000, 'Very High'), (2000, 'Medium'), (1500, 'Low'); | What is the maximum claim amount for each risk level? | SELECT Risk_Level, MAX(Claim_Amount) FROM Claims GROUP BY Risk_Level; | gretelai_synthetic_text_to_sql |
CREATE TABLE inspection_reports (id INT, restaurant_id INT, inspection_date DATE, is_compliant BOOLEAN); INSERT INTO inspection_reports (id, restaurant_id, inspection_date, is_compliant) VALUES (1, 1, '2021-01-01', false); INSERT INTO inspection_reports (id, restaurant_id, inspection_date, is_compliant) VALUES (2, 2, '... | Count the number of non-compliant food inspections | SELECT COUNT(*) FROM inspection_reports WHERE is_compliant = false; | gretelai_synthetic_text_to_sql |
CREATE TABLE teachers (teacher_id INT, name VARCHAR(50), state VARCHAR(20)); | Remove the 'teacher_certification' column from the 'teachers' table | ALTER TABLE teachers DROP COLUMN teacher_certification; | gretelai_synthetic_text_to_sql |
CREATE TABLE Organic_Produce (id INT, name VARCHAR(50), calories INT, category VARCHAR(50)); INSERT INTO Organic_Produce (id, name, calories, category) VALUES (1, 'Apples', 95, 'Fruits'), (2, 'Broccoli', 55, 'Vegetables'); CREATE TABLE Categories (id INT, name VARCHAR(50), category_avg_calories INT); INSERT INTO Catego... | Find the average calorie count for all organic produce items in the 'Fruits' category? | SELECT AVG(calories) FROM Organic_Produce o JOIN Categories c ON o.category = c.name WHERE c.name = 'Fruits'; | gretelai_synthetic_text_to_sql |
CREATE TABLE regions (id INT PRIMARY KEY, name VARCHAR(255)); CREATE TABLE ingredients (id INT PRIMARY KEY, name VARCHAR(255), origin VARCHAR(255)); CREATE TABLE sustainability (id INT PRIMARY KEY, ingredient_id INT, certification VARCHAR(255)); | Show all ingredients and their certifications from a specific region | SELECT ingredients.name, sustainability.certification FROM ingredients INNER JOIN sustainability ON ingredients.id = sustainability.ingredient_id INNER JOIN regions ON ingredients.origin = regions.name WHERE regions.name = 'Africa'; | gretelai_synthetic_text_to_sql |
CREATE TABLE smart_contracts (user_id INT, transaction_count INT); CREATE TABLE users (id INT, name VARCHAR(255)); INSERT INTO smart_contracts (user_id, transaction_count) VALUES (1, 50), (2, 100), (3, 75), (4, 200), (5, 150), (6, 120); INSERT INTO users (id, name) VALUES (1, 'User 1'), (2, 'User 2'), (3, 'User 3'), (4... | Who are the top 5 users with the most transactions in smart contracts? | SELECT u.name, sc.transaction_count FROM users u JOIN smart_contracts sc ON u.id = sc.user_id ORDER BY sc.transaction_count DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE Infrastructure (id INT, name VARCHAR(100), type VARCHAR(50), state VARCHAR(50), build_date DATE); INSERT INTO Infrastructure (id, name, type, state, build_date) VALUES (1, 'Golden Gate Bridge', 'Bridge', 'California', '1937-05-27'); INSERT INTO Infrastructure (id, name, type, state, build_date) VALUES (2, ... | Count the number of roads in Texas that have been built since 2010 | SELECT COUNT(*) FROM Infrastructure WHERE state = 'Texas' AND type = 'Road' AND build_date >= '2010-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE orders (order_date DATE, customer_id INT, size VARCHAR(10), quantity INT); INSERT INTO orders (order_date, customer_id, size, quantity) VALUES ('2022-01-01', 1, 'large', 100), ('2022-01-02', 2, 'large', 200), ('2022-01-03', 3, 'medium', 150), ('2022-01-04', 4, 'large', 120), ('2022-01-05', 4, 'large', 130)... | What is the percentage of orders placed by each customer in the 'large' size category in the first quarter of 2022? | SELECT c.customer_id, c.name, 100.0 * COUNT(o.order_id) / (SELECT COUNT(*) FROM orders WHERE order_date >= '2022-01-01' AND order_date < '2022-04-01') as pct_orders FROM orders o RIGHT JOIN customers c ON o.customer_id = c.customer_id WHERE size = 'large' AND EXTRACT(MONTH FROM order_date) < 4 GROUP BY c.customer_id, c... | gretelai_synthetic_text_to_sql |
CREATE TABLE shows (id INT, title TEXT, genre TEXT, view_count INT); | Add a new TV show 'Cobra Kai' with a genre 'Action' and a view count 1000000 | INSERT INTO shows (id, title, genre, view_count) VALUES (1, 'Cobra Kai', 'Action', 1000000); | gretelai_synthetic_text_to_sql |
CREATE TABLE athletes (athlete_id INT, age INT, world_cup INT); INSERT INTO athletes (athlete_id, age, world_cup) VALUES (1, 24, 1), (2, 29, 1), (3, 32, 0); | What is the average age of athletes who competed in the last world cup? | SELECT AVG(age) FROM athletes WHERE world_cup = (SELECT MAX(world_cup) FROM athletes); | gretelai_synthetic_text_to_sql |
CREATE TABLE interactions (id INT, user_id INT, post_id INT, created_at TIMESTAMP); CREATE TABLE posts (id INT, state VARCHAR(255), hashtags VARCHAR(255), created_at TIMESTAMP); | Show the number of unique users who have interacted with posts containing the hashtag "#foodjustice" in each state in the United States, in the past week. | SELECT state, COUNT(DISTINCT user_id) as user_count FROM interactions JOIN posts ON interactions.post_id = posts.id WHERE hashtags LIKE '%#foodjustice%' AND posts.created_at > NOW() - INTERVAL '1 week' GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE budget (region varchar(20), service varchar(20), allocation int); INSERT INTO budget (region, service, allocation) VALUES ('Northeast', 'Education', 4000000), ('Northeast', 'Healthcare', 6000000), ('Southeast', 'Education', 5000000), ('Southeast', 'Healthcare', 7000000); | What is the total budget allocation for all services in the Northeast region? | SELECT SUM(allocation) FROM budget WHERE region = 'Northeast'; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (id INT, product VARCHAR(50), quantity INT, price DECIMAL(5,2), sale_date DATE); INSERT INTO sales (id, product, quantity, price, sale_date) VALUES (1, 'Dress', 3, 100.00, '2020-01-01'); INSERT INTO sales (id, product, quantity, price, sale_date) VALUES (2, 'Dress', 2, 120.00, '2020-02-15'); | find the total revenue for the 'Dress' category for the year 2020 | SELECT SUM(quantity * price) FROM sales WHERE product = 'Dress' AND YEAR(sale_date) = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE workshops (id INT, workshop_date DATE); INSERT INTO workshops (id, workshop_date) VALUES (1, '2022-01-01'), (2, '2022-02-15'), (3, '2022-03-10'), (4, '2022-04-01'); | How many professional development workshops were conducted in the last 3 months? | SELECT COUNT(*) as num_workshops FROM workshops WHERE workshop_date >= DATEADD(month, -3, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE DefenseCooperation (Country VARCHAR(255), Region VARCHAR(255), CooperationType VARCHAR(255), ProvidesCybersecurity BOOLEAN); INSERT INTO DefenseCooperation (Country, Region, CooperationType, ProvidesCybersecurity) VALUES ('Israel', 'Middle East', 'MilitaryExercise', TRUE), ('Saudi Arabia', 'Middle East', '... | List the top 3 providers of cybersecurity cooperation during defense diplomacy events in the Middle East region? | SELECT Country, CooperationType FROM (SELECT Country, CooperationType, ROW_NUMBER() OVER (PARTITION BY CooperationType ORDER BY ProvidesCybersecurity DESC) AS Rank FROM DefenseCooperation WHERE Region = 'Middle East') AS RankedCooperation WHERE Rank <= 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE continent (continent_code CHAR(2), continent_name VARCHAR(50)); INSERT INTO continent VALUES ('AF', 'Africa'), ('AS', 'Asia'); CREATE TABLE visit_summary (continent_code CHAR(2), year INT, visitor_count INT); INSERT INTO visit_summary VALUES ('AF', 2020, 1000), ('AF', 2019, 1200), ('AS', 2020, 2000), ('AS'... | Which continent has the highest average visitor count? | SELECT continent_code, AVG(visitor_count) OVER (PARTITION BY continent_code) AS avg_visitor_count FROM visit_summary; | gretelai_synthetic_text_to_sql |
CREATE TABLE genetic_research_funding (id INT PRIMARY KEY, project_id INT, amount FLOAT, date DATE, FOREIGN KEY (project_id) REFERENCES genetic_research(id)); INSERT INTO genetic_research_funding (id, project_id, amount, date) VALUES (1, 1, 1000000.00, '2020-05-01'); | Update the funding amount for a specific genetic research project | UPDATE genetic_research_funding SET amount = 1200000.00 WHERE id = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE mental_health_parity (id INT, regulation VARCHAR(100), effective_date DATE); INSERT INTO mental_health_parity (id, regulation, effective_date) VALUES (1, 'Regulation 1', '2010-01-01'), (2, 'Regulation 2', '2015-01-01'); | List all mental health parity regulations and their corresponding effective dates in New York and Florida. | SELECT regulation, effective_date FROM mental_health_parity WHERE state IN ('New York', 'Florida'); | gretelai_synthetic_text_to_sql |
CREATE TABLE investments (id INT, category VARCHAR(255), date DATE, amount FLOAT); INSERT INTO investments (id, category, date, amount) VALUES (1, 'renewable energy', '2021-03-15', 10000), (2, 'technology', '2020-12-21', 15000), (3, 'renewable energy', '2021-01-03', 12000); | What is the total investment amount made in the renewable energy category in the last quarter? | SELECT SUM(amount) FROM investments WHERE category = 'renewable energy' AND date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE streams (id INT, artist VARCHAR(50), country VARCHAR(50), streams INT, year INT); INSERT INTO streams (id, artist, country, streams, year) VALUES (1, 'Burna Boy', 'Nigeria', 4000000, 2021); INSERT INTO streams (id, artist, country, streams, year) VALUES (2, 'Wizkid', 'Nigeria', 5000000, 2021); INSERT INTO ... | Find the total number of streams for artists from Africa in 2021. | SELECT SUM(streams) FROM streams WHERE country IN (SELECT DISTINCT country FROM artists WHERE continent = 'Africa') AND year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE sector (sector TEXT, investment_amount FLOAT); INSERT INTO sector (sector, investment_amount) VALUES ('Energy', 8000000), ('Transportation', 5000000), ('Agriculture', 3000000), ('Industry', 6000000), ('Buildings', 4000000); | What is the total amount of climate finance invested in each sector? | SELECT sector, SUM(investment_amount) FROM sector GROUP BY sector; | gretelai_synthetic_text_to_sql |
CREATE TABLE Bridge (id INT, name VARCHAR(255), build_date DATE); INSERT INTO Bridge (id, name, build_date) VALUES (1, 'Bridge A', '2001-01-01'), (2, 'Bridge B', '1999-05-15'), (3, 'Bridge C', '2005-03-25'); | List all bridges that were built after the year 2000 | SELECT * FROM Bridge WHERE build_date > '2000-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE SmartCityDevice (id INT, name VARCHAR(255), city_id INT, usage INT, install_date DATE); INSERT INTO SmartCityDevice (id, name, city_id, usage, install_date) VALUES (1, 'Smart Light', 1, 100, '2020-01-01'); INSERT INTO SmartCityDevice (id, name, city_id, usage, install_date) VALUES (2, 'Smart Trash Can', 2,... | What is the total usage of smart city devices installed after January 1, 2019? | SELECT SUM(usage) FROM SmartCityDevice WHERE install_date > '2019-01-01'; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists south_american_schema_2;CREATE TABLE south_american_schema_2.south_american_mines (id INT, name VARCHAR, location VARCHAR);INSERT INTO south_american_schema_2.south_american_mines (id, name, location) VALUES (1, 'Peru mining', 'Peru'), (2, 'Colombia mining', 'Colombia'); | How many mining operations in 'south_american_mines' are located in Peru? | SELECT COUNT(*) FROM south_american_schema_2.south_american_mines WHERE location = 'Peru'; | gretelai_synthetic_text_to_sql |
CREATE TABLE incidents (iid INT, incident_time TIMESTAMP); | What is the total number of crime incidents reported in the last month, broken down by hour? | SELECT HOUR(i.incident_time) AS hour, COUNT(i.iid) FROM incidents i WHERE i.incident_time >= DATE_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 MONTH) GROUP BY hour; | gretelai_synthetic_text_to_sql |
CREATE TABLE subway_entries_exits (id INT, station_name VARCHAR(50), entry_time TIMESTAMP, exit_time TIMESTAMP); INSERT INTO subway_entries_exits (id, station_name, entry_time, exit_time) VALUES (1, 'Times Square', '2022-01-01 08:00:00', '2022-01-01 08:10:00'), (2, 'Grand Central', '2022-01-01 08:05:00', '2022-01-01 08... | List the top 5 busiest subway stations in New York City, with the number of entries and exits? | SELECT station_name, COUNT(*) as entries_exits FROM subway_entries_exits WHERE entry_time IS NOT NULL OR exit_time IS NOT NULL GROUP BY station_name ORDER BY entries_exits DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE Project_Timelines (Project_ID INT, Sustainable BOOLEAN, Timeline INT); INSERT INTO Project_Timelines (Project_ID, Sustainable, Timeline) VALUES (1, true, 365), (2, true, 420), (3, true, 450), (4, false, 500), (5, true, 400), (6, false, 440), (7, true, 380), (8, true, 425), (9, false, 475), (10, false, 460)... | What is the average project timeline for sustainable projects in the state of California, and what is the average project timeline for non-sustainable projects in the state of California? | SELECT pt.Sustainable, AVG(pt.Timeline) FROM Project_Timelines pt GROUP BY pt.Sustainable; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_education (id INT PRIMARY KEY, country VARCHAR(20), program_name VARCHAR(30), start_date DATE, end_date DATE); | Insert a new record into the 'community_education' table with these values: 'USA', 'Wildlife Awareness Program', '2023-01-01', '2023-12-31' | INSERT INTO community_education (country, program_name, start_date, end_date) VALUES ('USA', 'Wildlife Awareness Program', '2023-01-01', '2023-12-31'); | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT, username VARCHAR(50)); CREATE TABLE status_updates (user_id INT, update_time TIMESTAMP); CREATE TABLE photos (user_id INT, photo_time TIMESTAMP); | Which users have posted more than 10 status updates or photos in the last week? | SELECT users.username FROM users JOIN (SELECT user_id FROM status_updates WHERE update_time > NOW() - INTERVAL '1 week' GROUP BY user_id HAVING COUNT(*) > 10 UNION SELECT user_id FROM photos WHERE photo_time > NOW() - INTERVAL '1 week' GROUP BY user_id HAVING COUNT(*) > 10) AS user_activity ON users.id = user_activity.... | gretelai_synthetic_text_to_sql |
CREATE TABLE menu_categories (id INT PRIMARY KEY, menu_category VARCHAR(255)); CREATE TABLE menu_orders (id INT PRIMARY KEY, menu_item VARCHAR(255), order_count INT, menu_category VARCHAR(255)); | Find the total number of times each menu category has been ordered | SELECT menu_categories.menu_category, SUM(menu_orders.order_count) as total_orders FROM menu_categories JOIN menu_orders ON menu_categories.menu_category = menu_orders.menu_category GROUP BY menu_categories.menu_category; | gretelai_synthetic_text_to_sql |
CREATE TABLE Events (id INT, name TEXT, city TEXT, funding INT); INSERT INTO Events (id, name, city, funding) VALUES (1, 'Art Exhibition', 'New York', 10000), (2, 'Theater Performance', 'Los Angeles', 15000), (3, 'Music Concert', 'Chicago', 20000); | Show the total funding received by events in 'Los Angeles' | SELECT SUM(funding) FROM Events WHERE city = 'Los Angeles'; | gretelai_synthetic_text_to_sql |
CREATE TABLE production (id INT, material VARCHAR(20), water_savings INT); INSERT INTO production (id, material, water_savings) VALUES (1, 'Organic Cotton', 1000), (2, 'Recycled Polyester', 1500), (3, 'Tencel', 800); | What is the total quantity of water saved by using sustainable materials in production? | SELECT SUM(water_savings) FROM production WHERE material IN ('Organic Cotton', 'Tencel'); | gretelai_synthetic_text_to_sql |
CREATE TABLE investment_strategies (strategy_id INT, name VARCHAR(30), aum DECIMAL(15,2)); INSERT INTO investment_strategies (strategy_id, name, aum) VALUES (1, 'Conservative Growth', 50000000.00), (2, 'Aggressive Growth', 70000000.00); | What is the total assets under management (AUM) for the investment strategy named "Conservative Growth"? | SELECT SUM(aum) FROM investment_strategies WHERE name = 'Conservative Growth'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Unions (UnionID INT, UnionName TEXT); CREATE TABLE Accidents (AccidentID INT, UnionID INT, NumberOfAccidents INT); | What is the total number of workplace accidents for each union, sorted by the number of accidents in descending order? | SELECT u.UnionName, SUM(a.NumberOfAccidents) AS TotalAccidents FROM Unions u INNER JOIN Accidents a ON u.UnionID = a.UnionID GROUP BY u.UnionName ORDER BY TotalAccidents DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE customers (id INT, name VARCHAR(50), age INT, account_balance DECIMAL(10, 2), assets DECIMAL(10, 2), category VARCHAR(20)); INSERT INTO customers (id, name, age, account_balance, assets, category) VALUES (1, 'Jane Smith', 50, 15000.00, 75000.00, 'Silver'), (2, 'Marie Jones', 45, 8000.00, 40000.00, 'Silver'... | What is the total value of assets for customers in the 'Silver' category who have an account balance over 10000? | SELECT SUM(assets) FROM customers WHERE account_balance > 10000 AND category = 'Silver'; | 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.