context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE materials (id INT PRIMARY KEY, name VARCHAR(255), origin VARCHAR(255), recyclability_rating FLOAT); INSERT INTO materials (id, name, origin, recyclability_rating) VALUES (1, 'Recycled Plastic', 'USA', 4.7), (2, 'Reused Metal', 'USA', 4.5);
What is the average recyclability rating of materials from the USA?
SELECT AVG(recyclability_rating) FROM materials WHERE origin = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE brands (brand_id INT, brand TEXT); CREATE TABLE products (product_id INT, product_name TEXT, brand_id INT); INSERT INTO brands (brand_id, brand) VALUES (1, 'Brand A'); INSERT INTO brands (brand_id, brand) VALUES (2, 'Brand B'); INSERT INTO brands (brand_id, brand) VALUES (3, 'Brand C'); INSERT INTO products (product_id, product_name, brand_id) VALUES (1, 'Product 1', 1); INSERT INTO products (product_id, product_name, brand_id) VALUES (2, 'Product 2', 2); INSERT INTO products (product_id, product_name, brand_id) VALUES (3, 'Product 3', 3); INSERT INTO products (product_id, product_name, brand_id) VALUES (4, 'Product 4', 1); INSERT INTO products (product_id, product_name, brand_id) VALUES (5, 'Product 5', 2); INSERT INTO products (product_id, product_name, brand_id) VALUES (6, 'Product 6', 3); INSERT INTO products (product_id, product_name, brand_id) VALUES (7, 'Product 7', 1);
How many products does each brand offer?
SELECT brand_id, COUNT(*) FROM products GROUP BY brand_id;
gretelai_synthetic_text_to_sql
ARTIST(artist_id, name, gender)
Update the name of the artist if their name starts with 'Mr.'
UPDATE ARTIST SET name = SUBSTRING(name, 3, LEN(name)) WHERE name LIKE 'Mr.%';
gretelai_synthetic_text_to_sql
CREATE TABLE sales (item VARCHAR(20), size VARCHAR(5), date DATE); INSERT INTO sales (item, size, date) VALUES ('T-Shirt', 'XL', '2022-01-01'), ('Pants', 'XL', '2022-02-01');
How many size XL garments were sold in the last quarter?
SELECT COUNT(*) FROM sales WHERE size = 'XL' AND date >= '2022-04-01' AND date <= '2022-06-30';
gretelai_synthetic_text_to_sql
CREATE TABLE hotel_tech_adoptions (id INT, hotel_id INT, tech_type TEXT, installed_date DATE); CREATE TABLE hotels (id INT, name TEXT, city TEXT, country TEXT);
How many hotels in Sydney, Australia have adopted any form of AI technology?
SELECT COUNT(DISTINCT hta.hotel_id) FROM hotel_tech_adoptions hta INNER JOIN hotels h ON hta.hotel_id = h.id WHERE h.city = 'Sydney' AND h.country = 'Australia';
gretelai_synthetic_text_to_sql
CREATE TABLE investments (id INT, region VARCHAR(20), date DATE, amount FLOAT); INSERT INTO investments (id, region, date, amount) VALUES (1, 'Latin America', '2022-04-01', 50000), (2, 'North America', '2022-05-15', 75000), (3, 'Latin America', '2022-06-30', 60000);
What is the total investment amount in the 'Latin America' region in Q2 2022?
SELECT SUM(amount) FROM investments WHERE region = 'Latin America' AND date BETWEEN '2022-04-01' AND '2022-06-30';
gretelai_synthetic_text_to_sql
CREATE TABLE urban.buildings (city VARCHAR(255), energy_consumption INT); INSERT INTO urban.buildings (city, energy_consumption) VALUES ('CityA', 1200), ('CityA', 1500), ('CityB', 1700), ('CityB', 1300);
What is the average energy consumption of buildings in the 'urban' schema, grouped by city?
SELECT city, AVG(energy_consumption) FROM urban.buildings GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE inventory (id INT, material VARCHAR(255), color VARCHAR(255), size VARCHAR(255), quantity INT); INSERT INTO inventory (id, material, color, size, quantity) VALUES (3, 'Hemp', 'Natural', 'L', 75); INSERT INTO inventory (id, material, color, size, quantity) VALUES (4, 'Tencel', 'Ecru', 'M', 125);
What is the total quantity of sustainable materials in inventory, grouped by color?
SELECT i.color, SUM(i.quantity) as total_quantity FROM inventory i JOIN materials m ON i.material = m.material JOIN suppliers s ON m.supplier_id = s.id WHERE s.sustainable = true GROUP BY i.color;
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_offset_programs_greentrees (id INT, program_name VARCHAR(255), co2_offset FLOAT); INSERT INTO carbon_offset_programs_greentrees (id, program_name, co2_offset) VALUES (1, 'GreenTrees', 7000.0), (2, 'CleanAir', 3000.0);
What is the total CO2 offset (in metric tons) for carbon offset program 'GreenTrees'?
SELECT SUM(co2_offset) FROM carbon_offset_programs_greentrees WHERE program_name = 'GreenTrees';
gretelai_synthetic_text_to_sql
CREATE TABLE charging_stations (id INT, station_name VARCHAR(255), region VARCHAR(255), num_stalls INT);
What is the maximum number of charging stations in the 'charging_stations' table, grouped by their 'region' and 'num_stalls'?
SELECT region, num_stalls, MAX(id) FROM charging_stations GROUP BY region, num_stalls;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, FirstName VARCHAR(50), LastName VARCHAR(50), DonationDate DATE, Amount DECIMAL(10,2));
Update records of donors with the first name 'John' and add a $250 bonus donation made on Dec 31, 2022
UPDATE Donors SET DonationDate = '2022-12-31', Amount = Amount + 250 WHERE FirstName = 'John';
gretelai_synthetic_text_to_sql
CREATE TABLE climate_finance (id INT, project_type VARCHAR(20), finance_type VARCHAR(20), amount INT, finance_year INT); INSERT INTO climate_finance (id, project_type, finance_type, amount, finance_year) VALUES (1, 'Renewable Energy', 'Private Investments', 750000, 2021), (2, 'Energy Efficiency', 'Private Investments', 600000, 2021), (3, 'Renewable Energy', 'Private Investments', 900000, 2021);
What is the total amount of climate finance invested in renewable energy projects by private companies in 2021?
SELECT SUM(amount) FROM climate_finance WHERE project_type = 'Renewable Energy' AND finance_type = 'Private Investments' AND finance_year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE artworks (id INT, added_date DATE); INSERT INTO artworks (id, added_date) VALUES (1, '2021-01-01'), (2, '2021-02-15'), (3, '2020-12-31');
How many artworks were added to the collection in 2021?
SELECT COUNT(*) FROM artworks WHERE added_date >= '2021-01-01' AND added_date < '2022-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE production_costs ( id INT PRIMARY KEY, element VARCHAR(20), country VARCHAR(50), year INT, cost FLOAT );
What is the average production cost for each rare earth element in China and the US?
SELECT element, country, AVG(cost) as avg_cost FROM production_costs WHERE country IN ('China', 'US') GROUP BY element, country;
gretelai_synthetic_text_to_sql
CREATE TABLE orders (order_id INT, customer_id INT, order_date DATE); CREATE TABLE order_items (order_id INT, item_id INT, quantity INT, price FLOAT); CREATE TABLE menu (item_id INT, name TEXT, category TEXT, price FLOAT); INSERT INTO menu (item_id, name, category, price) VALUES (1, 'Scrambled Tofu', 'Breakfast', 6.0), (2, 'Pancakes', 'Breakfast', 4.5); INSERT INTO orders (order_id, customer_id, order_date) VALUES (1, 101, '2022-03-05'), (2, 102, '2022-03-12'), (3, 103, '2022-04-01'); INSERT INTO order_items (order_id, item_id, quantity, price) VALUES (1, 1, 1, 6.0), (1, 2, 3, 4.5), (2, 1, 2, 6.0);
How many customers ordered from the breakfast menu in March?
SELECT COUNT(DISTINCT o.customer_id) as total_customers FROM orders o JOIN order_items oi ON o.order_id = oi.order_id JOIN menu m ON oi.item_id = m.item_id WHERE m.category = 'Breakfast' AND o.order_date BETWEEN '2022-03-01' AND '2022-03-31';
gretelai_synthetic_text_to_sql
CREATE TABLE Maintenance (ID INT, OperatorID INT, MaintenanceDate DATE); INSERT INTO Maintenance (ID, OperatorID, MaintenanceDate) VALUES (1, 10001, '2021-02-15'), (2, 10002, '2021-03-01'), (3, 10001, '2021-06-20'), (4, 10003, '2021-12-31');
How many times did each operator perform maintenance in 2021?
SELECT OperatorID, COUNT(*) as MaintenanceCount FROM Maintenance WHERE MaintenanceDate >= '2021-01-01' AND MaintenanceDate < '2022-01-01' GROUP BY OperatorID;
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (hotel_id INT, hotel_name VARCHAR(50), city VARCHAR(50), rating DECIMAL(2,1));
List the average rating of hotels in each city
SELECT city, AVG(rating) as avg_rating FROM hotels GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE Research_Papers (Id INT, Author VARCHAR(255), Country VARCHAR(255), Title VARCHAR(255), Publication_Year INT, Autonomous_Driving_Research BOOLEAN); INSERT INTO Research_Papers (Id, Author, Country, Title, Publication_Year, Autonomous_Driving_Research) VALUES (1, 'Smith', 'USA', 'Paper 1', 2020, TRUE); INSERT INTO Research_Papers (Id, Author, Country, Title, Publication_Year, Autonomous_Driving_Research) VALUES (2, 'Johnson', 'Germany', 'Paper 2', 2019, FALSE); INSERT INTO Research_Papers (Id, Author, Country, Title, Publication_Year, Autonomous_Driving_Research) VALUES (3, 'Williams', 'UK', 'Paper 3', 2020, TRUE);
What is the total number of autonomous driving research papers published by authors from different countries?
SELECT Country, COUNT(*) AS Total_Papers FROM Research_Papers WHERE Autonomous_Driving_Research = TRUE GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_usage (customer_id INT, data_usage FLOAT, city VARCHAR(20), year INT); INSERT INTO mobile_usage (customer_id, data_usage, city, year) VALUES (1, 3.5, 'Sydney', 2022), (2, 4.2, 'New York', 2022), (3, 3.8, 'Sydney', 2022), (4, 5.1, 'Sydney', 2022);
What is the maximum data usage for a single mobile customer in the city of Sydney for the year 2022?
SELECT MAX(data_usage) FROM mobile_usage WHERE city = 'Sydney' AND year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE restaurants (restaurant_id INT, name VARCHAR(50), location VARCHAR(50)); INSERT INTO restaurants (restaurant_id, name, location) VALUES (3, 'Eco-friendly Eats', 'Los Angeles'), (4, 'Healthy Bites', 'New York');
Update the location of 'Eco-friendly Eats' to 'San Francisco' if the current location is 'Los Angeles'.
UPDATE restaurants SET location = 'San Francisco' WHERE name = 'Eco-friendly Eats' AND location = 'Los Angeles';
gretelai_synthetic_text_to_sql
CREATE TABLE flu_shots (patient_id INT, state VARCHAR(255)); CREATE TABLE patients (patient_id INT, age INT); INSERT INTO flu_shots (patient_id, state) VALUES (1, 'New York'); INSERT INTO patients (patient_id, age) VALUES (1, 30);
What is the total number of flu shots administered in New York?
SELECT COUNT(*) FROM flu_shots WHERE state = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE sales (sale_id INT, product_id INT, quantity INT, sale_price DECIMAL(5,2), has_allergen BOOLEAN); INSERT INTO sales (sale_id, product_id, quantity, sale_price, has_allergen) VALUES (1, 1, 3, 19.99, true); INSERT INTO sales (sale_id, product_id, quantity, sale_price, has_allergen) VALUES (2, 2, 1, 29.99, false);
Calculate the total revenue of cosmetics sold to consumers in Asia with a known allergen.
SELECT SUM(quantity * sale_price) FROM sales WHERE has_allergen = true;
gretelai_synthetic_text_to_sql
CREATE TABLE NigerianRuralPhysicians (PhysicianName VARCHAR(50), PatientsSeen INT); INSERT INTO NigerianRuralPhysicians (PhysicianName, PatientsSeen) VALUES ('Physician A', 25), ('Physician B', 30), ('Physician C', 35), ('Physician D', 40);
What is the maximum number of patients seen in a day by a rural physician in Nigeria?
SELECT MAX(PatientsSeen) FROM NigerianRuralPhysicians;
gretelai_synthetic_text_to_sql
CREATE TABLE Vendors (id INT, name VARCHAR(255), last_inspection DATE); CREATE TABLE Regulations (id INT, regulation VARCHAR(255), last_updated DATE);
Which vendors have not complied with the food safety regulations in the last year?
SELECT v.name FROM Vendors v WHERE v.last_inspection < (SELECT MAX(r.last_updated) FROM Regulations r WHERE r.regulation = 'Food Safety');
gretelai_synthetic_text_to_sql
CREATE TABLE rural_innovations (id INT, project_name VARCHAR(50), funding_org VARCHAR(50)); INSERT INTO rural_innovations (id, project_name, funding_org) VALUES (1, 'Precision Agriculture', 'InnovateAfrica'), (2, 'Smart Greenhouses', 'GrowMoreFund'); CREATE TABLE rural_infrastructure (id INT, project_name VARCHAR(50), funding_org VARCHAR(50)); INSERT INTO rural_infrastructure (id, project_name, funding_org) VALUES (1, 'Irrigation System Upgrade', 'InnovateAfrica'), (2, 'Rural Road Expansion', 'GrowMoreFund');
Identify the agricultural innovation projects in the 'rural_innovations' table that have different funding organizations than any rural infrastructure projects in the 'rural_infrastructure' table.
SELECT project_name FROM rural_innovations WHERE funding_org NOT IN (SELECT funding_org FROM rural_infrastructure);
gretelai_synthetic_text_to_sql
CREATE TABLE young_trees (id INT, species VARCHAR(255), age INT); INSERT INTO young_trees (id, species, age) VALUES (1, 'Oak', 15), (2, 'Maple', 20), (3, 'Pine', 12);
What is the average age of trees in the 'young_trees' table?
SELECT AVG(age) FROM young_trees;
gretelai_synthetic_text_to_sql
CREATE TABLE Defense_Projects(id INT, project_name VARCHAR(255), start_year INT, end_year INT); INSERT INTO Defense_Projects(id, project_name, start_year, end_year) VALUES (1, 'Project A', 2015, 2018), (2, 'Project B', 2016, 2019), (3, 'Project C', 2017, 2020), (4, 'Project D', 2018, 2021), (5, 'Project E', 2015, 2020), (6, 'Project F', 2016, 2017);
Insert a new defense project 'Project G' with a start year of 2019 and an end year of 2022.
INSERT INTO Defense_Projects(project_name, start_year, end_year) VALUES ('Project G', 2019, 2022);
gretelai_synthetic_text_to_sql
CREATE TABLE astrophysics_research (id INT PRIMARY KEY, project_name VARCHAR(50), temperature FLOAT);
What are the average and maximum temperatures recorded in each astrophysics research project?
SELECT project_name, AVG(temperature) as avg_temperature, MAX(temperature) as max_temperature FROM astrophysics_research GROUP BY project_name;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, EmployeeName VARCHAR(50), Department VARCHAR(50), Salary DECIMAL(10,2), PromotionDate DATE); INSERT INTO Employees (EmployeeID, EmployeeName, Department, Salary, PromotionDate) VALUES (1, 'John Doe', 'IT', 70000, '2022-01-01'), (2, 'Jane Smith', 'IT', 85000, NULL), (3, 'Mike Johnson', 'HR', 60000, '2022-06-01'), (4, 'Sara Brown', 'HR', 65000, NULL);
Calculate the average salary increase for employees who have received a promotion in the last year, and the average salary increase for employees who have not received a promotion.
SELECT CASE WHEN PromotionDate IS NOT NULL THEN 'Promoted' ELSE 'Not Promoted' END AS PromotionStatus, AVG(Salary - LAG(Salary) OVER (PARTITION BY EmployeeID ORDER BY PromotionDate)) AS AverageSalaryIncrease FROM Employees WHERE PromotionDate IS NOT NULL OR DATEADD(YEAR, -1, GETDATE()) <= PromotionDate GROUP BY PromotionStatus;
gretelai_synthetic_text_to_sql
CREATE TABLE Inventory (inventory_id INT, product_id INT, name VARCHAR(255), quantity INT, price DECIMAL(5,2), type VARCHAR(255));
Update the price of all organic vegetables in the inventory of GreenMarket to $0.99 per pound.
UPDATE Inventory SET price = 0.99 WHERE type = 'organic vegetables';
gretelai_synthetic_text_to_sql
CREATE TABLE equipment_maintenance (request_id INT, priority INT, equipment_type VARCHAR(50)); INSERT INTO equipment_maintenance (request_id, priority, equipment_type) VALUES (1, 4, 'M1 Abrams'), (2, 5, 'HMMWV'), (3, 3, 'CH-47 Chinook');
Display the total number of military equipment maintenance requests, categorized by priority level, for equipment types starting with the letter 'H'.
SELECT priority, COUNT(*) as num_requests FROM equipment_maintenance WHERE equipment_type LIKE 'H%' GROUP BY priority;
gretelai_synthetic_text_to_sql
CREATE TABLE animal_population (species VARCHAR(10), population INT); INSERT INTO animal_population (species, population) VALUES ('tiger', 2000), ('lion', 1500), ('elephant', 5000);
Add a new animal record for a 'giraffe' with a population of 1200 in the 'animal_population' table
INSERT INTO animal_population (species, population) VALUES ('giraffe', 1200);
gretelai_synthetic_text_to_sql
CREATE TABLE MedicalSupplies (id INT, supply_type VARCHAR(50), quantity INT, delivery_date DATE, destination_country VARCHAR(50), camp_name VARCHAR(50)); INSERT INTO MedicalSupplies (id, supply_type, quantity, delivery_date, destination_country, camp_name) VALUES (1, 'Bandages', 100, '2022-02-15', 'Turkey', 'Camp1');
What is the total amount of medical supplies delivered to refugee camps in Turkey between January 1st and March 31st, 2022?
SELECT SUM(MedicalSupplies.quantity) AS total_supplies FROM MedicalSupplies WHERE MedicalSupplies.destination_country = 'Turkey' AND MedicalSupplies.delivery_date BETWEEN '2022-01-01' AND '2022-03-31' AND MedicalSupplies.camp_name IS NOT NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE world_heritage_sites (site_id INT, name TEXT, location TEXT, country TEXT, is_virtual BOOLEAN); INSERT INTO world_heritage_sites (site_id, name, location, country, is_virtual) VALUES (1, 'Machu Picchu', 'Cusco', 'Peru', FALSE);
Find the UNESCO World Heritage sites with virtual tours.
SELECT name FROM world_heritage_sites WHERE is_virtual = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE policies (id INT, policyholder_id INT, state TEXT); INSERT INTO policies (id, policyholder_id, state) VALUES (1, 1, 'CA'); INSERT INTO policies (id, policyholder_id, state) VALUES (2, 2, 'CA'); INSERT INTO policies (id, policyholder_id, state) VALUES (3, 3, 'NY');
What is the number of policies issued per state?
SELECT state, COUNT(*) FROM policies GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE MaterialSources (material_name TEXT, source_country TEXT, quantity INT); INSERT INTO MaterialSources (material_name, source_country, quantity) VALUES ('Material1', 'Country1', 500), ('Material2', 'Country2', 700), ('Material3', 'Country1', 300);
What is the total quantity of materials sourced from each country?
SELECT source_country, SUM(quantity) as total_quantity FROM MaterialSources GROUP BY source_country;
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_rates (city VARCHAR(255), quarter INT, material_type VARCHAR(255), recycling_rate DECIMAL(5,2));
Insert a new record for recycling rates in the city of Miami for the third quarter of 2021, with 50% for plastic, 65% for glass, and 75% for paper.
INSERT INTO recycling_rates (city, quarter, material_type, recycling_rate) VALUES ('Miami', 3, 'Plastic', 50), ('Miami', 3, 'Glass', 65), ('Miami', 3, 'Paper', 75);
gretelai_synthetic_text_to_sql
CREATE TABLE ticket_sales_by_date (sale_id INT, sale_date DATE, ticket_type VARCHAR(255), price DECIMAL(5,2)); INSERT INTO ticket_sales_by_date (sale_id, sale_date, ticket_type, price) VALUES (1, '2021-01-01', 'VIP', 200), (2, '2021-02-01', 'Regular', 100), (3, '2021-03-01', 'VIP', 250), (4, '2021-04-01', 'Regular', 150), (5, '2021-05-01', 'VIP', 300);
What is the average ticket price for each quarter in the year 2021?
SELECT EXTRACT(QUARTER FROM sale_date) as quarter, AVG(price) as avg_price FROM ticket_sales_by_date WHERE sale_date >= '2021-01-01' AND sale_date <= '2021-12-31' GROUP BY quarter;
gretelai_synthetic_text_to_sql
CREATE TABLE cities (id INT, name VARCHAR(255), country VARCHAR(255)); INSERT INTO cities (id, name, country) VALUES (1, 'New York', 'USA'), (2, 'Los Angeles', 'USA'), (3, 'London', 'UK'); CREATE TABLE properties (id INT, city_id INT, size INT); INSERT INTO properties (id, city_id, size) VALUES (1, 1, 1500), (2, 1, 2000), (3, 2, 1800), (4, 2, 2200), (5, 3, 1200), (6, 3, 1000);
What is the average property size for each city?
SELECT c.name, AVG(p.size) as avg_size FROM cities c JOIN properties p ON c.id = p.city_id GROUP BY c.id;
gretelai_synthetic_text_to_sql
CREATE TABLE co_projects (square_footage INT, sustainable_materials BOOLEAN, project_count INT); INSERT INTO co_projects (square_footage, sustainable_materials, project_count) VALUES (1000, FALSE, 2000), (2000, FALSE, 2500), (3000, TRUE, 3000), (4000, TRUE, 3500);
What was the total square footage of construction projects in Colorado that used sustainable materials?
SELECT SUM(square_footage) FROM co_projects WHERE sustainable_materials = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (ArtistID INT, Name VARCHAR(100), Nationality VARCHAR(50), BirthYear INT, DeathYear INT);
Insert a new artist
INSERT INTO Artists (ArtistID, Name, Nationality, BirthYear, DeathYear) VALUES (2, 'Frida Kahlo', 'Mexican', 1907, 1954);
gretelai_synthetic_text_to_sql
CREATE TABLE container_receipts (id INT, container_id INT, receipt_date DATE, PRIMARY KEY(id));
How many containers were received in the month of August for the past two years in the 'container_receipts' table?
SELECT COUNT(*) FROM container_receipts WHERE MONTH(receipt_date) = 8 AND YEAR(receipt_date) BETWEEN YEAR(NOW()) - 2 AND YEAR(NOW());
gretelai_synthetic_text_to_sql
CREATE TABLE state_members (id INT, state VARCHAR(255), union_count INT); INSERT INTO state_members (id, state, union_count) VALUES (1, 'New York', 50000), (2, 'California', 60000), (3, 'Pennsylvania', 40000);
List the top 3 states with the most union members.
SELECT state, union_count FROM state_members ORDER BY union_count DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE concert_events (id INT, artist VARCHAR(255), city VARCHAR(255), event_date DATE, ticket_price DECIMAL(10,2));
Delete all concert events in Miami.
WITH deleted_rows AS (DELETE FROM concert_events WHERE city = 'Miami' RETURNING *) SELECT * FROM deleted_rows;
gretelai_synthetic_text_to_sql
CREATE TABLE skincare_sales(brand VARCHAR(255), region VARCHAR(255), sales FLOAT); INSERT INTO skincare_sales(brand, region, sales) VALUES('B brand', 'California', 12000), ('C brand', 'California', 8000), ('D brand', 'California', 15000);
Which organic skincare brands are available in the California region with sales greater than $10,000?
SELECT brand FROM skincare_sales WHERE region = 'California' AND sales > 10000 AND brand LIKE '%organic%';
gretelai_synthetic_text_to_sql
CREATE TABLE clients (id INT PRIMARY KEY, name VARCHAR(255), age INT, city VARCHAR(255), account_id INT, balance DECIMAL(10,2)); INSERT INTO clients (id, name, age, city, account_id, balance) VALUES (1001, 'Jacob Smith', 34, 'New York', 1, 5000.00), (1002, 'Sophia Johnson', 45, 'Los Angeles', 2, 25000.00), (1003, 'Ethan Williams', 29, 'Chicago', 3, 8000.00), (1004, 'Aria Patel', 36, 'Toronto', 4, 12000.00), (1005, 'Mateo Davis', 42, 'Miami', 5, 22000.00);
List all clients who have accounts with a balance greater than $20,000 and their account balance.
SELECT c.name, c.balance FROM clients c WHERE c.balance > 20000.00;
gretelai_synthetic_text_to_sql
CREATE TABLE total_projects (project_id INT, name VARCHAR(50), location VARCHAR(50), capacity_mw FLOAT); INSERT INTO total_projects (project_id, name, location, capacity_mw) VALUES (1, 'Australia Project 1', 'Australia', 20.0);
Determine the total installed capacity of projects in Australia
SELECT SUM(capacity_mw) FROM total_projects WHERE location = 'Australia';
gretelai_synthetic_text_to_sql
CREATE TABLE concerts (event_id INT, event_name VARCHAR(50), location VARCHAR(50), date DATE, ticket_price DECIMAL(5,2), num_tickets INT, city VARCHAR(50)); CREATE TABLE fans (fan_id INT, fan_name VARCHAR(50), age INT, city VARCHAR(50), state VARCHAR(50), country VARCHAR(50));
What is the total revenue for each event by city in the 'concerts' and 'fans' tables?
SELECT event_name, city, SUM(ticket_price * num_tickets) as total_revenue FROM concerts c JOIN fans f ON c.city = f.city GROUP BY event_name, city;
gretelai_synthetic_text_to_sql
CREATE TABLE ai_adoption (year INT, hospitality_ai INT, general_ai INT); INSERT INTO ai_adoption (year, hospitality_ai, general_ai) VALUES (2018, 10, 20), (2019, 20, 30), (2020, 30, 50);
What is the trend of AI adoption in the hospitality industry?
SELECT year, (hospitality_ai / general_ai) * 100 as hospitality_ai_trend FROM ai_adoption;
gretelai_synthetic_text_to_sql
CREATE TABLE cotton_sources (source_id INT, source_country TEXT, source_quantity INT);
What is the total quantity of cotton sourced from India?
SELECT SUM(source_quantity) AS total_cotton_quantity FROM cotton_sources WHERE source_country = 'India'
gretelai_synthetic_text_to_sql
CREATE TABLE energy_storage (state VARCHAR(50), technology VARCHAR(50), capacity_mwh FLOAT); INSERT INTO energy_storage (state, technology, capacity_mwh) VALUES ('Texas', 'Pumped Hydro', 4000), ('Texas', 'Utility-scale Batteries', 1000), ('Texas', 'Flywheels', 150), ('Texas', 'Compressed Air Energy Storage', 700);
What is the total energy storage capacity in MWh for pumped hydro in Texas?
SELECT SUM(capacity_mwh) FROM energy_storage WHERE state = 'Texas' AND technology = 'Pumped Hydro';
gretelai_synthetic_text_to_sql
CREATE TABLE worker_salaries (id INT, gender VARCHAR(10), industry VARCHAR(50), region VARCHAR(50), years_of_experience INT, salary DECIMAL(10,2)); INSERT INTO worker_salaries (id, gender, industry, region, years_of_experience, salary) VALUES (1, 'Female', 'Renewable Energy', 'Europe', 6, 55000.00), (2, 'Male', 'Renewable Energy', 'Europe', 3, 52000.00), (3, 'Female', 'Renewable Energy', 'Europe', 7, 60000.00), (4, 'Male', 'Renewable Energy', 'Asia', 8, 65000.00), (5, 'Female', 'Renewable Energy', 'Europe', 2, 48000.00);
What is the average salary of female workers in the renewable energy sector in Europe with more than 5 years of experience?
SELECT AVG(salary) FROM worker_salaries WHERE gender = 'Female' AND industry = 'Renewable Energy' AND region = 'Europe' AND years_of_experience > 5;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists biotech;CREATE TABLE if not exists biotech.startups (id INT, name VARCHAR(50), sector VARCHAR(50), total_funding DECIMAL(10,2)); INSERT INTO biotech.startups (id, name, sector, total_funding) VALUES (1, 'StartupD', 'Genetic Research', 7000000.00), (2, 'StartupE', 'Biosensor Technology', 2000000.00), (3, 'StartupF', 'Bioprocess Engineering', 4000000.00);
What is the total funding for startups in the 'Genetic Research' sector?
SELECT SUM(total_funding) FROM biotech.startups WHERE sector = 'Genetic Research';
gretelai_synthetic_text_to_sql
CREATE TABLE programs (id INT, name VARCHAR(50), budget DECIMAL(10,2));
Identify the top 3 programs with the highest total budget
SELECT p.name, p.budget as total_budget FROM programs p ORDER BY total_budget DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE company (id INT, name TEXT, CEO_gender TEXT, CEO_ethnicity TEXT); INSERT INTO company (id, name, CEO_gender, CEO_ethnicity) VALUES (1, 'TechFuturo', 'male', 'Latinx'); INSERT INTO company (id, name, CEO_gender, CEO_ethnicity) VALUES (2, 'EcoVida', 'female', 'Latinx'); CREATE TABLE funding_round (company_id INT, round_amount INT); INSERT INTO funding_round (company_id, round_amount) VALUES (1, 7000000); INSERT INTO funding_round (company_id, round_amount) VALUES (2, 9000000);
What is the total funding raised by startups with a Latinx CEO?
SELECT SUM(funding_round.round_amount) FROM company JOIN funding_round ON company.id = funding_round.company_id WHERE company.CEO_ethnicity = 'Latinx';
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_depths (ocean TEXT, max_depth FLOAT, min_depth FLOAT); INSERT INTO ocean_depths (ocean, max_depth, min_depth) VALUES ('Pacific Ocean', 10994.0, 4283.0); INSERT INTO ocean_depths (ocean, max_depth, min_depth) VALUES ('Atlantic Ocean', 9218.0, 200.0); INSERT INTO ocean_depths (ocean, max_depth, min_depth) VALUES ('Indian Ocean', 7258.0, 2500.0);
What are the maximum and minimum depths of all oceans?
SELECT ocean, max_depth, min_depth FROM ocean_depths;
gretelai_synthetic_text_to_sql
CREATE TABLE network_investments (investment_id INT, vendor VARCHAR(100), investment_date DATE);
Which network equipment vendors have the most investments in the last 5 years, excluding investments made in the current year?
SELECT vendor, COUNT(investment_id) AS total_investments FROM network_investments WHERE investment_date >= DATE_SUB(CURRENT_DATE, INTERVAL 5 YEAR) AND investment_date < CURRENT_DATE GROUP BY vendor ORDER BY total_investments DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE vehicles (vehicle_id varchar(255), vehicle_type varchar(255), purchase_date date); INSERT INTO vehicles (vehicle_id, vehicle_type, purchase_date) VALUES ('V1', 'Bus', '2022-06-01'), ('V2', 'Bus', '2022-07-15'), ('V3', 'Train', '2022-06-30'), ('V4', 'Tram', '2022-07-31');
How many vehicles were added to the fleet in the month of July?
SELECT COUNT(*) FROM vehicles WHERE EXTRACT(MONTH FROM purchase_date) = 7;
gretelai_synthetic_text_to_sql
CREATE TABLE timber_production (id INT, region VARCHAR(255), volume FLOAT); INSERT INTO timber_production (id, region, volume) VALUES (1, 'Northwest', 1234.56), (2, 'Southeast', 789.12), (3, 'Northwest', 456.34);
What is the average volume of timber in the timber_production table?
SELECT AVG(volume) FROM timber_production;
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_sequestration (sequestration_id INT, species VARCHAR(50), co2_sequestration FLOAT);
Find the top 3 species with the highest CO2 sequestration in the carbon_sequestration table?
SELECT species, MAX(co2_sequestration) FROM carbon_sequestration GROUP BY species ORDER BY co2_sequestration DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE StorageUnits (id INT, location VARCHAR(50), temperature FLOAT); INSERT INTO StorageUnits (id, location, temperature) VALUES (1, 'India', 32.5), (2, 'Australia', 28.3), (3, 'India', 30.8);
What is the average temperature (in Celsius) for all chemical storage units located in India, for the month of May?
SELECT AVG(temperature) FROM StorageUnits WHERE location = 'India' AND EXTRACT(MONTH FROM DATE '2022-05-01' + INTERVAL id DAY) = 5;
gretelai_synthetic_text_to_sql
CREATE TABLE defense_contracts (contract_id INT, company_name TEXT, state TEXT, contract_value FLOAT); INSERT INTO defense_contracts (contract_id, company_name, state, contract_value) VALUES (1, 'ABC Corp', 'Texas', 5000000), (2, 'DEF Inc', 'California', 7000000), (3, 'GHI Ltd', 'New York', 6000000), (4, 'JKL Co', 'Florida', 4000000), (5, 'MNO Inc', 'Illinois', 3000000);
Find the top 5 states with the highest defense contract value
SELECT state, SUM(contract_value) AS total_contract_value FROM defense_contracts GROUP BY state ORDER BY total_contract_value DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE CommunityHealthWorker (WorkerID INT, State CHAR(2), CulturalCompetencyScore INT); INSERT INTO CommunityHealthWorker (WorkerID, State, CulturalCompetencyScore) VALUES (1, 'CA', 85), (2, 'TX', 80), (3, 'CA', 90), (4, 'TX', 82);
Determine the change in cultural competency scores between two consecutive community health workers in each state.
SELECT State, CulturalCompetencyScore - LAG(CulturalCompetencyScore) OVER (PARTITION BY State ORDER BY WorkerID) AS Change FROM CommunityHealthWorker;
gretelai_synthetic_text_to_sql
CREATE TABLE vessel_performance (id INT, vessel_name VARCHAR(50), speed FLOAT); INSERT INTO vessel_performance (id, vessel_name, speed) VALUES (1, 'VesselA', 15.5), (2, 'VesselB', 18.2), (3, 'VesselC', 17.3);
What is the maximum speed of a vessel in the 'vessel_performance' table?
SELECT MAX(speed) FROM vessel_performance;
gretelai_synthetic_text_to_sql
CREATE TABLE initiatives (initiative_id INT, initiative_name VARCHAR(255), initiative_type VARCHAR(255));CREATE VIEW open_pedagogy_initiatives AS SELECT * FROM initiatives WHERE initiative_type = 'Open Pedagogy';
List all initiatives that are not open pedagogy
SELECT * FROM initiatives WHERE initiative_id NOT IN (SELECT initiative_id FROM open_pedagogy_initiatives);
gretelai_synthetic_text_to_sql
CREATE TABLE events (event_id INT, name VARCHAR(255), city VARCHAR(255), price DECIMAL(5,2)); INSERT INTO events (event_id, name, city, price) VALUES (1, 'Basketball Game', 'New York', 120.50), (2, 'Baseball Game', 'New York', 35.00);
What is the average ticket price for basketball events in New York?
SELECT AVG(price) FROM events WHERE city = 'New York' AND name LIKE '%Basketball%';
gretelai_synthetic_text_to_sql
CREATE TABLE aircraft_maintenance (id INT, aircraft_type VARCHAR(50), maintenance_activity VARCHAR(100));
What are the maintenance activities for military aircraft?
SELECT maintenance_activity FROM aircraft_maintenance WHERE aircraft_type IN (SELECT aircraft_type FROM military_equipment WHERE equipment_category = 'Aircraft');
gretelai_synthetic_text_to_sql
CREATE TABLE nba_teams (team_id INT, team_name VARCHAR(100), avg_score DECIMAL(5,2));
What is the average score of all basketball teams in the 'nba_teams' table?
SELECT AVG(avg_score) FROM nba_teams;
gretelai_synthetic_text_to_sql
CREATE TABLE texas_cities (city_id INT, name VARCHAR(255)); INSERT INTO texas_cities (city_id, name) VALUES (1, 'Houston'), (2, 'San Antonio'), (3, 'Dallas'); CREATE TABLE emergency_calls (call_id INT, city_id INT, response_time INT); INSERT INTO emergency_calls (call_id, city_id, response_time) VALUES (1, 1, 15), (2, 2, 10), (3, 1, 20), (4, 3, 12);
What is the average response time to emergency calls in each city in Texas?
SELECT city_id, name, AVG(response_time) as avg_response_time FROM emergency_calls ec JOIN texas_cities tc ON ec.city_id = tc.city_id GROUP BY city_id, name;
gretelai_synthetic_text_to_sql
CREATE TABLE museums (museum_id INT, city_id INT, num_artifacts INT); CREATE TABLE cities (city_id INT, city_name VARCHAR(255)); INSERT INTO cities VALUES (1, 'Paris'), (2, 'New York'), (3, 'Tokyo'); INSERT INTO museums VALUES (1, 1, 5000), (2, 1, 3000), (3, 2, 8000), (4, 2, 9000), (5, 3, 6000), (6, 3, 7000);
What is the average number of artifacts in museums per city?
SELECT AVG(num_artifacts) FROM museums JOIN cities ON museums.city_id = cities.city_id;
gretelai_synthetic_text_to_sql
CREATE TABLE department_data (department VARCHAR(255), budget INT, year INT); INSERT INTO department_data VALUES ('Department A', 5000000, 2021), ('Department B', 7000000, 2021), ('Department C', 3000000, 2021);
What is the minimum budget for each department in 2021?
SELECT department, MIN(budget) FROM department_data WHERE year = 2021 GROUP BY department;
gretelai_synthetic_text_to_sql
CREATE TABLE students_projects (student_id INT, project_id INT); INSERT INTO students_projects (student_id, project_id) VALUES (1, 201), (2, 201), (3, 202), (4, 202), (5, 203); CREATE TABLE projects (project_id INT, project_name VARCHAR(50)); INSERT INTO projects (project_id, project_name) VALUES (201, 'Math Olympiad'), (202, 'Science Fair'), (203, 'History Day');
What is the number of unique students participating in open pedagogy projects per project?
SELECT projects.project_name, COUNT(DISTINCT students_projects.student_id) as unique_students FROM students_projects JOIN projects ON students_projects.project_id = projects.project_id GROUP BY projects.project_name;
gretelai_synthetic_text_to_sql
CREATE TABLE open_pedagogy_enrollment (student_id INT, course_id INT, enrollment_date DATE); INSERT INTO open_pedagogy_enrollment VALUES (1, 101, '2022-08-01'), (2, 102, '2022-08-02'); CREATE TABLE open_pedagogy_courses (course_id INT, course_name VARCHAR(50)); INSERT INTO open_pedagogy_courses VALUES (101, 'Open Source Software'), (102, 'Data Science');
Which open pedagogy courses have the highest student enrollment rate in the current month?
SELECT course_name, COUNT(DISTINCT student_id) OVER (PARTITION BY course_id ORDER BY COUNT(DISTINCT student_id) DESC) as rank FROM open_pedagogy_enrollment JOIN open_pedagogy_courses ON open_pedagogy_enrollment.course_id = open_pedagogy_courses.course_id WHERE MONTH(enrollment_date) = MONTH(CURRENT_DATE) AND YEAR(enrollment_date) = YEAR(CURRENT_DATE);
gretelai_synthetic_text_to_sql
CREATE TABLE fish_stock (species VARCHAR(50), water_temp DECIMAL(5,2)); CREATE TABLE weather_data (species VARCHAR(50), air_temp DECIMAL(5,2));
What is the difference between the water temperature and air temperature for each fish species?
SELECT f.species, (f.water_temp - w.air_temp) as temp_difference FROM fish_stock f INNER JOIN weather_data w ON f.species = w.species;
gretelai_synthetic_text_to_sql
CREATE TABLE project_data (project_name VARCHAR(50), imagery_analysis_cost FLOAT); INSERT INTO project_data (project_name, imagery_analysis_cost) VALUES ('Project A', 1200.50), ('Project B', 1500.75), ('Project C', 1800.25), ('Project D', 2000.00);
List the total satellite imagery analysis costs for each project
SELECT project_name, SUM(imager_analysis_cost) FROM project_data GROUP BY project_name;
gretelai_synthetic_text_to_sql
CREATE TABLE science_accommodations (student_id INT, semester VARCHAR(10));CREATE TABLE math_accommodations (student_id INT, semester VARCHAR(10)); INSERT INTO science_accommodations VALUES (1, 'spring 2021'), (2, 'spring 2021'), (3, 'spring 2021'); INSERT INTO math_accommodations VALUES (2, 'spring 2021'), (3, 'spring 2021'), (4, 'spring 2021');
Show the names of students who received accommodations in both the science and math departments during the spring 2021 semester.
SELECT student_id FROM science_accommodations WHERE semester = 'spring 2021' INTERSECT SELECT student_id FROM math_accommodations WHERE semester = 'spring 2021';
gretelai_synthetic_text_to_sql
CREATE TABLE production_data (year INT, country VARCHAR(255), element_type VARCHAR(255), production_quantity INT);
Display the names of the countries with production data for Neodymium, Europium, and Yttrium.
SELECT country FROM production_data WHERE element_type IN ('Neodymium', 'Europium', 'Yttrium') GROUP BY country HAVING COUNT(DISTINCT element_type) = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE residential_customers (customer_id INT, location VARCHAR(255), monthly_water_usage FLOAT); INSERT INTO residential_customers (customer_id, location, monthly_water_usage) VALUES (1, 'Seattle', 12.5), (2, 'Seattle', 15.7), (3, 'Portland', 14.3);
What is the average monthly water usage for residential customers in Seattle?
SELECT AVG(monthly_water_usage) FROM residential_customers WHERE location = 'Seattle';
gretelai_synthetic_text_to_sql
CREATE TABLE labor_statistics (labor_category VARCHAR(50), records INTEGER); INSERT INTO labor_statistics (labor_category, records) VALUES ('Carpenters', 15), ('Electricians', 12), ('Plumbers', 18), ('Roofers', 21);
How many construction labor statistics records are there for each labor category?
SELECT labor_category, COUNT(records) AS records_per_category FROM labor_statistics GROUP BY labor_category;
gretelai_synthetic_text_to_sql
CREATE TABLE SpaceMissions (mission_id INT, year INT, success BOOLEAN); INSERT INTO SpaceMissions (mission_id, year, success) VALUES (1, 2021, false), (2, 2021, true), (3, 2021, false), (4, 2021, true), (5, 2022, false);
List all space missions that were not successful in 2021.
SELECT mission_id FROM SpaceMissions WHERE year = 2021 AND success = false;
gretelai_synthetic_text_to_sql
CREATE TABLE Warehouse (id INT PRIMARY KEY, country VARCHAR(50), city VARCHAR(50), capacity INT); INSERT INTO Warehouse (id, country, city, capacity) VALUES (1, 'USA', 'New York', 5000), (2, 'USA', 'Los Angeles', 7000), (3, 'USA', 'Chicago', 6000), (4, 'India', 'Mumbai', 4000), (5, 'India', 'Delhi', 6000), (6, 'Japan', 'Tokyo', 3000);
Determine the warehouse with the largest capacity in each country.
SELECT country, MAX(capacity) AS max_capacity FROM Warehouse GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE reporters (id INT, name VARCHAR(50), gender VARCHAR(10), age INT, position VARCHAR(20), country VARCHAR(50)); INSERT INTO reporters (id, name, gender, age, position, country) VALUES (1, 'Anna Smith', 'Female', 35, 'News Reporter', 'USA'); INSERT INTO reporters (id, name, gender, age, position, country) VALUES (2, 'Mike Johnson', 'Male', 40, 'Investigative Journalist', 'Canada'); INSERT INTO reporters (id, name, gender, age, position, country) VALUES (3, 'Sofia Rodriguez', 'Female', 32, 'Investigative Journalist', 'Mexico'); CREATE TABLE news_articles (id INT, title VARCHAR(100), content TEXT, publication_date DATE, reporter_id INT); INSERT INTO news_articles (id, title, content, publication_date, reporter_id) VALUES (1, 'News Article 1', 'Content of News Article 1', '2021-01-01', 2); INSERT INTO news_articles (id, title, content, publication_date, reporter_id) VALUES (2, 'News Article 2', 'Content of News Article 2', '2021-02-01', 3); INSERT INTO news_articles (id, title, content, publication_date, reporter_id) VALUES (4, 'Noticias Articulo 4', 'Contenido del Noticias Articulo 4', '2022-01-01', 3);
How many news articles were published by each reporter in 2022?
SELECT reporter_id, COUNT(*) FROM news_articles WHERE YEAR(publication_date) = 2022 GROUP BY reporter_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Movies (movie_id INT, title VARCHAR(100), release_year INT, budget INT, marketing_budget INT); INSERT INTO Movies (movie_id, title, release_year, budget, marketing_budget) VALUES (3, 'MovieC', 2016, 60000000, 10000000); INSERT INTO Movies (movie_id, title, release_year, budget, marketing_budget) VALUES (4, 'MovieD', 2017, 70000000, 12000000);
What is the minimum marketing budget for movies released after 2015?
SELECT MIN(marketing_budget) FROM Movies WHERE release_year > 2015;
gretelai_synthetic_text_to_sql
CREATE TABLE safety_incidents (incident_id INT, incident_date DATE); INSERT INTO safety_incidents (incident_id, incident_date) VALUES (1, '2021-02-01'), (2, '2021-05-15'), (3, '2021-08-20'), (4, '2020-12-10');
What is the minimum safety incident date in the chemical plant?
SELECT MIN(incident_date) FROM safety_incidents;
gretelai_synthetic_text_to_sql
CREATE TABLE events (id INT, year INT, region VARCHAR(20)); INSERT INTO events (id, year, region) VALUES (1, 2022, 'Europe'), (2, 2021, 'Asia'), (3, 2022, 'North America'), (4, 2021, 'Europe'), (5, 2021, 'Asia'), (6, 2022, 'North America');
How many esports events were hosted in North America in 2022?
SELECT COUNT(*) FROM events WHERE year = 2022 AND region = 'North America';
gretelai_synthetic_text_to_sql
CREATE TABLE cultural_heritage_sites (site_id INT, site_name VARCHAR(50), city VARCHAR(50), country VARCHAR(50), funding_amount INT, funding_date DATE); INSERT INTO cultural_heritage_sites (site_id, site_name, city, country, funding_amount, funding_date) VALUES (1, 'Tsukiji Fish Market', 'Tokyo', 'Japan', 5000000, '2020-01-01'), (2, 'Meiji Shrine', 'Tokyo', 'Japan', 7000000, '2019-01-01');
Which cultural heritage sites in Tokyo, Japan, received the most funding in the last 3 years, and what was the total amount of funding received?
SELECT city, country, site_name, SUM(funding_amount) FROM cultural_heritage_sites WHERE city = 'Tokyo' AND country = 'Japan' AND YEAR(funding_date) >= 2019 GROUP BY city, country, site_name ORDER BY SUM(funding_amount) DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_plans (plan_id INT, plan_name VARCHAR(255), data_limit INT, price DECIMAL(5,2));
Update the data limit for an existing mobile plan in the 'mobile_plans' table
UPDATE mobile_plans SET data_limit = 15000 WHERE plan_id = 2001;
gretelai_synthetic_text_to_sql
CREATE TABLE member_data (member_id INT, join_date DATE, age INT); INSERT INTO member_data (member_id, join_date, age) VALUES (1, '2021-01-05', 27), (2, '2021-02-12', 32), (3, '2021-03-20', 26), (4, '2021-04-28', 28), (5, '2021-05-03', 31);
What is the age distribution of members who joined in 2021?
SELECT EXTRACT(YEAR FROM join_date) AS join_year, age, COUNT(*) AS members_count FROM member_data WHERE join_date >= '2021-01-01' AND join_date < '2022-01-01' GROUP BY join_year, age;
gretelai_synthetic_text_to_sql
CREATE TABLE food_aid (id INT, distributor VARCHAR(255), region VARCHAR(255), quantity DECIMAL(10, 2), distribution_date DATE); INSERT INTO food_aid (id, distributor, region, quantity, distribution_date) VALUES (1, 'UN World Food Programme', 'Africa', 15000, '2021-01-01');
What is the maximum amount of food aid distributed by 'UN World Food Programme' in 'Africa' in the year 2021?
SELECT MAX(quantity) FROM food_aid WHERE distributor = 'UN World Food Programme' AND region = 'Africa' AND YEAR(distribution_date) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE attorneys (id INT, name VARCHAR(50), cases_handled INT, region VARCHAR(50), billable_rate DECIMAL(10,2)); INSERT INTO attorneys (id, name, cases_handled, region, billable_rate) VALUES (1, 'John Lee', 40, 'Northeast', 200.00); INSERT INTO attorneys (id, name, cases_handled, region, billable_rate) VALUES (2, 'Jane Doe', 50, 'Southwest', 250.00);
Find the top 3 attorneys with the most cases handled
SELECT name, cases_handled, RANK() OVER (ORDER BY cases_handled DESC) as rank FROM attorneys;
gretelai_synthetic_text_to_sql
CREATE TABLE mining_operations (employee_id INT, job_title VARCHAR(50), age INT); INSERT INTO mining_operations (employee_id, job_title, age) VALUES (1, 'Engineer', 35), (2, 'Operator', 45), (3, 'Manager', 50);
What is the average age of employees in the 'mining_operations' table, grouped by their job title?
SELECT job_title, AVG(age) FROM mining_operations GROUP BY job_title;
gretelai_synthetic_text_to_sql
CREATE TABLE skincare_products (product_origin VARCHAR(20), sale_date DATE, revenue DECIMAL(10,2)); INSERT INTO skincare_products (product_origin, sale_date, revenue) VALUES ('France', '2022-01-01', 150.00), ('Italy', '2022-01-02', 120.00);
What was the total revenue for organic skincare products made in France in Q1 2022?
SELECT SUM(revenue) FROM skincare_products WHERE product_origin = 'France' AND sale_date BETWEEN '2022-01-01' AND '2022-03-31';
gretelai_synthetic_text_to_sql
CREATE TABLE drone_thermal_imaging (id INT, location VARCHAR(255), temperature DECIMAL(5,2), timestamp TIMESTAMP); INSERT INTO drone_thermal_imaging (id, location, temperature, timestamp) VALUES (1, 'US-California', 12.6, '2022-01-01 10:00:00'), (2, 'US-Texas', 11.8, '2022-01-01 10:00:00');
What is the minimum temperature recorded by drone-based thermal imaging in the United States?
SELECT MIN(temperature) FROM drone_thermal_imaging WHERE location LIKE 'US-%';
gretelai_synthetic_text_to_sql
CREATE SCHEMA mental_health; USE mental_health; CREATE TABLE patients (patient_id INT, diagnosis VARCHAR(50), age INT, country VARCHAR(50)); CREATE TABLE treatments (treatment_id INT, patient_id INT, treatment_type VARCHAR(50), treatment_date DATE, country VARCHAR(50)); INSERT INTO treatments VALUES (4, 5, 'psychotherapy', '2021-01-01', 'Germany');
What is the most common treatment type for patients in Germany?
SELECT treatment_type, COUNT(*) FROM treatments JOIN patients ON treatments.patient_id = patients.patient_id WHERE patients.country = 'Germany' GROUP BY treatment_type ORDER BY COUNT(*) DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE songs (song_id INT, genre TEXT); INSERT INTO songs VALUES (1, 'Pop'), (2, 'Soul'), (3, 'Pop'), (4, 'Jazz'), (5, 'Rock'), (6, 'Pop'), (7, 'Rock'), (8, 'Jazz'), (9, 'Soul'), (10, 'Pop');
List the names of all genres and the number of songs in each.
SELECT genre, COUNT(*) FROM songs GROUP BY genre;
gretelai_synthetic_text_to_sql
CREATE TABLE Scores_Australia (id INT, country VARCHAR(50), score INT); INSERT INTO Scores_Australia (id, country, score) VALUES (1, 'Australia', 85), (2, 'Australia', 90); CREATE TABLE Accommodations_Australia (id INT, country VARCHAR(50), type VARCHAR(50)); INSERT INTO Accommodations_Australia (id, country, type) VALUES (1, 'Australia', 'Eco-Friendly'), (2, 'Australia', 'Eco-Friendly');
What is the total number of eco-friendly accommodations in Australia and their average sustainability scores?
SELECT AVG(Scores_Australia.score) FROM Scores_Australia INNER JOIN Accommodations_Australia ON Scores_Australia.country = Accommodations_Australia.country WHERE Accommodations_Australia.type = 'Eco-Friendly' AND Scores_Australia.country = 'Australia';
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (VolunteerID INT, VolunteerName TEXT, Country TEXT, Domain TEXT, VolunteerHours INT); INSERT INTO Volunteers (VolunteerID, VolunteerName, Country, Domain, VolunteerHours) VALUES (1, 'Alex Johnson', 'USA', 'Technology', 100), (2, 'Sophia Patel', 'India', 'Education', 75);
What are the top 3 countries with the most volunteer hours in the Technology domain?
SELECT Country, SUM(VolunteerHours) AS TotalVolunteerHours FROM Volunteers WHERE Domain = 'Technology' GROUP BY Country ORDER BY TotalVolunteerHours DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE ProductionVolumes (Product VARCHAR(50), Volume INT, Timestamp DATETIME);
What is the change in production volume per product, per day, for the past week?
SELECT Product, LAG(Volume) OVER (PARTITION BY Product ORDER BY Timestamp) - Volume AS VolumeChange FROM ProductionVolumes WHERE Timestamp >= DATEADD(day, -7, CURRENT_TIMESTAMP)
gretelai_synthetic_text_to_sql
CREATE TABLE BuildingBudgets (BudgetID INT, BuildingID INT, BudgetAmount DECIMAL(10,2)); INSERT INTO BuildingBudgets (BudgetID, BuildingID, BudgetAmount) VALUES (1, 1, 5000); INSERT INTO BuildingBudgets (BudgetID, BuildingID, BudgetAmount) VALUES (2, 2, 7000);
What is the total budget for each building's accommodations?
SELECT b.BuildingName, SUM(bb.BudgetAmount) AS TotalBudget FROM BuildingBudgets bb INNER JOIN Buildings b ON bb.BuildingID = b.BuildingID GROUP BY b.BuildingName;
gretelai_synthetic_text_to_sql
CREATE TABLE visitors (id INT, country VARCHAR(20), year INT, visitors INT); INSERT INTO visitors (id, country, year, visitors) VALUES (1, 'Portugal', 2020, 1200000), (2, 'Spain', 2020, 2000000), (3, 'France', 2020, 3000000);
How many international visitors arrived in Portugal in 2020?
SELECT country, SUM(visitors) as total_visitors FROM visitors WHERE country = 'Portugal' AND year = 2020;
gretelai_synthetic_text_to_sql