context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE SpaceMissions (id INT, name VARCHAR(100), leader VARCHAR(100), duration INT); INSERT INTO SpaceMissions (id, name, leader, duration) VALUES (1, 'Mission1', 'Aliyah Johnson', 300), (2, 'Mission2', 'Aliyah Johnson', 400);
What is the maximum duration of space missions led by Captain Aliyah Johnson?
SELECT MAX(duration) FROM SpaceMissions WHERE leader = 'Aliyah Johnson';
gretelai_synthetic_text_to_sql
CREATE TABLE sales_by_category (product_category VARCHAR(255), revenue FLOAT); INSERT INTO sales_by_category (product_category, revenue) VALUES ('Tops', 8000), ('Bottoms', 9000), ('Dresses', 10000), ('Shoes', 7000);
Get the total sales for each product category for the month of February 2022?
SELECT product_category, SUM(revenue) FROM sales_by_category WHERE revenue IS NOT NULL AND product_category IS NOT NULL AND STR_TO_DATE(CONCAT('02-', MONTH(NOW())), '%d-%m-%Y') = STR_TO_DATE('02-2022', '%d-%m-%Y') GROUP BY product_category;
gretelai_synthetic_text_to_sql
CREATE TABLE Organizations (OrgID INT, OrgName TEXT, OrgState TEXT, ProjectID INT, ProjectCompletionDate DATE);
List all projects and their completion dates from organizations located in 'TX'?
SELECT p.ProjectID, p.ProjectCompletionDate FROM Projects p INNER JOIN Organizations o ON p.OrgID = o.OrgID WHERE o.OrgState = 'TX';
gretelai_synthetic_text_to_sql
CREATE TABLE bank (id INT, name VARCHAR(50), type VARCHAR(50)); INSERT INTO bank (id, name, type) VALUES (1, 'Green Bank', 'Shariah-compliant'), (2, 'Fair Lending Bank', 'Socially Responsible'); CREATE TABLE loans (bank_id INT, amount DECIMAL(10,2), type VARCHAR(50)); INSERT INTO loans (bank_id, amount, type) VALUES (1, 5000.00, 'Shariah-compliant'), (1, 6000.00, 'Shariah-compliant'), (2, 8000.00, 'Socially Responsible'), (2, 9000.00, 'Socially Responsible');
Calculate the percentage of Shariah-compliant loans issued by each bank out of the total loans issued?
SELECT bank_id, 100.0 * SUM(CASE WHEN type = 'Shariah-compliant' THEN amount ELSE 0 END) / SUM(amount) as shariah_loan_percentage FROM loans GROUP BY bank_id;
gretelai_synthetic_text_to_sql
CREATE TABLE production_costs (country VARCHAR(255), material VARCHAR(255), product VARCHAR(255), cost DECIMAL(10,2)); INSERT INTO production_costs (country, material, product, cost) VALUES ('Bangladesh', 'cotton', 't-shirt', 5.50);
What is the average production cost of cotton t-shirts in Bangladesh?
SELECT AVG(cost) FROM production_costs WHERE country = 'Bangladesh' AND material = 'cotton' AND product = 't-shirt';
gretelai_synthetic_text_to_sql
CREATE TABLE organic_farms (id INT, name VARCHAR(30), location VARCHAR(30), area DECIMAL(5,2), is_organic BOOLEAN);
What is the total area of organic farms in the 'organic_farms' table?
SELECT SUM(area) FROM organic_farms WHERE is_organic = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas (name VARCHAR(255), area_id INT, depth FLOAT, size INT, country VARCHAR(255)); INSERT INTO marine_protected_areas (name, area_id, depth, size, country) VALUES ('Bermuda Park', 21, 50, 24000, 'Bermuda'), ('Saba Bank National Park', 22, 20, 270000, 'Netherlands');
What is the minimum size of marine protected areas in the Atlantic Ocean?
SELECT MIN(size) FROM marine_protected_areas WHERE country = 'Atlantic Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE factories (factory_id INT, department VARCHAR(20));CREATE TABLE workers (worker_id INT, factory_id INT, salary DECIMAL(5,2), department VARCHAR(20)); INSERT INTO factories (factory_id, department) VALUES (1, 'textile'), (2, 'metal'), (3, 'electronics'); INSERT INTO workers (worker_id, factory_id, salary, department) VALUES (1, 1, 35000, 'textile'), (2, 1, 36000, 'textile'), (3, 2, 45000, 'metal'), (4, 2, 46000, 'metal'), (5, 3, 55000, 'electronics');
Insert a new record for a worker with ID 6 in the 'electronics' department at factory 3 with a salary of 60000.
INSERT INTO workers (worker_id, factory_id, salary, department) VALUES (6, 3, 60000, 'electronics');
gretelai_synthetic_text_to_sql
CREATE TABLE museum_operations (id INT, museum_name VARCHAR(50), location VARCHAR(50), annual_visitors INT); INSERT INTO museum_operations (id, museum_name, location, annual_visitors) VALUES (1, 'Metropolitan Museum of Art', 'New York', 7000000); INSERT INTO museum_operations (id, museum_name, location, annual_visitors) VALUES (2, 'British Museum', 'London', 6200000); INSERT INTO museum_operations (id, museum_name, location, annual_visitors) VALUES (3, 'Louvre Museum', 'Paris', 9000000);
What is the most visited museum in each city?
SELECT museum_name, location, annual_visitors, ROW_NUMBER() OVER(PARTITION BY location ORDER BY annual_visitors DESC) as ranking FROM museum_operations;
gretelai_synthetic_text_to_sql
CREATE TABLE readers (id INT, name TEXT, age INT, city TEXT, interest TEXT); INSERT INTO readers (id, name, age, city, interest) VALUES (1, 'John Doe', 35, 'Los Angeles', 'sports');
What is the average age of readers who prefer sports news in the city of Los Angeles?
SELECT AVG(age) FROM readers WHERE city = 'Los Angeles' AND interest = 'sports';
gretelai_synthetic_text_to_sql
CREATE TABLE water_usage (id INT, country VARCHAR(50), year INT, usage FLOAT); INSERT INTO water_usage (id, country, year, usage) VALUES (1, 'Canada', 2018, 150.3), (2, 'Canada', 2019, 155.1), (3, 'Mexico', 2018, 200.5), (4, 'Mexico', 2019, 210.0);
What is the average water usage per household in Canada for the year 2018?
SELECT AVG(usage) FROM water_usage WHERE country = 'Canada' AND year = 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE labor_hours (labor_id INT, hours FLOAT, city VARCHAR(50), year INT, sustainable BOOLEAN); INSERT INTO labor_hours (labor_id, hours, city, year, sustainable) VALUES (7, 150, 'Los Angeles', 2022, FALSE); INSERT INTO labor_hours (labor_id, hours, city, year, sustainable) VALUES (8, 180, 'Los Angeles', 2022, FALSE);
How many labor hours were spent on non-sustainable building practices in the city of Los Angeles in 2022?
SELECT SUM(hours) FROM labor_hours WHERE city = 'Los Angeles' AND year = 2022 AND sustainable = FALSE;
gretelai_synthetic_text_to_sql
CREATE TABLE programs (id INT, name VARCHAR(255)); INSERT INTO programs (id, name) VALUES (1, 'Education'), (2, 'Health'), (3, 'Environment'); CREATE TABLE volunteers (id INT, program_id INT, volunteer_date DATE); INSERT INTO volunteers (id, program_id, volunteer_date) VALUES (1, 1, '2020-01-01'), (2, 1, '2020-02-01'), (3, 2, '2020-03-01');
What is the total number of volunteers for each program in the year 2020?
SELECT v.program_id, COUNT(*) as total_volunteers FROM volunteers v WHERE YEAR(v.volunteer_date) = 2020 GROUP BY v.program_id;
gretelai_synthetic_text_to_sql
CREATE TABLE financial_wellbeing_ph (client_id INT, financial_wellbeing_score INT, country VARCHAR(50)); INSERT INTO financial_wellbeing_ph (client_id, financial_wellbeing_score, country) VALUES (1, 7, 'Philippines'), (2, 3, 'Philippines'), (3, 6, 'Philippines');
Update the financial wellbeing score of clients in the Philippines to 1 point higher than their current score, if their score is currently above 6.
WITH updated_scores AS (UPDATE financial_wellbeing_ph SET financial_wellbeing_score = financial_wellbeing_score + 1 WHERE country = 'Philippines' AND financial_wellbeing_score > 6) SELECT * FROM updated_scores;
gretelai_synthetic_text_to_sql
CREATE TABLE IF NOT EXISTS tourists (id INT PRIMARY KEY, name TEXT, country TEXT, daily_spending FLOAT, visit_date DATE); INSERT INTO tourists (id, name, country, daily_spending, visit_date) VALUES (1, 'John Doe', 'USA', 1200, '2020-07-01'), (2, 'Jane Smith', 'Canada', 800, '2020-10-15'), (3, 'Mike Johnson', 'Japan', 2000, '2020-02-20');
How many international tourists visited Japan in 2020 and spent more than $1000 per day on average?
SELECT COUNT(*) FROM tourists WHERE country = 'Japan' AND EXTRACT(YEAR FROM visit_date) = 2020 AND daily_spending > 1000;
gretelai_synthetic_text_to_sql
CREATE TABLE inventory (item_id INT, inventory_amount INT); INSERT INTO inventory VALUES (1, 500), (2, 300), (3, 700);
Calculate the inventory turnover for a specific item
SELECT inventory.item_id, sales.sales_amount / inventory.inventory_amount AS inventory_turnover FROM inventory JOIN sales ON inventory.item_id = sales.item_id WHERE inventory.item_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE employees (id INT PRIMARY KEY, first_name VARCHAR(50), last_name VARCHAR(50), department VARCHAR(50), hire_date DATE);
Update an employee's department in the 'employees' table
UPDATE employees SET department = 'Human Resources' WHERE id = 101;
gretelai_synthetic_text_to_sql
CREATE TABLE ports (port_id INT, port_name TEXT, country TEXT, unloaded_weight FLOAT, vessel_flag TEXT); INSERT INTO ports (port_id, port_name, country, unloaded_weight, vessel_flag) VALUES (1, 'Hong Kong', 'China', 123456.78, 'Panama'), (2, 'Hong Kong', 'China', 987654.32, 'Liberia'), (3, 'Hong Kong', 'China', 321897.54, 'Marshall Islands');
What is the total unloaded cargo weight in the port of Hong Kong for each flag?
SELECT vessel_flag, SUM(unloaded_weight) AS total_weight FROM ports WHERE port_name = 'Hong Kong' GROUP BY vessel_flag;
gretelai_synthetic_text_to_sql
CREATE TABLE landfill_capacity(year INT, landfill VARCHAR(255), capacity INT); INSERT INTO landfill_capacity VALUES (2018, 'Landfill A', 100000), (2018, 'Landfill B', 150000), (2018, 'Landfill C', 200000), (2019, 'Landfill A', 110000), (2019, 'Landfill B', 155000), (2019, 'Landfill C', 210000), (2020, 'Landfill A', 120000), (2020, 'Landfill B', 160000), (2020, 'Landfill C', 220000);
What is the total capacity of each landfill in 2020?
SELECT landfill, SUM(capacity) FROM landfill_capacity WHERE year = 2020 GROUP BY landfill;
gretelai_synthetic_text_to_sql
CREATE TABLE Sites (SiteID INT, SiteName TEXT); INSERT INTO Sites (SiteID, SiteName) VALUES (1, 'Site-A'), (2, 'Site-B'), (3, 'Site-C'); CREATE TABLE Artifacts (ArtifactID INT, ArtifactName TEXT, SiteID INT, Age INT, Era TEXT); INSERT INTO Artifacts (ArtifactID, ArtifactName, SiteID, Age, Era) VALUES (1, 'Pottery Shard', 1, 1000, 'Post-Columbian'), (2, 'Bronze Arrowhead', 2, 800, 'Iron Age'), (3, 'Flint Tool', 3, 2000, 'Stone Age'), (4, 'Ancient Coin', 1, 1500, 'Pre-Columbian'), (5, 'Stone Hammer', 2, 3000, 'Pre-Columbian');
Which excavation sites have at least 3 instances of artifacts from the pre-Columbian era?
SELECT Sites.SiteName, COUNT(Artifacts.ArtifactID) AS Quantity FROM Artifacts INNER JOIN Sites ON Artifacts.SiteID = Sites.SiteID WHERE Artifacts.Era = 'Pre-Columbian' GROUP BY Sites.SiteName HAVING Quantity >= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (id INT, name TEXT, type TEXT); CREATE TABLE vessel_operations (id INT, vessel_id INT, protected_area_id INT); CREATE TABLE marine_protected_areas (id INT, name TEXT); INSERT INTO vessels (id, name, type) VALUES (1, 'Fishing Vessel 1', 'Fishing'), (2, 'Research Vessel 1', 'Research'), (3, 'Tourist Vessel 1', 'Tourism'); INSERT INTO vessel_operations (id, vessel_id, protected_area_id) VALUES (1, 1, 1), (2, 2, 2), (3, 3, 1); INSERT INTO marine_protected_areas (id, name) VALUES (1, 'Galapagos Marine Reserve'), (2, 'Great Barrier Reef Marine Park');
List all vessels that operate in marine protected areas?
SELECT vessels.name FROM vessels INNER JOIN vessel_operations ON vessels.id = vessel_operations.vessel_id INNER JOIN marine_protected_areas ON vessel_operations.protected_area_id = marine_protected_areas.id;
gretelai_synthetic_text_to_sql
CREATE TABLE Attendees (AttendeeID INT, Age INT, Gender VARCHAR(10));CREATE TABLE Programs (ProgramID INT, ProgramName VARCHAR(20), ProgramCategory VARCHAR(20));CREATE TABLE Attendance (AttendeeID INT, ProgramID INT);
What is the average age of attendees who identify as 'Female' and have attended 'Music' programs, and how many unique programs have they attended?
SELECT AVG(A.Age) AS Avg_Age, COUNT(DISTINCT A.ProgramID) AS Num_Unique_Programs FROM Attendees A INNER JOIN Attendance AT ON A.AttendeeID = AT.AttendeeID INNER JOIN Programs P ON AT.ProgramID = P.ProgramID WHERE A.Gender = 'Female' AND P.ProgramCategory = 'Music';
gretelai_synthetic_text_to_sql
CREATE TABLE case_outcomes (case_id INT, outcome TEXT, precedent TEXT); CREATE TABLE case_assignments (case_id INT, attorney_id INT, PRIMARY KEY (case_id, attorney_id)); CREATE TABLE attorney_billing (attorney_id INT, hours_billed INT, PRIMARY KEY (attorney_id));
Display the average number of hours billed for cases with outcome 'Won'
SELECT AVG(hours_billed) as avg_hours_billed FROM attorney_billing JOIN case_assignments ON attorney_billing.attorney_id = case_assignments.attorney_id JOIN case_outcomes ON case_assignments.case_id = case_outcomes.case_id WHERE outcome = 'Won';
gretelai_synthetic_text_to_sql
CREATE TABLE movies (id INT, title VARCHAR(100), genre VARCHAR(50), release_year INT, production_budget INT); INSERT INTO movies (id, title, genre, release_year, production_budget) VALUES (1, 'MovieA', 'Action', 2005, 15000000); INSERT INTO movies (id, title, genre, release_year, production_budget) VALUES (2, 'MovieB', 'Action', 2002, 20000000);
What is the average production budget for action movies released between 2000 and 2010?
SELECT AVG(production_budget) FROM movies WHERE genre = 'Action' AND release_year BETWEEN 2000 AND 2010;
gretelai_synthetic_text_to_sql
CREATE TABLE supplier_deliveries (supplier VARCHAR(50), deliveries INT, is_sustainable BOOLEAN); INSERT INTO supplier_deliveries (supplier, deliveries, is_sustainable) VALUES ('GreenGrowers', 15, true), ('OrganicOrigins', 20, true); CREATE VIEW sustainable_supplier_deliveries AS SELECT supplier, deliveries FROM supplier_deliveries WHERE is_sustainable = true;
What was the maximum delivery frequency of a sustainable supplier?
SELECT MAX(deliveries) FROM sustainable_supplier_deliveries;
gretelai_synthetic_text_to_sql
CREATE TABLE articles (id INT, title TEXT, content TEXT, publication_date DATE, newspaper TEXT, category TEXT);
What is the total number of articles published in "The Hindu" in the "Politics" news category in 2021?
SELECT COUNT(*) FROM articles WHERE newspaper = 'The Hindu' AND category = 'Politics' AND YEAR(publication_date) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE players (id INT, name VARCHAR(50), country VARCHAR(50), level INT);
Add a new player 'Mateo' from 'Argentina' with level 15 to the 'players' table
INSERT INTO players (name, country, level) VALUES ('Mateo', 'Argentina', 15);
gretelai_synthetic_text_to_sql
CREATE TABLE Hospitals (HospitalID INT, HospitalName VARCHAR(50), State VARCHAR(20), NumberOfBeds INT); INSERT INTO Hospitals (HospitalID, HospitalName, State, NumberOfBeds) VALUES (1, 'Rural General Hospital', 'California', 75); INSERT INTO Hospitals (HospitalID, HospitalName, State, NumberOfBeds) VALUES (2, 'Mountain View Medical Center', 'Colorado', 95);
List the number of hospitals in each state that have less than 100 beds.
SELECT State, COUNT(*) FROM Hospitals WHERE NumberOfBeds < 100 GROUP BY State;
gretelai_synthetic_text_to_sql
CREATE TABLE Members (MemberID INT, Age INT, JoinDate DATE, MembershipType VARCHAR(20), PaymentAmount DECIMAL(5,2)); INSERT INTO Members (MemberID, Age, JoinDate, MembershipType, PaymentAmount) VALUES (1, 27, '2021-01-05', 'Premium', 59.99), (2, 31, '2021-03-18', 'Basic', 29.99), (3, 26, '2021-08-14', 'Premium', 59.99);
What is the total revenue generated from members in the age range of 25-34 for the year 2021?
SELECT SUM(PaymentAmount) FROM Members WHERE YEAR(JoinDate) = 2021 AND Age BETWEEN 25 AND 34;
gretelai_synthetic_text_to_sql
CREATE TABLE sustainability_metrics (id INT, region VARCHAR(255), co2_emissions INT); INSERT INTO sustainability_metrics (id, region, co2_emissions) VALUES (1, 'South America', 130), (2, 'Europe', 100), (3, 'Asia', 150);
What are the total CO2 emissions for garment production in each region?
SELECT region, SUM(co2_emissions) as total_co2_emissions FROM sustainability_metrics GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE regions (id INT, name TEXT, climate TEXT); INSERT INTO regions (id, name, climate) VALUES (1, 'Amazon', 'Tropical rainforest'), (2, 'Andes', 'Alpine tundra'), (3, 'Pampas', 'Humid subtropical'); CREATE TABLE climate_data (id INT, region_id INT, rainfall INT, year INT); INSERT INTO climate_data (id, region_id, rainfall, year) VALUES (1, 1, 1500, 2010), (2, 1, 1600, 2011), (3, 2, 300, 2010), (4, 2, 350, 2011), (5, 3, 800, 2010), (6, 3, 900, 2011);
Find the average annual rainfall for 'indigenous food systems' in 'South America'.
SELECT AVG(rainfall) FROM climate_data JOIN regions ON climate_data.region_id = regions.id WHERE regions.name = 'indigenous food systems' AND climate_data.year BETWEEN 2010 AND 2011;
gretelai_synthetic_text_to_sql
CREATE TABLE CourtCases (Id INT, CourtLocation VARCHAR(50), CaseNumber INT, Disposition VARCHAR(50), DismissalDate DATE); INSERT INTO CourtCases (Id, CourtLocation, CaseNumber, Disposition, DismissalDate) VALUES (1, 'NY Supreme Court', 12345, 'Dismissed', '2021-02-15'), (2, 'TX District Court', 67890, 'Proceeding', '2020-12-21'), (3, 'CA Superior Court', 23456, 'Dismissed', '2021-08-01');
Show the number of cases that were dismissed due to lack of evidence in each court location, for the past year.
SELECT CourtLocation, COUNT(*) as NumCases FROM CourtCases WHERE Disposition = 'Dismissed' AND DismissalDate >= DATEADD(year, -1, GETDATE()) AND Disposition = 'Dismissed' GROUP BY CourtLocation;
gretelai_synthetic_text_to_sql
CREATE TABLE ports (id INT, name TEXT, handling_time INT); INSERT INTO ports (id, name, handling_time) VALUES (5, 'Port of New York', 120), (6, 'Port of Los Angeles', 180), (7, 'Port of Hong Kong', 130);
What is the minimum cargo handling time for 'Port of New York'?
SELECT MIN(handling_time) FROM ports WHERE name = 'Port of New York';
gretelai_synthetic_text_to_sql
CREATE TABLE disaster_response_teams (id INT, name VARCHAR(100), region VARCHAR(50)); INSERT INTO disaster_response_teams (id, name, region) VALUES (1, 'Team A', 'Asia'), (2, 'Team B', 'Africa'), (3, 'Team C', 'Asia');
How many disaster response teams are there in Asia?
SELECT COUNT(*) FROM disaster_response_teams WHERE region = 'Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE Policyholders (PolicyholderID INT, Age INT, Region VARCHAR(10)); CREATE TABLE Policies (PolicyID INT, PolicyholderID INT, Coverage VARCHAR(20), Region VARCHAR(10)); INSERT INTO Policyholders (PolicyholderID, Age, Region) VALUES (1, 35, 'West'); INSERT INTO Policyholders (PolicyholderID, Age, Region) VALUES (2, 45, 'East'); INSERT INTO Policies (PolicyID, PolicyholderID, Coverage, Region) VALUES (101, 1, 'Basic', 'North'); INSERT INTO Policies (PolicyID, PolicyholderID, Coverage, Region) VALUES (102, 2, 'Premium', 'South');
List all policies with a coverage type of 'Basic' and their corresponding policyholders' ages.
SELECT Policies.Coverage, Policyholders.Age FROM Policies INNER JOIN Policyholders ON Policies.PolicyholderID = Policyholders.PolicyholderID WHERE Policies.Coverage = 'Basic';
gretelai_synthetic_text_to_sql
CREATE TABLE ArtistData (id INT, artist_name VARCHAR(50), country VARCHAR(50)); INSERT INTO ArtistData (id, artist_name, country) VALUES (1, 'Adele', 'England'), (2, 'Santana', 'Mexico'), (3, 'Hendrix', 'USA'), (4, 'Fela', 'Nigeria'), (5, 'Gilberto', 'Brazil');
How many artists in the database are from Africa or South America?
SELECT COUNT(*) FROM ArtistData WHERE country IN ('Africa', 'South America');
gretelai_synthetic_text_to_sql
CREATE TABLE threat_actors (id INT, category VARCHAR(50), incident_date DATE); INSERT INTO threat_actors (id, category, incident_date) VALUES (1, 'Nation State', '2022-01-01'), (2, 'Cyber Crime', '2022-02-05'), (3, 'Hacktivist', '2022-03-10');
What are the top 5 threat actor categories with the most incidents in the last 6 months?
SELECT category, COUNT(*) as incident_count FROM threat_actors WHERE incident_date >= DATEADD(month, -6, GETDATE()) GROUP BY category ORDER BY incident_count DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE garments (id INT, name VARCHAR(100), price DECIMAL(5,2), category VARCHAR(50));
List all garments in the 'Tops' category with a price greater than 25.00 from the garments table
SELECT * FROM garments WHERE category = 'Tops' AND price > 25.00;
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (VolunteerID INT, VolunteerName TEXT, Hours INT, Country TEXT); INSERT INTO Volunteers (VolunteerID, VolunteerName, Hours, Country) VALUES (3, 'Adebayo Adewale', 60, 'Nigeria'), (4, 'Bukola Adewale', 90, 'Nigeria');
What is the total number of volunteer hours contributed by volunteers from Nigeria?
SELECT Country, SUM(Hours) FROM Volunteers WHERE Country = 'Nigeria' GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE jordan_donors (donor_id INT, donor_name VARCHAR(50), donation_amount INT, project_type VARCHAR(30)); INSERT INTO jordan_donors (donor_id, donor_name, donation_amount, project_type) VALUES (1, 'USAID', 100000, 'education'), (2, 'EU', 120000, 'health'), (3, 'UNESCO', 80000, 'education'); CREATE TABLE lebanon_donors (donor_id INT, donor_name VARCHAR(50), donation_amount INT, project_type VARCHAR(30)); INSERT INTO lebanon_donors (donor_id, donor_name, donation_amount, project_type) VALUES (1, 'USAID', 150000, 'education'), (2, 'EU', 180000, 'infrastructure'), (3, 'UNICEF', 90000, 'education');
Who are the top 3 donors supporting education projects in Jordan and Lebanon?
SELECT d1.donor_name, SUM(d1.donation_amount) AS total_donation FROM jordan_donors d1 INNER JOIN lebanon_donors d2 ON d1.donor_name = d2.donor_name WHERE d1.project_type = 'education' GROUP BY d1.donor_name ORDER BY total_donation DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE broadband_subscribers (subscriber_id INT, monthly_bill FLOAT, city VARCHAR(20)); INSERT INTO broadband_subscribers (subscriber_id, monthly_bill, city) VALUES (1, 60.5, 'Chicago'), (2, 70.3, 'Houston'), (3, 55.7, 'Chicago');
What is the total revenue generated from broadband subscribers in the city of Chicago?
SELECT SUM(monthly_bill) FROM broadband_subscribers WHERE city = 'Chicago';
gretelai_synthetic_text_to_sql
CREATE TABLE reporters (id INT, name VARCHAR(50), gender VARCHAR(10), age INT, country VARCHAR(50));
List the names and countries of all female news reporters who are over the age of 40.
SELECT name, country FROM reporters WHERE gender = 'female' AND age > 40;
gretelai_synthetic_text_to_sql
CREATE TABLE accommodation (student_id INT, accommodation_type TEXT, accommodation_date DATE); INSERT INTO accommodation (student_id, accommodation_type, accommodation_date) VALUES (1, 'Wheelchair Access', '2022-01-05'), (2, 'Assistive Technology', '2022-02-10'), (3, 'Note Taker', '2022-03-15'), (4, 'Wheelchair Access', '2022-04-20'); CREATE TABLE student (student_id INT, disability TEXT); INSERT INTO student (student_id, disability) VALUES (1, 'Mobility Impairment'), (2, 'Learning Disability'), (3, 'Mobility Impairment'), (4, 'Mobility Impairment');
What is the average number of accommodations per month for students with mobility impairments?
SELECT AVG(COUNT(*)) as avg_accommodations FROM accommodation WHERE student_id IN (SELECT student_id FROM student WHERE disability = 'Mobility Impairment') GROUP BY DATE_TRUNC('month', accommodation_date);
gretelai_synthetic_text_to_sql
CREATE TABLE space_missions (id INT, mission_name VARCHAR(255), astronaut_name VARCHAR(255), duration INT); INSERT INTO space_missions (id, mission_name, astronaut_name, duration) VALUES (1, 'Apollo 11', 'Neil Armstrong', 195), (2, 'Apollo 12', 'Jane Foster', 244), (3, 'Ares 3', 'Mark Watney', 568), (4, 'Apollo 18', 'Anna Mitchell', 205);
What is the total duration of space missions led by female astronauts?
SELECT SUM(duration) FROM space_missions WHERE astronaut_name IN ('Jane Foster', 'Anna Mitchell');
gretelai_synthetic_text_to_sql
CREATE TABLE community_education (id INT PRIMARY KEY, program_name VARCHAR(255), location VARCHAR(255), region VARCHAR(255));
Calculate the total number of community education programs in each region
SELECT location as region, COUNT(*) as total_programs FROM community_education GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE Drug_Approvals(drug VARCHAR(20), approval_year INT, company VARCHAR(20));CREATE TABLE Drug_Sales(drug VARCHAR(20), year INT, sales DECIMAL(10,2));INSERT INTO Drug_Approvals VALUES('DrugA', 2019, 'PharmaCorp');INSERT INTO Drug_Sales VALUES('DrugA', 2019, 2000000.00);
Which drug was approved by the FDA in 2019 with the highest sales?
SELECT a.drug, MAX(s.sales) FROM Drug_Approvals a INNER JOIN Drug_Sales s ON a.drug = s.drug WHERE a.approval_year = 2019 GROUP BY a.drug;
gretelai_synthetic_text_to_sql
CREATE TABLE entree_orders (order_id INT, entree VARCHAR(255), entree_quantity INT, entree_price DECIMAL(10,2), order_date DATE); INSERT INTO entree_orders VALUES (1, 'Spaghetti', 2, 20.00, '2022-01-01'), (2, 'Pizza', 1, 15.00, '2022-01-03'), (3, 'Pizza', 2, 15.00, '2022-01-02');
What is the total revenue for each entree in the current month?
SELECT entree, SUM(entree_quantity * entree_price) FROM entree_orders WHERE order_date >= DATEADD(month, 0, GETDATE()) GROUP BY entree;
gretelai_synthetic_text_to_sql
CREATE TABLE environmental_impact_table (record_id INT, chemical_id INT, environmental_impact_float);
Show the environmental impact of 'Ethyl Acetate' and 'Methyl Ethyl Ketone' in the environmental_impact_table
SELECT chemical_id, environmental_impact_float FROM environmental_impact_table WHERE chemical_id IN (1, 2);
gretelai_synthetic_text_to_sql
CREATE TABLE space_missions(id INT, mission_name VARCHAR(50), leader_name VARCHAR(50), leader_country VARCHAR(50), duration INT); INSERT INTO space_missions VALUES(1, 'Apollo 11', 'Neil Armstrong', 'USA', 195.), (2, 'Gemini 12', 'James Lovell', 'USA', 94.);
What is the average duration of space missions led by astronauts from the USA?
SELECT AVG(duration) FROM space_missions WHERE leader_country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE students (id INT, name VARCHAR(255)); CREATE TABLE assignments (id INT, student_id INT, course_id INT, submitted_date DATE); INSERT INTO students (id, name) VALUES (1, 'Student A'), (2, 'Student B'), (3, 'Student C'); INSERT INTO assignments (id, student_id, course_id, submitted_date) VALUES (1, 1, 1, '2021-09-01'), (2, 2, 1, NULL);
Which students have not submitted any assignments in any course?
SELECT s.name FROM students s LEFT JOIN assignments a ON s.id = a.student_id WHERE a.submitted_date IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels (ID VARCHAR(20), Name VARCHAR(20), Type VARCHAR(20), MaxSpeed FLOAT); INSERT INTO Vessels VALUES ('V006', 'Vessel F', 'Cargo', 18.2), ('V007', 'Vessel G', 'Cargo', 16.3), ('V008', 'Vessel H', 'Passenger', 28.0);
How many vessels are there in total?
SELECT COUNT(*) FROM Vessels;
gretelai_synthetic_text_to_sql
CREATE SCHEMA global_health; CREATE TABLE hospitals (id INT, name TEXT, location TEXT, capacity INT); INSERT INTO global_health.hospitals (id, name, location, capacity) VALUES (1, 'Hospital A', 'City A', 200), (2, 'Hospital B', 'City B', 300), (3, 'Hospital C', 'City C', 150), (4, 'Hospital D', 'City D', 250), (5, 'Hospital E', 'City E', 400);
What is the minimum capacity of hospitals in the 'global_health' schema?
SELECT MIN(capacity) FROM global_health.hospitals;
gretelai_synthetic_text_to_sql
CREATE TABLE job_applications (id INT, applicant_name VARCHAR(50), date_applied DATE, underrepresented BOOLEAN);
How many job applications were received from underrepresented candidates in the past year?
SELECT COUNT(*) FROM job_applications WHERE underrepresented = TRUE AND date_applied >= DATEADD(year, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE SCHEMA canals; CREATE TABLE fish_farms (id INT, size FLOAT, location VARCHAR(25)); INSERT INTO fish_farms (id, size, location) VALUES (1, 15.2, 'europe'), (2, 28.5, 'europe'), (3, 42.3, 'europe');
What is the average size of fish farms in 'canals' schema located in 'europe'?
SELECT AVG(size) FROM canals.fish_farms WHERE location = 'europe';
gretelai_synthetic_text_to_sql
CREATE TABLE IncidentThreatLevel (IncidentID INT, IncidentType VARCHAR(50), ThreatLevel INT); INSERT INTO IncidentThreatLevel (IncidentID, IncidentType, ThreatLevel) VALUES (1, 'Phishing', 3), (2, 'Malware', 5), (3, 'Ransomware', 4), (4, 'SQL Injection', 2), (5, 'Insider Threat', 3), (6, 'Advanced Persistent Threat', 5), (7, 'Zero Day Exploit', 5), (8, 'Denial of Service', 4);
Update the threat level for all cybersecurity incidents related to a specific type of malware.
UPDATE IncidentThreatLevel SET ThreatLevel = 6 WHERE IncidentType = 'Malware';
gretelai_synthetic_text_to_sql
CREATE TABLE Policy (PolicyId INT, PolicyType VARCHAR(50), Premium DECIMAL(10,2), Region VARCHAR(50));
List the total premiums and number of policies for each policy type, along with the percentage of total premiums for each policy type.
SELECT PolicyType, COUNT(PolicyId) as PolicyCount, SUM(Premium) as TotalPremiums, (SUM(Premium) / (SELECT SUM(Premium) FROM Policy)) * 100 as PercentageOfTotalPremiums FROM Policy GROUP BY PolicyType;
gretelai_synthetic_text_to_sql
CREATE TABLE microfinance_clients (id INT, name VARCHAR(50), income FLOAT, city VARCHAR(50), country VARCHAR(50)); INSERT INTO microfinance_clients (id, name, income, city, country) VALUES (1, 'Ravi Kumar', 7000.00, 'Mumbai', 'India'), (2, 'Swati Singh', 8000.00, 'Delhi', 'India');
What is the average income for microfinance clients in India by city?
SELECT city, AVG(income) as avg_income FROM microfinance_clients WHERE country = 'India' GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE production(year INT, region VARCHAR(20), element VARCHAR(10), quantity INT); INSERT INTO production VALUES(2020, 'Asia', 'Holmium', 1200), (2020, 'Europe', 'Holmium', 800), (2020, 'Africa', 'Holmium', 400);
What is the percentage of Holmium production that comes from 'Asia' in 2020?
SELECT (SUM(CASE WHEN region = 'Asia' THEN quantity ELSE 0 END) / SUM(quantity)) * 100.0 FROM production WHERE element = 'Holmium' AND year = 2020
gretelai_synthetic_text_to_sql
CREATE TABLE machines (id INT PRIMARY KEY, name VARCHAR(255), type VARCHAR(255), status VARCHAR(255));
Drop the 'machines' table
DROP TABLE machines;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name VARCHAR(50));CREATE TABLE supplier_products (supplier_id INT, product_id INT);CREATE TABLE suppliers (supplier_id INT, supplier_name VARCHAR(50));
List all products and their suppliers
SELECT products.product_name, suppliers.supplier_name FROM products JOIN supplier_products ON products.product_id = supplier_products.product_id JOIN suppliers ON supplier_products.supplier_id = suppliers.supplier_id;
gretelai_synthetic_text_to_sql
CREATE TABLE patients (patient_id INT, patient_name TEXT, age INT, diagnosis TEXT, state TEXT); INSERT INTO patients (patient_id, patient_name, age, diagnosis, state) VALUES (2, 'Jane Doe', 55, 'Hypertension', 'Arizona');
Show the names and ages of patients who have been diagnosed with hypertension and are over 50 in rural Arizona.
SELECT patient_name, age FROM patients WHERE diagnosis = 'Hypertension' AND age > 50 AND state = 'Arizona';
gretelai_synthetic_text_to_sql
CREATE TABLE indian_ocean_fish (id INT, name VARCHAR(50), ph_level FLOAT); INSERT INTO indian_ocean_fish (id, name, ph_level) VALUES (1, 'Tuna', 8.1), (2, 'Marlin', 7.9), (3, 'Swordfish', 7.8), (4, 'Shark', 7.5);
What is the PH level for fish species in the Indian ocean?
SELECT name, ph_level FROM indian_ocean_fish;
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (DonationID INT, DonorFirstName TEXT, DonorLastName TEXT, DonationAmount DECIMAL); INSERT INTO Donations (DonationID, DonorFirstName, DonorLastName, DonationAmount) VALUES (1, 'Alex', 'Johnson', 75.00), (2, 'Anna', 'Williams', 100.00);
What is the total donation amount made by donors with the first name starting with 'A'?
SELECT SUM(DonationAmount) FROM Donations WHERE DonorFirstName LIKE 'A%';
gretelai_synthetic_text_to_sql
CREATE TABLE art_exhibitions (id INT, exhibition_type VARCHAR(20), attendance INT, attendee_age INT);
Update the attendance for a specific art exhibition where the exhibition type is modern and the attendee age is 25
UPDATE art_exhibitions SET attendance = 550 WHERE exhibition_type = 'modern' AND attendee_age = 25;
gretelai_synthetic_text_to_sql
CREATE TABLE agricultural_innovation_metrics (id INT PRIMARY KEY, metric_name VARCHAR(50), value DECIMAL(10, 2), measurement_date DATE);
What was the maximum value of the agricultural innovation metrics for the last quarter, by metric name?
SELECT metric_name, MAX(value) as max_value FROM agricultural_innovation_metrics WHERE measurement_date >= DATE_SUB(CURDATE(), INTERVAL 3 MONTH) GROUP BY metric_name;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists open_pedagogy_resources (id INT, course_id INT, type VARCHAR(50), link VARCHAR(100)); INSERT INTO open_pedagogy_resources (id, course_id, type, link) VALUES (2, 2, 'Blog Post', 'https://opensource.com/education/17/6/open-pedagogy-examples');
Add a new open pedagogy resource
INSERT INTO open_pedagogy_resources (id, course_id, type, link) VALUES (3, 3, 'Podcast', 'https://edunova.podbean.com/e/episode-1-open-pedagogy-and-the-future-of-education/');
gretelai_synthetic_text_to_sql
CREATE TABLE EmergencyTypes (Type VARCHAR(255)); INSERT INTO EmergencyTypes (Type) VALUES ('Fire'), ('Medical'), ('Police'); CREATE TABLE EmergencyResponses (ID INT, Type VARCHAR(255), Time FLOAT, Location VARCHAR(255)); INSERT INTO EmergencyResponses (ID, Type, Time, Location) VALUES (1, 'Fire', 6.5, 'San Francisco'), (2, 'Medical', 7.2, 'San Francisco'), (3, 'Police', 4.9, 'San Francisco');
What is the average incident response time for each type of emergency in San Francisco?
SELECT E.Type, AVG(E.Time) as AvgResponseTime FROM EmergencyResponses E WHERE E.Location = 'San Francisco' GROUP BY E.Type;
gretelai_synthetic_text_to_sql
CREATE TABLE events (name VARCHAR(255), date DATE, attendance INT);
Create a table named 'events' with columns 'name', 'date', and 'attendance'
CREATE TABLE events (name VARCHAR(255), date DATE, attendance INT);
gretelai_synthetic_text_to_sql
CREATE TABLE avg_revenue(product VARCHAR(20), location VARCHAR(20), revenue INT); INSERT INTO avg_revenue VALUES('Tops', 'Canada', 100);
Calculate the average 'Revenue' for 'Tops' sold in 'Canada'.
SELECT AVG(revenue) FROM avg_revenue WHERE product = 'Tops' AND location = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE satellite_mass (id INT, satellite_name VARCHAR(50), manufacturer VARCHAR(50), mass FLOAT); INSERT INTO satellite_mass (id, satellite_name, manufacturer, mass) VALUES (1, 'Sat1', 'Manufacturer1', 1000); INSERT INTO satellite_mass (id, satellite_name, manufacturer, mass) VALUES (2, 'Sat2', 'Manufacturer2', 2000);
What is the total mass of all satellites in the "satellite_mass" table, grouped by manufacturer?
SELECT manufacturer, SUM(mass) AS total_mass FROM satellite_mass GROUP BY manufacturer;
gretelai_synthetic_text_to_sql
CREATE TABLE menu_items (menu_id INT, name VARCHAR(50), total_cost FLOAT); CREATE TABLE recipe (menu_id INT, ingredient_id INT, quantity FLOAT); CREATE TABLE ingredients (ingredient_id INT, name VARCHAR(50), supplier VARCHAR(50), cost FLOAT);
What is the total cost of ingredients for each menu item, excluding those from a specific supplier?
SELECT m.menu_id, m.name, SUM(i.cost * r.quantity) as total_cost FROM menu_items m JOIN recipe r ON m.menu_id = r.menu_id JOIN ingredients i ON r.ingredient_id = i.ingredient_id WHERE i.supplier != 'Excluded Supplier' GROUP BY m.menu_id;
gretelai_synthetic_text_to_sql
CREATE TABLE organizations (id INT, name VARCHAR, contact VARCHAR, region VARCHAR); INSERT INTO organizations (id, name, contact, region) VALUES (1, 'Organization A', 'contact1@example.com', 'Africa'), (2, 'Organization B', 'contact2@example.com', 'Europe'); CREATE TABLE preservation_status (id INT, status VARCHAR); INSERT INTO preservation_status (id, status) VALUES (1, 'Active'), (2, 'Inactive');
What is the contact information and language preservation status for organizations in Africa?
SELECT organizations.name, organizations.contact, preservation_status.status FROM organizations INNER JOIN preservation_status ON organizations.region = preservation_status.status WHERE organizations.region = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE Accommodations (id INT, country VARCHAR(50), type VARCHAR(50), capacity INT); INSERT INTO Accommodations (id, country, type, capacity) VALUES (1, 'France', 'Eco-Friendly Hotel', 100), (2, 'France', 'Eco-Friendly Hostel', 50), (3, 'Italy', 'Eco-Friendly Resort', 150), (4, 'Italy', 'Eco-Friendly B&B', 80);
What is the total number of eco-friendly accommodations in France and Italy?
SELECT SUM(capacity) FROM Accommodations WHERE country IN ('France', 'Italy') AND type LIKE '%Eco-Friendly%';
gretelai_synthetic_text_to_sql
CREATE TABLE restorative_justice_programs (program_id INT, community_type VARCHAR(255)); INSERT INTO restorative_justice_programs (program_id, community_type) VALUES (1, 'Indigenous'), (2, 'Urban'), (3, 'Rural'), (4, 'Suburban'), (5, 'Indigenous'), (6, 'Urban');
Count the number of restorative justice programs implemented in Indigenous communities
SELECT COUNT(*) FROM restorative_justice_programs WHERE community_type = 'Indigenous';
gretelai_synthetic_text_to_sql
CREATE TABLE clinical_trials (drug_name TEXT, year INTEGER, trial_count INTEGER);
Rank drugs based on the average number of clinical trials per year.
SELECT drug_name, AVG(trial_count) AS avg_trials, RANK() OVER (ORDER BY AVG(trial_count) DESC) AS rank FROM clinical_trials GROUP BY drug_name ORDER BY rank;
gretelai_synthetic_text_to_sql
CREATE TABLE policy_4 (policy_id INT, policy_type VARCHAR(20), premium FLOAT); INSERT INTO policy_4 (policy_id, policy_type, premium) VALUES (5, 'Home', 1400.00), (6, 'Auto', 850.00), (7, 'Life', 650.00), (8, 'Rent', 1450.00), (9, 'Travel', 900.00);
Calculate the average premium for each policy type, ordered from highest to lowest.
SELECT policy_type, AVG(premium) AS avg_premium, RANK() OVER (ORDER BY AVG(premium) DESC) AS policy_rank FROM policy_4 GROUP BY policy_type ORDER BY policy_rank;
gretelai_synthetic_text_to_sql
CREATE TABLE adaptation_measures (measure VARCHAR(50), location VARCHAR(50), success_rate NUMERIC); INSERT INTO adaptation_measures (measure, location, success_rate) VALUES ('Building sea walls', 'Africa', 0.9), ('Planting mangroves', 'Africa', 0.85), ('Constructing flood barriers', 'Africa', 0.75);
Which adaptation measures have the highest success rate in Africa?
SELECT measure, MAX(success_rate) as highest_success_rate FROM adaptation_measures WHERE location = 'Africa' GROUP BY measure;
gretelai_synthetic_text_to_sql
CREATE TABLE feed_additives_manufacturers (id INT, feed_additive_id INT, manufacturer_name VARCHAR(255), manufacturer_country VARCHAR(255)); INSERT INTO feed_additives_manufacturers (id, feed_additive_id, manufacturer_name, manufacturer_country) VALUES (1, 1, 'Skretting', 'Netherlands'), (2, 2, 'Cargill Aqua Nutrition', 'USA'), (3, 3, 'BioMar', 'Denmark'), (4, 4, 'Skretting', 'Norway'), (5, 5, 'Cargill Aqua Nutrition', 'Canada');
List all feed additives with their manufacturers' names and countries.
SELECT feed_additives.name, manufacturers.name, manufacturers.country FROM feed_additives JOIN feed_additives_manufacturers ON feed_additives.id = feed_additive_id JOIN feed_manufacturers AS manufacturers ON feed_additives_manufacturers.manufacturer_country = manufacturers.country;
gretelai_synthetic_text_to_sql
CREATE TABLE Brands (brand_id INT, brand_name VARCHAR(50), country VARCHAR(50), sustainability_score INT); INSERT INTO Brands (brand_id, brand_name, country, sustainability_score) VALUES (1, 'Lush', 'UK', 90), (2, 'The Body Shop', 'UK', 85), (3, 'Sephora', 'France', 70), (4, 'Chanel', 'France', 60), (5, 'Shiseido', 'Japan', 75);
Which country has the least sustainable cosmetics brands?
SELECT country FROM Brands ORDER BY sustainability_score LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Genres (genre_id INT, genre_name VARCHAR(255)); INSERT INTO Genres (genre_id, genre_name) VALUES (1, 'Pop'), (2, 'Rock'), (3, 'Hip Hop'); CREATE TABLE Sales (song_id INT, genre_id INT, revenue DECIMAL(10, 2)); INSERT INTO Sales (song_id, genre_id, revenue) VALUES (1, 1, 10000), (2, 2, 15000), (3, 3, 20000);
What are the top 3 genres by total revenue?
SELECT Genres.genre_name, SUM(Sales.revenue) AS total_revenue FROM Genres INNER JOIN Sales ON Genres.genre_id = Sales.genre_id GROUP BY Genres.genre_name ORDER BY total_revenue DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE fan_demographics (fan_id INT, team_id INT, age INT, gender VARCHAR(10)); CREATE TABLE teams (team_id INT, team_name VARCHAR(255), sport_id INT); INSERT INTO fan_demographics VALUES (1, 101, 25, 'Male'), (2, 101, 35, 'Female'), (3, 102, 45, 'Male'), (4, 102, 19, 'Other'), (5, 103, 32, 'Female'), (6, 103, 40, 'Male'); INSERT INTO teams VALUES (101, 'TeamA', 1), (102, 'TeamB', 2), (103, 'TeamC', 1);
What is the distribution of fan demographics (age and gender) for each team's athlete wellbeing program?
SELECT t.team_name, f.gender, f.age, COUNT(f.fan_id) as fan_count FROM fan_demographics f JOIN teams t ON f.team_id = t.team_id GROUP BY t.team_name, f.gender, f.age ORDER BY t.team_name, f.gender, f.age;
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, donor_id INT, donor_country TEXT, donation_date DATE, donation_amount DECIMAL); INSERT INTO donations (id, donor_id, donor_country, donation_date, donation_amount) VALUES (1, 1, 'Palestine', '2019-01-01', 50.00), (2, 2, 'Palestine', '2019-06-01', 100.00), (3, 3, 'Palestine', '2019-12-31', 25.00);
What is the total amount of donations made by donors from Palestine in the year 2019?
SELECT SUM(donation_amount) FROM donations WHERE donor_country = 'Palestine' AND YEAR(donation_date) = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE music_streams (stream_id INT, genre VARCHAR(10), year INT, streams INT); INSERT INTO music_streams (stream_id, genre, year, streams) VALUES (1, 'Classical', 2019, 1000000), (2, 'Jazz', 2020, 1500000), (3, 'Classical', 2020, 1200000), (4, 'Pop', 2019, 1800000); CREATE VIEW genre_streams AS SELECT genre, SUM(streams) as total_streams FROM music_streams GROUP BY genre;
Which genre has the most streams in 2019?
SELECT genre, total_streams FROM genre_streams WHERE year = 2019 ORDER BY total_streams DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name TEXT, region TEXT, founding_year INT, funding FLOAT); INSERT INTO companies (id, name, region, founding_year, funding) VALUES (1, 'Startup A', 'west_coast', 2016, 5000000), (2, 'Startup B', 'east_coast', 2017, 3000000), (3, 'Startup C', 'west_coast', 2018, 7000000), (4, 'Startup D', 'east_coast', 2019, 8000000), (5, 'Startup E', 'south', 2020, 6000000), (6, 'Startup F', 'midwest', 2015, 9000000);
List the names and funding amounts of startups in the 'midwest' region that were founded before 2018
SELECT name, funding FROM companies WHERE region = 'midwest' AND founding_year < 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, subcategory VARCHAR(255), price DECIMAL(5,2), is_organic BOOLEAN); INSERT INTO products (product_id, subcategory, price, is_organic) VALUES (1, 'Fruits', 3.99, true);
What is the minimum price of organic products, grouped by subcategory?
SELECT subcategory, MIN(price) AS min_price FROM products WHERE is_organic = true GROUP BY subcategory;
gretelai_synthetic_text_to_sql
CREATE TABLE FarmersMarketData (MarketID int, State varchar(50), Product varchar(50), PricePerPound decimal(5,2));
What is the average price per pound of organic produce sold in farmers markets, grouped by state?
SELECT State, AVG(PricePerPound) FROM FarmersMarketData WHERE Product LIKE '%organic produce%' GROUP BY State;
gretelai_synthetic_text_to_sql
CREATE TABLE broadband_subscribers (subscriber_id INT, country VARCHAR(50), subscription_type VARCHAR(50)); INSERT INTO broadband_subscribers (subscriber_id, country, subscription_type) VALUES (1, 'Canada', 'Residential'), (2, 'USA', 'Business');
What are the names and subscription types of all broadband subscribers in Canada?
SELECT name, subscription_type FROM broadband_subscribers WHERE country = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE Country (id INT, name VARCHAR(255), region VARCHAR(255)); INSERT INTO Country (id, name, region) VALUES (1, 'China', 'Asia'); INSERT INTO Country (id, name, region) VALUES (2, 'Japan', 'Asia'); INSERT INTO Country (id, name, region) VALUES (3, 'India', 'Asia'); CREATE TABLE OpenData (id INT, country_id INT, initiative VARCHAR(255)); INSERT INTO OpenData (id, country_id, initiative) VALUES (1, 1, 'Open Data China'); INSERT INTO OpenData (id, country_id, initiative) VALUES (2, 2, 'Open Data Japan'); INSERT INTO OpenData (id, country_id, initiative) VALUES (3, 3, 'Open Data India');
What is the total number of open data initiatives in Asian countries?
SELECT COUNT(*) FROM OpenData JOIN Country ON OpenData.country_id = Country.id WHERE Country.region = 'Asia' AND OpenData.initiative IS NOT NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE fieldA (rainfall FLOAT, date DATE); INSERT INTO fieldA (rainfall, date) VALUES (12.5, '2021-05-01'), (15.3, '2021-05-02');
What is the average rainfall in fieldA for the month of May?
SELECT AVG(rainfall) FROM fieldA WHERE EXTRACT(MONTH FROM date) = 5 AND fieldA.date BETWEEN '2021-05-01' AND '2021-05-31';
gretelai_synthetic_text_to_sql
CREATE TABLE AquacultureFarms (FarmID int, FarmName varchar(50), FarmLocation varchar(50), FishSpecies varchar(50), Quantity int); INSERT INTO AquacultureFarms (FarmID, FarmName, FarmLocation, FishSpecies, Quantity) VALUES (1, 'Farm A', 'Pacific', 'Salmon', 5000), (2, 'Farm B', 'Atlantic', 'Tuna', 8000), (3, 'Farm C', 'Pacific', 'Cod', 3000);
List all the aquaculture farms in the Pacific region with fish species and quantity.
SELECT FarmName, FishSpecies, Quantity FROM AquacultureFarms WHERE FarmLocation = 'Pacific';
gretelai_synthetic_text_to_sql
CREATE TABLE UserStreamingData (UserID INT, Country VARCHAR(50), Platform VARCHAR(50), Genre VARCHAR(50), Streams INT); INSERT INTO UserStreamingData (UserID, Country, Platform, Genre, Streams) VALUES (1, 'USA', 'Spotify', 'Hip Hop', 100000), (2, 'Canada', 'Spotify', 'Hip Hop', 120000);
Which countries have the highest and lowest average streams per user for Hip Hop songs on Spotify?
SELECT Country, AVG(Streams) as AvgStreams FROM UserStreamingData WHERE Platform = 'Spotify' AND Genre = 'Hip Hop' GROUP BY Country ORDER BY AvgStreams DESC LIMIT 1; SELECT Country, AVG(Streams) as AvgStreams FROM UserStreamingData WHERE Platform = 'Spotify' AND Genre = 'Hip Hop' GROUP BY Country ORDER BY AvgStreams ASC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE vendors (id INT PRIMARY KEY, name VARCHAR(50), address VARCHAR(100));
Add a new vendor to the "vendors" table with ID 121314, name "ABC Company", and address "123 Main St"
INSERT INTO vendors (id, name, address) VALUES (121314, 'ABC Company', '123 Main St');
gretelai_synthetic_text_to_sql
CREATE TABLE Users (user_id INT, country VARCHAR(50), last_login DATE); CREATE VIEW Virtual_Workouts AS SELECT user_id, date FROM Virtual_Workout_Data WHERE workout_type = 'virtual';
How many users from each country participated in virtual workouts in the last week?
SELECT country, COUNT(DISTINCT user_id) FROM Users JOIN Virtual_Workouts ON Users.user_id = Virtual_Workouts.user_id WHERE last_login >= DATEADD(day, -7, GETDATE()) GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT, brand VARCHAR(255), country VARCHAR(255), sales_amount DECIMAL(10, 2), sale_date DATE);
What is the total sales amount of cosmetics sold in Germany in Q3 2022, grouped by week?
SELECT DATE_TRUNC('week', sale_date) as week, SUM(sales_amount) FROM sales WHERE country = 'Germany' AND sale_date BETWEEN '2022-07-01' AND '2022-09-30' GROUP BY week;
gretelai_synthetic_text_to_sql
CREATE TABLE ServiceFeedback (Service TEXT, Score INTEGER); INSERT INTO ServiceFeedback (Service, Score) VALUES ('Public Transportation', 8), ('Education', 9), ('Healthcare', 7);
What is the minimum citizen feedback score for public transportation and education services?
SELECT Service, MIN(Score) FROM ServiceFeedback WHERE Service IN ('Public Transportation', 'Education') GROUP BY Service;
gretelai_synthetic_text_to_sql
CREATE TABLE MLS_Matches (MatchID INT, HomeTeam VARCHAR(50), AwayTeam VARCHAR(50), HomeTeamScore INT, AwayTeamScore INT); INSERT INTO MLS_Matches (MatchID, HomeTeam, AwayTeam, HomeTeamScore, AwayTeamScore) VALUES (1, 'New York City FC', 'Atlanta United', 1, 1);
How many matches in the MLS have had a result of a 1-1 draw?
SELECT COUNT(*) FROM MLS_Matches WHERE HomeTeamScore = 1 AND AwayTeamScore = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_rates (category VARCHAR(20), region VARCHAR(20), year INT, rate DECIMAL(3,2)); INSERT INTO recycling_rates (category, region, year, rate) VALUES ('Paper', 'Northeast', 2020, 0.45), ('Paper', 'Northeast', 2021, 0.47), ('Metals', 'Northeast', 2020, 0.38), ('Metals', 'Northeast', 2021, 0.41);
What was the recycling rate for the 'Metals' category in the 'Northeast' region in 2021?
SELECT rate FROM recycling_rates WHERE category = 'Metals' AND region = 'Northeast' AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE countries (id INT PRIMARY KEY, name VARCHAR(255), certification_count INT);CREATE VIEW top_countries AS SELECT name, certification_count, ROW_NUMBER() OVER (ORDER BY certification_count DESC) as rank FROM countries;
What are the top 5 countries with the most sustainable tourism certifications?
SELECT name FROM top_countries WHERE rank <= 5;
gretelai_synthetic_text_to_sql
CREATE TABLE intelligence_ops (id INT, year INT, location VARCHAR(255), type VARCHAR(255), result VARCHAR(255)); INSERT INTO intelligence_ops (id, year, location, type, result) VALUES (1, 2015, 'Russia', 'Surveillance', 'Success');
Update the result of a specific intelligence operation in the "intelligence_ops" table
UPDATE intelligence_ops SET result = 'Failure' WHERE id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Patients (ID INT, Disease VARCHAR(20), DiagnosisDate DATE, State VARCHAR(20)); INSERT INTO Patients (ID, Disease, DiagnosisDate, State) VALUES (1, 'COVID-19', '2022-01-01', 'California'), (2, 'COVID-19', '2022-01-05', 'California');
What is the maximum number of patients diagnosed with COVID-19 per week in each state?
SELECT State, MAX(CountPerWeek) AS MaxCountPerWeek FROM (SELECT State, DATEPART(WEEK, DiagnosisDate) AS WeekNumber, COUNT(*) AS CountPerWeek FROM Patients WHERE Disease = 'COVID-19' GROUP BY State, WeekNumber) AS Subquery GROUP BY State;
gretelai_synthetic_text_to_sql