context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE incidents (incident_id INT, incident_type VARCHAR(50), date_time DATETIME);
List the number of incidents per month for the last 6 months
SELECT MONTH(date_time) AS month, COUNT(*) AS incidents_count FROM incidents WHERE date_time >= DATE_SUB(NOW(), INTERVAL 6 MONTH) GROUP BY month ORDER BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, TotalDonation FLOAT); INSERT INTO Donors (DonorID, TotalDonation) VALUES (1, 500.00), (2, 350.00), (3, 600.00);
What's the average donation amount per donor?
SELECT DonorID, AVG(TotalDonation) FROM Donors GROUP BY DonorID;
gretelai_synthetic_text_to_sql
CREATE TABLE FreightForwarder (FFID INT, FFName TEXT, Country TEXT); INSERT INTO FreightForwarder (FFID, FFName, Country) VALUES (1, 'Global Freight', 'USA'), (2, 'Northern Shipping', 'Canada'), (3, 'Pacific Logistics', 'Australia'); CREATE TABLE FulfillmentCenter (FCID INT, FCName TEXT, Country TEXT); INSERT INTO Fulf...
What are the names of unique freight forwarders operating in countries with more than 2 fulfillment centers?
SELECT DISTINCT FFName, Country FROM FreightForwarder WHERE Country IN (SELECT Country FROM FulfillmentCenter GROUP BY Country HAVING COUNT(DISTINCT FCID) > 2);
gretelai_synthetic_text_to_sql
CREATE TABLE Roads (name TEXT, number TEXT, state TEXT);
Which roads intersect with the "I-95" in Florida?
SELECT DISTINCT name FROM Roads WHERE state = 'Florida' AND number IN (SELECT number FROM Roads WHERE state = 'Florida' AND name IN (SELECT name FROM Roads WHERE number = 'I-95'));
gretelai_synthetic_text_to_sql
CREATE TABLE Infrastructure (id INT, name VARCHAR(100), type VARCHAR(50), state VARCHAR(50)); INSERT INTO Infrastructure (id, name, type, state) VALUES (3, 'Dallas/Fort Worth International Airport', 'Airport', 'Texas'), (4, 'Will Rogers World Airport', 'Airport', 'Oklahoma');
Show the number of airports in Texas and Oklahoma
SELECT state, COUNT(*) FROM Infrastructure WHERE type = 'Airport' AND state IN ('Texas', 'Oklahoma') GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (ArtistID INT, Name TEXT, Nationality TEXT); INSERT INTO Artists (ArtistID, Name, Nationality) VALUES (1, 'Auguste Rodin', 'France'), (2, 'Henry Moore', 'England'), (3, 'Barbara Hepworth', 'England'); CREATE TABLE Sculptures (SculptureID INT, Title TEXT, ArtistID INT); INSERT INTO Sculptures (Sculp...
What are the names and nationalities of the artists who have more than 50 sculptures in the 'Sculptures' table?
SELECT Artists.Name, Artists.Nationality FROM Artists INNER JOIN (SELECT ArtistID, COUNT(*) as SculptureCount FROM Sculptures GROUP BY ArtistID) as SculptureCounts ON Artists.ArtistID = SculptureCounts.ArtistID WHERE SculptureCounts.SculptureCount > 50;
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers (id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255), sustainability_score INT); CREATE TABLE suppliers_revenue (supplier_id INT, year INT, revenue INT, PRIMARY KEY (supplier_id, year), FOREIGN KEY (supplier_id) REFERENCES suppliers(id));
What is the total revenue for each supplier in 2022?
SELECT suppliers.name, suppliers_revenue.revenue FROM suppliers JOIN suppliers_revenue ON suppliers.id = suppliers_revenue.supplier_id WHERE suppliers_revenue.year = 2022 GROUP BY suppliers.name;
gretelai_synthetic_text_to_sql
CREATE TABLE menu_items (id INT, restaurant_id INT, name VARCHAR(255), category VARCHAR(255), price DECIMAL(5,2)); INSERT INTO menu_items (id, restaurant_id, name, category, price) VALUES (1, 1, 'Quinoa Salad', 'Salads', 15.99), (2, 1, 'Grilled Chicken Sandwich', 'Sandwiches', 12.49), (3, 2, 'Cheeseburger', 'Burgers', ...
Identify the menu item with the lowest price from the "menu_items" table.
SELECT name, MIN(price) FROM menu_items;
gretelai_synthetic_text_to_sql
CREATE TABLE programs (program_id INT, program_name VARCHAR(50), program_type VARCHAR(20)); CREATE TABLE funding (funding_id INT, program_id INT, funding_amount DECIMAL(10,2), funding_date DATE); INSERT INTO programs (program_id, program_name, program_type) VALUES (1, 'Art Education', 'Education'), (2, 'Music Education...
What is the total funding received by each program type in the last 3 years?
SELECT program_type, SUM(funding_amount) AS total_funding FROM funding f INNER JOIN programs p ON f.program_id = p.program_id WHERE f.funding_date >= DATEADD(year, -3, GETDATE()) GROUP BY program_type;
gretelai_synthetic_text_to_sql
CREATE TABLE Properties (id INT, price INT, city TEXT); INSERT INTO Properties (id, price, city) VALUES (1, 500000, 'Austin'), (2, 400000, 'Austin'), (3, 700000, 'Dallas'), (4, 800000, 'Houston');
What is the highest priced property in each city?
SELECT city, MAX(price) AS highest_price FROM Properties GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE forestry_survey (id INT, species VARCHAR(255), diameter FLOAT, height FLOAT, volume FLOAT); INSERT INTO forestry_survey (id, species, diameter, height, volume) VALUES (1, 'Redwood', 5.6, 120, 23.4); INSERT INTO forestry_survey (id, species, diameter, height, volume) VALUES (2, 'Oak', 2.4, 60, 4.2); INSERT ...
Which tree species have more than 20 cubic meters of volume?
SELECT species FROM forestry_survey WHERE volume > 20;
gretelai_synthetic_text_to_sql
CREATE TABLE Digital_Divide_Income (income VARCHAR(255), budget INT); INSERT INTO Digital_Divide_Income (income, budget) VALUES ('Low', 500000), ('Medium', 1500000), ('High', 2000000);
What is the total budget allocated for digital divide initiatives by income level?
SELECT income, SUM(budget) as total_budget FROM Digital_Divide_Income GROUP BY income;
gretelai_synthetic_text_to_sql
CREATE TABLE user_registrations (registration_date DATE); INSERT INTO user_registrations (registration_date) VALUES ('2021-01-01'), ('2021-01-15'), ('2021-02-10'), ('2021-03-01'), ('2021-04-05'), ('2021-05-12'), ('2021-06-08'), ('2021-07-02'), ('2021-08-04'), ('2021-09-07'), ('2021-10-01'), ('2021-11-05'), ('2021-12-10...
How many users registered in each month of 2021?
SELECT EXTRACT(MONTH FROM registration_date) AS month, COUNT(*) FROM user_registrations WHERE registration_date BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE CitizenFeedback (Year INT, Topic VARCHAR(20), Feedback VARCHAR(10)); INSERT INTO CitizenFeedback (Year, Topic, Feedback) VALUES (2022, 'Housing and Urban Development', 'Positive'), (2022, 'Housing and Urban Development', 'Negative'), (2022, 'Housing and Urban Development', 'Neutral'), (2022, 'Environment',...
What is the percentage of citizen feedback related to housing and urban development in 2022?
SELECT (COUNT(CASE WHEN Topic = 'Housing and Urban Development' AND Feedback IN ('Positive', 'Negative', 'Neutral') THEN 1 END) * 100.0 / COUNT(*)) as Pct_Housing_Feedback FROM CitizenFeedback WHERE Year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE VehicleSafetyTests (TestID INT PRIMARY KEY, VehicleID INT, TestDate DATE, TestResults VARCHAR(50)); CREATE TABLE Vehicles (VehicleID INT PRIMARY KEY, VehicleType VARCHAR(50), Manufacturer VARCHAR(50));
What are the vehicle types and test results for safety tests conducted in the first quarter of 2022?
SELECT Vehicles.VehicleType, VehicleSafetyTests.TestResults FROM Vehicles INNER JOIN VehicleSafetyTests ON Vehicles.VehicleID = VehicleSafetyTests.VehicleID WHERE VehicleSafetyTests.TestDate BETWEEN '2022-01-01' AND '2022-03-31';
gretelai_synthetic_text_to_sql
CREATE TABLE employees (id INT, first_name VARCHAR(50), last_name VARCHAR(50), hire_date DATE, country VARCHAR(50)); CREATE TABLE diversity_training (id INT, employee_id INT, training_name VARCHAR(50), completed_date DATE);
Insert a new employee record for 'Sophia' 'Garcia', who was hired on '2022-04-01', lives in 'Mexico', and has not completed any diversity and inclusion training.
INSERT INTO employees (id, first_name, last_name, hire_date, country) VALUES (4, 'Sophia', 'Garcia', '2022-04-01', 'Mexico');
gretelai_synthetic_text_to_sql
CREATE TABLE giraffes (id INT, name VARCHAR(20), species VARCHAR(20), weight INT, gender VARCHAR(10)); INSERT INTO giraffes (id, name, species, weight, gender) VALUES (1, 'Gustav', 'Giraffe', 1500, 'Male'); INSERT INTO giraffes (id, name, species, weight, gender) VALUES (2, 'Giselle', 'Giraffe', 1200, 'Female');
What is the average weight of male giraffes in the "giraffes" table?
SELECT AVG(weight) FROM giraffes WHERE gender = 'Male' AND species = 'Giraffe';
gretelai_synthetic_text_to_sql
CREATE SCHEMA IF NOT EXISTS Intelligence; CREATE TABLE IF NOT EXISTS Intelligence.Intel_Ops (operation_id INT, operation_name VARCHAR(255), location VARCHAR(255), start_date DATE, end_date DATE); INSERT INTO Intelligence.Intel_Ops (operation_id, operation_name, location, start_date, end_date) VALUES (1, 'Operation Blue...
What are the details of intelligence operations in the 'Intelligence' schema?
SELECT * FROM Intelligence.Intel_Ops;
gretelai_synthetic_text_to_sql
CREATE VIEW urban_hotels AS SELECT * FROM hotels WHERE region IN ('New York', 'Los Angeles', 'Chicago', 'San Francisco'); CREATE TABLE bookings (id INT, hotel_id INT, bookings INT);
What is the total number of bookings for each hotel in the urban_hotels view?
SELECT h.hotel_name, SUM(b.bookings) FROM urban_hotels h JOIN bookings b ON h.id = b.hotel_id GROUP BY h.hotel_name;
gretelai_synthetic_text_to_sql
CREATE TABLE fairness_issues (issue_id INT, ai_model TEXT, domain TEXT, issue_date DATE, description TEXT); INSERT INTO fairness_issues (issue_id, ai_model, domain, issue_date, description) VALUES (1, 'Medical Diagnosis Model', 'Healthcare', '2021-03-15', 'Racial bias in model predictions'), (2, 'Mental Health Chatbot'...
List all algorithmic fairness issues for AI models in the healthcare domain from the past year.
SELECT * FROM fairness_issues WHERE domain = 'Healthcare' AND issue_date >= DATEADD(year, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE diagnoses (patient_id INT, diagnosis_name VARCHAR(50), diagnosis_date DATE); INSERT INTO diagnoses (patient_id, diagnosis_name, diagnosis_date) VALUES (6, 'PTSD', '2022-10-01'); INSERT INTO diagnoses (patient_id, diagnosis_name, diagnosis_date) VALUES (7, 'Schizophrenia', '2022-11-15'); INSERT INTO diagnos...
How many patients were treated for PTSD and schizophrenia in Q4 2022?
SELECT COUNT(*) FROM diagnoses WHERE (diagnosis_name = 'PTSD' OR diagnosis_name = 'Schizophrenia') AND QUARTER(diagnosis_date) = 4 AND YEAR(diagnosis_date) = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE Farmers (id INT, name TEXT, crop TEXT, harvest_date DATE);INSERT INTO Farmers (id, name, crop, harvest_date) VALUES (1, 'John', 'Corn', '2020-07-01'), (1, 'John', 'Potatoes', '2020-10-01'), (2, 'Jane', 'Carrots', '2020-09-15'), (2, 'Jane', 'Beans', '2020-11-30');
How many crops were harvested per farmer in 2020?
SELECT name, COUNT(crop) Harvested_Crops FROM Farmers WHERE YEAR(harvest_date) = 2020 GROUP BY name;
gretelai_synthetic_text_to_sql
CREATE TABLE waste (factory VARCHAR(50), date DATE, waste_amount INT); INSERT INTO waste (factory, date, waste_amount) VALUES ('factory1', '2021-01-01', 500), ('factory1', '2021-01-02', 600);
What is the average waste production for 'factory1'?
SELECT AVG(waste_amount) FROM waste WHERE factory = 'factory1';
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_energy (id INT, name VARCHAR(100), location VARCHAR(50), capacity FLOAT, region VARCHAR(10)); INSERT INTO renewable_energy (id, name, location, capacity, region) VALUES (1, 'Solar Farm A', 'Los Angeles', 100.5, 'North America'); INSERT INTO renewable_energy (id, name, location, capacity, region) ...
List renewable energy projects in 'North America' and their capacities
SELECT name, capacity FROM renewable_energy WHERE region = 'North America';
gretelai_synthetic_text_to_sql
CREATE TABLE skincare_products (product_id INT, product_name VARCHAR(255), is_vegan BOOLEAN, country VARCHAR(255)); INSERT INTO skincare_products (product_id, product_name, is_vegan, country) VALUES (1, 'Hydrating Serum', true, 'Australia'), (2, 'Facial Cleanser', false, 'Australia'), (3, 'Nourishing Cream', false, 'Au...
What is the percentage of vegan skincare products in the Australian market?
SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM skincare_products WHERE country = 'Australia')) AS percentage FROM skincare_products WHERE is_vegan = true;
gretelai_synthetic_text_to_sql
CREATE SCHEMA socialmedia;CREATE TABLE user_settings (id INT, user_id INT, setting VARCHAR(255), timestamp TIMESTAMP);INSERT INTO user_settings (id, user_id, setting, timestamp) VALUES (1, 1, 'privacy', '2022-03-01 12:00:00'), (2, 2, 'privacy', '2022-01-15 15:00:00');
How many users in Australia and New Zealand had their data privacy settings changed in Q1 2022?
SELECT SUM(CASE WHEN region = 'Australia' THEN 1 ELSE 0 END + CASE WHEN region = 'New Zealand' THEN 1 ELSE 0 END) FROM (SELECT user_id, EXTRACT(MONTH FROM timestamp) AS month, CASE WHEN country = 'Australia' THEN 'Australia' WHEN country = 'New Zealand' THEN 'New Zealand' END AS region FROM socialmedia.users INNER JOIN...
gretelai_synthetic_text_to_sql
CREATE TABLE clinical_trials (country VARCHAR(20), phase INT, trials INT); INSERT INTO clinical_trials (country, phase, trials) VALUES ('USA', 1, 20), ('USA', 2, 30), ('USA', 3, 40), ('Canada', 1, 15), ('Canada', 2, 25), ('Canada', 3, 35);
How many clinical trials were conducted in each country in 2022, unpivoted by phase?
SELECT country, phase, SUM(trials) AS total_trials FROM clinical_trials GROUP BY country, phase ORDER BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE factories (id INT, name VARCHAR(255), location VARCHAR(255), type VARCHAR(255), PRIMARY KEY(id)); INSERT INTO factories (id, name, location, type) VALUES (3, 'Fair Trade Factories', 'Global', 'Factory'); CREATE TABLE workers (id INT, name VARCHAR(255), position VARCHAR(255), factory_id INT, PRIMARY KEY(id)...
How many workers are employed by fair trade factories?
SELECT COUNT(*) FROM workers WHERE factory_id = (SELECT id FROM factories WHERE name = 'Fair Trade Factories' AND type = 'Factory');
gretelai_synthetic_text_to_sql
CREATE TABLE Exhibitions (id INT, city VARCHAR(20), visitors INT); CREATE TABLE Visitors (id INT, exhibition_id INT, age INT); INSERT INTO Exhibitions (id, city, visitors) VALUES (1, 'Paris', 3000), (2, 'London', 4000), (3, 'New York', 5000); INSERT INTO Visitors (id, exhibition_id, age) VALUES (1, 1, 32), (2, 1, 45), ...
Identify the average age of visitors for each city.
SELECT e.city, AVG(v.age) AS avg_age FROM Exhibitions e JOIN Visitors v ON e.id = v.exhibition_id GROUP BY e.city;
gretelai_synthetic_text_to_sql
CREATE TABLE employees (id INT, name VARCHAR(50), department VARCHAR(50)); INSERT INTO employees (id, name, department) VALUES (1, 'John Doe', 'manufacturing'), (2, 'Jane Smith', 'marketing'), (3, 'Bob Johnson', 'manufacturing'), (4, 'Alice Davis', 'marketing');
What is the number of employees in the 'manufacturing' and 'marketing' departments?
SELECT department, COUNT(*) FROM employees WHERE department IN ('manufacturing', 'marketing') GROUP BY department;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (id INT, name VARCHAR(50), size VARCHAR(20), sustainable_range BOOLEAN); INSERT INTO customers (id, name, size, sustainable_range) VALUES (1, 'Alice', 'M', true); INSERT INTO customers (id, name, size, sustainable_range) VALUES (2, 'Bob', 'XL', true); INSERT INTO customers (id, name, size, sustai...
get the number of unique customers in the 'Eco-friendly' size range
SELECT COUNT(DISTINCT id) FROM customers WHERE sustainable_range = true AND size IN ('XS', 'S', 'M', 'L', 'XL');
gretelai_synthetic_text_to_sql
CREATE TABLE brands (brand_id INT, brand_name TEXT, cruelty_free BOOLEAN, vegan BOOLEAN, country TEXT);
Insert a new vegan brand in the database
INSERT INTO brands (brand_id, brand_name, cruelty_free, vegan, country) VALUES (4, 'Pacifica', TRUE, TRUE, 'USA');
gretelai_synthetic_text_to_sql
CREATE TABLE Artifacts (ArtifactID INT, ArtifactType VARCHAR(50), ArtifactWeight FLOAT); INSERT INTO Artifacts (ArtifactID, ArtifactType, ArtifactWeight) VALUES (1, 'Pottery', 2.3), (2, 'Stone Tool', 1.8), (3, 'Bone Tool', 3.1), (4, 'Ceramic Figurine', 4.7), (5, 'Metal Artifact', 5.9);
What is the average artifact weight for each artifact type, along with the number of artifacts and total weight?
SELECT ArtifactType, AVG(ArtifactWeight) AS AvgWeight, COUNT(*) AS ArtifactCount, SUM(ArtifactWeight) AS TotalWeight FROM Artifacts GROUP BY ArtifactType;
gretelai_synthetic_text_to_sql
CREATE TABLE underwater_canyons (canyon_name TEXT, location TEXT, max_depth FLOAT); INSERT INTO underwater_canyons (canyon_name, location, max_depth) VALUES ('Canyon 1', 'Pacific Ocean', 7000.0), ('Canyon 2', 'Pacific Ocean', 8100.0);
What is the maximum depth of any underwater canyon in the Pacific ocean?
SELECT MAX(max_depth) FROM underwater_canyons WHERE location = 'Pacific Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE appearances (id INT, case_id INT, appearance_date DATE); INSERT INTO appearances (id, case_id, appearance_date) VALUES (1, 1, '2021-01-01'), (2, 1, '2021-03-01'), (3, 1, '2021-05-01');
What is the minimum number of court appearances for a single case?
SELECT MIN(count) FROM (SELECT case_id, COUNT(*) as count FROM appearances GROUP BY case_id) as subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE emergency_response (id INT, incident_id INT, responder_id INT, response_time INT); INSERT INTO emergency_response (id, incident_id, responder_id, response_time) VALUES (1, 1, 1, 300), (2, 2, 2, 450), (3, 3, 3, 600); CREATE TABLE emergency_incidents (id INT, type TEXT, date DATE); INSERT INTO emergency_inci...
What is the average response time for emergency incidents by type?
SELECT e.type, AVG(er.response_time) as avg_response_time FROM emergency_response er JOIN emergency_incidents e ON er.incident_id = e.id GROUP BY e.type;
gretelai_synthetic_text_to_sql
CREATE TABLE Customers (id INT, size VARCHAR(10), last_purchase_date DATE); INSERT INTO Customers (id, size, last_purchase_date) VALUES (1, 'XS', '2022-01-01'), (2, '2XL', '2022-02-15');
How many size 2XL customers have made a purchase in the last month?
SELECT COUNT(*) FROM Customers WHERE size = '2XL' AND last_purchase_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE warehouses (id INT, name VARCHAR(50), location VARCHAR(50)); INSERT INTO warehouses (id, name, location) VALUES (1, 'Warehouse A', 'City A'), (2, 'Warehouse B', 'City B'), (3, 'Warehouse C', 'City C'); CREATE TABLE inventory (id INT, warehouse_id INT, item_type VARCHAR(50), quantity INT); INSERT INTO inven...
What is the average quantity of items stored in each warehouse?
SELECT warehouse_id, AVG(quantity) as avg_quantity FROM inventory GROUP BY warehouse_id;
gretelai_synthetic_text_to_sql
CREATE TABLE brands (brand_id INT, brand_name VARCHAR(50)); CREATE TABLE ratings (rating_id INT, brand_id INT, product_rating DECIMAL(3,2), rating_date DATE);
Calculate the 6-month moving average of product ratings for each brand, in order of date.
SELECT r.brand_id, r.rating_date, AVG(r.product_rating) OVER (PARTITION BY r.brand_id ORDER BY r.rating_date ROWS BETWEEN 6 PRECEDING AND CURRENT ROW) as moving_avg FROM ratings r;
gretelai_synthetic_text_to_sql
CREATE TABLE City (id INT, name VARCHAR(255), population INT, region VARCHAR(255)); INSERT INTO City (id, name, population, region) VALUES (1, 'Cairo', 9000000, 'Africa'); INSERT INTO City (id, name, population, region) VALUES (2, 'Johannesburg', 5000000, 'Africa'); INSERT INTO City (id, name, population, region) VALUE...
What is the maximum budget of agencies in cities with a population less than 1 million in the African region?
SELECT MAX(Agency.budget) FROM Agency JOIN City ON Agency.city_id = City.id WHERE City.region = 'Africa' AND City.population < 1000000;
gretelai_synthetic_text_to_sql
CREATE TABLE EmployeeTraining (EmployeeID int, EmployeeName varchar(50), Department varchar(50), TrainingProgram varchar(50), TrainingDate date); INSERT INTO EmployeeTraining (EmployeeID, EmployeeName, Department, TrainingProgram, TrainingDate) VALUES (1, 'Alex Johnson', 'IT', 'Diversity and Inclusion', '2023-01-01'), ...
How many diversity and inclusion training programs were completed by employees of each department in the past year?
SELECT Department, COUNT(*) AS num_diversity_trainings FROM EmployeeTraining WHERE TrainingProgram = 'Diversity and Inclusion' AND TrainingDate >= DATEADD(year, -1, GETDATE()) GROUP BY Department;
gretelai_synthetic_text_to_sql
CREATE TABLE ethical_ai_asia (country VARCHAR(50), initiative_count INT); INSERT INTO ethical_ai_asia (country, initiative_count) VALUES ('China', 50), ('Japan', 30), ('South Korea', 25);
What is the total number of ethical AI initiatives in Asia?
SELECT SUM(initiative_count) FROM ethical_ai_asia WHERE country = 'China' OR country = 'Japan' OR country = 'South Korea';
gretelai_synthetic_text_to_sql
CREATE TABLE locations (location_id INT, location_name VARCHAR(50)); CREATE TABLE weather (weather_id INT, location_id INT, measurement_date DATE, temperature DECIMAL(5,2)); INSERT INTO locations (location_id, location_name) VALUES (1, 'Svalbard'); INSERT INTO weather (weather_id, location_id, measurement_date, tempera...
What is the average temperature per month for the past 5 years in Svalbard?
SELECT EXTRACT(MONTH FROM measurement_date) as month, AVG(temperature) as avg_temperature FROM weather WHERE location_id = 1 AND measurement_date >= '2017-01-01' AND measurement_date < '2022-01-01' GROUP BY EXTRACT(MONTH FROM measurement_date) ORDER BY EXTRACT(MONTH FROM measurement_date);
gretelai_synthetic_text_to_sql
CREATE TABLE decentralized_applications (app_name TEXT, country TEXT, daily_transaction_value INTEGER); INSERT INTO decentralized_applications (app_name, country, daily_transaction_value) VALUES ('Uniswap', 'US', 15000000), ('Compound', 'US', 12000000), ('MakerDAO', 'US', 10000000);
Which decentralized applications in the US have the highest daily transaction value?
SELECT app_name, MAX(daily_transaction_value) FROM decentralized_applications WHERE country = 'US' GROUP BY app_name;
gretelai_synthetic_text_to_sql
CREATE TABLE water_savings (id INT, state VARCHAR(255), water_savings_per_appliance FLOAT, number_of_appliances INT); INSERT INTO water_savings (id, state, water_savings_per_appliance, number_of_appliances) VALUES (1, 'California', 10, 5000000), (2, 'Texas', 8, 6000000), (3, 'New York', 12, 4000000);
How much water is saved annually by using water-efficient appliances in the state of California?
SELECT state, water_savings_per_appliance * number_of_appliances AS annual_water_savings FROM water_savings WHERE state = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE factories (factory_id INT, location VARCHAR(255), co2_emission INT); INSERT INTO factories VALUES (1, 'Asia', 1000), (2, 'Europe', 1500), (3, 'Asia', 1200);
What is the total CO2 emission of factories in 'Asia'?
SELECT SUM(co2_emission) FROM factories WHERE location = 'Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE patients (id INT, name TEXT, age INT, disease TEXT, country TEXT); INSERT INTO patients (id, name, age, disease, country) VALUES (1, 'John Doe', 35, 'Malaria', 'Kenya'), (2, 'Jane Smith', 42, 'Malaria', 'Tanzania'), (3, 'Bob Johnson', 50, 'Malaria', 'Tanzania'), (4, 'Alice Williams', 60, 'Malaria', 'Kenya'...
What is the average age of patients with Malaria in each country in Africa?
SELECT country, AVG(age) FROM patients WHERE disease = 'Malaria' GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE security_incidents (id INT, country VARCHAR(50), incident_date DATE);
What are the top 3 countries with the highest number of security incidents in the last 6 months?
SELECT country, COUNT(*) as num_incidents FROM security_incidents WHERE incident_date >= DATEADD(month, -6, GETDATE()) GROUP BY country ORDER BY num_incidents DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE mining_companies (company_id INT, company_name TEXT); INSERT INTO mining_companies (company_id, company_name) VALUES (1001, 'Mining Corp A'), (1002, 'Mining Corp B'), (1003, 'Mining Corp C'); CREATE TABLE mining_sites (site_id INT, site_name TEXT, country TEXT, energy_consumption FLOAT, company_id INT); IN...
What is the average energy consumption per mining site and the total energy consumption per mining company?
SELECT company_name, AVG(energy_consumption) AS avg_energy_consumption FROM mining_sites JOIN mining_companies ON mining_sites.company_id = mining_companies.company_id GROUP BY company_name; SELECT company_name, SUM(energy_consumption) AS total_energy_consumption FROM mining_sites JOIN mining_companies ON mining_sites....
gretelai_synthetic_text_to_sql
CREATE TABLE sales_digital (song_id INT, genre VARCHAR(10), revenue DECIMAL(10,2));CREATE TABLE sales_physical (song_id INT, genre VARCHAR(10), revenue DECIMAL(10,2));
What is the total revenue generated from digital and physical sales of hip-hop and rock music?
SELECT SUM(revenue) FROM (SELECT revenue FROM sales_digital WHERE genre IN ('hip-hop', 'rock') UNION ALL SELECT revenue FROM sales_physical WHERE genre IN ('hip-hop', 'rock')) AS total_sales;
gretelai_synthetic_text_to_sql
CREATE TABLE sessions (region VARCHAR(50), session_date DATE);
What is the number of financial capability training sessions conducted per region?
SELECT region, COUNT(*) FROM sessions GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE Inspections (id INT, restaurant_id INT, location VARCHAR(50), rating INT); INSERT INTO Inspections (id, restaurant_id, location, rating) VALUES (1, 1, 'New York', 5); INSERT INTO Inspections (id, restaurant_id, location, rating) VALUES (2, 2, 'Los Angeles', 3); INSERT INTO Inspections (id, restaurant_id, l...
How many 5-star food safety inspections were there in New York?
SELECT COUNT(*) FROM Inspections WHERE location = 'New York' AND rating = 5;
gretelai_synthetic_text_to_sql
CREATE TABLE energy_sources (id INT, source VARCHAR(50), capacity FLOAT);
Show the total capacity for each energy source in the "energy_sources" table
SELECT source, SUM(capacity) as total_capacity FROM energy_sources GROUP BY source;
gretelai_synthetic_text_to_sql
CREATE TABLE VolunteerProgram (VolunteerProgramID INT, ProgramType TEXT, VolunteerHours DECIMAL); INSERT INTO VolunteerProgram (VolunteerProgramID, ProgramType, VolunteerHours) VALUES (1, 'Food Security', 75), (2, 'Education', 100), (3, 'Healthcare', 125);
What is the total number of volunteers and total volunteer hours per program type?
SELECT ProgramType, COUNT(*) as Volunteers, SUM(VolunteerHours) as TotalHours FROM VolunteerProgram GROUP BY ProgramType;
gretelai_synthetic_text_to_sql
CREATE TABLE cryptocurrencies (id INT, name VARCHAR(255), max_supply INT, min_supply INT); INSERT INTO cryptocurrencies (id, name, max_supply, min_supply) VALUES (1, 'BTC', 21000000, 21000000), (2, 'ETH', 18000000, 18000000), (3, 'XRP', 100000000000, 100000000000);
What's the maximum and minimum supply of each cryptocurrency?
SELECT name, MAX(max_supply) AS max_supply, MIN(min_supply) AS min_supply FROM cryptocurrencies;
gretelai_synthetic_text_to_sql
CREATE TABLE Aircraft (ID INT, Manufacturer VARCHAR(20), Country VARCHAR(20), Delivery_Time INT); INSERT INTO Aircraft (ID, Manufacturer, Country, Delivery_Time) VALUES (1, 'Boeing', 'USA', 36), (2, 'Airbus', 'Europe', 48), (3, 'Lockheed Martin', 'USA', 24);
What is the average delivery time for aircraft manufactured in the US?
SELECT AVG(Delivery_Time) FROM Aircraft WHERE Country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers(id INT, name VARCHAR(30), product VARCHAR(20), weight FLOAT, state VARCHAR(20), date DATE); INSERT INTO suppliers(id, name, product, weight, state, date) VALUES (1, 'Supplier A', 'soy milk', 300, 'California', '2022-01-01'); INSERT INTO suppliers(id, name, product, weight, state, date) VALUES (2,...
List the top 3 suppliers of non-GMO soy milk to California in the last 6 months, by total weight shipped?
SELECT name, SUM(weight) as total_weight FROM suppliers WHERE product LIKE 'soy milk%' AND state = 'California' AND date BETWEEN '2022-01-01' AND '2022-06-30' GROUP BY name ORDER BY total_weight DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE ai4good (contributor TEXT, donation INTEGER); INSERT INTO ai4good (contributor, donation) VALUES ('Contributor A', 25000); INSERT INTO ai4good (contributor, donation) VALUES ('Contributor B', 30000); INSERT INTO ai4good (contributor, donation) VALUES ('Contributor C', 35000);
Who are the top 3 contributors by donation amount to the 'ai4good' table?
SELECT contributor, donation FROM ai4good ORDER BY donation DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE habitats (name VARCHAR(255), animal_type VARCHAR(255), population INT); INSERT INTO habitats (name, animal_type, population) VALUES ('kwazulu-natal', 'rhino', 50); INSERT INTO habitats (name, animal_type, population) VALUES ('etosha', 'rhino', 60);
Which habitat has the lowest population of rhinos?
SELECT name FROM (SELECT name, population FROM habitats WHERE animal_type = 'rhino' ORDER BY population ASC LIMIT 1) AS subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE weather (id INT PRIMARY KEY, temperature DECIMAL(3,1), precipitation DECIMAL(3,1), date DATE, location VARCHAR(50)); INSERT INTO weather (id, temperature, precipitation, date, location) VALUES (4, 72.3, 12.5, '2021-12-31', 'Sydney');
What is the average precipitation in 'Sydney' for the year 2021?
SELECT AVG(precipitation) FROM weather WHERE date BETWEEN '2021-01-01' AND '2021-12-31' AND location = 'Sydney';
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID int, DonorName varchar(50), DonationDate date, DonationAmount decimal(10,2), Gender varchar(10)); INSERT INTO Donors (DonorID, DonorName, DonationDate, DonationAmount, Gender) VALUES (1, 'John Doe', '2021-02-01', 20.00, 'Male'), (2, 'Jane Smith', '2021-03-15', 50.00, 'Female'), (3, 'Mike Jo...
What was the average donation amount by gender in 2021, excluding donations below $10?
SELECT Gender, AVG(DonationAmount) as AverageDonationAmount FROM Donors WHERE DonationAmount >= 10 AND YEAR(DonationDate) = 2021 GROUP BY Gender;
gretelai_synthetic_text_to_sql
CREATE TABLE MiningOperations (OperationID INT, MineName VARCHAR(100), OperationType VARCHAR(50), Country VARCHAR(50), StartDate DATE, EndDate DATE); INSERT INTO MiningOperations (OperationID, MineName, OperationType, Country, StartDate, EndDate) VALUES (1, 'Golden Mine', 'Exploration', 'Canada', '2015-01-01', '2015-12...
What is the total number of workers by gender for a specific mining operation in Canada?
SELECT wf.OperationID, wf.Gender, COUNT(wf.EmployeeID) as TotalWorkers FROM WorkforceDiversity wf WHERE wf.OperationID = 1 GROUP BY wf.Gender;
gretelai_synthetic_text_to_sql
CREATE TABLE drugs_approval_region (drug_name TEXT, approval_year INTEGER, region TEXT); INSERT INTO drugs_approval_region (drug_name, approval_year, region) VALUES ('DrugX', 2018, 'North'), ('DrugY', 2019, 'South'), ('DrugZ', 2020, 'East'), ('DrugA', 2018, 'West'), ('DrugB', 2020, 'North'), ('DrugC', 2019, 'North'), (...
What is the total number of drugs approved in a given region across all years?
SELECT COUNT(DISTINCT drug_name) FROM drugs_approval_region WHERE region = 'North';
gretelai_synthetic_text_to_sql
CREATE TABLE Languages (LanguageID INT PRIMARY KEY, Name VARCHAR(50), Status VARCHAR(20), Region VARCHAR(50)); INSERT INTO Languages (LanguageID, Name, Status, Region) VALUES (1, 'English', 'Not Endangered', 'North America'), (2, 'Maori', 'Vulnerable', 'Oceania');
How many heritage languages in Oceania are considered vulnerable?
SELECT COUNT(*) FROM Languages WHERE Status = 'Vulnerable' AND Region = 'Oceania';
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, country VARCHAR(255), followers INT); INSERT INTO users (id, country, followers) VALUES (1, 'India', 100), (2, 'USA', 200), (3, 'India', 500);
What is the minimum number of followers for users in India?
SELECT MIN(followers) FROM users WHERE country = 'India';
gretelai_synthetic_text_to_sql
CREATE TABLE indigenous_defendants (id INT, case_id INT, defendant_race VARCHAR(25)); INSERT INTO indigenous_defendants (id, case_id, defendant_race) VALUES (1, 1001, 'Native American'), (2, 1002, 'First Nation'), (3, 1003, 'Maori');
What is the number of cases heard by race for indigenous defendants?
SELECT defendant_race, COUNT(case_id) FROM indigenous_defendants GROUP BY defendant_race;
gretelai_synthetic_text_to_sql
CREATE TABLE Donations2021Q4 (DonationID int, DonorType varchar(50), DonationAmount decimal(10,2), DonationDate date, RecurringDonor char(1)); INSERT INTO Donations2021Q4 (DonationID, DonorType, DonationAmount, DonationDate, RecurringDonor) VALUES (1, 'Individual', 100, '2021-11-12', 'Y'); INSERT INTO Donations2021Q4 (...
What is the average donation amount from recurring donors in Q4 2021?
SELECT AVG(DonationAmount) FROM Donations2021Q4 WHERE DonorType = 'Individual' AND RecurringDonor = 'Y' AND DonationDate BETWEEN '2021-10-01' AND '2021-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE creative_ai_algorithms (ai_algorithm_id INT PRIMARY KEY, algorithm_name VARCHAR(255), explainability_score FLOAT);
What is the average explainability score for creative AI algorithms?
SELECT AVG(explainability_score) FROM creative_ai_algorithms;
gretelai_synthetic_text_to_sql
CREATE TABLE Patents (patent_id INT, patent_name TEXT, patent_date DATE, country TEXT);
Which biosensor technology patents were filed in China in 2021?
SELECT COUNT(*) FROM Patents WHERE patent_date >= '2021-01-01' AND patent_date < '2022-01-01' AND country = 'China';
gretelai_synthetic_text_to_sql
CREATE TABLE tangible_heritage (id INT, name VARCHAR(255), region VARCHAR(255)); INSERT INTO tangible_heritage (id, name, region) VALUES (1, 'Red Square', 'Eastern Europe'); CREATE TABLE intangible_heritage (id INT, name VARCHAR(255), region VARCHAR(255)); INSERT INTO intangible_heritage (id, name, region) VALUES (1, '...
What is the total number of heritage sites (tangible and intangible) in the Eastern Europe region?
SELECT COUNT(*) FROM (SELECT 'tangible' as type, t.name FROM tangible_heritage t WHERE t.region = 'Eastern Europe' UNION ALL SELECT 'intangible' as type, i.name FROM intangible_heritage i WHERE i.region = 'Eastern Europe') AS h;
gretelai_synthetic_text_to_sql
CREATE TABLE Songs (song_id INT, title TEXT, artist TEXT, genre TEXT, release_date DATE, price DECIMAL(5,2));
Insert a new hip-hop song from an artist named 'Keisha Chiddick' released on '2022-10-15' with a price of $1.29
INSERT INTO Songs (song_id, title, artist, genre, release_date, price) VALUES (NULL, 'New Beginnings', 'Keisha Chiddick', 'hip-hop', '2022-10-15', 1.29);
gretelai_synthetic_text_to_sql
CREATE TABLE cultural_sites (site_id INT, name TEXT, country TEXT); INSERT INTO cultural_sites (site_id, name, country) VALUES (1, 'Alhambra', 'Spain'), (2, 'Sagrada Familia', 'Spain'), (3, 'Mosque of Cordoba', 'Spain');
What is the total number of cultural heritage sites in Spain?
SELECT COUNT(*) FROM cultural_sites WHERE country = 'Spain';
gretelai_synthetic_text_to_sql
CREATE TABLE Mediators (MediatorID INT, Name VARCHAR(50), Age INT, Experience INT); INSERT INTO Mediators (MediatorID, Name, Age, Experience) VALUES (1, 'John Doe', 45, 12), (2, 'Jane Smith', 38, 7), (3, 'Alice Johnson', 42, 18), (4, 'Bob Brown', 50, 25); CREATE TABLE Cases (CaseID INT, MediatorID INT, Date DATE); INSE...
What is the rank of each mediator based on the number of cases handled, with ties broken by age?
SELECT MediatorID, Name, RANK() OVER (ORDER BY COUNT(*) DESC, Age) as Rank FROM Mediators JOIN Cases ON Mediators.MediatorID = Cases.MediatorID GROUP BY MediatorID, Name;
gretelai_synthetic_text_to_sql
CREATE TABLE Spacecraft (id INT, name VARCHAR(50), launch_date DATE, max_speed FLOAT); INSERT INTO Spacecraft (id, name, launch_date, max_speed) VALUES (1, 'Mars Reconnaissance Orbiter', '2005-08-12', 9.63);
What is the average speed of all spacecraft that have traveled to Mars?
SELECT AVG(max_speed) FROM Spacecraft WHERE name IN ('Mars Reconnaissance Orbiter', 'Perseverance Rover', 'Curiosity Rover', 'Spirit Rover', 'Opportunity Rover');
gretelai_synthetic_text_to_sql
CREATE TABLE MPA (mpa_name VARCHAR(50), region VARCHAR(50), year_established INT, PRIMARY KEY(mpa_name)); INSERT INTO MPA (mpa_name, region, year_established) VALUES ('MPA1', 'Mediterranean Sea', 1986), ('MPA2', 'Mediterranean Sea', 2004);
What are the names of marine protected areas (MPAs) in the Mediterranean Sea and their year of establishment?
SELECT MPA.mpa_name, MPA.year_established FROM MPA WHERE MPA.region = 'Mediterranean Sea';
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, Gender VARCHAR(10), Department VARCHAR(20), Salary FLOAT); INSERT INTO Employees (EmployeeID, Gender, Department, Salary) VALUES (1, 'Male', 'Marketing', 70000), (2, 'Female', 'Marketing', 75000), (3, 'Male', 'Marketing', 72000), (4, 'Female', 'Marketing', 78000), (5, 'Non-binary...
What is the average salary of male employees who work in the marketing department?
SELECT AVG(Salary) FROM Employees WHERE Gender = 'Male' AND Department = 'Marketing';
gretelai_synthetic_text_to_sql
CREATE TABLE AutonomousVehicles (id INT, manufacturer VARCHAR(50), safety_rating INT, country VARCHAR(50)); INSERT INTO AutonomousVehicles (id, manufacturer, safety_rating, country) VALUES (1, 'Tesla', 90, 'USA'), (2, 'Waymo', 92, 'USA'), (3, 'NVIDIA', 88, 'USA'), (4, 'Baidu', 85, 'China');
What is the average safety rating of all autonomous vehicles manufactured in the US, grouped by manufacturer, ordered by the highest average safety rating?
SELECT manufacturer, AVG(safety_rating) as avg_safety_rating FROM AutonomousVehicles WHERE country = 'USA' GROUP BY manufacturer ORDER BY avg_safety_rating DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE energy_storage (id INT PRIMARY KEY, power_plant_id INT, date DATE, capacity FLOAT); INSERT INTO energy_storage (id, power_plant_id, date, capacity) VALUES (1, 2, '2023-01-01', 60.0); INSERT INTO energy_storage (id, power_plant_id, date, capacity) VALUES (2, 2, '2023-01-02', 62.5);
What is the average daily energy storage capacity for power plant 2 in Texas between January 1 and January 5, 2023?
SELECT e.power_plant_id, AVG(e.capacity) as avg_capacity FROM energy_storage e WHERE e.power_plant_id = 2 AND e.date BETWEEN '2023-01-01' AND '2023-01-05' GROUP BY e.power_plant_id;
gretelai_synthetic_text_to_sql
CREATE TABLE astronauts(id INT, name VARCHAR(50), country VARCHAR(50), missions VARCHAR(50)); INSERT INTO astronauts VALUES(1, 'Roberta Bondar', 'Canada', 'ISS'), (2, 'David Saint-Jacques', 'Canada', 'ISS');
How many astronauts are there from Canada who have been to the ISS?
SELECT COUNT(*) FROM astronauts WHERE country = 'Canada' AND missions = 'ISS';
gretelai_synthetic_text_to_sql
CREATE TABLE tax_rates (tax_id INT, country VARCHAR(255), tax_rate DECIMAL(4,2)); INSERT INTO tax_rates (tax_id, country, tax_rate) VALUES (1, 'USA', 0.07), (2, 'Canada', 0.13), (3, 'Mexico', 0.16); CREATE TABLE mobile_plans (plan_id INT, plan_name VARCHAR(255), data_limit DECIMAL(10,2), price DECIMAL(10,2)); INSERT IN...
What is the monthly revenue for each mobile plan in different countries?
SELECT plan_name, country, (price + (price * (SELECT tax_rate FROM tax_rates WHERE country = mobile_plans.country) * 1)) * 12 AS monthly_revenue_usd FROM mobile_plans;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, Department VARCHAR(255), Gender VARCHAR(255), Salary DECIMAL(10,2)); INSERT INTO Employees (EmployeeID, Department, Gender, Salary) VALUES (1, 'IT', 'Male', 75000.00), (2, 'Diversity and Inclusion', 'Female', 68000.00), (3, 'HR', 'Male', 65000.00), (4, 'HR', 'Female', 70000.00);
What is the total salary expense for the 'HR' department?
SELECT SUM(Salary) FROM Employees WHERE Department = 'HR';
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers (supplier_id INT, supplier_name VARCHAR(50), energy_type VARCHAR(50)); INSERT INTO suppliers (supplier_id, supplier_name, energy_type) VALUES (1, 'SupplierA', 'Wind'), (2, 'SupplierB', 'Solar'), (3, 'SupplierC', 'Wind'), (4, 'SupplierD', 'Solar'), (5, 'SupplierE', 'Wind'), (6, 'SupplierF', 'Solar...
List all suppliers who provide materials for both wind energy and solar energy systems.
SELECT supplier_name FROM suppliers WHERE energy_type = 'Wind' INTERSECT SELECT supplier_name FROM suppliers WHERE energy_type = 'Solar';
gretelai_synthetic_text_to_sql
CREATE TABLE terminations (id INT, employee_id INT, department_id INT, termination_date DATE); INSERT INTO terminations (id, employee_id, department_id, termination_date) VALUES (1, 1, 1, '2022-03-15'), (2, 2, 1, '2022-04-20'), (3, 3, 2, '2023-01-01');
What is the turnover rate by department?
SELECT department_id, COUNT(*) * 100.0 / (SELECT COUNT(*) FROM (SELECT employee_id FROM employment_history UNION SELECT employee_id FROM terminations) AS combined_employees) as turnover_rate FROM terminations GROUP BY department_id;
gretelai_synthetic_text_to_sql
CREATE TABLE AutonomousDrivingResearch (Id INT, Project VARCHAR(50), Country VARCHAR(50), StartDate DATE); INSERT INTO AutonomousDrivingResearch (Id, Project, Country, StartDate) VALUES (1, 'Project A', 'India', '2017-05-15'); INSERT INTO AutonomousDrivingResearch (Id, Project, Country, StartDate) VALUES (2, 'Project B...
How many autonomous driving research projects were initiated in India and France?
SELECT COUNT(*) FROM AutonomousDrivingResearch WHERE Country IN ('India', 'France');
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (VolunteerID int, Name varchar(100), Program varchar(50), Hours int, VolunteerDate date); INSERT INTO Volunteers (VolunteerID, Name, Program, Hours, VolunteerDate) VALUES (1, 'Fatima Ahmed', 'Education Support', 20); INSERT INTO Volunteers (VolunteerID, Name, Program, Hours, VolunteerDate) VALUE...
What is the average number of volunteer hours per volunteer for each program?
SELECT Program, AVG(Hours) as AverageHoursPerVolunteer FROM Volunteers GROUP BY Program;
gretelai_synthetic_text_to_sql
CREATE TABLE farmers (id INT PRIMARY KEY, name VARCHAR(50), age INT, gender VARCHAR(10), location VARCHAR(50));
Add a new column 'profession' to the 'farmers' table
ALTER TABLE farmers ADD COLUMN profession VARCHAR(50);
gretelai_synthetic_text_to_sql
CREATE TABLE Equipment_Manufacturer (id INT, name VARCHAR(50), pieces INT); INSERT INTO Equipment_Manufacturer (id, name, pieces) VALUES (1, 'Lockheed Martin', 100), (2, 'Boeing', 150); CREATE TABLE Equipment_Manufacturer_Mapping (equipment_id INT, manufacturer_id INT); INSERT INTO Equipment_Manufacturer_Mapping (equip...
Find the total number of military equipment pieces manufactured by each company?
SELECT Equipment_Manufacturer.name, SUM(Equipment_Manufacturer_Mapping.equipment_id) AS total_pieces FROM Equipment_Manufacturer JOIN Equipment_Manufacturer_Mapping ON Equipment_Manufacturer.id = Equipment_Manufacturer_Mapping.manufacturer_id GROUP BY Equipment_Manufacturer.name;
gretelai_synthetic_text_to_sql
CREATE TABLE properties (id INT, size INT, country VARCHAR(255)); INSERT INTO properties (id, size, country) VALUES (1, 1500, 'Spain'), (2, 2000, 'Spain'), (3, 1800, 'Spain');
What is the rank of each property size within its country?
SELECT id, size, country, ROW_NUMBER() OVER (PARTITION BY country ORDER BY size) as rn FROM properties;
gretelai_synthetic_text_to_sql
CREATE TABLE fish_species (id INT PRIMARY KEY, name VARCHAR(255), family VARCHAR(255), breeding_season VARCHAR(255));
Insert records into 'fish_species' table
INSERT INTO fish_species (id, name, family, breeding_season) VALUES (1, 'Atlantic Salmon', 'Salmonidae', 'Spring');
gretelai_synthetic_text_to_sql
CREATE TABLE industrial_water_usage (state VARCHAR(20), year INT, usage FLOAT); INSERT INTO industrial_water_usage (state, year, usage) VALUES ('Texas', 2019, 8.3), ('California', 2019, 7.9), ('Pennsylvania', 2019, 5.1), ('Illinois', 2019, 4.8), ('Ohio', 2019, 4.4);
What is the maximum water usage in the industrial sector in all states in 2019?
SELECT MAX(usage) FROM industrial_water_usage WHERE year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (id INT, species_name VARCHAR(255), region VARCHAR(255)); INSERT INTO marine_species (id, species_name, region) VALUES (1, 'Oceanic whitetip shark', 'North Atlantic');
Find the total number of marine species recorded in the North Atlantic and South Atlantic.
(SELECT COUNT(*) FROM marine_species WHERE region IN ('North Atlantic', 'South Atlantic'))
gretelai_synthetic_text_to_sql
CREATE TABLE graduates (student_id INT, name VARCHAR(100), department VARCHAR(50));CREATE TABLE publications (paper_id INT, student_id INT, publish_date DATE);
Which graduate students have published more than 5 papers in the past 2 years, and what is the average number of papers published by these students?
SELECT student_id, AVG(paper_count) as avg_papers FROM (SELECT student_id, COUNT(*) as paper_count FROM publications WHERE publish_date >= DATEADD(year, -2, GETDATE()) GROUP BY student_id HAVING COUNT(*) > 5) as subquery GROUP BY student_id;
gretelai_synthetic_text_to_sql
CREATE TABLE investment_strategies (id INT, name VARCHAR(50), risk_level VARCHAR(50)); INSERT INTO investment_strategies (id, name, risk_level) VALUES (1, 'Conservative', 'Low'), (2, 'Moderate', 'Medium'), (3, 'Aggressive', 'High');
List all the unique investment strategies and their associated risk levels.
SELECT DISTINCT name, risk_level FROM investment_strategies;
gretelai_synthetic_text_to_sql
CREATE TABLE projects (id INT, name VARCHAR, ethical_ai BOOLEAN, budget FLOAT); INSERT INTO projects (id, name, ethical_ai, budget) VALUES (1, 'AI for social good', true, 100000), (2, 'AI for healthcare', false, 200000), (3, 'Ethical AI for education', true, 150000);
List all ethical AI projects and their respective budgets.
SELECT name, budget FROM projects WHERE ethical_ai = true;
gretelai_synthetic_text_to_sql
CREATE TABLE flu_cases (id INT, country VARCHAR(255), case_number INT); INSERT INTO flu_cases (id, country, case_number) VALUES (1, 'Canada', 1001); INSERT INTO flu_cases (id, country, case_number) VALUES (2, 'Australia', 2002); INSERT INTO flu_cases (id, country, case_number) VALUES (3, 'Japan', 3003); INSERT INTO flu...
Delete all records of influenza cases reported in Japan.
DELETE FROM flu_cases WHERE country = 'Japan';
gretelai_synthetic_text_to_sql
CREATE TABLE fish_species (id INT, name VARCHAR(50), average_length DECIMAL(5,2)); CREATE TABLE fish_weights (id INT, fish_species_id INT, date DATE, weight DECIMAL(10,2)); INSERT INTO fish_species (id, name, average_length) VALUES (1, 'Salmon', 70.0), (2, 'Tilapia', 25.0); INSERT INTO fish_weights (id, fish_species_id...
Calculate the total biomass for each fish species in Q1 2022.
SELECT fs.name, SUM(fw.weight) AS total_biomass FROM fish_species fs JOIN fish_weights fw ON fs.id = fw.fish_species_id WHERE YEAR(fw.date) = 2022 AND QUARTER(fw.date) = 1 GROUP BY fs.name;
gretelai_synthetic_text_to_sql
CREATE TABLE satellites (id INT, name VARCHAR(50), launch_date DATE, launch_org VARCHAR(50));
List satellites launched by SpaceX with their launch dates and the number of days since the first SpaceX launch?
SELECT name, launch_date, DATEDIFF(launch_date, (SELECT MIN(launch_date) FROM satellites WHERE launch_org = 'SpaceX')) AS days_since_first_launch FROM satellites WHERE launch_org = 'SpaceX';
gretelai_synthetic_text_to_sql
CREATE TABLE GamePlayers (GameTitle VARCHAR(255), PlayerID INT); INSERT INTO GamePlayers VALUES ('GameA', 1), ('GameA', 2), ('GameA', 3), ('GameB', 1), ('GameB', 2), ('GameC', 1), ('GameC', 2), ('GameC', 3), ('GameC', 4); CREATE TABLE Games (GameTitle VARCHAR(255), GameID INT); INSERT INTO Games VALUES ('GameA', 1), ('...
Show the top 3 games with the highest number of unique players.
SELECT g.GameTitle, COUNT(DISTINCT gp.PlayerID) as UniquePlayers FROM Games g INNER JOIN GamePlayers gp ON g.GameID = gp.GameTitle GROUP BY g.GameTitle ORDER BY UniquePlayers DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE seafood_production (id INT, country VARCHAR(20), production_volume DECIMAL(10,2), organic BOOLEAN); INSERT INTO seafood_production (id, country, production_volume, organic) VALUES (1, 'US', 3000.5, TRUE), (2, 'Canada', 2500.2, TRUE);
What is the production volume of organic seafood in the United States and Canada?
SELECT SUM(production_volume) FROM seafood_production WHERE country IN ('US', 'Canada') AND organic = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE SupportStaff (StaffID INT, AccomID INT); INSERT INTO SupportStaff (StaffID, AccomID) VALUES (1, 1), (2, 2), (3, 2), (4, 3), (5, 4), (6, 5), (7, 1), (8, 2), (9, 3), (10, 4), (11, 5), (12, 1); CREATE TABLE Accommodation (AccomID INT, AccomName VARCHAR(50)); INSERT INTO Accommodation (AccomID, AccomName) VALU...
Show the number of staff members who provide support for each accommodation type
SELECT AccomName, COUNT(DISTINCT StaffID) as NumStaff FROM SupportStaff ss JOIN Accommodation a ON ss.AccomID = a.AccomID GROUP BY AccomName;
gretelai_synthetic_text_to_sql