context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE MentalHealthProviders (ProviderID INT, Name VARCHAR(50), Language VARCHAR(20)); INSERT INTO MentalHealthProviders (ProviderID, Name, Language) VALUES (1, 'John Doe', 'Spanish'), (2, 'Jane Smith', 'French'), (3, 'Mary Johnson', 'English');
|
List all mental health providers who speak a language other than English.
|
SELECT * FROM MentalHealthProviders WHERE Language != 'English';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE HealthcareDisparities (ID INT PRIMARY KEY, Metric VARCHAR(50), Value DECIMAL(5,2), Year INT); INSERT INTO HealthcareDisparities (ID, Metric, Value, Year) VALUES (1, 'Healthcare Disparities', 0.15, 2018); INSERT INTO HealthcareDisparities (ID, Metric, Value, Year) VALUES (2, 'Healthcare Disparities', 0.12, 2019); INSERT INTO HealthcareDisparities (ID, Metric, Value, Year) VALUES (3, 'Healthcare Disparities', 0.18, 2020);
|
What is the average value of 'Healthcare Disparities' metric for the year 2020?
|
SELECT AVG(Value) FROM HealthcareDisparities WHERE Metric = 'Healthcare Disparities' AND Year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE projects (id INT, title TEXT, location TEXT, start_date DATE, end_date DATE); INSERT INTO projects (id, title, location, start_date, end_date) VALUES (1, 'Project 1', 'US', '2018-01-01', '2018-12-31'); INSERT INTO projects (id, title, location, start_date, end_date) VALUES (2, 'Project 2', 'Canada', '2020-01-01', '2020-12-31'); INSERT INTO projects (id, title, location, start_date, end_date) VALUES (3, 'Project 3', 'Mexico', '2022-01-01', '2022-12-31');
|
What is the total number of investigative journalism projects conducted in the US, Canada, and Mexico, between 2018 and 2022?
|
SELECT SUM(DATEDIFF(end_date, start_date) + 1) FROM projects WHERE location IN ('US', 'Canada', 'Mexico') AND start_date BETWEEN '2018-01-01' AND '2022-12-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE endangered_species (id INT, animal_name VARCHAR(255), population INT, conservation_status VARCHAR(255));
|
What is the total number of animals in the endangered_species table that have a specific conservation status?
|
SELECT SUM(population) FROM endangered_species WHERE conservation_status = 'Critically Endangered';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE infrastructure_projects(project_id INT, country VARCHAR(50), completion_year INT); INSERT INTO infrastructure_projects VALUES (1, 'India', 2020), (2, 'Brazil', 2021), (3, 'India', 2022);
|
Which countries have the most rural infrastructure projects in the 'rural_development' schema?
|
SELECT country, COUNT(*) as num_projects FROM infrastructure_projects GROUP BY country ORDER BY num_projects DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE oceania_tourism (country VARCHAR(50), tourists INT); INSERT INTO oceania_tourism VALUES ('Australia', 9000000), ('New Zealand', 4500000), ('Fiji', 1200000), ('New Caledonia', 1100000), ('Vanuatu', 1000000);
|
List the top 5 destinations in Oceania for international tourists, excluding Australia.
|
SELECT country FROM oceania_tourism WHERE country != 'Australia' ORDER BY tourists DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE digital_divide_indonesia(id INT, initiative VARCHAR(50), country VARCHAR(10)); INSERT INTO digital_divide_indonesia VALUES (1, 'Indonesia Digital Divide', 'Indonesia'); CREATE TABLE digital_divide_thailand(id INT, initiative VARCHAR(50), country VARCHAR(10)); INSERT INTO digital_divide_thailand VALUES (1, 'Thailand Digital Inclusion', 'Thailand'); CREATE TABLE digital_divide_philippines(id INT, initiative VARCHAR(50), country VARCHAR(10)); INSERT INTO digital_divide_philippines VALUES (1, 'Philippines Digital Access', 'Philippines');
|
Find the number of digital divide initiatives in Southeast Asia, by country.
|
SELECT country, COUNT(initiative) AS num_initiatives FROM digital_divide_indonesia GROUP BY country UNION ALL SELECT country, COUNT(initiative) AS num_initiatives FROM digital_divide_thailand GROUP BY country UNION ALL SELECT country, COUNT(initiative) AS num_initiatives FROM digital_divide_philippines GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE projects (id INT, project_name VARCHAR(255), start_date DATE, end_date DATE, contractor VARCHAR(255)); INSERT INTO projects (id, project_name, start_date, end_date, contractor) VALUES (1, 'Stealth Fighter Development', '2017-04-01', '2022-12-31', 'Lockheed Martin'); INSERT INTO projects (id, project_name, start_date, end_date, contractor) VALUES (2, 'Missile Shield Upgrade', '2018-09-15', '2023-06-30', 'Raytheon');
|
List all defense projects with their start and end dates from the 'projects' table
|
SELECT project_name, start_date, end_date FROM projects;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donations (id INT, donor_name VARCHAR(50), donation_amount DECIMAL(10,2), donation_date DATE); CREATE TABLE VolunteerEvents (id INT, donor_name VARCHAR(50), total_volunteers INT, event_date DATE);
|
List all unique donor names who have donated more than $500 in total and have also volunteered for at least one program.
|
SELECT Donations.donor_name FROM Donations INNER JOIN (SELECT donor_name FROM VolunteerEvents GROUP BY donor_name HAVING SUM(total_volunteers) > 0) AS VolunteeredDonors ON Donations.donor_name = VolunteeredDonors.donor_name GROUP BY Donations.donor_name HAVING SUM(Donations.donation_amount) > 500;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE chemical_production (id INT PRIMARY KEY, chemical_id VARCHAR(10), quantity INT, country VARCHAR(50)); INSERT INTO chemical_production (id, chemical_id, quantity, country) VALUES (1, 'XY987', 700, 'Brazil'), (2, 'GH247', 600, 'India'), (3, 'XY987', 300, 'Australia'), (4, 'GH247', 500, 'India'), (5, 'GH247', 800, 'Brazil'), (6, 'XY987', 200, 'Chile');
|
Find the country with the lowest production quantity of chemical 'XY987'
|
SELECT country FROM chemical_production WHERE chemical_id = 'XY987' GROUP BY country ORDER BY SUM(quantity) ASC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE claims (policyholder_id INT, claim_amount DECIMAL(10,2), state VARCHAR(2)); INSERT INTO claims (policyholder_id, claim_amount, state) VALUES (1, 500, 'FL'), (2, 200, 'FL'), (3, 150, 'FL');
|
What is the minimum claim amount for policyholders in Florida?
|
SELECT MIN(claim_amount) FROM claims WHERE state = 'FL';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ConcertTicketSales (id INT, city VARCHAR(20), tickets_sold INT); INSERT INTO ConcertTicketSales (id, city, tickets_sold) VALUES (1, 'Sydney', 6000), (2, 'Melbourne', 8000);
|
How many concert tickets were sold in Sydney?
|
SELECT tickets_sold FROM ConcertTicketSales WHERE city = 'Sydney';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ingredients (ingredient_id INT, ingredient_name TEXT, sourcing_country TEXT, cost DECIMAL(5,2)); INSERT INTO ingredients (ingredient_id, ingredient_name, sourcing_country, cost) VALUES (1, 'Mica', 'Brazil', 56.78), (2, 'Jojoba Oil', 'Argentina', 23.99), (3, 'Rosehip Oil', 'Chile', 34.56);
|
List the top 3 most expensive ingredients sourced from Brazil?
|
SELECT * FROM (SELECT ingredient_name, cost, ROW_NUMBER() OVER (ORDER BY cost DESC) AS rn FROM ingredients WHERE sourcing_country = 'Brazil') sub WHERE rn <= 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Brands (BrandID INT, BrandName VARCHAR(50)); INSERT INTO Brands (BrandID, BrandName) VALUES (1, 'Brand1'), (2, 'Brand2'), (3, 'Brand3'); CREATE TABLE BrandMaterials (BrandID INT, MaterialID INT, Quantity INT); INSERT INTO BrandMaterials (BrandID, MaterialID, Quantity) VALUES (1, 1, 100), (1, 2, 200), (2, 1, 150);
|
What is the total quantity of materials used by all brands?
|
SELECT SUM(Quantity) FROM BrandMaterials;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ResearchPapers (ID INT, Title TEXT, Author TEXT, PublicationDate DATE); INSERT INTO ResearchPapers (ID, Title, Author, PublicationDate) VALUES (1, 'Deep Learning for Autonomous Driving', 'John Doe', '2021-03-15'); INSERT INTO ResearchPapers (ID, Title, Author, PublicationDate) VALUES (2, 'Reinforcement Learning in Autonomous Vehicles', 'Jane Smith', '2021-07-22');
|
What are the names of the autonomous driving research papers with a publication date in the first half of 2021?
|
SELECT Title FROM ResearchPapers WHERE PublicationDate BETWEEN '2021-01-01' AND '2021-06-30';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sales (id INT, category VARCHAR(255), subcategory VARCHAR(255), gender VARCHAR(50), material VARCHAR(50), country VARCHAR(50), quantity INT); INSERT INTO sales (id, category, subcategory, gender, material, country, quantity) VALUES (1, 'Tops', 'T-Shirts', 'Female', 'Recycled Polyester', 'Canada', 50); INSERT INTO sales (id, category, subcategory, gender, material, country, quantity) VALUES (2, 'Pants', 'Jeans', 'Female', 'Recycled Polyester', 'Canada', 30); INSERT INTO sales (id, category, subcategory, gender, material, country, quantity) VALUES (3, 'Outerwear', 'Jackets', 'Female', 'Recycled Polyester', 'Canada', 20);
|
What is the total quantity of women's garments made from recycled polyester sold in Canada?
|
SELECT SUM(quantity) FROM sales WHERE gender = 'Female' AND material = 'Recycled Polyester' AND country = 'Canada';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE project (id INT, city VARCHAR(20), type VARCHAR(20), hours INT); INSERT INTO project (id, city, type, hours) VALUES (1, 'Seattle', 'Sustainable', 500), (2, 'NYC', 'Sustainable', 800), (3, 'Seattle', 'Traditional', 300);
|
What are the total labor hours for all sustainable building projects in the city of Seattle?
|
SELECT SUM(hours) FROM project WHERE city = 'Seattle' AND type = 'Sustainable';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE if not exists investment_strategies (id INT PRIMARY KEY, strategy TEXT);
|
create a table for tracking social impact investments
|
CREATE TABLE if not exists investment_outcomes (id INT, strategy_id INT, outcome TEXT, PRIMARY KEY (id), FOREIGN KEY (strategy_id) REFERENCES investment_strategies (id));
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE trainings (id INT, title VARCHAR(50), completion_date DATE, duration INT); INSERT INTO trainings (id, title, completion_date, duration) VALUES (1, 'Agroecology Course', '2017-02-01', 7); INSERT INTO trainings (id, title, completion_date, duration) VALUES (2, 'Organic Farming Workshop', '2019-08-15', 5);
|
Delete all agricultural training programs that were completed before 2018 and have a duration of less than two weeks.
|
DELETE FROM trainings WHERE completion_date < '2018-01-01' AND duration < 14;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donations (DonationID INT, DonorID INT, Amount DECIMAL(10,2), DonationDate DATE); INSERT INTO Donations VALUES (1, 1, 100.00, '2020-01-01'), (2, 1, 200.00, '2020-02-01'), (3, 2, 300.00, '2020-03-01');
|
How many donations were received in each month of 2020?
|
SELECT MONTH(DonationDate), COUNT(DonationID) FROM Donations WHERE YEAR(DonationDate) = 2020 GROUP BY MONTH(DonationDate);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE auto_sales (id INT, region VARCHAR(20), vehicle_type VARCHAR(10), sale_type VARCHAR(10)); INSERT INTO auto_sales (id, region, vehicle_type, sale_type) VALUES (1, 'North America', 'EV', 'Sold'), (2, 'South America', 'EV', 'Sold'), (3, 'Asia', 'Hybrid', 'Leased');
|
Delete records of electric cars sold in 'South America' from the 'auto_sales' table.
|
DELETE FROM auto_sales WHERE vehicle_type = 'EV' AND region = 'South America';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Carps_Farming (Farm_ID INT, Farm_Name TEXT, Location TEXT, Water_Temperature FLOAT); INSERT INTO Carps_Farming (Farm_ID, Farm_Name, Location, Water_Temperature) VALUES (1, 'Farm 1', 'China', 22.5), (2, 'Farm 2', 'China', 23.3), (3, 'Farm 3', 'Vietnam', 24.7);
|
What is the average water temperature for each location in the Carps_Farming table?
|
SELECT Location, AVG(Water_Temperature) FROM Carps_Farming GROUP BY Location;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE DRILLING_HISTORY (WELL_NAME VARCHAR(255), DRILL_DATE DATE);
|
What are the names and drilling dates of all wells in the 'DRILLING_HISTORY' table?
|
SELECT WELL_NAME, DRILL_DATE FROM DRILLING_HISTORY;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Health_Equity_Metrics (Metric_ID INT, Metric_Name VARCHAR(255), Measurement_Date DATE); INSERT INTO Health_Equity_Metrics (Metric_ID, Metric_Name, Measurement_Date) VALUES (1, 'Access to Care', '2022-04-01'), (2, 'Quality of Care', '2022-03-15');
|
Identify the health equity metrics that have been measured in the past year and their respective measurement dates.
|
SELECT Metric_Name, Measurement_Date FROM Health_Equity_Metrics WHERE Measurement_Date >= DATEADD(year, -1, GETDATE());
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE budgets (program VARCHAR(255), region VARCHAR(255), amount INTEGER); INSERT INTO budgets (program, region, amount) VALUES ('Program A', 'Asia', 10000); INSERT INTO budgets (program, region, amount) VALUES ('Program B', 'South America', 15000);
|
What is the average budget for language preservation programs in Asia and South America?
|
SELECT AVG(amount) FROM budgets WHERE region IN ('Asia', 'South America') AND program LIKE 'language%'
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_species (id INT PRIMARY KEY, name VARCHAR(50), habitat VARCHAR(50), population INT);CREATE TABLE climate_change_impact (id INT PRIMARY KEY, species_id INT, impact VARCHAR(50), year INT);
|
List marine species impacted by climate change and their status in 2025.
|
SELECT m.name, c.impact, c.year FROM marine_species m JOIN climate_change_impact c ON m.id = c.species_id WHERE c.impact = 'Impacted' AND c.year = 2025;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE testing_data3 (id INT, algorithm VARCHAR(20), bias INT, fairness INT); INSERT INTO testing_data3 (id, algorithm, bias, fairness) VALUES (1, 'K-Nearest Neighbor', 4, 7), (2, 'K-Means', 6, 5), (3, 'K-Nearest Neighbor', 3, 8);
|
Update the 'bias' value to 6 for records with 'algorithm' = 'K-Nearest Neighbor' in the 'testing_data3' table
|
UPDATE testing_data3 SET bias = 6 WHERE algorithm = 'K-Nearest Neighbor';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE LanguagePreservation (id INT PRIMARY KEY, region VARCHAR(255), language VARCHAR(255), preserved BOOLEAN); INSERT INTO LanguagePreservation (id, region, language, preserved) VALUES (1, 'Region A', 'Language 1', TRUE), (2, 'Region B', 'Language 2', FALSE), (3, 'Region A', 'Language 3', TRUE), (4, 'Region C', 'Language 4', TRUE);
|
Get the names and number of languages preserved in each region, grouped by region.
|
SELECT region, COUNT(*) FROM LanguagePreservation WHERE preserved = TRUE GROUP BY region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SatelliteLaunches ( id INT, name VARCHAR(255), launch_country VARCHAR(255), launch_year INT, satellites INT);
|
How many satellites have been launched by China since 2010?
|
SELECT COUNT(*) FROM SatelliteLaunches WHERE launch_country = 'China' AND launch_year >= 2010;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE satellite_image (image_id INT, plot_id INT, resolution INT); INSERT INTO satellite_image (image_id, plot_id, resolution) VALUES (1, 456, 1080), (2, 456, 1440), (3, 456, 2160), (4, 456, 720), (5, 456, 1080);
|
Find the top 3 satellite images with the highest resolution for plot_id 456
|
SELECT image_id, resolution FROM (SELECT image_id, resolution, ROW_NUMBER() OVER (ORDER BY resolution DESC) row_num FROM satellite_image WHERE plot_id = 456) tmp WHERE row_num <= 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE open_pedagogy_courses (course_id INT, university VARCHAR(20), season VARCHAR(10)); INSERT INTO open_pedagogy_courses (course_id, university, season) VALUES (1, 'Acme U', 'Fall'), (2, 'Harvard U', 'Spring'), (3, 'Acme U', 'Spring');
|
What is the total number of open pedagogy courses offered by 'Acme U' in 'Fall' seasons?
|
SELECT COUNT(*) FROM open_pedagogy_courses WHERE university = 'Acme U' AND season = 'Fall';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sourcing (country VARCHAR(255), material VARCHAR(255), eco_friendly BOOLEAN);
|
How many eco-friendly materials are sourced by country?
|
SELECT country, COUNT(*) as eco_friendly_materials_count FROM sourcing WHERE eco_friendly = TRUE GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE equipment (id INT, date DATE, type VARCHAR(50), condition VARCHAR(50), farm_id INT, FOREIGN KEY (farm_id) REFERENCES farmers(id)); INSERT INTO equipment (id, date, type, condition, farm_id) VALUES (1, '2022-01-01', 'Tractors', 'Good', 1), (2, '2022-01-02', 'Combine harvesters', 'Excellent', 2), (3, '2022-01-03', 'Sprayers', 'Very good', 5), (4, '2022-01-04', 'Seed drills', 'Good', 6), (5, '2022-01-05', 'Tillage equipment', 'Fair', 3); INSERT INTO farmers (id, name, region, age) VALUES (1, 'James', 'South', 50), (2, 'Sophia', 'South', 40), (3, 'Mason', 'North', 45), (4, 'Lily', 'East', 55), (5, 'Olivia', 'South', 60), (6, 'Benjamin', 'East', 48);
|
What is the total number of unique equipment types, grouped by their types, on farms in the South region?
|
SELECT e.type, COUNT(DISTINCT e.id) as unique_equipment FROM equipment e JOIN farmers f ON e.farm_id = f.id WHERE f.region = 'South' GROUP BY e.type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE farmers (id INT PRIMARY KEY, name TEXT, location TEXT); INSERT INTO farmers (id, name, location) VALUES (1, 'John Doe', 'Springfield'); INSERT INTO farmers (id, name, location) VALUES (2, 'Jane Smith', 'Shelbyville'); CREATE TABLE crop_yields (farmer_id INT, year INT, yield INT); INSERT INTO crop_yields (farmer_id, year, yield) VALUES (1, 2020, 500); INSERT INTO crop_yields (farmer_id, year, yield) VALUES (1, 2021, 550); INSERT INTO crop_yields (farmer_id, year, yield) VALUES (2, 2020, 450); INSERT INTO crop_yields (farmer_id, year, yield) VALUES (2, 2021, 500);
|
What is the average yield of crops for each farmer in the 'rural_development' database?
|
SELECT f.name, AVG(cy.yield) as avg_yield FROM farmers f JOIN crop_yields cy ON f.id = cy.farmer_id GROUP BY f.id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE tourism_revenue (country VARCHAR(50), sector VARCHAR(50), revenue DECIMAL(10,2)); INSERT INTO tourism_revenue (country, sector, revenue) VALUES ('Saudi Arabia', 'Cultural Heritage', 15000.00), ('Jordan', 'Cultural Heritage', 12000.00), ('Israel', 'Virtual Tourism', 9000.00), ('Turkey', 'Cultural Heritage', 18000.00), ('Egypt', 'Cultural Heritage', 10000.00);
|
Which countries in the Middle East have the highest revenue from cultural heritage tourism?
|
SELECT country, SUM(revenue) as total_revenue FROM tourism_revenue WHERE sector = 'Cultural Heritage' AND country LIKE 'Middle%' GROUP BY country ORDER BY total_revenue DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE supplier (id INT PRIMARY KEY, name VARCHAR(50), country VARCHAR(50), product VARCHAR(50), cruelty_free BOOLEAN);
|
What is the name, country, and product of all cruelty-free suppliers from India?
|
SELECT supplier.name, supplier.country, product FROM supplier WHERE cruelty_free = TRUE AND country = 'India';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Dispensaries (Dispensary_ID INT, Dispensary_Name TEXT, State TEXT); INSERT INTO Dispensaries (Dispensary_ID, Dispensary_Name, State) VALUES (1, 'California Dream', 'CA'); CREATE TABLE Sales (Sale_ID INT, Dispensary_ID INT, Strain TEXT, Total_Sales DECIMAL); INSERT INTO Sales (Sale_ID, Dispensary_ID, Strain, Total_Sales) VALUES (1, 1, 'Blue Dream', 1800.00);
|
List the top 5 strains with the highest total sales in California dispensaries in Q3 2022.
|
SELECT Strain, SUM(Total_Sales) as Total FROM Sales JOIN Dispensaries ON Sales.Dispensary_ID = Dispensaries.Dispensary_ID WHERE State = 'CA' AND QUARTER(Sale_Date) = 3 GROUP BY Strain ORDER BY Total DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE crimes (id INT, type VARCHAR(255), year INT, count INT);
|
Find the total crime count for each type of crime in a given year.
|
SELECT type, SUM(count) FROM crimes WHERE year = 2022 GROUP BY type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE gold_extraction (id INT, mine TEXT, province TEXT, country TEXT, year INT, amount INT); INSERT INTO gold_extraction (id, mine, province, country, year, amount) VALUES (1, 'Gold Mine 1', 'Ontario', 'Canada', 2018, 1000); INSERT INTO gold_extraction (id, mine, province, country, year, amount) VALUES (2, 'Gold Mine 2', 'Ontario', 'Canada', 2019, 1200);
|
What is the total amount of gold extracted in the year 2019 in the province "Ontario" in Canada?
|
SELECT SUM(amount) FROM gold_extraction WHERE province = 'Ontario' AND country = 'Canada' AND year = 2019;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sectors (id INT, company_id INT, sector TEXT); INSERT INTO sectors (id, company_id, sector) VALUES (1, 3, 'Renewable Energy'), (2, 4, 'Healthcare'), (3, 5, 'Finance');
|
Find the number of companies in each sector in Asia with ESG scores above 75.
|
SELECT sectors.sector, COUNT(DISTINCT companies.id) FROM companies INNER JOIN sectors ON companies.id = sectors.company_id WHERE companies.country LIKE 'Asia%' AND companies.ESG_score > 75 GROUP BY sectors.sector;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE building_permit (permit_id INT, building_type VARCHAR(50), fee DECIMAL(10,2), city VARCHAR(50)); INSERT INTO building_permit (permit_id, building_type, fee, city) VALUES (1, 'Residential', 5000, 'Seattle'), (2, 'Commercial', 12000, 'Seattle'), (3, 'Residential', 4500, 'Los Angeles');
|
What is the average permit fee for residential buildings in the city of Seattle?
|
SELECT AVG(fee) FROM building_permit WHERE building_type = 'Residential' AND city = 'Seattle';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Labor_Statistics (state TEXT, workers_employed INTEGER, hours_worked INTEGER, wage_per_hour FLOAT); INSERT INTO Labor_Statistics (state, workers_employed, hours_worked, wage_per_hour) VALUES ('California', 5000, 25000, 30.5), ('Texas', 3000, 18000, 28.3), ('New York', 4000, 20000, 32.7);
|
What are the construction labor statistics for the state of California and New York?
|
SELECT * FROM Labor_Statistics WHERE state IN ('California', 'New York');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE madrid_bus (ride_id INT, fare DECIMAL(5,2), ride_date DATE); CREATE TABLE madrid_train (ride_id INT, fare DECIMAL(5,2), ride_date DATE); CREATE TABLE madrid_subway (ride_id INT, fare DECIMAL(5,2), ride_date DATE);
|
What is the total revenue for public transportation in Madrid on weekdays?
|
SELECT SUM(fare) FROM (SELECT fare FROM madrid_bus WHERE DAYOFWEEK(ride_date) BETWEEN 2 AND 6 UNION ALL SELECT fare FROM madrid_train WHERE DAYOFWEEK(ride_date) BETWEEN 2 AND 6 UNION ALL SELECT fare FROM madrid_subway WHERE DAYOFWEEK(ride_date) BETWEEN 2 AND 6) AS weekday_fares;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE digital_assets (id INT, name VARCHAR(255), type VARCHAR(50), price DECIMAL(10,2)); INSERT INTO digital_assets (id, name, type, price) VALUES (1, 'Asset1', 'Crypto', 10.5); INSERT INTO digital_assets (id, name, type, price) VALUES (2, 'Asset2', 'Crypto', 20.2); INSERT INTO digital_assets (id, name, type, price) VALUES (3, 'Asset3', 'Security', 50.0); INSERT INTO digital_assets (id, name, type, price) VALUES (4, 'Asset4', 'Security', 75.0); INSERT INTO digital_assets (id, name, type, price) VALUES (5, 'Asset5', 'Gaming', 15.0); INSERT INTO digital_assets (id, name, type, price) VALUES (6, 'Asset6', 'Gaming', 12.0); INSERT INTO digital_assets (id, name, type, price) VALUES (7, 'Asset7', 'Gaming', 22.0);
|
What is the average price of digital assets in the 'Gaming' category?
|
SELECT AVG(price) as avg_price FROM digital_assets WHERE type = 'Gaming';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Factories (factory_id INT, factory_name VARCHAR(50), country VARCHAR(50), certification VARCHAR(50)); CREATE TABLE Factory_Materials (factory_id INT, material_id INT); CREATE TABLE Materials (material_id INT, material_name VARCHAR(50), is_sustainable BOOLEAN); INSERT INTO Factories (factory_id, factory_name, country) VALUES (1, 'GreenSouth', 'Argentina'), (2, 'EcoCentral', 'Brazil'), (3, 'SustainableNorth', 'Colombia'); INSERT INTO Materials (material_id, material_name, is_sustainable) VALUES (1, 'Organic Cotton', true), (2, 'Synthetic Fiber', false), (3, 'Recycled Plastic', true), (4, 'Bamboo Fiber', true); INSERT INTO Factory_Materials (factory_id, material_id) VALUES (1, 1), (1, 3), (2, 1), (2, 3), (3, 3), (3, 4);
|
Which sustainable materials are used by factories in South America?
|
SELECT m.material_name FROM Factories f INNER JOIN Factory_Materials fm ON f.factory_id = fm.factory_id INNER JOIN Materials m ON fm.material_id = m.material_id WHERE f.country IN ('Argentina', 'Brazil', 'Colombia', 'Peru', 'Chile') AND m.is_sustainable = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE users (id INT PRIMARY KEY, name VARCHAR(50), age INT, gender VARCHAR(10), location VARCHAR(50)); CREATE TABLE comments (id INT PRIMARY KEY, post_id INT, user_id INT, comment_text VARCHAR(100)); INSERT INTO users (id, name, age, gender, location) VALUES (1, 'Maria', 28, 'Female', 'Brazil'); INSERT INTO users (id, name, age, gender, location) VALUES (2, 'Joao', 35, 'Male', 'Brazil'); INSERT INTO comments (id, post_id, user_id, comment_text) VALUES (1, 1, 1, 'Great post!'); INSERT INTO comments (id, post_id, user_id, comment_text) VALUES (2, 2, 2, 'Thanks!'); INSERT INTO comments (id, post_id, user_id, comment_text) VALUES (3, 1, 1, 'This is awesome!');
|
Which users are located in Brazil and have posted more than 5 comments?
|
SELECT users.name FROM users INNER JOIN comments ON users.id = comments.user_id WHERE users.location = 'Brazil' GROUP BY users.name HAVING COUNT(comments.id) > 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Asteroid_Impacts ( id INT, date DATE, impact_location VARCHAR(255), detected_by VARCHAR(255), size FLOAT );
|
Count the number of asteroid impacts on the Moon detected by the Lunar Reconnaissance Orbiter (LRO) in the year 2020.
|
SELECT COUNT(*) FROM Asteroid_Impacts WHERE date BETWEEN '2020-01-01' AND '2020-12-31' AND detected_by = 'Lunar Reconnaissance Orbiter';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE uk_workplaces (id INT, name TEXT, country TEXT, workplace_safety BOOLEAN, collective_bargaining BOOLEAN); INSERT INTO uk_workplaces (id, name, country, workplace_safety, collective_bargaining) VALUES (1, 'Workplace J', 'UK', true, true), (2, 'Workplace K', 'UK', false, true), (3, 'Workplace L', 'UK', true, false);
|
List the names of workplaces in the United Kingdom that have implemented workplace safety measures and have had successful collective bargaining agreements.
|
SELECT name FROM uk_workplaces WHERE workplace_safety = true AND collective_bargaining = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Members (MemberID INT, Age INT, Gender VARCHAR(10), MembershipType VARCHAR(20)); INSERT INTO Members (MemberID, Age, Gender, MembershipType) VALUES (1, 35, 'Female', 'Premium'), (2, 45, 'Male', 'Basic'), (3, 28, 'Female', 'Premium'); CREATE TABLE ClassAttendance (MemberID INT, Class VARCHAR(20), Date DATE); INSERT INTO ClassAttendance (MemberID, Class, Date) VALUES (1, 'Cycling', '2022-01-01'), (2, 'Yoga', '2022-01-02'), (3, 'Cycling', '2022-03-03'), (4, 'Yoga', '2022-03-04'), (5, 'Pilates', '2022-03-05');
|
Which workout was the most popular among female members in March 2022?
|
SELECT Class, COUNT(*) as AttendanceCount FROM Members JOIN ClassAttendance ON Members.MemberID = ClassAttendance.MemberID WHERE Members.Gender = 'Female' AND MONTH(ClassAttendance.Date) = 3 GROUP BY Class ORDER BY AttendanceCount DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Port_Singapore_Crane_Stats (crane_name TEXT, handling_date DATE, containers_handled INTEGER); INSERT INTO Port_Singapore_Crane_Stats (crane_name, handling_date, containers_handled) VALUES ('CraneA', '2021-02-01', 60), ('CraneB', '2021-02-02', 50), ('CraneC', '2021-02-03', 40), ('CraneD', '2021-02-04', 70);
|
What is the minimum number of containers handled in a single day by cranes in the Port of Singapore in February 2021?
|
SELECT MIN(containers_handled) FROM Port_Singapore_Crane_Stats WHERE handling_date >= '2021-02-01' AND handling_date <= '2021-02-28';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE factories (factory_id INT, factory_name VARCHAR(20)); INSERT INTO factories VALUES (1, 'Factory A'), (2, 'Factory B'), (3, 'Factory C'); CREATE TABLE roles (role_id INT, role_name VARCHAR(20)); INSERT INTO roles VALUES (1, 'junior'), (2, 'senior'), (3, 'manager'); CREATE TABLE workers (worker_id INT, factory_id INT, role_id INT, salary DECIMAL(5,2)); INSERT INTO workers VALUES (1, 1, 2, 35000.00), (2, 1, 2, 36000.00), (3, 2, 2, 45000.00), (4, 3, 2, 55000.00), (5, 3, 2, 65000.00);
|
What is the maximum salary paid by each factory to a 'senior' worker?
|
SELECT f.factory_name, MAX(salary) FROM workers w INNER JOIN factories f ON w.factory_id = f.factory_id INNER JOIN roles r ON w.role_id = r.role_id WHERE r.role_name = 'senior' GROUP BY f.factory_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Vessel_Age (ID INT, Vessel_Name VARCHAR(50), Construction_Country VARCHAR(50), Age INT); INSERT INTO Vessel_Age (ID, Vessel_Name, Construction_Country, Age) VALUES (1, 'Vessel1', 'China', 10); INSERT INTO Vessel_Age (ID, Vessel_Name, Construction_Country, Age) VALUES (2, 'Vessel2', 'Japan', 8); INSERT INTO Vessel_Age (ID, Vessel_Name, Construction_Country, Age) VALUES (3, 'Vessel3', 'China', 12);
|
What is the average age of vessels with a construction country of 'China'?
|
SELECT AVG(Age) FROM Vessel_Age WHERE Construction_Country = 'China';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE dishes (id INT, name TEXT, type TEXT, price FLOAT);
|
Calculate the average price of vegetarian dishes per category.
|
SELECT type, AVG(price) FROM dishes WHERE type LIKE '%vegetarian%' GROUP BY type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE energy_efficiency_stats (id INT PRIMARY KEY, building_type VARCHAR(255), building_location VARCHAR(255), energy_star_score INT, energy_consumption_kwh FLOAT);
|
List all energy efficiency stats for residential buildings in Texas.
|
SELECT * FROM energy_efficiency_stats WHERE building_type = 'Residential' AND building_location = 'Texas';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE artworks (id INT PRIMARY KEY, title VARCHAR(255), artist VARCHAR(255), year INT);
|
What is the latest artwork year?
|
SELECT MAX(year) FROM artworks;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE terbium_mines (country VARCHAR(20), num_mines INT); INSERT INTO terbium_mines (country, num_mines) VALUES ('China', 12), ('USA', 5), ('Australia', 3);
|
List the number of terbium mines in each country.
|
SELECT country, num_mines FROM terbium_mines;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE city_water_conservation (city VARCHAR(50), year INT, conservation_volume INT); INSERT INTO city_water_conservation (city, year, conservation_volume) VALUES ('CityA', 2019, 100), ('CityA', 2020, 200), ('CityB', 2019, 150), ('CityB', 2020, 250);
|
What is the total water conservation effort (in cubic meters) by each city in 2020?
|
SELECT city, SUM(conservation_volume) AS total_conservation_volume FROM city_water_conservation WHERE year = 2020 GROUP BY city;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE events (event_id INT, genre VARCHAR(20), revenue FLOAT, event_date DATE); INSERT INTO events (event_id, genre, revenue, event_date) VALUES (1, 'Classical Music', 5000, '2020-01-01'); INSERT INTO events (event_id, genre, revenue, event_date) VALUES (2, 'Classical Music', 7000, '2020-02-03');
|
What was the total revenue for the 'Classical Music' genre in 2020?
|
SELECT SUM(revenue) FROM events WHERE genre = 'Classical Music' AND event_date LIKE '2020-%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE neighborhoods (neighborhood_id INT, neighborhood_name VARCHAR(255));CREATE TABLE community_policing (event_id INT, event_date DATE, neighborhood_id INT); INSERT INTO neighborhoods VALUES (1, 'West Hill'), (2, 'East End'); INSERT INTO community_policing VALUES (1, '2020-01-01', 1), (2, '2020-02-01', 2);
|
What is the trend of community policing events in each neighborhood over time?
|
SELECT neighborhood_id, DATE_TRUNC('month', event_date) as month, COUNT(*) as num_events FROM community_policing GROUP BY neighborhood_id, month ORDER BY neighborhood_id, month
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Volunteers (id INT, volunteer_name TEXT, program TEXT, participation_date DATE); INSERT INTO Volunteers (id, volunteer_name, program, participation_date) VALUES (1, 'Jane Doe', 'Feeding the Hungry', '2022-01-05');
|
How many volunteers participated in each program in the last quarter?
|
SELECT program, COUNT(*) as num_volunteers FROM Volunteers WHERE participation_date >= DATEADD(quarter, -1, GETDATE()) GROUP BY program;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE green_buildings (id INT PRIMARY KEY, name VARCHAR(50), location VARCHAR(50), energy_rating INT);
|
Delete the 'green_buildings' table
|
DROP TABLE green_buildings;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE routes (route_id INT, route_name VARCHAR(255), length FLOAT, fare FLOAT);
|
What is the average length of each route in the 'routes' table?
|
SELECT route_name, AVG(length) as avg_length FROM routes GROUP BY route_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE co2_emissions (region VARCHAR(50), year INT, co2_emission_kg INT); INSERT INTO co2_emissions VALUES ('Latin America', 2015, 1000), ('Latin America', 2016, 900), ('Latin America', 2017, 850), ('Latin America', 2018, 800), ('Latin America', 2019, 750);
|
What is the average CO2 emission reduction in Latin America between 2015 and 2019?
|
SELECT AVG(co2_emission_kg) FROM co2_emissions WHERE region = 'Latin America' AND year BETWEEN 2015 AND 2019;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE energy_efficiency (sector VARCHAR(255), year INT, energy_improvement FLOAT); INSERT INTO energy_efficiency (sector, year, energy_improvement) VALUES ('Residential', 2017, 1.23), ('Commercial', 2017, 2.34), ('Industrial', 2017, 3.45), ('Transportation', 2017, 4.56), ('Residential', 2021, 6.78), ('Commercial', 2021, 7.89), ('Industrial', 2021, 8.90), ('Transportation', 2021, 9.01);
|
Calculate the total energy efficiency improvements for each sector in Australia from 2017 to 2021.
|
SELECT sector, SUM(energy_improvement) FROM energy_efficiency WHERE year IN (2017, 2021) GROUP BY sector;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vaccine_doses (patient_id INT, vaccine_name VARCHAR(255), administered_date DATE); INSERT INTO vaccine_doses VALUES (1, 'Pfizer-BioNTech', '2021-01-01'); INSERT INTO vaccine_doses VALUES (2, 'Moderna', '2021-01-15'); CREATE TABLE patients (patient_id INT, age INT, state VARCHAR(255)); INSERT INTO patients VALUES (1, 35, 'Texas'); INSERT INTO patients VALUES (2, 42, 'Texas'); CREATE TABLE census (state VARCHAR(255), population INT); INSERT INTO census VALUES ('Texas', 29527956);
|
What is the percentage of the population in Texas that has received at least one dose of the COVID-19 vaccine?
|
SELECT (COUNT(DISTINCT patients.patient_id) / census.population) * 100 AS percentage FROM patients INNER JOIN vaccine_doses ON patients.patient_id = vaccine_doses.patient_id CROSS JOIN census WHERE patients.state = 'Texas';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE concert_tours (concert_id INT, concert_name TEXT, artist_id INT, location TEXT, date DATE);
|
What is the earliest concert date for a specific artist in the 'concert_tours' table?
|
SELECT MIN(date) FROM concert_tours WHERE artist_id = 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE products (product_id int, product_category varchar(50), price decimal(5,2));
|
What is the number of products and their average price in each category, ranked by average price?
|
SELECT product_category, COUNT(*) as num_products, AVG(price) as avg_price, RANK() OVER (ORDER BY AVG(price) DESC) as rank FROM products GROUP BY product_category;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE clients (client_id INT, name VARCHAR(50), registration_date DATE); INSERT INTO clients VALUES (1, 'John Doe', '2021-01-05'), (2, 'Jane Smith', '2021-02-10'), (3, 'Alice Johnson', '2021-02-20'), (4, 'Bob Williams', '2021-03-03');
|
What is the number of new clients acquired each month in 2021?
|
SELECT DATE_FORMAT(registration_date, '%Y-%m') AS month, COUNT(*) FROM clients WHERE YEAR(registration_date) = 2021 GROUP BY month;
|
gretelai_synthetic_text_to_sql
|
CREATE VIEW autonomous_research AS SELECT * FROM research_data WHERE technology = 'autonomous'; INSERT INTO research_data (id, year, title, technology) VALUES (1, 2016, 'Study A', 'autonomous'), (2, 2017, 'Study B', 'autonomous'), (3, 2018, 'Study C', 'autonomous'), (4, 2019, 'Study D', 'autonomous');
|
List all autonomous vehicle research studies from '2018' in the 'autonomous_research' view.
|
SELECT * FROM autonomous_research WHERE year = 2018;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cities (id INT, name VARCHAR(255)); INSERT INTO cities (id, name) VALUES (1, 'City 1'), (2, 'City 2'); CREATE TABLE parks (id INT, name VARCHAR(255), city_id INT); INSERT INTO parks (id, name, city_id) VALUES (1, 'Park 1', 1), (2, 'Park 2', 1), (3, 'Park 3', 2); CREATE TABLE community_gardens (id INT, name VARCHAR(255), city_id INT); INSERT INTO community_gardens (id, name, city_id) VALUES (1, 'Community Garden 1', 1), (2, 'Community Garden 2', 1), (3, 'Community Garden 3', 2);
|
What is the total number of public parks and community gardens in 'City 1'?
|
SELECT COUNT(*) FROM parks WHERE city_id = (SELECT id FROM cities WHERE name = 'City 1'); SELECT COUNT(*) FROM community_gardens WHERE city_id = (SELECT id FROM cities WHERE name = 'City 1');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE regions (region_id INT, region_name VARCHAR(255)); CREATE TABLE tool_usage (usage_id INT, region_id INT, tool_name VARCHAR(255));
|
Which legal technology tools are most frequently used by region?
|
SELECT region_name, tool_name, COUNT(*) as usage_count FROM regions JOIN tool_usage ON regions.region_id = tool_usage.region_id GROUP BY region_name, tool_name ORDER BY usage_count DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Museums (museum_id INT, museum_name VARCHAR(50), country VARCHAR(50), has_virtual_tour BOOLEAN, is_sustainable_tourism_certified BOOLEAN); INSERT INTO Museums (museum_id, museum_name, country, has_virtual_tour, is_sustainable_tourism_certified) VALUES (1, 'VirtualUffizi Florence', 'Italy', true, true), (2, 'LeonardoDaVinci Museum Milan', 'Italy', false, true), (3, 'Colosseum Rome', 'Italy', false, false);
|
List all museums in Italy with virtual tours and sustainable tourism certifications.
|
SELECT museum_name FROM Museums WHERE country = 'Italy' AND has_virtual_tour = true AND is_sustainable_tourism_certified = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE GarmentSales (garment_type VARCHAR(50)); INSERT INTO GarmentSales (garment_type) VALUES ('T-Shirt'), ('Jackets'), ('Jeans');
|
Determine the number of unique garment types present in the 'GarmentSales' table.
|
SELECT COUNT(DISTINCT garment_type) FROM GarmentSales;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SoilTypes (id INT PRIMARY KEY, type VARCHAR(50), pH DECIMAL(3,1), farm_id INT); INSERT INTO SoilTypes (id, type, pH, farm_id) VALUES (1, 'Sandy', 6.5, 1001);
|
Update soil pH values for a specific farm
|
UPDATE SoilTypes SET pH = 6.8 WHERE farm_id = 1001;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SpaceConquerorsPlayers (PlayerID INT, PlayerName VARCHAR(50), PlaytimeMinutes INT, Rank VARCHAR(10)); INSERT INTO SpaceConquerorsPlayers VALUES (1, 'CharlotteMiller', 250, 'Bronze'), (2, 'JamesJohnson', 350, 'Bronze'), (3, 'SophiaLopez', 450, 'Silver'), (4, 'EthanGonzalez', 550, 'Gold');
|
What is the minimum playtime in minutes for players who have achieved a rank of Bronze or higher in the game "Space Conquerors"?
|
SELECT MIN(PlaytimeMinutes) FROM SpaceConquerorsPlayers WHERE Rank IN ('Bronze', 'Silver', 'Gold', 'Platinum');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ArtistSongData (ArtistID INT, ArtistName VARCHAR(100), Genre VARCHAR(50), SongID INT); INSERT INTO ArtistSongData (ArtistID, ArtistName, Genre, SongID) VALUES (1, 'Beyoncé', 'R&B', 1), (2, 'Rihanna', 'R&B', 2), (3, 'Beyoncé', 'R&B', 3);
|
Which artists have released the most songs in the R&B genre?
|
SELECT ArtistName, COUNT(*) as SongCount FROM ArtistSongData WHERE Genre = 'R&B' GROUP BY ArtistName ORDER BY SongCount DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE farmers (id INT PRIMARY KEY, name VARCHAR(50), age INT, location VARCHAR(50)); INSERT INTO farmers (id, name, age, location) VALUES (1, 'John Doe', 35, 'New York'); INSERT INTO farmers (id, name, age, location) VALUES (2, 'Jane Smith', 40, 'Los Angeles'); CREATE TABLE fertilizers (id INT PRIMARY KEY, name VARCHAR(50), used_on DATE, used_by INT, FOREIGN KEY (used_by) REFERENCES farmers(id)); INSERT INTO fertilizers (id, name, used_on, used_by) VALUES (1, 'Organic Fertilizer', '2022-07-01', 2); INSERT INTO fertilizers (id, name, used_on, used_by) VALUES (2, 'Chemical Fertilizer', '2022-02-01', 1);
|
Which farmers used organic fertilizers in the last 6 months?
|
SELECT farmers.name FROM farmers INNER JOIN fertilizers ON farmers.id = fertilizers.used_by WHERE fertilizers.name = 'Organic Fertilizer' AND fertilizers.used_on >= (CURRENT_DATE - INTERVAL '6 months');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE plants (id INT, name TEXT, region TEXT, safety_score INT); INSERT INTO plants (id, name, region, safety_score) VALUES (1, 'ChemCo', 'Midwest', 85), (2, 'EcoChem', 'Midwest', 92), (3, 'GreenChem', 'Southwest', 88);
|
What is the minimum safety score for chemical plants in the midwest region, ordered by safety score?
|
SELECT MIN(safety_score) AS min_safety_score FROM plants WHERE region = 'Midwest' ORDER BY safety_score;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Categories (CategoryID INT, CategoryName VARCHAR(50)); INSERT INTO Categories (CategoryID, CategoryName) VALUES (1, 'CategoryA'), (2, 'CategoryB'), (3, 'CategoryC'); CREATE TABLE EcoFriendlyProducts (ProductID INT, ProductName VARCHAR(50), CategoryID INT, Price DECIMAL(5,2)); INSERT INTO EcoFriendlyProducts (ProductID, ProductName, CategoryID, Price) VALUES (1, 'ProductA', 1, 15.50), (2, 'ProductB', 1, 18.60), (3, 'ProductC', 2, 20.70), (4, 'ProductD', 2, 23.80), (5, 'ProductE', 3, 25.90), (6, 'ProductF', 3, 30.00);
|
What is the minimum and maximum price of eco-friendly products in each category?
|
SELECT CategoryName, MIN(Price) as MinPrice, MAX(Price) as MaxPrice FROM Categories c JOIN EcoFriendlyProducts efp ON c.CategoryID = efp.CategoryID GROUP BY CategoryName;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ShariahCompliantTransactions (transactionID INT, userID VARCHAR(20), transactionAmount DECIMAL(10,2), transactionDate DATE); INSERT INTO ShariahCompliantTransactions (transactionID, userID, transactionAmount, transactionDate) VALUES (1, 'JohnDoe', 500.00, '2022-01-01'), (2, 'JaneDoe', 300.00, '2022-01-02'), (3, 'JohnDoe', 600.00, '2022-02-01');
|
Calculate the average transaction amount for users in the ShariahCompliantTransactions table, grouped by month.
|
SELECT MONTH(transactionDate), AVG(transactionAmount) FROM ShariahCompliantTransactions GROUP BY MONTH(transactionDate);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE environmental_incidents ( id INT, vessel_id INT, incident_type VARCHAR(255), incident_date DATE ); INSERT INTO environmental_incidents (id, vessel_id, incident_type, incident_date) VALUES (1, 8, 'Oil spill', '2021-08-15'); INSERT INTO environmental_incidents (id, vessel_id, incident_type, incident_date) VALUES (2, 9, 'Garbage disposal', '2021-06-28');
|
List all environmental pollution incidents for vessels in the Baltic Sea, sorted by date.
|
SELECT vessel_id, incident_type, incident_date FROM environmental_incidents WHERE latitude BETWEEN 54 AND 66 AND longitude BETWEEN 10 AND 30 ORDER BY incident_date;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE EsportsEvents (EventID int, EventName varchar(25), Location varchar(20), PrizeMoney decimal(10,2)); INSERT INTO EsportsEvents (EventID, EventName, Location, PrizeMoney) VALUES (1, 'Event1', 'Europe', 50000.00); INSERT INTO EsportsEvents (EventID, EventName, Location, PrizeMoney) VALUES (2, 'Event2', 'North America', 75000.00);
|
How many esports events were held in Europe and North America, and what is the total prize money awarded in these regions?
|
SELECT SUM(CASE WHEN Location IN ('Europe', 'North America') THEN PrizeMoney ELSE 0 END) AS TotalPrizeMoney, COUNT(CASE WHEN Location IN ('Europe', 'North America') THEN 1 ELSE NULL END) AS EventCount FROM EsportsEvents;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE glaciers (country VARCHAR(255), glacier_name VARCHAR(255), count INT);
|
How many glaciers are there in Iceland and Canada?
|
SELECT COUNT(DISTINCT glacier_name) FROM glaciers WHERE country IN ('Iceland', 'Canada');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE wells (id INT, name VARCHAR(255), location VARCHAR(255), production_quantity INT); INSERT INTO wells (id, name, location, production_quantity) VALUES (1, 'Well A', 'North Sea', 1000), (2, 'Well B', 'Gulf of Mexico', 2000), (3, 'Well C', 'North Sea', 1500);
|
What is the minimum production quantity for wells located in the 'North Sea'?
|
SELECT MIN(production_quantity) FROM wells WHERE location = 'North Sea';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE consumer_preferences (product_id INT, preference_score DECIMAL(5,2), country VARCHAR(50)); INSERT INTO consumer_preferences (product_id, preference_score, country) VALUES (1001, 4.8, 'USA'), (1002, 4.5, 'USA'), (1003, 4.9, 'Canada'), (1004, 4.7, 'USA'), (1005, 4.6, 'Mexico');
|
List the top 3 beauty products with the highest consumer preference score in the USA, ordered by the score in descending order.
|
SELECT product_id, preference_score FROM consumer_preferences WHERE country = 'USA' GROUP BY product_id ORDER BY preference_score DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE solar_panels (id INT, state VARCHAR(255), installed BOOLEAN); INSERT INTO solar_panels (id, state, installed) VALUES (1, 'California', true), (2, 'Texas', true), (3, 'California', true), (4, 'Texas', false), (5, 'California', false);
|
How many solar panels are installed in California and Texas?
|
SELECT state, COUNT(*) as total_installed FROM solar_panels WHERE installed = true GROUP BY state;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cuisine (cuisine_id INT, cuisine_name VARCHAR(255)); INSERT INTO cuisine (cuisine_id, cuisine_name) VALUES (1, 'Italian'), (2, 'Mexican'), (3, 'Indian'); CREATE TABLE dishes (dish_id INT, dish_name VARCHAR(255), cuisine_id INT, is_vegetarian BOOLEAN); INSERT INTO dishes (dish_id, dish_name, cuisine_id, is_vegetarian) VALUES (1, 'Margherita Pizza', 1, true), (2, 'Chiles Rellenos', 2, false), (3, 'Palak Paneer', 3, true);
|
What is the total number of vegetarian dishes offered by each cuisine category?
|
SELECT cuisine_name, COUNT(*) as total_veg_dishes FROM dishes d JOIN cuisine c ON d.cuisine_id = c.cuisine_id WHERE is_vegetarian = true GROUP BY cuisine_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE incidents (incident_id INT, incident_type VARCHAR(50), location VARCHAR(50), date_time DATETIME);
|
List the 'incident_type' and 'location' for incidents that occurred between 2021-01-01 and 2021-06-30
|
SELECT incident_type, location FROM incidents WHERE date_time BETWEEN '2021-01-01' AND '2021-06-30';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE success_rates (id INT, effort TEXT, country TEXT, success BOOLEAN); INSERT INTO success_rates (id, effort, country, success) VALUES (1, 'Agro-processing', 'Peru', TRUE), (2, 'Textiles', 'Colombia', FALSE);
|
What is the success rate of economic diversification efforts in Peru and Colombia?
|
SELECT COUNT(*) FILTER (WHERE success = TRUE) * 100.0 / COUNT(*) FROM success_rates WHERE country IN ('Peru', 'Colombia');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE revenue (restaurant_id INT, sustainable BOOLEAN, amount DECIMAL(10,2)); INSERT INTO revenue (restaurant_id, sustainable, amount) VALUES (5, true, 1200.00), (5, false, 800.00), (5, true, 1500.00), (5, false, 500.00);
|
What is the total revenue for 'Restaurant E' from sustainable sourced ingredients in the year 2022?
|
SELECT SUM(amount) FROM revenue WHERE restaurant_id = 5 AND sustainable = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sports (id INT PRIMARY KEY, name VARCHAR(255)); CREATE TABLE athletes (id INT PRIMARY KEY, name VARCHAR(255), age INT, sport_id INT, team VARCHAR(255), FOREIGN KEY (sport_id) REFERENCES sports(id)); INSERT INTO sports (id, name) VALUES (1, 'Basketball'); INSERT INTO athletes (id, name, age, sport_id, team) VALUES (1, 'John Doe', 25, 1, 'Lakers'); INSERT INTO athletes (id, name, age, sport_id, team) VALUES (2, 'Jane Smith', 28, 1, 'Knicks');
|
List all athletes who play basketball
|
SELECT athletes.name FROM athletes INNER JOIN sports ON athletes.sport_id = sports.id WHERE sports.name = 'Basketball';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE waste_generation (city VARCHAR(20), year INT, material VARCHAR(20), weight FLOAT); INSERT INTO waste_generation (city, year, material, weight) VALUES ('London', 2018, 'Plastic', 1800), ('London', 2018, 'Paper', 3000), ('London', 2018, 'Glass', 2000);
|
What is the total waste generation by material type in the city of London in 2018?
|
SELECT material, SUM(weight) as total_weight FROM waste_generation WHERE city = 'London' AND year = 2018 GROUP BY material;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE projects (id INT, location VARCHAR(50), project_type VARCHAR(50), completion_date DATE); INSERT INTO projects (id, location, project_type, completion_date) VALUES (1, 'India', 'community development', '2019-05-01'), (2, 'Brazil', 'rural infrastructure', '2017-12-31'), (3, 'Ghana', 'community development', '2016-08-15'), (4, 'India', 'community development', '2018-09-05'), (5, 'Tanzania', 'agricultural innovation', '2014-11-23');
|
How many community development projects were completed in rural areas in 2019?
|
SELECT COUNT(*) FROM projects WHERE project_type = 'community development' AND location LIKE 'rural%' AND completion_date BETWEEN '2019-01-01' AND '2019-12-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE RecyclingRates (Date date, Location text, Material text, Rate real);CREATE TABLE CircularEconomyInitiatives (Location text, Initiative text, StartDate date);
|
What is the average recycling rate and the number of circular economy initiatives for each location and material, for the year 2021?
|
SELECT rr.Location, rr.Material, AVG(rr.Rate) as AvgRecyclingRate, COUNT(DISTINCT cei.Initiative) as NumberOfInitiatives FROM RecyclingRates rr LEFT JOIN CircularEconomyInitiatives cei ON rr.Location = cei.Location WHERE rr.Date >= '2021-01-01' AND rr.Date < '2022-01-01' GROUP BY rr.Location, rr.Material;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE PlayerGames (PlayerID INT, GameID INT, GameWon BOOLEAN);
|
Get the total number of wins for each player in the 'PlayerGames' table
|
SELECT PlayerID, SUM(GameWon) as TotalWins FROM PlayerGames WHERE GameWon = TRUE GROUP BY PlayerID;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Accounts (CustomerID INT, AccountType VARCHAR(50), Balance DECIMAL(10,2)); INSERT INTO Accounts (CustomerID, AccountType, Balance) VALUES (1, 'Savings', 10000); INSERT INTO Accounts (CustomerID, AccountType, Balance) VALUES (2, 'Checking', 5000);
|
What are the total assets of customers who don't have a savings account?
|
SELECT SUM(Balance) FROM Accounts WHERE AccountType != 'Savings'
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donations (DonationID INT, DonorID INT, CauseID INT, Amount DECIMAL(10,2), Quarter INT, Year INT); INSERT INTO Donations (DonationID, DonorID, CauseID, Amount, Quarter, Year) VALUES (1, 1, 1, 1000, 2, 2021), (2, 2, 2, 1500, 2, 2021), (3, 3, 3, 1200, 2, 2021), (4, 4, 4, 1800, 2, 2021), (5, 5, 1, 800, 2, 2021);
|
How many donations were made in Q2 2021?
|
SELECT COUNT(*) FROM Donations WHERE Quarter = 2 AND Year = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donors (DonorID int, DonorName varchar(50), DonationDate date, DonationAmount decimal(10,2), Program varchar(50)); INSERT INTO Donors (DonorID, DonorName, DonationDate, DonationAmount, Program) VALUES (1, 'John Doe', '2019-07-02', 50.00, 'ProgramA'), (2, 'Jane Smith', '2019-08-15', 100.00, 'ProgramB'), (3, 'Mike Johnson', '2019-09-01', 75.00, 'ProgramA');
|
What was the total donation amount and average donation amount per donor for each program in Q3 2019?
|
SELECT Program, SUM(DonationAmount) as TotalDonationAmount, AVG(DonationAmount) as AverageDonationAmountPerDonor FROM Donors WHERE DonationDate BETWEEN '2019-07-01' AND '2019-09-30' GROUP BY Program;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cruelty_free_certification (id INT PRIMARY KEY, product_name VARCHAR(255), certification_date DATE, certified_by VARCHAR(255)); INSERT INTO cruelty_free_certification (id, product_name, certification_date, certified_by) VALUES (1, 'Organic Lipstick', '2021-01-01', 'Leaping Bunny');
|
How many cruelty-free certifications were issued in the first half of 2021?
|
SELECT COUNT(*) as count FROM cruelty_free_certification WHERE certification_date BETWEEN '2021-01-01' AND '2021-06-30';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE policies (policy_id INT, policyholder_id INT, policy_start_date DATE, policy_end_date DATE); CREATE TABLE claims_info (claim_id INT, policy_id INT, claim_date DATE); INSERT INTO policies VALUES (1, 1, '2020-01-01', '2021-01-01'); INSERT INTO policies VALUES (2, 2, '2019-01-01', '2020-01-01'); INSERT INTO claims_info VALUES (1, 1, '2020-01-01'); INSERT INTO claims_info VALUES (2, 1, '2020-06-01'); INSERT INTO claims_info VALUES (3, 2, '2019-02-01');
|
Show policy details and the number of claims filed for each policy
|
SELECT policies.policy_id, policyholder_id, policy_start_date, policy_end_date, COUNT(claim_id) AS num_claims FROM policies INNER JOIN claims_info USING (policy_id) GROUP BY policies.policy_id, policyholder_id, policy_start_date, policy_end_date
|
gretelai_synthetic_text_to_sql
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.