context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE disaster_assistance (disaster_type TEXT, families_assisted INTEGER); INSERT INTO disaster_assistance (disaster_type, families_assisted) VALUES ('Flood', 100), ('Earthquake', 125), ('Fire', 75); CREATE TABLE assistance (disaster_type TEXT, families_assisted INTEGER); INSERT INTO assistance (disaster_type, f...
What is the total number of families assisted in each disaster type?
SELECT da.disaster_type, SUM(da.families_assisted + a.families_assisted) FROM disaster_assistance da CROSS JOIN assistance a GROUP BY da.disaster_type;
gretelai_synthetic_text_to_sql
CREATE TABLE reserve_years (reserve_id INT, year_established INT);
Get the number of marine reserves that have been established since 2010, including the year of establishment in the 'reserve_years' table.
SELECT year_established, COUNT(*) FROM reserve_years WHERE year_established >= 2010 GROUP BY year_established;
gretelai_synthetic_text_to_sql
CREATE TABLE mental_health_parity_complaints (complaint_id INT, complaint_date DATE, state VARCHAR(20), race VARCHAR(20)); INSERT INTO mental_health_parity_complaints (complaint_id, complaint_date, state, race) VALUES (1, '2021-07-01', 'California', 'Asian'), (2, '2021-03-15', 'California', 'Black'), (3, '2021-01-01', ...
What is the total number of mental health parity complaints filed in California in the last 12 months by race?
SELECT race, COUNT(*) as num_complaints FROM mental_health_parity_complaints WHERE complaint_date >= DATE_SUB(CURRENT_DATE, INTERVAL 12 MONTH) AND state = 'California' GROUP BY race;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, FirstName TEXT, LastName TEXT, RegistrationDate DATE); INSERT INTO Donors (DonorID, FirstName, LastName, RegistrationDate) VALUES (1, 'John', 'Doe', '2021-01-15'), (2, 'Jane', 'Doe', '2020-12-20'), (3, 'Mike', 'Smith', '2021-03-01'); CREATE TABLE Donations (DonationID INT, DonorID INT,...
How many new donors made a donation in each month of 2021?
SELECT EXTRACT(MONTH FROM DonationDate) as Month, COUNT(DISTINCT DonorID) as NewDonors FROM Donations d JOIN Donors don ON d.DonorID = don.DonorID WHERE DonationDate BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY Month;
gretelai_synthetic_text_to_sql
CREATE TABLE Loans (id INT, project_id INT, leader_gender VARCHAR(10), disbursal_amount DECIMAL(10,2), disbursal_date DATE); INSERT INTO Loans (id, project_id, leader_gender, disbursal_amount, disbursal_date) VALUES (1, 1001, 'Female', 5000.00, '2020-03-15'), (2, 1002, 'Male', 8000.00, '2020-06-28'), (3, 1003, 'Female'...
What was the total amount of loans disbursed for women-led agricultural projects in Rwanda in 2020?
SELECT SUM(disbursal_amount) FROM Loans WHERE leader_gender = 'Female' AND YEAR(disbursal_date) = 2020 AND country = 'Rwanda';
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, name VARCHAR(255), gender VARCHAR(10), country VARCHAR(255), registration_date DATE, listening_time INT); INSERT INTO users (id, name, gender, country, registration_date, listening_time) VALUES (1, 'User 1', 'Male', 'USA', '2018-01-01', 120), (2, 'User 2', 'Female', 'Canada', '2017-01-01', 9...
What is the total listening time for users from the USA?
SELECT SUM(listening_time) AS total_listening_time FROM users WHERE country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, name VARCHAR(255), category VARCHAR(255), price DECIMAL(5,2));
Delete a product from the "products" table
DELETE FROM products WHERE product_id = 1001;
gretelai_synthetic_text_to_sql
CREATE TABLE rd_expenditure (drug_name TEXT, quarter TEXT, year INTEGER, expenditure INTEGER);
What is the maximum R&D expenditure in Q3 2022?
SELECT MAX(expenditure) FROM rd_expenditure WHERE quarter = 'Q3' AND year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, DonorCountry VARCHAR(50), Amount DECIMAL(10,2)); INSERT INTO Donors (DonorID, DonorCountry, Amount) VALUES (1, 'United States', 12000), (2, 'Canada', 10000), (3, 'Mexico', 8000), (4, 'Brazil', 9000), (5, 'Argentina', 7000);
Which countries had the highest and lowest donation amounts in H2 of 2021?
SELECT DonorCountry, MAX(Amount) as HighestDonation, MIN(Amount) as LowestDonation FROM Donors WHERE YEAR(DonationDate) = 2021 AND MONTH(DonationDate) > 6 GROUP BY DonorCountry HAVING COUNT(DonorID) > 1;
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name TEXT, industry TEXT, founding_year INT, founder_gender TEXT); INSERT INTO companies (id, name, industry, founding_year, founder_gender) VALUES (1, 'MedHealth', 'Healthcare', 2015, 'Female'); INSERT INTO companies (id, name, industry, founding_year, founder_gender) VALUES (2, 'Tech I...
Find the number of companies founded by women in the healthcare sector that received funding in 2021.
SELECT COUNT(*) FROM companies JOIN funding_records ON companies.id = funding_records.company_id WHERE companies.founder_gender = 'Female' AND companies.industry = 'Healthcare' AND funding_records.funding_year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE member_attendance (member_id INT, class_type VARCHAR(50)); INSERT INTO member_attendance (member_id, class_type) VALUES (1, 'strength'), (2, 'cardio'), (3, 'yoga'), (4, 'pilates'), (5, 'cardio');
List all members who have never attended a 'cardio' class.
SELECT member_id FROM member_attendance WHERE class_type NOT IN ('cardio');
gretelai_synthetic_text_to_sql
CREATE TABLE MilitaryTech (TechID INT, TechName VARCHAR(255), TechCategory VARCHAR(255), ReleaseYear INT);CREATE TABLE CountryTech (CountryID INT, TechID INT, AcquisitionYear INT);CREATE TABLE Countries (CountryID INT, CountryName VARCHAR(255));
Which countries have acquired a specific military technology in the past year?
SELECT C.CountryName FROM Countries C INNER JOIN CountryTech CT ON C.CountryID = CT.CountryID INNER JOIN MilitaryTech MT ON CT.TechID = MT.TechID WHERE MT.ReleaseYear BETWEEN EXTRACT(YEAR FROM CURRENT_DATE)-1 AND EXTRACT(YEAR FROM CURRENT_DATE);
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_floor (floor_name TEXT, location TEXT, min_depth FLOAT, max_depth FLOAT); INSERT INTO ocean_floor VALUES ('Central Indian Basin', 'Indian Ocean', 5449, 5570), ('Wharton Basin', 'Indian Ocean', 5904, 6036);
What is the minimum and maximum depth of the ocean floor in the Indian Ocean?
SELECT location, MIN(min_depth) AS min_depth, MAX(max_depth) AS max_depth FROM ocean_floor WHERE location = 'Indian Ocean' GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE museums (id INT, name TEXT, type TEXT); INSERT INTO museums (id, name, type) VALUES (1, 'abstract', 'museum'), (2, 'modernart', 'museum'); CREATE TABLE artworks (id INT, museum_id INT, title TEXT, creation_date DATE); INSERT INTO artworks (id, museum_id, title, creation_date) VALUES (1, 1, 'Composition VII...
What is the oldest artwork in the 'abstract' museum?
SELECT title, creation_date FROM artworks WHERE museum_id = 1 ORDER BY creation_date LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE soil_moisture (id INT PRIMARY KEY, farm_id INT, moisture INT, date DATE);
Delete all records from the table "soil_moisture" where the "moisture" is less than 30
DELETE FROM soil_moisture WHERE moisture < 30;
gretelai_synthetic_text_to_sql
CREATE TABLE treatments ( treatment_id INT PRIMARY KEY, name VARCHAR(100), description TEXT, condition_id INT, FOREIGN KEY (condition_id) REFERENCES conditions(condition_id));
Create a table named 'treatments'
CREATE TABLE treatments ( treatment_id INT PRIMARY KEY, name VARCHAR(100), description TEXT, condition_id INT, FOREIGN KEY (condition_id) REFERENCES conditions(condition_id));
gretelai_synthetic_text_to_sql
CREATE TABLE emergency_calls (id INT, call_time TIMESTAMP, sector VARCHAR(20), city VARCHAR(20)); INSERT INTO emergency_calls VALUES (1, '2022-01-01 10:00:00', 'SectorA', 'Los Angeles'); CREATE TABLE community_sectors (id INT, sector VARCHAR(20), location VARCHAR(20)); INSERT INTO community_sectors VALUES (1, 'SectorA'...
What is the average response time for emergency calls in the city of Los Angeles, broken down by community policing sector?
SELECT c.sector, AVG(TIMESTAMPDIFF(MINUTE, call_time, '2022-01-01 11:00:00')) as avg_response_time FROM emergency_calls c JOIN community_sectors s ON c.sector = s.sector WHERE c.city = 'Los Angeles' GROUP BY c.sector;
gretelai_synthetic_text_to_sql
INSERT INTO policyholders (id, name, age, gender, policy_type, state) VALUES (5, 'David Brown', 32, 'Male', 'Home', 'Texas');
What is the count of policyholders in Texas with 'Auto' and 'Home' policy_types?
SELECT COUNT(DISTINCT policyholders.id) FROM policyholders WHERE state = 'Texas' AND (policy_type = 'Auto' OR policy_type = 'Home');
gretelai_synthetic_text_to_sql
CREATE TABLE patients (patient_id INT, diagnosis VARCHAR(255), age INT, county VARCHAR(255)); INSERT INTO patients (patient_id, diagnosis, age, county) VALUES (1, 'diabetes', 60, 'Briarwood'), (2, 'asthma', 30, 'Briarwood'), (3, 'diabetes', 55, 'Pineville'), (4, 'asthma', 40, 'Pineville'), (5, 'diabetes', 45, 'Oakwood'...
What is the number of patients diagnosed with diabetes and asthma in rural communities?
SELECT COUNT(*) FROM diabetes_asthma_patients WHERE county IN ('Briarwood', 'Pineville', 'Oakwood');
gretelai_synthetic_text_to_sql
CREATE TABLE PeacekeepingOperations (OperationID INT PRIMARY KEY, Location VARCHAR(50), Year INT, HumanitarianAssistance BOOLEAN); INSERT INTO PeacekeepingOperations (OperationID, Location, Year, HumanitarianAssistance) VALUES (1, 'Democratic Republic of the Congo', 2019, TRUE), (2, 'South Sudan', 2019, TRUE), (3, 'Cen...
What is the number of peacekeeping operations in Africa that involved humanitarian assistance in the last 3 years?
SELECT COUNT(*) AS 'Number of Operations' FROM PeacekeepingOperations WHERE Year BETWEEN 2019 AND 2021 AND HumanitarianAssistance = TRUE AND Location LIKE '%Africa%';
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists biotech;USE biotech;CREATE TABLE if not exists projects (id INT, country VARCHAR(255), type VARCHAR(255));INSERT INTO projects (id, country, type) VALUES (1, 'Brazil', 'Bioprocess'), (2, 'India', 'Genetic'), (3, 'USA', 'Bioprocess'), (4, 'Germany', 'Biosensor'), (5, 'Australia', 'Genetic'), ...
What are the top 2 countries with the most bioprocess engineering projects?
SELECT country, COUNT(*) as num_projects FROM projects WHERE type = 'Bioprocess' GROUP BY country ORDER BY num_projects DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE AnalyzedByCountry (Country TEXT, Analyzed INT); INSERT INTO AnalyzedByCountry (Country, Analyzed) VALUES ('UK', 2), ('USA', 3), ('France', 1);
What are the total number of artifacts analyzed by researchers from each country?
SELECT Country, SUM(Analyzed) FROM AnalyzedByCountry GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE donations_date_jpn (donation_id INT, donation_date DATE, country VARCHAR(255)); INSERT INTO donations_date_jpn (donation_id, donation_date, country) VALUES (11, '2021-02-01', 'Japan'), (12, '2021-03-15', 'Japan'), (13, '2021-01-20', 'Japan'), (14, '2021-04-05', 'Japan');
How many donations were made in each month of 2021 in Japan?
SELECT EXTRACT(MONTH FROM donation_date) as month, COUNT(*) as num_donations FROM donations_date_jpn WHERE country = 'Japan' GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE MilitaryProduction (id INT, year INT, country TEXT, vehicles INT); INSERT INTO MilitaryProduction (id, year, country, vehicles) VALUES (1, 2012, 'Germany', 250), (2, 2013, 'Germany', 270);
How many military vehicles were produced in Germany each year for the past decade?
SELECT YEAR(MilitaryProduction.year) as year, SUM(MilitaryProduction.vehicles) as total_vehicles FROM MilitaryProduction WHERE MilitaryProduction.country = 'Germany' GROUP BY YEAR(MilitaryProduction.year) ORDER BY YEAR(MilitaryProduction.year) DESC LIMIT 10;
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, name VARCHAR(50), gender VARCHAR(10), age INT, location VARCHAR(50), likes INT); CREATE TABLE posts (id INT, user_id INT, content TEXT, timestamp TIMESTAMP, likes INT);
What is the total number of likes on posts created by users in 'New York' between '2021-06-01' and '2021-06-30'?
SELECT SUM(posts.likes) AS total_likes FROM posts JOIN users ON posts.user_id = users.id WHERE users.location = 'New York' AND posts.timestamp BETWEEN '2021-06-01' AND '2021-06-30';
gretelai_synthetic_text_to_sql
CREATE TABLE VehicleSales(id INT, type VARCHAR(20), country VARCHAR(20), year INT, quantity INT);
What is the market share of electric vehicles in the US over time?
SELECT type, country, AVG(quantity*100.0/SUM(quantity)) OVER (PARTITION BY type ORDER BY year ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) as market_share FROM VehicleSales WHERE country = 'US' AND type IN ('Electric', 'Gasoline') ORDER BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE national_security_budgets (id INT, agency_name VARCHAR(255), budget DECIMAL(10,2), year INT); INSERT INTO national_security_budgets (id, agency_name, budget, year) VALUES (1, 'FSB', 40000000, 2016); INSERT INTO national_security_budgets (id, agency_name, budget, year) VALUES (2, 'MI6', 55000000, 2018);
What is the average budget for national security agencies in the Pacific Islands in the last 5 years?
SELECT AVG(budget) AS avg_budget FROM national_security_budgets WHERE year BETWEEN 2016 AND 2021 AND agency_name IN ('FSB', 'MI6', 'ASIO', 'DGSE', 'SIB');
gretelai_synthetic_text_to_sql
CREATE TABLE species (id INT, name VARCHAR(255)); INSERT INTO species (id, name) VALUES (1, 'Oak'), (2, 'Pine'), (3, 'Maple'); CREATE TABLE harvest (id INT, species_id INT, year INT, volume DECIMAL(10,2)); INSERT INTO harvest (id, species_id, year, volume) VALUES (1, 1, 2020, 1200.50), (2, 2, 2020, 1500.75), (3, 3, 202...
What is the total volume of timber harvested by species in 2020?
SELECT SUM(volume) AS total_volume, species.name FROM harvest JOIN species ON harvest.species_id = species.id WHERE harvest.year = 2020 GROUP BY species.name;
gretelai_synthetic_text_to_sql
CREATE TABLE CountryStats (Country TEXT, ObesityRate FLOAT); INSERT INTO CountryStats VALUES ('Canada', 29.4);
What is the obesity rate in Canada?
SELECT ObesityRate FROM CountryStats WHERE Country = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE startups (id INT, name TEXT, industry TEXT, founders TEXT, funding FLOAT); INSERT INTO startups (id, name, industry, founders, funding) VALUES (1, 'MECyber', 'Cybersecurity', 'Middle East', 4000000);
List the names of all startups founded by individuals from the Middle East in the cybersecurity sector with funding over 3 million dollars.
SELECT name FROM startups WHERE industry = 'Cybersecurity' AND founders = 'Middle East' AND funding > 3000000;
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, PlayerName VARCHAR(50));CREATE TABLE ESportsEvents (EventID INT, PlayerID INT);CREATE TABLE PlayerGames (PlayerID INT, GameID INT);CREATE TABLE Games (GameID INT, GameName VARCHAR(50));
Identify all games that have been played by players who have also participated in ESports events.
SELECT g.GameName FROM Games g INNER JOIN PlayerGames pg ON g.GameID = pg.GameID INNER JOIN Players p ON pg.PlayerID = p.PlayerID INNER JOIN ESportsEvents e ON p.PlayerID = e.PlayerID;
gretelai_synthetic_text_to_sql
CREATE TABLE therapy_outcome (therapy_type VARCHAR(50), outcome_status VARCHAR(50), treatment_center VARCHAR(50)); INSERT INTO therapy_outcome (therapy_type, outcome_status, treatment_center) VALUES ('Group Therapy', 'Success', 'clinic_j'), ('Family Therapy', 'Success', 'clinic_j');
What is the success rate of 'Group Therapy' and 'Family Therapy' in 'clinic_j'?
SELECT therapy_type, COUNT(*) * 100.0 / (SELECT COUNT(*) FROM therapy_outcome WHERE therapy_outcome.treatment_center = 'clinic_j' AND outcome_status = 'Success') FROM therapy_outcome WHERE (therapy_type = 'Group Therapy' OR therapy_type = 'Family Therapy') AND treatment_center = 'clinic_j';
gretelai_synthetic_text_to_sql
CREATE TABLE trams (route_id INT, time INT, line VARCHAR(10)); CREATE TABLE routes (route_id INT, line VARCHAR(10));
What is the average time taken for each tram line in Berlin to complete a route?
SELECT r.line, AVG(t.time) FROM trams t JOIN routes r ON t.route_id = r.route_id GROUP BY r.line;
gretelai_synthetic_text_to_sql
CREATE TABLE Events (EventID INT, City VARCHAR(50), Year INT); CREATE TABLE Capitals (City VARCHAR(50), Country VARCHAR(50)); INSERT INTO Events VALUES (1, 'Washington', 2010, 12), (2, 'London', 2012, 15), (3, 'Ottawa', 2017, 18); INSERT INTO Capitals VALUES ('Washington', 'USA'), ('London', 'UK'), ('Ottawa', 'Canada')...
How many public events were held in the capital city for each year since 2010?
SELECT Capitals.City, Year, COUNT(*) AS Events FROM Events INNER JOIN Capitals ON Events.City = Capitals.City WHERE Capitals.City IN ('Washington', 'London', 'Ottawa') AND Year >= 2010 GROUP BY Year, Capitals.City;
gretelai_synthetic_text_to_sql
CREATE TABLE MusicSales (SaleID INT, Genre VARCHAR(10), SalesAmount DECIMAL(10,2)); INSERT INTO MusicSales (SaleID, Genre, SalesAmount) VALUES (1, 'Jazz', 12.99), (2, 'Rock', 15.00), (3, 'Pop', 19.45), (4, 'Pop', 11.99);
What is the total revenue generated from digital music sales by each genre?
SELECT Genre, SUM(SalesAmount) as TotalRevenue FROM MusicSales GROUP BY Genre;
gretelai_synthetic_text_to_sql
CREATE TABLE Bridges (id INT, name TEXT, construction_date DATE, state TEXT); INSERT INTO Bridges (id, name, construction_date, state) VALUES (1, 'Bixby Creek Bridge', '1932-06-29', 'California');
What are the names and construction dates of all bridges built before 2000 in California?
SELECT name, construction_date FROM Bridges WHERE state = 'California' AND construction_date < '2000-01-01'
gretelai_synthetic_text_to_sql
CREATE TABLE creators (id INT, media_literacy_score FLOAT, country VARCHAR(20)); INSERT INTO creators (id, media_literacy_score, country) VALUES (1, 75.3, 'Germany'), (2, 82.1, 'France'), (3, 68.9, 'United States');
What is the distribution of media literacy scores for creators in Germany?
SELECT media_literacy_score, COUNT(*) AS count, AVG(media_literacy_score) AS avg_score, STDDEV(media_literacy_score) AS stddev_score FROM creators WHERE country = 'Germany' GROUP BY media_literacy_score ORDER BY count DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE restorative_justice_programs (program_id INT, state VARCHAR(20), start_date DATE); INSERT INTO restorative_justice_programs (program_id, state, start_date) VALUES (1, 'California', '2017-01-01'), (2, 'Texas', '2018-06-15'), (3, 'New York', '2019-02-03');
What is the total number of restorative justice programs, by state, with a start date within the last 5 years?
SELECT restorative_justice_programs.state, COUNT(*) as num_programs FROM restorative_justice_programs WHERE restorative_justice_programs.start_date >= DATE_SUB(CURRENT_DATE, INTERVAL 5 YEAR) GROUP BY restorative_justice_programs.state;
gretelai_synthetic_text_to_sql
CREATE TABLE membership_data (id INT, user_id INT, join_date DATE); CREATE TABLE user_profile (id INT, user_id INT, age INT, city VARCHAR(50)); INSERT INTO membership_data (id, user_id, join_date) VALUES (1, 1, '2021-01-01'), (2, 2, '2021-04-15'), (3, 3, '2021-03-01'); INSERT INTO user_profile (id, user_id, age, city) ...
How many users from each age group have joined the gym in the last 3 months, for users aged 18-24 and 35-45?
SELECT CASE WHEN age BETWEEN 18 AND 24 THEN '18-24' WHEN age BETWEEN 35 AND 45 THEN '35-45' END as age_group, COUNT(*) as user_count FROM membership_data m JOIN user_profile u ON m.user_id = u.user_id WHERE m.join_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH) AND (age BETWEEN 18 AND 24 OR age BETWEEN 35 AND 45) GROU...
gretelai_synthetic_text_to_sql
CREATE TABLE port (port_id INT, name TEXT);CREATE TABLE crane (crane_id INT, port_id INT, name TEXT);CREATE TABLE container (container_id INT, crane_id INT, weight INT, handled_at DATETIME);INSERT INTO port VALUES (8, 'Singapore');
Identify the heaviest container handled daily by each crane in 'Singapore'.
SELECT crane.name, DATE(container.handled_at) AS handling_date, MAX(container.weight) AS heaviest_weight FROM crane JOIN port ON crane.port_id = port.port_id JOIN container ON crane.crane_id = container.crane_id WHERE port.name = 'Singapore' GROUP BY crane.name, handling_date;
gretelai_synthetic_text_to_sql
CREATE TABLE economic_diversification (id INT, project_name TEXT, sector TEXT); INSERT INTO economic_diversification (id, project_name, sector) VALUES (1, 'Renewable Energy', 'Energy'), (2, 'Smart Farming', 'Agriculture');
How many economic diversification projects are present in the 'economic_diversification' table for each sector?
SELECT sector, COUNT(*) FROM economic_diversification GROUP BY sector;
gretelai_synthetic_text_to_sql
CREATE TABLE Restaurants (RestaurantID int, RestaurantName varchar(50), City varchar(50), State varchar(50), Country varchar(50)); INSERT INTO Restaurants (RestaurantID, RestaurantName, City, State, Country) VALUES (1, 'Tasty Thai', 'New York', 'NY', 'USA'), (2, 'Pizzeria Napoli', 'Rome', 'Italy', 'Italy'), (3, 'Sushi ...
What is the total revenue for each restaurant, ordered by total revenue in descending order?
SELECT RestaurantName, SUM(Revenue) as TotalRevenue FROM Restaurants JOIN Revenue ON Restaurants.RestaurantID = Revenue.RestaurantID GROUP BY RestaurantName ORDER BY TotalRevenue DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (donor_id INT, donation_date DATE, amount DECIMAL(10, 2)); INSERT INTO Donors (donor_id, donation_date, amount) VALUES (1, '2021-01-01', 50.00), (2, '2021-02-01', 100.00), (3, '2020-12-31', 75.00);
What is the total amount donated by all donors in 2021?
SELECT SUM(amount) FROM Donors WHERE YEAR(donation_date) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE policyholders (id INT, name TEXT, city TEXT, state TEXT, total_claims INT); INSERT INTO policyholders (id, name, city, state, total_claims) VALUES (1, 'John Doe', 'Oakland', 'CA', 800); INSERT INTO policyholders (id, name, city, state, total_claims) VALUES (2, 'Jane Smith', 'San Francisco', 'CA', 1200); IN...
What is the total claim amount for policies in 'NY' and 'TX'?
SELECT SUM(total_claims) FROM policyholders WHERE state = 'NY' OR state = 'TX';
gretelai_synthetic_text_to_sql
CREATE TABLE wastewater_treatment (id INT, location VARCHAR(255), treatment_type VARCHAR(255), capacity INT);
Show the location and treatment type for each wastewater treatment plant
SELECT location, treatment_type FROM wastewater_treatment;
gretelai_synthetic_text_to_sql
CREATE TABLE deep_sea_missions (id INT, name VARCHAR(255), location VARCHAR(255), type VARCHAR(255)); INSERT INTO deep_sea_missions (id, name, location, type) VALUES (1, 'MARUM-Queen Mary 2 Expedition', 'Arctic Ocean', 'Research'), (2, 'Project Nereus', 'Atlantic Ocean', 'Robotic Vehicle');
List all deep-sea exploration missions in the Arctic.
SELECT name FROM deep_sea_missions WHERE location = 'Arctic Ocean';
gretelai_synthetic_text_to_sql
CREATE SCHEMA IF NOT EXISTS renewable_energy; CREATE TABLE IF NOT EXISTS renewable_energy.solar_power ( project_id INT NOT NULL, location VARCHAR(255) NOT NULL, installed_capacity FLOAT NOT NULL, PRIMARY KEY (project_id));
Find the sum of installed capacity for solar power projects in the renewable_energy schema.
SELECT SUM(installed_capacity) FROM renewable_energy.solar_power;
gretelai_synthetic_text_to_sql
CREATE TABLE community_health_workers_2 (worker_id INT, region VARCHAR(10), cultural_competency_score INT); INSERT INTO community_health_workers_2 (worker_id, region, cultural_competency_score) VALUES (1, 'Northeast', 70), (2, 'Southeast', 75), (3, 'Midwest', 80);
Find the community health worker with the lowest cultural competency score.
SELECT worker_id, MIN(cultural_competency_score) FROM community_health_workers_2;
gretelai_synthetic_text_to_sql
CREATE TABLE funds (fund_id INT, community_id INT, amount DECIMAL(10, 2), donation_date DATE); INSERT INTO funds (fund_id, community_id, amount, donation_date) VALUES (1, 1, 5000.00, '2021-01-01');
What is the total amount of funds raised by each community in 'community_development' schema?
SELECT community_id, SUM(amount) as total_funds_raised FROM funds GROUP BY community_id;
gretelai_synthetic_text_to_sql
CREATE TABLE supporters (id INT, name TEXT, country TEXT); INSERT INTO supporters (id, name, country) VALUES (1, 'John Doe', 'Syria'), (2, 'Jane Smith', 'Iraq'), (3, 'Aisha Ahmed', 'Afghanistan'), (4, 'Ahmed Raza', 'Pakistan'), (5, 'Marie Curie', 'France');
What is the total number of supporters from each country?
SELECT country, COUNT(*) OVER (PARTITION BY country) AS total_supporters FROM supporters;
gretelai_synthetic_text_to_sql
CREATE TABLE space_debris (category TEXT, mass FLOAT); INSERT INTO space_debris (category, mass) VALUES ('Aluminum', 80.5), ('Titanium', 90.2), ('Copper', 60.3), ('Steel', 250.7), ('Other', 30.1);
What is the minimum mass of space debris in different categories?
SELECT category, MIN(mass) AS min_mass FROM space_debris GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE safety_incidents (id INT, facility VARCHAR(255), incident_date DATE); INSERT INTO safety_incidents (id, facility, incident_date) VALUES (1, 'Facility A', '2021-03-15'), (2, 'Facility B', '2021-06-23'), (3, 'Facility A', '2021-11-09'); CREATE VIEW incident_counts AS SELECT facility, COUNT(*) as incident_cou...
How many safety incidents were recorded for each facility in 2021?
SELECT facility, incident_count FROM incident_counts
gretelai_synthetic_text_to_sql
CREATE TABLE dept_services (dept VARCHAR(50), service VARCHAR(50)); INSERT INTO dept_services (dept, service) VALUES ('Infrastructure', 'Road Maintenance'), ('Infrastructure', 'Bridge Maintenance'), ('Education', 'K-12 Education');
How many services are provided by each department?
SELECT dept, COUNT(service) FROM dept_services GROUP BY dept;
gretelai_synthetic_text_to_sql
CREATE TABLE RuralInfrastructure (id INT, project_id INT, infrastructure_name VARCHAR(50), location VARCHAR(50), cost DECIMAL(10,2), start_date DATE, end_date DATE); INSERT INTO RuralInfrastructure (id, project_id, infrastructure_name, location, cost, start_date, end_date) VALUES (1, 1, 'Water Purification Plant', 'Rur...
What is the cost of rural infrastructure projects in 'Latin America' and 'Middle East' that were completed on or after 2022?
SELECT location, AVG(cost) FROM RuralInfrastructure WHERE end_date >= '2022-12-31' AND location IN ('Latin America', 'Middle East') GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE fan_data (fan_id INT, age_group VARCHAR(20), income INT);
What is the average income of fans by age group?
SELECT age_group, AVG(income) as avg_income FROM fan_data GROUP BY age_group;
gretelai_synthetic_text_to_sql
CREATE TABLE Research (id INT, title VARCHAR(100), country VARCHAR(100), year INT, cost FLOAT); INSERT INTO Research (id, title, country, year, cost) VALUES (1, 'Project A', 'Germany', 2010, 100000), (2, 'Project B', 'Germany', 2011, 120000);
What is the total cost of astrophysics research conducted in Germany between 2010 and 2015?
SELECT SUM(cost) FROM Research WHERE country = 'Germany' AND year BETWEEN 2010 AND 2015;
gretelai_synthetic_text_to_sql
CREATE TABLE shipments (id INT, source_country VARCHAR(20), destination_city VARCHAR(20), package_weight FLOAT, shipment_date DATE); INSERT INTO shipments (id, source_country, destination_city, package_weight, shipment_date) VALUES (1, 'Australia', 'Sydney', 12.5, '2022-02-10'), (2, 'Australia', 'Sydney', 18.3, '2021-0...
Determine the total weight of packages shipped from Australia to Sydney in the past year.
SELECT SUM(package_weight) FROM shipments WHERE source_country = 'Australia' AND destination_city = 'Sydney' AND shipment_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE community_health_workers (id INT, name TEXT, zip TEXT, consultations INT); INSERT INTO community_health_workers (id, name, zip, consultations) VALUES (1, 'John Doe', '75201', 25), (2, 'Jane Smith', '77001', 35); CREATE VIEW tx_workers AS SELECT * FROM community_health_workers WHERE zip BETWEEN '75201' AND ...
What is the ZIP code of the community health worker who conducted the most mental health parity consultations in Texas?
SELECT zip FROM tx_workers WHERE consultations = (SELECT MAX(consultations) FROM tx_workers);
gretelai_synthetic_text_to_sql
CREATE TABLE reporters (id INT, name VARCHAR(50), gender VARCHAR(10), age INT, role VARCHAR(20));
What is the average age of female news reporters in the 'reporters' table?
SELECT AVG(age) FROM reporters WHERE gender = 'female' AND role = 'news_reporter';
gretelai_synthetic_text_to_sql
CREATE TABLE games (game_id INT, date DATE, team TEXT, runs INT);
What is the maximum number of runs scored by a team in a single MLB game, and which team was it?
SELECT team, MAX(runs) FROM games;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_conservation_projects (id INT, name TEXT, location TEXT, ocean TEXT); INSERT INTO marine_conservation_projects (id, name, location, ocean) VALUES (1, 'Flower Garden Banks National Marine Sanctuary', 'Gulf of Mexico', 'Atlantic'), (2, 'Gulf of Mexico Marine Protected Areas', 'Gulf of Mexico', 'Atlant...
List all marine conservation projects in the Gulf of Mexico.
SELECT * FROM marine_conservation_projects WHERE ocean = 'Gulf of Mexico';
gretelai_synthetic_text_to_sql
CREATE TABLE workout_data(member_id INT, calories INT, workout_date DATE); INSERT INTO workout_data(member_id, calories, workout_date) VALUES (1,500,'2021-01-03'),(2,750,'2021-02-15'),(3,600,'2021-03-27'),(4,800,'2021-05-09'),(5,450,'2021-06-21'),(6,900,'2021-07-04'),(7,300,'2021-08-12'),(8,1000,'2021-09-26'),(9,550,'2...
What is the maximum calories burned by a member in a single workout?
SELECT MAX(calories) FROM workout_data;
gretelai_synthetic_text_to_sql
CREATE TABLE RecyclingRates (Country VARCHAR(50), RecyclingRate FLOAT, WasteType VARCHAR(50)); INSERT INTO RecyclingRates (Country, RecyclingRate, WasteType) VALUES ('Japan', 20.8, 'Municipal'), ('South Korea', 59.3, 'Municipal'), ('China', 22.5, 'Municipal'), ('India', 14.0, 'Municipal'), ('Singapore', 61.0, 'Municipa...
Identify the top three countries with the highest recycling rates in Asia, excluding special waste types.
SELECT Country, RecyclingRate FROM RecyclingRates WHERE WasteType != 'Special' AND Region = 'Asia' ORDER BY RecyclingRate DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE district (id INT, name VARCHAR(20)); INSERT INTO district (id, name) VALUES (1, 'West'), (2, 'East'), (3, 'North'), (4, 'South'); CREATE TABLE calls (id INT, district_id INT, call_type VARCHAR(20), call_time TIMESTAMP); INSERT INTO calls (id, district_id, call_type, call_time) VALUES (1, 2, 'Medical', '202...
How many fire calls were there between 12:00 PM and 5:00 PM in the West district?
SELECT COUNT(*) FROM calls WHERE district_id = (SELECT id FROM district WHERE name = 'West') AND call_type = 'Fire' AND call_time BETWEEN '2021-06-01 12:00:00' AND '2021-06-01 17:00:00';
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tours (tour_id INT, hotel_id INT, engagement_date DATE, engagement_time TIME); CREATE TABLE hotels (hotel_id INT, hotel_name VARCHAR(255), country VARCHAR(255));
What is the average virtual tour engagement time per hotel in the last month?
SELECT hotels.hotel_name, AVG(engagement_time) FROM virtual_tours INNER JOIN hotels ON virtual_tours.hotel_id = hotels.hotel_id WHERE engagement_date >= DATEADD(month, -1, GETDATE()) GROUP BY hotels.hotel_name;
gretelai_synthetic_text_to_sql
CREATE TABLE union_safety_region (union_id INT, region_id INT, safety_focus BOOLEAN); CREATE TABLE regions (region_id INT, region_name TEXT); INSERT INTO union_safety_region (union_id, region_id, safety_focus) VALUES (1, 1, true), (2, 1, false), (3, 2, true), (4, 2, true), (5, 3, false); INSERT INTO regions (region_id,...
Show the number of unions in each region that have a focus on worker safety.
SELECT regions.region_name, COUNT(*) FROM union_safety_region INNER JOIN regions ON union_safety_region.region_id = regions.region_id WHERE union_safety_region.safety_focus = true GROUP BY regions.region_name;
gretelai_synthetic_text_to_sql
CREATE TABLE ports (id INT, name TEXT); INSERT INTO ports (id, name) VALUES (1, 'Port of Long Beach'); CREATE TABLE vessel_arrivals (id INT, port_id INT, vessel_id INT, arrival_date DATE); INSERT INTO vessel_arrivals (id, port_id, vessel_id, arrival_date) VALUES (1, 1, 1, '2022-01-01'), (2, 1, 1, '2022-01-15'), (3, 1, ...
Which vessels arrived in the Port of Long Beach more than once in the last month?
SELECT DISTINCT v.vessel_name FROM vessel_arrivals va JOIN vessels v ON v.id = va.vessel_id WHERE va.port_id = (SELECT id FROM ports WHERE name = 'Port of Long Beach') AND va.arrival_date BETWEEN DATEADD(day, -30, CURRENT_DATE) AND CURRENT_DATE GROUP BY v.vessel_name HAVING COUNT(v.vessel_name) > 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Rural_Infrastructure(project_id INT, project_name VARCHAR(50), country VARCHAR(50), cost FLOAT); INSERT INTO Rural_Infrastructure(project_id, project_name, country, cost) VALUES (1, 'Road Construction', 'France', 1000000), (2, 'Bridge Building', 'Germany', 1200000);
What is the total number of rural infrastructure projects in 'Europe' and their total cost?
SELECT COUNT(*), SUM(cost) as total_cost FROM Rural_Infrastructure WHERE country = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE music_platform (id INT, artist VARCHAR(100), gender VARCHAR(10), country VARCHAR(50), streams INT);
What is the total number of streams for all songs by female artists on the music streaming platform in the USA?
SELECT SUM(streams) as total_streams FROM music_platform WHERE gender = 'female' AND country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE mining_operations (id INT PRIMARY KEY, operation_name VARCHAR(50), location VARCHAR(50), num_employees INT);
How many mining operations have more than 500 employees?
SELECT COUNT(*) FROM mining_operations WHERE num_employees > 500;
gretelai_synthetic_text_to_sql
CREATE TABLE PolicyAdvocacyEvents (event_id INT, event_name VARCHAR(255), event_date DATE); INSERT INTO PolicyAdvocacyEvents (event_id, event_name, event_date) VALUES (1001, 'Accessibility Awareness Fair', '2022-05-01'), (1002, 'Disability Rights Rally', '2022-06-15'), (1003, 'Inclusive Education Symposium', '2022-09-2...
How many policy advocacy events were held in the 'PolicyAdvocacyEvents' table, and what are their names?
SELECT event_name, COUNT(*) FROM PolicyAdvocacyEvents GROUP BY event_name;
gretelai_synthetic_text_to_sql
CREATE TABLE strains (id INT, name TEXT, type TEXT); INSERT INTO strains (id, name, type) VALUES (11, 'Girl Scout Cookies', 'Hybrid'); CREATE TABLE sales (id INT, strain_id INT, retail_price DECIMAL, sale_date DATE, state TEXT); INSERT INTO sales (id, strain_id, retail_price, sale_date, state) VALUES (30, 11, 24.00, '2...
Calculate the moving average of daily sales for the strain 'Girl Scout Cookies' over the last 60 days in Washington State.
SELECT AVG(retail_price) OVER (ORDER BY sale_date ROWS BETWEEN 59 PRECEDING AND CURRENT ROW) FROM sales WHERE strain_id = 11 AND state = 'Washington';
gretelai_synthetic_text_to_sql
CREATE TABLE garment_sales (id INT, garment_type VARCHAR(50), sustainability_rating INT, country VARCHAR(50), price DECIMAL(5,2), quantity INT); INSERT INTO garment_sales (id, garment_type, sustainability_rating, country, price, quantity) VALUES (1, 'jeans', 4, 'France', 79.99, 150), (2, 'jeans', 5, 'France', 99.99, 20...
Calculate the total revenue generated from the sales of sustainable denim jeans in France.
SELECT SUM(price * quantity) FROM garment_sales WHERE garment_type = 'jeans' AND country = 'France' AND sustainability_rating >= 4;
gretelai_synthetic_text_to_sql
CREATE TABLE Landfills (LandfillID INT, LandfillName VARCHAR(50), Capacity INT, AvailableSpace INT, Location VARCHAR(50)); INSERT INTO Landfills (LandfillID, LandfillName, Capacity, AvailableSpace, Location) VALUES (2, 'South Landfill', 12000, 1800, 'Miami');
What is the total processed waste quantity for recycling centers located in the same cities as landfills with available space less than 20% of their capacity?
SELECT SUM(ProcessedWasteQuantity) as TotalProcessed FROM RecyclingCenters rc INNER JOIN Landfills l ON rc.Location = l.Location WHERE l.AvailableSpace < 0.2 * l.Capacity;
gretelai_synthetic_text_to_sql
CREATE TABLE facility_waste_data (facility_id INT, facility_location VARCHAR(255), waste_quantity INT, year INT);
What is the total waste produced by each production facility in the Middle East region for 2022?
SELECT facility_location, SUM(waste_quantity) AS total_waste FROM facility_waste_data WHERE facility_location LIKE 'Middle East%' AND year = 2022 GROUP BY facility_location;
gretelai_synthetic_text_to_sql
CREATE TABLE defense_diplomacy (country VARCHAR(50), agreement_type VARCHAR(50), year INT); INSERT INTO defense_diplomacy (country, agreement_type, year) VALUES (), (), ();
Add a new record to the "defense_diplomacy" table with the following information: ('USA', 'arms_reduction_treaty', '2015')
INSERT INTO defense_diplomacy (country, agreement_type, year) VALUES ('USA', 'arms_reduction_treaty', 2015);
gretelai_synthetic_text_to_sql
CREATE TABLE daily_gas_usage (gas_used BIGINT, date TIMESTAMP);
What is the average daily gas usage for the Bitcoin network in 2021?
SELECT AVG(gas_used) as avg_daily_gas_usage FROM daily_gas_usage WHERE date BETWEEN '2021-01-01' AND '2021-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE energy_efficiency_projects (id INT, name VARCHAR(100), country VARCHAR(50), capacity_mw FLOAT); INSERT INTO energy_efficiency_projects (id, name, country, capacity_mw) VALUES (1, 'Project 1', 'USA', 75.6), (2, 'Project 2', 'Canada', 40.2), (3, 'Project 3', 'Brazil', 100.7);
Calculate the total capacity (in MW) of all energy efficiency projects in the world
SELECT SUM(capacity_mw) FROM energy_efficiency_projects;
gretelai_synthetic_text_to_sql
CREATE TABLE pro_bono (pro_bono_id INT, date DATE, hours DECIMAL(10,2)); INSERT INTO pro_bono (pro_bono_id, date, hours) VALUES (1, '2022-01-01', 20.00), (2, '2022-01-15', 25.00), (3, '2022-02-01', 30.00), (4, '2022-02-15', 35.00), (5, '2022-03-01', 40.00), (6, '2022-03-15', 45.00);
What is the maximum pro bono hours for each month in the 'pro_bono' table, grouped by month?
SELECT EXTRACT(MONTH FROM date) as month, MAX(hours) FROM pro_bono GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE MalariaData (Country VARCHAR(50), Infections INT, Population INT); INSERT INTO MalariaData (Country, Infections, Population) VALUES ('Kenya', 15000, 53000000), ('Tanzania', 20000, 61000000);
What is the infection rate for malaria in Sub-Saharan Africa?
SELECT Country, (Infections / Population) * 100000 AS InfectionRate FROM MalariaData WHERE Country IN ('Kenya', 'Tanzania');
gretelai_synthetic_text_to_sql
CREATE TABLE menu (id INT, name TEXT, category TEXT, calories INT, is_vegan BOOLEAN); INSERT INTO menu (id, name, category, calories, is_vegan) VALUES (1, 'Chickpea Curry', 'Entrée', 800, true); INSERT INTO menu (id, name, category, calories, is_vegan) VALUES (2, 'Quinoa Salad', 'Side', 400, true); INSERT INTO menu (id...
What is the minimum and maximum calorie count for all vegan dishes in the menu table?
SELECT MIN(calories), MAX(calories) FROM menu WHERE is_vegan = true;
gretelai_synthetic_text_to_sql
CREATE TABLE DigitalExhibits (ExhibitID INT, Title VARCHAR(50), Curator VARCHAR(50)); INSERT INTO DigitalExhibits (ExhibitID, Title, Curator) VALUES (1, 'Digital Art Museum', 'Alice Johnson'); INSERT INTO DigitalExhibits (ExhibitID, Title, Curator) VALUES (2, 'Virtual Reality Experience', 'Bob Smith');
List all digital exhibits along with their respective curators.
SELECT DigitalExhibits.Title, DigitalExhibits.Curator FROM DigitalExhibits;
gretelai_synthetic_text_to_sql
CREATE TABLE product_launches(product_id INT, product_type VARCHAR(20), launch_date DATE, vegan BOOLEAN); INSERT INTO product_launches(product_id, product_type, launch_date, vegan) VALUES(1, 'Cleanser', '2020-01-01', TRUE), (2, 'Moisturizer', '2019-05-15', FALSE);
Display the number of vegan skincare products launched before 2021
SELECT COUNT(*) FROM product_launches WHERE product_type LIKE 'Skincare%' AND vegan = TRUE AND YEAR(launch_date) < 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE military_technology (id INT, name VARCHAR(255), technology_type VARCHAR(255), development_budget DECIMAL(10,2));INSERT INTO military_technology (id, name, technology_type, development_budget) VALUES (1, 'F-35', 'Fighter Jet', 30000000.00), (2, 'M1 Abrams', 'Tank', 15000000.00), (3, 'Patriot', 'Missile Syst...
Update the military technology with ID 1 to have a new technology type and increase its development budget by 10%.
UPDATE military_technology SET technology_type = '5th Generation Fighter Jet', development_budget = development_budget * 1.10 WHERE id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE MarineSpecies (id INT PRIMARY KEY, species VARCHAR(255), population INT, conservation_status VARCHAR(255)); INSERT INTO MarineSpecies (id, species, population, conservation_status) VALUES (1, 'Bottlenose Dolphin', 600000, 'Least Concern'), (2, 'Blue Whale', 12000, 'Endangered');
What is the average population of endangered marine species?
SELECT AVG(population) FROM MarineSpecies WHERE conservation_status = 'Endangered';
gretelai_synthetic_text_to_sql
CREATE TABLE Aircraft (id INT, model VARCHAR(255), manufacturer VARCHAR(255), year_manufactured INT, total_flight_hours INT); INSERT INTO Aircraft (id, model, manufacturer, year_manufactured, total_flight_hours) VALUES (1, 'B747', 'Boeing', 1990, 50000); INSERT INTO Aircraft (id, model, manufacturer, year_manufactured,...
What is the average total flight hours for aircraft manufactured by Boeing?
SELECT AVG(total_flight_hours) FROM Aircraft WHERE manufacturer = 'Boeing';
gretelai_synthetic_text_to_sql
CREATE TABLE Bear_Population (id INT, species VARCHAR(10), population INT); CREATE TABLE Conservation_Efforts (id INT, species VARCHAR(10), efforts INT);
Find the total number of polar bears in the 'Bear_Population' table and the 'Conservation_Efforts' table, then sum the results.
SELECT SUM(population) FROM Bear_Population WHERE species = 'Polar Bear' UNION ALL SELECT SUM(efforts) FROM Conservation_Efforts WHERE species = 'Polar Bear'
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (id VARCHAR(20), name VARCHAR(20)); INSERT INTO vessels (id, name) VALUES ('VES004', 'VESSEL004'), ('VES005', 'VESSEL005'); CREATE TABLE cargo (id INT, vessel_id VARCHAR(20), weight INT); INSERT INTO cargo (id, vessel_id, weight) VALUES (1, 'VES004', 12000), (2, 'VES004', 15000), (3, 'VES004', 1400...
What is the maximum cargo weight for VESSEL004
SELECT MAX(weight) FROM cargo WHERE vessel_id = 'VES004';
gretelai_synthetic_text_to_sql
CREATE TABLE founders (id INT, company_id INT, gender VARCHAR(10), community_type VARCHAR(255)); CREATE TABLE companies (id INT, industry VARCHAR(255)); INSERT INTO founders SELECT 1, 1, 'Female', 'Rural'; INSERT INTO founders SELECT 2, 2, 'Male', 'Urban'; INSERT INTO founders SELECT 3, 3, 'Female', 'Rural'; INSERT INT...
Count the number of startups founded by women from rural communities in the agriculture sector
SELECT COUNT(DISTINCT companies.id) FROM founders JOIN companies ON founders.company_id = companies.id WHERE companies.industry = 'Agriculture' AND founders.gender = 'Female' AND founders.community_type = 'Rural';
gretelai_synthetic_text_to_sql
CREATE TABLE MentalHealthFacilities (Id INT, Area VARCHAR(255), HealthEquityRating INT); INSERT INTO MentalHealthFacilities (Id, Area, HealthEquityRating) VALUES (1, 'Urban', 8); INSERT INTO MentalHealthFacilities (Id, Area, HealthEquityRating) VALUES (2, 'Rural', 7); INSERT INTO MentalHealthFacilities (Id, Area, Healt...
What is the minimum health equity rating for mental health facilities in urban areas?
SELECT MIN(HealthEquityRating) FROM MentalHealthFacilities WHERE Area = 'Urban';
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (VolunteerID INT, VolunteerName TEXT); INSERT INTO Volunteers (VolunteerID, VolunteerName) VALUES (1, 'Gabriela'), (2, 'Hamza'), (3, 'Isabella'); CREATE TABLE Programs (ProgramID INT, ProgramName TEXT); INSERT INTO Programs (ProgramID, ProgramName) VALUES (1, 'Education'), (2, 'Health'), (3, 'Su...
How many unique volunteers have participated in programs with a total cost of supplies over $10,000?
SELECT COUNT(DISTINCT Volunteers.VolunteerID) AS TotalVolunteers FROM Volunteers INNER JOIN Programs ON Volunteers.VolunteerID = Programs.ProgramID INNER JOIN ProgramSupplies ON Programs.ProgramID = ProgramSupplies.ProgramID INNER JOIN Supplies ON ProgramSupplies.SupplyID = Supplies.SupplyID GROUP BY Programs.ProgramID...
gretelai_synthetic_text_to_sql
CREATE TABLE consumers (consumer_id INT, product_name VARCHAR(50)); INSERT INTO consumers (consumer_id, product_name) VALUES (1, 'Clean Slate'), (2, 'Eye Have You'), (3, 'Clean Slate'), (4, 'Clean Slate');
Find the number of unique consumers who purchased both a cruelty-free product and a product not certified as cruelty-free.
SELECT COUNT(DISTINCT consumers.consumer_id) FROM consumers JOIN products ON consumers.product_name = products.product_name WHERE products.is_cruelty_free = true AND consumers.consumer_id IN (SELECT consumer_id FROM consumers WHERE product_name NOT IN (SELECT product_name FROM products WHERE is_cruelty_free = true));
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (vessel_id INT, vessel_name VARCHAR(50), flag_state VARCHAR(50)); CREATE TABLE voyages (voyage_id INT, vessel_id INT, voyage_start_date DATE, voyage_end_date DATE); INSERT INTO vessels VALUES (1, 'MSC Maya', 'Panama'); INSERT INTO voyages VALUES (1, 1, '2023-01-01', '2023-01-15'); INSERT INTO voyag...
How many voyages were completed by each vessel in the first half of 2023?
SELECT vessel_name, COUNT(*) as num_voyages FROM voyages JOIN vessels ON voyages.vessel_id = vessels.vessel_id WHERE EXTRACT(YEAR FROM voyage_start_date) = 2023 AND EXTRACT(MONTH FROM voyage_start_date) <= 6 GROUP BY vessel_name;
gretelai_synthetic_text_to_sql
CREATE TABLE vehicle_safety (id INT, make VARCHAR(50), model VARCHAR(50), type VARCHAR(50), mpg FLOAT);
What is the average miles per gallon (MPG) for electric vehicles in the vehicle_safety table?
SELECT AVG(mpg) FROM vehicle_safety WHERE type = 'Electric';
gretelai_synthetic_text_to_sql
CREATE TABLE blockchain_transactions (transaction_id INT PRIMARY KEY, sender VARCHAR(255), receiver VARCHAR(255), timestamp TIMESTAMP, amount DECIMAL(10,2)); INSERT INTO blockchain_transactions (transaction_id, sender, receiver, timestamp, amount) VALUES (4, 'David', 'Eve', '2022-01-04 18:00:00', 70.00);
Who received the most funds in blockchain transactions during the week of January 1, 2022?
SELECT receiver, SUM(amount) as total_received FROM blockchain_transactions WHERE timestamp BETWEEN '2022-01-01 00:00:00' AND '2022-01-07 23:59:59' GROUP BY receiver ORDER BY total_received DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Artifacts (ArtifactID INT, ArtifactType VARCHAR(50), Quantity INT); INSERT INTO Artifacts (ArtifactID, ArtifactType, Quantity) VALUES (1, 'Pottery', 25), (2, 'Tools', 12), (3, 'Pottery', 30);
Insert new artifact types and quantities?
INSERT INTO Artifacts (ArtifactID, ArtifactType, Quantity) VALUES (4, 'Jewelry', 15), (5, 'Beads', 20);
gretelai_synthetic_text_to_sql
CREATE TABLE SupplyChainTransparency(supplier_id INT, supplier_country VARCHAR(50), is_organic BOOLEAN, is_vegan BOOLEAN, avg_rating FLOAT);
What is the average rating for suppliers in the SupplyChainTransparency table who supply both organic and vegan products?
SELECT AVG(avg_rating) FROM SupplyChainTransparency WHERE is_organic = TRUE AND is_vegan = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE VesselArrivals (ID INT, VesselName VARCHAR(50), ArrivalPort VARCHAR(50), ArrivalDate DATE); INSERT INTO VesselArrivals (ID, VesselName, ArrivalPort, ArrivalDate) VALUES (1, 'Test Vessel 1', 'Tokyo', '2022-01-01'), (2, 'Test Vessel 2', 'Osaka', '2022-01-02'), (3, 'Test Vessel 3', 'Yokohama', '2022-01-03');
What is the number of vessels that arrived in Japan ports in the last 30 days?
SELECT COUNT(*) FROM VesselArrivals WHERE ArrivalDate >= DATEADD(day, -30, GETDATE()) AND ArrivalPort LIKE 'Japan%';
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, Age INT, Gender VARCHAR(10), GamesPlayed INT, Country VARCHAR(20));
What is the total number of games played by players in each country, and what is the percentage of female players in each country?
SELECT Country, COUNT(*) as TotalGames, COUNT(*) FILTER (WHERE Gender = 'Female') * 100.0 / COUNT(*) as PercentageFemale FROM Players GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE Artifacts (ArtifactID int, SiteID int, Name varchar(50), Description text, DateFound date);
Insert a new artifact into the Artifacts table
INSERT INTO Artifacts (ArtifactID, SiteID, Name, Description, DateFound) VALUES (1, 1, 'Artifact X', 'An interesting artifact', '2012-02-03');
gretelai_synthetic_text_to_sql