context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE Satellites_With_Launch_Dates (ID INT, Satellite_Name VARCHAR(255), Launch_Date DATE); INSERT INTO Satellites_With_Launch_Dates (ID, Satellite_Name, Launch_Date) VALUES (1, 'Starlink-1', '2019-05-23'), (2, 'Galileo-1', '2011-10-21');
What is the earliest launch date for any satellite in the Satellites table?
SELECT MIN(Launch_Date) FROM Satellites_With_Launch_Dates;
gretelai_synthetic_text_to_sql
CREATE TABLE PublicTransportationBudget(Year INT, Amount INT); INSERT INTO PublicTransportationBudget VALUES (2018, 5000), (2019, 7000), (2020, 9000);
What was the total budget allocated for public transportation in 2019?
SELECT SUM(Amount) FROM PublicTransportationBudget WHERE Year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE cargo_containers(container_type TEXT, weight INT);CREATE TABLE cargo(cargo_id INT, container_type TEXT);INSERT INTO cargo_containers VALUES ('Dry Van',1000),('Reefer',1500),('Flat Rack',2000),('Open Top',2500);INSERT INTO cargo VALUES (1,'Dry Van'),(2,'Reefer'),(3,'Dry Van'),(4,'Flat Rack'),(5,'Open Top'),...
Calculate the percentage of the total cargo weight that is carried by each type of cargo container, for all container types used in the shipping industry.
SELECT container_type, (COUNT(c.container_type) * 100.0 / (SELECT COUNT(*) FROM cargo)) as percentage FROM cargo_containers cc JOIN cargo c ON cc.container_type = c.container_type GROUP BY container_type;
gretelai_synthetic_text_to_sql
CREATE TABLE traffic (ip_address VARCHAR(15), timestamp TIMESTAMP, network VARCHAR(255)); INSERT INTO traffic (ip_address, timestamp, network) VALUES ('192.168.1.1', '2022-01-02 12:00:00', 'Internal'), ('10.0.0.1', '2022-01-02 13:00:00', 'Botnet'), ('172.16.1.1', '2022-01-02 14:00:00', 'Internal');
Count the number of unique IP addresses in the 'traffic' table that belong to the 'botnet' network
SELECT COUNT(DISTINCT ip_address) as unique_botnet_ips FROM traffic WHERE network = 'Botnet';
gretelai_synthetic_text_to_sql
CREATE TABLE mammals (id INT, name VARCHAR(255), biomass FLOAT);
What is the minimum biomass of all marine mammals in the 'mammals' table?
SELECT MIN(biomass) FROM mammals;
gretelai_synthetic_text_to_sql
CREATE TABLE cybersecurity_strategies (id INT, strategy TEXT, category TEXT); INSERT INTO cybersecurity_strategies (id, strategy, category) VALUES (1, 'Strategy1', 'Category1'), (2, 'Strategy2', 'Category2'), (3, 'Strategy3', 'Category1');
List all cybersecurity strategies and their corresponding national security categories.
SELECT strategy, category FROM cybersecurity_strategies;
gretelai_synthetic_text_to_sql
CREATE TABLE activities_america (activity_id INT, activity_name VARCHAR(255), region VARCHAR(255)); INSERT INTO activities_america (activity_id, activity_name, region) VALUES (1, 'Hiking Tour', 'America');
What is the total number of sustainable tourism activities in the American region?
SELECT COUNT(*) FROM activities_america WHERE region = 'America';
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_workforce (year INT, technology VARCHAR(50), workers NUMERIC); INSERT INTO renewable_workforce (year, technology, workers) VALUES (2019, 'Solar', 10000), (2019, 'Wind', 8000), (2019, 'Hydro', 6000), (2020, 'Solar', 12000), (2020, 'Wind', 9000), (2020, 'Hydro', 7000);
What is the percentage change in the number of workers employed in the renewable energy sector, by technology, between 2019 and 2020?
SELECT technology, (SUM(workers)*100.0/ (SELECT SUM(workers) FROM renewable_workforce WHERE year = 2019 AND technology = t.technology) - 100.0) as pct_change FROM renewable_workforce t WHERE year = 2020 GROUP BY technology;
gretelai_synthetic_text_to_sql
CREATE TABLE community_health_workers (id INT, name VARCHAR(255), region VARCHAR(255), active BOOLEAN); INSERT INTO community_health_workers (id, name, region, active) VALUES (1, 'John Doe', 'Urban', true), (2, 'Jane Doe', 'Rural', true), (3, 'Jim Smith', 'Urban', false), (4, 'Jill Smith', 'Rural', true);
How many community health workers are currently active in urban and rural regions?
SELECT region, COUNT(*) FROM community_health_workers WHERE active = true GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE food_safety_inspections (restaurant_id INT, inspection_date DATE, result VARCHAR(20));
Insert a new food safety inspection record with a rating of 'Satisfactory' for 'Fresh Bites' on '2022-06-01' if it does not exist already.
INSERT INTO food_safety_inspections (restaurant_id, inspection_date, result) SELECT 7, '2022-06-01', 'Satisfactory' FROM (SELECT 1 FROM food_safety_inspections WHERE restaurant_id = 7 AND inspection_date = '2022-06-01') AS dummy WHERE NOT EXISTS (SELECT 1 FROM food_safety_inspections WHERE restaurant_id = 7 AND inspect...
gretelai_synthetic_text_to_sql
CREATE TABLE Manufacturer (ID INT, Name VARCHAR(50)); CREATE TABLE AircraftModel (ID INT, Name VARCHAR(50), ManufacturerID INT); CREATE TABLE Accidents (AircraftModelID INT, AccidentDate DATE);
What is the total number of accidents per manufacturer?
SELECT m.Name, COUNT(a.AircraftModelID) AS AccidentCount FROM Manufacturer m JOIN AircraftModel am ON m.ID = am.ManufacturerID JOIN Accidents a ON am.ID = a.AircraftModelID GROUP BY m.Name;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, DonorName TEXT, DonationAmount DECIMAL, Program TEXT, Country TEXT); INSERT INTO Donors (DonorID, DonorName, DonationAmount, Program, Country) VALUES (1, 'James Smith', 50.00, 'Education', 'Canada'), (2, 'Jessica Johnson', 100.00, 'Health', 'Canada');
What is the average donation amount per program for donors from Canada?
SELECT Program, AVG(DonationAmount) FROM Donors WHERE Country = 'Canada' GROUP BY Program;
gretelai_synthetic_text_to_sql
CREATE TABLE agricultural_innovation (id INT, region VARCHAR(255), investment FLOAT, innovation_year INT); INSERT INTO agricultural_innovation (id, region, investment, innovation_year) VALUES (1, 'Karnataka', 15000, 2018), (2, 'Karnataka', 20000, 2019), (3, 'Karnataka', 25000, 2020);
What is the average investment in agricultural innovation in the region of 'Karnataka' between 2018 and 2020?
SELECT AVG(investment) FROM agricultural_innovation WHERE region = 'Karnataka' AND innovation_year BETWEEN 2018 AND 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (sale_id INT, product_id INT, quantity INT, sale_date DATE, has_recycled_material BOOLEAN); INSERT INTO sales (sale_id, product_id, quantity, sale_date, has_recycled_material) VALUES (1, 1, 20, '2021-01-01', true); CREATE TABLE products (product_id INT, product_name VARCHAR(255)); INSERT INTO product...
What is the total quantity of recycled material products sold, pivoted by quarter?
SELECT EXTRACT(QUARTER FROM sale_date) AS quarter, has_recycled_material, SUM(quantity) AS total_quantity FROM sales JOIN products ON sales.product_id = products.product_id WHERE has_recycled_material = true GROUP BY quarter, has_recycled_material;
gretelai_synthetic_text_to_sql
CREATE TABLE Shipment (id INT, source_country VARCHAR(255), destination_continent VARCHAR(255), quantity INT); INSERT INTO Shipment (id, source_country, destination_continent, quantity) VALUES (1, 'Brazil', 'South America', 500), (2, 'Argentina', 'South America', 300), (3, 'Colombia', 'South America', 200), (4, 'Chile'...
What is the total quantity of items shipped from each country to South America?
SELECT source_country, SUM(quantity) FROM Shipment WHERE destination_continent = 'South America' GROUP BY source_country
gretelai_synthetic_text_to_sql
CREATE TABLE financial_wellbeing_ng (client_id INT, financial_wellbeing_score INT, country VARCHAR(50)); INSERT INTO financial_wellbeing_ng (client_id, financial_wellbeing_score, country) VALUES (1, 7, 'Nigeria'), (2, 10, 'Nigeria'), (3, 6, 'Nigeria'); CREATE TABLE socially_responsible_lending_ng (client_id INT, countr...
Delete records of clients who have not participated in socially responsible lending in Nigeria, if their financial wellbeing score is above 8.
DELETE FROM financial_wellbeing_ng WHERE country = 'Nigeria' AND client_id NOT IN (SELECT client_id FROM socially_responsible_lending_ng);
gretelai_synthetic_text_to_sql
CREATE TABLE City_Washington_Labor (labor_id INT, labor_cost FLOAT, labor_city VARCHAR(20), labor_quarter DATE); INSERT INTO City_Washington_Labor (labor_id, labor_cost, labor_city, labor_quarter) VALUES (1, 800, 'Seattle', '2022-04-01'), (2, 900, 'Spokane', '2022-07-01'), (3, 1000, 'Tacoma', '2022-10-01');
Which quarter of the year has the highest labor cost for each city in Washington?
SELECT labor_city, labor_quarter, MAX(labor_cost) OVER (PARTITION BY labor_city) AS max_labor_cost FROM City_Washington_Labor WHERE EXTRACT(MONTH FROM labor_quarter) IN (4, 5, 6, 7, 8, 9, 10, 11, 12) AND labor_city LIKE 'Washington%' GROUP BY labor_city, labor_quarter;
gretelai_synthetic_text_to_sql
CREATE TABLE Attorneys (AttorneyID INT, Gender VARCHAR(20), ProBonoHours INT); INSERT INTO Attorneys (AttorneyID, Gender, ProBonoHours) VALUES (1, 'Female', 120), (2, 'Male', 100), (3, 'Non-binary', 70);
What is the minimum pro-bono work hours for cases handled by attorneys who identify as non-binary?
SELECT MIN(ProBonoHours) FROM Attorneys WHERE Gender = 'Non-binary';
gretelai_synthetic_text_to_sql
CREATE SCHEMA IF NOT EXISTS public_transport;CREATE TABLE IF NOT EXISTS public_transport.maintenance (maintenance_id SERIAL PRIMARY KEY, vehicle_type TEXT, request_date DATE);INSERT INTO public_transport.maintenance (vehicle_type, request_date) VALUES ('Bus', '2021-11-01'), ('Tram', '2021-11-02'), ('Bus', '2021-12-03')...
Show the number of maintenance requests for each vehicle type and month in the 'maintenance' table
SELECT EXTRACT(MONTH FROM request_date) AS month, vehicle_type, COUNT(*) FROM public_transport.maintenance GROUP BY EXTRACT(MONTH FROM request_date), vehicle_type;
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_depths (ocean TEXT, depth FLOAT); INSERT INTO ocean_depths (ocean, depth) VALUES ('Southern Ocean', 7280.0);
What is the minimum depth in the Southern Ocean?
SELECT MIN(depth) FROM ocean_depths WHERE ocean = 'Southern Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE inventory(product_id INT, product_name TEXT, quantity INT); CREATE TABLE safety_assessments(product_id INT, risk_level TEXT);
What are the names and quantities of products that are both in the 'inventory' table and have 'high' risk levels in the 'safety_assessments' table?
SELECT inventory.product_name, inventory.quantity FROM inventory INNER JOIN safety_assessments ON inventory.product_id = safety_assessments.product_id WHERE safety_assessments.risk_level = 'high';
gretelai_synthetic_text_to_sql
CREATE TABLE MiningSites (SiteID int, SiteName varchar(50), Location varchar(50)); INSERT INTO MiningSites VALUES (1, 'SiteA', 'Amazon Rainforest'), (2, 'SiteB', 'Andes Mountains'), (3, 'SiteC', 'Sahara Desert'); CREATE TABLE AccidentData (SiteID int, AccidentDate date); INSERT INTO AccidentData VALUES (1, '2021-03-15'...
How many labor accidents occurred in mining sites located in the Amazon rainforest in 2021?
SELECT COUNT(*) as LaborAccidents FROM AccidentData ad JOIN MiningSites ms ON ad.SiteID = ms.SiteID WHERE ms.Location = 'Amazon Rainforest' AND ad.AccidentDate BETWEEN '2021-01-01' AND '2021-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE open_data_portals (id INT, name VARCHAR(255), country VARCHAR(255)); INSERT INTO open_data_portals (id, name, country) VALUES (1, 'data.gov', 'USA'), (2, 'data.gov.uk', 'UK'), (3, 'data.gouv.fr', 'France');
How many open data portals exist in each country?
SELECT country, COUNT(*) FROM open_data_portals GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE us_institutions (institution_id INT, institution_name TEXT); CREATE TABLE loans_us (loan_id INT, institution_id INT, loan_amount FLOAT, is_socially_responsible BOOLEAN);
List the names of financial institutions offering socially responsible loans in the United States.
SELECT us_institutions.institution_name FROM us_institutions JOIN loans_us ON us_institutions.institution_id = loans_us.institution_id WHERE loans_us.is_socially_responsible = TRUE AND us_institutions.institution_id IN (SELECT loans_us.institution_id FROM loans_us WHERE loans_us.is_socially_responsible = TRUE AND us_in...
gretelai_synthetic_text_to_sql
CREATE TABLE Streams (song_genre VARCHAR(255), city VARCHAR(255), stream_count INT, stream_date DATE); INSERT INTO Streams (song_genre, city, stream_count, stream_date) VALUES ('pop', 'New York', 500, '2022-01-01'), ('R&B', 'Chicago', 700, '2022-01-03');
What is the number of streams for R&B songs in Chicago last week?
SELECT SUM(stream_count) FROM Streams WHERE song_genre = 'R&B' AND city = 'Chicago' AND stream_date >= DATEADD(WEEK, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE oceanacidity (year INTEGER, location VARCHAR(20), acidity FLOAT); INSERT INTO oceanacidity (year, location, acidity) VALUES (2017, 'Arctic Ocean', 7.8), (2018, 'Arctic Ocean', 7.7), (2019, 'Arctic Ocean', 7.6), (2020, 'Arctic Ocean', 7.5), (2021, 'Arctic Ocean', 7.4);
What is the change in ocean acidity levels in the Arctic Ocean over the past 5 years?
SELECT acidity FROM oceanacidity WHERE location = 'Arctic Ocean' ORDER BY year DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE weather_data (id INT PRIMARY KEY, location VARCHAR(255), temperature FLOAT, precipitation FLOAT, wind_speed FLOAT, date DATE);
Insert a new record into the "weather_data" table with the following data: location: 'Field 2', temperature: 20, precipitation: 0, wind_speed: 5, date: '2023-01-06'
INSERT INTO weather_data (location, temperature, precipitation, wind_speed, date) VALUES ('Field 2', 20, 0, 5, '2023-01-06');
gretelai_synthetic_text_to_sql
CREATE TABLE Warehouses (WarehouseID INT, WarehouseName VARCHAR(50), Country VARCHAR(50)); INSERT INTO Warehouses (WarehouseID, WarehouseName, Country) VALUES (1, 'Mexico City Warehouse', 'Mexico'); CREATE TABLE Shipments (ShipmentID INT, WarehouseID INT, Quantity INT);
What is the total quantity of shipments for each warehouse in Mexico?
SELECT W.WarehouseID, W.WarehouseName, SUM(S.Quantity) AS TotalQuantity FROM Warehouses W JOIN Shipments S ON W.WarehouseID = S.WarehouseID WHERE W.Country = 'Mexico' GROUP BY W.WarehouseID, W.WarehouseName;
gretelai_synthetic_text_to_sql
CREATE TABLE security_incidents (id INT, country VARCHAR(50), incident_count INT, incident_date DATE); INSERT INTO security_incidents (id, country, incident_count, incident_date) VALUES (1, 'USA', 25, '2021-08-01'), (2, 'Canada', 18, '2021-08-02'), (3, 'UK', 22, '2021-08-03');
What are the top 3 countries with the most security incidents in the past month, based on the 'security_incidents' table?
SELECT country, COUNT(*) as incident_count FROM security_incidents WHERE incident_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY country ORDER BY incident_count DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE company_industries (id INT, company VARCHAR(255), industry VARCHAR(255), total_funding INT); INSERT INTO company_industries (id, company, industry, total_funding) VALUES (1, 'Acme Inc', 'Technology', 2500000), (2, 'Beta Corp', 'Technology', 3750000), (3, 'Gamma Inc', 'Healthcare', 1300000), (4, 'Delta Ltd'...
Display the total funding for each industry
SELECT industry, SUM(total_funding) as total_funding FROM company_industries GROUP BY industry;
gretelai_synthetic_text_to_sql
CREATE TABLE accommodation (student_id INT, accommodation_type TEXT, accommodation_date DATE); INSERT INTO accommodation (student_id, accommodation_type, accommodation_date) VALUES (1, 'Screen Reader', '2022-01-01'), (2, 'Braille Materials', '2022-02-01'), (3, 'Screen Reader', '2022-03-01'), (4, 'Assistive Technology',...
List the top 3 most requested accommodations for students with visual impairments.
SELECT accommodation_type, COUNT(*) as count FROM accommodation WHERE student_id IN (SELECT student_id FROM student WHERE disability = 'Visual Impairment') GROUP BY accommodation_type ORDER BY count DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE veteran_employment (id INT, veteran_status VARCHAR(50), employment_date DATE);
Show veteran employment statistics for the last 3 months, grouped by month and veteran status
SELECT MONTH(employment_date) AS month, veteran_status, COUNT(*) AS total FROM veteran_employment WHERE employment_date >= DATE_SUB(NOW(), INTERVAL 3 MONTH) GROUP BY month, veteran_status;
gretelai_synthetic_text_to_sql
CREATE TABLE Factories (id INT, country VARCHAR, water_recycling_rate DECIMAL);
Which factories in Italy have the highest water recycling rates?
SELECT id, country, water_recycling_rate FROM Factories WHERE country = 'Italy' ORDER BY water_recycling_rate DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE departments (id INT, name VARCHAR(255)); INSERT INTO departments (id, name) VALUES (1, 'HR'), (2, 'IT'), (3, 'Sales'); CREATE TABLE employees (id INT, name VARCHAR(255), department_id INT); INSERT INTO employees (id, name, department_id) VALUES (1, 'John Doe', 1), (2, 'Jane Smith', 2), (3, 'Alice Johnson',...
What is the total number of employees per department?
SELECT departments.name, COUNT(employees.id) as total FROM departments JOIN employees ON departments.id = employees.department_id GROUP BY departments.name;
gretelai_synthetic_text_to_sql
CREATE TABLE Vehicle (id INT, name TEXT, is_autonomous BOOLEAN, is_electric BOOLEAN, safety_rating FLOAT, city_traffic_speed FLOAT); INSERT INTO Vehicle (id, name, is_autonomous, is_electric, safety_rating, city_traffic_speed) VALUES (1, 'Model S', false, true, 5.1, 14.5), (2, 'Camry', false, false, 4.8, 19.2), (3, 'Bo...
What is the maximum safety rating of non-autonomous electric vehicles in city traffic?
SELECT MAX(safety_rating) FROM Vehicle WHERE is_autonomous = false AND is_electric = true AND city_traffic_speed < 20;
gretelai_synthetic_text_to_sql
CREATE TABLE Policyholders (PolicyholderID INT, Age INT, Gender VARCHAR(10)); CREATE TABLE Policies (PolicyID INT, PolicyholderID INT); INSERT INTO Policyholders (PolicyholderID, Age, Gender) VALUES (1, 34, 'Female'), (2, 45, 'Male'), (3, 52, 'Male'), (4, 30, 'Male'), (5, 40, 'Female'); INSERT INTO Policies (PolicyID, ...
Display all policyholders with no policies
SELECT Policyholders.* FROM Policyholders LEFT JOIN Policies ON Policyholders.PolicyholderID = Policies.PolicyholderID WHERE Policies.PolicyholderID IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE ProgramVolunteers (ProgramID INT, VolunteerCount INT); INSERT INTO ProgramVolunteers (ProgramID, VolunteerCount) VALUES (1, 10), (2, 20);
What is the sum of donations and number of volunteers for each program in Q3 2021?
SELECT ProgramName, SUM(DonationAmount) as TotalDonation, SUM(VolunteerCount) as TotalVolunteers FROM Programs JOIN ProgramVolunteers ON Programs.ProgramID = ProgramVolunteers.ProgramID WHERE DonationDate BETWEEN '2021-07-01' AND '2021-09-30' GROUP BY ProgramName;
gretelai_synthetic_text_to_sql
CREATE TABLE imagery (id INT, field_name VARCHAR(20), filename VARCHAR(30)); INSERT INTO imagery (id, field_name, filename) VALUES (1, 'north_field', 'img101.jpg'), (2, 'west_field', 'img102.jpg'), (3, 'west_field', 'img103.jpg'), (4, 'east_field', 'img104.jpg'), (5, 'north_field', 'img105.jpg'), (6, 'south_field', 'im...
List all satellite image filenames for the 'north_field' and 'south_field' from the 'imagery' table?
SELECT filename FROM imagery WHERE field_name IN ('north_field', 'south_field');
gretelai_synthetic_text_to_sql
CREATE TABLE sustainability_metrics (factory_id INT, energy_consumption FLOAT, measurement_date DATE); INSERT INTO sustainability_metrics (factory_id, energy_consumption, measurement_date) VALUES (1, 25000.5, '2021-09-01'), (2, 18000.3, '2021-09-01'), (3, 22000.0, '2021-08-01');
Update the sustainability_metrics table to reflect the latest energy consumption data for factory 3.
UPDATE sustainability_metrics SET energy_consumption = 23000.0, measurement_date = CURRENT_DATE WHERE factory_id = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE ingredients (ingredient VARCHAR(255), menu_item VARCHAR(255)); INSERT INTO ingredients (ingredient, menu_item) VALUES ('Chicken', 'Chicken Alfredo'), ('Pasta', 'Chicken Alfredo'), ('Beef', 'Beef Stew'), ('Carrots', 'Beef Stew'), ('Potatoes', 'Beef Stew');
What is the inventory level for ingredients used in a specific menu item?
SELECT ingredient, quantity FROM ingredients JOIN inventory ON ingredients.ingredient = inventory.ingredient WHERE menu_item = 'Chicken Alfredo';
gretelai_synthetic_text_to_sql
CREATE TABLE beneficiaries (id INT, name TEXT, age INT, gender TEXT, needs TEXT, location TEXT); INSERT INTO beneficiaries (id, name, age, gender, needs, location) VALUES (1, 'Charlie Davis', 12, 'Male', 'Food, Water', 'Boston'); INSERT INTO beneficiaries (id, name, age, gender, needs, location) VALUES (2, 'Diana Green...
What is the rank of each beneficiary by age within their location?
SELECT *, RANK() OVER (PARTITION BY location ORDER BY age) as rank FROM beneficiaries;
gretelai_synthetic_text_to_sql
CREATE TABLE Attendees (attendee_id INT, event_id INT, event_location VARCHAR(20)); INSERT INTO Attendees (attendee_id, event_id, event_location) VALUES (1, 1, 'Tokyo'), (2, 2, 'Paris'), (3, 1, 'Mumbai'), (4, 3, 'Los Angeles'), (5, 4, 'Mumbai');
Find the number of unique attendees for events in 'Tokyo' or 'Mumbai' that are not 'Workshops'.
SELECT DISTINCT event_location FROM Attendees WHERE event_location IN ('Tokyo', 'Mumbai') AND event_location <> 'Workshop';
gretelai_synthetic_text_to_sql
CREATE TABLE SustainablePractices (practice_id INT, practice_name VARCHAR(255), description TEXT);
Create a table named "SustainablePractices" with columns "practice_id", "practice_name", and "description"
CREATE TABLE SustainablePractices (practice_id INT, practice_name VARCHAR(255), description TEXT);
gretelai_synthetic_text_to_sql
CREATE TABLE clients (client_id INT, name VARCHAR(50), region VARCHAR(50), credit_rating INT); INSERT INTO clients (client_id, name, region, credit_rating) VALUES (1, 'Pablo Rodriguez', 'Latin America', 750), (2, 'Sofia Gonzales', 'Europe', 650);
What is the total number of clients in the Latin America region with a credit rating above 700?
SELECT COUNT(*) FROM clients WHERE region = 'Latin America' AND credit_rating > 700;
gretelai_synthetic_text_to_sql
CREATE TABLE Tunnel (tunnel_id INT, region VARCHAR(20), construction_cost DECIMAL(10,2)); INSERT INTO Tunnel (tunnel_id, region, construction_cost) VALUES (1, 'Midwest', 5000000.00), (2, 'Northeast', 6000000.00);
What is the standard deviation of construction costs for tunnels in the Midwest?
SELECT STDDEV(construction_cost) FROM Tunnel WHERE region = 'Midwest';
gretelai_synthetic_text_to_sql
CREATE TABLE indigenous_communities (name TEXT, location TEXT, livelihood TEXT); INSERT INTO indigenous_communities (name, location, livelihood) VALUES ('Inuit', 'Greenland', 'Hunting and Fishing'), ('Kalaallit', 'Greenland', 'Hunting and Fishing');
What is the number of indigenous communities in Greenland that rely on hunting and fishing?
SELECT COUNT(*) FROM indigenous_communities WHERE location = 'Greenland' AND livelihood = 'Hunting and Fishing';
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT PRIMARY KEY, name VARCHAR(50), age INT, city VARCHAR(50), region VARCHAR(50)); INSERT INTO users (id, name, age, city, region) VALUES (1, 'Alice', 30, 'New York', 'North America'); INSERT INTO users (id, name, age, city, region) VALUES (2, 'Bob', 25, 'San Francisco', 'North America'); INSERT ...
What is the name and age group of users from 'Asia'?
SELECT name, (CASE WHEN age > 30 THEN 'Older' ELSE 'Younger' END) AS age_group FROM users WHERE region = 'Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE Forests (Fid INT PRIMARY KEY, Name VARCHAR(50), Country VARCHAR(50), Area FLOAT); CREATE TABLE Wildlife (Wid INT PRIMARY KEY, Fid INT, Species VARCHAR(50), Population INT, FOREIGN KEY (Fid) REFERENCES Forests(Fid)); CREATE TABLE Rangers (Rid INT PRIMARY KEY, Fid INT, Name VARCHAR(50), Age INT, FOREIGN KEY ...
What are the names of forests in South Africa and their respective wildlife species, along with their populations and the names of the rangers responsible for each forest?
SELECT Forests.Name, Wildlife.Species, Wildlife.Population, Rangers.Name FROM Forests FULL OUTER JOIN Wildlife ON Forests.Fid = Wildlife.Fid FULL OUTER JOIN Rangers ON Forests.Fid = Rangers.Fid WHERE Forests.Country = 'South Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE CulturalHeritage (SiteID int, SiteName varchar(50), Country varchar(50), Visitors int); INSERT INTO CulturalHeritage (SiteID, SiteName, Country, Visitors) VALUES (1, 'Pyramids of Giza', 'Egypt', 3000000); INSERT INTO CulturalHeritage (SiteID, SiteName, Country, Visitors) VALUES (2, 'Victoria Falls', 'Zimba...
Identify cultural heritage sites in Africa with the highest number of visitors.
SELECT SiteName, Visitors FROM CulturalHeritage WHERE Country = 'Africa' GROUP BY SiteName, Country ORDER BY Visitors DESC
gretelai_synthetic_text_to_sql
CREATE TABLE reverse_logistics (id INT, region VARCHAR(5), order_date DATE, processed INT); INSERT INTO reverse_logistics VALUES (1, 'EU', '2021-10-01', 20), (2, 'NA', '2021-10-03', 15), (3, 'ASIA', '2021-10-05', 30);
How many reverse logistics orders were processed in 'EU' region in October 2021?
SELECT SUM(processed) FROM reverse_logistics WHERE region = 'EU' AND order_date BETWEEN '2021-10-01' AND '2021-10-31';
gretelai_synthetic_text_to_sql
CREATE TABLE education (id INT, topic VARCHAR(50), attendees INT);
Update the education table and set the attendees to 30 for any records where the topic is 'Climate Change'
UPDATE education SET attendees = 30 WHERE topic = 'Climate Change';
gretelai_synthetic_text_to_sql
CREATE TABLE exploration_wells (well_id INT PRIMARY KEY, well_name VARCHAR(50), well_type VARCHAR(20), well_status VARCHAR(20));
Update the 'exploration_wells' table and set the 'well_status' to 'abandoned' for any record where 'well_type' is 'horizontal'
UPDATE exploration_wells SET well_status = 'abandoned' WHERE well_type = 'horizontal';
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (id INT PRIMARY KEY, volunteer_name VARCHAR(255), hours_volunteered DECIMAL(10,2));
Insert a new record into the 'Volunteers' table for a volunteer named 'Alice Lee' with 3 hours of volunteered time
INSERT INTO Volunteers (volunteer_name, hours_volunteered) VALUES ('Alice Lee', 3.00);
gretelai_synthetic_text_to_sql
CREATE TABLE community_development (id INT, initiative VARCHAR(50), budget FLOAT, status VARCHAR(20));
What are the unique types of community development initiatives in the 'community_development' table, along with the number of successful, ongoing, and abandoned initiatives for each type?
SELECT type, SUM(CASE WHEN status = 'successful' THEN 1 ELSE 0 END) as successful, SUM(CASE WHEN status = 'ongoing' THEN 1 ELSE 0 END) as ongoing, SUM(CASE WHEN status = 'abandoned' THEN 1 ELSE 0 END) as abandoned FROM (SELECT initiative as type FROM community_development GROUP BY initiative) t GROUP BY type;
gretelai_synthetic_text_to_sql
CREATE TABLE regions (region_id INT, region_name VARCHAR(255)); CREATE TABLE products (product_id INT, product_name VARCHAR(255), is_sustainable BOOLEAN, region_id INT, sales INT);
What is the percentage of sustainable nail polish sales by region?
SELECT r.region_name, (SUM(p.sales) / (SELECT SUM(sales) FROM products WHERE is_sustainable = TRUE) * 100) as pct_sustainable_sales FROM regions r INNER JOIN products p ON r.region_id = p.region_id WHERE p.product_name LIKE '%nail polish%' AND p.is_sustainable = TRUE GROUP BY r.region_name;
gretelai_synthetic_text_to_sql
CREATE TABLE FoI_Requests (RequestID INT, RequestDate DATE); INSERT INTO FoI_Requests (RequestID, RequestDate) VALUES (1, '2021-01-01'), (2, '2021-02-15'), (3, '2021-03-05');
How many freedom of information requests were submitted per month in the last year?
SELECT EXTRACT(MONTH FROM RequestDate), EXTRACT(YEAR FROM RequestDate), COUNT(*) FROM FoI_Requests WHERE RequestDate >= '2021-01-01' GROUP BY EXTRACT(MONTH FROM RequestDate), EXTRACT(YEAR FROM RequestDate);
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists countries (country_id INT, country VARCHAR(255)); INSERT INTO countries (country_id, country) VALUES (1, 'Mexico'), (2, 'Brazil'), (3, 'Canada'); CREATE TABLE if not exists athletes (athlete_id INT, country_id INT, speed FLOAT, sport VARCHAR(255)); INSERT INTO athletes (athlete_id, country_id...
Who has the highest average running speed among athletes in Mexico?
SELECT athlete_id, AVG(speed) FROM athletes WHERE country_id = 1 AND sport = 'Running' GROUP BY athlete_id ORDER BY AVG(speed) DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE daily_activity (id INT, game VARCHAR(20), genre VARCHAR(10), active_day INT); INSERT INTO daily_activity (id, game, genre, active_day) VALUES (1, 'Game1', 'RPG', 1), (2, 'Game2', 'Strategy', 2), (3, 'Game1', 'RPG', 3);
What is the average number of daily active users for a specific game genre?
SELECT genre, AVG(active_day) FROM daily_activity WHERE game = 'Game1' GROUP BY genre;
gretelai_synthetic_text_to_sql
CREATE TABLE farm_communities (id INT, farm_id INT, community VARCHAR(30)); INSERT INTO farm_communities (id, farm_id, community) VALUES (1, 1, 'indigenous'), (2, 2, 'urban'), (3, 3, 'rural'); CREATE VIEW indigenous_farms AS SELECT f.name AS farmer_name, c.crop_name FROM farmers f JOIN crops c ON f.id = c.farmer_id JOI...
What is the total number of crops cultivated by farmers in 'indigenous' communities?
SELECT COUNT(DISTINCT crop_name) FROM indigenous_farms;
gretelai_synthetic_text_to_sql
CREATE TABLE exit_strategy(id INT, startup_id INT, exit_type TEXT);
How many startups founded by BIPOC individuals have had a successful exit strategy in the biotech sector?
SELECT COUNT(*) FROM (SELECT startups.id FROM startups JOIN founders ON startups.id = founders.startup_id WHERE founders.founder_identity = 'BIPOC' AND startups.industry = 'Biotech') subquery JOIN exit_strategy ON subquery.id = exit_strategy.startup_id WHERE exit_type = 'Successful';
gretelai_synthetic_text_to_sql
CREATE TABLE CourtCases (CaseID INT, Year INT, Reason VARCHAR(20)); INSERT INTO CourtCases (CaseID, Year, Reason) VALUES (1, 2019, 'Lack of Evidence'), (2, 2020, 'Guilty'), (3, 2021, 'Lack of Evidence');
How many court cases were dismissed due to lack of evidence in the last 3 years?
SELECT COUNT(*) FROM CourtCases WHERE Year BETWEEN 2019 AND 2021 AND Reason = 'Lack of Evidence';
gretelai_synthetic_text_to_sql
CREATE TABLE rural_infrastructure (id INT, project_name VARCHAR(255), budget INT, location VARCHAR(255));
List the names and budgets of all rural infrastructure projects in the 'rural_infrastructure' table that are located in 'Africa'.
SELECT project_name, budget FROM rural_infrastructure WHERE location = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE GlacierData (region VARCHAR(255), area FLOAT); INSERT INTO GlacierData (region, area) VALUES ('Arctic', 4.2); INSERT INTO GlacierData (region, area) VALUES ('Antarctic', 12.5);
What is the percentage of the Arctic region covered by glaciers?
SELECT (area/SUM(area))*100 FROM GlacierData WHERE region = 'Arctic';
gretelai_synthetic_text_to_sql
CREATE TABLE CulturalEvents (event_id INT, event_name TEXT, country TEXT, year_of_occurrence INT); INSERT INTO CulturalEvents (event_id, event_name, country, year_of_occurrence) VALUES (1, 'Japanese Flower Festival', 'Japan', 2022); INSERT INTO CulturalEvents (event_id, event_name, country, year_of_occurrence) VALUES (...
How many local cultural events are organized in Japan annually?
SELECT COUNT(*) FROM CulturalEvents WHERE country = 'Japan' GROUP BY year_of_occurrence;
gretelai_synthetic_text_to_sql
CREATE TABLE hospital (hospital_id INT, hospital_name TEXT, location TEXT, num_beds INT); INSERT INTO hospital (hospital_id, hospital_name, location, num_beds) VALUES (1, 'Rural Hospital A', 'Oregon', 100);
What is the maximum number of hospital beds in hospitals located in the rural areas of Oregon?
SELECT MAX(num_beds) FROM hospital WHERE hospital.location = 'Oregon';
gretelai_synthetic_text_to_sql
CREATE TABLE Veteran_Employment (id INT, veteran_id INT, employment_date DATE, sector VARCHAR(50));
How many veterans have been employed in the IT sector in the last year?
SELECT COUNT(*) FROM Veteran_Employment WHERE employment_date >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR) AND sector = 'IT';
gretelai_synthetic_text_to_sql
CREATE TABLE cuisine_revenue (cuisine VARCHAR(50), revenue INT); INSERT INTO cuisine_revenue (cuisine, revenue) VALUES ('italian', 400000); INSERT INTO cuisine_revenue (cuisine, revenue) VALUES ('mexican', 500000); INSERT INTO cuisine_revenue (cuisine, revenue) VALUES ('chinese', 350000);
What is the total revenue for each cuisine category, ordered by revenue in descending order?
SELECT cuisine, SUM(revenue) as total_revenue FROM cuisine_revenue GROUP BY cuisine ORDER BY total_revenue DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE events (event_id INT, event_location VARCHAR(50), event_date DATE); INSERT INTO events (event_id, event_location, event_date) VALUES (1, 'New York', '2021-06-01'); INSERT INTO events (event_id, event_location, event_date) VALUES (2, 'New York', '2021-10-15'); CREATE TABLE audience (audience_id INT, event_i...
What is the distribution of audience members by age group, for events held in New York, in the past year?
SELECT age_group, COUNT(*) as audience_count FROM audience JOIN events ON audience.event_id = events.event_id WHERE events.event_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) AND events.event_location = 'New York' GROUP BY age_group;
gretelai_synthetic_text_to_sql
CREATE TABLE district (did INT, district_name VARCHAR(255)); INSERT INTO district (did, district_name) VALUES (1, 'Central'), (2, 'North'), (3, 'South'); CREATE TABLE budget (budget_id INT, did INT, budget_amount DECIMAL(10, 2));
What is the total budget for emergency response in the 'North' district?
SELECT SUM(budget_amount) FROM budget WHERE did = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (id INT, name VARCHAR(20), year INT, safety_incidents INT); INSERT INTO vessels (id, name, year, safety_incidents) VALUES (1, 'Vessel A', 2019, 3), (2, 'Vessel B', 2019, 1), (3, 'Vessel A', 2020, 2), (4, 'Vessel C', 2020, 4), (5, 'Vessel A', 2021, 5), (6, 'Vessel B', 2021, 3);
Which vessels had the most safety incidents in the last 3 years?
SELECT name, SUM(safety_incidents) AS total_safety_incidents FROM vessels WHERE year >= 2019 GROUP BY name ORDER BY total_safety_incidents DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE species (id INT, name TEXT, location TEXT); INSERT INTO species (id, name, location) VALUES (1, 'Species A', 'Mediterranean Sea'); INSERT INTO species (id, name, location) VALUES (2, 'Species B', 'Caribbean Sea');
How many marine species are registered in the Mediterranean sea in the species table?
SELECT COUNT(*) FROM species WHERE location = 'Mediterranean Sea';
gretelai_synthetic_text_to_sql
CREATE TABLE sales (drug_class TEXT, drug_name TEXT, sales_amount INTEGER);
Which neurology drugs had sales greater than $100,000,000?
SELECT drug_class FROM sales WHERE drug_class = 'neurology' GROUP BY drug_class HAVING SUM(sales_amount) > 100000000;
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (DonationID INT, DonorID INT, DonationDate DATE); INSERT INTO Donations (DonationID, DonorID, DonationDate) VALUES (1, 1, '2023-01-01'), (2, 2, '2023-02-15'), (3, 1, '2023-04-05'), (4, 3, '2023-07-10'), (5, 4, '2023-10-25');
How many donors made donations in each month of 2023?
SELECT DATE_FORMAT(DonationDate, '%Y-%m') as Month, COUNT(DISTINCT DonorID) as DonorCount FROM Donations WHERE YEAR(DonationDate) = 2023 GROUP BY Month;
gretelai_synthetic_text_to_sql
CREATE TABLE SamariumProduction (country VARCHAR(50), year INT, production INT); INSERT INTO SamariumProduction (country, year, production) VALUES ('China', 2020, 1500), ('China', 2021, 1600), ('USA', 2020, 1200), ('USA', 2021, 1250), ('Australia', 2020, 900), ('Australia', 2021, 950);
Which country had the largest increase in Samarium production from 2020 to 2021?
SELECT country, MAX(production_change) FROM (SELECT country, (production - LAG(production) OVER (PARTITION BY country ORDER BY year)) AS production_change FROM SamariumProduction) AS subquery WHERE production_change IS NOT NULL GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE halal_cosmetics (sale_date DATE, revenue DECIMAL(10,2), manufacturing_country VARCHAR(20), halal_certified BOOLEAN); INSERT INTO halal_cosmetics (sale_date, revenue, manufacturing_country, halal_certified) VALUES ('2022-01-01', 45.00, 'Malaysia', TRUE), ('2022-01-02', 50.00, 'Indonesia', FALSE);
What was the average revenue per sale for halal-certified cosmetics in Malaysia in 2022?
SELECT AVG(revenue) FROM halal_cosmetics WHERE manufacturing_country = 'Malaysia' AND halal_certified = TRUE AND sale_date BETWEEN '2022-01-01' AND '2022-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE Cities (CityID INT, CityName VARCHAR(255)); CREATE TABLE Properties (PropertyID INT, PropertyTax FLOAT, InclusiveHousing BOOLEAN, CityID INT); INSERT INTO Cities VALUES (1, 'Portland'); INSERT INTO Properties VALUES (1, 5000, TRUE, 1);
What is the sum of property taxes for inclusive housing units in 'Portland'?
SELECT SUM(PropertyTax) FROM Properties p JOIN Cities c ON p.CityID = c.CityID WHERE p.InclusiveHousing = TRUE AND c.CityName = 'Portland';
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, PlayerCountry VARCHAR(20), Game VARCHAR(20)); INSERT INTO Players (PlayerID, PlayerCountry, Game) VALUES (1, 'USA', 'League of Legends'), (2, 'Canada', 'League of Legends'), (3, 'Mexico', 'League of Legends');
How many players are in the top 10 countries by player count for League of Legends?
SELECT COUNT(*) FROM (SELECT PlayerCountry, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) as rank FROM Players WHERE Game = 'League of Legends' GROUP BY PlayerCountry) WHERE rank <= 10;
gretelai_synthetic_text_to_sql
CREATE TABLE SpaceMissions (Id INT, Country VARCHAR(255), Mission VARCHAR(255), Status VARCHAR(255)); INSERT INTO SpaceMissions (Id, Country, Mission, Status) VALUES (1, 'USA', 'Apollo 11', 'Success'), (2, 'USA', 'Apollo 13', 'Failure'), (3, 'Russia', 'Vostok 1', 'Success'), (4, 'Russia', 'Soyuz 1', 'Failure');
How many space missions were successfully completed by each country?
SELECT Country, COUNT(*) as SuccessfulMissions FROM SpaceMissions WHERE Status = 'Success' GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE farmers (farmer_id INT PRIMARY KEY, name VARCHAR(255), age INT, location VARCHAR(255));
Insert data into the 'farmers' table
INSERT INTO farmers (farmer_id, name, age, location) VALUES (1, 'John Doe', 35, 'Springfield');
gretelai_synthetic_text_to_sql
CREATE TABLE workplaces (id INT, country VARCHAR(50), num_employees INT, has_lrv BOOLEAN); INSERT INTO workplaces (id, country, num_employees, has_lrv) VALUES (1, 'Spain', 500, true), (2, 'Spain', 300, false), (3, 'Spain', 400, true);
What is the total number of employees in workplaces with labor rights violations in Spain?
SELECT SUM(num_employees) FROM workplaces WHERE country = 'Spain' AND has_lrv = true;
gretelai_synthetic_text_to_sql
CREATE TABLE field_sizes (crop_type VARCHAR(50), location VARCHAR(50), area_acres FLOAT); INSERT INTO field_sizes (crop_type, location, area_acres) VALUES ('Soybean', 'Brazil', 650); INSERT INTO field_sizes (crop_type, location, area_acres) VALUES ('Soybean', 'Brazil', 475);
Find the total area of soybean fields in the 'field_sizes' table that are larger than 500 acres and are located in Brazil.
SELECT SUM(area_acres) FROM field_sizes WHERE crop_type = 'Soybean' AND location = 'Brazil' AND area_acres > 500;
gretelai_synthetic_text_to_sql
CREATE TABLE ai_apps (app_id INT, app_name VARCHAR(255), algorithm_id INT, safety_score FLOAT, launch_date DATE, region VARCHAR(255)); INSERT INTO ai_apps (app_id, app_name, algorithm_id, safety_score, launch_date, region) VALUES (1, 'App1', 1, 0.95, '2022-01-01', 'Brazil'), (2, 'App2', 2, 0.88, '2022-03-15', 'Mexico')...
List the top 3 AI algorithms with the highest safety scores, for applications launched in Latin America.
SELECT algorithm_id, safety_score FROM ai_apps WHERE region = 'Latin America' ORDER BY safety_score DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE deep_sea_expeditions (expedition_id INTEGER, max_depth FLOAT); INSERT INTO deep_sea_expeditions (expedition_id, max_depth) VALUES (1, 8000.0), (2, 9000.0), (3, 7000.0);
What is the maximum depth reached during deep-sea expeditions?
SELECT MAX(max_depth) FROM deep_sea_expeditions;
gretelai_synthetic_text_to_sql
CREATE TABLE assessment (id INT, name TEXT, state TEXT, assessment_year INT, assessment_company TEXT); INSERT INTO assessment (id, name, state, assessment_year, assessment_company) VALUES (1, 'Assessment A', 'California', 2019, 'Company A'); INSERT INTO assessment (id, name, state, assessment_year, assessment_company) ...
What is the total number of seismic assessments conducted in the state of California in the last 10 years and their respective assessment companies?
SELECT COUNT(*), assessment_company FROM assessment WHERE state = 'California' AND assessment_year >= 2011 GROUP BY assessment_company;
gretelai_synthetic_text_to_sql
CREATE TABLE clients (id INT, name VARCHAR(50), gender VARCHAR(50), location VARCHAR(50), financial_wellbeing_score FLOAT);
Find the average financial wellbeing score for clients in urban areas, grouped by gender.
SELECT gender, AVG(financial_wellbeing_score) FROM clients WHERE location LIKE '%urban%' GROUP BY gender;
gretelai_synthetic_text_to_sql
CREATE TABLE Fall2022 (garment_id INT, garment_name VARCHAR(50), retail_price DECIMAL(5,2)); INSERT INTO Fall2022 (garment_id, garment_name, retail_price) VALUES (1, 'Wool Coat', 250.00), (2, 'Cotton Shirt', 50.00), (3, 'Denim Jeans', 75.00);
What is the average retail price of garments produced in the "Fall 2022" collection?
SELECT AVG(retail_price) FROM Fall2022;
gretelai_synthetic_text_to_sql
CREATE TABLE students (id INT, name VARCHAR(50), gender VARCHAR(10), program VARCHAR(50), publications INT); INSERT INTO students (id, name, gender, program, publications) VALUES (1, 'Charlie', 'Non-binary', 'Arts', 2), (2, 'Dana', 'Female', 'Physics', 1), (3, 'Eli', 'Male', 'Engineering', 0);
What is the minimum number of publications for graduate students in the Engineering program?
SELECT MIN(s.publications) FROM students s WHERE s.program = 'Engineering';
gretelai_synthetic_text_to_sql
CREATE TABLE software_engineers (id INT, salary FLOAT, union_member BOOLEAN); INSERT INTO software_engineers (id, salary, union_member) VALUES (1, 90000.0, true), (2, 95000.0, false), (3, 85000.0, true);
What is the average salary of software engineers in the 'tech_company' database who are part of a union?
SELECT AVG(salary) FROM software_engineers WHERE union_member = true;
gretelai_synthetic_text_to_sql
CREATE TABLE incident_resolution_times (id INT, sector VARCHAR(255), incident_type VARCHAR(255), resolution_time FLOAT, occurrence_date DATE); INSERT INTO incident_resolution_times (id, sector, incident_type, resolution_time, occurrence_date) VALUES (1, 'Retail', 'Phishing', 6.5, '2021-02-03');
What was the average resolution time for phishing incidents in the retail sector in Asia in 2021?
SELECT AVG(resolution_time) AS avg_resolution_time FROM incident_resolution_times WHERE sector = 'Retail' AND incident_type = 'Phishing' AND occurrence_date >= '2021-01-01' AND occurrence_date < '2022-01-01' AND region = 'Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE Player (Player_ID INT, Name VARCHAR(50), Date_Joined DATE); INSERT INTO Player (Player_ID, Name, Date_Joined) VALUES (1, 'John Doe', '2019-06-15'), (2, 'Jane Smith', '2020-03-08'), (3, 'Alice Johnson', '2021-02-22'), (4, 'Bob Brown', '2020-08-10');
Insert a new record for a player with Player_ID 5, name 'Keisha Jones', and date 2021-09-15 into the 'Player' table
INSERT INTO Player (Player_ID, Name, Date_Joined) VALUES (5, 'Keisha Jones', '2021-09-15');
gretelai_synthetic_text_to_sql
CREATE TABLE SustainableTrends (id INT, trend VARCHAR(255), sustainability_score INT); INSERT INTO SustainableTrends (id, trend, sustainability_score) VALUES (1, 'Organic Cotton T-Shirt', 90), (2, 'Recycled Polyester Hoodie', 80), (3, 'Bamboo Viscose Pants', 85); CREATE TABLE CustomerSizes (id INT, size VARCHAR(255), c...
What is the most popular sustainable fashion trend among petite customers in the UK?
SELECT st.trend, c.country, MAX(c.percentage) AS popularity FROM SustainableTrends st CROSS JOIN CustomerSizes c WHERE c.size = 'XS' AND c.country = 'UK' GROUP BY st.trend, c.country;
gretelai_synthetic_text_to_sql
CREATE TABLE ThreatIntel (systemName VARCHAR(50), CVECount INT); INSERT INTO ThreatIntel (systemName, CVECount) VALUES ('SystemA', 3), ('SystemB', 5), ('SystemC', 7), ('SystemD', 2), ('SystemE', 6);
What are the top 5 most vulnerable systems by CVE count in the ThreatIntel database?
SELECT systemName, CVECount FROM ThreatIntel ORDER BY CVECount DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE employees (emp_id INT, dept_id INT, hire_date DATE, annual_salary INT); INSERT INTO employees (emp_id, dept_id, hire_date, annual_salary) VALUES (1, 1, '2018-01-01', 80000), (2, 2, '2019-05-05', 90000), (3, 3, '2020-07-01', 70000), (4, 1, '2020-12-30', 120000);
Delete all employee records with an annual salary greater than 100000 and hired after 2019-12-31.
DELETE FROM employees WHERE annual_salary > 100000 AND hire_date > '2019-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE daily_revenue (restaurant_name TEXT, category TEXT, daily_revenue NUMERIC, date DATE); INSERT INTO daily_revenue (restaurant_name, category, daily_revenue, date) VALUES ('Farm-to-Table Fusion', 'Asian Fusion', 800, '2023-04-01'), ('Farm-to-Table Fusion', 'Asian Fusion', 900, '2023-04-02'), ('Local Harvest ...
What was the minimum daily revenue for each restaurant category in Q2 2023?
SELECT category, MIN(daily_revenue) as min_daily_revenue FROM daily_revenue WHERE date BETWEEN '2023-04-01' AND '2023-06-30' GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE open_pedagogy_schools (id INT, school_name VARCHAR(50), student_ethnicity VARCHAR(50)); INSERT INTO open_pedagogy_schools (id, school_name, student_ethnicity) VALUES (1, 'Innovate School', 'Hispanic'), (2, 'Open Learning School', 'Asian');
What is the distribution of students by ethnicity in open pedagogy schools?
SELECT student_ethnicity, COUNT(*) FROM open_pedagogy_schools GROUP BY student_ethnicity;
gretelai_synthetic_text_to_sql
CREATE TABLE wildlife_species (id INT, type VARCHAR(255), species INT); INSERT INTO wildlife_species (id, type, species) VALUES (1, 'Coniferous', 50), (2, 'Deciduous', 70), (3, 'Mangrove', 60);
Provide the total number of wildlife species in each forest type.
SELECT wildlife_species.type, SUM(wildlife_species.species) FROM wildlife_species GROUP BY wildlife_species.type;
gretelai_synthetic_text_to_sql
CREATE TABLE destinations (id INT, country TEXT); INSERT INTO destinations (id, country) VALUES (1, 'France'), (2, 'Spain'), (3, 'Italy'); CREATE TABLE visits (id INT, visitor_origin TEXT, destination_id INT); INSERT INTO visits (id, visitor_origin, destination_id) VALUES (1, 'Germany', 1), (2, 'France', 2), (3, 'Irela...
Which destinations received the most visitors from the European Union?
SELECT d.country, COUNT(*) as num_visitors FROM visits v JOIN destinations d ON v.destination_id = d.id WHERE v.visitor_origin LIKE 'Europe%' GROUP BY d.country ORDER BY num_visitors DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE mars_missions (mission_name VARCHAR(255), budget FLOAT); INSERT INTO mars_missions (mission_name, budget) VALUES ('Mars Sample Return', 5000000000.00); INSERT INTO mars_missions (mission_name, budget) VALUES ('Mars Science Laboratory', 2800000000.00);
What is the maximum budget allocated for a single Mars mission?
SELECT MAX(budget) FROM mars_missions;
gretelai_synthetic_text_to_sql
CREATE TABLE tech_patents (location VARCHAR(255), is_accessible BOOLEAN); INSERT INTO tech_patents (location, is_accessible) VALUES ('Germany', true), ('France', false), ('UK', true);
What is the percentage of accessible technology patents in Europe?
SELECT location, COUNT(*) * 100.0 / SUM(COUNT(*)) OVER () as percentage_accessible FROM tech_patents WHERE location LIKE 'Europe%' AND is_accessible = true GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (name VARCHAR(255), weight FLOAT, location VARCHAR(255)); INSERT INTO marine_species (name, weight, location) VALUES ('Great White Shark', 2000.0, 'Pacific Ocean'), ('Giant Squid', 700.0, 'Atlantic Ocean');
Delete all records from the marine_species table where the weight is less than 1000
DELETE FROM marine_species WHERE weight < 1000;
gretelai_synthetic_text_to_sql