context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE fund_managers (id INT, name VARCHAR(50), category VARCHAR(20), performance FLOAT); INSERT INTO fund_managers (id, name, category, performance) VALUES (1, 'John Smith', 'ESG', 92.5), (2, 'Jane Doe', 'traditional', 88.0), (3, 'Mary Major', 'ESG', 90.3), (4, 'Mike Minor', 'traditional', 85.2);
Who is the top performing fund manager in the 'ESG' category?
SELECT name FROM fund_managers WHERE category = 'ESG' ORDER BY performance DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE WasteGeneration (id INT, area VARCHAR(10), amount INT); INSERT INTO WasteGeneration (id, area, amount) VALUES (1, 'urban', 3500), (2, 'rural', 2000);
Calculate the difference between the waste generation figures of urban and rural areas.
SELECT (SELECT SUM(amount) FROM WasteGeneration WHERE area = 'urban') - (SELECT SUM(amount) FROM WasteGeneration WHERE area = 'rural');
gretelai_synthetic_text_to_sql
CREATE TABLE education_programs (id INT, program_name VARCHAR(255), budget INT); INSERT INTO education_programs (id, program_name, budget) VALUES (1, 'Wildlife Awareness', 15000), (2, 'Conservation Workshops', 20000), (3, 'Nature Camps', 10000);
List all community education programs and their respective budgets
SELECT program_name, budget FROM education_programs;
gretelai_synthetic_text_to_sql
CREATE TABLE inventory (id INT, garment_id INT, material VARCHAR(50), CO2_emissions INT); INSERT INTO inventory (id, garment_id, material, CO2_emissions) VALUES (1, 1011, 'wool', 12);
What is the total CO2 emissions for garments made of wool?
SELECT SUM(CO2_emissions) FROM inventory WHERE material = 'wool';
gretelai_synthetic_text_to_sql
CREATE TABLE retail_union_members (member_id INT, union VARCHAR(20), gender VARCHAR(10), age INT); INSERT INTO retail_union_members (member_id, union, gender, age) VALUES (1, 'Retail', 'Female', 25); INSERT INTO retail_union_members (member_id, union, gender, age) VALUES (2, 'Retail', 'Male', 30);
What is the minimum age of 'retail' union members who are female?
SELECT MIN(age) FROM retail_union_members WHERE gender = 'Female';
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species_by_ocean (species_name VARCHAR(50), ocean_name VARCHAR(50)); INSERT INTO marine_species_by_ocean (species_name, ocean_name) VALUES ('Polar Bear', 'Arctic'), ('Krill', 'Antarctic'), ('Walrus', 'Arctic');
What is the total number of marine species in the Arctic and Antarctic Oceans?
SELECT COUNT(DISTINCT species_name) FROM marine_species_by_ocean WHERE ocean_name IN ('Arctic', 'Antarctic');
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (id INT, donor VARCHAR(50), city VARCHAR(50), amount FLOAT, donation_date DATE); INSERT INTO Donors (id, donor, city, amount, donation_date) VALUES (1, 'John Doe', 'New York', 500, '2020-01-01'); INSERT INTO Donors (id, donor, city, amount, donation_date) VALUES (2, 'Jane Smith', 'Los Angeles', 300,...
Who were the top 3 donors in 2020 and what was their total donation amount?
SELECT donor, SUM(amount) as total_donation FROM Donors WHERE YEAR(donation_date) = 2020 GROUP BY donor ORDER BY total_donation DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE pollution_reports (id INT, location TEXT, date DATE, type TEXT); INSERT INTO pollution_reports (id, location, date, type) VALUES (1, 'Bermuda Triangle', '2021-06-01', 'Oil Spill'), (2, 'North Atlantic Garbage Patch', '2021-07-15', 'Plastic Waste');
How many pollution incidents were reported in the Atlantic Ocean in 2021?
SELECT COUNT(*) FROM pollution_reports WHERE location LIKE '%Atlantic%' AND date BETWEEN '2021-01-01' AND '2021-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE AquaticSpecies (id INT, species VARCHAR(255), population INT); INSERT INTO AquaticSpecies (id, species, population) VALUES (1, 'Salmon', 50000); INSERT INTO AquaticSpecies (id, species, population) VALUES (2, 'Trout', 25000); INSERT INTO AquaticSpecies (id, species, population) VALUES (3, 'Carp', 40000); I...
Display the total population of fish for each species in the 'AquaticSpecies' table
SELECT species, SUM(population) FROM AquaticSpecies GROUP BY species;
gretelai_synthetic_text_to_sql
CREATE SCHEMA disease_data; CREATE TABLE malaria_cases (id INT, clinic_id INT, date DATE, cases INT); INSERT INTO disease_data.malaria_cases (id, clinic_id, date, cases) VALUES (1, 1001, '2019-01-01', 2), (2, 1001, '2019-02-01', 3), (3, 1002, '2019-03-01', 1), (4, 1002, '2019-04-01', 5), (5, 1003, '2019-05-01', 4);
How many malaria cases were reported in 'disease_data' for the year 2019?
SELECT SUM(cases) FROM disease_data.malaria_cases WHERE date BETWEEN '2019-01-01' AND '2019-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE Farm ( id INT PRIMARY KEY, location VARCHAR(50) ); CREATE TABLE Salmon ( id INT, survival_rate DECIMAL(5,2), farm_id INT, FOREIGN KEY (farm_id) REFERENCES Farm(id) );
What is the average survival rate of salmon by farm location?
SELECT Farm.location, AVG(Salmon.survival_rate) FROM Farm INNER JOIN Salmon ON Farm.id = Salmon.farm_id GROUP BY Farm.location;
gretelai_synthetic_text_to_sql
CREATE TABLE south_america_initiatives (region VARCHAR(50), initiative_name VARCHAR(50), budget NUMERIC(10,2), start_date DATE); INSERT INTO south_america_initiatives (region, initiative_name, budget, start_date) VALUES ('South America', 'Green Schools', 25000, '2019-01-01'), ('South America', 'Sustainable Agriculture'...
Get the circular economy initiative name and start date with the lowest budget for 'South America'.
SELECT initiative_name, start_date FROM (SELECT initiative_name, start_date, ROW_NUMBER() OVER (PARTITION BY region ORDER BY budget ASC) AS rn FROM south_america_initiatives WHERE region = 'South America') x WHERE rn = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE jaxa_satellites (id INT, satellite_name VARCHAR(255), launch_date DATE, organization VARCHAR(255)); INSERT INTO jaxa_satellites (id, satellite_name, launch_date, organization) VALUES (1, 'Hayabusa 2', '2014-12-03', 'JAXA');
What is the latest launch date of a satellite by the Japan Aerospace Exploration Agency (JAXA)?
SELECT MAX(launch_date) FROM jaxa_satellites WHERE organization = 'JAXA';
gretelai_synthetic_text_to_sql
CREATE TABLE EmployeeTraining (EmployeeID INT, Department VARCHAR(255), TrainingID INT); CREATE TABLE TrainingCourses (TrainingID INT, TrainingName VARCHAR(255), Completed DATE); INSERT INTO EmployeeTraining (EmployeeID, Department, TrainingID) VALUES (1, 'HR', 1), (2, 'IT', 2), (3, 'IT', 1), (4, 'HR', NULL); INSERT IN...
What is the percentage of employees who have completed leadership training, by department?
SELECT Department, COUNT(DISTINCT e.EmployeeID) * 100.0 / (SELECT COUNT(DISTINCT EmployeeID) FROM Employees WHERE Department = e.Department) AS Percentage FROM EmployeeTraining e JOIN TrainingCourses t ON e.TrainingID = t.TrainingID WHERE t.Completed IS NOT NULL GROUP BY e.Department;
gretelai_synthetic_text_to_sql
CREATE TABLE sustainability (product_id INT, product_name VARCHAR(100), brand VARCHAR(50), sustainability_score DECIMAL(3, 2)); INSERT INTO sustainability (product_id, product_name, brand, sustainability_score) VALUES (1, 'Cleanser', 'Green Essentials', 4.2), (2, 'Toner', 'Natural Path', 4.5);
What are the top 3 sustainable brands with the highest average sustainability scores?
SELECT brand, AVG(sustainability_score) AS avg_sustainability_score FROM sustainability GROUP BY brand ORDER BY avg_sustainability_score DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE digital_assets (asset_id INT, asset_name TEXT, creation_date DATE); INSERT INTO digital_assets (asset_id, asset_name, creation_date) VALUES (1, 'Asset1', '2021-05-15'); INSERT INTO digital_assets (asset_id, asset_name, creation_date) VALUES (2, 'Asset2', '2022-08-20'); CREATE TABLE smart_contracts (contrac...
What is the total number of smart contracts associated with digital assets that were created after 2020-01-01?
SELECT COUNT(*) FROM smart_contracts JOIN digital_assets ON smart_contracts.asset_id = digital_assets.asset_id WHERE smart_contracts.creation_date > '2020-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE mining_operations (id INT, state VARCHAR(255), environmental_impact_score INT); INSERT INTO mining_operations (id, state, environmental_impact_score) VALUES (1, 'New South Wales', 60), (2, 'New South Wales', 70), (3, 'Queensland', 80), (4, 'Queensland', 90), (5, 'Western Australia', 50), (6, 'Western Austr...
What is the average environmental impact score of mining operations in each state of Australia?
SELECT state, AVG(environmental_impact_score) FROM mining_operations GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE patients (id INT, country VARCHAR(255), improvement VARCHAR(255)); INSERT INTO patients (id, country, improvement) VALUES (1, 'USA', 'Improved'), (2, 'USA', 'Not Improved'), (3, 'USA', 'Improved'); CREATE TABLE therapy (patient_id INT, therapy_type VARCHAR(255)); INSERT INTO therapy (patient_id, therapy_ty...
What is the percentage of patients who received CBT and reported improvement?
SELECT 100.0 * COUNT(CASE WHEN improvement = 'Improved' AND therapy_type = 'CBT' THEN 1 END) / COUNT(*) as percentage FROM patients JOIN therapy ON patients.id = therapy.patient_id;
gretelai_synthetic_text_to_sql
CREATE TABLE security_incidents (id INT, organization TEXT, country TEXT, incident_date DATE); INSERT INTO security_incidents (id, organization, country, incident_date) VALUES (1, 'Healthcare Organization A', 'USA', '2021-04-05'); INSERT INTO security_incidents (id, organization, country, incident_date) VALUES (2, 'Hea...
How many security incidents were there in healthcare organizations in Q2 2021, grouped by country?
SELECT country, COUNT(*) FROM security_incidents WHERE organization LIKE '%Healthcare Organization%' AND incident_date >= '2021-04-01' AND incident_date < '2021-07-01' GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE EV_Sales (id INT, vehicle_model VARCHAR(255), production_year INT, is_electric BOOLEAN); INSERT INTO EV_Sales (id, vehicle_model, production_year, is_electric) VALUES (1, 'Nissan Leaf', 2020, true); INSERT INTO EV_Sales (id, vehicle_model, production_year, is_electric) VALUES (2, 'Toyota Prius', 2019, true...
Find the number of electric vehicles produced in Japan in the year 2020.
SELECT COUNT(*) FROM EV_Sales WHERE production_year = 2020 AND is_electric = true AND vehicle_model IN (SELECT vehicle_model FROM EV_Sales WHERE production_year = 2020 GROUP BY vehicle_model HAVING COUNT(DISTINCT production_year) > 1);
gretelai_synthetic_text_to_sql
CREATE TABLE sustainable_water_projects (id INT, investment_date DATE, project_type VARCHAR(255), investment_amount FLOAT);
What was the total sustainable investment in water conservation projects in 2020?
SELECT SUM(investment_amount) FROM sustainable_water_projects WHERE project_type = 'water conservation' AND investment_date BETWEEN '2020-01-01' AND '2020-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE train_stations (station_id INT, station_name TEXT, is_accessible BOOLEAN); INSERT INTO train_stations (station_id, station_name, is_accessible) VALUES (1, 'Union Station', true), (2, 'City Hall', false), (3, 'Downtown Crossing', true);
Which train stations have accessibility features?
SELECT station_id, station_name, is_accessible FROM train_stations WHERE is_accessible = true;
gretelai_synthetic_text_to_sql
CREATE TABLE Economic_Impact (id INT, venue_id INT, revenue INT, jobs_created INT); INSERT INTO Economic_Impact (id, venue_id, revenue, jobs_created) VALUES (1, 1, 100000, 50); INSERT INTO Economic_Impact (id, venue_id, revenue, jobs_created) VALUES (2, 2, 150000, 75); INSERT INTO Economic_Impact (id, venue_id, revenue...
What is the total revenue generated by venues with more than 50 jobs created?
SELECT SUM(revenue) as 'Total Revenue' FROM Economic_Impact WHERE venue_id IN (SELECT venue_id FROM Economic_Impact GROUP BY venue_id HAVING SUM(jobs_created) > 50);
gretelai_synthetic_text_to_sql
CREATE TABLE threat_intelligence (id INT PRIMARY KEY, source VARCHAR(50), actionable_report BOOLEAN); INSERT INTO threat_intelligence (id, source, actionable_report) VALUES (1, 'FireEye', TRUE), (2, 'CrowdStrike', FALSE), (3, 'Mandiant', TRUE);
List the top 3 threat intelligence sources that provided the most actionable intelligence in the past month, along with the number of actionable intelligence reports.
SELECT source, COUNT(*) as actionable_reports FROM threat_intelligence WHERE actionable_report = TRUE AND id IN (SELECT id FROM threat_intelligence WHERE occurrence_time >= NOW() - INTERVAL '1 month' ORDER BY id DESC LIMIT 3) GROUP BY source ORDER BY actionable_reports DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Projects (id INT PRIMARY KEY, project_name VARCHAR(255), country VARCHAR(255), budget FLOAT);
Delete all records in the 'Projects' table where the country is 'Indonesia'
DELETE FROM Projects WHERE country = 'Indonesia';
gretelai_synthetic_text_to_sql
CREATE TABLE maritime_laws (region TEXT, year INT, law_name TEXT); INSERT INTO maritime_laws (region, year, law_name) VALUES ('Mediterranean Sea', 2010, 'MARPOL Annex V'); INSERT INTO maritime_laws (region, year, law_name) VALUES ('Mediterranean Sea', 2012, 'MSFD'); INSERT INTO maritime_laws (region, year, law_name) VA...
Which maritime laws were enacted in the Mediterranean Sea since 2010?
SELECT * FROM maritime_laws WHERE region = 'Mediterranean Sea' AND year >= 2010;
gretelai_synthetic_text_to_sql
CREATE TABLE Labor_Unions (id INT, union_type VARCHAR(20)); INSERT INTO Labor_Unions (id, union_type) VALUES (1, 'Trade'), (2, 'Industrial'), (3, 'Trade'), (4, 'Professional');
Show the number of unions by 'Union_Type' in the 'Labor_Unions' table.
SELECT union_type, COUNT(*) FROM Labor_Unions GROUP BY union_type;
gretelai_synthetic_text_to_sql
CREATE TABLE accommodation(accommodation_id INT, accommodation_name TEXT, country TEXT, is_eco_friendly BOOLEAN, occupancy_rate INT); INSERT INTO accommodation (accommodation_id, accommodation_name, country, is_eco_friendly, occupancy_rate) VALUES (1, 'Eco Lodge', 'Brazil', true, 85), (2, 'Luxury Resort', 'Brazil', fal...
What is the average occupancy rate for eco-friendly accommodations in Brazil?
SELECT AVG(occupancy_rate) FROM accommodation WHERE country = 'Brazil' AND is_eco_friendly = true;
gretelai_synthetic_text_to_sql
CREATE TABLE PeacekeepingOperations (nation VARCHAR(50), year INT, operation_count INT); INSERT INTO PeacekeepingOperations (nation, year, operation_count) VALUES ('Egypt', 2017, 3), ('Nigeria', 2017, 4), ('South Africa', 2017, 2), ('Algeria', 2017, 1), ('Morocco', 2017, 5), ('Egypt', 2018, 3), ('Nigeria', 2018, 4), ('...
How many peacekeeping operations were conducted by African nations between 2017 and 2021?
SELECT SUM(operation_count) FROM PeacekeepingOperations WHERE nation IN ('Egypt', 'Nigeria', 'South Africa', 'Algeria', 'Morocco') AND year BETWEEN 2017 AND 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE SpacecraftManufacturing (id INT, model VARCHAR, cost FLOAT);
What is the NTILE rank of spacecraft models based on their manufacturing cost?
SELECT model, NTILE(4) OVER (ORDER BY cost) FROM SpacecraftManufacturing;
gretelai_synthetic_text_to_sql
CREATE TABLE Menu (id INT PRIMARY KEY, name VARCHAR(255), category VARCHAR(255), price DECIMAL(5,2));
Calculate the total number of menu items in the Vegan category
SELECT COUNT(*) FROM Menu WHERE category = 'Vegan';
gretelai_synthetic_text_to_sql
CREATE TABLE climate_adaptation(project_name TEXT, country TEXT, budget FLOAT); INSERT INTO climate_adaptation(project_name, country, budget) VALUES ('Project C', 'China', 500000.00), ('Project D', 'Germany', 200000.00);
Identify countries in Asia with climate adaptation projects that have a higher budget than any project in Europe.
SELECT country FROM climate_adaptation WHERE budget > (SELECT MAX(budget) FROM climate_adaptation WHERE country = 'Europe') AND country = 'Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE genres (id INT, genre TEXT); CREATE TABLE artist_genres (artist_id INT, genre_id INT); INSERT INTO genres (id, genre) VALUES (1, 'Pop'), (2, 'Rock'), (3, 'Hip Hop'); INSERT INTO artist_genres (artist_id, genre_id) VALUES (1, 1), (2, 3), (3, 1), (3, 2);
How many artists are associated with each genre?
SELECT genre, COUNT(DISTINCT artist_id) FROM artist_genres JOIN genres ON artist_genres.genre_id = genres.id GROUP BY genre;
gretelai_synthetic_text_to_sql
CREATE TABLE Equipment_Maintenance (Equipment_Type VARCHAR(255), Maintenance_Date DATE); INSERT INTO Equipment_Maintenance (Equipment_Type, Maintenance_Date) VALUES ('Aircraft', '2020-01-01'), ('Vehicles', '2020-02-15'), ('Naval', '2020-03-01'), ('Naval', '2020-03-05'), ('Naval', '2020-03-10');
What is the average time between maintenance for each type of naval equipment?
SELECT Equipment_Type, AVG(DATEDIFF(day, LAG(Maintenance_Date) OVER (PARTITION BY Equipment_Type ORDER BY Maintenance_Date), Maintenance_Date)) as Avg_Maintenance_Interval FROM Equipment_Maintenance WHERE Equipment_Type = 'Naval' GROUP BY Equipment_Type;
gretelai_synthetic_text_to_sql
CREATE TABLE item_inventory (item_id INT, item_name VARCHAR(50), quantity INT, warehouse_id INT); CREATE TABLE warehouse (warehouse_id INT, warehouse_name VARCHAR(50), city VARCHAR(50), country VARCHAR(50));
Insert new records for 3 items in a warehouse in Mexico City with the warehouse_id 30
INSERT INTO item_inventory (item_id, item_name, quantity, warehouse_id) VALUES (1001, 'Item 1', 100, 30), (1002, 'Item 2', 200, 30), (1003, 'Item 3', 300, 30); INSERT INTO warehouse (warehouse_id, warehouse_name, city, country) VALUES (30, 'Mexico City Warehouse', 'Mexico City', 'Mexico');
gretelai_synthetic_text_to_sql
CREATE TABLE mental_health_parity_violations (id INT, state VARCHAR(50), violation_type VARCHAR(50), violation_date DATE); INSERT INTO mental_health_parity_violations (id, state, violation_type, violation_date) VALUES (1, 'California', 'Denial of Coverage', '2022-04-15'), (2, 'Texas', 'Inadequate Facilities', '2022-05-...
List the number of mental health parity violations by state and violation type in Q2 2022.
SELECT state, violation_type, COUNT(*) as num_violations FROM mental_health_parity_violations WHERE violation_date >= '2022-04-01' AND violation_date < '2022-07-01' GROUP BY state, violation_type;
gretelai_synthetic_text_to_sql
CREATE TABLE department (id INT, name TEXT); CREATE TABLE graduate_students (id INT, department_id INT, gpa REAL);
What is the number of graduate students in each department and their average GPA?
SELECT d.name, AVG(gs.gpa), COUNT(gs.id) FROM department d JOIN graduate_students gs ON d.id = gs.department_id GROUP BY d.name;
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (artist_id INT, artist_name TEXT); CREATE TABLE Streams (stream_id INT, artist_id INT, streams INT);
Which artists are most popular on streaming platforms?
SELECT artist_name, SUM(streams) as total_streams FROM Artists JOIN Streams ON Artists.artist_id = Streams.artist_id GROUP BY artist_name ORDER BY total_streams DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE cargo_incidents (id INT, vessel_name TEXT, location TEXT, incident_date DATE);
Count the number of cargo incidents in the Mediterranean sea in the last 6 months.
SELECT COUNT(*) FROM cargo_incidents WHERE location = 'Mediterranean sea' AND incident_date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE DefenseProjects (project_id INT, region VARCHAR(50), timeline_days INT); INSERT INTO DefenseProjects (project_id, region, timeline_days) VALUES (1, 'North America', 365), (2, 'North America', 90);
Identify the defense projects with the longest and shortest timelines in North America.
SELECT project_id, timeline_days FROM DefenseProjects WHERE region = 'North America' AND timeline_days = (SELECT MAX(timeline_days) FROM DefenseProjects WHERE region = 'North America') UNION SELECT project_id, timeline_days FROM DefenseProjects WHERE region = 'North America' AND timeline_days = (SELECT MIN(timeline_day...
gretelai_synthetic_text_to_sql
CREATE TABLE founders (id INT, name VARCHAR(50), country VARCHAR(30));
List the top 3 countries with the most startup founders and the number of founders in each.
SELECT country, COUNT(*) AS founder_count FROM founders GROUP BY country ORDER BY founder_count DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE menus (menu_id INT, name VARCHAR(100), category VARCHAR(50), price DECIMAL(5,2), quantity INT); INSERT INTO menus (menu_id, name, category, price, quantity) VALUES (1, 'Chicken Caesar Salad', 'Salad', 12.99, 300), (2, 'Margherita Pizza', 'Pizza', 9.99, 450);
What are the total sales for each category in the last month?
SELECT category, SUM(quantity * price) as total_sales FROM menus WHERE MONTH(order_date) = MONTH(CURRENT_DATE()) - 1 GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE faculty (id INT, gender TEXT, total_grants_awarded INT);
What is the total number of research grants awarded to female and male faculty members?
SELECT f.gender, SUM(f.total_grants_awarded) FROM faculty f GROUP BY f.gender;
gretelai_synthetic_text_to_sql
CREATE TABLE Astronauts (AstronautID INT, Name VARCHAR(50), Age INT, CountryOfOrigin VARCHAR(50)); INSERT INTO Astronauts (AstronautID, Name, Age, CountryOfOrigin) VALUES (1, 'Anna Ivanova', 35, 'Russia'), (2, 'John Doe', 45, 'USA'), (3, 'Pedro Gomez', 50, 'Mexico'); CREATE TABLE MedicalExaminations (ExaminationID INT,...
How many medical examinations have been conducted on astronauts from Russia?
SELECT COUNT(*) FROM Astronauts INNER JOIN MedicalExaminations ON Astronauts.AstronautID = MedicalExaminations.AstronautID WHERE Astronauts.CountryOfOrigin = 'Russia';
gretelai_synthetic_text_to_sql
CREATE TABLE threat_intel (id INT, ip_address VARCHAR(50), activity VARCHAR(50), timestamp TIMESTAMP);
Which IP addresses have been associated with the most malicious activities in the last month from the 'threat_intel' table?
SELECT ip_address, COUNT(*) FROM threat_intel WHERE activity = 'malicious' AND timestamp >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY ip_address ORDER BY COUNT(*) DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE project (id INT, country VARCHAR(50), energy_type VARCHAR(50), capacity INT); INSERT INTO project VALUES (1, 'USA', 'Wind', 200), (2, 'Canada', 'Solar', 150), (3, 'Mexico', 'Hydro', 250);
What is the total installed capacity (in MW) of renewable energy projects for each country, grouped by energy type?
SELECT energy_type, country, SUM(capacity) FROM project GROUP BY energy_type, country;
gretelai_synthetic_text_to_sql
CREATE TABLE shipwreck (id INT, name TEXT, location TEXT, depth FLOAT); INSERT INTO shipwreck (id, name, location, depth) VALUES (1, 'Titanic', 'Atlantic Ocean', 3784); INSERT INTO shipwreck (id, name, location, depth) VALUES (2, 'Bismarck', 'Atlantic Ocean', 4791);
What is the maximum depth at which a shipwreck has been discovered in the Atlantic Ocean?
SELECT MAX(depth) FROM shipwreck WHERE location = 'Atlantic Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE SiteD (site_id INT, site_name VARCHAR(20), artifact_type VARCHAR(20), quantity INT); INSERT INTO SiteD (site_id, site_name, artifact_type, quantity) VALUES (1, 'SiteD', 'Bone Fragments', 30), (2, 'SiteE', 'Pottery', 40), (3, 'SiteF', 'Bone Fragments', 20);
Which excavation site has the most bone fragments?
SELECT site_name, MAX(quantity) FROM SiteD WHERE artifact_type = 'Bone Fragments';
gretelai_synthetic_text_to_sql
CREATE TABLE garment_manufacturing (manufacturer_id INT, garment_id INT, production_date DATE, lead_time INT); INSERT INTO garment_manufacturing VALUES (1, 1, '2022-01-01', 7), (1, 2, '2022-01-05', 10), (2, 3, '2022-02-01', 5), (2, 4, '2022-02-03', 8), (3, 5, '2022-03-01', 6);
Find the number of garments produced by each manufacturer, and the average lead time for each manufacturer, for the year 2022.
SELECT manufacturer_id, COUNT(*) as num_garments, AVG(lead_time) as avg_lead_time FROM garment_manufacturing WHERE EXTRACT(YEAR FROM production_date) = 2022 GROUP BY manufacturer_id ORDER BY num_garments DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE claims_table (claim_id INT, policy_holder TEXT, claim_amount INT);
Insert a new claim for policyholder 'David Kim' with a claim amount of $20,000 into the claims_table
INSERT INTO claims_table (claim_id, policy_holder, claim_amount) VALUES (1, 'David Kim', 20000);
gretelai_synthetic_text_to_sql
CREATE TABLE spacecrafts (spacecraft_id INT, name VARCHAR(50)); CREATE TABLE missions (mission_id INT, spacecraft_id INT, crew VARCHAR(50));
Which spacecraft were used in missions that had both a scientist and an engineer as crew members?
SELECT s.name FROM spacecrafts s INNER JOIN missions m ON s.spacecraft_id = m.spacecraft_id INNER JOIN (SELECT crew FROM crew_members WHERE role = 'scientist' INTERSECT SELECT crew FROM crew_members WHERE role = 'engineer') cm ON m.crew = cm.crew;
gretelai_synthetic_text_to_sql
CREATE TABLE production (id INT, country VARCHAR(255), element VARCHAR(255), quantity INT, year INT); INSERT INTO production (id, country, element, quantity, year) VALUES (1, 'China', 'Yttrium', 1200, 2022), (2, 'China', 'Yttrium', 1400, 2022), (3, 'USA', 'Yttrium', 1000, 2022), (4, 'USA', 'Yttrium', 1100, 2022), (5, '...
Identify the top 2 countries with the highest total Yttrium production in 2022, using a window function.
SELECT country, SUM(quantity) as total_quantity FROM production WHERE element = 'Yttrium' AND year = 2022 GROUP BY country ORDER BY total_quantity DESC FETCH FIRST 2 ROWS ONLY;
gretelai_synthetic_text_to_sql
CREATE TABLE Student (StudentID INT, District VARCHAR(20)); CREATE TABLE MentalHealth (StudentID INT, Issue DATE); INSERT INTO Student (StudentID, District) VALUES (1, 'OpenMindedSchool'); INSERT INTO Student (StudentID, District) VALUES (2, 'ClosedMindedSchool'); INSERT INTO MentalHealth (StudentID, Issue) VALUES (1, ...
How many students have experienced mental health issues in 'OpenMindedSchool' district in the last year?
SELECT COUNT(*) FROM StudentMentalHealthView WHERE District = 'OpenMindedSchool';
gretelai_synthetic_text_to_sql
CREATE TABLE rural_infrastructure (id INT, name VARCHAR(50), type VARCHAR(50), budget FLOAT); INSERT INTO rural_infrastructure (id, name, type, budget) VALUES (1, 'Solar Irrigation', 'Agricultural Innovation', 150000.00), (2, 'Wind Turbines', 'Rural Infrastructure', 200000.00);
What are the unique types of rural infrastructure projects in the 'rural_infrastructure' table?
SELECT DISTINCT type FROM rural_infrastructure WHERE type = 'Rural Infrastructure';
gretelai_synthetic_text_to_sql
CREATE TABLE water_savings (savings_id INT, savings_date DATE, state VARCHAR(50), amount FLOAT); INSERT INTO water_savings (savings_id, savings_date, state, amount) VALUES (1, '2020-01-01', 'California', 10000), (2, '2020-02-01', 'California', 12000), (3, '2020-03-01', 'Texas', 15000), (4, '2020-04-01', 'California', 1...
Show the total amount of water saved through conservation efforts in the state of California for the year 2020
SELECT SUM(amount) as total_savings FROM water_savings WHERE savings_date BETWEEN '2020-01-01' AND '2020-12-31' AND state = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE investments (id INT, region VARCHAR(20), date DATE); INSERT INTO investments (id, region, date) VALUES (1, 'Asia-Pacific', '2021-01-05'), (2, 'Europe', '2021-02-10'), (3, 'Asia-Pacific', '2021-03-25'), (4, 'Africa', '2021-04-15'), (5, 'Europe', '2021-06-01');
How many investments were made in total in Q2 2021?
SELECT COUNT(*) FROM investments WHERE date BETWEEN '2021-04-01' AND '2021-06-30';
gretelai_synthetic_text_to_sql
CREATE TABLE SpaceMissions (MissionID INT, MissionName VARCHAR(50), PlannedLaunchDate DATE, ActualLaunchDate DATE, Duration INT); INSERT INTO SpaceMissions (MissionID, MissionName, PlannedLaunchDate, ActualLaunchDate, Duration) VALUES (1, 'Mission1', '2022-01-01', '2022-01-05', 30);
What are the average delays in days for each space mission, calculated as the difference between the actual and planned launch date?
SELECT MissionName, AVG(DATEDIFF(day, PlannedLaunchDate, ActualLaunchDate)) AS AverageDelay FROM SpaceMissions GROUP BY MissionName;
gretelai_synthetic_text_to_sql
CREATE TABLE rehab_ages (animal_id INT, age INT, admission_date DATE); INSERT INTO rehab_ages (animal_id, age, admission_date) VALUES (1, 3, '2022-01-02'), (2, 7, '2022-01-15'), (3, 5, '2022-01-31'), (4, 6, '2022-02-03');
What is the maximum age of animals in the rehabilitation center in the month of January 2022?
SELECT MAX(age) FROM rehab_ages WHERE admission_date BETWEEN '2022-01-01' AND '2022-01-31';
gretelai_synthetic_text_to_sql
CREATE TABLE water_usage (id INT, state VARCHAR(2), city VARCHAR(50), year INT, monthly_consumption FLOAT); INSERT INTO water_usage (id, state, city, year, monthly_consumption) VALUES (1, 'CA', 'Los Angeles', 2020, 150), (2, 'CA', 'Los Angeles', 2021, 155), (3, 'NY', 'New York', 2020, 200), (4, 'NY', 'New York', 2021, ...
What is the average monthly water consumption per capita in the United States?
SELECT AVG(monthly_consumption) FROM water_usage WHERE state IN ('CA', 'NY');
gretelai_synthetic_text_to_sql
CREATE TABLE cult_tours (tour_id INT, tour_name TEXT, country TEXT, revenue FLOAT, tour_date DATE); INSERT INTO cult_tours (tour_id, tour_name, country, revenue, tour_date) VALUES (1, 'Acropolis Tour', 'Greece', 3000.00, '2021-05-01'); INSERT INTO cult_tours (tour_id, tour_name, country, revenue, tour_date) VALUES (2, ...
What was the average daily revenue for cultural heritage tours in Greece for the year 2021?
SELECT AVG(revenue/100) FROM cult_tours WHERE country = 'Greece' AND YEAR(tour_date) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species_depths_arctic (name VARCHAR(255), basin VARCHAR(255), depth FLOAT); INSERT INTO marine_species_depths_arctic (name, basin, depth) VALUES ('Species5', 'Arctic', 210.43), ('Species6', 'Atlantic', 123.45);
What is the maximum depth reached by a marine species in the Arctic basin?
SELECT MAX(depth) as max_depth FROM marine_species_depths_arctic WHERE basin = 'Arctic';
gretelai_synthetic_text_to_sql
CREATE TABLE hospitals (id INT, name TEXT, state TEXT, num_employees INT);
Identify the number of rural hospitals in each state with more than 50 employees.
SELECT state, COUNT(*) FROM hospitals WHERE num_employees > 50 GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE satellites (satellite_id INT, satellite_name VARCHAR(100), country VARCHAR(50), launch_date DATE, apogee FLOAT); INSERT INTO satellites (satellite_id, satellite_name, country, launch_date, apogee) VALUES (1, 'Himawari 8', 'Japan', '2014-10-07', 35786); INSERT INTO satellites (satellite_id, satellite_name, ...
What is the maximum altitude reached by any satellite launched by Japan?
SELECT MAX(apogee) FROM satellites WHERE country = 'Japan';
gretelai_synthetic_text_to_sql
CREATE TABLE agriculture_innovation (id INT, name VARCHAR(50), country VARCHAR(50), is_woman BOOLEAN); INSERT INTO agriculture_innovation VALUES (1, 'John Doe', 'USA', false), (2, 'Jane Smith', 'Canada', true), (3, 'Pedro Sanchez', 'Mexico', false), (4, 'Maria Garcia', 'Brazil', true), (5, 'Jacques Dupont', 'France', f...
What is the total number of women farmers in the 'agriculture_innovation' table, partitioned by their country and sorted by the number of women farmers in descending order?;
SELECT country, SUM(is_woman) as total_women_farmers FROM agriculture_innovation GROUP BY country ORDER BY total_women_farmers DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE students_enrollment (id INT, student_id INT, country VARCHAR(255), enrollment_date DATE); INSERT INTO students_enrollment (id, student_id, country, enrollment_date) VALUES (1, 1, 'USA', '2021-08-01'), (2, 2, 'Canada', '2021-07-15'), (3, 3, 'USA', '2021-01-01');
How many students have enrolled in lifelong learning programs in the last month?
SELECT COUNT(DISTINCT student_id) FROM students_enrollment WHERE enrollment_date >= DATEADD(month, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE water_usage_canada(id INT, province VARCHAR(50), usage FLOAT, year INT); INSERT INTO water_usage_canada(id, province, usage, year) VALUES (1, 'Ontario', 550.2, 2020);
What is the average water usage by province for the year 2020 in Canada?
SELECT province, AVG(usage) as avg_usage FROM water_usage_canada WHERE year = 2020 GROUP BY province;
gretelai_synthetic_text_to_sql
CREATE TABLE infrastructure_projects (id INT, name VARCHAR(50), location VARCHAR(50), start_date DATE, completion_date DATE, total_cost FLOAT);
find the total cost of projects in the 'infrastructure_projects' table that were completed in the second quarter of 2021, partitioned by the project's location and ordered by the total cost.
SELECT location, SUM(total_cost) as total_cost, ROW_NUMBER() OVER (PARTITION BY location ORDER BY SUM(total_cost) DESC) as rn FROM infrastructure_projects WHERE DATEPART(quarter, completion_date) = 2 AND DATEPART(year, completion_date) = 2021 GROUP BY location ORDER BY total_cost DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Warehouse (name varchar(20), pallets_handled int, handling_date date); INSERT INTO Warehouse (name, pallets_handled, handling_date) VALUES ('Warehouse C', 50, '2022-01-01'), ('Warehouse C', 60, '2022-01-02');
What is the average number of pallets handled per day by 'Warehouse C'?
SELECT AVG(pallets_handled / (EXTRACT(DAY FROM handling_date) - EXTRACT(DAY FROM LAG(handling_date) OVER (PARTITION BY name ORDER BY handling_date)))) FROM Warehouse WHERE name = 'Warehouse C';
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, customer_name VARCHAR(255), city VARCHAR(255)); CREATE TABLE transactions (transaction_id INT, customer_id INT, transaction_date DATE, transaction_value DECIMAL(10,2)); INSERT INTO customers (customer_id, customer_name, city) VALUES (1, 'John Doe', 'New York'), (2, 'Jane Smith',...
List all transactions in December 2021 that exceeded the customer's average transaction value.
SELECT t.transaction_id, t.customer_id, t.transaction_date, t.transaction_value FROM transactions t INNER JOIN (SELECT customer_id, AVG(transaction_value) as avg_transaction_value FROM transactions WHERE transaction_date BETWEEN '2021-12-01' AND '2021-12-31' GROUP BY customer_id) avg_tv ON t.customer_id = avg_tv.custom...
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, name VARCHAR(255), country VARCHAR(255)); CREATE TABLE posts (id INT, user_id INT, content TEXT); CREATE TABLE comments (id INT, post_id INT, content TEXT); CREATE TABLE likes (id INT, user_id INT, post_id INT);
Find the total number of posts, comments, and likes from users in India, Japan, and Brazil.
SELECT COUNT(*) FROM posts JOIN users ON posts.user_id = users.id WHERE users.country IN ('India', 'Japan', 'Brazil') UNION ALL SELECT COUNT(*) FROM comments JOIN users ON comments.post_id = posts.id JOIN users ON posts.user_id = users.id WHERE users.country IN ('India', 'Japan', 'Brazil') UNION ALL SELECT COUNT(*) FRO...
gretelai_synthetic_text_to_sql
CREATE TABLE vessel_cargo ( id INT, vessel_id INT, cargo_type VARCHAR(255) ); INSERT INTO vessel_cargo (id, vessel_id, cargo_type) VALUES (1, 4, 'Containers'); INSERT INTO vessel_cargo (id, vessel_id, cargo_type) VALUES (2, 4, 'Coal');
How many unique cargo types were transported by each vessel in the Mediterranean Sea?
SELECT vessel_id, COUNT(DISTINCT cargo_type) as unique_cargo_types FROM vessel_cargo WHERE latitude BETWEEN 30 AND 46 AND longitude BETWEEN -10 AND 36 GROUP BY vessel_id;
gretelai_synthetic_text_to_sql
CREATE TABLE state_vaccination_policies (policy_id INT, policy_name VARCHAR(100), state_abbr CHAR(2)); INSERT INTO state_vaccination_policies VALUES (1, 'Mandatory Vaccination for School Children', 'NY'), (2, 'Influenza Vaccination Program for Healthcare Workers', 'CA'), (3, 'Optional Vaccination for Adults', 'TX');
Which public health policies related to vaccination were implemented in each state?
SELECT policy_name FROM state_vaccination_policies;
gretelai_synthetic_text_to_sql
CREATE TABLE MilitaryPersonnel (id INT, branch VARCHAR(255), personnel_count INT); INSERT INTO MilitaryPersonnel (id, branch, personnel_count) VALUES (1, 'Army', 500000), (2, 'Navy', 350000), (3, 'Air Force', 300000);
What is the total number of military personnel in each branch of the armed forces?
SELECT branch, SUM(personnel_count) FROM MilitaryPersonnel GROUP BY branch;
gretelai_synthetic_text_to_sql
CREATE TABLE Artworks (id INT, title VARCHAR(255), artist_id INT); CREATE TABLE Artists (id INT, name VARCHAR(255), nationality VARCHAR(255)); INSERT INTO Artists (id, name, nationality) VALUES (1, 'Frida Kahlo', 'Mexico'); INSERT INTO Artworks (id, title, artist_id) VALUES (1, 'Self-Portrait with Thorn Necklace and Hu...
What is the average number of artworks created by artists from Mexico?
SELECT AVG(COUNT(*)) FROM Artworks GROUP BY artist_id HAVING nationality = 'Mexico';
gretelai_synthetic_text_to_sql
CREATE TABLE smart_contracts (contract_id INT, contract_name VARCHAR(50), daily_transactions INT); INSERT INTO smart_contracts (contract_id, contract_name, daily_transactions) VALUES (1, 'Uniswap', 10000); INSERT INTO smart_contracts (contract_id, contract_name, daily_transactions) VALUES (2, 'SushiSwap', 8000);
What is the average daily number of transactions for each smart contract in the 'smart_contracts' table?
SELECT contract_name, AVG(daily_transactions) FROM smart_contracts GROUP BY contract_name;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (id INT, name VARCHAR(50), region VARCHAR(20), assets DECIMAL(10,2)); INSERT INTO customers (id, name, region, assets) VALUES (1, 'John Doe', 'Southwest', 50000.00), (2, 'Jane Smith', 'Northeast', 75000.00), (3, 'Ali Ahmed', 'Asia', 100000.00), (4, 'Min Ji', 'Asia', 120000.00);
What is the average assets value for customers in 'Asia'?
SELECT AVG(assets) FROM customers WHERE region = 'Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE AsianSales (id INT, vehicle_type VARCHAR(50), quantity INT, country VARCHAR(50), quarter INT, year INT); INSERT INTO AsianSales (id, vehicle_type, quantity, country, quarter, year) VALUES (1, 'Electric', 1500, 'Japan', 1, 2021), (2, 'Electric', 1200, 'Japan', 2, 2021), (3, 'Electric', 1800, 'China', 1, 202...
How many electric vehicles were sold in Japan in Q1 2021?
SELECT SUM(quantity) FROM AsianSales WHERE vehicle_type = 'Electric' AND country = 'Japan' AND quarter = 1 AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE posts (post_id INT, user_id INT, post_date DATE); INSERT INTO posts (post_id, user_id, post_date) VALUES (1, 1, '2021-01-01'), (2, 1, '2021-01-02'), (3, 2, '2021-01-01'), (4, 3, '2021-01-02'), (5, 3, '2021-01-03'), (6, 4, '2021-01-01');
Determine the average number of posts per day for the 'social_media' database.
SELECT AVG(num_posts_per_day) FROM (SELECT user_id, COUNT(*) / COUNT(DISTINCT post_date) AS num_posts_per_day FROM posts GROUP BY user_id) AS subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels (VesselID INT, VesselName VARCHAR(255), AvgSpeed DECIMAL(5,2)); INSERT INTO Vessels (VesselID, VesselName, AvgSpeed) VALUES (1, 'VesselA', 15.5), (2, 'VesselB', 17.3), (3, 'VesselC', 13.9); CREATE TABLE Docking (DockingID INT, VesselID INT, Port VARCHAR(255), DockingTime TIMESTAMP); INSERT INTO Doc...
What is the average speed of vessels that docked in the Port of Oakland in the last month?
SELECT AVG(V.AvgSpeed) FROM Vessels V INNER JOIN Docking D ON V.VesselID = D.VesselID WHERE D.Port = 'Oakland' AND DockingTime BETWEEN DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 1 MONTH) AND CURRENT_TIMESTAMP;
gretelai_synthetic_text_to_sql
CREATE TABLE union_safety (union_name TEXT, region TEXT); INSERT INTO union_safety (union_name, region) VALUES ('Union A', 'north_region'), ('Union B', 'east_region'), ('Union C', 'north_region'), ('Union D', 'east_region'); CREATE TABLE union_advocacy (union_name TEXT, region TEXT); INSERT INTO union_advocacy (union_n...
Display union names that have workplace safety metrics in both 'north_region' and 'east_region' but no labor rights advocacy activities?
SELECT union_name FROM union_safety WHERE region = 'north_region' INTERSECT SELECT union_name FROM union_safety WHERE region = 'east_region' EXCEPT SELECT union_name FROM union_advocacy;
gretelai_synthetic_text_to_sql
CREATE TABLE Carriers (CarrierID int, CarrierName varchar(255), Region varchar(255));CREATE TABLE Shipments (ShipmentID int, CarrierID int, DeliveryTime int, ShippedDate datetime); INSERT INTO Carriers (CarrierID, CarrierName, Region) VALUES (1, 'Carrier A', 'Europe'); INSERT INTO Shipments (ShipmentID, CarrierID, Deli...
Calculate the average delivery time for each carrier in the Europe region over the past year, including only carriers with at least 500 shipments.
SELECT c.CarrierName, AVG(s.DeliveryTime) as AverageDeliveryTime FROM Carriers c INNER JOIN Shipments s ON c.CarrierID = s.CarrierID WHERE c.Region = 'Europe' AND s.ShippedDate >= DATEADD(year, -1, GETDATE()) GROUP BY c.CarrierName HAVING COUNT(*) >= 500;
gretelai_synthetic_text_to_sql
CREATE TABLE covid_testing (id INT PRIMARY KEY, hospital_id INT, test_date DATE, tests_conducted INT);
Create a table for storing COVID-19 testing data
INSERT INTO covid_testing (id, hospital_id, test_date, tests_conducted) VALUES (1, 1, '2023-02-01', 100), (2, 1, '2023-02-03', 120), (3, 2, '2023-02-01', 150);
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (id INT, species_name VARCHAR(255), iucn_status VARCHAR(255));
Find the number of marine species with a vulnerable or endangered IUCN status.
(SELECT COUNT(*) FROM marine_species WHERE iucn_status IN ('Vulnerable', 'Endangered'))
gretelai_synthetic_text_to_sql
CREATE TABLE production_batch (batch_id INT, batch_date DATE, product_id INT, product_name TEXT, co2_emission FLOAT); INSERT INTO production_batch (batch_id, batch_date, product_id, product_name, co2_emission) VALUES (1, '2021-01-01', 1, 'Product A', 50.5), (2, '2021-02-05', 2, 'Product B', 75.3), (3, '2021-03-10', 3, ...
What is the average CO2 emission rate per production batch, for each chemical product, in the past year?
SELECT product_name, AVG(co2_emission) OVER (PARTITION BY product_id ORDER BY batch_date ROWS BETWEEN 11 PRECEDING AND CURRENT ROW) AS avg_co2_rate FROM production_batch WHERE batch_date >= DATEADD(year, -1, CURRENT_DATE);
gretelai_synthetic_text_to_sql
CREATE TABLE community_dev (id INT, name VARCHAR(255), region VARCHAR(255), budget FLOAT); INSERT INTO community_dev (id, name, region, budget) VALUES (1, 'Healthcare Center', 'North America', 350000.00);
Determine the number of community development initiatives in North America having a budget between $100,000 and $500,000.
SELECT COUNT(*) FROM community_dev WHERE region = 'North America' AND budget BETWEEN 100000 AND 500000;
gretelai_synthetic_text_to_sql
CREATE TABLE Vehicles (VehicleID int, VehicleType varchar(255), Region varchar(255)); INSERT INTO Vehicles (VehicleID, VehicleType, Region) VALUES (1, 'Bus', 'East'), (2, 'Tram', 'West'), (3, 'Wheelchair Bus', 'South');
What is the total number of accessible vehicles in the 'South' region?
SELECT COUNT(*) FROM Vehicles WHERE VehicleType = 'Wheelchair Bus' OR VehicleType = 'Accessible Tram' AND Region = 'South';
gretelai_synthetic_text_to_sql
CREATE TABLE ride_sharing_berlin_paris (id INT, vehicle VARCHAR(20), city VARCHAR(20)); INSERT INTO ride_sharing_berlin_paris (id, vehicle, city) VALUES (1, 'bike', 'Berlin'), (2, 'e-scooter', 'Berlin'), (3, 'bike', 'Paris'), (4, 'e-scooter', 'Paris');
How many bikes and e-scooters are available in Berlin and Paris?
SELECT COUNT(*) FROM ride_sharing_berlin_paris WHERE city IN ('Berlin', 'Paris') AND vehicle IN ('bike', 'e-scooter');
gretelai_synthetic_text_to_sql
CREATE TABLE RegulatoryCompliance (Id INT, VesselName VARCHAR(50), Area VARCHAR(50), ComplianceDate DATETIME);
What is the total number of vessels that complied with regulations in the South China Sea in the last quarter?
SELECT COUNT(DISTINCT VesselName) FROM RegulatoryCompliance WHERE Area = 'South China Sea' AND ComplianceDate >= DATEADD(QUARTER, -1, GETDATE()) GROUP BY VesselName HAVING COUNT(*) = 4;
gretelai_synthetic_text_to_sql
CREATE TABLE user_activity (id INT, user_id INT, activity_type VARCHAR(50), activity_date DATE, followers INT); INSERT INTO user_activity (id, user_id, activity_type, activity_date, followers) VALUES (1, 1, 'Followers Gained', '2021-01-01', 100), (2, 2, 'Followers Lost', '2021-01-02', 50); CREATE TABLE users (id INT, c...
Show the number of followers gained by users from Africa, grouped by week.
SELECT WEEK(activity_date) as week, COUNT(*) as follower_gain FROM user_activity JOIN users ON user_activity.user_id = users.id WHERE users.country IN ('Egypt', 'South Africa') AND activity_type = 'Followers Gained' GROUP BY WEEK(activity_date);
gretelai_synthetic_text_to_sql
CREATE TABLE department (id INT, name TEXT);CREATE TABLE faculty (id INT, department_id INT, publication_count INT);CREATE TABLE research_grant (id INT, faculty_id INT, amount INT);
What is the total amount of research grants awarded to faculty members in the College of Engineering who have authored more than 5 publications?
SELECT SUM(rg.amount) FROM research_grant rg JOIN faculty f ON rg.faculty_id = f.id JOIN department d ON f.department_id = d.id WHERE d.name = 'College of Engineering' AND f.publication_count > 5;
gretelai_synthetic_text_to_sql
CREATE TABLE defense_projects (project_name VARCHAR(255), start_date DATE, end_date DATE); INSERT INTO defense_projects (project_name, start_date, end_date) VALUES ('Project A', '2021-01-01', '2023-12-31'), ('Project B', '2019-01-01', '2022-12-31'), ('Project F', '2020-01-01', '2023-12-31');
List all defense projects with timelines ending in 2023 or later
SELECT project_name FROM defense_projects WHERE end_date >= '2023-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE unions (id INT, state VARCHAR(2), workers INT, issue VARCHAR(14));
What is the maximum number of workers in unions advocating for workplace safety in California?
SELECT MAX(workers) FROM unions WHERE state = 'CA' AND issue = 'workplace_safety';
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, name VARCHAR(255), posts INT); CREATE TABLE posts (id INT, user INT, content TEXT, timestamp TIMESTAMP);
Who is the user with the highest number of posts containing "#gaming" in the past year, with at least 20 posts?
SELECT u.name FROM users u JOIN (SELECT user, COUNT(*) AS post_count FROM posts WHERE content LIKE '%#gaming%' AND timestamp BETWEEN DATE_SUB(NOW(), INTERVAL 1 YEAR) AND NOW() GROUP BY user HAVING COUNT(*) >= 20) pc ON u.id = pc.user ORDER BY u.posts DESC, pc.post_count DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE budget_allocation (location VARCHAR(20), category VARCHAR(30), amount DECIMAL); INSERT INTO budget_allocation (location, category, amount) VALUES ('Urban', 'Accessibility Improvements', 250000.00); INSERT INTO budget_allocation (location, category, amount) VALUES ('Urban', 'Accessibility Improvements', 300...
What is the total budget allocated for accessibility improvements in urban areas?
SELECT SUM(amount) FROM budget_allocation WHERE location = 'Urban' AND category = 'Accessibility Improvements';
gretelai_synthetic_text_to_sql
CREATE TABLE warehouse (warehouse_id VARCHAR(10), city VARCHAR(20), state VARCHAR(20), country VARCHAR(20));
Update the warehouse table to set the city for warehouse_id 001 to 'New York'
UPDATE warehouse SET city = 'New York' WHERE warehouse_id = '001';
gretelai_synthetic_text_to_sql
CREATE TABLE security_incidents (id INT, company TEXT, country TEXT, incident_date DATE, response_time INT); INSERT INTO security_incidents (id, company, country, incident_date, response_time) VALUES (1, 'IT Company A', 'USA', '2020-10-15', 120); INSERT INTO security_incidents (id, company, country, incident_date, resp...
What is the average response time to security incidents for IT companies in Q4 2020, grouped by country?
SELECT country, AVG(response_time) FROM security_incidents WHERE company LIKE '%IT Company%' AND incident_date >= '2020-10-01' AND incident_date < '2021-01-01' GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE posts (user_id INT, post_date DATE); CREATE TABLE users (id INT, community VARCHAR(20)); INSERT INTO posts (user_id, post_date) VALUES (1, '2022-01-01'), (2, '2022-02-01'), (3, '2022-03-01'); INSERT INTO users (id, community) VALUES (1, 'Women in Tech'), (2, 'LGBTQ+'), (3, 'Minority Owned Business'); INSER...
How many posts were created by users from underrepresented communities in Q1 2022?
SELECT COUNT(*) FROM posts JOIN users ON posts.user_id = users.id WHERE users.community IN ('Women in Tech', 'LGBTQ+', 'Minority Owned Business') AND posts.post_date BETWEEN '2022-01-01' AND '2022-03-31';
gretelai_synthetic_text_to_sql
CREATE TABLE products (id INT, company VARCHAR(255), cruelty_free BOOLEAN); INSERT INTO products (id, company, cruelty_free) VALUES (1, 'ABC', TRUE), (2, 'DEF', FALSE), (3, 'ABC', TRUE);
How many cruelty-free products does the company have?
SELECT COUNT(*) FROM products WHERE cruelty_free = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE libraries (library_name VARCHAR(255), district_name VARCHAR(255), square_footage INT); INSERT INTO libraries (library_name, district_name, square_footage) VALUES ('Library1', 'DistrictA', 15000), ('Library2', 'DistrictA', 20000), ('Library3', 'DistrictB', 25000), ('Library4', 'DistrictB', 30000);
What is the number of public libraries and the total square footage of each library in the state of New York?
SELECT district_name, COUNT(library_name) AS num_libraries, SUM(square_footage) AS total_square_footage FROM libraries GROUP BY district_name;
gretelai_synthetic_text_to_sql
CREATE TABLE PollutionControl (id INT, initiative VARCHAR(50), region VARCHAR(20)); INSERT INTO PollutionControl (id, initiative, region) VALUES (1, 'Ocean Cleanup', 'Arctic'), (2, 'Plastic Reduction', 'Atlantic'), (3, 'Carbon Capture', 'Global');
List the total number of pollution control initiatives implemented in the Atlantic and Arctic regions.
SELECT region, COUNT(*) as total_initiatives FROM PollutionControl WHERE region IN ('Atlantic', 'Arctic') GROUP BY region;
gretelai_synthetic_text_to_sql