context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE CommunityPolicing (id INT, district VARCHAR(255), police_interactions INT);
Which community policing districts have the highest police interactions?
SELECT district, MAX(police_interactions) FROM CommunityPolicing GROUP BY district;
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (VolID INT, OrgID INT, VolName VARCHAR(255), Hours INT); INSERT INTO Volunteers (VolID, OrgID, VolName, Hours) VALUES (1, 1, 'Alice', 50), (2, 1, 'Bob', 75), (3, 2, 'Charlie', 100), (4, 3, 'David', 120), (5, 3, 'Eve', 150), (6, 4, 'Frank', 180), (7, 5, 'Grace', 200);
Which organizations have the highest and lowest total hours of volunteer work?
SELECT OrgID, SUM(Hours) as TotalHours FROM Volunteers GROUP BY OrgID ORDER BY TotalHours DESC, OrgID;
gretelai_synthetic_text_to_sql
CREATE TABLE IntelligenceBudget (id INT PRIMARY KEY, year INT, budget DECIMAL(10,2)); INSERT INTO IntelligenceBudget (id, year, budget) VALUES (1, 2018, 5000000.00), (2, 2019, 5500000.00), (3, 2020, 6000000.00);
What is the maximum and minimum budget for intelligence operations by year?
SELECT YEAR(budget_date) as year, MAX(budget) as max_budget, MIN(budget) as min_budget FROM IntelligenceBudget GROUP BY YEAR(budget_date);
gretelai_synthetic_text_to_sql
CREATE TABLE ai_algorithms_fairness (algorithm_id INT, algorithm_name VARCHAR(50), fairness_score DECIMAL(5,2)); INSERT INTO ai_algorithms_fairness (algorithm_id, algorithm_name, fairness_score) VALUES (1, 'DeepQA', 0.87), (2, 'Random Forest', 0.92), (3, 'Support Vector Machine', 0.91), (4, 'Neural Network', 0.88);
What is the fairness score for each AI algorithm, partitioned by algorithm type, ordered by score in ascending order?
SELECT algorithm_name, AVG(fairness_score) as avg_fairness_score FROM ai_algorithms_fairness GROUP BY algorithm_name ORDER BY avg_fairness_score ASC;
gretelai_synthetic_text_to_sql
CREATE TABLE Inventory (Item VARCHAR(10), Quantity INT); INSERT INTO Inventory (Item, Quantity) VALUES ('EAA-001', 300), ('EAA-002', 400);
Update the quantity of item 'EAA-001' in the inventory table to 500
UPDATE Inventory SET Quantity = 500 WHERE Item = 'EAA-001';
gretelai_synthetic_text_to_sql
CREATE TABLE contracts (id INT, category VARCHAR(255), value DECIMAL(10,2));INSERT INTO contracts (id, category, value) VALUES (1, 'Aircraft', 5000000.00), (2, 'Missiles', 2000000.00), (3, 'Shipbuilding', 8000000.00), (4, 'Cybersecurity', 3000000.00), (5, 'Aircraft', 6000000.00), (6, 'Shipbuilding', 9000000.00);
What is the number of contracts for each category?
SELECT category, COUNT(*) as contract_count FROM contracts GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE DisabilitySupportPrograms (year INT, budget DECIMAL(5,2)); INSERT INTO DisabilitySupportPrograms (year, budget) VALUES (2019, 120000.00), (2020, 150000.00), (2021, 180000.00);
What is the average budget allocated for disability support programs in '2021'?
SELECT AVG(budget) FROM DisabilitySupportPrograms WHERE year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE epl_2020_2021 (player TEXT, goals INT);
Find the top 5 goal scorers in the English Premier League in the 2020-2021 season.
SELECT player, goals FROM epl_2020_2021 ORDER BY goals DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE machines (id INT PRIMARY KEY, name VARCHAR(255), type VARCHAR(255), year INT); INSERT INTO machines (id, name, type, year) VALUES (1, 'Machine A', 'CNC', 2015), (2, 'Machine B', '3D Printing', 2020), (3, 'Machine C', 'CNC', 2018);
What is the total number of machines for each type, and the latest model year for each type?
SELECT type, COUNT(*) as total_machines, MAX(year) as latest_model FROM machines GROUP BY type;
gretelai_synthetic_text_to_sql
CREATE TABLE organic_materials (country VARCHAR(50), fashion_production_sector VARCHAR(50), organic_material_type VARCHAR(50), percentage_use FLOAT); INSERT INTO organic_materials (country, fashion_production_sector, organic_material_type, percentage_use) VALUES ('India', 'fashion_production', 'organic_cotton', 75.5), ...
Update the percentage of 'organic_cotton' use in 'India' to 76.5
UPDATE organic_materials SET percentage_use = 76.5 WHERE country = 'India' AND organic_material_type = 'organic_cotton';
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_customers (customer_id INT, monthly_revenue FLOAT, city VARCHAR(20), plan_type VARCHAR(10)); INSERT INTO mobile_customers (customer_id, monthly_revenue, city, plan_type) VALUES (1, 25.5, 'Dallas', 'prepaid'), (2, 32.2, 'Houston', 'postpaid'), (3, 28.9, 'Dallas', 'prepaid');
What is the average monthly revenue for prepaid mobile customers in the city of Dallas?
SELECT AVG(monthly_revenue) FROM mobile_customers WHERE city = 'Dallas' AND plan_type = 'prepaid';
gretelai_synthetic_text_to_sql
CREATE TABLE wind_farm_germany (id INT, name TEXT, location TEXT, capacity_mw FLOAT); INSERT INTO wind_farm_germany (id, name, location, capacity_mw) VALUES (1, 'Windpark Nordsee One', 'Germany', 332.0); CREATE TABLE wind_farm_france (id INT, name TEXT, location TEXT, capacity_mw FLOAT); INSERT INTO wind_farm_france (i...
What are the total installed capacities (in MW) of wind farms in Germany and France?
SELECT SUM(capacity_mw) FROM wind_farm_germany WHERE location = 'Germany' UNION SELECT SUM(capacity_mw) FROM wind_farm_france WHERE location = 'France';
gretelai_synthetic_text_to_sql
CREATE TABLE City_Policy (city_id INT, description TEXT, implemented BOOLEAN, impact INT); INSERT INTO City_Policy (city_id, description, implemented, impact) VALUES (1, 'Bike lane expansion', true, 8); INSERT INTO City_Policy (city_id, description, implemented, impact) VALUES (1, 'Park renovation', false, NULL); INSER...
What is the average policy impact for cities with implemented policies with a positive impact?
SELECT City_Policy.city_id, AVG(City_Policy.impact) as 'Avg Policy Impact' FROM City_Policy WHERE City_Policy.implemented = true AND City_Policy.impact > 0 GROUP BY City_Policy.city_id;
gretelai_synthetic_text_to_sql
CREATE TABLE EsportsEvents (EventID INT, EventName VARCHAR(50), Location VARCHAR(50), Attendance INT); INSERT INTO EsportsEvents (EventID, EventName, Location, Attendance) VALUES (1, 'GameCon Europe', 'London', 60000), (2, 'Esports World Cup', 'Berlin', 90000), (3, 'Gaming Summit', 'Paris', 70000);
What is the maximum number of attendees at an esports event held in Europe?
SELECT MAX(Attendance) FROM EsportsEvents WHERE Location = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE smart_contracts (id INT, name VARCHAR(255), technology VARCHAR(50)); INSERT INTO smart_contracts (id, name, technology) VALUES (1, 'SC1', 'EVM'); INSERT INTO smart_contracts (id, name, technology) VALUES (2, 'SC2', 'Solidity'); INSERT INTO smart_contracts (id, name, technology) VALUES (3, 'SC3', 'EVM'); CR...
What's the total number of smart contracts by technology type?
SELECT technology, COUNT(*) FROM smart_contracts GROUP BY technology;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID int, FirstName varchar(50), LastName varchar(50)); INSERT INTO Donors (DonorID, FirstName, LastName) VALUES (1, 'John', 'Doe'), (2, 'Jane', 'Doe');
Insert new donor records for the first quarter of 2023.
INSERT INTO Donors (DonorID, FirstName, LastName) VALUES (3, 'Mohammad', 'Ali'), (4, 'Hanako', 'Yamada'), (5, 'Leonel', 'Messi');
gretelai_synthetic_text_to_sql
CREATE TABLE autonomous_driving_research (id INT, vehicle_name VARCHAR(50), research_topic VARCHAR(50));
Add a new row to the 'autonomous_driving_research' table with id 100, vehicle_name 'Wayve', and research_topic 'Deep Learning'
INSERT INTO autonomous_driving_research (id, vehicle_name, research_topic) VALUES (100, 'Wayve', 'Deep Learning');
gretelai_synthetic_text_to_sql
CREATE TABLE sensor_installation (sensor_id INT, install_date DATE); INSERT INTO sensor_installation (sensor_id, install_date) VALUES (1001, '2021-04-03'), (1002, '2021-04-17'), (1003, '2021-04-01'), (1004, '2021-04-15'), (1005, '2021-03-30');
How many IoT moisture sensors are currently installed?
SELECT COUNT(*) FROM sensor_installation WHERE install_date <= CURDATE();
gretelai_synthetic_text_to_sql
CREATE TABLE menu_sales(menu_item VARCHAR(50), sale_date DATE, sales INT, type VARCHAR(10)); INSERT INTO menu_sales VALUES ('Burger', '2022-01-01', 50, 'non-veg'), ('Pizza', '2022-01-01', 30, 'veg'), ('Salad', '2022-01-01', 20, 'veg'), ('Burger', '2022-01-02', 60, 'non-veg'), ('Pizza', '2022-01-02', 40, 'veg'), ('Salad...
What is the weekly sales trend for vegan menu items?
SELECT sale_date, type, SUM(sales) AS total_sales, ROW_NUMBER() OVER (PARTITION BY type ORDER BY SUM(sales) DESC) AS ranking FROM menu_sales WHERE type = 'veg' GROUP BY sale_date, type ORDER BY sale_date, total_sales DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, name VARCHAR(50)); INSERT INTO customers (customer_id, name) VALUES (1, 'John Smith'), (2, 'Jane Doe'), (3, 'Bob Johnson'); CREATE TABLE transactions (transaction_id INT, customer_id INT, amount DECIMAL(10,2), transaction_date DATE); INSERT INTO transactions (transaction_id, cus...
List all customers who have not made any transactions in the last 6 months.
SELECT c.customer_id, c.name FROM customers c LEFT JOIN transactions t ON c.customer_id = t.customer_id WHERE t.transaction_date IS NULL OR t.transaction_date < DATE_SUB(CURDATE(), INTERVAL 6 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE fashion_trends (id INT, garment_type VARCHAR(255), region VARCHAR(255), popularity INT); INSERT INTO fashion_trends (id, garment_type, region, popularity) VALUES (1, 'Ankara Dress', 'Africa', 90), (2, 'Kente Cloth Pants', 'Africa', 80), (3, 'Dashiki Shirt', 'Africa', 70);
Insert new records into the fashion_trends table with the latest trending garment types in the African market.
INSERT INTO fashion_trends (id, garment_type, region, popularity) VALUES (4, 'Boubou', 'Africa', 85), (5, 'Kufi Hat', 'Africa', 95), (6, 'Fila Jacket', 'Africa', 88);
gretelai_synthetic_text_to_sql
CREATE TABLE Commercial_Buildings (province VARCHAR(255), consumption INT); INSERT INTO Commercial_Buildings (province, consumption) VALUES ('Ontario', 120), ('Quebec', 100), ('British Columbia', 150);
What is the average energy consumption for commercial buildings in Canada, grouped by province?
SELECT province, AVG(consumption) AS avg_consumption FROM Commercial_Buildings GROUP BY province;
gretelai_synthetic_text_to_sql
CREATE TABLE public_libraries (library_id INT, name VARCHAR(255), location VARCHAR(255), city VARCHAR(255), state VARCHAR(255), zip INT); INSERT INTO public_libraries (library_id, name, location, city, state, zip) VALUES (1, 'New York Public Library', 'Fifth Avenue', 'New York', 'NY', 10003); INSERT INTO public_librari...
Select the total number of public libraries in New York City
SELECT COUNT(*) FROM public_libraries WHERE city = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (id INT, name TEXT, city TEXT); INSERT INTO hotels (id, name, city) VALUES (1, 'Hotel Plaza', 'New York'), (2, 'Hotel Wellington', 'New York'), (3, 'Hotel Giraffe', 'New York');
How many hotels are there in 'New York'?
SELECT COUNT(*) FROM hotels WHERE city = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE legal_technology_patents (patent_id INT, filing_year INT, women_led_team BOOLEAN); INSERT INTO legal_technology_patents (patent_id, filing_year, women_led_team) VALUES (1, 2010, FALSE), (2, 2011, TRUE), (3, 2012, TRUE), (4, 2015, FALSE), (5, 2018, TRUE), (6, 2020, TRUE);
Identify the total number of legal technology patents filed by women-led teams from 2010 to 2020
SELECT SUM(women_led_team) FROM legal_technology_patents WHERE filing_year BETWEEN 2010 AND 2020 AND women_led_team = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE clinical_trial_data (clinical_trial_id INT, drug_name VARCHAR(255), primary_investigator VARCHAR(255), start_date DATE, end_date DATE);
Delete all clinical trial records for drug 'DrugX' from the 'clinical_trial_data' table.
DELETE FROM clinical_trial_data WHERE drug_name = 'DrugX';
gretelai_synthetic_text_to_sql
CREATE TABLE professors (id INT, name VARCHAR(50), department VARCHAR(50), research_interest VARCHAR(50), grant INT); INSERT INTO professors (id, name, department, research_interest, grant) VALUES (1, 'John Doe', 'Computer Science', 'Machine Learning', 1), (2, 'Jane Smith', 'Computer Science', 'Data Science', 1), (3, '...
List the names and research interests of all professors who have received a research grant.
SELECT name, research_interest FROM professors WHERE grant = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE police_stations (station_id INT, station_name TEXT, zone_id INT); INSERT INTO police_stations (station_id, station_name, zone_id) VALUES (1, 'Central', 1), (2, 'North', 2), (3, 'South', 3); CREATE TABLE zones (zone_id INT, zone_name TEXT); INSERT INTO zones (zone_id, zone_name) VALUES (1, 'A'), (2, 'B'), (...
List all the police stations and their respective zones?
SELECT station_name, zone_name FROM police_stations p JOIN zones z ON p.zone_id = z.zone_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Europe (Country VARCHAR(50), Population INT, ObesityRate FLOAT); INSERT INTO Europe (Country, Population, ObesityRate) VALUES ('Germany', 83.123456, 22.1), ('France', 66.789123, 20.5), ('United Kingdom', 67.564321, 24.9), ('Italy', 60.345678, 21.3), ('Spain', 48.987654, 23.2), ('Russia', 145.678901, 25.7),...
Which European country has the highest obesity rate?
SELECT Country, ObesityRate FROM Europe ORDER BY ObesityRate DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE strains (id INT, name TEXT, category TEXT, yield FLOAT); INSERT INTO strains (id, name, category, yield) VALUES (1, 'Purple Kush', 'Indica', 0.5), (2, 'Northern Lights', 'Indica', 0.6), (3, 'Granddaddy Purple', 'Indica', 0.7), (4, 'Afghan Kush', 'Indica', 0.8), (5, 'Bubba Kush', 'Indica', 0.9);
Which strains have the lowest yield in the 'Indica' category?
SELECT name FROM strains WHERE category = 'Indica' ORDER BY yield ASC;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists genetics; USE genetics; CREATE TABLE if not exists startups (id INT, name VARCHAR(100), industry VARCHAR(100), total_funding DECIMAL(10,2)); CREATE TABLE if not exists studies (id INT, name VARCHAR(100), year INT, funding DECIMAL(10,2)); INSERT INTO startups (id, name, industry, total_fundin...
Identify the total funding amount for each biotech startup, along with the average genetic research study funding per year, grouped by industry.
SELECT startups.industry, AVG(studies.funding) AS avg_yearly_funding FROM genetics.startups INNER JOIN genetics.studies ON startups.id = studies.id GROUP BY startups.industry;
gretelai_synthetic_text_to_sql
CREATE TABLE labor_certifications (certification_id INT, certification_name VARCHAR(50)); INSERT INTO labor_certifications (certification_id, certification_name) VALUES (1, 'Fair Trade'), (2, 'Certified B Corporation'), (3, 'SA8000 Social Accountability');
How many unique ethical labor certifications are there in the labor_certifications table?
SELECT COUNT(DISTINCT certification_name) FROM labor_certifications;
gretelai_synthetic_text_to_sql
CREATE TABLE DisasterPreparedness (id INT, state VARCHAR(20), year INT, training_count INT);
What is the total number of disaster preparedness trainings held in the state of California in the year 2019?
SELECT SUM(training_count) FROM DisasterPreparedness WHERE state = 'California' AND year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE Instructor_Student_Mapping (instructor_id INT, student_id INT);
Identify instructors with no students requiring accommodations.
SELECT i.name as instructor_name FROM Instructors i LEFT JOIN Instructor_Student_Mapping ism ON i.id = ism.instructor_id LEFT JOIN Accommodations a ON ism.student_id = a.student_id WHERE a.id IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE ota_data (hotel_id INT, location VARCHAR(20), ota VARCHAR(20), commission DECIMAL(5,2));
Compare OTA commission rates for hotels in Asia and Europe.
SELECT ota, AVG(commission) as avg_commission FROM ota_data WHERE location IN ('Asia', 'Europe') GROUP BY ota
gretelai_synthetic_text_to_sql
CREATE TABLE Innovation_Grants (Grant_ID INT PRIMARY KEY, Grant_Name VARCHAR(255), Recipient VARCHAR(255), Amount DECIMAL(10,2), Date_Granted DATE); INSERT INTO Innovation_Grants (Grant_ID, Grant_Name, Recipient, Amount, Date_Granted) VALUES (1, 'Project STARLIGHT', 'Lockheed Martin', 5000000, '2018-05-15');
Which countries received innovation grants over 10 million dollars?
SELECT DISTINCT Recipient FROM Innovation_Grants WHERE Amount > 10000000;
gretelai_synthetic_text_to_sql
CREATE TABLE DisasterPreparedness ( id INT, city VARCHAR(20), year INT, budget DECIMAL(10,2), preparedness_score INT); INSERT INTO DisasterPreparedness (id, city, year, budget, preparedness_score) VALUES (1, 'San Francisco', 2020, 1500000, 85); INSERT INTO DisasterPreparedness (id, city, year, budget, preparedness_scor...
Identify the city with the lowest preparedness score in DisasterPreparedness table.
SELECT city, MIN(preparedness_score) OVER () as lowest_preparedness_score FROM DisasterPreparedness WHERE year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE emissions (id INT, brand VARCHAR(255), emissions FLOAT);
What is the total carbon emissions for each brand?
SELECT brand, SUM(emissions) FROM emissions GROUP BY brand;
gretelai_synthetic_text_to_sql
CREATE TABLE developers (developer_id INT, name VARCHAR(255), country VARCHAR(255)); CREATE TABLE smart_contracts (contract_id INT, name VARCHAR(255), developer_id INT); INSERT INTO developers (developer_id, name, country) VALUES (1, 'Alice', 'USA'), (2, 'Bob', 'Canada'), (3, 'Charlie', 'India'), (4, 'Dave', 'Brazil'),...
How many smart contracts were created by developers in each country?
SELECT d.country, COUNT(*) as num_contracts FROM smart_contracts sc JOIN developers d ON sc.developer_id = d.developer_id GROUP BY d.country;
gretelai_synthetic_text_to_sql
CREATE TABLE clients (client_id INT, name TEXT, dob DATE, branch TEXT, state TEXT);CREATE TABLE accounts (account_id INT, client_id INT, account_type TEXT);INSERT INTO clients VALUES (4, 'Alice Davis', '1985-02-25', 'Houston', 'Texas');INSERT INTO accounts VALUES (104, 4, 'Credit Card');
What is the number of clients with a credit card and residing in Texas?
SELECT COUNT(*) FROM clients INNER JOIN accounts ON clients.client_id = accounts.client_id WHERE accounts.account_type = 'Credit Card' AND clients.state = 'Texas';
gretelai_synthetic_text_to_sql
CREATE TABLE organic_farms (id INT, country VARCHAR(50), region VARCHAR(50), no_farms INT, area_ha FLOAT); INSERT INTO organic_farms (id, country, region, no_farms, area_ha) VALUES (1, 'Kenya', 'Africa', 1000, 5678.9); INSERT INTO organic_farms (id, country, region, no_farms, area_ha) VALUES (2, 'Tanzania', 'Africa', 2...
What is the average area of organic farming per farm in 'Africa'?
SELECT AVG(area_ha/no_farms) FROM organic_farms WHERE region = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE products_ext(id INT, name TEXT, source_country TEXT, natural_ingredients BOOLEAN); INSERT INTO products_ext(id, name, source_country, natural_ingredients) VALUES (1, 'Cleanser X', 'US', true), (2, 'Lotion Y', 'France', true), (3, 'Shampoo Z', 'Australia', false), (4, 'Conditioner W', 'Canada', true), (5, '...
What percentage of products sourced from Australia have natural ingredients?
SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM products_ext WHERE source_country = 'Australia')) AS percentage FROM products_ext WHERE natural_ingredients = true AND source_country = 'Australia';
gretelai_synthetic_text_to_sql
CREATE TABLE Wells (well_id INT, location VARCHAR(50), depth INT, production_rate FLOAT); INSERT INTO Wells (well_id, location, depth, production_rate) VALUES (1, 'Oklahoma', 16000, 500), (2, 'Texas', 14000, 400), (3, 'Louisiana', 18000, 600), (4, 'Alabama', 15500, 450);
What is the production rate of wells with a depth greater than 15000 feet in the 'Wells' table, ordered by production rate in descending order?
SELECT production_rate FROM (SELECT well_id, location, depth, production_rate, ROW_NUMBER() OVER (ORDER BY production_rate DESC) as rank FROM Wells WHERE depth > 15000) AS wells_filtered WHERE rank <= 5;
gretelai_synthetic_text_to_sql
CREATE TABLE journalists (journalist_id INT, name TEXT, article_count INT);
Which journalists published the most articles in 2018?
SELECT name, article_count FROM journalists WHERE publish_date >= '2018-01-01' AND publish_date < '2019-01-01' ORDER BY article_count DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE unions (id INT, name TEXT, domain TEXT); INSERT INTO unions (id, name, domain) VALUES (1, 'National Nurses United', 'Healthcare'); INSERT INTO unions (id, name, domain) VALUES (2, 'Service Employees International Union', 'Healthcare, Public Services');
What is the total number of members in unions that have a focus on healthcare?
SELECT COUNT(*) FROM unions WHERE domain LIKE '%Healthcare%';
gretelai_synthetic_text_to_sql
CREATE TABLE ResourceDepletion (Operation VARCHAR(50), Resource VARCHAR(50), DepletionQuantity FLOAT); INSERT INTO ResourceDepletion(Operation, Resource, DepletionQuantity) VALUES ('Operation A', 'Coal', 12000), ('Operation A', 'Iron', 15000), ('Operation B', 'Coal', 10000), ('Operation B', 'Iron', 18000), ('Operation ...
What is the total amount of coal and iron depleted by each mining operation in the last quarter?
SELECT Operation, SUM(DepletionQuantity) FROM ResourceDepletion WHERE Resource IN ('Coal', 'Iron') AND DepletionQuantity >= 0 GROUP BY Operation;
gretelai_synthetic_text_to_sql
CREATE TABLE vessel_status (id INT PRIMARY KEY, vessel_id INT, status VARCHAR(50), timestamp TIMESTAMP);
What was the average waiting time in hours for vessels arriving at the Port of Singapore in Q1 2020?
SELECT AVG(TIMESTAMPDIFF(HOUR, vessel_status.timestamp, lead(vessel_status.timestamp) OVER (PARTITION BY vessel_id ORDER BY vessel_status.timestamp))) FROM vessel_status WHERE status = 'arrived' AND DATE(vessel_status.timestamp) BETWEEN '2020-01-01' AND '2020-03-31' GROUP BY vessel_id;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, name VARCHAR(50), region VARCHAR(20), account_balance DECIMAL(10,2)); INSERT INTO customers (customer_id, name, region, account_balance) VALUES (1, 'John Doe', 'South', 5000.00), (2, 'Jane Smith', 'North', 7000.00);
What is the third highest account balance for microfinance customers in the West region?
SELECT DISTINCT account_balance FROM (SELECT account_balance, ROW_NUMBER() OVER (PARTITION BY region ORDER BY account_balance DESC) as rn FROM customers WHERE region = 'West' AND product_type = 'Microfinance') as sub WHERE rn = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (vessel_id INT, name VARCHAR(50), certificate_expiration_date DATE);
Show vessels with outdated safety certifications before 2010
SELECT name FROM vessels WHERE certificate_expiration_date < '2010-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE smart_city_initiatives (initiative_id INT, country VARCHAR(50), city VARCHAR(100), status VARCHAR(50)); INSERT INTO smart_city_initiatives (initiative_id, country, city, status) VALUES (1, 'France', 'Paris', 'Implemented');
List all smart city initiatives that have been implemented in the European Union.
SELECT city, status FROM smart_city_initiatives WHERE country = 'European Union';
gretelai_synthetic_text_to_sql
CREATE TABLE VeteranEmployment (id INT, state VARCHAR(50), status VARCHAR(50), unemployed_date DATE); INSERT INTO VeteranEmployment (id, state, status, unemployed_date) VALUES (1, 'California', 'Unemployed', '2021-03-01');
List the number of veteran unemployed per state in March 2021
SELECT state, COUNT(*) FROM VeteranEmployment WHERE EXTRACT(MONTH FROM unemployed_date) = 3 AND EXTRACT(YEAR FROM unemployed_date) = 2021 AND status = 'Unemployed' GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE arctic_weather (date DATE, temperature FLOAT);
What is the average temperature recorded in the 'arctic_weather' table for each month in 2020?
SELECT AVG(temperature) FROM arctic_weather WHERE EXTRACT(YEAR FROM date) = 2020 GROUP BY EXTRACT(MONTH FROM date);
gretelai_synthetic_text_to_sql
CREATE TABLE sales_data (sale_id INT, product_id INT, sale_date DATE, organic BOOLEAN); INSERT INTO sales_data (sale_id, product_id, sale_date, organic) VALUES (1, 101, '2022-01-05', true), (2, 102, '2022-02-10', false), (3, 103, '2022-03-15', true);
Total sales of organic cosmetics by quarter?
SELECT DATEPART(quarter, sale_date) as quarter, SUM(CASE WHEN organic THEN 1 ELSE 0 END) as organic_sales FROM sales_data GROUP BY DATEPART(quarter, sale_date);
gretelai_synthetic_text_to_sql
CREATE TABLE incidents (id INT, vessel_id INT, type VARCHAR(50), date DATE); INSERT INTO incidents (id, vessel_id, type, date) VALUES (1, 1, 'Collision', '2021-03-15'); INSERT INTO incidents (id, vessel_id, type, date) VALUES (2, 1, 'Grounding', '2021-08-22'); INSERT INTO incidents (id, vessel_id, type, date) VALUES (3...
How many safety incidents were reported for each vessel type in 2021?
SELECT type as vessel_type, COUNT(*) as incident_count FROM incidents WHERE date >= '2021-01-01' AND date < '2022-01-01' GROUP BY vessel_type;
gretelai_synthetic_text_to_sql
CREATE TABLE wind_farms (id INT, country VARCHAR(255), name VARCHAR(255), capacity FLOAT, start_date DATE, end_date DATE); INSERT INTO wind_farms (id, country, name, capacity, start_date, end_date) VALUES (1, 'Germany', 'Windfarm A', 50.5, '2020-01-01', '2024-12-31');
Update the installed capacity of 'Windfarm A' in the 'wind_farms' table to 55.0, and also update its end_date to '2025-12-31'
UPDATE wind_farms SET capacity = 55.0, end_date = '2025-12-31' WHERE name = 'Windfarm A';
gretelai_synthetic_text_to_sql
CREATE TABLE visitors (id INT, age INT, gender TEXT, country TEXT);
Insert new records for visitors from Nigeria, South Africa, and Egypt into the visitors table
INSERT INTO visitors (id, age, gender, country) VALUES (7001, 28, 'Male', 'Nigeria'), (7002, 35, 'Female', 'South Africa'), (7003, 42, 'Male', 'Egypt');
gretelai_synthetic_text_to_sql
CREATE TABLE train_fares (fare_id INT, region_id INT, fare DECIMAL(5,2)); INSERT INTO train_fares (fare_id, region_id, fare) VALUES (1, 1, 3.50), (2, 2, 4.25), (3, 3, 3.75), (4, 2, 4.25);
What is the average fare for trains in the 'south' region?
SELECT AVG(tf.fare) FROM train_fares tf INNER JOIN regions r ON tf.region_id = r.region_id WHERE r.region_name = 'south';
gretelai_synthetic_text_to_sql
CREATE TABLE soldiers_personal_data (soldier_id INT, name VARCHAR(50), rank VARCHAR(50), departure_date DATE);
Update the name of soldier with ID 2001 to 'Emily Davis' in the soldiers_personal_data table
UPDATE soldiers_personal_data SET name = 'Emily Davis' WHERE soldier_id = 2001;
gretelai_synthetic_text_to_sql
CREATE TABLE spacecraft_launches (spacecraft_name VARCHAR(50), launch_year INT);
How many spacecraft were launched per year?
SELECT launch_year, COUNT(*) as num_launches FROM spacecraft_launches GROUP BY launch_year;
gretelai_synthetic_text_to_sql
CREATE TABLE broadband_customers (customer_id INT, monthly_revenue FLOAT, state VARCHAR(20)); INSERT INTO broadband_customers (customer_id, monthly_revenue, state) VALUES (11, 60, 'New York'), (12, 70, 'New York'), (13, 55, 'California'), (14, 65, 'Texas'), (15, 75, 'New York');
What is the total revenue generated from broadband services in the state of New York?
SELECT SUM(monthly_revenue) FROM broadband_customers WHERE state = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE donors (id INT, name TEXT); INSERT INTO donors (id, name) VALUES (1, 'John Doe'), (2, 'Jane Smith'), (3, 'Alice Johnson'), (4, 'Bob Williams'), (5, 'Charlie Brown'); CREATE TABLE donations (id INT, donor_id INT, amount INT, cause TEXT); INSERT INTO donations (id, donor_id, amount, cause) VALUES (1, 1, 500,...
List the top 5 donors by total donation amount in descending order for disaster relief in Haiti.
SELECT donors.name, SUM(donations.amount) AS total_donation FROM donors INNER JOIN donations ON donors.id = donations.donor_id WHERE donations.cause = 'Disaster relief in Haiti' GROUP BY donors.name ORDER BY total_donation DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE Products (ProductID INT, Halal BOOLEAN, IngredientCost DECIMAL(5,2)); INSERT INTO Products (ProductID, Halal, IngredientCost) VALUES (1, TRUE, 16.99), (2, FALSE, 11.49), (3, TRUE, 13.25);
What are the average ingredient costs for halal products?
SELECT AVG(IngredientCost) FROM Products WHERE Halal = TRUE;
gretelai_synthetic_text_to_sql
CREATE VIEW peacekeeping_view AS SELECT operation_id, name, location FROM peacekeeping_operations
Delete the 'peacekeeping_view' view
DROP VIEW peacekeeping_view
gretelai_synthetic_text_to_sql
CREATE TABLE movie (id INT, title VARCHAR(100), production_company VARCHAR(50), country VARCHAR(50)); CREATE TABLE tv_show (id INT, title VARCHAR(100), production_company VARCHAR(50), country VARCHAR(50)); INSERT INTO movie (id, title, production_company, country) VALUES (1, 'Movie1', 'ProductionCompany1', 'USA'); INSE...
Which production companies are based in the US and have produced both movies and TV shows?
SELECT production_company FROM movie INNER JOIN tv_show ON movie.production_company = tv_show.production_company WHERE movie.country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (ArtistID INT, Name VARCHAR(50), BirthDate DATE, DeathDate DATE, Movement VARCHAR(50)); INSERT INTO Artists (ArtistID, Name, BirthDate, DeathDate, Movement) VALUES (1, 'Salvador Dalí', '1904-05-11', '1989-01-23', 'Surrealism');
Insert a new artist from the Surrealist movement.
INSERT INTO Artists (ArtistID, Name, BirthDate, DeathDate, Movement) VALUES (2, 'Meret Oppenheim', '1913-10-06', '1985-11-15', 'Surrealism');
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (donor_id INT, donation_amount DECIMAL(10,2), donation_year INT, donor_country VARCHAR(50)); INSERT INTO Donations (donor_id, donation_amount, donation_year, donor_country) VALUES (1, 5000, 2021, 'USA'), (2, 7000, 2021, 'Canada'), (3, 6000, 2022, 'Mexico'), (4, 8000, 2022, 'Brazil');
Which countries had the highest total donations in 2021 and 2022?
SELECT donor_country, SUM(donation_amount) FROM Donations WHERE donation_year IN (2021, 2022) GROUP BY donor_country ORDER BY SUM(donation_amount) DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE customer_transactions (customer_id INT, transaction_city VARCHAR(20)); INSERT INTO customer_transactions (customer_id, transaction_city) VALUES (1, 'New York'), (2, 'London'), (3, 'New York'), (4, 'Paris'), (5, 'London');
Identify customers who made transactions in both New York and London.
SELECT customer_id FROM customer_transactions WHERE transaction_city IN ('New York', 'London') GROUP BY customer_id HAVING COUNT(DISTINCT transaction_city) = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE accessibility_training (region VARCHAR(20), training VARCHAR(30), participants INT); INSERT INTO accessibility_training (region, training, participants) VALUES ('Midwest', 'Accessibility Training', 100); INSERT INTO accessibility_training (region, training, participants) VALUES ('Midwest', 'Accessibility T...
What is the total number of employees who have completed accessibility training in the Midwest region?
SELECT region, SUM(participants) FROM accessibility_training WHERE region = 'Midwest' AND training = 'Accessibility Training';
gretelai_synthetic_text_to_sql
CREATE TABLE patients (patient_id INT, has_depression BOOLEAN, treatment_date DATE); INSERT INTO patients (patient_id, has_depression, treatment_date) VALUES (1, TRUE, '2021-01-01'), (2, FALSE, '2020-12-25'), (3, TRUE, '2022-03-15');
How many patients with depression were treated in India in the last year?
SELECT COUNT(*) FROM patients WHERE has_depression = TRUE AND treatment_date >= '2021-01-01' AND country = 'India';
gretelai_synthetic_text_to_sql
CREATE TABLE AstronautMedicalData (astronaut_name VARCHAR(30), country VARCHAR(20), medical_issues INT); INSERT INTO AstronautMedicalData (astronaut_name, country, medical_issues) VALUES ('Michael Johnson', 'Canada', 1), ('Jessica Smith', 'Australia', 1), ('Oliver Lee', 'UK', 1);
Which countries have astronauts with the fewest medical issues?
SELECT country, SUM(medical_issues) as total_issues FROM AstronautMedicalData GROUP BY country ORDER BY total_issues ASC;
gretelai_synthetic_text_to_sql
CREATE TABLE trials (id INT, drug_id INT, start_date DATE, end_date DATE, status VARCHAR(20)); INSERT INTO trials (id, drug_id, start_date, end_date, status) VALUES (1, 1, '2020-01-01', '2022-12-31', 'Completed'); CREATE TABLE drugs (id INT, name VARCHAR(50), company VARCHAR(50), indication VARCHAR(50)); INSERT INTO dr...
List all the drugs and their respective trials for completed trials in the neurology indication.
SELECT t.drug_id, d.name, COUNT(*) as trial_count FROM trials t JOIN drugs d ON t.drug_id = d.id WHERE t.status = 'Completed' AND d.indication = 'Neurology' GROUP BY t.drug_id
gretelai_synthetic_text_to_sql
CREATE TABLE department (name VARCHAR(255), id INT);CREATE TABLE professor (name VARCHAR(255), gender VARCHAR(255), department_id INT, grant_amount DECIMAL(10,2), publication_year INT);
What is the total number of research grants awarded to female professors in the Art department who have published at least two papers?
SELECT COUNT(DISTINCT p.name) FROM professor p WHERE p.gender = 'Female' AND p.department_id IN (SELECT id FROM department WHERE name = 'Art') AND p.publication_year IS NOT NULL GROUP BY p.name HAVING COUNT(p.publication_year) >= 2;
gretelai_synthetic_text_to_sql
CREATE TABLE community_policing (neighborhood VARCHAR(255), safety_score INT); INSERT INTO community_policing (neighborhood, safety_score) VALUES ('Pinewood', 80), ('Elmwood', 88), ('Maplewood', 92);
Update the community_policing table and add a new record for neighborhood 'Oakwood' with a score of 85
INSERT INTO community_policing (neighborhood, safety_score) VALUES ('Oakwood', 85);
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, Age INT); INSERT INTO Players (PlayerID, Age) VALUES (1, 20), (2, 25), (3, 18), (4, 30);
What is the minimum age of players who participate in esports events?
SELECT MIN(Age) FROM Players;
gretelai_synthetic_text_to_sql
CREATE TABLE tlad_orgs (org_name TEXT, loan_amount NUMERIC); INSERT INTO tlad_orgs (org_name, loan_amount) VALUES ('Socially Responsible India', 1000000), ('Lending with Care', 1500000), ('Fair Lending Foundation', 800000);
What is the total loan amount disbursed by socially responsible lending organizations in India?
SELECT SUM(loan_amount) FROM tlad_orgs WHERE org_name IN ('Socially Responsible India', 'Lending with Care', 'Fair Lending Foundation') AND country = 'India';
gretelai_synthetic_text_to_sql
CREATE TABLE vessel_safety (id INT, vessel_name VARCHAR(50), safety_rating INT);
Find the number of vessels and their corresponding safety inspection ratings in the 'vessel_safety' table
SELECT vessel_name, safety_rating FROM vessel_safety;
gretelai_synthetic_text_to_sql
CREATE TABLE legal_aid_alberta (court_location VARCHAR(50), date DATE); INSERT INTO legal_aid_alberta VALUES ('Edmonton', '2022-02-01'), ('Calgary', '2021-06-15'), ('Red Deer', '2020-09-03'); CREATE TABLE legal_aid_manitoba (court_location VARCHAR(50), date DATE); INSERT INTO legal_aid_manitoba VALUES ('Winnipeg', '202...
List the unique court locations where legal aid was provided in Alberta and Manitoba in the last 5 years.
SELECT DISTINCT court_location FROM legal_aid_alberta WHERE date >= DATE_SUB(CURRENT_DATE, INTERVAL 5 YEAR) UNION ALL SELECT DISTINCT court_location FROM legal_aid_manitoba WHERE date >= DATE_SUB(CURRENT_DATE, INTERVAL 5 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (id INT, name TEXT, rating FLOAT, country TEXT, has_spa BOOLEAN); INSERT INTO hotels (id, name, rating, country, has_spa) VALUES (1, 'Hotel Europa', 4.5, 'Italy', true), (2, 'Paris Palace', 4.7, 'France', false), (3, 'Berlin Spa Resort', 4.2, 'Germany', true);
What is the average rating of hotels in 'Europe' that have a spa?
SELECT AVG(rating) FROM hotels WHERE country LIKE 'Europe%' AND has_spa = true;
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_floors (id INT, region TEXT, point TEXT, depth INT); INSERT INTO ocean_floors (id, region, point, depth) VALUES (1, 'Indian Ocean', 'Java Trench', 8075), (2, 'Indian Ocean', 'Sunda Trench', 7450);
What is the maximum depth of any point in the Indian Ocean?
SELECT MAX(depth) FROM ocean_floors WHERE region = 'Indian Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE habitats (habitat_type VARCHAR(255), area_size FLOAT);
Show the average area size for each habitat type in the "habitats" table
SELECT habitat_type, AVG(area_size) as avg_area_size FROM habitats GROUP BY habitat_type;
gretelai_synthetic_text_to_sql
CREATE TABLE songs (id INT, title VARCHAR(255), artist_id INT, streams BIGINT); CREATE TABLE artists (id INT, country VARCHAR(255));
Find the number of streams for songs with 'love' in the title, for artists from Japan, in descending order by number of streams.
SELECT artist_id, SUM(streams) as total_streams FROM songs INNER JOIN artists ON songs.artist_id = artists.id WHERE title LIKE '%love%' AND country = 'Japan' GROUP BY artist_id ORDER BY total_streams DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE VesselTypes (id INT, vessel_type VARCHAR(50), capacity INT); CREATE TABLE CargoTransports (id INT, vessel_id INT, transport_weight INT, transport_time TIMESTAMP);
How many vessels transported liquefied natural gas in the Caribbean Sea in each month of 2021?
SELECT EXTRACT(MONTH FROM CT.transport_time) as month, COUNT(DISTINCT CT.vessel_id) as vessels_count FROM CargoTransports CT JOIN VesselTypes VT ON CT.vessel_id = VT.id WHERE VT.vessel_type = 'Liquefied Natural Gas Carrier' AND CT.transport_time > '2021-01-01' AND CT.transport_time < '2022-01-01' AND CT.latitude BETWEE...
gretelai_synthetic_text_to_sql
CREATE TABLE agricultural_projects (id INT PRIMARY KEY, name VARCHAR(100), location VARCHAR(50), funding_source VARCHAR(50), start_date DATE, end_date DATE); INSERT INTO agricultural_projects (id, name, location, funding_source, start_date, end_date) VALUES (1, 'Solar Powered Irrigation', 'Rural Kenya', 'World Bank', '...
Count of agricultural projects by funding source
SELECT funding_source, COUNT(*) FROM agricultural_projects GROUP BY funding_source;
gretelai_synthetic_text_to_sql
CREATE TABLE donors (id INT, donor_name VARCHAR(50), donation_amount DECIMAL(10, 2), country VARCHAR(50)); INSERT INTO donors (id, donor_name, donation_amount, country) VALUES (1, 'Li Mei', 800.00, 'China'); INSERT INTO donors (id, donor_name, donation_amount, country) VALUES (2, 'Raj Patel', 900.00, 'India');
Who are the top 3 donors from Asian countries?
SELECT donor_name, donation_amount FROM (SELECT donor_name, donation_amount, country, ROW_NUMBER() OVER (PARTITION BY country ORDER BY donation_amount DESC) as rank FROM donors WHERE country IN ('China', 'India', 'Japan', 'South Korea', 'Vietnam')) as donor_ranks WHERE rank <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Coral_Distribution (coral_species text, point_longitude numeric, point_latitude numeric, point_depth numeric);
Find the minimum depth at which corals are found in the Atlantic Ocean.
SELECT MIN(point_depth) FROM Coral_Distribution WHERE coral_species = 'Any Coral Species' AND point_longitude BETWEEN -90 AND -10 AND point_latitude BETWEEN 0 AND 60;
gretelai_synthetic_text_to_sql
CREATE TABLE affordable_housing (id INT, address VARCHAR(255), city VARCHAR(255), state VARCHAR(255)); INSERT INTO affordable_housing (id, address, city, state) VALUES (1, '789 Pine St', 'Seattle', 'WA'), (2, '321 Cedar Rd', 'Seattle', 'WA'), (3, '543 Elm Ave', 'Portland', 'OR');
How many properties are there in the 'affordable_housing' table for each city?
SELECT city, COUNT(*) FROM affordable_housing GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE diversity_metrics (company_name VARCHAR(100), founders_race VARCHAR(50), investments INT);
Identify the total number of investments in startups founded by BIPOC individuals
SELECT SUM(investments) FROM diversity_metrics WHERE founders_race LIKE '%BIPOC%';
gretelai_synthetic_text_to_sql
CREATE TABLE regions (region_id INT, name VARCHAR(255)); INSERT INTO regions (region_id, name) VALUES (1, 'Caribbean'); CREATE TABLE ports (port_id INT, name VARCHAR(255), region_id INT); INSERT INTO ports (port_id, name, region_id) VALUES (1, 'Caribbean Port 1', 1), (2, 'Caribbean Port 2', 1); CREATE TABLE vessel_stat...
How many vessels are currently docked at ports in the Caribbean region?
SELECT COUNT(DISTINCT vessel_id) FROM vessel_status vs JOIN ports p ON vs.port_id = p.port_id JOIN regions r ON p.region_id = r.region_id WHERE r.name = 'Caribbean' AND vs.status = 'Docked';
gretelai_synthetic_text_to_sql
CREATE TABLE fish_species (species_id INT PRIMARY KEY, species_name VARCHAR(50), conservation_status VARCHAR(20))
Get the conservation status of the bluefin tuna
SELECT conservation_status FROM fish_species WHERE species_name = 'bluefin tuna'
gretelai_synthetic_text_to_sql
MUSEUM_STORES(store_id, name, location, country_id); ARTIST(artist_id, name, gender, birth_place)
Update the location of museum stores if they are in the same country as the artist's birthplace
UPDATE MUSEUM_STORES SET location = ar.birth_place FROM MUSEUM_STORES ms INNER JOIN ARTIST ar ON ms.country_id = ar.country_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID int, Age int, Gender varchar(10), LastEsportsParticipation date); INSERT INTO Players (PlayerID, Age, Gender, LastEsportsParticipation) VALUES (1, 25, 'Female', '2021-06-01');
How many players identify as female and have participated in esports events in the last year?
SELECT COUNT(*) FROM Players WHERE Gender = 'Female' AND LastEsportsParticipation >= DATEADD(year, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE Crime (cid INT, year INT, category VARCHAR(255), location VARCHAR(255));
What is the total number of crimes reported in each location in 2021?
SELECT location, COUNT(*) FROM Crime WHERE year = 2021 GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE BeautyProducts (product_name VARCHAR(100), product_type VARCHAR(50), product_price DECIMAL(10, 2)); INSERT INTO BeautyProducts (product_name, product_type, product_price) VALUES ('Brightening Eye Serum', 'Face Cream', 75.00), ('Volumizing Shampoo', 'Shampoo', 24.50);
Show which beauty products have a higher price than the average face cream.
SELECT product_name, product_type, product_price FROM BeautyProducts WHERE product_price > (SELECT AVG(product_price) FROM BeautyProducts WHERE product_type = 'Face Cream');
gretelai_synthetic_text_to_sql
CREATE TABLE copper_extraction (id INT, mine TEXT, state TEXT, country TEXT, year INT, amount INT); INSERT INTO copper_extraction (id, mine, state, country, year, amount) VALUES (1, 'Copper Mine 1', 'Arizona', 'United States', 2015, 500); INSERT INTO copper_extraction (id, mine, state, country, year, amount) VALUES (2,...
What is the average amount of copper extracted per year in the state "Arizona" in the period 2015-2020?
SELECT AVG(amount) FROM copper_extraction WHERE state = 'Arizona' AND country = 'United States' AND year BETWEEN 2015 AND 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE rural_infrastructure (id INT, project_name VARCHAR(50), project_type VARCHAR(50), location VARCHAR(50), cost DECIMAL(10,2)); INSERT INTO rural_infrastructure VALUES (1, 'Solar Irrigation System', 'Agricultural Innovation', 'Village A', 25000.00); CREATE TABLE community_development (id INT, project_name VAR...
What are the total number of agricultural innovation projects in the 'rural_infrastructure' and 'community_development' tables?
SELECT COUNT(*) FROM (SELECT * FROM rural_infrastructure WHERE project_type = 'Agricultural Innovation' UNION ALL SELECT * FROM community_development WHERE project_type = 'Agricultural Innovation') AS combined_projects;
gretelai_synthetic_text_to_sql
CREATE TABLE policies (id INT, policy_id TEXT, system TEXT, description TEXT, last_updated DATE);INSERT INTO policies (id, policy_id, system, description, last_updated) VALUES (1, 'PS-001', 'firewall', 'Block all incoming traffic', '2021-01-03');
Rank policies for a system based on their last update date.
SELECT policy_id, system, description, last_updated, RANK() OVER (PARTITION BY system ORDER BY last_updated DESC) as rank FROM policies WHERE system = 'firewall';
gretelai_synthetic_text_to_sql
CREATE TABLE ArtSales4 (MuseumName TEXT, SaleDate DATE, NumPieces INTEGER, PricePerPiece FLOAT); INSERT INTO ArtSales4 (MuseumName, SaleDate, NumPieces, PricePerPiece) VALUES ('Metropolitan Museum', '2022-01-01', 5, 100.5), ('Metropolitan Museum', '2022-02-15', 8, 120.0), ('Metropolitan Museum', '2022-04-20', 12, 150.0...
What is the total revenue generated from art sales at the "Metropolitan Museum" in 2022?
SELECT SUM(NumPieces * PricePerPiece) FROM ArtSales4 WHERE MuseumName = 'Metropolitan Museum' AND YEAR(SaleDate) = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE departments (department_id INT, department_name TEXT); CREATE TABLE courses (course_id INT, course_name TEXT, department_id INT); CREATE TABLE enrollments (enrollment_id INT, student_id INT, course_id INT, enrollment_date DATE); INSERT INTO departments VALUES (1, 'Mathematics'), (2, 'Science'), (3, 'Englis...
What is the total number of students who have ever enrolled in a course offered by each department?
SELECT d.department_name, COUNT(DISTINCT e.student_id) FROM departments d INNER JOIN courses c ON d.department_id = c.department_id INNER JOIN enrollments e ON c.course_id = e.course_id GROUP BY d.department_id;
gretelai_synthetic_text_to_sql
CREATE TABLE solar_projects (id INT, name VARCHAR(255), energy_production FLOAT);
What's the total energy production from solar projects?
SELECT SUM(energy_production) FROM solar_projects;
gretelai_synthetic_text_to_sql
CREATE TABLE aquatic_farms (id INT, name TEXT, region TEXT); INSERT INTO aquatic_farms (id, name, region) VALUES (1, 'Farm A', 'Caribbean Sea'), (2, 'Farm B', 'Atlantic Ocean'), (3, 'Farm C', 'Caribbean Sea');
What are the names of aquatic farms in the 'Caribbean Sea' region?
SELECT DISTINCT aquatic_farms.name FROM aquatic_farms WHERE aquatic_farms.region = 'Caribbean Sea';
gretelai_synthetic_text_to_sql