context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE customers (id INT, segment VARCHAR(20)); CREATE TABLE transactions (id INT, customer_id INT, amount DECIMAL(10,2), transaction_date DATE); INSERT INTO customers (id, segment) VALUES (1, 'Premium'); INSERT INTO transactions (id, customer_id, amount, transaction_date) VALUES (1, 1, 250, '2022-03-15');
Find the average transaction amount for the 'Premium' customer segment in the last month.
SELECT AVG(amount) FROM transactions JOIN customers ON transactions.customer_id = customers.id WHERE customers.segment = 'Premium' AND transaction_date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE Streaming (country VARCHAR(50), genre VARCHAR(50), year INT, streams INT); INSERT INTO Streaming (country, genre, year, streams) VALUES ('Spain', 'Latin', 2021, 1500000); INSERT INTO Streaming (country, genre, year, streams) VALUES ('Spain', 'Latin', 2021, 1600000);
Count the number of streams for Latin songs in Spain during 2021.
SELECT COUNT(streams) FROM Streaming WHERE country = 'Spain' AND genre = 'Latin' AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE gender (gender_id INT, gender TEXT); CREATE TABLE enrollment (enrollment_id INT, gender_id INT, num_students INT); INSERT INTO gender (gender_id, gender) VALUES (1, 'Female'), (2, 'Male'), (3, 'Non-binary'); INSERT INTO enrollment (enrollment_id, gender_id, num_students) VALUES (101, 1, 150), (102, 2, 120)...
What is the maximum number of students enrolled in lifelong learning courses by gender?
SELECT gender, MAX(num_students) FROM enrollment INNER JOIN gender ON enrollment.gender_id = gender.gender_id GROUP BY gender;
gretelai_synthetic_text_to_sql
CREATE TABLE properties (id INT, coowners INT, affordability VARCHAR(20)); INSERT INTO properties (id, coowners, affordability) VALUES (1, 2, 'affordable'), (2, 1, 'unaffordable');
What is the maximum co-ownership in areas with affordable housing?
SELECT MAX(coowners) FROM properties WHERE affordability = 'affordable';
gretelai_synthetic_text_to_sql
CREATE TABLE trips (trip_id INT, user_id INT, trip_date DATE, trip_mode VARCHAR(255)); INSERT INTO trips (trip_id, user_id, trip_date, trip_mode) VALUES (10, 10, '2022-03-01', 'Bus'), (11, 11, '2022-03-02', 'Train'); CREATE TABLE user_demographics (user_id INT, age_group VARCHAR(255)); INSERT INTO user_demographics (us...
What is the total number of public transportation trips taken by seniors in the last month, by mode?
SELECT trip_mode, COUNT(*) AS trips_taken FROM trips JOIN user_demographics ON trips.user_id = user_demographics.user_id WHERE age_group = 'Senior' AND trip_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY trip_mode;
gretelai_synthetic_text_to_sql
CREATE TABLE District (district_id INT, district_name VARCHAR(20)); INSERT INTO District (district_id, district_name) VALUES (1, 'Urban'), (2, 'Rural'); CREATE TABLE EmergencyCalls (call_id INT, district_id INT, response_time INT);
What is the average response time for emergency calls in the 'Urban' district?
SELECT AVG(response_time) FROM EmergencyCalls WHERE district_id = (SELECT district_id FROM District WHERE district_name = 'Urban');
gretelai_synthetic_text_to_sql
CREATE TABLE matches (id INT, game VARCHAR(10), player VARCHAR(50), kills INT, deaths INT, match_date DATE); INSERT INTO matches (id, game, player, kills, deaths, match_date) VALUES (1, 'Fortnite', 'Max', 12, 6, '2022-06-15');
Determine the percentage of 'Fortnite' matches with more than 10 kills per player.
SELECT COUNT(*) * 100.0 / (SELECT COUNT(*) FROM matches WHERE game = 'Fortnite') AS match_percentage FROM matches WHERE game = 'Fortnite' AND kills / NULLIF(deaths, 0) > 10.0;
gretelai_synthetic_text_to_sql
CREATE TABLE farmers (id INT, name VARCHAR(50), location VARCHAR(50), crops VARCHAR(50)); CREATE TABLE crops (id INT, name VARCHAR(50), yield INT); CREATE TABLE sales (id INT, farmer_id INT, crop_name VARCHAR(50), quantity INT, price DECIMAL(5,2)); INSERT INTO farmers VALUES (1, 'Jane Doe', 'Summerfield', 'Tomatoes'); ...
Who is the farmer with the highest yield of tomatoes?
SELECT name FROM farmers INNER JOIN crops ON farmers.crops = crops.name WHERE crops.name = 'Tomatoes' AND crops.yield = (SELECT MAX(yield) FROM crops);
gretelai_synthetic_text_to_sql
CREATE TABLE regions (region_id INT, region_name VARCHAR(50)); INSERT INTO regions (region_id, region_name) VALUES (1, 'North'), (2, 'South'), (3, 'East'), (4, 'West'); CREATE TABLE mobile_subscribers (subscriber_id INT, region_id INT, join_date DATE); INSERT INTO mobile_subscribers (subscriber_id, region_id, join_date...
List the number of mobile and broadband subscribers per region for the most recent quarter.
SELECT r.region_name, COUNT(m.subscriber_id) AS mobile_count, COUNT(b.subscriber_id) AS broadband_count FROM regions r LEFT JOIN mobile_subscribers m ON r.region_id = m.region_id LEFT JOIN broadband_subscribers b ON r.region_id = b.region_id WHERE QUARTER(m.join_date) = QUARTER(CURRENT_DATE()) AND YEAR(m.join_date) = Y...
gretelai_synthetic_text_to_sql
CREATE TABLE climate_change_impacts (id INT, species VARCHAR(50), year INT, impact VARCHAR(50), magnitude INT); INSERT INTO climate_change_impacts (id, species, year, impact, magnitude) VALUES (1, 'Seagrass', 2000, 'Temperature Increase', 20); INSERT INTO climate_change_impacts (id, species, year, impact, magnitude) VA...
What is the average magnitude of climate change impacts on seagrass?
SELECT AVG(magnitude) FROM climate_change_impacts WHERE species = 'Seagrass';
gretelai_synthetic_text_to_sql
CREATE TABLE policy_making (department TEXT, year INT, num_projects INT); INSERT INTO policy_making (department, year, num_projects) VALUES ('Education', 2021, 50), ('Healthcare', 2021, 70), ('Transportation', 2021, 60), ('Justice', 2021, 40);
Who are the top 2 government departments with the highest number of evidence-based policy making projects in 2021?
SELECT department, num_projects, ROW_NUMBER() OVER (ORDER BY num_projects DESC) as rank FROM policy_making WHERE year = 2021 AND rank <= 2;
gretelai_synthetic_text_to_sql
CREATE TABLE cafeterias.menu_items (menu_item_id INT, name TEXT, category TEXT, sustainable_certification BOOLEAN); INSERT INTO cafeterias.menu_items (menu_item_id, name, category, sustainable_certification) VALUES (1, 'Tofu Stir Fry', 'Vegan', true), (2, 'Chicken Sandwich', 'Meat', false);
List the names of restaurants in the 'cafeterias' schema that have a sustainable sourcing certification and serve vegan dishes.
SELECT name FROM cafeterias.menu_items WHERE category LIKE '%Vegan%' AND sustainable_certification = true;
gretelai_synthetic_text_to_sql
CREATE TABLE centers (id INT, name VARCHAR(255), capacity INT);CREATE VIEW center_types AS SELECT c.id, t.type FROM centers c JOIN center_types t ON c.type_id = t.id;
List all disaster relief centers and their corresponding capacities, sorted by capacity.
SELECT ct.name, ct.capacity FROM center_types ct ORDER BY ct.capacity DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE machine_types (machine_type VARCHAR(50), industry VARCHAR(50), production_rate FLOAT); INSERT INTO machine_types (machine_type, industry, production_rate) VALUES ('Automated Guided Vehicle', 'Electronics', 50), ('Selective Soldering Machine', 'Electronics', 120), ('Surface Mount Technology Machine', 'Elect...
Show the machine types and their average production rates in the electronics manufacturing industry.
SELECT machine_type, AVG(production_rate) FROM machine_types WHERE industry = 'Electronics' GROUP BY machine_type;
gretelai_synthetic_text_to_sql
CREATE TABLE extended_cb_agreements (id INT, union_chapter VARCHAR(255), extension_date DATE, extension_duration INT); INSERT INTO extended_cb_agreements (id, union_chapter, extension_date, extension_duration) VALUES (1, 'NYC', '2022-05-01', 9), (2, 'LA', '2022-07-15', 7), (3, 'NYC', '2022-10-01', 12), (4, 'LA', '2022-...
List collective bargaining agreements that have been extended by more than 6 months, ordered by the extension date.
SELECT * FROM extended_cb_agreements WHERE extension_duration > 6 ORDER BY extension_date DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE bridge_materials (material_id INT, bridge_id INT, material VARCHAR(50)); CREATE TABLE materials (material_id INT, material_name VARCHAR(50), quantity INT); CREATE TABLE bridges (bridge_id INT, state VARCHAR(50), construction_year INT);
What are the top 3 materials used in bridge construction in California?
SELECT materials.material_name, SUM(materials.quantity) as total_quantity FROM bridge_materials JOIN materials ON bridge_materials.material_id = materials.material_id JOIN bridges ON bridge_materials.bridge_id = bridges.bridge_id WHERE bridges.state = 'California' GROUP BY materials.material_name ORDER BY total_quantit...
gretelai_synthetic_text_to_sql
CREATE TABLE AstronautMissions (AstronautName TEXT, MissionType TEXT);
Display the number of space missions and their types for astronauts who have flown on at least 3 missions.
SELECT MissionType, COUNT(*) FROM AstronautMissions GROUP BY MissionType HAVING COUNT(*) >= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE cargo_weights (id INT, visit_id INT, weight INT); INSERT INTO cargo_weights (id, visit_id, weight) VALUES (1, 1, 500), (2, 1, 800), (3, 2, 1200), (4, 3, 1000), (5, 4, 1500);
Show total weight of cargo moved in and out of each port.
SELECT ports.name, SUM(cargo_weights.weight) FROM ports INNER JOIN visits ON ports.id = visits.port_id INNER JOIN cargo_weights ON visits.id = cargo_weights.visit_id GROUP BY ports.name;
gretelai_synthetic_text_to_sql
CREATE TABLE Visitors (id INT, name VARCHAR(100), country VARCHAR(50), visit_date DATE); INSERT INTO Visitors (id, name, country, visit_date) VALUES (1, 'Heidi Klum', 'Germany', '2021-06-01'); INSERT INTO Visitors (id, name, country, visit_date) VALUES (2, 'Jurgen Klopp', 'Germany', '2021-07-01');
Update the visit date for all visitors from Germany to '2021-10-01'.
UPDATE Visitors SET visit_date = '2021-10-01' WHERE country = 'Germany';
gretelai_synthetic_text_to_sql
CREATE TABLE Artworks (artwork_id INT, art_type VARCHAR(20), style VARCHAR(20), price DECIMAL(10,2)); INSERT INTO Artworks (artwork_id, art_type, style, price) VALUES (1, 'Painting', 'Impressionist', 1200.00), (2, 'Sculpture', 'Modern', 2500.00), (3, 'Painting', 'Cubist', 3000.00), (4, 'Painting', 'Impressionist', 1800...
What is the maximum price for all 'Cubist' paintings?
SELECT MAX(price) FROM Artworks WHERE art_type = 'Painting' AND style = 'Cubist';
gretelai_synthetic_text_to_sql
CREATE TABLE ai_model (model_id INT, model_name VARCHAR(50), model_type VARCHAR(30), fairness_score DECIMAL(5,4)); INSERT INTO ai_model (model_id, model_name, model_type, fairness_score) VALUES (1, 'ModelA', 'Classification', 0.8765); INSERT INTO ai_model (model_id, model_name, model_type, fairness_score) VALUES (2, 'M...
What are the fairness scores and model names for models with a model type of 'Classification'?
SELECT model_name, fairness_score FROM ai_model WHERE model_type = 'Classification';
gretelai_synthetic_text_to_sql
CREATE TABLE department (id INT, name TEXT);CREATE TABLE faculty (id INT, department_id INT, gender TEXT);
How many female faculty members are in the College of Arts and Sciences?
SELECT COUNT(f.id) FROM faculty f JOIN department d ON f.department_id = d.id WHERE d.name = 'College of Arts and Sciences' AND f.gender = 'female';
gretelai_synthetic_text_to_sql
CREATE TABLE marine_cables (ocean TEXT, length INTEGER); INSERT INTO marine_cables (ocean, length) VALUES ('Pacific Ocean', 100000), ('Atlantic Ocean', 200000), ('Indian Ocean', 150000);
What is the total length of all marine cables in the Pacific Ocean?
SELECT SUM(length) FROM marine_cables WHERE ocean = 'Pacific Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, Age INT, GamePreference VARCHAR(20)); INSERT INTO Players (PlayerID, Age, GamePreference) VALUES (1, 22, 'Strategy');
What is the most popular game genre among players aged 18-24?
SELECT GamePreference, COUNT(*) FROM Players WHERE Age BETWEEN 18 AND 24 GROUP BY GamePreference ORDER BY COUNT(*) DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE HumanitarianAssistance (id INT PRIMARY KEY, operation VARCHAR(100), location VARCHAR(50), year INT, budget INT); INSERT INTO HumanitarianAssistance (id, operation, location, year, budget) VALUES (3, 'Middle East Refugee Aid', 'Syria', 2018, 78901234);
What is the minimum budget for humanitarian assistance operations in the Middle East since 2018?
SELECT MIN(budget) FROM HumanitarianAssistance WHERE location LIKE '%Middle East%' AND year >= 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE Artworks (id INT, artist_id INT, name TEXT, creation_date DATE);
Identify the 5 most recent artworks (creation date) for each artist.
SELECT artist_id, name, creation_date FROM (SELECT artist_id, name, creation_date, ROW_NUMBER() OVER (PARTITION BY artist_id ORDER BY creation_date DESC) as rn FROM Artworks) t WHERE rn <= 5;
gretelai_synthetic_text_to_sql
CREATE TABLE games (id INT, title VARCHAR(50), release_date DATE, rating INT, genre VARCHAR(20), platform VARCHAR(20));
What is the average rating of games released in the past year, grouped by genre and platform?
SELECT g.genre, g.platform, AVG(g.rating) FROM games g WHERE g.release_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY g.genre, g.platform;
gretelai_synthetic_text_to_sql
CREATE TABLE waste_generation (id INT, waste_type VARCHAR(20), year INT, quantity INT);
Delete records in waste_generation table where waste_type is 'Organic' and year is 2020
WITH data_to_delete AS (DELETE FROM waste_generation WHERE waste_type = 'Organic' AND year = 2020 RETURNING *) DELETE FROM waste_generation WHERE id IN (SELECT id FROM data_to_delete);
gretelai_synthetic_text_to_sql
CREATE TABLE manufacturing_equipment (equipment_id INT, equipment_name VARCHAR(50), year_manufactured INT, manufacturer_country VARCHAR(50)); INSERT INTO manufacturing_equipment (equipment_id, equipment_name, year_manufactured, manufacturer_country) VALUES (1, 'CNC Mill', 2018, 'Germany'), (2, 'Injection Molding Machin...
What is the average year of equipment manufacturing for equipment from 'Japan'?
SELECT AVG(year_manufactured) FROM manufacturing_equipment WHERE manufacturer_country = 'Japan';
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (id INT, name VARCHAR(50), type VARCHAR(20), flag VARCHAR(20), length FLOAT);
Insert new records into the 'vessels' table for a new oil tanker named 'Ocean Wave' flying the Liberian flag
INSERT INTO vessels (id, name, type, flag, length) VALUES (1, 'Ocean Wave', 'Oil Tanker', 'Liberia', 300.0);
gretelai_synthetic_text_to_sql
CREATE TABLE rural_hospitals (name TEXT, state TEXT, num_beds INTEGER); INSERT INTO rural_hospitals (name, state, num_beds) VALUES ('Hospital A', 'CA', 50), ('Hospital B', 'CA', 75), ('Hospital C', 'TX', 40), ('Hospital D', 'NY', 60);
What is the average number of beds in rural hospitals in each state?
SELECT state, AVG(num_beds) FROM rural_hospitals GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE ai_papers (paper_id INT, title VARCHAR(100), publication_year INT, author_id INT, author_country VARCHAR(50));
Identify the number of AI research papers published in the last 2 years, along with their authors, focusing on AI ethics and fairness, and group the results by the country of the authors' affiliation.
SELECT author_country, COUNT(*) AS total_papers FROM ai_papers WHERE publication_year >= YEAR(CURRENT_DATE) - 2 AND title LIKE '%AI ethics%' OR title LIKE '%AI fairness%' GROUP BY author_country;
gretelai_synthetic_text_to_sql
CREATE TABLE ports (port_id INT, port_name VARCHAR(50), city VARCHAR(50), country VARCHAR(50)); CREATE TABLE cargo (cargo_id INT, port_id INT, weight FLOAT, handling_date DATE);
Calculate the total cargo weight handled at the port of 'Dakar', Senegal, partitioned by year and month, and show the results for the last 12 months.
SELECT YEAR(c.handling_date) AS handling_year, MONTH(c.handling_date) AS handling_month, SUM(weight) AS total_weight FROM cargo c JOIN ports p ON c.port_id = p.port_id WHERE p.port_name = 'Dakar' AND p.country = 'Senegal' AND c.handling_date >= DATEADD(month, -12, GETDATE()) GROUP BY YEAR(c.handling_date), MONTH(c.hand...
gretelai_synthetic_text_to_sql
CREATE TABLE consumer_feedback(feedback_id INT, product_id INT, feedback VARCHAR(100), feedback_date DATE);
Which cosmetics products received the most negative consumer feedback in the past year?
SELECT product_id, COUNT(*) as negative_feedback_count FROM consumer_feedback WHERE feedback IN ('very dissatisfied', 'dissatisfied') AND feedback_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY product_id ORDER BY negative_feedback_count DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE departments (id INT, name TEXT); CREATE TABLE grants (id INT, department_id INT, amount INT); INSERT INTO departments (id, name) VALUES (1, 'Mathematics'), (2, 'Computer Science'); INSERT INTO grants (id, department_id, amount) VALUES (1, 1, 50000), (2, 1, 75000), (3, 2, 100000), (4, 2, 125000), (5, 2, 15...
What is the distribution of research grant amounts per department?
SELECT g.department_id, AVG(g.amount) as avg_grant_amount, MAX(g.amount) as max_grant_amount, MIN(g.amount) as min_grant_amount, STDDEV(g.amount) as stddev_grant_amount FROM grants g GROUP BY g.department_id;
gretelai_synthetic_text_to_sql
CREATE TABLE arctic_research (id INTEGER, type TEXT);
How many times was each type of research conducted in the 'arctic_research' table?
SELECT type, COUNT(*) FROM arctic_research GROUP BY type;
gretelai_synthetic_text_to_sql
CREATE TABLE Accommodations (ID INT, StudentID INT, Disability VARCHAR(50), Accommodation VARCHAR(50)); INSERT INTO Accommodations (ID, StudentID, Disability, Accommodation) VALUES (1, 1, 'Visual Impairment', 'Braille Materials'); INSERT INTO Accommodations (ID, StudentID, Disability, Accommodation) VALUES (2, 1, 'Visu...
What is the maximum number of accommodations provided for a single student with a disability?
SELECT StudentID, MAX(COUNT(*)) as MaxAccommodations FROM Accommodations GROUP BY StudentID;
gretelai_synthetic_text_to_sql
CREATE TABLE RecyclingRates (year INT, material VARCHAR(20), rate FLOAT); INSERT INTO RecyclingRates (year, material, rate) VALUES (2018, 'plastic', 0.35), (2018, 'paper', 0.65), (2019, 'plastic', 0.40), (2019, 'paper', 0.70), (2020, 'glass', NULL), (2020, 'plastic', 0.45), (2020, 'paper', 0.75);
What was the recycling rate for glass in 2020?
SELECT rate FROM RecyclingRates WHERE year = 2020 AND material = 'glass';
gretelai_synthetic_text_to_sql
CREATE TABLE Publications (publication_id INT, author_id INT, title TEXT); INSERT INTO Publications (publication_id, author_id, title) VALUES (1, 1001, 'Archeology Review'), (2, 1002, 'Unearthed History'), (3, 1001, 'Digging Deeper');
Which authors have published more than one paper?
SELECT author_id FROM Publications GROUP BY author_id HAVING COUNT(*) > 1;
gretelai_synthetic_text_to_sql
CREATE TABLE student (id INT, name VARCHAR(255), department VARCHAR(255), publications INT);CREATE VIEW vw_math_grad AS SELECT * FROM student WHERE department = 'Graduate Program in Mathematics';
What is the maximum number of publications by a single author in the Graduate Program in Mathematics?
SELECT MAX(publications) FROM vw_math_grad;
gretelai_synthetic_text_to_sql
CREATE TABLE funding (funding_id INT, org_id INT, amount INT, funding_type VARCHAR(50)); INSERT INTO funding (funding_id, org_id, amount, funding_type) VALUES (1, 1, 100000, 'government'), (2, 1, 200000, 'private'), (3, 2, 150000, 'private'); CREATE TABLE organizations (org_id INT, name VARCHAR(50), implemented_digital...
What is the total funding received by organizations that have implemented digital divide initiatives, broken down by the type of funding (government or private)?
SELECT implemented_digital_divide_initiatives, funding_type, SUM(amount) FROM funding INNER JOIN organizations ON funding.org_id = organizations.org_id GROUP BY implemented_digital_divide_initiatives, funding_type;
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, Age INT, EsportsExperience BOOLEAN, GamePreference VARCHAR(20)); INSERT INTO Players (PlayerID, Age, EsportsExperience, GamePreference) VALUES (1, 22, TRUE, 'VR'), (2, 19, FALSE, 'FPS'), (3, 25, FALSE, 'Strategy');
List the player IDs and ages of players who have played in both esports events and VR games
SELECT PlayerID, Age FROM Players WHERE EsportsExperience = TRUE AND GamePreference = 'VR';
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (id INT, donor_id INT, ngo_leader VARCHAR(255), category VARCHAR(255), amount DECIMAL(10, 2), donation_date DATE); INSERT INTO Donations (id, donor_id, ngo_leader, category, amount, donation_date) VALUES (1, 1001, 'Female', 'Health', 5000, '2022-03-05'), (2, 1002, 'Male', 'Environment', 3000, '20...
What is the average donation amount per donor for BIPOC-led NGOs in the Health sector for H1 2022?
SELECT ngo_leader, AVG(amount) as avg_donation FROM Donations WHERE donation_date BETWEEN '2022-01-01' AND '2022-06-30' AND ngo_leader LIKE 'BIPOC%' AND category = 'Health' GROUP BY ngo_leader;
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (id INT, name VARCHAR(50), reg_date DATE, community VARCHAR(30)); INSERT INTO volunteers (id, name, reg_date, community) VALUES (1, 'Alex', '2023-02-01', 'LGBTQ+'), (2, 'Bella', '2023-01-15', 'women in tech'), (3, 'Charlie', '2023-03-05', 'indigenous'); INSERT INTO volunteers (id, name, reg_date...
How many volunteers from historically marginalized groups have registered in the last 6 months?
SELECT COUNT(*) FROM volunteers WHERE reg_date >= DATEADD(month, -6, GETDATE()) AND community IN ('LGBTQ+', 'women in tech', 'indigenous', 'people with disabilities');
gretelai_synthetic_text_to_sql
CREATE TABLE Plays (Platform VARCHAR(20), Genre VARCHAR(10), Plays INT); INSERT INTO Plays (Platform, Genre, Plays) VALUES ('Spotify', 'Pop', 15000000), ('AppleMusic', 'Pop', 12000000), ('Youtube', 'Pop', 18000000), ('Pandora', 'Pop', 8000000), ('Deezer', 'Pop', 9000000);
What are the top 3 streaming platforms by total plays for the pop genre in 2021?
SELECT Platform, SUM(Plays) as TotalPlays FROM Plays WHERE Genre = 'Pop' AND YEAR(EventDate) = 2021 GROUP BY Platform ORDER BY TotalPlays DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE streams (song_id INT, stream_date DATE, genre VARCHAR(20), country VARCHAR(20), revenue DECIMAL(10,2)); INSERT INTO streams (song_id, stream_date, genre, country, revenue) VALUES (5, '2021-01-05', 'Jazz', 'France', 7.00), (6, '2021-01-06', 'Jazz', 'France', 7.50);
How many streams of Jazz music were there in France in January 2021?
SELECT COUNT(*) FROM streams WHERE genre = 'Jazz' AND country = 'France' AND stream_date BETWEEN '2021-01-01' AND '2021-01-31';
gretelai_synthetic_text_to_sql
CREATE TABLE ProgramCategories (CategoryID INT, CategoryName TEXT, Budget DECIMAL(10, 2)); INSERT INTO ProgramCategories (CategoryID, CategoryName, Budget) VALUES (1, 'Education', 75000.00), (2, 'Health', 100000.00);
What's the total budget allocated for each program category?
SELECT CategoryName, SUM(Budget) AS TotalBudget FROM ProgramCategories GROUP BY CategoryName;
gretelai_synthetic_text_to_sql
CREATE TABLE life_expectancy (id INT, expectancy INT, location TEXT); INSERT INTO life_expectancy (id, expectancy, location) VALUES (1, 75, 'Rural United States'); INSERT INTO life_expectancy (id, expectancy, location) VALUES (2, 80, 'Urban United States');
What is the average life expectancy in rural areas of the United States?
SELECT AVG(expectancy) FROM life_expectancy WHERE location LIKE 'Rural%';
gretelai_synthetic_text_to_sql
CREATE TABLE VolunteerSignups (VolunteerSignupID INT, VolunteerID INT, SignUpDate DATE); INSERT INTO VolunteerSignups (VolunteerSignupID, VolunteerID, SignUpDate) VALUES (1, 1, '2023-01-05'), (2, 2, '2023-04-10'), (3, 3, '2023-07-20'), (4, 4, '2023-02-25');
How many volunteers signed up in Q1 and Q2 of 2023?
SELECT CONCAT('Q', FLOOR(MONTH(SignUpDate) / 3)) AS Quarter, COUNT(*) as VolunteerCount FROM VolunteerSignups WHERE YEAR(SignUpDate) = 2023 GROUP BY Quarter;
gretelai_synthetic_text_to_sql
CREATE TABLE fantom_dexs (dex_id INT, dex_name VARCHAR(255), network VARCHAR(50)); CREATE TABLE fantom_trading_volumes (volume_id INT, dex_id INT, daily_volume DECIMAL(30,2), daily_volume_time DATE);
Find the top 3 decentralized exchanges (DEXs) with the highest daily trading volumes on the Fantom Opera network in the last month.
SELECT d.dex_name, SUM(ftv.daily_volume) as total_volume FROM fantom_dexs d JOIN fantom_trading_volumes ftv ON d.dex_id = ftv.dex_id WHERE ftv.daily_volume_time >= NOW() - INTERVAL '1 month' AND d.network = 'Fantom Opera' GROUP BY d.dex_name ORDER BY total_volume DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Companies (id INT, name TEXT, industry TEXT, country TEXT, founder_gender TEXT); INSERT INTO Companies (id, name, industry, country, founder_gender) VALUES (1, 'Acme Inc', 'Tech', 'USA', 'Female'); INSERT INTO Companies (id, name, industry, country, founder_gender) VALUES (2, 'Beta Corp', 'Biotech', 'Canad...
Update the industry for a specific company.
UPDATE Companies SET industry = 'Fintech' WHERE name = 'Beta Corp';
gretelai_synthetic_text_to_sql
CREATE TABLE crop_data (id INT, crop_type VARCHAR(255), soil_moisture INT, measurement_date DATE);
Insert new records for a new crop type 'Sunflower' with soil moisture readings.
INSERT INTO crop_data (id, crop_type, soil_moisture, measurement_date) VALUES (5, 'Sunflower', 65, '2021-06-01'); INSERT INTO crop_data (id, crop_type, soil_moisture, measurement_date) VALUES (6, 'Sunflower', 62, '2021-06-02');
gretelai_synthetic_text_to_sql
CREATE TABLE seoul_public_events (event_id INT, city VARCHAR(20), year INT, month INT, events_type VARCHAR(20), events_held INT); INSERT INTO seoul_public_events (event_id, city, year, month, events_type, events_held) VALUES (1, 'Seoul', 2021, 1, 'Festival', 5);
Determine the number of public events and their type held in the city of Seoul in each month of the year 2021
SELECT month, events_type, SUM(events_held) FROM seoul_public_events WHERE city = 'Seoul' AND year = 2021 GROUP BY month, events_type;
gretelai_synthetic_text_to_sql
CREATE TABLE plants (id INT, plant_name VARCHAR(50), state VARCHAR(50), capacity INT); INSERT INTO plants VALUES (1, 'New York Wastewater Treatment Plant', 'New York', 5000000), (2, 'Buffalo Wastewater Treatment Plant', 'New York', 3000000);
List the wastewater treatment plants and their corresponding capacities in the state of New York.
SELECT plant_name, capacity FROM plants WHERE state = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE wastewater_treatment (plant_id INT PRIMARY KEY, location VARCHAR(100), capacity INT);
Add a new water treatment plant to the 'wastewater_treatment' table with the following data: plant_id = 8, location = 'Ho Chi Minh City', capacity = 1000000
INSERT INTO wastewater_treatment (plant_id, location, capacity) VALUES (8, 'Ho Chi Minh City', 1000000);
gretelai_synthetic_text_to_sql
CREATE TABLE farmland (farmland_id INT, country VARCHAR(255), precision_agriculture BOOLEAN); INSERT INTO farmland (farmland_id, country, precision_agriculture) VALUES (1, 'France', TRUE), (2, 'Germany', FALSE), (3, 'China', TRUE), (4, 'Japan', TRUE);
What is the total area of farmland in Europe and Asia utilizing precision agriculture techniques?
SELECT SUM(CASE WHEN farmland.precision_agriculture = TRUE THEN 1 ELSE 0 END) AS precision_agriculture_farmlans, farmland.country FROM farmland GROUP BY farmland.country HAVING farmland.country IN ('Europe', 'Asia');
gretelai_synthetic_text_to_sql
CREATE TABLE state_water_use (state VARCHAR(50), year INT, amount INT); INSERT INTO state_water_use (state, year, amount) VALUES ('California', 2019, 15000), ('Texas', 2019, 13000), ('Florida', 2019, 12000), ('Georgia', 2019, 9000), ('New York', 2019, 8000);
List the top 5 water-consuming states and their respective annual water consumption amounts in 2019?
SELECT s.state, s.amount FROM state_water_use s ORDER BY s.amount DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE consumer_awareness (region_id INT PRIMARY KEY, region_name VARCHAR(100), awareness_score INT);
Which regions have the lowest consumer awareness score?
SELECT region_name, MIN(awareness_score) FROM consumer_awareness GROUP BY region_id ORDER BY MIN(awareness_score) ASC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE whale_sharks (id INT, name VARCHAR(255), location VARCHAR(255), status VARCHAR(255));
How many whale sharks are there in the 'whale_sharks' table?
SELECT COUNT(*) FROM whale_sharks WHERE status = 'alive';
gretelai_synthetic_text_to_sql
CREATE TABLE appointment (appointment_id INT, clinic_id INT, appointment_date DATE, appointment_type VARCHAR(20)); INSERT INTO appointment (appointment_id, clinic_id, appointment_date, appointment_type) VALUES (1, 1, '2022-01-01', 'dental'), (2, 1, '2022-02-01', 'general'), (3, 1, '2022-03-01', 'dental'), (4, 2, '2022-...
How many rural health clinics in the state of Texas have no dental check-ups performed in the year 2022?
SELECT COUNT(*) FROM clinic_detail WHERE clinic_id NOT IN (SELECT clinic_id FROM appointment WHERE appointment_type = 'dental' AND YEAR(appointment_date) = 2022) AND location = 'Texas';
gretelai_synthetic_text_to_sql
CREATE TABLE heritage_sites (id INT, name TEXT, country TEXT); INSERT INTO heritage_sites (id, name, country) VALUES (1, 'Mount Fuji', 'Japan'), (2, 'Himeji Castle', 'Japan');
How many cultural heritage sites are in Japan?
SELECT COUNT(*) FROM heritage_sites WHERE country = 'Japan';
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (id INT, name TEXT, volunteer_id INT, volunteer_date DATE);CREATE TABLE volunteer_hours (id INT, volunteer_id INT, hours DECIMAL(3,1), hour_date DATE);
What is the maximum number of hours volunteered by a single volunteer in a specific month, based on the 'volunteer_hours' and 'volunteers' tables?
SELECT volunteers.name, MAX(volunteer_hours.hours) FROM volunteers INNER JOIN volunteer_hours ON volunteers.id = volunteer_hours.volunteer_id WHERE EXTRACT(MONTH FROM volunteer_hours.hour_date) = 5 GROUP BY volunteers.name;
gretelai_synthetic_text_to_sql
CREATE TABLE incidents_by_sector (id INT, incident_type VARCHAR(255), sector VARCHAR(255), date DATE, is_insider BOOLEAN); INSERT INTO incidents_by_sector (id, incident_type, sector, date, is_insider) VALUES (1, 'Phishing', 'Healthcare', '2021-08-01', true); INSERT INTO incidents_by_sector (id, incident_type, sector, d...
What is the percentage of security incidents caused by insiders in the healthcare sector in the last year?
SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM incidents_by_sector WHERE sector = 'Healthcare' AND date >= DATEADD(year, -1, GETDATE()))) as percentage FROM incidents_by_sector WHERE sector = 'Healthcare' AND date >= DATEADD(year, -1, GETDATE()) AND is_insider = true;
gretelai_synthetic_text_to_sql
CREATE TABLE union_membership (id INT, union VARCHAR(20), member_count INT); INSERT INTO union_membership (id, union, member_count) VALUES (1, 'construction', 3500), (2, 'education', 8000), (3, 'manufacturing', 5000);
What is the name of the union with the least number of members?
SELECT union FROM union_membership WHERE member_count = (SELECT MIN(member_count) FROM union_membership);
gretelai_synthetic_text_to_sql
CREATE TABLE financial_institutions (institution_id INT, institution_name VARCHAR(255), state VARCHAR(255)); INSERT INTO financial_institutions (institution_id, institution_name, state) VALUES (1, 'Institution A', 'New York'), (2, 'Institution B', 'California'); CREATE TABLE shariah_compliant_mortgages (mortgage_id INT...
Find the total amount of Shariah-compliant mortgages issued by each financial institution in the United States, for the year 2020, and order the results by the total amount.
SELECT f.institution_name, SUM(s.mortgage_amount) as total_mortgage_amount FROM shariah_compliant_mortgages s JOIN financial_institutions f ON s.institution_id = f.institution_id WHERE YEAR(mortgage_date) = 2020 GROUP BY f.institution_name ORDER BY total_mortgage_amount DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE consumer_preferences (consumer_id INT, product_type VARCHAR(50)); INSERT INTO consumer_preferences VALUES (1, 'lipstick'), (2, 'lipstick'), (3, 'eyeshadow'), (4, 'lipstick'), (5, 'eyeshadow');
How many consumers prefer lipstick over eyeshadow?
SELECT COUNT(*) FROM consumer_preferences WHERE product_type = 'lipstick';
gretelai_synthetic_text_to_sql
CREATE TABLE waste_generation(city VARCHAR(20), year INT, amount INT); INSERT INTO waste_generation VALUES('Bangkok', 2019, 200000);
What is the total waste generation in the city of Bangkok in 2019?
SELECT amount FROM waste_generation WHERE city = 'Bangkok' AND year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE sustainable_practices (id INT PRIMARY KEY, country VARCHAR(50), practice VARCHAR(100));
Delete records from sustainable tourism practices table with id less than 2
WITH cte AS (DELETE FROM sustainable_practices WHERE id < 2 RETURNING *) SELECT * FROM cte;
gretelai_synthetic_text_to_sql
CREATE TABLE infractions (id INT PRIMARY KEY, dispensary_id INT, infraction_date TIMESTAMP);
Delete all records from the infractions table that occurred more than 3 years ago.
DELETE FROM infractions WHERE infraction_date < NOW() - INTERVAL '3 years';
gretelai_synthetic_text_to_sql
CREATE TABLE WasteGeneration (country VARCHAR(50), population INT, waste_generated_kg FLOAT);
What is the average waste generation rate per capita in the European Union?
SELECT AVG(waste_generated_kg/population) FROM WasteGeneration WHERE country IN ('Germany', 'France', 'Italy', 'Spain', 'United Kingdom');
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, name VARCHAR(50), posts_count INT, followers INT); CREATE TABLE posts (id INT, user_id INT, post_text VARCHAR(255));
What is the average number of followers per post for users in the social_media schema?
SELECT AVG(followers / posts_count) FROM users JOIN posts ON users.id = posts.user_id;
gretelai_synthetic_text_to_sql
CREATE TABLE subway_delays (route_id INT, delay DECIMAL(3,2), date DATE); INSERT INTO subway_delays (route_id, delay, date) VALUES (1, 3.1, '2022-02-01'), (1, 4.2, '2022-02-02'), (2, 2.9, '2022-02-01'), (2, 3.0, '2022-02-02'), (3, 0.0, '2022-02-01'), (3, 0.1, '2022-02-02'); CREATE TABLE subway_routes_ext (id INT, name ...
What is the total number of delays and the maximum delay for each subway line?
SELECT r.name, COUNT(d.route_id) AS total_delays, MAX(d.delay) AS max_delay FROM subway_delays d JOIN subway_routes_ext r ON d.route_id = r.id GROUP BY r.name;
gretelai_synthetic_text_to_sql
CREATE TABLE mine (id INT, name TEXT, location TEXT); INSERT INTO mine (id, name, location) VALUES (1, 'Mine A', 'Country X'), (2, 'Mine B', 'Country Y'); CREATE TABLE environmental_impact (mine_id INT, co2_emission INT); INSERT INTO environmental_impact (mine_id, co2_emission) VALUES (1, 1000), (2, 1500);
What is the total CO2 emission for each mine?
SELECT mine_id, SUM(co2_emission) as total_emission FROM environmental_impact GROUP BY mine_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (id INT, user VARCHAR(255), amount DECIMAL(10, 2)); INSERT INTO Donations (id, user, amount) VALUES (1, 'John', 50.00), (2, 'Jane', 25.00);
What is the minimum donation amount in the Donations table?
SELECT MIN(amount) FROM Donations;
gretelai_synthetic_text_to_sql
CREATE TABLE mental_health_parity (diagnosis VARCHAR(10), incidents INT); INSERT INTO mental_health_parity (diagnosis, incidents) VALUES ('F33', 120), ('F41', 150), ('F60', 80);
What is the total number of mental health parity violation incidents for each diagnosis code?
SELECT diagnosis, SUM(incidents) FROM mental_health_parity GROUP BY diagnosis;
gretelai_synthetic_text_to_sql
CREATE TABLE music_genres (genre VARCHAR(255), revenue FLOAT, marketing_budget FLOAT, release_year INT); INSERT INTO music_genres VALUES ('Afrobeats', 90000, 35000, 2021); CREATE TABLE time_periods (period VARCHAR(255), year INT); INSERT INTO time_periods VALUES ('2018', 2018), ('2019', 2019), ('2020', 2020), ('2021...
Insert a new record for Afrobeats with 2021 revenue and 2021 marketing budget
INSERT INTO music_genres (genre, revenue, marketing_budget, release_year) VALUES ('Afrobeats', 100000, 40000, 2021);
gretelai_synthetic_text_to_sql
CREATE TABLE vaccinations (id INT, patient_id INT, vaccine_type TEXT, date_given DATE); INSERT INTO vaccinations (id, patient_id, vaccine_type, date_given) VALUES (1, 123, 'Influenza', '2019-12-01'); INSERT INTO vaccinations (id, patient_id, vaccine_type, date_given) VALUES (2, 456, 'COVID-19', '2020-03-20'); INSERT IN...
How many unique types of vaccinations were given in New York state in 2020?
SELECT COUNT(DISTINCT vaccine_type) FROM vaccinations WHERE date_given >= '2020-01-01' AND date_given < '2021-01-01' AND state = 'NY';
gretelai_synthetic_text_to_sql
CREATE TABLE collections (collection_name VARCHAR(20), product_type VARCHAR(20), price DECIMAL(5,2)); INSERT INTO collections (collection_name, product_type, price) VALUES ('spring22', 'shirt', 25.99), ('spring22', 'shirt', 30.99), ('spring22', 'pant', 40.00), ('fall21', 'shirt', 20.00), ('fall21', 'shirt', 25.00), ('f...
Which collection has the most products?
SELECT collection_name, COUNT(*) FROM collections GROUP BY collection_name ORDER BY COUNT(*) DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Buildings (id INT, state VARCHAR(2), building_type VARCHAR(10), occupancy_classification VARCHAR(10), resilience_score INT); INSERT INTO Buildings (id, state, building_type, occupancy_classification, resilience_score) VALUES (1, 'NY', 'Office', 'Assembly', 80), (2, 'NY', 'Educational', 'Business', 75), (3,...
What is the average resilience score for public buildings in New York, categorized by building type and occupancy classification?
SELECT building_type, occupancy_classification, AVG(resilience_score) FROM Buildings WHERE state = 'NY' GROUP BY building_type, occupancy_classification;
gretelai_synthetic_text_to_sql
CREATE TABLE india_mines (id INT, mine_name TEXT, location TEXT, num_employees INT, production_rate FLOAT); INSERT INTO india_mines (id, mine_name, location, num_employees, production_rate) VALUES (1, 'Graphite Glory', 'Tamil Nadu, India', 150, 3000.0), (2, 'Carbon Castles', 'Jharkhand, India', 200, 4000.0);
Determine labor productivity metrics for graphite mines in India.
SELECT mine_name, num_employees, production_rate, production_rate/num_employees AS labor_productivity FROM india_mines WHERE mineral = 'Graphite';
gretelai_synthetic_text_to_sql
CREATE TABLE Inventory (inventory_id INT PRIMARY KEY, menu_item VARCHAR(50), inventory_quantity INT, inventory_cost DECIMAL(5,2), inventory_date DATE); CREATE TABLE Menu (menu_item VARCHAR(50) PRIMARY KEY, menu_item_category VARCHAR(50));
What is the total inventory cost for each menu item in the "dessert" category from the past month?
SELECT m.menu_item, SUM(i.inventory_cost * i.inventory_quantity) FROM Inventory i JOIN Menu m ON i.menu_item = m.menu_item WHERE m.menu_item_category = 'dessert' AND i.inventory_date >= DATEADD(month, -1, GETDATE()) GROUP BY m.menu_item;
gretelai_synthetic_text_to_sql
CREATE TABLE broadband_subscribers (subscriber_id INT, subscriber_name VARCHAR(50), monthly_data_usage DECIMAL(10,2)); INSERT INTO broadband_subscribers (subscriber_id, subscriber_name, monthly_data_usage) VALUES (1, 'Ram', 75.50), (2, 'Shyam', 120.75), (3, 'Radha', 110.25);
List all the broadband subscribers who have used more than 100 GB data in a month and their monthly data usage, sorted by the data usage in descending order.
SELECT subscriber_id, subscriber_name, monthly_data_usage FROM broadband_subscribers WHERE monthly_data_usage > 100 ORDER BY monthly_data_usage DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE LandfillCapacity (Region TEXT, Capacity INTEGER); INSERT INTO LandfillCapacity (Region, Capacity) VALUES ('NorthEast', 5000), ('SouthEast', 7000), ('MidWest', 6000), ('SouthWest', 4000), ('NorthWest', 8000), ('Europe', 9000), ('Asia', 10000); CREATE TABLE CircularEconomyInitiatives (Region TEXT, Initiative...
Identify the circular economy initiatives in the regions with the lowest landfill capacity and their respective capacities.
SELECT Region, Initiative, Capacity FROM (SELECT Region, Initiative, Capacity, ROW_NUMBER() OVER (ORDER BY Capacity ASC) as rn FROM CircularEconomyInitiatives ce INNER JOIN LandfillCapacity lc ON ce.Region = lc.Region) t WHERE t.rn <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE menus (menu_id INT, menu_name TEXT, type TEXT, price DECIMAL, quarter DATE); INSERT INTO menus (menu_id, menu_name, type, price, quarter) VALUES (1, 'Quinoa Salad', 'Vegetarian', 12.99, '2022-01-01'), (2, 'Chicken Caesar Wrap', 'Gluten-free', 10.99, '2022-02-15'), (3, 'Vegan Burger', 'Vegan', 14.99, '2022-...
How many vegan menu items were sold in the first quarter of 2022?
SELECT COUNT(*) FROM menus WHERE type = 'Vegan' AND quarter = '2022-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE department (name VARCHAR(255), id INT);CREATE TABLE professor (name VARCHAR(255), gender VARCHAR(255), department_id INT, grant_amount DECIMAL(10,2));
How many male professors are there in the Mathematics department with no research grants?
SELECT COUNT(DISTINCT name) FROM professor WHERE gender = 'Male' AND department_id IN (SELECT id FROM department WHERE name = 'Mathematics') AND grant_amount IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE unions (union_id INT, union_name TEXT, advocacy TEXT, members INT); INSERT INTO unions (union_id, union_name, advocacy, members) VALUES (1001, 'United Steelworkers', 'labor rights', 5000); INSERT INTO unions (union_id, union_name, advocacy, members) VALUES (1002, 'Transport Workers Union', 'collective barg...
What is the average number of members per union advocating for collective bargaining?
SELECT AVG(u.members) FROM unions u WHERE u.advocacy = 'collective bargaining';
gretelai_synthetic_text_to_sql
CREATE TABLE Subscribers (subscriber_id INT, service VARCHAR(20), region VARCHAR(20), revenue FLOAT, payment_date DATE); INSERT INTO Subscribers (subscriber_id, service, region, revenue, payment_date) VALUES (1, 'Broadband', 'Metro', 50.00, '2022-01-01'), (2, 'Mobile', 'Urban', 35.00, NULL), (3, 'Mobile', 'Rural', 20.0...
Delete subscribers who have not made any payments in Q4 of 2021 for the 'Mobile' service.
DELETE FROM Subscribers WHERE service = 'Mobile' AND QUARTER(payment_date) = 4 AND YEAR(payment_date) = 2021 AND payment_date IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE forests (id INT, species VARCHAR(255), year INT, volume FLOAT); INSERT INTO forests (id, species, year, volume) VALUES (1, 'Pine', 2018, 1200.5), (2, 'Oak', 2019, 1500.3), (3, 'Maple', 2020, 2000.7), (4, 'Birch', 2020, 1750.6);
What is the total volume of timber harvested in 2020, grouped by species?
SELECT species, SUM(volume) as total_volume FROM forests WHERE year = 2020 GROUP BY species;
gretelai_synthetic_text_to_sql
CREATE TABLE forests (id INT, name VARCHAR(255)); INSERT INTO forests (id, name) VALUES (1, 'Forest 1'), (2, 'Forest 2'), (3, 'Forest 3'); CREATE TABLE trees (id INT, forest_id INT, age INT); INSERT INTO trees (id, forest_id, age) VALUES (1, 1, 60), (2, 1, 45), (3, 2, 55), (4, 2, 65), (5, 3, 35), (6, 3, 30);
Which forests have more than 100 trees with ages over 50 years?
SELECT f.name FROM forests f JOIN (SELECT forest_id FROM trees WHERE age > 50 GROUP BY forest_id HAVING COUNT(*) > 100) t ON f.id = t.forest_id;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (id INT, name VARCHAR(255), class VARCHAR(255), depth FLOAT); INSERT INTO marine_species (id, name, class, depth) VALUES (1, 'Pacific salmon', 'Actinopterygii', 50.0), (2, 'Blue whale', 'Mammalia', 500.0), (3, 'Sea anemone', 'Anthozoa', 0.01);
What is the maximum depth of all marine species, grouped by class?
SELECT class, MAX(depth) AS max_depth FROM marine_species GROUP BY class;
gretelai_synthetic_text_to_sql
CREATE TABLE Bridges (id INT, name VARCHAR(50), location VARCHAR(50)); INSERT INTO Bridges (id, name, location) VALUES (1, 'Texas Twin Span', 'Texas');
Display the names and locations of all bridges in Texas
SELECT name, location FROM Bridges WHERE state = 'Texas';
gretelai_synthetic_text_to_sql
CREATE TABLE organic_farms (id INT, country VARCHAR(50), region VARCHAR(50), no_farms INT, certified BOOLEAN); INSERT INTO organic_farms (id, country, region, no_farms, certified) VALUES (1, 'Kenya', 'Africa', 1000, TRUE); INSERT INTO organic_farms (id, country, region, no_farms, certified) VALUES (2, 'Tanzania', 'Afri...
How many organic farms are in 'Africa' with a certification?
SELECT SUM(no_farms) FROM organic_farms WHERE region = 'Africa' AND certified = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE Sales (SaleID INT, Game VARCHAR(50), Platform VARCHAR(50), Revenue INT, SalesDate DATE); INSERT INTO Sales (SaleID, Game, Platform, Revenue, SalesDate) VALUES (1, 'Beat Saber', 'Oculus', 50, '2023-02-12'); INSERT INTO Sales (SaleID, Game, Platform, Revenue, SalesDate) VALUES (2, 'Superhot VR', 'HTC Vive', ...
What is the total revenue of VR games in 2023?
SELECT SUM(Revenue) FROM Sales WHERE Platform = 'VR' AND YEAR(SalesDate) = 2023;
gretelai_synthetic_text_to_sql
CREATE TABLE app_creativity (application_name TEXT, creativity_score FLOAT); INSERT INTO app_creativity (application_name, creativity_score) VALUES ('Application1', 0.60), ('Application2', 0.85), ('Application3', 0.77);
What is the minimum creativity score for each AI application in the 'app_creativity' table?
SELECT application_name, MIN(creativity_score) OVER (PARTITION BY application_name) AS min_creativity_score FROM app_creativity;
gretelai_synthetic_text_to_sql
CREATE TABLE community_policing (id INT, event_type VARCHAR(20), location VARCHAR(20), event_date DATE); INSERT INTO community_policing (id, event_type, location, event_date) VALUES (1, 'meeting', 'northside', '2019-07-01');
What was the total number of community policing events held in 'northside' and 'southside' in Q3 of 2019?
SELECT SUM(*) FROM community_policing WHERE location IN ('northside', 'southside') AND event_date BETWEEN '2019-07-01' AND '2019-09-30';
gretelai_synthetic_text_to_sql
CREATE TABLE areas (id INT, name VARCHAR(20)); INSERT INTO areas (id, name) VALUES (1, 'Urban'), (2, 'Rural'); CREATE TABLE budget (item VARCHAR(20), area_id INT, amount INT); INSERT INTO budget (item, area_id, amount) VALUES ('Healthcare', 1, 7000000), ('Healthcare', 2, 4000000);
What is the total budget allocated for healthcare in rural areas?
SELECT SUM(amount) FROM budget WHERE item = 'Healthcare' AND area_id = (SELECT id FROM areas WHERE name = 'Rural');
gretelai_synthetic_text_to_sql
CREATE TABLE community_health_workers (id INT, name VARCHAR(50), region VARCHAR(50), years_of_experience INT);
Identify community health workers with more than 10 years of experience
SELECT community_health_workers.name FROM community_health_workers WHERE community_health_workers.years_of_experience > 10;
gretelai_synthetic_text_to_sql
CREATE TABLE meat (id INT, name VARCHAR(255), qty_sold INT); INSERT INTO meat (id, name, qty_sold) VALUES (1, 'Locally Sourced Chicken', 500), (2, 'Grass Fed Beef', 400), (3, 'Free Range Pork', 300); CREATE TABLE date (id INT, date DATE); INSERT INTO date (id, date) VALUES (1, '2022-03-21'), (2, '2022-03-22'), (3, '202...
What is the total quantity of 'Locally Sourced Chicken' sold this week?
SELECT SUM(qty_sold) AS total_qty_sold FROM meat WHERE name = 'Locally Sourced Chicken' AND date IN (SELECT date FROM date WHERE date BETWEEN DATE_SUB(NOW(), INTERVAL 1 WEEK) AND NOW());
gretelai_synthetic_text_to_sql
CREATE TABLE subscriber_activity (subscriber_id INT, last_activity_date DATE, region VARCHAR(20)); INSERT INTO subscriber_activity (subscriber_id, last_activity_date, region) VALUES (1, '2022-01-01', 'Southwest'), (2, '2022-06-15', 'Southwest'), (3, '2021-12-31', 'Southwest');
Delete subscribers who have not used mobile services in the last 6 months in the Southwest region.
DELETE FROM subscriber_activity WHERE last_activity_date < (CURRENT_DATE - INTERVAL '6 months') AND region = 'Southwest';
gretelai_synthetic_text_to_sql
CREATE TABLE Brokers (BrokerID INT, CommissionRate DECIMAL(5,2)); INSERT INTO Brokers (BrokerID, CommissionRate) VALUES (1, 0.03); CREATE TABLE Claims (ClaimID INT, BrokerID INT, ClaimAmount INT, ClaimDate DATE); INSERT INTO Claims (ClaimID, BrokerID, ClaimAmount, ClaimDate) VALUES (1, 1, 12000, '2021-05-15');
Which brokers have processed claims exceeding $10000 in the last 6 months, and what are their broker IDs, commission rates, and the total claim amount?
SELECT b.BrokerID, b.CommissionRate, SUM(c.ClaimAmount) AS TotalClaimAmount FROM Brokers b INNER JOIN Claims c ON b.BrokerID = c.BrokerID WHERE c.ClaimDate >= DATE_SUB(CURDATE(), INTERVAL 6 MONTH) AND c.ClaimAmount > 10000 GROUP BY b.BrokerID;
gretelai_synthetic_text_to_sql