context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE veteran_employment (veteran_id INT, sector VARCHAR(255), employment_date DATE); INSERT INTO veteran_employment (veteran_id, sector, employment_date) VALUES (1, 'IT', '2020-01-01'), (2, 'Healthcare', '2019-06-15'), (3, 'Finance', '2018-09-30'), (4, 'Manufacturing', '2021-04-01'), (5, 'Education', '2020-12-15');
Delete all records with an employment date before '2020-01-01' from the 'veteran_employment' table
DELETE FROM veteran_employment WHERE employment_date < '2020-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE research_grants (id INT, name TEXT, amount INT); INSERT INTO research_grants (id, name, amount) VALUES (1, 'Grant A', 50000), (2, 'Grant B', 75000), (3, 'Grant C', 100000);
Update the research_grants table with the new grant amounts
UPDATE research_grants SET amount = 60000 WHERE name = 'Grant A'; UPDATE research_grants SET amount = 80000 WHERE name = 'Grant B'; UPDATE research_grants SET amount = 90000 WHERE name = 'Grant C';
gretelai_synthetic_text_to_sql
CREATE TABLE conditions (condition_id INT, condition_name TEXT); INSERT INTO conditions (condition_id, condition_name) VALUES (1, 'Anxiety'), (2, 'Depression'), (3, 'Bipolar Disorder'); CREATE TABLE campaigns (campaign_id INT, condition_id INT, campaign_name TEXT); INSERT INTO campaigns (campaign_id, condition_id, campaign_name) VALUES (1, 1, 'Mind Matters'), (2, 2, 'Beyond Blue'), (3, 3, 'Balance'), (4, 2, 'Hope');
List all mental health conditions and their corresponding awareness campaigns, if any.
SELECT conditions.condition_name, campaigns.campaign_name FROM conditions LEFT JOIN campaigns ON conditions.condition_id = campaigns.condition_id;
gretelai_synthetic_text_to_sql
CREATE TABLE expedition (org VARCHAR(20), depth INT); INSERT INTO expedition VALUES ('Ocean Explorer', 2500), ('Ocean Explorer', 3000), ('Sea Discoverers', 2000), ('Marine Investigators', 4000), ('Marine Investigators', 4500), ('Deep Sea Divers', 7000), ('Deep Sea Divers', 6500);
What is the difference between the maximum and minimum expedition depths for the 'Deep Sea Divers' organization?
SELECT MAX(depth) - MIN(depth) FROM expedition WHERE org = 'Deep Sea Divers';
gretelai_synthetic_text_to_sql
CREATE TABLE donors (id INT, name VARCHAR(50), city VARCHAR(50), state VARCHAR(50), amount DECIMAL(10,2)); INSERT INTO donors (id, name, city, state, amount) VALUES (1, 'John Doe', 'San Francisco', 'CA', 100.00), (2, 'Jane Smith', 'Oakland', 'CA', 200.00);
What is the total amount donated by individuals in the San Francisco Bay Area?
SELECT SUM(amount) FROM donors WHERE city = 'San Francisco' OR city = 'Oakland';
gretelai_synthetic_text_to_sql
CREATE TABLE schools (id INT PRIMARY KEY, name VARCHAR(255)); CREATE TABLE students (id INT PRIMARY KEY, school_id INT, mental_health_score INT);
How many students in each school have a mental health score above the average?
SELECT s.name, COUNT(st.id) FROM students st JOIN schools s ON st.school_id = s.id GROUP BY st.school_id HAVING AVG(st.mental_health_score) < st.mental_health_score;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, Gender VARCHAR(50), Department VARCHAR(50)); INSERT INTO Employees (EmployeeID, Gender, Department) VALUES (1, 'Female', 'Marketing'), (2, 'Male', 'Marketing');
How many female and male employees are there in the Marketing department?
SELECT Gender, COUNT(*) FROM Employees WHERE Department = 'Marketing' GROUP BY Gender;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (id INT, name TEXT, country TEXT, donation FLOAT, quarter TEXT, year INT); INSERT INTO Donors (id, name, country, donation, quarter, year) VALUES (1, 'Charlie', 'USA', 100.0, 'Q2', 2021), (2, 'David', 'Mexico', 150.0, 'Q2', 2021), (3, 'Eve', 'Canada', 75.0, 'Q2', 2021);
How many unique donors from each country made donations in Q2 2021?
SELECT country, COUNT(DISTINCT id) FROM Donors WHERE quarter = 'Q2' AND year = 2021 GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE underrepresented_communities_destinations (id INT, country VARCHAR(10), visitors INT); INSERT INTO underrepresented_communities_destinations (id, country, visitors) VALUES (1, 'Nigeria', 8000); INSERT INTO underrepresented_communities_destinations (id, country, visitors) VALUES (2, 'Colombia', 9000); INSERT INTO underrepresented_communities_destinations (id, country, visitors) VALUES (3, 'Indonesia', 7000);
Identify the destinations with the highest number of visitors from historically underrepresented communities in Q4 of 2023.
SELECT country FROM underrepresented_communities_destinations WHERE QUARTER(arrival_date) = 4 GROUP BY country ORDER BY SUM(visitors) DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE Farmers (id INT PRIMARY KEY, name VARCHAR(100), age INT, location VARCHAR(100)); INSERT INTO Farmers (id, name, age, location) VALUES (1, 'Ramesh Patel', 55, 'India'); INSERT INTO Farmers (id, name, age, location) VALUES (2, 'Seetha Reddy', 47, 'India'); CREATE TABLE Plots (id INT PRIMARY KEY, farmer_id INT, size FLOAT, crop VARCHAR(50)); INSERT INTO Plots (id, farmer_id, size, crop) VALUES (1, 1, 0.6, 'Rice'); INSERT INTO Plots (id, farmer_id, size, crop) VALUES (2, 2, 0.7, 'Lentils'); CREATE TABLE Crops (id INT PRIMARY KEY, name VARCHAR(50), growth_season VARCHAR(50)); INSERT INTO Crops (id, name, growth_season) VALUES (1, 'Rice', 'Summer'); INSERT INTO Crops (id, name, growth_season) VALUES (2, 'Lentils', 'Winter');
What are the names and crops of farmers who grow crops in India?
SELECT f.name, p.crop FROM Farmers f INNER JOIN Plots p ON f.id = p.farmer_id INNER JOIN Crops c ON p.crop = c.name WHERE f.location = 'India';
gretelai_synthetic_text_to_sql
CREATE TABLE crops (id INT PRIMARY KEY, name VARCHAR(255), production_metric_tons FLOAT, country VARCHAR(255)); INSERT INTO crops (id, name, production_metric_tons, country) VALUES (1, 'Quinoa', 85.2, 'Bolivia'), (2, 'Potatoes', 400.5, 'Bolivia'), (3, 'Corn', 200.0, 'Bolivia');
What is the total production of quinoa in Bolivia, in metric tons?
SELECT SUM(production_metric_tons) FROM crops WHERE name = 'Quinoa' AND country = 'Bolivia';
gretelai_synthetic_text_to_sql
CREATE TABLE algorithmic_fairness (method TEXT, technique TEXT, dataset TEXT, impact TEXT);
Insert new records into the 'algorithmic_fairness' table for 'Bias Mitigation' methods
INSERT INTO algorithmic_fairness (method, technique, dataset, impact) VALUES ('Bias Mitigation', 'Disparate Impact Removal', 'COMPAS', 'Reduction in disparate impact'), ('Bias Mitigation', 'Adversarial Debiasing', 'Facial Recognition', 'Reduction in racial bias');
gretelai_synthetic_text_to_sql
CREATE TABLE canadian_scooters (city VARCHAR(20), num_scooters INT); INSERT INTO canadian_scooters (city, num_scooters) VALUES ('Toronto', 1000), ('Vancouver', 800), ('Montreal', 600), ('Calgary', 400), ('Edmonton', 200);
What is the total number of shared electric scooters in Toronto and Vancouver?
SELECT SUM(num_scooters) FROM canadian_scooters WHERE city IN ('Toronto', 'Vancouver');
gretelai_synthetic_text_to_sql
CREATE TABLE deliveries (id INT, order_id INT, delivery_time INT, transportation_mode VARCHAR(50)); INSERT INTO deliveries (id, order_id, delivery_time, transportation_mode) VALUES (1, 1001, 3, 'Air'), (2, 1002, 7, 'Road'), (3, 1003, 5, 'Rail'), (4, 1004, 2, 'Sea');
What is the total delivery time for each transportation mode?
SELECT transportation_mode, SUM(delivery_time) as total_delivery_time FROM deliveries GROUP BY transportation_mode;
gretelai_synthetic_text_to_sql
CREATE TABLE Countries (CountryID INT, CountryName TEXT); INSERT INTO Countries (CountryID, CountryName) VALUES (1, 'Country-X'), (2, 'Country-Y'), (3, 'Country-Z'); CREATE TABLE Sites (SiteID INT, SiteName TEXT, CountryID INT); INSERT INTO Sites (SiteID, SiteName, CountryID) VALUES (1, 'Site-A', 1), (2, 'Site-B', 2), (3, 'Site-C', 3), (4, 'Site-D', 1), (5, 'Site-E', 1), (6, 'Site-F', 2), (7, 'Site-G', 3), (8, 'Site-H', 3), (9, 'Site-I', 3);
Which countries have more than 5 excavation sites?
SELECT Countries.CountryName, COUNT(DISTINCT Sites.SiteID) AS SiteCount FROM Countries INNER JOIN Sites ON Countries.CountryID = Sites.CountryID GROUP BY Countries.CountryName HAVING SiteCount > 5;
gretelai_synthetic_text_to_sql
CREATE TABLE subway_stations (station_id INT, station_name VARCHAR(50), city VARCHAR(50), time_between_arrivals TIME); INSERT INTO subway_stations (station_id, station_name, city, time_between_arrivals) VALUES (1, 'Shinjuku', 'Tokyo', '3:00'), (2, 'Shibuya', 'Tokyo', '4:00'), (3, 'Ginza', 'Tokyo', '5:00');
What is the average time between subway train arrivals in Tokyo?
SELECT AVG(TIME_TO_SEC(time_between_arrivals))/60.0 FROM subway_stations WHERE city = 'Tokyo';
gretelai_synthetic_text_to_sql
CREATE TABLE Developers (developer_id INT, developer_name TEXT, developer_country TEXT); INSERT INTO Developers (developer_id, developer_name, developer_country) VALUES (1, 'Ana', 'Brazil'), (2, 'Beto', 'Argentina'); CREATE TABLE DigitalAssets (asset_id INT, asset_name TEXT, developer_id INT, transaction_fee DECIMAL(10, 2)); INSERT INTO DigitalAssets (asset_id, asset_name, developer_id, transaction_fee) VALUES (1, 'Asset1', 1, 30.50), (2, 'Asset2', 1, 40.00), (3, 'Asset3', 2, 15.00);
What is the highest transaction fee for digital assets created by developers from Brazil?
SELECT MAX(DigitalAssets.transaction_fee) FROM DigitalAssets INNER JOIN Developers ON DigitalAssets.developer_id = Developers.developer_id WHERE Developers.developer_country = 'Brazil';
gretelai_synthetic_text_to_sql
CREATE TABLE ElectricBuses (Id INT, Country VARCHAR(255), Year INT, Quarter INT, Buses INT); INSERT INTO ElectricBuses (Id, Country, Year, Quarter, Buses) VALUES (1, 'South Korea', 2021, 1, 50), (2, 'South Korea', 2021, 2, NULL), (3, 'South Korea', 2022, 1, 75), (4, 'South Korea', 2022, 2, 80), (5, 'China', 2021, 1, 100);
How many electric buses were sold in South Korea in H1 of 2021?
SELECT SUM(Buses) FROM ElectricBuses WHERE Country = 'South Korea' AND Year = 2021 AND Quarter BETWEEN 1 AND 2;
gretelai_synthetic_text_to_sql
CREATE TABLE maritime_incidents (year INT, region VARCHAR(255), incident_type VARCHAR(255), number_of_ships INT);INSERT INTO maritime_incidents (year, region, incident_type, number_of_ships) VALUES (2019, 'South China Sea', 'collision', 3), (2018, 'South China Sea', 'grounding', 2), (2017, 'South China Sea', 'collision', 4);
How many ships were involved in collisions in the South China Sea in 2019?
SELECT number_of_ships FROM maritime_incidents WHERE region = 'South China Sea' AND incident_type = 'collision' AND year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE Attorneys (AttorneyID int, State varchar(50), TotalBillingAmount numeric); INSERT INTO Attorneys VALUES (1, 'CA', 15000), (2, 'TX', 12000), (3, 'CA', 18000), (4, 'TX', 13000), (5, 'CA', 20000), (6, 'TX', 16000);
What is the average billing amount per case for attorneys in California, compared to Texas?
SELECT AVG(TotalBillingAmount) FROM Attorneys WHERE State = 'CA' OR State = 'TX' GROUP BY State;
gretelai_synthetic_text_to_sql
CREATE TABLE Underwriting (PolicyID INT, PolicyholderID INT, PolicyType TEXT, Premium INT); INSERT INTO Underwriting (PolicyID, PolicyholderID, PolicyType, Premium) VALUES (101, 1, 'Auto', 1200), (102, 2, 'Life', 500), (103, 3, 'Auto', 800), (104, 4, 'Life', 600);
Show Underwriting data for policies with an 'Auto' type and a premium greater than $1000.
SELECT * FROM Underwriting WHERE PolicyType = 'Auto' AND Premium > 1000;
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (transaction_id INT, customer_id INT, region VARCHAR(20), transaction_amount DECIMAL(10,2)); INSERT INTO transactions (transaction_id, customer_id, region, transaction_amount) VALUES (1, 1, 'West Coast', 500.00), (2, 1, 'East Coast', 700.00), (3, 2, 'West Coast', 800.00), (4, 3, 'North East', 900.00);
What is the maximum transaction amount in each region?
SELECT region, MAX(transaction_amount) FROM transactions GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE water_projects (project_name TEXT, funder TEXT, start_date DATE, end_date DATE, location TEXT); INSERT INTO water_projects (project_name, funder, start_date, end_date, location) VALUES ('Mudi Dam', 'EU', '2019-01-10', '2021-06-30', 'Mangochi'), ('Likhubula Water Supply', 'EU', '2019-03-01', '2020-12-20', 'Phalombe'), ('Nkhata Bay Water Network', 'USAID', '2018-06-15', '2022-09-30', 'Nkhata Bay');
List all the water projects funded by the EU in Malawi in 2019.
SELECT * FROM water_projects WHERE funder = 'EU' AND start_date BETWEEN '2019-01-01' AND '2019-12-31' AND location = 'Malawi';
gretelai_synthetic_text_to_sql
CREATE TABLE Suppliers (id INT PRIMARY KEY, supplier_name VARCHAR(255), country VARCHAR(100), sustainability_rating INT); INSERT INTO Suppliers (id, supplier_name, country, sustainability_rating) VALUES (1, 'Green Farms', 'Canada', 4), (2, 'Tropical Fruits', 'Brazil', 3), (3, 'Ocean Harvest', 'Norway', 5);
Which suppliers have a sustainability rating of 5?
SELECT supplier_name, country FROM Suppliers WHERE sustainability_rating = 5;
gretelai_synthetic_text_to_sql
CREATE TABLE job_offers (id INT, offer_date DATE, department VARCHAR(50), offer_accepted BOOLEAN); INSERT INTO job_offers (id, offer_date, department, offer_accepted) VALUES (1, '2021-03-15', 'IT', TRUE); INSERT INTO job_offers (id, offer_date, department, offer_accepted) VALUES (2, '2021-06-28', 'HR', FALSE);
What is the percentage of job offers accepted, by department, for the year 2021?
SELECT department, SUM(CASE WHEN offer_accepted = TRUE THEN 1 ELSE 0 END) / COUNT(*) * 100 AS pct_offer_acceptance FROM job_offers WHERE YEAR(offer_date) = 2021 GROUP BY department;
gretelai_synthetic_text_to_sql
CREATE TABLE Members (MemberID INT PRIMARY KEY, Age INT, Gender VARCHAR(10), MembershipType VARCHAR(20)); INSERT INTO Members (MemberID, Age, Gender, MembershipType) VALUES (1, 35, 'Female', 'Premium'); CREATE TABLE Wellness (ProgramID INT PRIMARY KEY, MemberID INT, Category VARCHAR(20), StartDate DATE, EndDate DATE); INSERT INTO Wellness (ProgramID, MemberID, Category, StartDate, EndDate) VALUES (1, 1, 'Nutrition', '2022-04-01', '2022-04-30'); CREATE TABLE Wearables (DeviceID INT PRIMARY KEY, MemberID INT, Steps INT, Date DATE); INSERT INTO Wearables (DeviceID, MemberID, Steps, Date) VALUES (1, 1, 12000, '2022-05-01');
What is the total number of steps taken by members in their 20s who have completed a wellness program in the 'Nutrition' category?
SELECT SUM(Steps) FROM Wearables w JOIN Members m ON w.MemberID = m.MemberID JOIN Wellness well ON m.MemberID = well.MemberID WHERE m.Age BETWEEN 20 AND 29 AND well.Category = 'Nutrition' AND well.EndDate IS NOT NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE SatelliteMissions (MissionID INT, Name VARCHAR(50), LaunchCountry VARCHAR(50), LaunchDate DATE, Success BOOLEAN); INSERT INTO SatelliteMissions VALUES (1, 'GSAT-12', 'India', '2011-07-15', true); INSERT INTO SatelliteMissions VALUES (2, 'GSAT-11', 'India', '2018-12-04', true);
What is the success rate of orbital satellite missions launched by India?
SELECT 100.0 * COUNT(*) / (SELECT COUNT(*) FROM SatelliteMissions WHERE LaunchCountry = 'India') AS SuccessRate FROM SatelliteMissions WHERE LaunchCountry = 'India' AND Success = true
gretelai_synthetic_text_to_sql
CREATE TABLE tech_conferences (conference_location VARCHAR(255), is_accessible BOOLEAN); INSERT INTO tech_conferences (conference_location, is_accessible) VALUES ('Brazil', true), ('Colombia', false), ('Argentina', true);
What is the total number of accessible technology conferences in South America?
SELECT COUNT(*) FROM tech_conferences WHERE conference_location LIKE 'South%' AND is_accessible = true;
gretelai_synthetic_text_to_sql
CREATE TABLE labor_costs (id INT, task VARCHAR(50), cost FLOAT, state VARCHAR(50)); INSERT INTO labor_costs (id, task, cost, state) VALUES (1, 'Framing', 35.50, 'Florida'); INSERT INTO labor_costs (id, task, cost, state) VALUES (2, 'Roofing', 45.25, 'Florida');
What is the average construction labor cost per hour in Florida?
SELECT AVG(cost) FROM labor_costs WHERE state = 'Florida' AND task = 'Framing'
gretelai_synthetic_text_to_sql
CREATE TABLE ProjectSustainability (ProjectID INT, PracticeID INT); INSERT INTO ProjectSustainability (ProjectID, PracticeID) VALUES (8, 9), (8, 10); CREATE TABLE SustainablePractices (PracticeID INT, PracticeName VARCHAR(50), Description VARCHAR(255), PracticeType VARCHAR(50)); INSERT INTO SustainablePractices (PracticeID, PracticeName, Description, PracticeType) VALUES (9, 'Solar Panels', 'Installing solar panels for renewable energy.', 'Sustainable'), (10, 'Insulation', 'Improving insulation for energy efficiency.', 'Sustainable');
Which 'Sustainable' practices were implemented in 'Mechanical Engineering' projects?
SELECT SustainablePractices.PracticeName FROM ProjectSustainability INNER JOIN SustainablePractices ON ProjectSustainability.PracticeID = SustainablePractices.PracticeID WHERE ProjectSustainability.ProjectID IN (SELECT ProjectID FROM Projects WHERE Projects.Department = 'Mechanical Engineering');
gretelai_synthetic_text_to_sql
CREATE TABLE DonorCountry (DonorID INT, DonorName TEXT, DonationAmount DECIMAL(10,2), Country TEXT, DonationDate DATE); INSERT INTO DonorCountry (DonorID, DonorName, DonationAmount, Country, DonationDate) VALUES (1, 'Sophia Lee', 1500.00, 'South Korea', '2022-12-15');
List the top 2 donors from each country in December 2022?
SELECT DonorID, DonorName, SUM(DonationAmount) FROM DonorCountry WHERE DonationDate BETWEEN '2022-12-01' AND '2022-12-31' GROUP BY DonorID, DonorName, Country HAVING COUNT(DISTINCT Country) = 1 ORDER BY SUM(DonationAmount) DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE hospitals (hospital_id INT, hospital_name VARCHAR(50), country VARCHAR(50)); INSERT INTO hospitals (hospital_id, hospital_name, country) VALUES (1, 'Toronto Mental Health Hospital', 'Canada'), (2, 'Montreal Mental Health Centre', 'Canada'); CREATE TABLE therapy_sessions (session_id INT, hospital_id INT, session_date DATE); INSERT INTO therapy_sessions (session_id, hospital_id, session_date) VALUES (1, 1, '2021-01-01'), (2, 1, '2021-01-02');
Identify the hospital in Canada with the highest number of mental health treatment sessions.
SELECT hospital_name, COUNT(session_id) AS session_count FROM therapy_sessions JOIN hospitals ON therapy_sessions.hospital_id = hospitals.hospital_id WHERE hospitals.country = 'Canada' GROUP BY hospital_name ORDER BY session_count DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE TimeEntries (EntryID INT, CaseID INT, Hours DECIMAL(10,2)); INSERT INTO TimeEntries (EntryID, CaseID, Hours) VALUES (1, 1, 5.00), (2, 2, 7.50);
What is the total billable hours for cases opened in the last year?
SELECT SUM(Hours) FROM TimeEntries INNER JOIN Cases ON TimeEntries.CaseID = Cases.CaseID WHERE OpenDate >= DATEADD(year, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE Infrastructure (id INT, name VARCHAR(100), type VARCHAR(50), location VARCHAR(100), state VARCHAR(50)); INSERT INTO Infrastructure (id, name, type, location, state) VALUES (4, 'Greater New Orleans Levee System', 'Levee', 'New Orleans', 'Louisiana');
Get the names and locations of all levees in Louisiana
SELECT name, location FROM Infrastructure WHERE type = 'Levee' AND state = 'Louisiana';
gretelai_synthetic_text_to_sql
CREATE TABLE players (id INT, name VARCHAR(50)); CREATE TABLE games (id INT, player_id INT, kills INT, deaths INT, assists INT); INSERT INTO players VALUES (1, 'Aarav Singh'); INSERT INTO players VALUES (2, 'Bella Rodriguez'); INSERT INTO games VALUES (1, 1, 12, 6, 8); INSERT INTO games VALUES (2, 1, 18, 4, 12); INSERT INTO games VALUES (3, 2, 7, 3, 2); INSERT INTO games VALUES (4, 2, 10, 5, 6);
What is the average KDA ratio for each player in the 'gaming' tournament?
SELECT player_id, AVG( kills / NULLIF(deaths, 0) + assists / NULLIF(deaths, 0)) as avg_kda_ratio FROM games GROUP BY player_id;
gretelai_synthetic_text_to_sql
CREATE SCHEMA MaritimeLaw(species_id INT, species_name TEXT, ocean_name TEXT, min_limit INT, max_limit INT); INSERT INTO MaritimeLaw(species_id, species_name, ocean_name, min_limit, max_limit) VALUES (1, 'Salmon', 'Pacific', 5, 10), (2, 'Herring', 'Pacific', 2, 5), (3, 'Shark', 'Atlantic', 1, 3);
List all marine species and their legal catch limits in 'Pacific' waters.
SELECT species_name, min_limit, max_limit FROM MaritimeLaw WHERE ocean_name = 'Pacific';
gretelai_synthetic_text_to_sql
CREATE TABLE labor_practices(company VARCHAR(50), violation VARCHAR(50), severity INT);
List the top 3 labor practice violations by company in the ethical fashion industry.
SELECT company, violation, ROW_NUMBER() OVER (PARTITION BY company ORDER BY severity DESC) as rank FROM labor_practices WHERE rank <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE organizations (org_id INT, org_name TEXT, city_id INT); CREATE TABLE cities (city_id INT, city_name TEXT);
Show the total donation amount for each organization in the 'organizations' table, joined with their corresponding city information from the 'cities' table.
SELECT organizations.org_name, SUM(donation_amount) as total_donations FROM organizations INNER JOIN (SELECT donor_id, donation_amount, organizations.org_id FROM donors INNER JOIN organizations ON donors.org_id = organizations.org_id) as donor_org ON organizations.org_id = donor_org.org_id GROUP BY organizations.org_name;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT PRIMARY KEY, FirstName VARCHAR(50), LastName VARCHAR(50), Email VARCHAR(100));
Delete a record from the 'Donors' table
DELETE FROM Donors WHERE DonorID = 101;
gretelai_synthetic_text_to_sql
CREATE TABLE attorney_cases (case_id INT, attorney_name VARCHAR(50), billing_amount DECIMAL(10,2)); INSERT INTO attorney_cases (case_id, attorney_name, billing_amount) VALUES (1, 'Maria Garcia', 4000.00), (2, 'James Lee', 3000.00), (3, 'Maria Garcia', 500.00);
What is the minimum billing amount for cases handled by attorney 'Maria Garcia'?
SELECT MIN(billing_amount) FROM attorney_cases WHERE attorney_name = 'Maria Garcia';
gretelai_synthetic_text_to_sql
CREATE TABLE manufacturers (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), sustainability_score FLOAT); INSERT INTO manufacturers (id, name, location, sustainability_score) VALUES (2, 'Green Trends', 'Tokyo, Japan', 8.8);
Find the average sustainability score for manufacturers in Tokyo, Japan.
SELECT AVG(sustainability_score) AS avg_sustainability_score FROM manufacturers WHERE location = 'Tokyo, Japan';
gretelai_synthetic_text_to_sql
CREATE TABLE social_impact_investments (id INT, region VARCHAR(50), category VARCHAR(50), transaction_value FLOAT); INSERT INTO social_impact_investments (id, region, category, transaction_value) VALUES (1, 'Asia', 'Climate Action', 8000.0), (2, 'Europe', 'Gender Equality', 6000.0), (3, 'Africa', 'Climate Action', 10000.0), (4, 'North America', 'Renewable Energy', 5000.0), (5, 'Europe', 'Renewable Energy', 7000.0), (6, 'North America', 'Gender Equality', 9000.0);
Identify the average transaction value for social impact investments in the 'Renewable Energy' category in North America and 'Gender Equality' category in Europe.
SELECT AVG(transaction_value) FROM social_impact_investments WHERE (region = 'North America' AND category = 'Renewable Energy') OR (region = 'Europe' AND category = 'Gender Equality');
gretelai_synthetic_text_to_sql
CREATE TABLE Cyber_Incidents (incident_id INT, incident_date DATE, incident_type VARCHAR(50), incident_severity INT); INSERT INTO Cyber_Incidents (incident_id, incident_date, incident_type, incident_severity) VALUES (1, '2021-01-01', 'Phishing', 3); INSERT INTO Cyber_Incidents (incident_id, incident_date, incident_type, incident_severity) VALUES (2, '2021-02-15', 'Malware', 5);
What is the total number of cybersecurity incidents in the 'Cyber_Incidents' table?
SELECT COUNT(*) FROM Cyber_Incidents;
gretelai_synthetic_text_to_sql
CREATE TABLE building_energy (building_id INT, city VARCHAR(50), rating FLOAT); INSERT INTO building_energy (building_id, city, rating) VALUES (1, 'New York', 85.3), (2, 'Chicago', 78.9), (3, 'New York', 92.1), (4, 'Chicago', 88.7), (5, 'New York', 74.5), (6, 'Chicago', 69.2);
What is the average energy efficiency rating of buildings in New York and Chicago?
SELECT AVG(rating) FROM building_energy WHERE city IN ('New York', 'Chicago');
gretelai_synthetic_text_to_sql
CREATE TABLE donations (donation_id INT, donor_id INT, donation_amount DECIMAL, donation_date DATE, donation_region TEXT); INSERT INTO donations (donation_id, donor_id, donation_amount, donation_date, donation_region) VALUES (1, 1, 50.00, '2022-01-01', 'Northeast');
Which 'region' had the highest average donation amount in '2022'?
SELECT donation_region, AVG(donation_amount) FROM donations WHERE donation_date BETWEEN '2022-01-01' AND '2022-12-31' GROUP BY donation_region ORDER BY AVG(donation_amount) DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE mining_operations (id INT, name VARCHAR(50), department VARCHAR(50), age INT);
What is the total number of employees in the "mining_operations" table, who are older than 50?
SELECT COUNT(*) FROM mining_operations WHERE age > 50;
gretelai_synthetic_text_to_sql
CREATE TABLE asian_production (id INT, country TEXT, year INT, quantity FLOAT); INSERT INTO asian_production (id, country, year, quantity) VALUES (1, 'China', 2014, 120000), (2, 'China', 2015, 130000), (3, 'China', 2016, 140000), (4, 'Mongolia', 2014, 1000), (5, 'Mongolia', 2015, 1500), (6, 'Mongolia', 2016, 2000);
What are the top 2 rare earth element producing countries in Asia in terms of total production quantity for the year 2016?
SELECT country, SUM(quantity) FROM asian_production WHERE year = 2016 GROUP BY country ORDER BY SUM(quantity) DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE country (id INT PRIMARY KEY, name VARCHAR(50));CREATE TABLE carbon_price (id INT PRIMARY KEY, name VARCHAR(50), country_id INT, FOREIGN KEY (country_id) REFERENCES country(id), price DECIMAL(10,2));CREATE TABLE carbon_emission (id INT PRIMARY KEY, date DATE, source_id INT, FOREIGN KEY (source_id) REFERENCES renewable_source(id), carbon_emitted DECIMAL(10,2));CREATE TABLE power_usage (id INT PRIMARY KEY, date DATE, usage_amount INT, country_id INT, FOREIGN KEY (country_id) REFERENCES country(id));
What is the average carbon price and total carbon emitted in India for the year 2020?
SELECT c.name AS country_name, cp.name AS carbon_price_name, AVG(cp.price) AS average_carbon_price, SUM(ce.carbon_emitted) AS total_carbon_emitted FROM carbon_emission ce JOIN carbon_price cp ON ce.country_id = cp.country_id JOIN power_usage pu ON ce.date = pu.date AND ce.country_id = pu.country_id JOIN country c ON pu.country_id = c.id WHERE c.name = 'India' AND pu.date BETWEEN '2020-01-01' AND '2020-12-31' GROUP BY c.name, cp.name;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, DonorName VARCHAR(100)); CREATE TABLE DonationsOrgs (DonationID INT, DonorID INT, OrgID INT, Amount DECIMAL(10,2)); INSERT INTO Donors (DonorID, DonorName) VALUES (1, 'John Doe'), (2, 'Jane Smith'), (3, 'Mike Johnson'); INSERT INTO DonationsOrgs (DonationID, DonorID, OrgID, Amount) VALUES (1, 1, 1, 500), (2, 1, 1, 1000), (3, 2, 1, 750), (4, 2, 2, 250), (5, 3, 2, 150), (6, 3, 2, 350), (7, 1, 3, 800), (8, 1, 3, 400), (9, 2, 3, 600), (10, 2, 3, 100);
List the top 3 contributors by total donation amount for a specific organization?
SELECT d.DonorName, SUM(do.Amount) as TotalDonations FROM Donors d JOIN DonationsOrgs do ON d.DonorID = do.DonorID WHERE do.OrgID = 3 GROUP BY d.DonorName ORDER BY TotalDonations DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE patient_kenya (id INT, age INT, diagnosis TEXT); INSERT INTO patient_kenya (id, age, diagnosis) VALUES (1, 45, 'Hypertension');
What is the minimum age of patients with hypertension in Kenya?
SELECT MIN(age) FROM patient_kenya WHERE diagnosis = 'Hypertension';
gretelai_synthetic_text_to_sql
CREATE TABLE EmployeeDemographics (EmployeeID INT PRIMARY KEY, Age INT, Gender VARCHAR(10), Ethnicity VARCHAR(20));
Insert records into the EmployeeDemographics table
INSERT INTO EmployeeDemographics (EmployeeID, Age, Gender, Ethnicity) VALUES (1, 30, 'Female', 'Hispanic'), (2, 35, 'Male', 'Caucasian'), (3, 40, 'Non-binary', 'African American');
gretelai_synthetic_text_to_sql
CREATE TABLE products (id INT PRIMARY KEY, name VARCHAR(255), category VARCHAR(255), price DECIMAL(5,2), sustainability_score INT); CREATE TABLE sustainability_scores (id INT PRIMARY KEY, product_id INT, score INT);
Insert a new record for a "Foundation" product with an id of 10, a price of $15.00, and a sustainability score of 80.
INSERT INTO products (id, name, category, price, sustainability_score) VALUES (10, 'Foundation', 'Base', 15.00, NULL); INSERT INTO sustainability_scores (id, product_id, score) VALUES (1, 10, 80);
gretelai_synthetic_text_to_sql
CREATE TABLE open_pedagogy_enrollments (student_id INT, country TEXT, open_pedagogy_course INT); INSERT INTO open_pedagogy_enrollments (student_id, country, open_pedagogy_course) VALUES (1, 'USA', 1), (2, 'Canada', 0), (3, 'Mexico', 1), (4, 'Brazil', 1), (5, 'Argentina', 0);
What is the number of students who have taken an open pedagogy course in each country?
SELECT country, SUM(open_pedagogy_course) as num_students FROM open_pedagogy_enrollments GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE crop_temperature (crop_id INT, crop_type VARCHAR(50), timestamp TIMESTAMP, temperature INT);
Calculate the average temperature for each crop type, partitioned by month.
SELECT crop_type, EXTRACT(MONTH FROM timestamp) AS month, AVG(temperature) AS avg_temperature FROM crop_temperature GROUP BY crop_type, month;
gretelai_synthetic_text_to_sql
CREATE TABLE community_education (event VARCHAR(50), fiscal_year INT); INSERT INTO community_education (event, fiscal_year) VALUES ('Wildlife Conservation Workshop', 2021), ('Habitat Restoration Symposium', 2022);
Insert a new record for a community education event in the community_education table
INSERT INTO community_education (event, fiscal_year) VALUES ('Endangered Species Awareness Campaign', 2023);
gretelai_synthetic_text_to_sql
CREATE TABLE rural_hospitals( hospital_id INT PRIMARY KEY, name VARCHAR(255), bed_count INT, rural_population_served INT);
What is the name of the hospital with id 1?
SELECT name FROM rural_hospitals WHERE hospital_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, DonorName VARCHAR(50), Country VARCHAR(50)); INSERT INTO Donors (DonorID, DonorName, Country) VALUES (1, 'John Doe', 'USA'), (2, 'Jane Smith', 'Canada'), (3, 'Donor A', 'UK'), (4, 'Donor B', 'USA'), (5, 'Donor C', 'Germany'); CREATE TABLE Donations (DonationID INT, DonorID INT, Amount DECIMAL(10,2), Field VARCHAR(50)); INSERT INTO Donations (DonationID, DonorID, Amount, Field) VALUES (1, 1, 5000, 'Education'), (2, 1, 7000, 'Arts'), (3, 2, 3000, 'Global Health'), (4, 3, 10000, 'Climate Change'), (5, 4, 8000, 'Education'), (6, 5, 9000, 'Arts');
Display the top 5 donors in terms of total donations, who have not donated to the field of global health.
SELECT D.DonorID, D.DonorName, SUM(D.Amount) FROM Donors D JOIN Donations DO ON D.DonorID = DO.DonorID WHERE DO.Field != 'Global Health' GROUP BY D.DonorID, D.DonorName ORDER BY SUM(D.Amount) DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_mammals (name VARCHAR(255), region VARCHAR(255)); INSERT INTO marine_mammals (name, region) VALUES ('Species 1', 'Arctic'); INSERT INTO marine_mammals (name, region) VALUES ('Species 2', 'Antarctic');
What is the total number of marine mammal species in the Antarctic region?
SELECT COUNT(*) FROM marine_mammals WHERE region = 'Antarctic';
gretelai_synthetic_text_to_sql
CREATE TABLE loan_types (id INT, client_id INT, country VARCHAR(50), loan_type VARCHAR(50)); INSERT INTO loan_types (id, client_id, country, loan_type) VALUES (1, 201, 'USA', 'Green Loan'), (2, 202, 'USA', 'Microfinance Loan');
What is the distribution of loan types for socially responsible lending in the US?
SELECT country, loan_type, COUNT(*) as num_loans, 100.0 * COUNT(*) / (SELECT COUNT(*) FROM loan_types WHERE country = 'USA') as percentage FROM loan_types WHERE country = 'USA' GROUP BY country, loan_type;
gretelai_synthetic_text_to_sql
CREATE TABLE europe_regulatory_frameworks (framework_name TEXT, country TEXT, enactment_date DATE);
List the regulatory frameworks in 'Europe' that have enacted blockchain-related legislation in the last 5 years.
SELECT framework_name FROM europe_regulatory_frameworks WHERE country = 'Europe' AND enactment_date >= CURRENT_DATE - INTERVAL '5 years' AND framework_name LIKE '%blockchain%';
gretelai_synthetic_text_to_sql
CREATE TABLE electric_vehicle_sales (id INT PRIMARY KEY, make VARCHAR(255), model VARCHAR(255), year INT, num_sold INT);
List all electric vehicle makes in the electric_vehicles table that have more than 1000 EVs
SELECT make FROM electric_vehicles JOIN electric_vehicle_sales ON electric_vehicles.make = electric_vehicle_sales.make WHERE electric_vehicles.ev_type = 'Electric' AND num_sold > 1000 GROUP BY make;
gretelai_synthetic_text_to_sql
CREATE TABLE concentrate_sales (dispensary_id INT, sale_date DATE, weight DECIMAL(5,2)); INSERT INTO concentrate_sales (dispensary_id, sale_date, weight) VALUES (1, '2022-04-01', 2.1), (1, '2022-05-01', 3.5), (2, '2022-04-15', 1.8); CREATE TABLE dispensaries (dispensary_id INT, state CHAR(2)); INSERT INTO dispensaries (dispensary_id, state) VALUES (1, 'WA'), (2, 'CA'), (3, 'OR');
What is the total weight of cannabis concentrate sold in Washington state in Q2 2022?
SELECT SUM(weight) FROM concentrate_sales cs JOIN dispensaries d ON cs.dispensary_id = d.dispensary_id WHERE d.state = 'WA' AND cs.sale_date BETWEEN '2022-04-01' AND '2022-06-30';
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name TEXT, industry TEXT, founding_year INT, founder_gender TEXT); CREATE TABLE funding_rounds (id INT, company_id INT, round_type TEXT, amount INT); INSERT INTO companies (id, name, industry, founding_year, founder_gender) VALUES (1, 'Healthera', 'Healthcare', 2015, 'Female'); INSERT INTO companies (id, name, industry, founding_year, founder_gender) VALUES (2, 'Vira Health', 'Healthcare', 2018, 'Female'); INSERT INTO companies (id, name, industry, founding_year, founder_gender) VALUES (3, 'Edvance', 'Education', 2017, 'Male'); INSERT INTO funding_rounds (id, company_id, round_type, amount) VALUES (1, 1, 'Seed', 1000000); INSERT INTO funding_rounds (id, company_id, round_type, amount) VALUES (2, 2, 'Series A', 5000000); INSERT INTO funding_rounds (id, company_id, round_type, amount) VALUES (3, 3, 'Seed', 2000000);
Delete the funding round with the highest amount in the education sector.
DELETE FROM funding_rounds WHERE id = (SELECT funding_rounds.id FROM funding_rounds JOIN companies ON funding_rounds.company_id = companies.id WHERE companies.industry = 'Education' ORDER BY funding_rounds.amount DESC LIMIT 1);
gretelai_synthetic_text_to_sql
CREATE TABLE Sustainability (ProductName VARCHAR(255), CO2Emission DECIMAL(10,2), WaterUsage DECIMAL(10,2), WasteGeneration DECIMAL(10,2)); INSERT INTO Sustainability (ProductName, CO2Emission, WaterUsage, WasteGeneration) VALUES ('Foundation', 1.2, 2.5, 0.7), ('Mascara', 1.5, 3.0, 1.0), ('Lip Balm', 1.1, 1.5, 0.5); CREATE TABLE VeganCertified (ProductName VARCHAR(255), Certified BOOLEAN); INSERT INTO VeganCertified (ProductName, Certified) VALUES ('Foundation', FALSE), ('Mascara', TRUE), ('Lip Balm', TRUE);
Show products that are not vegan certified and have CO2 emissions greater than 1.3.
SELECT ProductName FROM Sustainability INNER JOIN VeganCertified ON Sustainability.ProductName = VeganCertified.ProductName WHERE Sustainability.CO2Emission > 1.3 AND VeganCertified.Certified = FALSE;
gretelai_synthetic_text_to_sql
CREATE TABLE PipelineSegments (SegmentID INT, SegmentName VARCHAR(50), Length DECIMAL(10,2), Diameter DECIMAL(10,2), StartLocation VARCHAR(50), EndLocation VARCHAR(50)); INSERT INTO PipelineSegments (SegmentID, SegmentName, Length, Diameter, StartLocation, EndLocation) VALUES (1, 'Alaska Pipeline Segment 1', 12.34, 34.56, 'Prudhoe Bay', 'Valdez'); INSERT INTO PipelineSegments (SegmentID, SegmentName, Length, Diameter, StartLocation, EndLocation) VALUES (2, 'Alaska Pipeline Segment 2', 15.67, 45.67, 'Valdez', 'Anchorage');
Calculate the average length and diameter of pipeline segments with a start location in Valdez.
SELECT StartLocation, AVG(Length) AS Avg_Length, AVG(Diameter) AS Avg_Diameter FROM PipelineSegments WHERE StartLocation = 'Valdez' GROUP BY StartLocation;
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (DonationID INT, DonationRegion TEXT, DonationAmount DECIMAL(10,2)); INSERT INTO Donations (DonationID, DonationRegion, DonationAmount) VALUES (1, 'Asia', 1000.00), (2, 'Africa', 1500.00), (3, 'Europe', 2000.00), (4, 'Asia', 500.00), (5, 'Africa', 800.00), (6, 'Europe', 1200.00);
List all regions with a total donation amount above the overall average, in alphabetical order.
SELECT DonationRegion, SUM(DonationAmount) AS TotalDonation FROM Donations GROUP BY DonationRegion HAVING SUM(DonationAmount) > (SELECT AVG(DonationAmount) FROM Donations) ORDER BY TotalDonation;
gretelai_synthetic_text_to_sql
CREATE TABLE VisitorStatistics (visitor_id INT, destination VARCHAR(50), country VARCHAR(50), visit_date DATE); INSERT INTO VisitorStatistics (visitor_id, destination, country, visit_date) VALUES (1, 'Eco Lodge', 'Kenya', '2021-01-01'); INSERT INTO VisitorStatistics (visitor_id, destination, country, visit_date) VALUES (2, 'Green Safari', 'Tanzania', '2021-07-01');
What is the total number of visitors to sustainable destinations in Africa in 2021?
SELECT SUM(visitor_id) FROM VisitorStatistics WHERE country = 'Africa' AND YEAR(visit_date) = 2021 AND destination IN ('Eco Lodge', 'Green Safari');
gretelai_synthetic_text_to_sql
CREATE TABLE news_articles (article_id INT PRIMARY KEY, title TEXT, topic TEXT, author TEXT, publication_date DATE);
What is the total number of articles published by each author?
SELECT author, COUNT(*) FROM news_articles GROUP BY author;
gretelai_synthetic_text_to_sql
CREATE TABLE Faculty_Demographics (id INT, faculty_id INT, college VARCHAR(50), ethnicity VARCHAR(50)); CREATE TABLE Disability_Training (id INT, faculty_id INT, training_type VARCHAR(50), completed BOOLEAN); INSERT INTO Faculty_Demographics (id, faculty_id, college, ethnicity) VALUES (1, 7001, 'Education', 'Asian'), (2, 7002, 'Engineering', 'African American'), (3, 7003, 'Business', 'Hispanic'), (4, 7004, 'Arts', 'Native American'); INSERT INTO Disability_Training (id, faculty_id, training_type, completed) VALUES (1, 7001, 'Disability Awareness', true), (2, 7002, 'Disability Awareness', false), (3, 7003, 'Disability Awareness', true), (4, 7004, 'Disability Awareness', true);
What is the percentage of faculty who have completed disability awareness training by college and ethnicity?
SELECT (COUNT(Disability_Training.completed) * 100.0 / COUNT(Faculty_Demographics.faculty_id)) as percentage, Faculty_Demographics.college, Faculty_Demographics.ethnicity FROM Faculty_Demographics INNER JOIN Disability_Training ON Faculty_Demographics.faculty_id = Disability_Training.faculty_id WHERE Disability_Training.training_type = 'Disability Awareness' GROUP BY Faculty_Demographics.college, Faculty_Demographics.ethnicity;
gretelai_synthetic_text_to_sql
CREATE TABLE customer_meals (customer_id INTEGER, restaurant_name TEXT, city TEXT, calories INTEGER, meal_date DATE); INSERT INTO customer_meals (customer_id, restaurant_name, city, calories, meal_date) VALUES (1, 'Green Garden', 'Berlin', 1200, '2022-01-01'); INSERT INTO customer_meals (customer_id, restaurant_name, city, calories, meal_date) VALUES (2, 'Green Garden', 'Berlin', 1500, '2022-01-01');
What are the total calories consumed by each customer for the 'Green Garden' restaurant in Berlin, Germany in the month of January 2022, ranked by consumption?
SELECT customer_id, SUM(calories) as total_calories FROM customer_meals WHERE restaurant_name = 'Green Garden' AND city = 'Berlin' AND meal_date >= '2022-01-01' AND meal_date < '2022-02-01' GROUP BY customer_id ORDER BY total_calories DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE country_wastewater (country VARCHAR(255), plants INT); INSERT INTO country_wastewater (country, plants) VALUES ('United States', 16000), ('China', 22000), ('India', 9000);
How many wastewater treatment plants are there in each country?
SELECT country, COUNT(plants) FROM country_wastewater GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (id INT, account_id INT, transaction_date DATE); CREATE TABLE customers (id INT, name VARCHAR(100), age INT, gender VARCHAR(10), city VARCHAR(50), state VARCHAR(50));
Identify customers from Texas who have made more than 5 transactions in the last week.
SELECT c.id, c.name FROM customers c JOIN (SELECT account_id FROM transactions t WHERE t.transaction_date >= DATEADD(day, -7, CURRENT_DATE) GROUP BY account_id HAVING COUNT(id) > 5) t ON c.id = t.account_id WHERE c.state = 'Texas';
gretelai_synthetic_text_to_sql
CREATE TABLE facilities (facility_id INT, facility_name TEXT, capacity INT, location TEXT); CREATE TABLE nonprofits (nonprofit_id INT, nonprofit_name TEXT, sector TEXT); CREATE TABLE nonprofit_facilities (nonprofit_id INT, facility_id INT); INSERT INTO facilities VALUES (1, 'Community Clinic', 50, 'New York'); INSERT INTO nonprofits VALUES (1, 'HealthCare NY', 'health'); INSERT INTO nonprofit_facilities VALUES (1, 1);
What is the average capacity utilization of nonprofits focused on health in the US?
SELECT AVG(f.capacity / count(*)) as avg_capacity_utilization FROM facilities f JOIN nonprofit_facilities nf ON f.facility_id = nf.facility_id JOIN nonprofits n ON nf.nonprofit_id = n.nonprofit_id WHERE n.sector = 'health';
gretelai_synthetic_text_to_sql
CREATE TABLE MentalHealthParityPolicies (ID INT, Policy VARCHAR(50), Organization VARCHAR(50), Region VARCHAR(50)); CREATE TABLE Organizations (ID INT, Name VARCHAR(50), CulturalCompetencyScore INT); INSERT INTO MentalHealthParityPolicies (ID, Policy, Organization, Region) VALUES (1, 'MHP Policy 1', 'Org A', 'Midwest'); INSERT INTO Organizations (ID, Name, CulturalCompetencyScore) VALUES (1, 'Org A', 85);
List all mental health parity policies in the Midwest region, along with the organizations that implemented them and their respective cultural competency scores?
SELECT MHPPolicies.Policy, Organizations.Name, Organizations.CulturalCompetencyScore FROM MentalHealthParityPolicies AS MHPPolicies INNER JOIN Organizations ON MHPPolicies.Organization = Organizations.Name WHERE MHPPolicies.Region = 'Midwest';
gretelai_synthetic_text_to_sql
CREATE TABLE Explainable_Models (Model_Type VARCHAR(20), Model_Name VARCHAR(30)); INSERT INTO Explainable_Models (Model_Type, Model_Name) VALUES ('Classical', 'Decision Trees'), ('Classical', 'Logistic Regression'), ('Deep', 'DeepLIFT'), ('Deep', 'SHAP');
What is the total number of models, both classical and deep, developed for explainable AI?
SELECT COUNT(*) FROM Explainable_Models;
gretelai_synthetic_text_to_sql
CREATE TABLE customer_purchases ( id INT PRIMARY KEY, gender VARCHAR(255), size VARCHAR(255), purchase_date DATE ); CREATE VIEW customer_purchases_group AS SELECT gender, size, COUNT(*) as purchase_frequency FROM customer_purchases GROUP BY gender, size;
Which size is most frequently purchased by gender?
SELECT gender, size, ROW_NUMBER() OVER (PARTITION BY gender ORDER BY purchase_frequency DESC) as most_frequent_size FROM customer_purchases_group;
gretelai_synthetic_text_to_sql
CREATE TABLE Protected_Habitats (id INT, country VARCHAR(50), size INT);
What is the average size of protected habitats for each country?
SELECT country, AVG(size) FROM Protected_Habitats GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, name VARCHAR(255)); CREATE TABLE regional_bank_transactions (transaction_id INT, customer_id INT, amount DECIMAL(10,2), trans_date DATE);
Identify the top 3 customers with the highest transaction values in the past week in a regional bank?
SELECT customers.name, SUM(regional_bank_transactions.amount) as total_amount FROM customers INNER JOIN regional_bank_transactions ON customers.customer_id = regional_bank_transactions.customer_id WHERE regional_bank_transactions.trans_date >= NOW() - INTERVAL '1 week' GROUP BY customers.name ORDER BY total_amount DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE individuals_state (ind_id INT, ind_name TEXT, state_id INT);CREATE TABLE states (state_id INT, state_name TEXT);
How many individuals with disabilities are enrolled in each state?
SELECT s.state_name, COUNT(i.ind_id) AS enrolled_individuals FROM individuals_state i INNER JOIN states s ON i.state_id = s.state_id GROUP BY s.state_name;
gretelai_synthetic_text_to_sql
CREATE TABLE donors (id INT, name TEXT, amount_donated DECIMAL(10,2)); INSERT INTO donors (id, name, amount_donated) VALUES (1, 'John Doe', 500.00), (2, 'Jane Smith', 350.00);
What is the total amount donated by individuals in the 'donors' table?
SELECT SUM(amount_donated) FROM donors WHERE id < 3 AND type = 'individual';
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists biotech; USE biotech; CREATE TABLE if not exists startups (id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255), funding DECIMAL(10,2)); INSERT INTO startups (id, name, country, funding) VALUES (1, 'StartupA', 'USA', 5000000.00), (2, 'StartupB', 'USA', 7000000.00), (3, 'StartupC', 'Canada', 3000000.00);
List all biotech startups with their associated funding.
SELECT * FROM startups;
gretelai_synthetic_text_to_sql
CREATE TABLE Permits (PermitID INT, ProjectID INT, PermitType CHAR(1), PermitDate DATE);
Update the permit type to 'C' for permit number 2022001 in the Permits table.
UPDATE Permits SET PermitType='C' WHERE PermitID=2022001;
gretelai_synthetic_text_to_sql
CREATE TABLE bsc_digital_assets (asset_id INT, asset_name VARCHAR(50), network VARCHAR(20)); INSERT INTO bsc_digital_assets (asset_id, asset_name, network) VALUES (1, 'BNB', 'Binance Smart Chain'); CREATE TABLE bsc_contract_transactions (transaction_id INT, asset_id INT, block_number INT, value DECIMAL(10,2)); INSERT INTO bsc_contract_transactions (transaction_id, asset_id, block_number, value) VALUES (1, 1, 10, 100.50); INSERT INTO bsc_contract_transactions (transaction_id, asset_id, block_number, value) VALUES (2, 1, 20, 200.25);
What is the average value of transactions for each digital asset on the 'Binance Smart Chain'?
SELECT d.asset_name, AVG(c.value) as avg_value FROM bsc_digital_assets d JOIN bsc_contract_transactions c ON d.asset_id = c.asset_id WHERE d.network = 'Binance Smart Chain' GROUP BY d.asset_name;
gretelai_synthetic_text_to_sql
CREATE TABLE mining_site_2 (site_id INT, mineral_type VARCHAR(50), production_date DATE, num_employees INT); INSERT INTO mining_site_2 (site_id, mineral_type, production_date, num_employees) VALUES (1, 'gold', '2014-01-02', 60), (2, 'copper', '2013-12-31', 150), (3, 'gold', '2016-03-04', 20), (4, 'copper', '2015-06-10', 50), (5, 'silver', '2015-06-10', 45), (6, 'silver', '2015-06-10', 40);
What is the minimum number of employees per mining site, grouped by mineral type, for mining sites having a production date on or after 2014-01-01 and less than 50 employees?
SELECT mineral_type, MIN(num_employees) as min_employees FROM mining_site_2 WHERE production_date >= '2014-01-01' AND num_employees < 50 GROUP BY mineral_type;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, name VARCHAR(255), category VARCHAR(255), sales_volume INT);
List all products that have a sales volume higher than the average sales volume for their respective category, ordered by category in ascending order.
SELECT * FROM products WHERE sales_volume > (SELECT AVG(sales_volume) FROM products p2 WHERE p2.category = products.category) ORDER BY category ASC;
gretelai_synthetic_text_to_sql
CREATE TABLE olympic_athletes (athlete_id INT, athlete_name VARCHAR(50), sport VARCHAR(50), gold INT, silver INT, bronze INT);
List the top 3 athletes with the most gold medals in swimming?
SELECT athlete_name FROM olympic_athletes WHERE sport = 'swimming' ORDER BY gold DESC, silver DESC, bronze DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_life (id INT, name VARCHAR(255), depth FLOAT); INSERT INTO marine_life (id, name, depth) VALUES (1, 'Coral Reef', 10.0), (2, 'Seagrass Meadow', 25.0), (3, 'Open Ocean', 4000.0);
What is the average depth of marine life habitats?
SELECT AVG(depth) FROM marine_life WHERE depth IS NOT NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE restaurant_revenue (item VARCHAR(50), revenue NUMERIC(10,2), sales_date DATE); INSERT INTO restaurant_revenue (item, revenue, sales_date) VALUES ('Organic Veggie Pizza', 120.50, '2022-01-01'), ('Organic Veggie Pizza', 155.25, '2022-01-02');
What was the total revenue for the 'Organic Veggie Pizza' item in January 2022?
SELECT SUM(revenue) FROM restaurant_revenue WHERE item = 'Organic Veggie Pizza' AND sales_date BETWEEN '2022-01-01' AND '2022-01-31';
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name VARCHAR(50), esg_rating VARCHAR(1)); INSERT INTO companies (id, name, esg_rating) VALUES (1, 'ABC Inc.', 'A'); INSERT INTO companies (id, name, esg_rating) VALUES (2, 'DEF Inc.', 'B'); INSERT INTO companies (id, name, esg_rating) VALUES (3, 'XYZ Inc.', 'C');
Update the ESG rating of 'XYZ Inc.' to 'B' in the companies table.
UPDATE companies SET esg_rating = 'B' WHERE name = 'XYZ Inc.';
gretelai_synthetic_text_to_sql
CREATE TABLE Complaints (Date DATE, Department VARCHAR(20), Complaint INT); INSERT INTO Complaints (Date, Department, Complaint) VALUES ('2021-01-01', 'Police', 100), ('2021-01-02', 'Fire', 50), ('2021-01-03', 'Police', 120);
How many citizen complaints were there in Q1 2021, separated by department?
SELECT Department, COUNT(Complaint) FROM Complaints WHERE Date BETWEEN '2021-01-01' AND '2021-03-31' GROUP BY Department;
gretelai_synthetic_text_to_sql
CREATE TABLE financial_capability (id INT, individual_id INT, annual_income DECIMAL(10,2), financially_capable BOOLEAN, country VARCHAR(50));
What is the average annual income for financially capable individuals in Europe?
SELECT AVG(annual_income) FROM financial_capability WHERE financially_capable = TRUE AND country LIKE 'Europe%';
gretelai_synthetic_text_to_sql
CREATE TABLE Suppliers (SupplierID int, SupplierName varchar(255), IsFairTrade boolean); INSERT INTO Suppliers (SupplierID, SupplierName, IsFairTrade) VALUES (1, 'Supplier A', true), (2, 'Supplier B', false); CREATE TABLE Orders (OrderID int, SupplierID int, DeliveryTime int);
What is the average delivery time for products sourced from Fair Trade suppliers?
SELECT AVG(DeliveryTime) FROM Orders WHERE SupplierID IN (SELECT SupplierID FROM Suppliers WHERE IsFairTrade = true);
gretelai_synthetic_text_to_sql
CREATE TABLE accommodations (accommodation_id INT, name TEXT, city TEXT, eco_friendly BOOLEAN); INSERT INTO accommodations (accommodation_id, name, city, eco_friendly) VALUES (1, 'Hotel Kyoto Brighton', 'Kyoto', true), (2, 'Imano Kyoto Hostel', 'Kyoto', true), (3, 'The Royal Park Hotel Kyoto Sanjo', 'Kyoto', false);
What is the total number of eco-friendly accommodations in Kyoto?
SELECT COUNT(*) FROM accommodations WHERE city = 'Kyoto' AND eco_friendly = true;
gretelai_synthetic_text_to_sql
CREATE TABLE regions (id INT, name VARCHAR(255)); INSERT INTO regions (id, name) VALUES (1, 'North'), (2, 'South'); CREATE TABLE forests (id INT, region_id INT, name VARCHAR(255)); INSERT INTO forests (id, region_id, name) VALUES (1, 1, 'Northern Forest'), (2, 1, 'Snowy Forest'), (3, 2, 'Southern Forest'); CREATE TABLE wildlife_habitats (id INT, forest_id INT, animal VARCHAR(255)); INSERT INTO wildlife_habitats (id, forest_id, animal) VALUES (1, 1, 'Moose'), (2, 1, 'Lynx'), (3, 2, 'Wolverine');
List all forests in the 'North' region and their wildlife habitats.
SELECT f.name, wh.animal FROM forests f JOIN wildlife_habitats wh ON f.id = wh.forest_id WHERE f.region_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE workers (id INT, role TEXT, ethnicity TEXT); INSERT INTO workers (id, role, ethnicity) VALUES (1, 'Manager', 'Non-Indigenous'), (2, 'Engineer', 'Indigenous'), (3, 'Operator', 'Non-Indigenous'), (4, 'Manager', 'Indigenous'), (5, 'Engineer', 'Non-Indigenous'), (6, 'Operator', 'Indigenous');
What is the percentage of Indigenous workers in the mining industry by role?
SELECT role, (COUNT(*) FILTER (WHERE ethnicity = 'Indigenous')) * 100.0 / COUNT(*) FROM workers GROUP BY role;
gretelai_synthetic_text_to_sql
CREATE TABLE autonomous_buses (id INT, make VARCHAR(255), model VARCHAR(255), license_plate VARCHAR(255), city VARCHAR(255), state VARCHAR(255)); INSERT INTO autonomous_buses (id, make, model, license_plate, city, state) VALUES (1, 'Autonodyne', 'E-Bus', 'A1B2C3', 'New York', 'NY'); INSERT INTO autonomous_buses (id, make, model, license_plate, city, state) VALUES (2, 'EasyMile', 'Flash', 'D4E5F6', 'Los Angeles', 'CA'); INSERT INTO autonomous_buses (id, make, model, license_plate, city, state) VALUES (3, 'Navya', 'Arma', 'G7H8I9', 'Chicago', 'IL');
How many autonomous buses are there in New York, Los Angeles, and Chicago?
SELECT COUNT(*) FROM autonomous_buses WHERE city IN ('New York', 'Los Angeles', 'Chicago');
gretelai_synthetic_text_to_sql
CREATE TABLE districts (district_id INT, district_name TEXT); INSERT INTO districts (district_id, district_name) VALUES (1, 'Urban'), (2, 'Suburban'), (3, 'Rural'); CREATE TABLE students (student_id INT, student_name TEXT, district_id INT, mental_health_score INT); INSERT INTO students (student_id, student_name, district_id, mental_health_score) VALUES (1, 'Jamal Johnson', 1, 85), (2, 'Sofia Rodriguez', 2, 90), (3, 'Hana Lee', 3, 70), (4, 'Alex Brown', 2, 95), (5, 'Nia Davis', 1, 80);
What is the minimum mental health score of students in the 'Rural' district?
SELECT MIN(s.mental_health_score) as min_score FROM students s JOIN districts d ON s.district_id = d.district_id WHERE d.district_name = 'Rural';
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_subscribers (subscriber_id INT, has_mobile BOOLEAN);
Find subscribers who have both mobile and broadband services
SELECT m.subscriber_id FROM mobile_subscribers m JOIN broadband_subscribers b ON m.subscriber_id = b.subscriber_id WHERE m.has_mobile = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE tourism_data (visitor_id INT, country VARCHAR(50), arrival_age INT); INSERT INTO tourism_data (visitor_id, country, arrival_age) VALUES (1, 'USA', 35), (2, 'USA', 42), (3, 'Japan', 28), (4, 'Australia', 31), (5, 'UK', 29), (6, 'UK', 34), (7, 'Canada', 22), (8, 'Canada', 25); CREATE VIEW uk_aus_visitors AS SELECT * FROM tourism_data WHERE country IN ('UK', 'Australia');
What is the total number of visitors from the United Kingdom and Australia?
SELECT COUNT(*) FROM uk_aus_visitors;
gretelai_synthetic_text_to_sql
CREATE TABLE user_data (id INT, name VARCHAR(50), gender VARCHAR(10), country VARCHAR(50), heart_rate INT); INSERT INTO user_data (id, name, gender, country, heart_rate) VALUES (4, 'Raj Patel', 'Male', 'India', 90), (5, 'Yumi Nakamura', 'Female', 'Japan', 85), (6, 'Akshay Singh', 'Male', 'India', 95), (7, 'Hanae Sato', 'Female', 'Japan', 90);
What is the maximum heart rate recorded for users in India and Japan, grouped by gender?
SELECT gender, MAX(heart_rate) as max_heart_rate FROM user_data WHERE country IN ('India', 'Japan') GROUP BY gender;
gretelai_synthetic_text_to_sql