context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE volunteers (id INT, name VARCHAR(255), program VARCHAR(255), volunteer_date DATE); CREATE TABLE all_programs (id INT, name VARCHAR(255), focus_area VARCHAR(255)); | How many unique volunteers have there been in each program in the past year? | SELECT program, COUNT(DISTINCT id) FROM volunteers JOIN all_programs ON volunteers.program = all_programs.name WHERE volunteer_date >= DATEADD(year, -1, GETDATE()) GROUP BY program; | gretelai_synthetic_text_to_sql |
CREATE TABLE fields (field_id INT, field_name TEXT, location TEXT); | Insert a new record into the 'fields' table for a field named 'Offshore Field X' located in the Gulf of Mexico. | INSERT INTO fields (field_name, location) VALUES ('Offshore Field X', 'Gulf of Mexico'); | gretelai_synthetic_text_to_sql |
CREATE TABLE carbon_offset_projects (id INT PRIMARY KEY, project_name VARCHAR(100), location VARCHAR(50)); | Add a new carbon offset project called 'Peatland Restoration' to the 'carbon_offset_projects' table | INSERT INTO carbon_offset_projects (project_name, location) VALUES ('Peatland Restoration', 'Boreal Forest'); | gretelai_synthetic_text_to_sql |
CREATE SCHEMA space; USE space; CREATE TABLE spacecraft (name VARCHAR(50), destination VARCHAR(50), visits INT); INSERT INTO spacecraft (name, destination, visits) VALUES ('Mariner 4', 'Mars', 1), ('Mariner 6', 'Mars', 1), ('Mariner 7', 'Mars', 1), ('Viking 1', 'Mars', 1), ('Viking 2', 'Mars', 1), ('Mars Global Surveyo... | What is the total number of spacecraft that have visited Mars? | SELECT COUNT(name) FROM space.spacecraft WHERE destination = 'Mars'; | gretelai_synthetic_text_to_sql |
CREATE TABLE news_articles (id INT, title VARCHAR(100), section VARCHAR(50), rating INT); INSERT INTO news_articles (id, title, section, rating) VALUES (1, 'Article 1', 'technology', 4), (2, 'Article 2', 'politics', 5), (3, 'Article 3', 'sports', 3), (4, 'Article 4', 'international', 7); CREATE TABLE news_ratings (arti... | Which international news article has the highest rating? | SELECT title FROM news_articles WHERE id = (SELECT article_id FROM news_ratings WHERE rating = (SELECT MAX(rating) FROM news_ratings WHERE section = 'international')); | gretelai_synthetic_text_to_sql |
CREATE TABLE IndigenousCommunities (id INT PRIMARY KEY, community VARCHAR(255), location VARCHAR(255), population INT); INSERT INTO IndigenousCommunities (id, community, location, population) VALUES (1, 'Inuit', 'Canada', 60000); INSERT INTO IndigenousCommunities (id, community, location, population) VALUES (2, 'Sami',... | Calculate the total number of indigenous communities in each Arctic country. | SELECT location, COUNT(DISTINCT community) as total_communities FROM IndigenousCommunities GROUP BY location; | gretelai_synthetic_text_to_sql |
CREATE TABLE wildlife_habitat (species VARCHAR(255), forest_type VARCHAR(255)); | Find the wildlife species that are present in both temperate and tropical forests. | SELECT species FROM wildlife_habitat WHERE forest_type IN ('temperate', 'tropical') GROUP BY species HAVING COUNT(DISTINCT forest_type) = 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE RuralInfrastructure (region TEXT, year INTEGER, project_status TEXT); INSERT INTO RuralInfrastructure (region, year, project_status) VALUES ('South Asia', 2019, 'completed'), ('South Asia', 2020, 'completed'), ('South Asia', 2021, 'completed'), ('South Asia', 2019, 'in progress'), ('South Asia', 2020, 'in ... | How many rural infrastructure projects were completed in South Asia in each year? | SELECT year, COUNT(*) FROM RuralInfrastructure WHERE region = 'South Asia' AND project_status = 'completed' GROUP BY year; | gretelai_synthetic_text_to_sql |
CREATE TABLE patients (id INT, condition VARCHAR(50), region VARCHAR(50)); INSERT INTO patients (id, condition, region) VALUES (1, 'Anxiety', 'Europe'), (2, 'Depression', 'Europe'), (3, 'Bipolar Disorder', 'Europe'), (4, 'Anxiety', 'USA'); | What percentage of patients in Europe have anxiety as a primary condition? | SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM patients WHERE region = 'Europe')) AS percentage FROM patients WHERE region = 'Europe' AND condition = 'Anxiety'; | gretelai_synthetic_text_to_sql |
CREATE TABLE date (date_id INT, date DATE); INSERT INTO date (date_id, date) VALUES (1, '2022-01-01'), (2, '2022-02-01'), (3, '2022-03-01'), (4, '2022-04-01'), (5, '2022-05-01'), (6, '2022-06-01'), (7, '2022-07-01'), (8, '2022-08-01'), (9, '2022-09-01'), (10, '2022-10-01'), (11, '2022-11-01'), (12, '2022-12-01'); CREAT... | What is the total water usage per month for the last year? | SELECT EXTRACT(MONTH FROM d.date) as month, AVG(w.water_usage_m3) as avg_water_usage_m3 FROM water_usage w JOIN date d ON w.date_id = d.date_id WHERE d.date BETWEEN '2021-01-01' AND '2022-12-31' GROUP BY EXTRACT(MONTH FROM d.date); | gretelai_synthetic_text_to_sql |
CREATE TABLE companies (id INT, name TEXT, founder_gender TEXT); INSERT INTO companies (id, name, founder_gender) VALUES (1, 'Acme Inc', 'female'), (2, 'Beta Corp', 'male'); CREATE TABLE funding (company_id INT, amount INT); INSERT INTO funding (company_id, amount) VALUES (1, 500000), (2, 750000); | What is the total funding received by startups founded by women? | SELECT SUM(funding.amount) FROM companies INNER JOIN funding ON companies.id = funding.company_id WHERE companies.founder_gender = 'female'; | gretelai_synthetic_text_to_sql |
CREATE TABLE timber_production (id INT, year INT, volume FLOAT); INSERT INTO timber_production (id, year, volume) VALUES (1, 2020, 1200.5), (2, 2021, 1500.7), (3, 2022, 1700.3); | How many timber production records were inserted in 2022? | SELECT COUNT(*) FROM timber_production WHERE year = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE heritage_preservation (project_id INT, project_name TEXT, start_date DATE, end_date DATE, budget INT); | Insert new records into the heritage_preservation table for a new project. | INSERT INTO heritage_preservation (project_id, project_name, start_date, end_date, budget) VALUES (2001, 'Conservation of Indigenous Art', '2023-01-01', '2023-12-31', 500000); | gretelai_synthetic_text_to_sql |
CREATE TABLE SupportPrograms (programID INT, programName VARCHAR(50), enrollment INT); | What is the maximum number of students enrolled in a support program in the SupportPrograms table? | SELECT MAX(enrollment) FROM SupportPrograms; | gretelai_synthetic_text_to_sql |
CREATE TABLE dallas_emergency_response (id INT, incident_type TEXT, response_time INT); INSERT INTO dallas_emergency_response (id, incident_type, response_time) VALUES (1, 'Fire', 120), (2, 'Medical', 150), (3, 'Police', 180); | What is the average incident response time in Dallas? | SELECT AVG(response_time) FROM dallas_emergency_response WHERE incident_type = 'Police'; | gretelai_synthetic_text_to_sql |
CREATE TABLE CitizenFeedback (District VARCHAR(10), Quarter INT, Year INT, FeedbackCount INT); INSERT INTO CitizenFeedback VALUES ('District K', 3, 2021, 700), ('District K', 4, 2021, 800), ('District L', 3, 2021, 600), ('District L', 4, 2021, 700); | How many citizens provided feedback in District K and L in Q3 and Q4 of 2021? | SELECT SUM(FeedbackCount) FROM CitizenFeedback WHERE District IN ('District K', 'District L') AND Quarter IN (3, 4) AND Year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (species_name TEXT, conservation_status TEXT, habitat TEXT); INSERT INTO marine_species (species_name, conservation_status, habitat) VALUES ('Beluga Whale', 'Near Threatened', 'Arctic Ocean'), ('Greenland Shark', 'Least Concern', 'Atlantic and Arctic Oceans'), ('Polar Bear', 'Vulnerable', 'A... | List all marine species found in the Arctic Ocean | SELECT species_name FROM marine_species WHERE habitat = 'Arctic Ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE inspection_scores (restaurant_name TEXT, location TEXT, score INTEGER); INSERT INTO inspection_scores (restaurant_name, location, score) VALUES ('Restaurant A', 'California', 90), ('Restaurant B', 'California', 85), ('Restaurant C', 'California', 95); | What is the maximum food safety score for restaurants in 'California'? | SELECT MAX(score) FROM inspection_scores WHERE location = 'California'; | gretelai_synthetic_text_to_sql |
CREATE TABLE FashionBrands (BrandID INT, BrandName VARCHAR(50), SustainableFabricsUsed INT); CREATE TABLE FabricUsage (BrandID INT, FabricType VARCHAR(50), QuantityUsed INT); | What is the total quantity of sustainable fabrics used by each fashion brand? | SELECT FB.BrandName, SUM(FU.QuantityUsed) AS TotalSustainableFabricsUsed FROM FashionBrands FB INNER JOIN FabricUsage FU ON FB.BrandID = FU.BrandID WHERE FB.SustainableFabricsUsed = 1 GROUP BY FB.BrandName; | gretelai_synthetic_text_to_sql |
CREATE TABLE canada_platforms (platform_id INT, platform_name VARCHAR(50), location VARCHAR(50), operational_status VARCHAR(15)); INSERT INTO canada_platforms VALUES (1, 'Suncor 1', 'Alberta', 'Active'); INSERT INTO canada_platforms VALUES (2, 'Imperial Oil 1', 'Alberta', 'Active'); CREATE TABLE oil_production (platfor... | What was the average crude oil production in Canada by month? | SELECT month, AVG(production) FROM oil_production GROUP BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE Organic_Cosmetics (product_id INT, product_name VARCHAR(255), category VARCHAR(255), price DECIMAL(10,2)); INSERT INTO Organic_Cosmetics (product_id, product_name, category, price) VALUES (1, 'Organic Cosmetic 1', 'Organic', 35.99), (2, 'Organic Cosmetic 2', 'Organic', 45.99), (3, 'Organic Cosmetic 3', 'Or... | List all cosmetics with a price greater than 40 USD from the organic line. | SELECT * FROM Organic_Cosmetics WHERE price > 40; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (DonorID INT, DonorName TEXT, DonationAmount DECIMAL(10,2), FirstDonationDate DATE); INSERT INTO Donors (DonorID, DonorName, DonationAmount, FirstDonationDate) VALUES (1, 'Grace', 250.00, '2021-08-20'), (2, 'Harry', 550.00, '2022-02-10'); | What is the average donation amount for new and returning donors in H1 2022? | SELECT CASE WHEN FirstDonationDate BETWEEN '2022-01-01' AND '2022-06-30' THEN 'New Donor' ELSE 'Returning Donor' END as DonorType, AVG(DonationAmount) as AvgDonation FROM Donors WHERE DonationDate BETWEEN '2022-01-01' AND '2022-06-30' GROUP BY DonorType; | gretelai_synthetic_text_to_sql |
CREATE TABLE restorative_justice_program (id INT, age INT, completion_date DATE); | What is the average age of individuals who have completed a restorative justice program in the last year? | SELECT AVG(age) FROM restorative_justice_program WHERE completion_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR); | gretelai_synthetic_text_to_sql |
CREATE TABLE production (id INT, product_id INT, material VARCHAR(50), production_cost DECIMAL(5,2)); | What is the total production cost for each sustainable material? | SELECT material, SUM(production_cost) AS total_production_cost FROM production WHERE material IN ('organic_cotton', 'recycled_polyester', 'tencel', 'hemp', 'modal') GROUP BY material; | gretelai_synthetic_text_to_sql |
CREATE TABLE AIEthicsPapers (id INT, paper_title VARCHAR(50), author_name VARCHAR(50), affiliation VARCHAR(50), publication_date DATE, num_citations INT); INSERT INTO AIEthicsPapers (id, paper_title, author_name, affiliation, publication_date, num_citations) VALUES (1, 'AI Ethics in Africa: A Review', 'John Doe', 'Univ... | How many AI ethics research papers were published in the past year by authors affiliated with universities in Africa, and what is the minimum number of citations for a single paper? | SELECT affiliation, COUNT(*) as paper_count FROM AIEthicsPapers WHERE affiliation IN (SELECT affiliation FROM AIEthicsPapers WHERE publication_date >= '2022-01-01' AND author_name IN (SELECT author_name FROM AIEthicsPapers WHERE affiliation LIKE '%Africa%')) GROUP BY affiliation; SELECT MIN(num_citations) as min_citati... | gretelai_synthetic_text_to_sql |
CREATE TABLE mental_health (patient_id INT, gender VARCHAR(10), condition VARCHAR(50)); INSERT INTO mental_health (patient_id, gender, condition) VALUES (1, 'Male', 'Depression'), (2, 'Female', 'Anxiety'), (3, 'Non-binary', 'Bipolar'), (4, 'Male', 'PTSD'), (5, 'Female', 'Depression'), (6, 'Non-binary', 'Anxiety'), (7, ... | What is the distribution of mental health conditions among different genders? | SELECT gender, condition, COUNT(*) as count FROM mental_health GROUP BY gender, condition; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_mammals (mammal_id INT, mammal_name VARCHAR(255), PRIMARY KEY(mammal_id)); INSERT INTO marine_mammals (mammal_id, mammal_name) VALUES (1, 'Polar Bear'); CREATE TABLE population_trends (population_id INT, mammal_id INT, region VARCHAR(255), population_status VARCHAR(255), PRIMARY KEY(population_id, m... | List all marine mammal species and their population trends in the Arctic Ocean. | SELECT marine_mammals.mammal_name, population_trends.population_status FROM marine_mammals INNER JOIN population_trends ON marine_mammals.mammal_id = population_trends.mammal_id WHERE population_trends.region = 'Arctic Ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE IslandSite (site VARCHAR(50), date DATE, artifacts INT); INSERT INTO IslandSite (site, date, artifacts) VALUES ('IslandSite1', '2019-01-01', 5), ('IslandSite1', '2019-01-02', 7); INSERT INTO IslandSite (site, date, artifacts) VALUES ('IslandSite2', '2019-01-01', 3), ('IslandSite2', '2019-01-02', 4); | What was the total number of artifacts found in 'IslandSite1' and 'IslandSite2' in '2019'? | SELECT SUM(artifacts) FROM IslandSite WHERE site IN ('IslandSite1', 'IslandSite2') AND date LIKE '2019-%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE countries (country_name VARCHAR(50), eco_tourism_activities INT); INSERT INTO countries (country_name, eco_tourism_activities) VALUES ('Costa Rica', 100), ('Nepal', 80), ('Bhutan', 60), ('New Zealand', 120); | Rank countries by the number of eco-tourism activities offered, highest first. | SELECT country_name, ROW_NUMBER() OVER(ORDER BY eco_tourism_activities DESC) as rank FROM countries; | gretelai_synthetic_text_to_sql |
CREATE TABLE Tours (id INT, country TEXT, type TEXT, participants INT); INSERT INTO Tours (id, country, type, participants) VALUES (1, 'South Africa', 'Eco-friendly', 200), (2, 'South Africa', 'Regular', 300), (3, 'South Africa', 'Eco-friendly', 250); | What is the total number of eco-friendly tours in South Africa? | SELECT SUM(participants) FROM Tours WHERE country = 'South Africa' AND type = 'Eco-friendly'; | gretelai_synthetic_text_to_sql |
CREATE TABLE movies (title VARCHAR(255), rating INT, director VARCHAR(50)); INSERT INTO movies (title, rating, director) VALUES ('Movie1', 8, 'DirectorA'), ('Movie2', 7, 'DirectorB'), ('Movie3', 9, 'DirectorA'), ('Movie4', 6, 'DirectorB'); | What is the average movie rating for each director? | SELECT director, AVG(rating) as avg_rating FROM movies GROUP BY director; | gretelai_synthetic_text_to_sql |
CREATE TABLE MentalHealthParityRegulations (State VARCHAR(20), Year INT, Regulation VARCHAR(100)); INSERT INTO MentalHealthParityRegulations (State, Year, Regulation) VALUES ('New York', 2016, 'Regulation 1'), ('New York', 2018, 'Regulation 2'), ('Florida', 2017, 'Regulation A'), ('Florida', 2019, 'Regulation B'); | What is the number of mental health parity regulations implemented in New York and Florida since 2015? | SELECT * FROM MentalHealthParityRegulations WHERE State IN ('New York', 'Florida') AND Year >= 2015; | gretelai_synthetic_text_to_sql |
CREATE TABLE vehicle_stats (id INT, vehicle_make VARCHAR(50), mpg INT, is_domestic BOOLEAN); INSERT INTO vehicle_stats (id, vehicle_make, mpg, is_domestic) VALUES (1, 'Toyota', 32, false), (2, 'Honda', 35, false), (3, 'Ford', 28, true), (4, 'Chevy', 25, true), (5, 'Tesla', null, true); | Calculate the average miles per gallon for domestic vehicles | SELECT AVG(mpg) as avg_mpg FROM vehicle_stats WHERE is_domestic = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE Water_Distribution (project_id INT, project_name VARCHAR(100), total_cost FLOAT); INSERT INTO Water_Distribution (project_id, project_name, total_cost) VALUES (1, 'Water Treatment Plant', 5000000.00), (2, 'Pipe Replacement', 2000000.00), (4, 'Water Main Installation', 4000000.00); | What is the number of projects in the 'Water_Distribution' table that have a total cost greater than $3,000,000.00? | SELECT COUNT(*) FROM Water_Distribution WHERE total_cost > 3000000.00; | gretelai_synthetic_text_to_sql |
CREATE TABLE HealthEquityMetrics (ID INT, CommunityHealthWorker VARCHAR(50), Score INT); INSERT INTO HealthEquityMetrics (ID, CommunityHealthWorker, Score) VALUES (1, 'John Doe', 95), (2, 'Jane Smith', 88); | What is the health equity metric performance for each community health worker? | SELECT CommunityHealthWorker, Score, RANK() OVER (PARTITION BY Score ORDER BY CommunityHealthWorker) as Rank FROM HealthEquityMetrics; | gretelai_synthetic_text_to_sql |
CREATE TABLE Audience (AudienceID INT, AudienceName VARCHAR(50)); CREATE TABLE AudienceAttendance (EventID INT, AudienceID INT); INSERT INTO Audience (AudienceID, AudienceName) VALUES (1, 'Alice'), (2, 'Bob'), (3, 'Charlie'); INSERT INTO AudienceAttendance (EventID, AudienceID) VALUES (1, 1), (1, 2), (2, 1), (2, 3); | How many unique audience members attended events in 2021? | SELECT COUNT(DISTINCT a.AudienceID) as NumUniqueAudienceMembers FROM Audience a INNER JOIN AudienceAttendance aa ON a.AudienceID = aa.AudienceID INNER JOIN Events e ON aa.EventID = e.EventID WHERE e.EventDate >= '2021-01-01' AND e.EventDate < '2022-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteers (id INT PRIMARY KEY, name VARCHAR(255), email VARCHAR(255), hours_per_week FLOAT); | Delete the record for Maria Garcia from the 'volunteers' table | DELETE FROM volunteers WHERE name = 'Maria Garcia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE patients (id INT, name VARCHAR(50), ethnicity VARCHAR(50), mental_health_parity BOOLEAN); INSERT INTO patients (id, name, ethnicity, mental_health_parity) VALUES (1, 'Alice', 'Caucasian', true), (2, 'Brian', 'African American', false); CREATE TABLE interpreter_services (id INT, patient_id INT, interpreter_... | List patients who have used interpreter services but do not have mental health parity. | SELECT patients.name FROM patients WHERE mental_health_parity = false INTERSECT SELECT patients.name FROM patients INNER JOIN interpreter_services ON patients.id = interpreter_services.patient_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE recycling_rates(year INT, state VARCHAR(255), plastic_recycling FLOAT, paper_recycling FLOAT, glass_recycling FLOAT); INSERT INTO recycling_rates VALUES (2020, 'California', 0.6, 0.7, 0.5), (2020, 'Texas', 0.5, 0.6, 0.4); | What is the maximum recycling rate for plastic in 2020 for each state? | SELECT MAX(plastic_recycling) AS max_plastic_recycling, state FROM recycling_rates WHERE year = 2020 GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE vessels (id INT, name TEXT, type TEXT, speed FLOAT, gps_position TEXT); CREATE TABLE gps_positions (id INT, latitude FLOAT, longitude FLOAT, country TEXT, month INT); | What is the average speed of vessels in the Arctic, grouped by month and vessel type? | SELECT v.type, AVG(v.speed), g.month FROM vessels v JOIN gps_positions g ON v.gps_position = g.id WHERE g.country = 'Arctic' GROUP BY v.type, g.month; | gretelai_synthetic_text_to_sql |
CREATE TABLE Spending (id INT, country TEXT, year INT, spending FLOAT); INSERT INTO Spending (id, country, year, spending) VALUES (1, 'Indonesia', 2018, 1000), (2, 'Indonesia', 2019, 1200), (3, 'Indonesia', 2020, 800); | What is the average tourist spending in Indonesia? | SELECT AVG(spending) FROM Spending WHERE country = 'Indonesia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_protected_areas (area_name TEXT, ocean_basin TEXT, depth FLOAT); INSERT INTO marine_protected_areas (area_name, ocean_basin, depth) VALUES ('Galapagos Islands', 'Pacific', 2000.0), ('Great Barrier Reef', 'Pacific', 1000.0), ('Palau National Marine Sanctuary', 'Pacific', 5000.0), ('Northwest Atlantic... | List all marine protected areas in the Atlantic Ocean and their depths. | SELECT area_name, depth FROM marine_protected_areas WHERE ocean_basin = 'Atlantic'; | gretelai_synthetic_text_to_sql |
CREATE TABLE investments_esg (id INT, sector VARCHAR(255), esg_factor VARCHAR(255), investment_amount INT); INSERT INTO investments_esg (id, sector, esg_factor, investment_amount) VALUES (1, 'Energy', 'E', 500000), (2, 'Energy', 'S', 350000), (3, 'Energy', 'G', 450000); | What is the total investment in the Energy sector, broken down by ESG factors? | SELECT sector, esg_factor, SUM(investment_amount) FROM investments_esg WHERE sector = 'Energy' GROUP BY sector, esg_factor; | gretelai_synthetic_text_to_sql |
CREATE TABLE multimodal_mobility (id INT, city VARCHAR(50), mode VARCHAR(50), users INT); | Delete records from the 'multimodal_mobility' table where the 'mode' is 'Bus' | DELETE FROM multimodal_mobility WHERE mode = 'Bus'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Members (ID INT, Gender VARCHAR(10), Age INT, Activity VARCHAR(20)); INSERT INTO Members (ID, Gender, Age, Activity) VALUES (1, 'Male', 35, 'Yoga'); | What's the average age of male members who do yoga? | SELECT AVG(Age) FROM Members WHERE Gender = 'Male' AND Activity = 'Yoga'; | gretelai_synthetic_text_to_sql |
CREATE TABLE games (game_id INT, game_genre VARCHAR(255), num_players INT); | How many games were played in the 'Strategy' genre that have more than 1000 players? | SELECT COUNT(game_id) FROM games WHERE game_genre = 'Strategy' HAVING num_players > 1000; | gretelai_synthetic_text_to_sql |
CREATE TABLE threat_intelligence (report_id INT, report_date DATE, region TEXT); INSERT INTO threat_intelligence (report_id, report_date, region) VALUES (1, '2022-01-01', 'Northeast'), (2, '2022-02-15', 'Midwest'); | Identify the number of threat intelligence reports generated in the last 6 months by region | SELECT region, COUNT(report_id) FROM threat_intelligence WHERE report_date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE stations (station_id INTEGER, name TEXT, latitude REAL, longitude REAL); INSERT INTO stations (station_id, name, latitude, longitude) VALUES (1, 'Downtown', 40.7128, -74.0060); | List all unique station names and their corresponding latitudes and longitudes from the stations table | SELECT DISTINCT name, latitude, longitude FROM stations; | gretelai_synthetic_text_to_sql |
CREATE TABLE dishes (dish_id INT, name VARCHAR(50), fiber INT, serving_size INT); INSERT INTO dishes (dish_id, name, fiber, serving_size) VALUES (1, 'Quinoa Salad', 8, 200), (2, 'Lentil Soup', 12, 300), (3, 'Chickpea Curry', 10, 350); | What is the percentage of dishes that meet the daily recommended intake of fiber? | SELECT 100.0 * COUNT(*) / (SELECT COUNT(*) FROM dishes) AS percentage FROM dishes WHERE fiber >= (SELECT serving_size * 0.5); | gretelai_synthetic_text_to_sql |
CREATE TABLE defense_contracts (contract_id INT, vendor_state VARCHAR(2), contract_value DECIMAL(10,2), contract_date DATE); INSERT INTO defense_contracts VALUES (1, 'CA', 500000.00, '2020-01-05'), (2, 'CA', 600000.00, '2020-01-10'), (3, 'TX', 400000.00, '2020-01-15'); | What is the total value of defense contracts signed by vendors from California in Q1 2020? | SELECT SUM(contract_value) FROM defense_contracts WHERE vendor_state = 'CA' AND contract_date >= '2020-01-01' AND contract_date < '2020-04-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE labor_productivity (id INT, mine_id INT, state TEXT, employees INT, production INT); INSERT INTO labor_productivity (id, mine_id, state, employees, production) VALUES (1, 3, 'Texas', 50, 2000), (2, 3, 'Texas', 50, 2000), (3, 4, 'California', 75, 3000); | What is the average labor productivity per mine by state in the USA? | SELECT state, AVG(production/employees) as avg_productivity FROM labor_productivity GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT, name VARCHAR(50), gender VARCHAR(10), age INT, location VARCHAR(50)); CREATE TABLE posts (id INT, user_id INT, content TEXT, timestamp TIMESTAMP); | What is the total number of posts created by users in 'California' between '2021-01-01' and '2021-03-31'? | SELECT COUNT(posts.id) AS total_posts FROM posts JOIN users ON posts.user_id = users.id WHERE users.location = 'California' AND posts.timestamp BETWEEN '2021-01-01' AND '2021-03-31'; | gretelai_synthetic_text_to_sql |
trends(id, industry, innovation_trend, trend_impact) | Add a new innovation trend for the industry 'technology' in the 'trends' table | INSERT INTO trends (id, industry, innovation_trend, trend_impact) VALUES (4, 'technology', 'AI in healthcare', 0.9); | gretelai_synthetic_text_to_sql |
CREATE TABLE Policy_Advocacy_Events (event_id INT, year INT, type VARCHAR(255)); INSERT INTO Policy_Advocacy_Events VALUES (1, 2021, 'Webinar'); | What is the number of policy advocacy events held in 2021? | SELECT COUNT(*) FROM Policy_Advocacy_Events WHERE year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE payment_methods (id INT, payment_method VARCHAR(50), donation_date DATE, donation_amount FLOAT); INSERT INTO payment_methods (id, payment_method, donation_date, donation_amount) VALUES (1, 'Credit Card', '2023-04-01', 50.0), (2, 'Debit Card', '2023-05-15', 100.0), (3, 'PayPal', '2023-06-30', 200.0); | What was the average donation amount by payment method in Q2 2023? | SELECT payment_method, AVG(donation_amount) FROM payment_methods WHERE donation_date BETWEEN '2023-04-01' AND '2023-06-30' GROUP BY payment_method; | gretelai_synthetic_text_to_sql |
CREATE TABLE OccupationGenderData (Occupation VARCHAR(255), Gender VARCHAR(10), AvgIncome DECIMAL(10,2)); INSERT INTO OccupationGenderData (Occupation, Gender, AvgIncome) VALUES ('Occupation A', 'Male', 50000.00), ('Occupation A', 'Female', 45000.00), ('Occupation B', 'Male', 60000.00), ('Occupation B', 'Female', 55000... | What is the average income by occupation and gender, and how does it compare to the overall average income? | SELECT Occupation, Gender, AvgIncome, AvgIncome * 100.0 / (SELECT OverallAvgIncome FROM OverallData) AS Percentage FROM OccupationGenderData; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotels (id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255)); CREATE TABLE sustainable_practices (id INT PRIMARY KEY, hotel_id INT, practice VARCHAR(255)); INSERT INTO hotels (id, name, country) VALUES (1, 'Eco-Friendly Hotel', 'Sweden'); INSERT INTO hotels (id, name, country) VALUES (2, 'Sustainab... | Create a new view that shows the hotels and their sustainable practices | CREATE VIEW hotel_sustainable_practices AS SELECT hotels.name, sustainable_practices.practice FROM hotels INNER JOIN sustainable_practices ON hotels.id = sustainable_practices.hotel_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE transactions (id INT, tx_hash VARCHAR(50), tx_type VARCHAR(10), block_height INT, tx_time TIMESTAMP); INSERT INTO transactions (id, tx_hash, tx_type, block_height, tx_time) VALUES (1, '0x123...', 'transfer', 1000000, '2021-01-01 00:00:00'), (2, '0x456...', 'deploy', 1000001, '2021-01-02 00:00:00'); | What is the latest transaction time in the 'transactions' table? | SELECT MAX(tx_time) FROM transactions; | gretelai_synthetic_text_to_sql |
CREATE TABLE garment (id INT PRIMARY KEY, garment_name VARCHAR(255), quantity INT, price DECIMAL(5,2)); INSERT INTO garment (id, garment_name, quantity, price) VALUES (1, 'Rayon', 100, 15.00), (2, 'Silk', 0, 0), (3, 'Cotton', 200, 20.00); | Update the price of 'Silk' garments to $25.00 in the garment table. | UPDATE garment SET price = 25.00 WHERE garment_name = 'Silk'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Workers (id INT, industry VARCHAR(20), employment_status VARCHAR(20)); INSERT INTO Workers (id, industry, employment_status) VALUES (1, 'Manufacturing', 'Part-time'), (2, 'Retail', 'Full-time'), (3, 'Manufacturing', 'Full-time'); | How many workers in the 'Retail' industry have a 'Full-time' status? | SELECT COUNT(*) FROM Workers WHERE industry = 'Retail' AND employment_status = 'Full-time'; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT, country VARCHAR(255), created_at TIMESTAMP); | Show the number of new users who signed up from India in the past week and the number of new users who signed up from India in the past month. | SELECT COUNT(*) as last_week, (SELECT COUNT(*) FROM users WHERE country = 'India' AND created_at > NOW() - INTERVAL '1 month') as last_month FROM users WHERE country = 'India' AND created_at > NOW() - INTERVAL '1 week'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Songs (id INT, title VARCHAR(100), artist VARCHAR(100), streams INT); CREATE TABLE Artists (id INT, name VARCHAR(100), country VARCHAR(100)); | What is the maximum number of streams for a song by an artist from Canada? | SELECT MAX(s.streams) FROM Songs s JOIN Artists a ON s.artist = a.name WHERE a.country = 'Canada'; | gretelai_synthetic_text_to_sql |
CREATE TABLE players (id INT PRIMARY KEY, name VARCHAR(50), age INT, country VARCHAR(50)); | Insert a new player, 'Leila Zhang', aged 28 from China | INSERT INTO players (name, age, country) VALUES ('Leila Zhang', 28, 'China'); | gretelai_synthetic_text_to_sql |
CREATE TABLE digital_divide_asia (country VARCHAR(20), population INT, affected INT); INSERT INTO digital_divide_asia (country, population, affected) VALUES ('China', 1439323776, 197243372), ('India', 1380004385, 191680581), ('Indonesia', 273523615, 39032361); | What is the average number of people affected by the digital divide in Asia? | SELECT AVG(affected) FROM digital_divide_asia WHERE country = 'Asia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE mobile_data_usage (customer_id INT, data_usage FLOAT); INSERT INTO mobile_data_usage (customer_id, data_usage) VALUES (1, 3.0), (2, 4.5), (3, 1.9), (4, 3.1); | What is the total number of mobile customers in the telecom company's database who are using exactly 3GB of data per month? | SELECT COUNT(*) FROM mobile_data_usage WHERE data_usage = 3.0; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_name VARCHAR(50), vendor VARCHAR(50)); CREATE TABLE vulnerabilities (product_name VARCHAR(50), published DATE, cvss_score FLOAT); INSERT INTO products (product_name, vendor) VALUES ('Windows 10', 'Microsoft'), ('Office 365', 'Microsoft'), ('iPhone', 'Apple'), ('macOS', 'Apple'); INSERT IN... | Get the number of cybersecurity vulnerabilities for each product in the last year | SELECT products.product_name, COUNT(*) as vulnerability_count FROM products INNER JOIN vulnerabilities ON products.product_name = vulnerabilities.product_name WHERE vulnerabilities.published >= DATE(NOW()) - INTERVAL 1 YEAR GROUP BY products.product_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE therapy (therapy_id INT, patient_id INT, therapist_id INT, therapy_date DATE, city TEXT); INSERT INTO therapy (therapy_id, patient_id, therapist_id, therapy_date, city) VALUES (1, 1, 101, '2018-01-02', 'Paris'); | How many patients started therapy in Paris each quarter of 2021? | SELECT DATE_TRUNC('quarter', therapy_date) as quarter, COUNT(DISTINCT patient_id) as num_patients FROM therapy WHERE city = 'Paris' AND EXTRACT(YEAR FROM therapy_date) = 2021 GROUP BY quarter ORDER BY quarter; | gretelai_synthetic_text_to_sql |
CREATE TABLE snapchat_stories (story_id INT, user_id INT, story_date DATE);CREATE TABLE users (user_id INT, state VARCHAR(50), registration_date DATE);CREATE TABLE state_populations (state VARCHAR(50), population INT); | What is the total number of users who have posted a story on Snapchat in the past week and who are located in a state with a population of over 10 million? | SELECT COUNT(DISTINCT s.user_id) as num_users FROM snapchat_stories s JOIN users u ON s.user_id = u.user_id JOIN state_populations sp ON u.state = sp.state WHERE s.story_date >= DATE(NOW()) - INTERVAL 1 WEEK AND sp.population > 10000000; | gretelai_synthetic_text_to_sql |
CREATE TABLE projects (project_id INT, project_name VARCHAR(50), budget DECIMAL(10, 2), area VARCHAR(50)); INSERT INTO projects (project_id, project_name, budget, area) VALUES (1, 'ProjectQ', 6000000.00, 'Urban'), (2, 'ProjectR', 12000000.00, 'Urban'), (3, 'ProjectS', 18000000.00, 'Urban'); | What is the average budget for public transportation projects in the "projects" table for projects with a budget between $5 million and $15 million? | SELECT AVG(budget) FROM projects WHERE budget BETWEEN 5000000.00 AND 15000000.00; | gretelai_synthetic_text_to_sql |
CREATE TABLE safety_protocols (id INT PRIMARY KEY, chemical_name VARCHAR(255), safety_protocol VARCHAR(255), date_implemented DATE); INSERT INTO safety_protocols (id, chemical_name, safety_protocol, date_implemented) VALUES (1, 'Ammonia', 'Always wear safety goggles when handling', '2022-01-01'); | Update the safety protocol for 'Ammonia' in the "safety_protocols" table | UPDATE safety_protocols SET safety_protocol = 'Always wear safety goggles and gloves when handling' WHERE chemical_name = 'Ammonia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ProductTransparency (product_id INT, recycled_materials BOOLEAN); INSERT INTO ProductTransparency (product_id, recycled_materials) VALUES (1, TRUE), (2, FALSE), (3, TRUE); CREATE TABLE Products (product_id INT, quantity INT); INSERT INTO Products (product_id, quantity) VALUES (1, 10), (2, 20), (3, 30); | Find the total quantity of products made from recycled materials. | SELECT SUM(quantity) FROM Products INNER JOIN ProductTransparency ON Products.product_id = ProductTransparency.product_id WHERE ProductTransparency.recycled_materials = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE genetics_research (id INT, project_name VARCHAR(50), lead_name VARCHAR(50), lead_email VARCHAR(50), location VARCHAR(50)); INSERT INTO genetics_research (id, project_name, lead_name, lead_email, location) VALUES (1, 'Genome Mapping', 'Jose Silva', 'jose.silva@email.com.br', 'Brazil'); INSERT INTO genetics_... | Who is the lead researcher for the genetic research project 'Genome Mapping' in Brazil? | SELECT lead_name FROM genetics_research WHERE project_name = 'Genome Mapping' AND location = 'Brazil'; | gretelai_synthetic_text_to_sql |
CREATE TABLE investment_products (id INT, name VARCHAR(50), asset_class VARCHAR(50)); INSERT INTO investment_products (id, name, asset_class) VALUES (1, 'Stock A', 'Equities'), (2, 'Bond B', 'Fixed Income'), (3, 'Mutual Fund C', 'Equities'), (4, 'ETF D', 'Commodities'); | List all the unique investment products and their associated asset classes. | SELECT DISTINCT name, asset_class FROM investment_products; | gretelai_synthetic_text_to_sql |
CREATE TABLE teacher_pd (teacher_id INT, course_name VARCHAR(50), location VARCHAR(20)); INSERT INTO teacher_pd (teacher_id, course_name, location) VALUES (101, 'Python for Educators', 'New York'), (102, 'Data Science for Teachers', 'Chicago'), (103, 'Open Pedagogy', 'New York'); | List the unique professional development courses attended by teachers in 'New York'? | SELECT DISTINCT course_name FROM teacher_pd WHERE location = 'New York'; | gretelai_synthetic_text_to_sql |
CREATE TABLE solar_farms (id INT, state VARCHAR(20), capacity FLOAT); INSERT INTO solar_farms (id, state, capacity) VALUES (1, 'Arizona', 120.5), (2, 'Nevada', 150.2), (3, 'Arizona', 180.1), (4, 'Oregon', 200.5); | What is the total installed capacity of solar farms in 'Arizona'? | SELECT SUM(capacity) FROM solar_farms WHERE state = 'Arizona'; | gretelai_synthetic_text_to_sql |
CREATE TABLE GreenBuildings (id INT, name VARCHAR(100), location VARCHAR(100), energy_consumption FLOAT); | List the top 5 cities with the highest number of green buildings in the 'GreenBuildings' table. | SELECT location, COUNT(*) as building_count FROM GreenBuildings GROUP BY location ORDER BY building_count DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE deep_sea_trenches (trench_name TEXT, location TEXT, max_depth FLOAT); INSERT INTO deep_sea_trenches (trench_name, location, max_depth) VALUES ('Trench 1', 'Indian Ocean', 7600.0), ('Trench 2', 'Pacific Ocean', 8601.0), ('Trench 3', 'Indian Ocean', 8000.0); | List the names and maximum depths of all deep-sea trenches in the Indian ocean. | SELECT trench_name, max_depth FROM deep_sea_trenches WHERE location = 'Indian Ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE city_environmental_budget (city VARCHAR(255), fiscal_year INT, budget DECIMAL(10,2)); INSERT INTO city_environmental_budget (city, fiscal_year, budget) VALUES ('New York', 2023, 12000000.00), ('Los Angeles', 2023, 10000000.00), ('Chicago', 2023, 15000000.00), ('Houston', 2023, 8000000.00), ('Miami', 2023, ... | Identify the top 3 cities with the highest budget allocated for environmental services, for the fiscal year 2023, and their respective budgets. | SELECT city, budget FROM (SELECT city, budget, ROW_NUMBER() OVER (ORDER BY budget DESC) as rank FROM city_environmental_budget WHERE fiscal_year = 2023 AND service = 'Environmental') as ranked_cities WHERE rank <= 3 | gretelai_synthetic_text_to_sql |
CREATE TABLE labor_costs (project_id INT, labor_cost DECIMAL(10, 2)); | What was the total construction labor cost for a specific project with project_id = 123? | SELECT SUM(labor_cost) FROM labor_costs WHERE project_id = 123; | gretelai_synthetic_text_to_sql |
CREATE TABLE VESSEL_CARGO (ID INT, VESSEL_ID INT, CARGO_TYPE VARCHAR(50), WEIGHT INT); INSERT INTO VESSEL_CARGO VALUES (1, 1, 'Container', 2500); INSERT INTO VESSEL_CARGO VALUES (2, 1, 'Bulk', 50000); INSERT INTO VESSEL_CARGO VALUES (3, 2, 'Container', 3000); | Show the average cargo weight per vessel, ranked in descending order. | SELECT V.NAME, AVG(VC.WEIGHT) AS AVG_WEIGHT, ROW_NUMBER() OVER(ORDER BY AVG(VC.WEIGHT) DESC) AS RANK FROM VESSEL_CARGO VC JOIN VESSELS V ON VC.VESSEL_ID = V.ID GROUP BY V.ID, V.NAME | gretelai_synthetic_text_to_sql |
CREATE TABLE authors (author_id INT, name VARCHAR(255), nationality VARCHAR(100)); | Insert a new record in the 'authors' table | INSERT INTO authors (author_id, name, nationality) VALUES (1, 'Chimamanda Ngozi Adichie', 'Nigerian'); | gretelai_synthetic_text_to_sql |
CREATE TABLE covid_cases (county TEXT, population INT, cases INT); INSERT INTO covid_cases (county, population, cases) VALUES ('County A', 500000, 5000), ('County B', 750000, 8000), ('County C', 600000, 6500), ('County D', 450000, 4000); | What is the number of COVID-19 cases per 100,000 population for each county in the covid_cases table? | SELECT county, (cases * 100000) / population AS cases_per_100k FROM covid_cases; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteers (id INT, region VARCHAR(50), hours INT); INSERT INTO volunteers (id, region, hours) VALUES (1, 'Northeast', 500), (2, 'Southeast', 700), (3, 'Midwest', 600), (4, 'West', 800); | Which regions have the highest volunteer hours? | SELECT region, MAX(hours) as max_hours FROM volunteers GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE startups (id INT, name TEXT, location TEXT, founder_gender TEXT, funding_amount INT); INSERT INTO startups (id, name, location, founder_gender, funding_amount) VALUES (1, 'Startup A', 'USA', 'female', 3000000); INSERT INTO startups (id, name, location, founder_gender, funding_amount) VALUES (2, 'Startup B'... | What is the average funding amount for startups founded by people from historically marginalized gender identities? | SELECT AVG(funding_amount) FROM startups WHERE founder_gender IN ('female', 'non-binary'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT, Gender VARCHAR(20), Department VARCHAR(30), Salary INT); INSERT INTO Employees (EmployeeID, Gender, Department, Salary) VALUES (1, 'Non-binary', 'IT', 60000), (2, 'Transgender', 'HR', 65000), (3, 'Non-binary', 'Finance', 70000), (4, 'Transgender', 'Marketing', 62000); | What is the average salary of non-binary and transgender employees, partitioned by department? | SELECT Department, AVG(CASE WHEN Gender = 'Non-binary' THEN Salary ELSE NULL END) AS Avg_Nonbinary_Salary, AVG(CASE WHEN Gender = 'Transgender' THEN Salary ELSE NULL END) AS Avg_Transgender_Salary FROM Employees GROUP BY Department; | gretelai_synthetic_text_to_sql |
CREATE TABLE songs (song_id INT, genre VARCHAR(20), album VARCHAR(30), artist VARCHAR(30), length FLOAT, release_year INT); CREATE TABLE genres (genre VARCHAR(20)); INSERT INTO genres (genre) VALUES ('pop'), ('rock'), ('jazz'), ('hip-hop'); ALTER TABLE songs ADD CONSTRAINT fk_genre FOREIGN KEY (genre) REFERENCES genres... | What is the average length of songs in the jazz genre released in the 2000s? | SELECT AVG(length) as avg_length FROM songs WHERE genre = (SELECT genre FROM genres WHERE genre = 'jazz') AND release_year BETWEEN 2000 AND 2009; | gretelai_synthetic_text_to_sql |
CREATE TABLE transactions (transaction_id INT, transaction_date DATE, transaction_category VARCHAR(255), transaction_value DECIMAL(10,2)); INSERT INTO transactions (transaction_id, transaction_date, transaction_category, transaction_value) VALUES (1, '2021-03-02', 'Food', 50.00), (2, '2021-03-05', 'Electronics', 300.00... | What is the total transaction value for each hour of the day for the month of March 2021? | SELECT HOUR(transaction_date) as hour_of_day, SUM(transaction_value) as total_value FROM transactions WHERE transaction_date BETWEEN '2021-03-01' AND '2021-03-31' GROUP BY hour_of_day; | gretelai_synthetic_text_to_sql |
CREATE TABLE spacecraft (id INT, name VARCHAR(50), manufacturer VARCHAR(50), launch_year INT);INSERT INTO spacecraft (id, name, manufacturer, launch_year) VALUES (1, 'Dragon', 'SpaceX', 2010), (2, 'Falcon', 'SpaceX', 2006), (3, 'Crew', 'SpaceX', 2020); | Count the number of spacecraft manufactured by SpaceX before 2015 | SELECT COUNT(*) FROM spacecraft WHERE manufacturer = 'SpaceX' AND launch_year < 2015; | gretelai_synthetic_text_to_sql |
CREATE TABLE Road_Projects (project_id int, project_name varchar(255), location varchar(255), cost decimal(10,2)); | Find the top 3 most expensive road projects | SELECT project_id, project_name, location, cost FROM Road_Projects ORDER BY cost DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE news_articles (article_id INT, author_name VARCHAR(50), title VARCHAR(100), published_date DATE); | Find the number of articles published by each author in the 'news_articles' table | SELECT author_name, COUNT(article_id) as article_count FROM news_articles GROUP BY author_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_protected_areas (name VARCHAR(255), location VARCHAR(255), depth FLOAT); INSERT INTO marine_protected_areas (name, location, depth) VALUES ('MPA 1', 'Indian', 150.7); INSERT INTO marine_protected_areas (name, location, depth) VALUES ('MPA 2', 'Atlantic', 200.3); | What is the maximum depth of any marine protected area in the Indian region? | SELECT MAX(depth) FROM marine_protected_areas WHERE location = 'Indian'; | gretelai_synthetic_text_to_sql |
CREATE TABLE posts (id INT, content TEXT, likes INT, created_at TIMESTAMP, user_location VARCHAR(255)); CREATE VIEW user_country AS SELECT user_location, COUNT(DISTINCT id) AS num_users FROM users GROUP BY user_location; | List the top 3 countries with the most user engagement on posts related to "sports" in 2021. | SELECT user_country.user_location, SUM(posts.likes) AS total_likes FROM posts JOIN user_country ON posts.user_location = user_country.user_location WHERE posts.content LIKE '%sports%' AND YEAR(posts.created_at) = 2021 GROUP BY user_country.user_location ORDER BY total_likes DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE offenses (offender_id INT, offense_date DATE, crime VARCHAR(20)); INSERT INTO offenses (offender_id, offense_date, crime) VALUES (1, '2018-01-01', 'Murder'), (1, '2019-01-01', 'Robbery'), (2, '2017-01-01', 'Assault'); | What is the earliest offense date and corresponding crime type for each offender? | SELECT offender_id, MIN(offense_date) OVER (PARTITION BY offender_id) AS min_offense_date, FIRST_VALUE(crime) OVER (PARTITION BY offender_id ORDER BY offense_date) AS first_crime FROM offenses; | gretelai_synthetic_text_to_sql |
CREATE TABLE meetings (id INT, dept VARCHAR(255), meeting_date DATE); INSERT INTO meetings (id, dept, meeting_date) VALUES (1, 'Urban Development', '2022-03-01'), (2, 'Urban Development', '2022-05-15'), (3, 'Transportation', '2022-03-04'); | Report the number of public meetings in the 'Urban Development' department in the first half of 2022, grouped by the week they were held. | SELECT WEEKOFYEAR(meeting_date) AS week, COUNT(*) AS num_meetings FROM meetings WHERE dept = 'Urban Development' AND meeting_date BETWEEN '2022-01-01' AND '2022-06-30' GROUP BY week | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (DonorID int, DonorName varchar(50), Country varchar(50)); INSERT INTO Donors (DonorID, DonorName, Country) VALUES (1, 'John Doe', 'USA'), (2, 'Jane Smith', 'Canada'); CREATE TABLE Donations (DonationID int, DonorID int, DonationAmount decimal(10,2)); INSERT INTO Donations (DonationID, DonorID, Dona... | What is the average donation amount from donors in each country? | SELECT Country, AVG(DonationAmount) FROM Donations JOIN Donors ON Donations.DonorID = Donors.DonorID GROUP BY Country; | gretelai_synthetic_text_to_sql |
CREATE TABLE SmartContracts (ContractID INT, LastUpdate DATETIME); | Delete smart contracts from the 'SmartContracts' table that have not been updated in the past year from the current date. | DELETE FROM SmartContracts WHERE LastUpdate < DATEADD(year, -1, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE timber_production (production_id INT, year INT, volume FLOAT); | List all the timber_production data for a specific year, such as 2020? | SELECT * FROM timber_production WHERE year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE DefenseProjects (ProjectID INT, Contractor VARCHAR(50), Region VARCHAR(50), StartDate DATE, EndDate DATE); INSERT INTO DefenseProjects (ProjectID, Contractor, Region, StartDate, EndDate) VALUES (1, 'Raytheon', 'Asia-Pacific', '2018-04-01', '2019-03-31'), (2, 'Boeing', 'Europe', '2019-01-01', '2020-12-31'),... | How many defense projects did Raytheon undertake in the Asia-Pacific region between 2018 and 2020? | SELECT COUNT(*) FROM DefenseProjects WHERE Contractor = 'Raytheon' AND Region = 'Asia-Pacific' AND StartDate <= '2020-12-31' AND EndDate >= '2018-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE vessel_performance (id INT, vessel_name VARCHAR(50), average_speed DECIMAL(5,2)); | Which vessels in the 'vessel_performance' table have an average speed below 10 knots? | SELECT vessel_name FROM vessel_performance WHERE average_speed < 10; | gretelai_synthetic_text_to_sql |
CREATE TABLE VR_Games (Game_ID INT, Release_Year INT, Game_Category VARCHAR(20)); INSERT INTO VR_Games (Game_ID, Release_Year, Game_Category) VALUES (1, 2022, 'VR'); | How many virtual reality (VR) games have been released in 2022 and 2023 from the 'VR_Games' table? | SELECT COUNT(*) FROM VR_Games WHERE Release_Year IN (2022, 2023) AND Game_Category = 'VR'; | 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.