context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE veteran_unemployment (id INT, claim_date DATE, state VARCHAR(50), claim_status VARCHAR(50)); INSERT INTO veteran_unemployment (id, claim_date, state, claim_status) VALUES (1, '2022-01-05', 'California', 'Filed'), (2, '2022-02-10', 'Texas', 'Rejected');
How many veteran unemployment claims were filed in California in the last month?
SELECT COUNT(*) FROM veteran_unemployment WHERE state = 'California' AND claim_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) AND claim_status = 'Filed';
gretelai_synthetic_text_to_sql
CREATE TABLE regions (id INT, region_name VARCHAR(50)); INSERT INTO regions (id, region_name) VALUES (1, 'Northeast'), (2, 'Southeast'); CREATE TABLE transactions (region_id INT, transaction_count INT); INSERT INTO transactions (region_id, transaction_count) VALUES (1, 20), (1, 30), (2, 10), (2, 40);
How many transactions were made in each region?
SELECT r.region_name, SUM(t.transaction_count) as total_transactions FROM regions r JOIN transactions t ON r.id = t.region_id GROUP BY r.region_name;
gretelai_synthetic_text_to_sql
CREATE TABLE violations (id INT, workplace_id INT, violation_date DATE, num_violations INT); INSERT INTO violations (id, workplace_id, violation_date, num_violations) VALUES (1, 1, '2019-01-01', 5); INSERT INTO violations (id, workplace_id, violation_date, num_violations) VALUES (2, 2, '2019-02-15', 3); INSERT INTO violations (id, workplace_id, violation_date, num_violations) VALUES (3, 3, '2020-01-01', 7);
What is the maximum number of workplace safety violations recorded in a single workplace in the year 2019?
SELECT MAX(num_violations) FROM violations WHERE EXTRACT(YEAR FROM violation_date) = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE pollution_sources (id INT, name VARCHAR(255), region VARCHAR(255));
Add a new record for the pollution_sources table with the name 'Oceanic Plastic Pollution' in the 'Pacific Ocean' region.
INSERT INTO pollution_sources (id, name, region) VALUES ((SELECT COALESCE(MAX(id), 0) + 1 FROM pollution_sources), 'Oceanic Plastic Pollution', 'Pacific Ocean');
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (id INT, city VARCHAR(20), country VARCHAR(20), stars INT); INSERT INTO hotels (id, city, country, stars) VALUES (1, 'Tokyo', 'Japan', 4), (2, 'Tokyo', 'Japan', 5), (3, 'Osaka', 'Japan', 3);
What is the average hotel star rating in Tokyo, Japan?
SELECT AVG(stars) FROM hotels WHERE city = 'Tokyo' AND country = 'Japan';
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers( id INT PRIMARY KEY AUTO_INCREMENT, volunteer_name VARCHAR(255), hours_served INT, volunteer_date DATE) INSERT INTO Volunteers (volunteer_name, hours_served, volunteer_date) VALUES ('Juanita Flores', 12, '2022-01-01') INSERT INTO Volunteers (volunteer_name, hours_served, volunteer_date) VALUES ('Mohammed Ahmed', 15, '2022-02-15') INSERT INTO Volunteers (volunteer_name, hours_served, volunteer_date) VALUES ('Priya Shah', 10, '2022-03-30') INSERT INTO Volunteers (volunteer_name, hours_served, volunteer_date) VALUES ('Samir Singh', 20, '2022-04-10')
List volunteers from March 2022
SELECT * FROM Volunteers WHERE volunteer_date BETWEEN '2022-03-01' AND '2022-03-31'
gretelai_synthetic_text_to_sql
CREATE TABLE Events (id INT, city VARCHAR(20), country VARCHAR(20), date DATE, price DECIMAL(5,2)); INSERT INTO Events (id, city, country, date, price) VALUES (1, 'Los Angeles', 'USA', '2023-01-01', 20.00), (2, 'Los Angeles', 'USA', '2023-03-15', 30.00);
What is the total revenue for events in Los Angeles, CA in the last quarter?
SELECT SUM(price) as total_revenue FROM Events WHERE city = 'Los Angeles' AND country = 'USA' AND date >= DATEADD(quarter, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE stores (store_id INT, store_name VARCHAR(20), state VARCHAR(20)); CREATE TABLE sales (sale_id INT, product_type VARCHAR(20), store_id INT, quantity_sold INT); INSERT INTO stores (store_id, store_name, state) VALUES (1, 'Store1', 'New York'), (2, 'Store2', 'California'), (3, 'Store3', 'Texas'); INSERT INTO sales (sale_id, product_type, store_id, quantity_sold) VALUES (1, 'Dress', 1, 50), (2, 'Trousers', 1, 60), (3, 'Shirts', 2, 40), (4, 'Dress', 2, 30), (5, 'Trousers', 3, 70), (6, 'Shirts', 3, 45), (7, 'Shirts', 1, 55), (8, 'Shirts', 2, 65);
What is the total quantity of 'Shirts' sold by stores in 'New York' and 'California'?
SELECT SUM(quantity_sold) FROM sales JOIN stores ON sales.store_id = stores.store_id WHERE stores.state IN ('New York', 'California') AND product_type = 'Shirts';
gretelai_synthetic_text_to_sql
CREATE TABLE Projects (id INT, project_id INT, project_type VARCHAR(20), economic_diversification_index DECIMAL(5,2)); INSERT INTO Projects (id, project_id, project_type, economic_diversification_index) VALUES (1, 3001, 'Agricultural', 45.67), (2, 3002, 'Infrastructure', 78.34), (3, 3003, 'Agricultural', 56.89);
What was the average economic diversification index for agricultural projects in Mexico?
SELECT AVG(economic_diversification_index) FROM Projects WHERE project_type = 'Agricultural';
gretelai_synthetic_text_to_sql
CREATE TABLE mining_sites (site_id INT, job_title VARCHAR(20), productivity FLOAT);
Delete records of workers from the 'mining_sites' table who have not recorded any productivity metrics.
DELETE FROM mining_sites WHERE productivity IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE accessibility_current (id INT PRIMARY KEY, project VARCHAR(100), organization VARCHAR(100), funding FLOAT, start_date DATE, end_date DATE);INSERT INTO accessibility_current (id, project, organization, funding, start_date, end_date) VALUES (1, 'Accessible AI v3', 'Equal Tech.', 400000, '2022-01-01', '2023-12-31');
Which currently active project in the accessibility domain has the lowest funding amount?
SELECT project FROM accessibility_current WHERE start_date <= CURDATE() AND end_date >= CURDATE() ORDER BY funding LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE HealthEquityMetrics (WorkerID INT, Race VARCHAR(255), MetricScore INT); INSERT INTO HealthEquityMetrics (WorkerID, Race, MetricScore) VALUES (1, 'Hispanic', 80), (2, 'African American', 85), (3, 'Caucasian', 90), (4, 'Asian', 95);
What is the health equity metric for each community health worker by race?
SELECT Race, AVG(MetricScore) as AvgMetricScore FROM HealthEquityMetrics GROUP BY Race;
gretelai_synthetic_text_to_sql
CREATE TABLE artists (id INT, name VARCHAR(100), genre VARCHAR(20), gender VARCHAR(6)); CREATE TABLE songs (id INT, artist_id INT, title VARCHAR(100), year INT, user_id INT); INSERT INTO artists (id, name, genre, gender) VALUES (1, 'ArtistA', 'Pop', 'Female'); INSERT INTO artists (id, name, genre, gender) VALUES (2, 'ArtistB', 'Pop', 'Female'); INSERT INTO songs (id, artist_id, title, year, user_id) VALUES (1, 1, 'SongA', 2020, 1); INSERT INTO songs (id, artist_id, title, year, user_id) VALUES (2, 1, 'SongB', 2021, 2); INSERT INTO songs (id, artist_id, title, year, user_id) VALUES (3, 2, 'SongC', 2020, 3); INSERT INTO songs (id, artist_id, title, year, user_id) VALUES (4, 2, 'SongD', 2021, 4);
Show the total number of users who listened to music from female artists in the Pop genre in 2020 and 2021, along with the artists' names.
SELECT artist_id, gender, genre, COUNT(DISTINCT user_id) FROM songs INNER JOIN artists ON artists.id = songs.artist_id WHERE genre = 'Pop' AND gender = 'Female' AND year BETWEEN 2020 AND 2021 GROUP BY artist_id;
gretelai_synthetic_text_to_sql
CREATE TABLE sales_summary (id INT, product VARCHAR(255), sales_amount DECIMAL(10, 2)); INSERT INTO sales_summary (id, product, sales_amount) VALUES (1, 'Lotion', 500.00), (2, 'Shampoo', 400.00), (3, 'Conditioner', 350.00), (4, 'Body Wash', 300.00), (5, 'Deodorant', 250.00), (6, 'Sunscreen', 200.00), (7, 'Hand Cream', 150.00), (8, 'Lip Balm', 100.00), (9, 'Toothpaste', 50.00), (10, 'Soap', 25.00);
Calculate the percentage of sales from the top 5 selling products.
SELECT ROUND(SUM(sales_amount) FILTER (WHERE id <= 5) * 100.0 / SUM(sales_amount), 2) AS top_5_percentage FROM sales_summary;
gretelai_synthetic_text_to_sql
CREATE TABLE refugee_camps (id INT, camp_name TEXT, location TEXT, population INT, food_aid_tons FLOAT);
What is the maximum number of people served by a single 'refugee_camp'?
SELECT MAX(population) FROM refugee_camps;
gretelai_synthetic_text_to_sql
CREATE TABLE Warehouse (id INT, location VARCHAR(255), capacity INT); INSERT INTO Warehouse (id, location, capacity) VALUES (1, 'New York', 500), (2, 'Toronto', 700), (3, 'Montreal', 600); CREATE TABLE Shipment (id INT, warehouse_id INT, delivery_time INT); INSERT INTO Shipment (id, warehouse_id, delivery_time) VALUES (1, 1, 5), (2, 2, 3), (3, 3, 4), (4, 1, 6), (5, 2, 7), (6, 3, 8);
Find the number of shipments and total delivery time for each warehouse?
SELECT warehouse_id, COUNT(*) as num_shipments, SUM(delivery_time) as total_delivery_time FROM Shipment GROUP BY warehouse_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Astronauts (AstronautID INT, Name VARCHAR(50), Manufacturer VARCHAR(50), Mission VARCHAR(50));
List all astronauts who have flown on missions with spacecraft manufactured by Roscosmos and their missions.
SELECT Name, Mission FROM Astronauts WHERE Manufacturer = 'Roscosmos';
gretelai_synthetic_text_to_sql
CREATE TABLE Bridges (BridgeID INT, Name TEXT, Age INT, State TEXT); INSERT INTO Bridges (BridgeID, Name, Age, State) VALUES (1, 'Bridge1', 25, 'California'); INSERT INTO Bridges (BridgeID, Name, Age, State) VALUES (2, 'Bridge2', 30, 'California');
What is the average age of bridges in the state of California?
SELECT AVG(Age) FROM Bridges WHERE State = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE health_equity_metrics (metric_id INT, metric_name TEXT, city TEXT, community TEXT); INSERT INTO health_equity_metrics (metric_id, metric_name, city, community) VALUES (1, 'Life Expectancy', 'Seattle', 'Asian'), (2, 'Infant Mortality', 'Seattle', 'Hispanic'), (3, 'Access to Care', 'New York', 'African American');
List the health equity metrics that were measured in Seattle for the Asian community.
SELECT metric_name FROM health_equity_metrics WHERE city = 'Seattle' AND community = 'Asian';
gretelai_synthetic_text_to_sql
CREATE TABLE healthcare_budget (budget_id INT, budget_year INT, budget_state TEXT, budget_amount FLOAT); INSERT INTO healthcare_budget (budget_id, budget_year, budget_state, budget_amount) VALUES (1, 2022, 'California', 12000000), (2, 2021, 'California', 11000000), (3, 2022, 'Texas', 15000000);
What is the total budget allocated for healthcare in the state of California in the year 2022?
SELECT SUM(budget_amount) FROM healthcare_budget WHERE budget_year = 2022 AND budget_state = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE PacificSpecies (species_name TEXT, conservation_status TEXT); INSERT INTO PacificSpecies (species_name, conservation_status) VALUES ('Great White Shark', 'Vulnerable'), ('Sea Otter', 'Endangered'); CREATE TABLE MarineSpecies (species_name TEXT, habitat TEXT); INSERT INTO MarineSpecies (species_name, habitat) VALUES ('Blue Whale', 'Pacific Ocean'), ('Dolphin', 'Pacific Ocean');
What are the conservation statuses of marine species in the Pacific Ocean?
SELECT MarineSpecies.species_name, PacificSpecies.conservation_status FROM MarineSpecies INNER JOIN PacificSpecies ON MarineSpecies.species_name = PacificSpecies.species_name;
gretelai_synthetic_text_to_sql
CREATE TABLE eu_humanitarian_assistance (donor VARCHAR(255), recipient VARCHAR(255), cost DECIMAL(10, 2), assistance_date DATE);
What is the total cost of humanitarian assistance provided by the EU to South American countries since 2016?
SELECT SUM(cost) FROM eu_humanitarian_assistance WHERE donor = 'EU' AND recipient LIKE 'South America%' AND assistance_date >= '2016-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE aircraft (aircraft_id INT, name VARCHAR(100), manufacturer VARCHAR(100), first_flight DATE); INSERT INTO aircraft (aircraft_id, name, manufacturer, first_flight) VALUES (1, 'Boeing 707', 'Boeing', '1957-12-20'), (2, 'Boeing 727', 'Boeing', '1963-02-09');
List all aircraft manufactured by Boeing.
SELECT name FROM aircraft WHERE manufacturer = 'Boeing';
gretelai_synthetic_text_to_sql
CREATE TABLE stories (id INT, title VARCHAR(50), publication_date DATE, journalist_id INT); INSERT INTO stories (id, title, publication_date, journalist_id) VALUES (1, 'The Big Heist', '2021-01-01', 1), (2, 'Mystery of the Lost Art', '2021-02-01', 2), (3, 'The Unsolved Case', '2021-03-01', 3), (4, 'The Secret Files', '2021-01-01', 1); CREATE TABLE journalists (id INT, name VARCHAR(50), city VARCHAR(50)); INSERT INTO journalists (id, name, city) VALUES (1, 'Dana', 'New York'), (2, 'Eliot', 'Los Angeles'), (3, 'Fiona', 'Chicago');
What is the total number of news stories published per city in the "stories" and "journalists" tables?
SELECT city, COUNT(DISTINCT stories.id) AS total_stories FROM stories INNER JOIN journalists ON stories.journalist_id = journalists.id GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE vr_sales (id INT, product VARCHAR(100), quantity INT, sale_date DATE, region VARCHAR(100)); INSERT INTO vr_sales (id, product, quantity, sale_date, region) VALUES (1, 'Oculus Quest 2', 100, '2022-04-01', 'North America'), (2, 'HTC Vive Pro 2', 50, '2022-05-01', 'Europe'), (3, 'Valve Index', 75, '2022-06-01', 'Asia');
How many VR headsets were sold in each region for the last quarter?
SELECT region, SUM(quantity) as total_sold FROM vr_sales WHERE sale_date >= (CURRENT_DATE - INTERVAL '3 months') GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE departments (name VARCHAR(255), open_data_portal BOOLEAN);
Show the number of open data portals for each department.
SELECT name, COUNT(*) FROM departments WHERE open_data_portal = TRUE GROUP BY name;
gretelai_synthetic_text_to_sql
CREATE VIEW animal_population AS SELECT 'Penguin' AS species, COUNT(*) AS num_animals FROM penguins WHERE age < 5 UNION ALL SELECT 'Turtle' AS species, COUNT(*) AS num_animals FROM turtles WHERE age < 5;
What is the total population of animals in the "animal_population" view that are younger than 5?
SELECT SUM(num_animals) FROM animal_population;
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (volunteer_id INT, volunteer_name TEXT, program TEXT, country TEXT); INSERT INTO volunteers VALUES (1, 'Alex Johnson', 'Education', 'Australia'), (2, 'Emily Brown', 'Healthcare', 'Australia'), (3, 'Oliver Smith', 'Education', 'Australia');
What is the total number of volunteers for education programs in Australia?
SELECT COUNT(*) FROM volunteers WHERE program = 'Education' AND country = 'Australia';
gretelai_synthetic_text_to_sql
CREATE TABLE Barcelona_Neighborhoods (Neighborhood_Name TEXT, Green_Space BOOLEAN); INSERT INTO Barcelona_Neighborhoods (Neighborhood_Name, Green_Space) VALUES ('Eixample', false), ('Gracia', true), ('Born', false), ('Raval', false), ('Sants-Montjuic', true); CREATE TABLE Barcelona_Properties (Neighborhood_Name TEXT, Property_Price INTEGER); INSERT INTO Barcelona_Properties (Neighborhood_Name, Property_Price) VALUES ('Eixample', 800000), ('Gracia', 900000), ('Born', 700000), ('Raval', 600000), ('Sants-Montjuic', 750000);
What is the total property value in neighborhoods with green spaces in Barcelona?
SELECT SUM(Barcelona_Properties.Property_Price) FROM Barcelona_Properties INNER JOIN Barcelona_Neighborhoods ON Barcelona_Properties.Neighborhood_Name = Barcelona_Neighborhoods.Neighborhood_Name WHERE Barcelona_Neighborhoods.Green_Space = true;
gretelai_synthetic_text_to_sql
CREATE TABLE field_1 (date DATE, temperature FLOAT); INSERT INTO field_1 (date, temperature) VALUES ('2022-01-01', 15.0), ('2022-01-02', 14.5); CREATE TABLE field_2 (date DATE, temperature FLOAT); INSERT INTO field_2 (date, temperature) VALUES ('2022-01-01', 16.0), ('2022-01-02', 18.0);
Which fields have recorded a temperature lower than 13.5 degrees Celsius?
SELECT 'field_1' AS field_name FROM field_1 WHERE temperature < 13.5 UNION SELECT 'field_2' AS field_name FROM field_2 WHERE temperature < 13.5;
gretelai_synthetic_text_to_sql
CREATE TABLE MusicEvents (eventID INT, visitorID INT, eventDate DATE); INSERT INTO MusicEvents (eventID, visitorID, eventDate) VALUES (1, 1, '2021-01-01'), (2, 2, '2021-02-10'), (3, 1, '2021-03-20');
How many unique visitors attended music events in the first quarter of 2021?
SELECT COUNT(DISTINCT visitorID) FROM MusicEvents WHERE eventDate >= '2021-01-01' AND eventDate < '2021-04-01';
gretelai_synthetic_text_to_sql
CREATE TABLE clinical_trials (id INT, company VARCHAR(255), department VARCHAR(255), trial_status VARCHAR(255), fda_approval_date DATE, company_location VARCHAR(255)); INSERT INTO clinical_trials (id, company, department, trial_status, fda_approval_date, company_location) VALUES (1, 'Asian BioTech 1', 'Oncology', 'Successful', NULL, 'Japan'), (2, 'Asian BioTech 2', 'Oncology', 'Failed', '2018-04-02', 'China'), (3, 'Asian BioTech 3', 'Neurology', 'Successful', '2019-09-10', 'South Korea');
Identify the number of clinical trials conducted by Asian biotech companies in the oncology department that were successful but not yet approved by the FDA between 2017 and 2020, excluding trials from South Korea.
SELECT COUNT(*) FROM clinical_trials WHERE department = 'Oncology' AND trial_status = 'Successful' AND fda_approval_date IS NULL AND company_location NOT IN ('South Korea') AND fda_approval_date BETWEEN '2017-01-01' AND '2020-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_subscribers (subscriber_id INT, technology VARCHAR(20)); CREATE TABLE broadband_subscribers (subscriber_id INT, technology VARCHAR(20)); INSERT INTO mobile_subscribers (subscriber_id, technology) VALUES (1, '4G'), (2, '5G'), (3, '3G'); INSERT INTO broadband_subscribers (subscriber_id, technology) VALUES (4, 'Fiber'), (5, 'Cable'), (6, 'DSL');
What is the total number of mobile and broadband subscribers for each technology type?
SELECT 'Mobile' as source, technology, COUNT(*) as total FROM mobile_subscribers GROUP BY technology UNION ALL SELECT 'Broadband' as source, technology, COUNT(*) as total FROM broadband_subscribers GROUP BY technology;
gretelai_synthetic_text_to_sql
CREATE TABLE workouts (id INT, member_id INT, workout_type VARCHAR(20), workout_date DATE, member_age INT);
List the total number of workouts and unique members who participated in Pilates classes, broken down by age group (18-24, 25-34, 35-44, 45-54, 55+).
SELECT CASE WHEN member_age BETWEEN 18 AND 24 THEN '18-24' WHEN member_age BETWEEN 25 AND 34 THEN '25-34' WHEN member_age BETWEEN 35 AND 44 THEN '35-44' WHEN member_age BETWEEN 45 AND 54 THEN '45-54' ELSE '55+' END as age_group, COUNT(DISTINCT member_id) as total_members, COUNT(*) as total_workouts FROM workouts WHERE workout_type = 'Pilates' GROUP BY age_group;
gretelai_synthetic_text_to_sql
CREATE TABLE Suppliers (supplier_id INT, supplier_name VARCHAR(50), location VARCHAR(50), vegan BOOLEAN); INSERT INTO Suppliers (supplier_id, supplier_name, location, vegan) VALUES (1, 'Farm Fresh', 'EcoVillage', false), (2, 'GreenGrocer', 'EcoVillage', true), (3, 'Harvest House', 'EcoVillage', false);
List all suppliers from 'EcoVillage' who do not provide vegan ingredients.
SELECT supplier_name FROM Suppliers WHERE location = 'EcoVillage' AND vegan = false
gretelai_synthetic_text_to_sql
CREATE TABLE lifespan (country TEXT, lifespan INT); INSERT INTO lifespan (country, lifespan) VALUES ('France', 82), ('Germany', 81), ('Italy', 83);
What is the average lifespan for each country in the European Union?
SELECT country, AVG(lifespan) AS avg_lifespan FROM lifespan GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE trainings (training_id INT, quarter INT, training_type VARCHAR(50), trainings_conducted INT); INSERT INTO trainings (training_id, quarter, training_type, trainings_conducted) VALUES (1, 1, 'Cultural Competency', 10), (2, 2, 'Cultural Competency', 15), (3, 3, 'Cultural Competency', 12), (4, 4, 'Cultural Competency', 8), (5, 1, 'Health Equity', 7), (6, 2, 'Health Equity', 9), (7, 3, 'Health Equity', 11), (8, 4, 'Health Equity', 14);
What is the total number of cultural competency trainings conducted in each quarter?
SELECT training_type, quarter, SUM(trainings_conducted) as total_trainings_conducted FROM trainings GROUP BY training_type, quarter;
gretelai_synthetic_text_to_sql
CREATE TABLE SpaceMissions (mission_id INT, year INT, success BOOLEAN); INSERT INTO SpaceMissions (mission_id, year, success) VALUES (1, 2020, true), (2, 2020, false), (3, 2019, true), (4, 2021, true), (5, 2018, false), (6, 2020, true);
List all space missions that were successful in 2020.
SELECT mission_id FROM SpaceMissions WHERE year = 2020 AND success = true;
gretelai_synthetic_text_to_sql
CREATE TABLE concerts (id INT, type VARCHAR(10), price DECIMAL(5,2), tickets_sold INT); INSERT INTO concerts (id, type, price, tickets_sold) VALUES (1, 'classical', 50.00, 100), (2, 'pop', 30.00, 200), (3, 'classical', 60.00, 150);
What is the total revenue for classical concerts?
SELECT SUM(price * tickets_sold) FROM concerts WHERE type = 'classical';
gretelai_synthetic_text_to_sql
CREATE TABLE Policyholders (PolicyholderID INT, City VARCHAR(20), IssueDate DATE); INSERT INTO Policyholders (PolicyholderID, City, IssueDate) VALUES (1, 'Miami', '2022-01-15'), (2, 'Miami', '2022-02-20'), (3, 'Miami', '2022-03-25');
How many policies were issued per month in 'Miami' for the year 2022?
SELECT DATE_FORMAT(IssueDate, '%Y-%m') AS Month, COUNT(*) as NumberOfPolicies FROM Policyholders WHERE City = 'Miami' AND YEAR(IssueDate) = 2022 GROUP BY Month;
gretelai_synthetic_text_to_sql
CREATE TABLE agricultural_farms (id INT, name VARCHAR(30), num_employees INT, region VARCHAR(20));
What is the average number of employees in the 'agricultural_farms' table per region?
SELECT region, AVG(num_employees) FROM agricultural_farms GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE dams (id INT, name TEXT, country TEXT, build_year INT); INSERT INTO dams (id, name, country, build_year) VALUES (1, 'CN-AB Hydro Dam', 'CA', 1965); INSERT INTO dams (id, name, country, build_year) VALUES (2, 'US-OR Columbia River Dam', 'US', 1968);
How many dams in total were constructed in Canada and the USA before 1970?
SELECT COUNT(*) FROM dams WHERE (country = 'CA' OR country = 'US') AND build_year < 1970;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, Department VARCHAR(20), Age INT); INSERT INTO Employees (EmployeeID, Department, Age) VALUES (1, 'IT', 30), (2, 'IT', 35), (3, 'HR', 40), (4, 'Sales', 45), (5, 'Sales', 50);
Find the average age of employees in each department.
SELECT Department, AVG(Age) FROM Employees GROUP BY Department;
gretelai_synthetic_text_to_sql
CREATE TABLE exoplanets (exoplanet_id INT, exoplanet_name VARCHAR(100), mission_name VARCHAR(100), discovery_date DATE);
What are the names and discovery dates of exoplanets discovered by the Kepler mission?
SELECT exoplanet_name, discovery_date FROM exoplanets WHERE mission_name = 'Kepler';
gretelai_synthetic_text_to_sql
CREATE TABLE ticket_sales (id INT PRIMARY KEY, event_id INT, sport VARCHAR(50), tickets_sold INT, price DECIMAL(5,2)); CREATE TABLE events (id INT PRIMARY KEY, name VARCHAR(100), date DATE, location VARCHAR(100));
What is the average ticket price for each sport in the 'ticket_sales' table?
SELECT t.sport, AVG(t.price) as avg_price FROM ticket_sales t JOIN events e ON t.event_id = e.id GROUP BY t.sport;
gretelai_synthetic_text_to_sql
CREATE TABLE fields (id INT, field_name VARCHAR(255), area FLOAT, soil_type VARCHAR(255)); INSERT INTO fields (id, field_name, area, soil_type) VALUES (1, 'field1', 10.5, 'loamy'), (2, 'field2', 12.3, 'sandy'), (3, 'field3', 8.9, 'loamy');
What is the average area of fields?
SELECT AVG(area) FROM fields;
gretelai_synthetic_text_to_sql
CREATE TABLE cases (case_id INT, category VARCHAR(50), billing_amount INT); INSERT INTO cases (case_id, category, billing_amount) VALUES (1, 'Personal Injury', 5000), (2, 'Civil Litigation', 7000);
Count the number of cases in the 'Civil Litigation' category
SELECT COUNT(*) FROM cases WHERE category = 'Civil Litigation';
gretelai_synthetic_text_to_sql
CREATE TABLE vessel_performance (vessel_id INT, speed FLOAT, timestamp TIMESTAMP);
What is the average speed of all vessels in the 'vessel_performance' table?
SELECT AVG(speed) FROM vessel_performance;
gretelai_synthetic_text_to_sql
CREATE TABLE athletes(athlete_id INT, name VARCHAR(50), age INT, sport VARCHAR(20));
Calculate the average age difference between athletes in basketball and football.
SELECT AVG(basketball_age - football_age) AS avg_age_difference FROM (SELECT AVG(age) AS basketball_age FROM athletes WHERE sport = 'basketball') AS basketball, (SELECT AVG(age) AS football_age FROM athletes WHERE sport = 'football') AS football;
gretelai_synthetic_text_to_sql
CREATE TABLE emergency_calls(id INT, location VARCHAR(20), month_year DATE, emergency_type VARCHAR(20));
Insert new emergency calls in 'Seattle' for October 2021
INSERT INTO emergency_calls(id, location, month_year, emergency_type) VALUES (1, 'Seattle', '2021-10-01', 'medical'), (2, 'Seattle', '2021-10-02', 'fire'), (3, 'Seattle', '2021-10-03', 'police');
gretelai_synthetic_text_to_sql
CREATE TABLE circular_economy (country VARCHAR(50), year INT, initiative VARCHAR(100)); INSERT INTO circular_economy (country, year, initiative) VALUES ('South Africa', 2017, 'Waste-to-Energy Project'), ('South Africa', 2018, 'Recycling Plant Expansion'), ('South Africa', 2019, 'Composting Program'), ('South Africa', 2020, 'Product Reuse Program'), ('South Africa', 2021, 'Sustainable Packaging Initiative');
Circular economy initiatives in South Africa since 2017.
SELECT * FROM circular_economy WHERE country = 'South Africa' ORDER BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE ticket_sales (sale_date DATE, quantity INT, price DECIMAL(10,2));
What is the total number of tickets sold for each day of the week?
SELECT DATE_FORMAT(sale_date, '%W') as day_of_week, SUM(quantity * price) as total_revenue FROM ticket_sales GROUP BY day_of_week;
gretelai_synthetic_text_to_sql
CREATE TABLE TraditionalArtEvents (ID INT, Art VARCHAR(50), Country VARCHAR(50), YearAdded INT, Events INT); INSERT INTO TraditionalArtEvents (ID, Art, Country, YearAdded, Events) VALUES (1, 'Kathak', 'India', 2021, 20); INSERT INTO TraditionalArtEvents (ID, Art, Country, YearAdded, Events) VALUES (2, 'Hula', 'Hawaii', 2022, 15);
How many traditional art events have been added in each country in the past two years?
SELECT Country, YearAdded, COUNT(*) OVER (PARTITION BY Country, YearAdded - YearAdded % 2 ORDER BY YearAdded) AS EventsAddedInPeriod FROM TraditionalArtEvents;
gretelai_synthetic_text_to_sql
CREATE TABLE faculty (faculty_id INT, name VARCHAR(50), department VARCHAR(50)); CREATE TABLE publications (publication_id INT, faculty_id INT, pub_date DATE);
List the top 10 most productive faculty members in terms of number of publications in the last 3 years, along with their respective departments.
SELECT f.name, f.department, COUNT(p.publication_id) AS num_publications FROM faculty f INNER JOIN publications p ON f.faculty_id = p.faculty_id WHERE p.pub_date BETWEEN DATE_SUB(NOW(), INTERVAL 3 YEAR) AND NOW() GROUP BY f.faculty_id, f.name, f.department ORDER BY num_publications DESC LIMIT 10;
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, Age INT, Gender VARCHAR(10), Location VARCHAR(20)); INSERT INTO Players (PlayerID, Age, Gender, Location) VALUES (1, 22, 'Female', 'France'); INSERT INTO Players (PlayerID, Age, Gender, Location) VALUES (2, 35, 'Male', 'Germany'); CREATE TABLE Games (GameID INT, GameName VARCHAR(20), Genre VARCHAR(20)); INSERT INTO Games (GameID, GameName, Genre) VALUES (1, 'Mystery Explorer', 'Adventure');
What's the total number of players who play adventure games in Europe?
SELECT COUNT(*) FROM Players INNER JOIN (SELECT DISTINCT PlayerID FROM Games WHERE Genre = 'Adventure') AS AdventurePlayers ON Players.PlayerID = AdventurePlayers.PlayerID WHERE Players.Location = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_plans (plan_id INT, plan_name VARCHAR(50), monthly_cost DECIMAL(5,2)); CREATE TABLE subscribers (subscriber_id INT, plan_id INT, region VARCHAR(50)); CREATE TABLE sales (sale_id INT, subscriber_id INT, sale_date DATE, data_usage DECIMAL(5,2));
What is the average monthly data usage for each mobile plan in the European region, for the first quarter of 2022?
SELECT m.plan_name, AVG(s.data_usage) AS avg_data_usage FROM mobile_plans m JOIN subscribers s ON m.plan_id = s.plan_id JOIN sales ON s.subscriber_id = sales.subscriber_id WHERE s.region = 'Europe' AND QUARTER(sale_date) = 1 GROUP BY m.plan_name;
gretelai_synthetic_text_to_sql
CREATE SCHEMA space; USE space; CREATE TABLE rover (name VARCHAR(50), type VARCHAR(50), mass FLOAT); INSERT INTO rover (name, type, mass) VALUES ('Curiosity', 'Rover', 899000), ('Perseverance', 'Rover', 1025000), ('Spirit', 'Rover', 185000), ('Opportunity', 'Rover', 174000), ('Viking 1', 'Lander', 576000), ('Viking 2', 'Lander', 576000);
What is the total mass of operational Mars rovers and landers?
SELECT SUM(mass) FROM space.rover WHERE type = 'Rover' AND name IN ('Curiosity', 'Perseverance', 'Spirit', 'Opportunity') OR type = 'Lander' AND name IN ('Viking 1', 'Viking 2');
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_plans (plan_type VARCHAR(10), monthly_rate INT, additional_fees INT);
Show the total revenue for each mobile plan type
SELECT plan_type, (monthly_rate + additional_fees) AS total_revenue FROM mobile_plans;
gretelai_synthetic_text_to_sql
CREATE VIEW south_america_hotels AS SELECT * FROM hotels WHERE continent = 'South America'; CREATE VIEW hotel_ratings AS SELECT hotel_id, AVG(rating) as avg_rating FROM hotel_reviews GROUP BY hotel_id;
What is the ranking of hotel types by average rating, for hotels in the 'south_america_hotels' view?
SELECT type, ROW_NUMBER() OVER (ORDER BY avg_rating DESC) as ranking FROM south_america_hotels JOIN hotel_ratings ON south_america_hotels.id = hotel_ratings.hotel_id GROUP BY type;
gretelai_synthetic_text_to_sql
CREATE TABLE TreesPlanted (Id INT, Location VARCHAR(50), Purpose VARCHAR(50), NumberPlanted INT);
How many trees were planted in South America for climate change mitigation?
SELECT SUM(NumberPlanted) FROM TreesPlanted WHERE Purpose = 'climate change mitigation' AND Location = 'South America';
gretelai_synthetic_text_to_sql
CREATE TABLE countries (country_id INT, country_name TEXT); CREATE TABLE wells (well_id INT, country_id INT, well_name TEXT, production_qty INT, start_date DATE, end_date DATE); INSERT INTO countries (country_id, country_name) VALUES (1, 'Country A'), (2, 'Country B'); INSERT INTO wells (well_id, country_id, well_name, production_qty, start_date, end_date) VALUES (1, 1, 'Well A', 500, '2020-01-01', '2022-02-28'), (2, 1, 'Well B', 700, '2021-01-01', '2023-01-01'), (3, 2, 'Well C', 300, '2022-01-01', '2024-01-01');
List all countries, their total production, and the number of active wells in each country, for countries with at least one active well in 2022.
SELECT c.country_name, SUM(w.production_qty) AS total_production, COUNT(w.well_id) AS active_wells FROM countries c INNER JOIN wells w ON c.country_id = w.country_id WHERE w.start_date <= '2022-01-01' AND w.end_date >= '2022-01-01' GROUP BY c.country_name;
gretelai_synthetic_text_to_sql
CREATE TABLE LuxuryVehicles (id INT, make VARCHAR(50), model VARCHAR(50), safetyrating INT); CREATE TABLE Vehicles (id INT, make VARCHAR(50), model VARCHAR(50), PRIMARY KEY (id)); CREATE TABLE Luxury (id INT, vehicle_id INT, PRIMARY KEY (id), FOREIGN KEY (vehicle_id) REFERENCES Vehicles(id));
What is the average safety rating for luxury vehicles in the luxuryvehicles schema?
SELECT AVG(safetyrating) FROM luxuryvehicles JOIN Luxury ON luxuryvehicles.id = Luxury.vehicle_id;
gretelai_synthetic_text_to_sql
CREATE TABLE attorneys (id INT, first_name VARCHAR, last_name VARCHAR, department VARCHAR); CREATE TABLE cases (id INT, attorney_id INT, outcome VARCHAR); INSERT INTO attorneys (id, first_name, last_name, department) VALUES (1, 'Maria', 'Garcia', 'Civil'), (2, 'Juan', 'Williams', 'Criminal'), (3, 'Carlos', 'Rodriguez', 'Family'), (4, 'Laura', 'Williams', 'Immigration'); INSERT INTO cases (id, attorney_id, outcome) VALUES (1, 1, 'Favorable'), (2, 2, 'Unfavorable'), (3, 3, 'Favorable'), (4, 4, 'Favorable');
What is the number of cases handled by attorneys with the last name 'Williams'?
SELECT COUNT(*) FROM attorneys a JOIN cases c ON a.id = c.attorney_id WHERE a.last_name = 'Williams';
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, HireDate DATE, Location VARCHAR(50)); INSERT INTO Employees (EmployeeID, HireDate, Location) VALUES (1, '2018-01-01', 'NYC'), (2, '2020-03-15', 'LA'), (3, '2019-08-25', 'NYC'), (4, '2019-11-04', 'NYC'), (5, '2020-02-16', 'LA');
Show the number of employees hired in each location, ordered by the number of hires.
SELECT Location, COUNT(*) FROM Employees GROUP BY Location ORDER BY COUNT(*) DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE threat_actors (threat_actor_id INT, attack_type VARCHAR(20), success_count INT, last_updated DATETIME); INSERT INTO threat_actors (threat_actor_id, attack_type, success_count, last_updated) VALUES (1, 'Malware', 10, '2022-01-01'), (2, 'Phishing', 15, '2022-01-05'), (3, 'SQL Injection', 20, '2022-01-03'), (4, 'Cross-Site Scripting', 12, '2022-01-04'), (5, 'Malware', 18, '2022-01-02');
List the top 5 threat actors with the highest number of successful attacks in the last quarter, partitioned by their attack type.
SELECT attack_type, threat_actor_id, success_count FROM (SELECT attack_type, threat_actor_id, success_count, ROW_NUMBER() OVER (PARTITION BY attack_type ORDER BY success_count DESC) rn FROM threat_actors WHERE last_updated >= DATEADD(quarter, -1, GETDATE())) t WHERE rn <= 5;
gretelai_synthetic_text_to_sql
CREATE TABLE energy_prices (country VARCHAR(50), technology VARCHAR(50), year INT, price_per_mwh FLOAT); INSERT INTO energy_prices (country, technology, year, price_per_mwh) VALUES ('India', 'Solar', 2018, 50), ('India', 'Solar', 2019, 55), ('India', 'Solar', 2020, 60), ('India', 'Solar', 2021, 65);
What is the average price per MWh for solar energy in India?
SELECT AVG(price_per_mwh) FROM energy_prices WHERE country = 'India' AND technology = 'Solar';
gretelai_synthetic_text_to_sql
CREATE TABLE student_mental_health_resources (student_id INT, country VARCHAR(20), resource_id VARCHAR(5)); INSERT INTO student_mental_health_resources (student_id, country, resource_id) VALUES (1, 'Canada', 'R101'), (2, 'USA', 'R201'), (3, 'Canada', 'R102'), (4, 'Mexico', 'R301'), (5, 'USA', 'R202'), (6, 'Canada', 'R103'), (7, 'Mexico', 'R302');
What is the number of students who have accessed mental health resources in each country?
SELECT country, COUNT(*) FROM student_mental_health_resources GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE broadband_subscribers (subscriber_id INT, speed FLOAT, state VARCHAR(255)); INSERT INTO broadband_subscribers (subscriber_id, speed, state) VALUES (1, 150, 'California'), (2, 200, 'California'), (3, 40, 'California'), (4, 120, 'California');
Delete records of subscribers with speed below 50Mbps in California.
DELETE FROM broadband_subscribers WHERE speed < 50 AND state = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE solar_panels (id INT PRIMARY KEY, manufacturer VARCHAR(50), installed_year INT, capacity FLOAT);
Add a new record to the 'solar_panels' table with id 1001, manufacturer 'SunPower', installed_year 2015, and capacity 350
INSERT INTO solar_panels (id, manufacturer, installed_year, capacity) VALUES (1001, 'SunPower', 2015, 350);
gretelai_synthetic_text_to_sql
CREATE TABLE students (id INT, name VARCHAR(255)); CREATE TABLE courses (id INT, name VARCHAR(255), is_online BOOLEAN); CREATE TABLE enrollments (id INT, student_id INT, course_id INT); INSERT INTO students (id, name) VALUES (1, 'Student A'), (2, 'Student B'), (3, 'Student C'); INSERT INTO courses (id, name, is_online) VALUES (1, 'Open Pedagogy 101', TRUE), (2, 'Math', FALSE), (3, 'Science', FALSE); INSERT INTO enrollments (id, student_id, course_id) VALUES (1, 1, 1), (2, 2, 1), (3, 3, 1), (4, 1, 2), (5, 2, 3);
Which students have enrolled in online courses?
SELECT s.name AS student_name FROM students s JOIN enrollments e ON s.id = e.student_id JOIN courses c ON e.course_id = c.id WHERE c.is_online = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE investment_strategies (id INT, strategy VARCHAR(50), risk_level INT); INSERT INTO investment_strategies (id, strategy, risk_level) VALUES (1, 'Impact Bonds', 30), (2, 'Green Equity Funds', 20), (3, 'Sustainable Real Estate', 40);
Find the investment strategies with a risk level lower than the average risk level.
SELECT strategy, risk_level FROM investment_strategies WHERE risk_level < (SELECT AVG(risk_level) FROM investment_strategies);
gretelai_synthetic_text_to_sql
CREATE TABLE museums (id INT, name VARCHAR(255), location VARCHAR(255), attendance INT); INSERT INTO museums (id, name, location, attendance) VALUES (1, 'Museum1', 'CityA', 10000), (2, 'Museum2', 'CityB', 15000), (3, 'Museum3', 'CityC', 5000);
Which museums had the highest and lowest attendance in 2021?
SELECT name, attendance FROM museums WHERE YEAR(location) = 2021 ORDER BY attendance LIMIT 1; SELECT name, attendance FROM museums WHERE YEAR(location) = 2021 ORDER BY attendance DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Vehicle_Sales (Sale_ID INT, Vehicle_ID INT, Country VARCHAR(50), Year INT, Quantity INT); INSERT INTO Vehicle_Sales (Sale_ID, Vehicle_ID, Country, Year, Quantity) VALUES (1, 1, 'Germany', 2021, 500), (2, 2, 'France', 2021, 300), (3, 3, 'Italy', 2020, 400), (4, 4, 'Spain', 2021, 600), (5, 5, 'United Kingdom', 2021, 700), (6, 1, 'Germany', 2020, 400);
How many electric vehicles were sold in the European Union in 2021?
SELECT SUM(Quantity) FROM Vehicle_Sales WHERE Year = 2021 AND Vehicle_ID IN (SELECT Vehicle_ID FROM Vehicles WHERE Electric = TRUE) AND Country LIKE '%European Union%';
gretelai_synthetic_text_to_sql
CREATE TABLE players (id INT, age INT, country VARCHAR(255), hours_played DECIMAL(5,2)); INSERT INTO players (id, age, country, hours_played) VALUES (1, 25, 'India', 10.5), (2, 30, 'USA', 12.0), (3, 35, 'Mexico', 8.5); CREATE TABLE games (id INT, name VARCHAR(255), category VARCHAR(255)); INSERT INTO games (id, name, category) VALUES (1, 'GameA', 'VR'), (2, 'GameB', 'Non-VR'), (3, 'GameC', 'VR'); CREATE TABLE player_games (player_id INT, game_id INT, hours_played DECIMAL(5,2)); INSERT INTO player_games (player_id, game_id, hours_played) VALUES (1, 1, 10.5), (2, 1, 12.0), (3, 1, 8.5);
What is the total number of players who play VR games and their average hours played, grouped by country?
SELECT p.country, COUNT(p.id) as num_players, AVG(p.hours_played) as avg_hours_played FROM players p JOIN player_games pg ON p.id = pg.player_id JOIN games g ON pg.game_id = g.id WHERE g.category = 'VR' GROUP BY p.country;
gretelai_synthetic_text_to_sql
CREATE TABLE improvements (id INT, condition TEXT, approach TEXT, region TEXT, improvement FLOAT); INSERT INTO improvements (id, condition, approach, region, improvement) VALUES (1, 'Depression', 'CBT', 'Oceania', 0.8), (2, 'Anxiety', 'DBT', 'Oceania', 0.7), (3, 'PTSD', 'EMDR', 'Oceania', 0.9), (4, 'Depression', 'Medication', 'Oceania', 0.6);
Identify the mental health condition with the highest improvement rate for patients in Oceania, along with the associated treatment approach.
SELECT condition, approach, MAX(improvement) as max_improvement FROM improvements WHERE region = 'Oceania' GROUP BY condition, approach;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (id INT PRIMARY KEY, name VARCHAR(255), conservation_status VARCHAR(255)); INSERT INTO marine_species (id, name, conservation_status) VALUES (1, 'Leatherback Sea Turtle', 'Vulnerable'); CREATE TABLE oceanography (id INT PRIMARY KEY, species_id INT, oxygen_minimum_zone INT); INSERT INTO oceanography (id, species_id, oxygen_minimum_zone) VALUES (1, 1, 200);
What is the conservation status of the species with the lowest oxygen minimum zone value?
SELECT m.name, m.conservation_status FROM marine_species m JOIN (SELECT species_id, MIN(oxygen_minimum_zone) AS min_zone FROM oceanography GROUP BY species_id) o ON m.id = o.species_id WHERE o.min_zone = 200;
gretelai_synthetic_text_to_sql
CREATE TABLE model_algorithm (id INT, model_name TEXT, algorithm TEXT); INSERT INTO model_algorithm (id, model_name, algorithm) VALUES (1, 'modelA', 'algorithmA'), (2, 'modelB', 'algorithmB');
Get the 'id' of models that use 'algorithmA'.
SELECT id FROM model_algorithm WHERE algorithm = 'algorithmA';
gretelai_synthetic_text_to_sql
CREATE TABLE music_streams (artist_name VARCHAR(255), country VARCHAR(50), streams INT); INSERT INTO music_streams (artist_name, country, streams) VALUES ('Artist4', 'Brazil', 1000000), ('Artist5', 'Brazil', 1200000), ('Artist6', 'Brazil', 900000);
Who are the top 3 music artists with the highest number of streams in Brazil?
SELECT artist_name, SUM(streams) as total_streams FROM music_streams WHERE country = 'Brazil' GROUP BY artist_name ORDER BY total_streams DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_mitigation_projects (project_id INTEGER, project_name TEXT, allocation INTEGER); INSERT INTO climate_mitigation_projects (project_id, project_name, allocation) VALUES (1, 'Carbon Capture', 8000000);
Which climate mitigation project has the highest allocation?
SELECT project_name, allocation FROM climate_mitigation_projects ORDER BY allocation DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE mangrove_wildlife (id INT, species VARCHAR(50), year INT, region VARCHAR(20));
How many times has each wildlife species been observed in mangrove forests since 2015?
SELECT species, region, COUNT(*) as total_observations FROM mangrove_wildlife WHERE region = 'Mangrove' AND year >= 2015 GROUP BY species, region;
gretelai_synthetic_text_to_sql
CREATE TABLE seafoodspecies (species VARCHAR(30), biomass FLOAT, location VARCHAR(20)); INSERT INTO seafoodspecies (species, biomass, location) VALUES ('Tuna', 12000, 'Black Sea'), ('Mackerel', 15000, 'Black Sea');
What is the biomass of seafood species at risk in the Black Sea?
SELECT biomass FROM seafoodspecies WHERE species IN ('Tuna', 'Mackerel') AND location = 'Black Sea';
gretelai_synthetic_text_to_sql
CREATE TABLE supply_chain (country VARCHAR(50), element VARCHAR(10), year INT, production INT); INSERT INTO supply_chain (country, element, year, production) VALUES ('China', 'Dysprosium', 2020, 2000), ('Malaysia', 'Dysprosium', 2020, 1500), ('Australia', 'Dysprosium', 2020, 1000), ('India', 'Dysprosium', 2020, 500), ('Russia', 'Dysprosium', 2020, 1200), ('USA', 'Dysprosium', 2020, 1800);
Find the percentage of global Dysprosium production in 2020 from the 'supply_chain' table.
SELECT 100.0 * SUM(production) / (SELECT SUM(production) FROM supply_chain WHERE element = 'Dysprosium' AND year = 2020) as percentage FROM supply_chain WHERE element = 'Dysprosium' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE members (member_id INT, name VARCHAR(50), gender VARCHAR(10), dob DATE); INSERT INTO members (member_id, name, gender, dob) VALUES (1, 'Jamie Park', 'Non-binary', '2005-07-23'); INSERT INTO members (member_id, name, gender, dob) VALUES (2, 'Kai Chen', 'Male', '1999-10-11'); CREATE TABLE workout_sessions (session_id INT, member_id INT, session_date DATE); INSERT INTO workout_sessions (session_id, member_id, session_date) VALUES (1, 1, '2023-01-02'); INSERT INTO workout_sessions (session_id, member_id, session_date) VALUES (2, 1, '2023-01-10'); INSERT INTO workout_sessions (session_id, member_id, session_date) VALUES (3, 2, '2023-01-15'); INSERT INTO workout_sessions (session_id, member_id, session_date) VALUES (4, 1, '2023-01-25');
How many workout sessions did each member have in January 2023?
SELECT member_id, COUNT(*) AS sessions_in_jan_2023 FROM workout_sessions WHERE MONTH(session_date) = 1 AND YEAR(session_date) = 2023 GROUP BY member_id;
gretelai_synthetic_text_to_sql
CREATE TABLE RPGScores (PlayerID int, PlayerName varchar(50), Game varchar(50), Score int); INSERT INTO RPGScores (PlayerID, PlayerName, Game, Score) VALUES (1, 'Player1', 'Game2', 1000), (2, 'Player2', 'Game2', 1200), (3, 'Player3', 'Game2', 1400), (4, 'Player4', 'Game2', 1600);
What is the difference in scores between consecutive players in the 'RPG' game category, ordered by score?
SELECT Game, Score, LEAD(Score) OVER (PARTITION BY Game ORDER BY Score) as NextScore, LEAD(Score) OVER (PARTITION BY Game ORDER BY Score) - Score as ScoreDifference FROM RPGScores WHERE Game = 'Game2' ORDER BY Score;
gretelai_synthetic_text_to_sql
CREATE TABLE students (id INT, name TEXT, disability TEXT, sign_language_interpreter BOOLEAN); INSERT INTO students (id, name, disability, sign_language_interpreter) VALUES (1, 'John Doe', 'hearing impairment', true); INSERT INTO students (id, name, disability, sign_language_interpreter) VALUES (2, 'Jane Smith', 'learning disability', false);
How many students with hearing impairments have not utilized sign language interpreters in the past year?
SELECT COUNT(*) FROM students WHERE disability = 'hearing impairment' AND sign_language_interpreter = false AND date >= DATE_SUB(NOW(), INTERVAL 1 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE Tourists (country TEXT, transport TEXT); INSERT INTO Tourists (country, transport) VALUES ('Italy', 'Train'), ('France', 'Plane'), ('Spain', 'Bus'), ('Greece', 'Car'), ('Portugal', 'Train'), ('Germany', 'Bike');
What is the percentage of tourists who prefer sustainable modes of transport?
SELECT COUNT(CASE WHEN transport IN ('Train', 'Bike') THEN 1 ELSE NULL END) / COUNT(*) FROM Tourists;
gretelai_synthetic_text_to_sql
CREATE TABLE salesperson (salesperson_id INT, name VARCHAR(50), revenue DECIMAL(10,2)); INSERT INTO salesperson VALUES (1, 'John Doe', 5000.00), (2, 'Jane Smith', 6000.00), (3, 'Alice Johnson', 7000.00);
What is the total revenue for each salesperson, ordered by total revenue in descending order?
SELECT name, SUM(revenue) as total_revenue FROM salesperson GROUP BY name ORDER BY total_revenue DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE waste_generation (country VARCHAR(50), year INT, population INT, waste_amount INT);
What is the waste generation trend in 'waste_generation' table for the US?
SELECT year, AVG(waste_amount) as avg_waste_amount FROM waste_generation WHERE country = 'US' GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE taxi_rides (id INT, distance FLOAT, type VARCHAR(20), city VARCHAR(20)); INSERT INTO taxi_rides (id, distance, type, city) VALUES (1, 5.3, 'Autonomous', 'Berlin');
What is the average distance of autonomous taxi rides in Berlin?
SELECT AVG(distance) FROM taxi_rides WHERE type = 'Autonomous' AND city = 'Berlin';
gretelai_synthetic_text_to_sql
CREATE TABLE soil_moisture_irrigation_system (system_id INT, moisture DECIMAL(3,1), system_timestamp DATETIME);
Update all records in the soil_moisture_irrigation_system table with a moisture level of 60 where system_id is 10 and moisture level is less than 60
UPDATE soil_moisture_irrigation_system SET moisture = 60 WHERE system_id = 10 AND moisture < 60;
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (id INT, name VARCHAR(255)); INSERT INTO vessels (id, name) VALUES (1, 'Vessel_A'), (2, 'Vessel_B'), (3, 'Vessel_C'); CREATE TABLE cargo (vessel_id INT, weight INT, month VARCHAR(9)); INSERT INTO cargo (vessel_id, weight, month) VALUES (1, 5000, 'February 2021'), (1, 4000, 'February 2021'), (2, 3000, 'February 2021'), (3, 6000, 'February 2021'), (3, 7000, 'February 2021');
Which vessels had the most total cargo weight in February 2021?
SELECT v.name, SUM(c.weight) as total_weight FROM cargo c JOIN vessels v ON c.vessel_id = v.id WHERE c.month = 'February 2021' GROUP BY v.name ORDER BY total_weight DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE MentalHealthParity (Id INT, Region VARCHAR(20), ReportDate DATE); INSERT INTO MentalHealthParity (Id, Region, ReportDate) VALUES (1, 'Southwest', '2020-01-01'), (2, 'Northeast', '2019-12-31'), (3, 'Southwest', '2020-06-15'), (4, 'Northeast', '2020-01-10'), (5, 'Southwest', '2020-06-15');
What is the maximum number of mental health parity cases reported in a single day?
SELECT ReportDate, COUNT(*) as CountOfCases FROM MentalHealthParity GROUP BY ReportDate ORDER BY CountOfCases DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE loans (id INT, loan_type VARCHAR, date DATE); INSERT INTO loans (id, loan_type, date) VALUES (1, 'Shariah-compliant', '2022-01-05'), (2, 'socially responsible', '2022-02-07'), (3, 'Shariah-compliant', '2022-03-03'), (4, 'socially responsible', '2022-04-30');
What is the total number of Shariah-compliant and socially responsible loans issued in 2022?
SELECT COUNT(*) FROM loans WHERE EXTRACT(YEAR FROM date) = 2022 AND (loan_type = 'Shariah-compliant' OR loan_type = 'socially responsible');
gretelai_synthetic_text_to_sql
CREATE TABLE mental_health_parity (region VARCHAR(20), case_count INT); INSERT INTO mental_health_parity (region, case_count) VALUES ('Northeast', 200), ('Southeast', 150), ('Midwest', 180), ('Southwest', 250), ('West', 220);
What is the total number of mental health parity cases reported in the Northeast and Midwest regions?
SELECT SUM(case_count) FROM mental_health_parity WHERE region IN ('Northeast', 'Midwest');
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT, product_id INT, country VARCHAR(255), quantity INT); CREATE TABLE products (id INT, name VARCHAR(255), is_organic BOOLEAN);
Get the number of organic products sold in the USA
SELECT COUNT(*) FROM sales s INNER JOIN products p ON s.product_id = p.id WHERE p.is_organic = TRUE AND s.country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE Artworks (ArtworkID INT, ArtistID INT, Title VARCHAR(255), Period VARCHAR(255)); INSERT INTO Artworks VALUES (1, 1, 'The Starry Night', 'Post-Impressionist'); CREATE TABLE Artists (ArtistID INT, Name VARCHAR(255), Birthplace VARCHAR(255)); INSERT INTO Artists VALUES (1, 'Vincent van Gogh', 'Netherlands');
What is the name and birthplace of the artist with the most artwork in the 'Post-Impressionist' period?
SELECT Artists.Name, Artists.Birthplace FROM Artists INNER JOIN (SELECT ArtistID, COUNT(*) AS ArtworkCount FROM Artworks WHERE Period = 'Post-Impressionist' GROUP BY ArtistID) SubQuery ON Artists.ArtistID = SubQuery.ArtistID ORDER BY ArtworkCount DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE faculties (faculty_id INT, name VARCHAR(255), dept_id INT, gender VARCHAR(10));CREATE TABLE departments (dept_id INT, dept_name VARCHAR(255));
Calculate the percentage of female faculty members per department, in descending order of percentage.
SELECT dept_name, COUNT(*) * 100.0 / (SELECT COUNT(*) FROM faculties WHERE dept_id = f.dept_id) AS percentage FROM faculties f JOIN departments d ON f.dept_id = d.dept_id WHERE gender = 'female' GROUP BY dept_name ORDER BY percentage DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE mining_operations (operation_id INT, operation_name VARCHAR(50), resource_type VARCHAR(50), depletion_date DATE, quantity INT); INSERT INTO mining_operations (operation_id, operation_name, resource_type, depletion_date, quantity) VALUES (1, 'Operation A', 'Coal', '2022-01-01', 100), (2, 'Operation B', 'Iron', '2022-02-15', 200), (3, 'Operation C', 'Gold', '2022-03-30', 150);
How many resources were depleted in each mining operation in the last quarter?
SELECT operation_name, resource_type, SUM(quantity) AS total_depleted FROM mining_operations WHERE depletion_date >= DATE_SUB(CURDATE(), INTERVAL 3 MONTH) GROUP BY operation_name, resource_type;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (id INT, name VARCHAR(50), region VARCHAR(50), balance DECIMAL(10,2)); INSERT INTO customers (id, name, region, balance) VALUES (1, 'John Doe', 'East', 5000.00), (2, 'Jane Smith', 'East', 7000.00), (3, 'Alice Johnson', 'East', 2000.00);
What is the minimum balance for customers in the East region?
SELECT MIN(balance) FROM customers WHERE region = 'East';
gretelai_synthetic_text_to_sql
CREATE TABLE ai_models (model_name TEXT, safety_score INTEGER, fairness_score INTEGER); INSERT INTO ai_models (model_name, safety_score, fairness_score) VALUES ('ModelX', 85, 90), ('ModelY', 70, 75), ('ModelZ', 95, 80);
Identify AI models with inconsistent safety and fairness scores.
SELECT model_name FROM ai_models WHERE safety_score < 80 AND fairness_score < 80;
gretelai_synthetic_text_to_sql