context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE water_usage ( date DATE, usage_category VARCHAR(20), region VARCHAR(20), usage_amount INT ); INSERT INTO water_usage (date, usage_category, region, usage_amount) VALUES ( '2022-07-01', 'Residential', 'Northeast', 15000), ('2022-07-02', 'Industrial', 'Midwest', 200000), ('2022-07-03', 'Agricultural', 'West'...
Delete the water usage data for the 'Agricultural' category in the water_usage table for the date '2022-07-03'
DELETE FROM water_usage WHERE usage_category = 'Agricultural' AND date = '2022-07-03';
gretelai_synthetic_text_to_sql
CREATE TABLE MenuItems(menu_item_id INT, item_name VARCHAR(255), order_count INT, food_cost_percentage DECIMAL(5,2));
What is the maximum food cost percentage for menu items that have been ordered more than 100 times?
SELECT MAX(food_cost_percentage) FROM MenuItems WHERE order_count > 100;
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tours (tour_id INT, hotel_name TEXT, engagement_rate FLOAT); INSERT INTO virtual_tours (tour_id, hotel_name, engagement_rate) VALUES (1, 'Hotel A', 0.05), (2, 'Hotel B', 0.07), (3, 'Hotel C', 0.06);
What is the virtual tour engagement rate for each hotel, sorted by engagement rate in ascending order?
SELECT hotel_name, engagement_rate FROM virtual_tours ORDER BY engagement_rate ASC;
gretelai_synthetic_text_to_sql
CREATE TABLE violent_crimes (id INT, city VARCHAR(20), clearance_rate FLOAT); INSERT INTO violent_crimes (id, city, clearance_rate) VALUES (1, 'Dallas', 0.55);
What is the clearance rate for violent crimes in the city of Dallas?
SELECT clearance_rate FROM violent_crimes WHERE city = 'Dallas';
gretelai_synthetic_text_to_sql
CREATE TABLE red_line_rides (ride_id int, time_of_day varchar(20)); INSERT INTO red_line_rides (ride_id, time_of_day) VALUES (1, 'Morning'), (2, 'Evening'), (3, 'Morning');
How many 'Red' line rides were there in 'Evening'?
SELECT COUNT(*) FROM red_line_rides WHERE time_of_day = 'Evening';
gretelai_synthetic_text_to_sql
CREATE TABLE hospital_beds (id INT, hospital_name VARCHAR(50), hospital_type VARCHAR(50), num_beds INT); INSERT INTO hospital_beds (id, hospital_name, hospital_type, num_beds) VALUES (1, 'Hospital A', 'Public', 500);
What is the total number of hospital beds by hospital type?
SELECT hospital_type, SUM(num_beds) as total_beds FROM hospital_beds GROUP BY hospital_type;
gretelai_synthetic_text_to_sql
CREATE TABLE users (user_id INT, region VARCHAR(50), profile_picture_update_date DATE, gender VARCHAR(50));CREATE TABLE posts (post_id INT, user_id INT, post_date DATE); INSERT INTO users (user_id, region, profile_picture_update_date, gender) VALUES (1, 'Asia', '2023-03-25', 'female'), (2, 'Asia', '2023-03-23', 'male')...
How many users in Asia have updated their profile pictures in the past month and what is the average number of posts they have made?
SELECT AVG(post_count) as avg_posts, COUNT(DISTINCT user_id) as num_users FROM (SELECT user_id, COUNT(*) as post_count FROM posts WHERE post_date >= DATEADD(month, -1, CURRENT_DATE) GROUP BY user_id) as post_counts JOIN users ON post_counts.user_id = users.user_id WHERE region = 'Asia' AND profile_picture_update_date >...
gretelai_synthetic_text_to_sql
CREATE TABLE patients(id INT, name TEXT, location TEXT, primary_care_physician TEXT); INSERT INTO patients(id, name, location, primary_care_physician) VALUES (1, 'Patient A', 'Midwest', 'Dr. Smith'), (2, 'Patient B', 'Midwest', 'Dr. Johnson'), (3, 'Patient C', 'California', 'Dr. Brown'), (4, 'Patient D', 'Florida', 'Dr...
What is the number of patients and their respective primary care physicians in the Midwest?
SELECT COUNT(*) as patient_count, primary_care_physician FROM patients WHERE location = 'Midwest' GROUP BY primary_care_physician;
gretelai_synthetic_text_to_sql
CREATE TABLE nutrition (product_id VARCHAR(10), calories INTEGER); INSERT INTO nutrition (product_id, calories) VALUES ('P001', 150), ('P002', 200), ('P003', 250), ('P004', 120), ('P005', 180);CREATE TABLE products (product_id VARCHAR(10), name VARCHAR(50), is_organic BOOLEAN); INSERT INTO products (product_id, name, i...
Get the average calories for organic products.
SELECT AVG(nutrition.calories) FROM nutrition JOIN products ON nutrition.product_id = products.product_id WHERE products.is_organic = true;
gretelai_synthetic_text_to_sql
CREATE TABLE building_permits (permit_id INT); CREATE TABLE labor_stats (permit_id INT, violation VARCHAR(100));
List all permits and the number of labor violations for each permit
SELECT bp.permit_id, COUNT(ls.permit_id) AS num_violations FROM building_permits bp LEFT JOIN labor_stats ls ON bp.permit_id = ls.permit_id GROUP BY bp.permit_id;
gretelai_synthetic_text_to_sql
CREATE TABLE model_scores (model_name TEXT, accuracy FLOAT, category TEXT); INSERT INTO model_scores (model_name, accuracy, category) VALUES ('modelA', 0.91, 'explainable_ai'), ('modelB', 0.85, 'algorithmic_fairness'), ('modelC', 0.95, 'explainable_ai'), ('modelD', 0.78, 'creative_ai');
List the names and accuracy scores of all models that belong to the 'explainable_ai' category.
SELECT model_name, accuracy FROM model_scores WHERE category = 'explainable_ai';
gretelai_synthetic_text_to_sql
CREATE TABLE FilmPrograms (Id INT, ProgramName VARCHAR(50), Category VARCHAR(50), Budget DECIMAL(10,2));
What is the total budget for film programs, and what percentage of the budget is allocated to each program category?
SELECT Category, SUM(Budget) as TotalBudget, 100.0 * SUM(Budget) / (SELECT SUM(Budget) FROM FilmPrograms) as Percentage FROM FilmPrograms GROUP BY Category;
gretelai_synthetic_text_to_sql
CREATE TABLE age_groups (subscriber_id INT, data_usage_gb FLOAT, age_group VARCHAR(25));
What is the average monthly data usage for mobile customers in each age group?
SELECT age_group, AVG(data_usage_gb) FROM age_groups GROUP BY age_group;
gretelai_synthetic_text_to_sql
CREATE TABLE incidents (incident_id INT, region VARCHAR(50), severity VARCHAR(10)); INSERT INTO incidents (incident_id, region, severity) VALUES (1, 'region_1', 'medium'), (2, 'region_2', 'high'), (3, 'region_3', 'high'), (4, 'region_1', 'low'), (5, 'region_3', 'medium');
How many security incidents were recorded in 'region_3' in the 'incidents' table?
SELECT COUNT(*) FROM incidents WHERE region = 'region_3';
gretelai_synthetic_text_to_sql
CREATE TABLE organizations (id INT, name TEXT, city TEXT, state TEXT, donations_received DECIMAL(10,2), volunteers INT); INSERT INTO organizations (id, name, city, state, donations_received, volunteers) VALUES (1, 'Organization A', 'San Francisco', 'CA', 50000.00, 100), (2, 'Organization B', 'Los Angeles', 'CA', 75000....
What are the average donations received per volunteer for organizations located in the Midwest region?
SELECT AVG(o.donations_received / o.volunteers) AS avg_donations_per_volunteer FROM organizations o JOIN states s ON o.state = s.state WHERE s.region = 'Midwest';
gretelai_synthetic_text_to_sql
CREATE TABLE funds (fund_id INT, community_id INT, amount DECIMAL(10, 2), donation_date DATE); INSERT INTO funds (fund_id, community_id, amount, donation_date) VALUES (1, 1, 5000.00, '2021-01-01');
What is the total amount of funds raised by year in 'community_development' schema?
SELECT YEAR(donation_date) as year, SUM(amount) as total_funds_raised FROM funds GROUP BY YEAR(donation_date);
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, Gender VARCHAR(10), Department VARCHAR(20)); INSERT INTO Employees (EmployeeID, Gender, Department) VALUES (1, 'Female', 'IT'), (2, 'Male', 'IT'), (3, 'Non-binary', 'HR'), (4, 'Male', 'Finance'), (5, 'Non-binary', 'IT'), (6, 'Genderqueer', 'IT');
List all unique genders in the Employees table.
SELECT DISTINCT Gender FROM Employees;
gretelai_synthetic_text_to_sql
CREATE TABLE waste_generation(region VARCHAR(20), year INT, waste_gram INT); INSERT INTO waste_generation(region, year, waste_gram) VALUES('North', 2021, 50000),('North', 2022, 60000),('South', 2021, 40000),('South', 2022, 70000);
Insert new waste generation records for the 'Mountain' region in 2024 with a waste_gram of 55000.
INSERT INTO waste_generation(region, year, waste_gram) VALUES('Mountain', 2024, 55000);
gretelai_synthetic_text_to_sql
CREATE TABLE agricultural_projects (id INT, province VARCHAR(50), cost FLOAT, project_type VARCHAR(50), start_date DATE, end_date DATE); INSERT INTO agricultural_projects (id, province, cost, project_type, start_date, end_date) VALUES (1, 'Quebec', 45000.00, 'Smart Farming', '2017-01-01', '2017-12-31');
How many agricultural innovation projects were completed in the province of Quebec between 2017 and 2019?
SELECT COUNT(*) FROM agricultural_projects WHERE province = 'Quebec' AND start_date <= '2019-12-31' AND end_date >= '2017-01-01' AND project_type = 'Smart Farming';
gretelai_synthetic_text_to_sql
CREATE TABLE bus_routes (route_id INT, route_name TEXT, starting_point TEXT, ending_point TEXT); INSERT INTO bus_routes (route_id, route_name, starting_point, ending_point) VALUES (1, 'Green Line', 'Downtown', 'Suburbia'); CREATE TABLE fares (fare_id INT, route_id INT, fare_amount DECIMAL, fare_date DATE);
What is the total revenue for each bus route in the past month?
SELECT br.route_name, SUM(f.fare_amount) as total_revenue FROM bus_routes br INNER JOIN fares f ON br.route_id = f.route_id WHERE f.fare_date >= DATEADD(month, -1, GETDATE()) GROUP BY br.route_name;
gretelai_synthetic_text_to_sql
CREATE TABLE Inspections (restaurant TEXT, score INT, date TEXT); INSERT INTO Inspections (restaurant, score, date) VALUES ('Asian Fusion', 95, '2022-01-01'), ('Bistro Bella Vita', 90, '2022-01-02'), ('Taqueria Tsunami', 98, '2022-01-03'), ('Asian Fusion', 96, '2022-01-04'), ('Bistro Bella Vita', 92, '2022-01-05');
What is the average food safety score for each restaurant over time, with the most recent score first?
SELECT restaurant, AVG(score) as avg_score, MAX(date) as max_date FROM Inspections GROUP BY restaurant ORDER BY max_date DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE SmartCityAdoption (region VARCHAR(20), adoption_rate FLOAT); INSERT INTO SmartCityAdoption (region, adoption_rate) VALUES ('RegionA', 70.5), ('RegionB', 80.0), ('RegionC', 65.0), ('RegionD', 85.0);
What is the maximum smart city technology adoption rate per region?
SELECT region, MAX(adoption_rate) FROM SmartCityAdoption;
gretelai_synthetic_text_to_sql
CREATE TABLE Precedents ( PrecedentID INT, CaseID INT, BillingAmount DECIMAL(10,2) ); INSERT INTO Precedents (PrecedentID, CaseID, BillingAmount) VALUES (1, 1, 500.00), (2, 1, 750.00), (3, 2, 800.00), (4, 3, 900.00), (5, 4, 1000.00), (6, 5, 400.00), (7, 6, 350.00), (8, 7, 1200.00), (9, 8, 1500.00), (10, 9, 1100.00), (1...
What is the maximum and minimum billing amount for each legal precedent?
SELECT PrecedentID, MAX(BillingAmount) AS Max_Billing_Amount, MIN(BillingAmount) AS Min_Billing_Amount FROM Precedents GROUP BY PrecedentID;
gretelai_synthetic_text_to_sql
CREATE TABLE restaurants (id INT, name TEXT, area TEXT); INSERT INTO restaurants (id, name, area) VALUES (1, 'Restaurant A', 'downtown'), (2, 'Restaurant B', 'uptown'), (3, 'Restaurant C', 'downtown'), (4, 'Restaurant D', 'downtown'), (5, 'Restaurant E', 'uptown'), (6, 'Restaurant F', 'downtown');
How many restaurants are there in each area?
SELECT area, COUNT(area) FROM restaurants GROUP BY area;
gretelai_synthetic_text_to_sql
CREATE TABLE organizations (id INT, name VARCHAR(255)); INSERT INTO organizations (id, name) VALUES (1, 'UNESCO'), (2, 'UNICEF'), (3, 'Save the Children'); CREATE TABLE resources (id INT, organization_id INT, resource_type VARCHAR(255), quantity INT, distribution_date DATE); INSERT INTO resources (id, organization_id, ...
How many educational resources were provided in total by each organization in 2020?
SELECT organization_id, SUM(quantity) as total_resources FROM resources WHERE YEAR(distribution_date) = 2020 GROUP BY organization_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Forests (id INT, name VARCHAR(255), hectares FLOAT, country VARCHAR(255)); INSERT INTO Forests (id, name, hectares, country) VALUES (1, 'Amazon Rainforest', 55000000.0, 'Brazil'); CREATE TABLE WildlifeHabitat (id INT, forest_id INT, hectares FLOAT); INSERT INTO WildlifeHabitat (id, forest_id, hectares) VAL...
What is the maximum and minimum hectares of wildlife habitat in each forest?
SELECT Forests.name, MAX(WildlifeHabitat.hectares) as max_wildlife_habitat, MIN(WildlifeHabitat.hectares) as min_wildlife_habitat FROM Forests INNER JOIN WildlifeHabitat ON Forests.id = WildlifeHabitat.forest_id GROUP BY Forests.name;
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels (VesselID INT, VesselName VARCHAR(100), LoadingCapacity FLOAT); INSERT INTO Vessels (VesselID, VesselName, LoadingCapacity) VALUES (1, 'Ocean Titan', 65000), (2, 'Sea Giant', 35000), (3, 'Marine Unicorn', 42000), (4, 'Sky Wanderer', 28000);
Determine the number of unique vessel names for vessels with a loading capacity greater than 40000 tons
SELECT COUNT(DISTINCT VesselName) FROM Vessels WHERE LoadingCapacity > 40000;
gretelai_synthetic_text_to_sql
CREATE TABLE events (event_id INT, event_name VARCHAR(50), event_type VARCHAR(50), visitor_count INT, gender VARCHAR(10));
How many female and male visitors attended performing arts events?
SELECT event_type, SUM(CASE WHEN gender = 'Female' THEN visitor_count ELSE 0 END) AS female_visitors, SUM(CASE WHEN gender = 'Male' THEN visitor_count ELSE 0 END) AS male_visitors FROM events WHERE event_type = 'Performing Arts' GROUP BY event_type;
gretelai_synthetic_text_to_sql
CREATE TABLE donations_climate_change (id INT, donor_id INT, category VARCHAR(255), donation_amount DECIMAL(10,2), donation_date DATE); INSERT INTO donations_climate_change (id, donor_id, category, donation_amount, donation_date) VALUES (1, 9001, 'climate_change', 50.00, '2022-01-01'); INSERT INTO donations_climate_cha...
What is the maximum amount donated to "climate_change" by a unique donor?
SELECT MAX(donation_amount) FROM donations_climate_change WHERE category = 'climate_change' GROUP BY donor_id HAVING COUNT(donor_id) = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE company_founding (id INT, company_name VARCHAR(100), founding_date DATE); INSERT INTO company_founding (id, company_name, founding_date) VALUES (1, 'Acme Inc.', '2015-06-20'), (2, 'Bravo Corp.', '2016-08-10'), (9, 'Kilo Ltd.', '2016-03-05');
Update all records in the "company_founding" table, setting the founding date to 2017-01-01 for the company 'Kilo Ltd.'
UPDATE company_founding SET founding_date = '2017-01-01' WHERE company_name = 'Kilo Ltd.';
gretelai_synthetic_text_to_sql
CREATE TABLE regions (region_id INT, name VARCHAR(255)); INSERT INTO regions VALUES (1, 'Oceania'); INSERT INTO regions VALUES (2, 'Asia'); CREATE TABLE factories (factory_id INT, name VARCHAR(255), location VARCHAR(255), country_id INT, labor_rating INT, region_id INT); INSERT INTO factories VALUES (1, 'Ethical Factor...
How many factories are located in 'Oceania' and have a labor rating of 80 or higher?
SELECT COUNT(factories.factory_id) FROM factories WHERE factories.region_id IN (SELECT region_id FROM regions WHERE regions.name = 'Oceania') AND factories.labor_rating >= 80;
gretelai_synthetic_text_to_sql
CREATE TABLE SecurityIncidents (incident_id INT, status VARCHAR(10), assets_impacted INT, timestamp TIMESTAMP); INSERT INTO SecurityIncidents (incident_id, status, assets_impacted, timestamp) VALUES (1, 'Open', 2, '2022-01-01 10:00:00');
List all security incidents that occurred in the last month, including their status and the number of assets impacted?
SELECT incident_id, status, assets_impacted, timestamp FROM SecurityIncidents WHERE timestamp BETWEEN DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 1 MONTH) AND CURRENT_TIMESTAMP;
gretelai_synthetic_text_to_sql
CREATE TABLE restaurants (id INT, name TEXT, location TEXT);CREATE TABLE dishes (id INT, name TEXT, restaurant_id INT);CREATE TABLE orders (id INT, dish_id INT, customer_name TEXT, order_date DATE);INSERT INTO restaurants (id, name, location) VALUES (1, 'Diner A', 'USA');INSERT INTO dishes (id, name, restaurant_id) VAL...
What are the top 3 favorite dishes of customers from the USA?
SELECT d.name, COUNT(o.id) AS orders_count FROM dishes d JOIN orders o ON d.id = o.dish_id JOIN restaurants r ON d.restaurant_id = r.id WHERE r.location = 'USA' GROUP BY d.name ORDER BY orders_count DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE landfills (province VARCHAR(255), num_landfills INT); INSERT INTO landfills (province, num_landfills) VALUES ('Ontario', 100);
How many landfills are there in the province of Ontario?
SELECT num_landfills FROM landfills WHERE province = 'Ontario';
gretelai_synthetic_text_to_sql
CREATE TABLE sustainable_practices (contractor_name VARCHAR(50), practice_date DATE, practice_description VARCHAR(100)); INSERT INTO sustainable_practices (contractor_name, practice_date, practice_description) VALUES ('Green Builders Inc.', '2023-02-01', 'Installed solar panels on a residential project.'), ('Green Buil...
Get the average number of sustainable building practices per month for 'Green Builders Inc.' in the 'sustainable_practices' table
SELECT AVG(DATEDIFF(MONTH, practice_date, LAG(practice_date) OVER (PARTITION BY contractor_name ORDER BY practice_date))) FROM sustainable_practices WHERE contractor_name = 'Green Builders Inc.';
gretelai_synthetic_text_to_sql
CREATE TABLE workouts (id INT, user_id INT, duration INT, heart_rate INT, workout_time TIME); INSERT INTO workouts (id, user_id, duration, heart_rate, workout_time) VALUES (1, 1, 60, 120, '07:00:00');
What is the average heart rate of users during their morning workouts?
SELECT AVG(heart_rate) FROM workouts WHERE workout_time BETWEEN '06:00:00' AND '11:59:59';
gretelai_synthetic_text_to_sql
CREATE TABLE climate_mitigation_targets (id INT, country VARCHAR(255), sector VARCHAR(255), year INT, target FLOAT);
Update the 'target' column in the 'climate_mitigation_targets' table where the 'country' is 'Germany' and 'sector' is 'Energy'
UPDATE climate_mitigation_targets SET target = target * 1.05 WHERE country = 'Germany' AND sector = 'Energy';
gretelai_synthetic_text_to_sql
CREATE TABLE production (element VARCHAR(10), country VARCHAR(20), quantity INT, year INT); INSERT INTO production (element, country, quantity, year) VALUES ('Neodymium', 'Australia', 9000, 2016), ('Neodymium', 'Australia', 10000, 2017), ('Neodymium', 'Australia', 11000, 2018), ('Neodymium', 'Australia', 12000, 2019), ...
What is the maximum quantity of 'Neodymium' produced in a year by 'Australia'?
SELECT MAX(quantity) FROM production WHERE element = 'Neodymium' AND country = 'Australia';
gretelai_synthetic_text_to_sql
CREATE TABLE CountryProduction (item_id INT, country VARCHAR(255)); INSERT INTO CountryProduction (item_id, country) VALUES (1, 'Spain'), (2, 'Italy'), (3, 'Spain'), (4, 'France'), (5, 'Spain'), (6, 'Germany'), (7, 'Spain');
How many items are produced in the top 2 countries with the most productions?
SELECT COUNT(*) FROM (SELECT country, ROW_NUMBER() OVER (ORDER BY COUNT(*) DESC) rn FROM CountryProduction GROUP BY country) t WHERE rn <= 2;
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (donation_id INT, donor_name TEXT, donation_amount DECIMAL(10,2), donation_date DATE, org_id INT);
Insert a new record into the 'Donations' table for a $500 donation to the 'Habitat for Humanity' organization by a 'John Smith' on '2022-03-15'
INSERT INTO Donations (donor_name, donation_amount, donation_date, org_id) VALUES ('John Smith', 500, '2022-03-15', (SELECT org_id FROM Organizations WHERE org_name = 'Habitat for Humanity'));
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, 1003, 'cotton', 5);
Find the total CO2 emissions for garments made of cotton.
SELECT SUM(CO2_emissions) FROM inventory WHERE material = 'cotton';
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_footprint(material VARCHAR(20), carbon_footprint DECIMAL(5,2)); INSERT INTO carbon_footprint(material, carbon_footprint) VALUES('organic cotton', 2.50), ('recycled polyester', 3.20), ('tencel', 1.80);
What is the average carbon footprint of the top 3 materials used in production?
SELECT AVG(carbon_footprint) FROM carbon_footprint WHERE material IN (SELECT material FROM carbon_footprint ORDER BY carbon_footprint LIMIT 3);
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, company_name TEXT, city TEXT, employees INT); INSERT INTO companies (id, company_name, city, employees) VALUES (1, 'Eco-Construction Ltd.', 'Vancouver', 500), (2, 'GreenTech Inc.', 'Toronto', 300);
Who is the largest construction company in 'Vancouver'?
SELECT company_name FROM companies WHERE city = 'Vancouver' ORDER BY employees DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Products (ProductID INT, Product TEXT, Price DECIMAL, Trade TEXT); INSERT INTO Products (ProductID, Product, Price, Trade) VALUES (1, 'Coffee', 15, 'Fair Trade'); CREATE TABLE Retailers (RetailerID INT, Retailer TEXT, Size TEXT); INSERT INTO Retailers (RetailerID, Retailer, Size) VALUES (1, 'Mom and Pop Gr...
List the total sales of 'Fair Trade' products from 'Small Retailers'?
SELECT Products.Product, SUM(Sales.Quantity * Products.Price) as TotalSales FROM Sales INNER JOIN Products ON Sales.ProductID = Products.ProductID INNER JOIN Retailers ON Sales.RetailerID = Retailers.RetailerID WHERE Products.Trade = 'Fair Trade' AND Retailers.Size = 'Small' GROUP BY Products.Product;
gretelai_synthetic_text_to_sql
CREATE TABLE DisasterDonations (DisasterID INT, DonationID INT, Amount DECIMAL(10,2)); INSERT INTO DisasterDonations (DisasterID, DonationID, Amount) VALUES (1, 1, 100.00), (2, 2, 150.00);
Which disaster types have no donations?
SELECT d.DisasterType FROM Disasters d LEFT JOIN DisasterDonations dd ON d.DisasterID = dd.DisasterID WHERE dd.DonationID IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas (id INT, name VARCHAR(255), ocean VARCHAR(255), size FLOAT); INSERT INTO marine_protected_areas (id, name, ocean, size) VALUES (1, 'Area A', 'Arctic', 100000); INSERT INTO marine_protected_areas (id, name, ocean, size) VALUES (2, 'Area B', 'Southern Ocean', 200000); INSERT INTO marin...
What is the total number of marine protected areas in the Arctic and Southern Oceans?
SELECT SUM(size) FROM marine_protected_areas WHERE ocean IN ('Arctic', 'Southern Ocean');
gretelai_synthetic_text_to_sql
CREATE TABLE CyberSecurity (Strategy_Name VARCHAR(255), Budget INT, Fiscal_Year INT); INSERT INTO CyberSecurity (Strategy_Name, Budget, Fiscal_Year) VALUES ('Endpoint Protection', 15000000, 2024); INSERT INTO CyberSecurity (Strategy_Name, Budget, Fiscal_Year) VALUES ('Cloud Security', 25000000, 2024);
List all cybersecurity strategies and their respective budgets from the 'CyberSecurity' table for the year 2024
SELECT * FROM CyberSecurity WHERE Fiscal_Year = 2024;
gretelai_synthetic_text_to_sql
CREATE TABLE patients_anxiety (patient_id INT, country VARCHAR(50), condition VARCHAR(50), medication BOOLEAN); INSERT INTO patients_anxiety (patient_id, country, condition, medication) VALUES (1, 'South Korea', 'Anxiety Disorder', TRUE), (2, 'South Korea', 'Depression', FALSE), (3, 'South Korea', 'Anxiety Disorder', T...
How many patients with anxiety disorders in South Korea have been treated with medication?
SELECT COUNT(*) FROM patients_anxiety WHERE country = 'South Korea' AND condition = 'Anxiety Disorder' AND medication = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE influencer_posts (post_id INT, post_date DATE, influencer_name VARCHAR(50), genre VARCHAR(50), likes INT); INSERT INTO influencer_posts VALUES (505, '2022-01-01', 'Influencer U', 'Music', 100), (506, '2022-01-03', 'Influencer V', 'Music', 150), (507, '2022-01-05', 'Influencer W', 'Music', 50), (508, '2022-...
What is the average number of likes per post for influencers in the music genre?
SELECT genre, AVG(likes) as avg_likes_per_post FROM (SELECT genre, influencer_name, AVG(likes) as likes FROM influencer_posts GROUP BY genre, influencer_name) AS subquery WHERE genre = 'Music';
gretelai_synthetic_text_to_sql
CREATE TABLE tours (id INT, city VARCHAR(20), eco_friendly BOOLEAN); INSERT INTO tours (id, city, eco_friendly) VALUES (1, 'Paris', true), (2, 'Paris', false), (3, 'Berlin', true);
Show the total number of eco-friendly tours in Paris.
SELECT COUNT(*) FROM tours WHERE city = 'Paris' AND eco_friendly = true;
gretelai_synthetic_text_to_sql
CREATE TABLE impact_investments (investment_id INT, investment_name TEXT, sector TEXT, esg_score INT); INSERT INTO impact_investments (investment_id, investment_name, sector, esg_score) VALUES (1, 'Investment X', 'Healthcare', 85), (2, 'Investment Y', 'Healthcare', 90), (3, 'Investment Z', 'Education', 80);
What is the maximum ESG score for all impact investments in the healthcare sector?
SELECT MAX(esg_score) FROM impact_investments WHERE sector = 'Healthcare';
gretelai_synthetic_text_to_sql
CREATE TABLE Policyholders (PolicyholderID INT, Region VARCHAR(20)); CREATE TABLE Claims (ClaimID INT, PolicyholderID INT, Amount DECIMAL(10, 2)); INSERT INTO Policyholders (PolicyholderID, Region) VALUES (1, 'Southwest'), (2, 'Northeast'); INSERT INTO Claims (ClaimID, PolicyholderID, Amount) VALUES (1, 1, 500), (2, 1,...
What is the average claim amount for policyholders in the Southwest region?
SELECT AVG(Claims.Amount) FROM Claims INNER JOIN Policyholders ON Claims.PolicyholderID = Policyholders.PolicyholderID WHERE Policyholders.Region = 'Southwest';
gretelai_synthetic_text_to_sql
CREATE TABLE circular_economy_initiatives (city varchar(255), initiative varchar(255)); INSERT INTO circular_economy_initiatives (city, initiative) VALUES ('Los Angeles', 'Waste-to-Energy Program'); INSERT INTO circular_economy_initiatives (city, initiative) VALUES ('Los Angeles', 'Recycling Expansion Project');
What are the circular economy initiatives in the city of Los Angeles?
SELECT initiative FROM circular_economy_initiatives WHERE city = 'Los Angeles'
gretelai_synthetic_text_to_sql
CREATE TABLE financial_institutions (institution_id INT, institution_name TEXT, region TEXT);CREATE TABLE loans (loan_id INT, institution_id INT, loan_amount INT, issue_date DATE); INSERT INTO financial_institutions (institution_id, institution_name, region) VALUES (1, 'Institution A', 'Asia'), (2, 'Institution B', 'As...
What is the total amount of socially responsible loans issued by financial institutions in the Asia region for the year 2020?
SELECT SUM(loan_amount) FROM loans JOIN financial_institutions ON loans.institution_id = financial_institutions.institution_id WHERE region = 'Asia' AND EXTRACT(YEAR FROM issue_date) = 2020 AND loans.loan_amount IN (SELECT loan_amount FROM loans WHERE loan_amount >= 0);
gretelai_synthetic_text_to_sql
CREATE TABLE job_applications (application_id INT, name VARCHAR(50), department VARCHAR(50), application_date DATE);
List the total number of job applications in the 'Research' department for each month in the year 2022, including the months without any applications.
SELECT EXTRACT(MONTH FROM application_date) AS month, COUNT(*) AS total_applications FROM job_applications WHERE department = 'Research' AND EXTRACT(YEAR FROM application_date) = 2022 GROUP BY month ORDER BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE ProgramDonations (DonationID int, ProgramID int, DonationAmount decimal(10,2)); INSERT INTO ProgramDonations VALUES (1, 1, 250), (2, 2, 500), (3, 3, 150), (4, 4, 400), (5, 5, 750), (6, 1, 300), (7, 2, 550), (8, 3, 175), (9, 4, 425), (10, 5, 800);
What was the average donation amount for each program in 2023?
SELECT ProgramName, AVG(DonationAmount) as AvgDonation FROM ProgramDonations GROUP BY ProgramName;
gretelai_synthetic_text_to_sql
CREATE TABLE inventory (id INT, product_name TEXT, category TEXT, weight FLOAT); INSERT INTO inventory (id, product_name, category, weight) VALUES (1, 'Wild Alaskan Salmon', 'Seafood', 15.2), (2, 'Farm-Raised Shrimp', 'Seafood', 2.1), (3, 'Pacific Cod', 'Seafood', 12.5), (4, 'Squid', 'Seafood', 7.3);
List all seafood products with a weight greater than 10.
SELECT * FROM inventory WHERE category = 'Seafood' AND weight > 10;
gretelai_synthetic_text_to_sql
CREATE TABLE Textiles (id INT, country VARCHAR(20), quantity INT); CREATE VIEW TextilesByCountry AS SELECT country, SUM(quantity) as total_quantity FROM Textiles GROUP BY country;
What is the total quantity of textiles sourced from each country?
SELECT country, total_quantity FROM TextilesByCountry;
gretelai_synthetic_text_to_sql
CREATE TABLE teacher_professional_development (teacher_name VARCHAR(20), course_name VARCHAR(30), completion_date DATE); INSERT INTO teacher_professional_development (teacher_name, course_name, completion_date) VALUES ('Teacher B', 'Course 4', '2019-02-03'), ('Teacher B', 'Course 5', '2019-11-17'), ('Teacher B', 'Cours...
How many professional development courses did 'Teacher B' complete in '2019' and '2020'?
SELECT teacher_name, COUNT(course_name) as total_courses FROM teacher_professional_development WHERE teacher_name = 'Teacher B' AND EXTRACT(YEAR FROM completion_date) IN (2019, 2020) GROUP BY teacher_name;
gretelai_synthetic_text_to_sql
CREATE TABLE life_habitat (region VARCHAR(50), habitat VARCHAR(50), biomass FLOAT); INSERT INTO life_habitat VALUES ('Region A', 'Habitat 1', 123.4), ('Region A', 'Habitat 2', 234.5), ('Region B', 'Habitat 1', 345.6);
What is the total biomass for marine life in each type of habitat, partitioned by region?
SELECT region, habitat, SUM(biomass) OVER (PARTITION BY region, habitat) as total_biomass FROM life_habitat;
gretelai_synthetic_text_to_sql
CREATE TABLE travel_advisories (country VARCHAR(50), year INT, advisories INT);CREATE TABLE canada_travel_advisories (country VARCHAR(50), year INT, advisory_level INT);
What is the total number of travel advisories issued by the US and Canada for all countries in 2020?
SELECT SUM(advisories) FROM (SELECT country, SUM(advisories) AS advisories FROM travel_advisories WHERE year = 2020 GROUP BY country UNION ALL SELECT country, SUM(advisory_level) AS advisories FROM canada_travel_advisories WHERE year = 2020 GROUP BY country) AS total;
gretelai_synthetic_text_to_sql
CREATE TABLE donors (donor_id INT, donor_name TEXT, donor_region TEXT, donation_date DATE); INSERT INTO donors (donor_id, donor_name, donor_region, donation_date) VALUES (1, 'Jane Doe', 'North', '2019-01-01'), (2, 'Rajesh Smith', 'North', '2020-01-01'), (3, 'Sophia Johnson', 'North', '2019-05-05');
How many unique donors have donated in the North since 2019?
SELECT COUNT(DISTINCT donor_name) as unique_donors FROM donors WHERE donation_date >= '2019-01-01' AND donor_region = 'North';
gretelai_synthetic_text_to_sql
CREATE TABLE status_offenses (id INT, case_number INT, offense VARCHAR(20)); INSERT INTO status_offenses (id, case_number, offense) VALUES (1, 33333, 'Truancy'); INSERT INTO status_offenses (id, case_number, offense) VALUES (2, 44444, 'Curfew Violation');
List all juvenile court cases that involved a status offense?
SELECT * FROM status_offenses WHERE offense IN ('Truancy', 'Curfew Violation');
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_pricing (country VARCHAR(50), scheme VARCHAR(50), price FLOAT); INSERT INTO carbon_pricing (country, scheme, price) VALUES ('Canada', 'Carbon Tax', 30.0), ('Canada', 'Cap-and-Trade', 20.5), ('United States', 'Regulation', 0.0);
Compare the carbon pricing schemes in Canada and the United States
SELECT * FROM carbon_pricing WHERE country IN ('Canada', 'United States');
gretelai_synthetic_text_to_sql
CREATE TABLE cosmetics (product_name TEXT, cruelty_free BOOLEAN); INSERT INTO cosmetics (product_name, cruelty_free) VALUES ('ProductA', true), ('ProductB', false), ('ProductC', true), ('ProductD', true), ('ProductE', false), ('ProductF', true);
What percentage of cosmetic products are certified cruelty-free?
SELECT 100.0 * COUNT(*) / (SELECT COUNT(*) FROM cosmetics) AS percentage FROM cosmetics WHERE cruelty_free = true;
gretelai_synthetic_text_to_sql
CREATE TABLE wildlife_habitat (id INT, name VARCHAR(50), area FLOAT); INSERT INTO wildlife_habitat (id, name, area) VALUES (1, 'Habitat1', 150.3), (2, 'Habitat2', 250.8), (3, 'Habitat3', 175.5);
How many wildlife habitat records were inserted?
SELECT COUNT(*) FROM wildlife_habitat;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, name VARCHAR(50), registration_date DATE); INSERT INTO customers (customer_id, name, registration_date) VALUES (1, 'John Doe', '2020-01-01'); INSERT INTO customers (customer_id, name, registration_date) VALUES (2, 'Jane Smith', '2020-02-15'); CREATE TABLE transactions (transacti...
What is the average monthly transaction value per customer for the last 6 months?
SELECT c.customer_id, AVG(t.amount) as avg_monthly_transaction FROM customers c JOIN transactions t ON c.customer_id = t.customer_id WHERE t.transaction_date >= DATE_SUB(CURDATE(), INTERVAL 6 MONTH) GROUP BY c.customer_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Causes (CauseID int, CauseName varchar(50), CauseCategory varchar(50), DonationCount int, TotalDonations numeric(18,2));
What is the total number of donations and total amount donated by each cause category in the 'Causes' table?
SELECT CauseCategory, SUM(DonationCount) as TotalDonationsCount, SUM(TotalDonations) as TotalDonationsAmount FROM Causes GROUP BY CauseCategory;
gretelai_synthetic_text_to_sql
CREATE TABLE AircraftManufacturers (ID INT, Manufacturer VARCHAR(50), Quantity INT); INSERT INTO AircraftManufacturers (ID, Manufacturer, Quantity) VALUES (1, 'Boeing', 15000), (2, 'Airbus', 16000);
Find the total number of aircraft manufactured by Boeing and Airbus.
SELECT Manufacturer, SUM(Quantity) FROM AircraftManufacturers GROUP BY Manufacturer;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, name VARCHAR(255), recycled_materials BOOLEAN); INSERT INTO products (product_id, name, recycled_materials) VALUES (1, 'Recycled Notebook', TRUE), (2, 'Plastic Phone Case', FALSE); CREATE TABLE sales (sale_id INT, product_id INT, sale_price DECIMAL(10, 2), sale_date DATE); INSERT ...
Show total sales revenue for recycled products in the last month.
SELECT SUM(sale_price) FROM products JOIN sales ON products.product_id = sales.product_id WHERE recycled_materials = TRUE AND sale_date BETWEEN '2022-12-01' AND '2022-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE company_waste(waste_type VARCHAR(255), year INT, recycled_waste FLOAT, total_waste FLOAT); INSERT INTO company_waste(waste_type, year, recycled_waste, total_waste) VALUES('Organic Waste', 2021, 123.45, 234.56);
What is the percentage of organic waste recycled in the waste management company's own operations in 2021?
SELECT (recycled_waste / total_waste) * 100 FROM company_waste WHERE waste_type = 'Organic Waste' AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE policy_advocacy (initiative_id INT, initiative_name VARCHAR(30), budget DECIMAL(10,2), initiation_date DATE); INSERT INTO policy_advocacy (initiative_id, initiative_name, budget, initiation_date) VALUES (1, 'Accessibility Laws', 50000, '2021-01-01'), (2, 'Inclusive Education', 75000, '2020-06-15'), (3, 'Em...
What is the total budget for policy advocacy initiatives in the past 2 years?
SELECT SUM(budget) FROM policy_advocacy WHERE initiation_date >= '2020-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, donor_name VARCHAR(50), donation_amount DECIMAL(10,2), donation_date DATE); INSERT INTO donations (id, donor_name, donation_amount, donation_date) VALUES (1, 'John Doe', 50.00, '2022-01-05'), (2, 'Jane Smith', 100.00, '2022-03-15');
What was the total amount donated by individuals from the United States in Q1 2022?
SELECT SUM(donation_amount) FROM donations WHERE donor_country = 'United States' AND donation_date BETWEEN '2022-01-01' AND '2022-03-31';
gretelai_synthetic_text_to_sql
CREATE TABLE events (id INT PRIMARY KEY, event_name VARCHAR(100), event_date DATE, num_attendees INT);
How many total visitors attended events in each month of the year?
SELECT EXTRACT(MONTH FROM event_date) AS month, SUM(num_attendees) AS total_visitors FROM events GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species_research (id INT, species TEXT, location TEXT, year INT, population INT); INSERT INTO marine_species_research (id, species, location, year, population) VALUES (1, 'Whale Shark', 'Indian Ocean', 2010, 1200), (2, 'Dolphin', 'Indian Ocean', 2005, 500), (3, 'Turtle', 'Indian Ocean', 2018, 2000);
Delete marine species records from the Indian Ocean with a population less than 1000.
DELETE FROM marine_species_research WHERE location = 'Indian Ocean' AND population < 1000;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists financial_assets (id INT, institution_name VARCHAR(100), country VARCHAR(50), is_shariah_compliant BOOLEAN, assets DECIMAL(15,2));
Find the total financial assets of Shariah-compliant institutions in Malaysia and Indonesia?
SELECT SUM(assets) FROM financial_assets WHERE country IN ('Malaysia', 'Indonesia') AND is_shariah_compliant = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE southern_ocean_species (species_name TEXT, year INTEGER, discovered BOOLEAN); INSERT INTO southern_ocean_species (species_name, year, discovered) VALUES ('Antarctic Krill', 2005, TRUE), ('Southern Ocean Squid', 2010, TRUE);
How many marine species have been discovered in the Southern Ocean since 2000?
SELECT COUNT(*) FROM southern_ocean_species WHERE year >= 2000 AND discovered = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE community_engagement (id INT, program VARCHAR(50), country VARCHAR(50)); INSERT INTO community_engagement (id, program, country) VALUES (1, 'Cultural Awareness Program', 'USA'), (2, 'Language Preservation Project', 'Canada'), (3, 'Artistic Heritage Revitalization', 'Mexico'), (4, 'Traditional Craftsmanship...
Delete all records in the community_engagement table related to the 'Cultural Awareness Program'?
DELETE FROM community_engagement WHERE program = 'Cultural Awareness Program';
gretelai_synthetic_text_to_sql
CREATE TABLE species (id INT, name VARCHAR(50), habitat_ocean VARCHAR(50)); CREATE TABLE conservation_status (id INT, species_id INT, status VARCHAR(50), score FLOAT);
Identify marine species with a conservation status score below 50 that inhabit the Pacific Ocean.
SELECT species.name FROM species INNER JOIN conservation_status ON species.id = conservation_status.species_id WHERE habitat_ocean = 'Pacific Ocean' AND score < 50;
gretelai_synthetic_text_to_sql
CREATE TABLE DefenseProjects (ProjectID INT, ProjectName VARCHAR(255), StartDate DATE, EndDate DATE); INSERT INTO DefenseProjects (ProjectID, ProjectName, StartDate, EndDate) VALUES (1, 'Project A', '2022-01-01', '2022-12-31'), (2, 'Project B', '2021-12-01', '2023-06-30'), (3, 'Project C', '2021-06-01', '2022-11-30');
List all defense projects with a start date after 2021-01-01 and end date before 2023-12-31
SELECT * FROM DefenseProjects WHERE StartDate > '2021-01-01' AND EndDate < '2023-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE Departments (department_id INT, department_name VARCHAR(50), manufacturer_id INT); INSERT INTO Departments (department_id, department_name, manufacturer_id) VALUES (1, 'Department1', 4), (2, 'Department2', 4), (3, 'Department3', 5); CREATE TABLE Employees (employee_id INT, employee_name VARCHAR(50), depart...
Identify the departments with zero employees
SELECT d.department_name FROM Departments d LEFT JOIN Employees e ON d.department_id = e.department_id WHERE e.employee_id IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE Policy (PolicyID INT, PolicyType VARCHAR(20), Region VARCHAR(20)); INSERT INTO Policy (PolicyID, PolicyType, Region) VALUES (1, 'Auto', 'Northeast'), (2, 'Home', 'Northeast'), (3, 'Life', 'Midwest');
What is the distribution of policy types by region?
SELECT PolicyType, Region, COUNT(*) OVER (PARTITION BY PolicyType, Region) AS CountByTypeRegion, ROW_NUMBER() OVER (PARTITION BY PolicyType ORDER BY Region) AS RankByPolicyType FROM Policy;
gretelai_synthetic_text_to_sql
CREATE TABLE donations (donation_id INT, donation_amount DECIMAL, donation_date DATE, project_category VARCHAR(255)); INSERT INTO donations (donation_id, donation_amount, donation_date, project_category) VALUES (1, 500, '2021-06-15', 'Arts & Culture'), (2, 300, '2021-03-01', 'Arts & Culture'), (3, 700, '2021-12-28', 'E...
What percentage of total donations was allocated to each project category in 2021?
SELECT project_category, (SUM(donation_amount) / (SELECT SUM(donation_amount) FROM donations WHERE donation_date BETWEEN '2021-01-01' AND '2021-12-31')) * 100 as percentage_of_total FROM donations WHERE donation_date BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY project_category;
gretelai_synthetic_text_to_sql
CREATE TABLE ReportedCrimes (ID INT, State VARCHAR(20), Year INT, Crimes INT); INSERT INTO ReportedCrimes (ID, State, Year, Crimes) VALUES (1, 'New York', 2018, 1200);
What is the total number of reported crimes in the state of New York in 2018?
SELECT SUM(Crimes) FROM ReportedCrimes WHERE State = 'New York' AND Year = 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE ExcavationSites (SiteID INT, SiteName TEXT, Country TEXT, StartDate DATE, EndDate DATE);
Find all excavation sites in 'Country X' and 'Country Y'
SELECT SiteName FROM ExcavationSites WHERE Country IN ('Country X', 'Country Y');
gretelai_synthetic_text_to_sql
CREATE TABLE Supplier_Components (component_id INT, component_name VARCHAR(50), supplier VARCHAR(50), component_cost DECIMAL(10, 2), year INT); INSERT INTO Supplier_Components (component_id, component_name, supplier, component_cost, year) VALUES (1, 'Solar Panel', 'SpaceX', 10000, 2019), (2, 'Communications System', 'B...
What are the total costs of satellite components supplied by each supplier in 2019?
SELECT supplier, SUM(component_cost) as total_component_cost FROM Supplier_Components WHERE year = 2019 GROUP BY supplier;
gretelai_synthetic_text_to_sql
CREATE TABLE ResearchPapers (Id INT, Title VARCHAR(50), PublicationDate DATE, Country VARCHAR(20)); INSERT INTO ResearchPapers (Id, Title, PublicationDate, Country) VALUES (1, 'Autonomous Driving Revolution', '2022-01-01', 'USA'), (2, 'AI and Self-Driving Cars', '2021-12-15', 'Germany'), (3, 'The Future of Autonomous V...
How many autonomous driving research papers have been published in Europe?
SELECT COUNT(*) FROM ResearchPapers WHERE Country = 'Germany';
gretelai_synthetic_text_to_sql
CREATE TABLE imports (id INT, country VARCHAR(50), Lanthanum_imported FLOAT, importer_id INT, datetime DATETIME); INSERT INTO imports (id, country, Lanthanum_imported, importer_id, datetime) VALUES (1, 'Australia', 120.0, 500, '2016-01-01 10:00:00'), (2, 'New Zealand', 90.0, 350, '2016-02-15 14:30:00');
Find the total quantity of Lanthanum imported to Oceania before 2017 and the number of unique importers.
SELECT country, SUM(Lanthanum_imported) AS total_Lanthanum, COUNT(DISTINCT importer_id) AS unique_importers FROM imports WHERE YEAR(datetime) < 2017 AND Lanthanum_imported IS NOT NULL AND country LIKE 'Oceania%' GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE company (name VARCHAR(50), type VARCHAR(50)); INSERT INTO company (name, type) VALUES ('Global Defence Inc.', 'Defense Contractor'), ('Techno Solutions', 'Defense Contractor'), ('Alpha Corp.', 'Defense Contractor'), ('Beta Industries', 'Defense Contractor'); CREATE TABLE contract_negotiations (contract_id ...
Show the total number of contract negotiations for 'Global Defence Inc.'
SELECT COUNT(*) FROM contract_negotiations WHERE company_name = 'Global Defence Inc.';
gretelai_synthetic_text_to_sql
CREATE TABLE train_routes (route_id INT, route_distance INT, city VARCHAR(255)); CREATE TABLE train_trips (trip_id INT, route_id INT, trip_date DATE);
What is the total distance traveled by trains in the Paris metropolitan area in the last year?
SELECT SUM(route_distance) FROM train_routes JOIN train_trips ON train_routes.route_id = train_trips.route_id WHERE train_routes.city = 'Paris' AND train_trips.trip_date >= DATEADD(YEAR, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (asset TEXT, tx_date DATE); INSERT INTO transactions (asset, tx_date) VALUES ('Securitize', '2021-01-01'), ('Securitize', '2021-01-02'), ('Polymath', '2021-01-01'), ('Polymath', '2021-01-02'), ('Polymath', '2021-01-03');
List the digital assets that have had the most transactions on a single day.
SELECT asset, MAX(tx_count) FROM (SELECT asset, COUNT(*) AS tx_count FROM transactions GROUP BY asset, tx_date) AS subquery GROUP BY asset;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_finance (project_id INT, project_name TEXT, location TEXT, funded_year INT, funding_amount FLOAT); INSERT INTO climate_finance (project_id, project_name, location, funded_year, funding_amount) VALUES (1, 'Adaptation 1', 'France', 2010, 6000000.0), (2, 'Mitigation 1', 'Germany', 2013, 8000000.0), (3...
What is the total amount of climate finance committed to climate adaptation projects in Europe between 2010 and 2015?
SELECT SUM(funding_amount) FROM climate_finance WHERE funded_year BETWEEN 2010 AND 2015 AND project_type = 'climate adaptation' AND location LIKE 'Europe%';
gretelai_synthetic_text_to_sql
CREATE TABLE SiteArtifacts (SiteID varchar(5), ArtifactPeriod varchar(15)); INSERT INTO SiteArtifacts (SiteID, ArtifactPeriod) VALUES ('S001', 'Stone Age'), ('S002', 'Bronze Age');
Which sites have 'Stone Age' artifacts?
SELECT SiteID FROM SiteArtifacts WHERE ArtifactPeriod = 'Stone Age';
gretelai_synthetic_text_to_sql
CREATE TABLE ConstructionUnion (member_id INT, member_name TEXT, salary FLOAT, state TEXT); INSERT INTO ConstructionUnion (member_id, member_name, salary, state) VALUES (1, 'John Doe', 45000, 'Texas'); INSERT INTO ConstructionUnion (member_id, member_name, salary, state) VALUES (2, 'Jane Smith', 50000, 'Texas');
What is the minimum salary of members in the 'Construction Union' who work in Texas?
SELECT MIN(salary) FROM ConstructionUnion WHERE state = 'Texas';
gretelai_synthetic_text_to_sql
CREATE TABLE PlayerTeam (PlayerID INT, TeamID INT); INSERT INTO PlayerTeam (PlayerID, TeamID) VALUES (101, 1), (102, 1), (103, 2), (104, 3); CREATE TABLE PlayerScore (PlayerID INT, GameID INT, TeamID INT, Score INT); INSERT INTO PlayerScore (PlayerID, GameID, TeamID, Score) VALUES (101, 1001, 1, 70), (102, 1001, 1, 80)...
What are the total scores for the 'Apex Predators' team?
SELECT SUM(Score) FROM PlayerScore WHERE TeamID = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE SatelliteDeployments (satellite_id INT, launch_date DATE, delivery_time INT);
What is the average delivery time for satellites?
SELECT AVG(delivery_time) FROM SatelliteDeployments;
gretelai_synthetic_text_to_sql
CREATE TABLE crops (id SERIAL PRIMARY KEY, name TEXT, yield INT, region TEXT);
Add a new entry to the "crops" table with the name "sorghum", a yield of 80, and region "Africa"
INSERT INTO crops (name, yield, region) VALUES ('sorghum', 80, 'Africa');
gretelai_synthetic_text_to_sql
CREATE TABLE Artworks (ArtworkID INT, ArtworkName TEXT, Movement TEXT, Year INT); INSERT INTO Artworks (ArtworkID, ArtworkName, Movement, Year) VALUES (1, 'Moonlight', 'Impressionism', 1920); INSERT INTO Artworks (ArtworkID, ArtworkName, Movement, Year) VALUES (2, 'Silent Song', 'Cubism', 1930);
Which art movements had the most artworks created in Asia during the 20th century?
SELECT Movement, COUNT(*) as NumArtworks FROM Artworks WHERE Year BETWEEN 1900 AND 1999 AND Region = 'Asia' GROUP BY Movement ORDER BY NumArtworks DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE alternative_sentencing_ca (id INT, program_name VARCHAR(50), start_date DATE, end_date DATE, state VARCHAR(50)); INSERT INTO alternative_sentencing_ca (id, program_name, start_date, end_date, state) VALUES (1, 'Rehabilitation Works', '2017-01-01', '2020-12-31', 'California'), (2, 'Justice Alternatives', '2...
What is the total number of alternative sentencing programs implemented in California between 2017 and 2020?
SELECT SUM(id) FROM alternative_sentencing_ca WHERE state = 'California' AND start_date >= '2017-01-01' AND end_date <= '2020-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE fares (ride_type TEXT, fare DECIMAL(5,2));
Insert a new fare for 'Ferry' rides
INSERT INTO fares (ride_type, fare) VALUES ('Ferry', 3.00);
gretelai_synthetic_text_to_sql