context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE atlantic_oxygen (year INT, oxygen FLOAT); INSERT INTO atlantic_oxygen (year, oxygen) VALUES (2017, 4.5), (2018, 4.8), (2019, 5.0), (2020, 5.2), (2021, 5.5);
What is the minimum dissolved oxygen level recorded in the Atlantic Ocean for the last 5 years?
SELECT MIN(oxygen) FROM atlantic_oxygen WHERE year BETWEEN (SELECT EXTRACT(YEAR FROM NOW()) - 5) AND EXTRACT(YEAR FROM NOW());
gretelai_synthetic_text_to_sql
CREATE TABLE neighborhoods (neighborhood_id INT, city VARCHAR(255), avg_property_price DECIMAL(10,2), num_properties INT); INSERT INTO neighborhoods (neighborhood_id, city, avg_property_price, num_properties) VALUES (1, 'NYC', 850000, 300), (2, 'NYC', 1200000, 250), (3, 'NYC', 1100000, 200), (4, 'LA', 600000, 400), (5,...
Calculate the total number of properties in neighborhoods below the median property price for their respective cities.
SELECT SUM(num_properties) FROM neighborhoods WHERE avg_property_price < (SELECT AVG(avg_property_price) FROM neighborhoods GROUP BY city)
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT, state VARCHAR(20), weight DECIMAL(10,2), month INT, year INT);
What was the total weight of cannabis sold in Texas in the fourth quarter of 2020?
SELECT SUM(weight) FROM sales WHERE state = 'Texas' AND month BETWEEN 10 AND 12 AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE creative_ai_applications (application_id INT, algorithm_type VARCHAR(50), usage INT); INSERT INTO creative_ai_applications (application_id, algorithm_type, usage) VALUES (1, 'Deep Learning', 100), (2, 'Computer Vision', 80), (3, 'Natural Language Processing', 90), (4, 'Reinforcement Learning', 70);
What is the algorithm type and the number of times it has been used in creative AI applications, ordered by usage in descending order?
SELECT algorithm_type, SUM(usage) as total_usage FROM creative_ai_applications GROUP BY algorithm_type ORDER BY total_usage DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE pacific_countries (country VARCHAR(255), id INTEGER); INSERT INTO pacific_countries (country, id) VALUES ('Canada', 1), ('Mexico', 2); CREATE TABLE fish_biomass (country_id INTEGER, value FLOAT);
What is the total biomass of fish in the Pacific Ocean by country?
SELECT p.country, SUM(f.value) FROM fish_biomass f JOIN pacific_countries p ON f.country_id = p.id GROUP BY p.country;
gretelai_synthetic_text_to_sql
CREATE TABLE drug_approval (drug_id INT, drug_name VARCHAR(255), approval_date DATE); INSERT INTO drug_approval (drug_id, drug_name, approval_date) VALUES (1, 'Drug1', '2020-01-01'), (2, 'Drug2', '2019-06-15'), (3, 'Drug3', '2021-03-20'), (4, 'Drug4', '2021-08-01'); CREATE TABLE drug_launch (drug_id INT, launch_date DA...
List drugs that were approved but not launched in Asia.
SELECT drug_name FROM drug_approval WHERE drug_id NOT IN (SELECT drug_id FROM drug_launch WHERE launch_region LIKE 'Asia%');
gretelai_synthetic_text_to_sql
CREATE TABLE dish_engineering (ingredient_id INT, organic BOOLEAN, dish_id INT, category VARCHAR(50));
What is the percentage of organic ingredients for each dish category?
SELECT category, COUNT(*) * 100.0 / (SELECT COUNT(*) FROM dish_engineering WHERE dish_id = dishes.id) as percentage FROM dish_engineering JOIN dishes ON dish_engineering.dish_id = dishes.id WHERE organic = TRUE GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE criminal_justice_reform (contributor_id INT, contributions INT); INSERT INTO criminal_justice_reform (contributor_id, contributions) VALUES (1, 5000), (2, 7000), (3, 8000), (4, 3000);
Who are the top three contributors to criminal justice reform initiatives?
SELECT contributor_id, contributions FROM criminal_justice_reform ORDER BY contributions DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE complaints (complaint_id INT, media_outlet VARCHAR(255), date DATE); INSERT INTO complaints (complaint_id, media_outlet, date) VALUES (1, 'ABC News', '2022-01-01'), (2, 'CNN', '2022-02-15'), (3, 'ABC News', '2021-12-31');
Identify the number of unique user complaints for each media outlet in the past year.
SELECT media_outlet, COUNT(DISTINCT complaint_id) as unique_complaints FROM complaints WHERE date >= DATE_SUB(NOW(), INTERVAL 1 YEAR) GROUP BY media_outlet;
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (id INT, name TEXT, country TEXT, signup_date DATE); INSERT INTO volunteers (id, name, country, signup_date) VALUES (1, 'Anna Muller', 'Germany', '2021-08-20'), (2, 'Benedict Schmidt', 'Austria', '2022-02-15');
How many volunteers signed up in 2021 from Germany?
SELECT COUNT(*) FROM volunteers WHERE country = 'Germany' AND YEAR(signup_date) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (sale_id INT, product_id INT, quantity INT, hypoallergenic BOOLEAN); CREATE TABLE products (product_id INT, product_name VARCHAR(255), category VARCHAR(255)); INSERT INTO sales (sale_id, product_id, quantity, hypoallergenic) VALUES (1, 1, 250, true), (2, 2, 75, false), (3, 3, 150, true); INSERT INTO ...
Find the number of hypoallergenic lotions that have been sold more than 200 times
SELECT COUNT(*) FROM sales JOIN products ON sales.product_id = products.product_id WHERE sales.quantity > 200 AND sales.hypoallergenic = true;
gretelai_synthetic_text_to_sql
CREATE TABLE exports (id INT, product VARCHAR(100), value INT, year INT, country VARCHAR(50)); INSERT INTO exports (id, product, value, year, country) VALUES (1, 'cotton', 5000, 2020, 'Burkina Faso');
What is the total value of agricultural exports from a specific country?
SELECT SUM(value) FROM exports WHERE product LIKE '%agricultural%' AND year = 2020 AND country = 'Burkina Faso'
gretelai_synthetic_text_to_sql
CREATE TABLE SiteJ (artifact_id INT, artifact_type TEXT, quantity INT); INSERT INTO SiteJ (artifact_id, artifact_type, quantity) VALUES (1, 'Pottery', 30), (2, 'Tools', 15), (3, 'Beads', 25); CREATE TABLE SiteK (artifact_id INT, artifact_type TEXT, quantity INT); INSERT INTO SiteK (artifact_id, artifact_type, quantity)...
What is the total quantity of 'Beads' artifacts in 'SiteJ' and 'SiteK'?
SELECT SUM(quantity) FROM SiteJ WHERE artifact_type = 'Beads' UNION ALL SELECT SUM(quantity) FROM SiteK WHERE artifact_type = 'Beads';
gretelai_synthetic_text_to_sql
CREATE TABLE salmon_population (species VARCHAR(255), population INT, year INT, region VARCHAR(255), PRIMARY KEY (species, year, region)); INSERT INTO salmon_population (species, population, year, region) VALUES ('Atlantic Salmon', 30000, 2018, 'Atlantic Ocean'), ('Atlantic Salmon', 28000, 2019, 'Atlantic Ocean'), ('Pa...
Which salmon species have experienced a decrease in population in the Atlantic Ocean since 2018?
SELECT species FROM salmon_population WHERE region = 'Atlantic Ocean' AND population < (SELECT population FROM salmon_population WHERE species = 'Atlantic Salmon' AND year = 2018 AND region = 'Atlantic Ocean' GROUP BY species);
gretelai_synthetic_text_to_sql
CREATE TABLE incidents (id INT, incident_date DATE, target_country VARCHAR(50)); INSERT INTO incidents (id, incident_date, target_country) VALUES (1, '2022-01-01', 'USA'), (2, '2022-01-02', 'Canada'), (3, '2022-01-03', 'USA');
Identify the top 3 most frequently targeted countries by threat actors in the past year.
SELECT target_country, COUNT(*) as num_incidents FROM incidents WHERE incident_date >= DATEADD(year, -1, GETDATE()) GROUP BY target_country ORDER BY num_incidents DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE energy_efficiency_state (state VARCHAR(50), improvement FLOAT); INSERT INTO energy_efficiency_state (state, improvement) VALUES ('State E', 3.5, 'State F', 4.2), ('State G', 5.0, 'State H', 2.8);
What is the energy efficiency improvement (in %) for each state, ranked from highest to lowest?
SELECT state, improvement, ROW_NUMBER() OVER (ORDER BY improvement DESC) as rank FROM energy_efficiency_state;
gretelai_synthetic_text_to_sql
CREATE TABLE savings (customer_id INT, name TEXT, state TEXT, savings DECIMAL(10, 2));
Insert a new customer record for 'Sophia Rodriguez' living in 'Florida' with savings of '12000'?
INSERT INTO savings (customer_id, name, state, savings) VALUES (13, 'Sophia Rodriguez', 'Florida', 12000);
gretelai_synthetic_text_to_sql
CREATE TABLE Player (PlayerID INT, Name VARCHAR(50), Country VARCHAR(50), Score INT);
What is the total score of players whose name starts with 'B' or 'C'?
SELECT SUM(Score) FROM Player WHERE Name LIKE 'B%' OR Name LIKE 'C%';
gretelai_synthetic_text_to_sql
CREATE TABLE Visitor_Log (Visitor_ID INT, Visit_Date DATE, Country VARCHAR(255)); INSERT INTO Visitor_Log (Visitor_ID, Visit_Date, Country) VALUES (1001, '2022-01-01', 'USA'), (1002, '2022-01-02', 'Canada'), (1003, '2022-01-03', 'Mexico'), (1001, '2022-02-01', 'USA');
Which countries had the highest number of repeat visitors in the last year?
SELECT Country, COUNT(DISTINCT Visitor_ID) AS Number_Of_Visitors, COUNT(*) - COUNT(DISTINCT Visitor_ID) AS Number_Of_Repeats FROM Visitor_Log WHERE Visit_Date >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR) GROUP BY Country ORDER BY Number_Of_Repeats DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE IntelligenceOperations (region TEXT, year INTEGER, num_operations INTEGER); INSERT INTO IntelligenceOperations (region, year, num_operations) VALUES ('Asia-Pacific', 2021, 15), ('Europe', 2021, 10), ('Asia-Pacific', 2020, 12), ('Europe', 2020, 14);
What is the total number of intelligence operations conducted last year?
SELECT SUM(num_operations) FROM IntelligenceOperations WHERE year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE patients (id INT, name TEXT, age INT, treatment TEXT); INSERT INTO patients (id, name, age, treatment) VALUES (1, 'Alice', 35, 'CBT'), (2, 'Bob', 42, 'DBT');
Delete the record for patient 'Bob' from the 'patients' table.
DELETE FROM patients WHERE name = 'Bob';
gretelai_synthetic_text_to_sql
CREATE TABLE public_participations (id INT, state VARCHAR, meeting INT, participants INT); INSERT INTO public_participations (id, state, meeting, participants) VALUES (1, 'New York', 1, 50), (2, 'New York', 2, 60);
What is the maximum number of public participations in government meetings in the state of New York?
SELECT MAX(participants) FROM public_participations WHERE state = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE ai_app_diversity (id INT, app_name VARCHAR(50), country VARCHAR(50), diversity_score FLOAT); INSERT INTO ai_app_diversity VALUES (1, 'DiversePainter', 'France', 0.87), (2, 'CreativeWriter', 'Canada', 0.91), (3, 'ArtisticCoder', 'USA', 0.83);
What is the average creative AI application diversity score in Europe and North America?
SELECT AVG(diversity_score) FROM ai_app_diversity WHERE country IN ('France', 'Canada', 'USA');
gretelai_synthetic_text_to_sql
CREATE TABLE district (did INT, name VARCHAR(255)); INSERT INTO district VALUES (1, 'Downtown'), (2, 'Uptown'); CREATE TABLE crimes (crime_id INT, district_id INT, year INT);
Find the number of crimes in each district in 2021.
SELECT d.name, COUNT(c.crime_id) FROM district d JOIN crimes c ON d.did = c.district_id WHERE c.year = 2021 GROUP BY d.did;
gretelai_synthetic_text_to_sql
CREATE TABLE energy_efficiency (id INT PRIMARY KEY, building_type VARCHAR(50), efficiency_rating FLOAT); INSERT INTO energy_efficiency (id, building_type, efficiency_rating) VALUES (1, 'Residential', 85.0), (2, 'Commercial', 80.0), (3, 'Residential', 90.0);
What is the maximum efficiency rating for residential buildings?
SELECT building_type, MAX(efficiency_rating) FROM energy_efficiency WHERE building_type = 'Residential';
gretelai_synthetic_text_to_sql
CREATE TABLE machinery (machine_id INT, manufacturer VARCHAR(20), energy_consumption INT); INSERT INTO machinery (machine_id, manufacturer, energy_consumption) VALUES (1, 'ABC Corp', 100), (2, 'XYZ Inc', 200), (3, 'ABC Corp', 150);
What is the average 'energy_consumption' of machines in the 'machinery' table, grouped by 'manufacturer'?
SELECT manufacturer, AVG(energy_consumption) FROM machinery GROUP BY manufacturer;
gretelai_synthetic_text_to_sql
CREATE TABLE Stadium (StadiumID int, StadiumName varchar(50), City varchar(50), Capacity int); CREATE TABLE Game (GameID int, StadiumID int, Attendance int); INSERT INTO Stadium (StadiumID, StadiumName, City, Capacity) VALUES (1, 'MetLife Stadium', 'East Rutherford', 82500), (2, 'AT&T Stadium', 'Arlington', 105000); I...
What is the average game attendance for each stadium?
SELECT s.StadiumName, AVG(g.Attendance) AS AvgAttendance FROM Stadium s JOIN Game g ON s.StadiumID = g.StadiumID GROUP BY s.StadiumID, s.StadiumName;
gretelai_synthetic_text_to_sql
CREATE TABLE EV_Charging_Prices (city VARCHAR(20), quarter INT, year INT, avg_price DECIMAL(5,2)); INSERT INTO EV_Charging_Prices (city, quarter, year, avg_price) VALUES ('Paris', 2, 2022, 0.25), ('Paris', 3, 2022, 0.26), ('Berlin', 2, 2022, 0.28), ('Berlin', 3, 2022, 0.29);
What was the average price of electric vehicle charging in Paris per kWh in Q2 2022?
SELECT AVG(avg_price) FROM EV_Charging_Prices WHERE city = 'Paris' AND quarter = 2 AND year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE passengers_by_station (line_name VARCHAR(50), station_name VARCHAR(50), passengers_served INT); INSERT INTO passengers_by_station (line_name, station_name, passengers_served) VALUES ('Yellow', 'Downtown', 700), ('Yellow', 'Uptown', 850), ('Yellow', 'Suburbia', 600);
What is the minimum number of passengers served by any station on the 'Yellow Line'?
SELECT MIN(passengers_served) FROM passengers_by_station WHERE line_name = 'Yellow';
gretelai_synthetic_text_to_sql
CREATE TABLE irrigation_systems (farm_name TEXT, irrigation_type TEXT); INSERT INTO irrigation_systems (farm_name, irrigation_type) VALUES ('Farm A', 'Center Pivot'), ('Farm B', 'Drip'), ('Farm C', 'Center Pivot');
List farms using center pivot irrigation systems
SELECT DISTINCT farm_name FROM irrigation_systems WHERE irrigation_type = 'Center Pivot';
gretelai_synthetic_text_to_sql
CREATE TABLE solar_power_plants (id INT, name TEXT, region TEXT, capacity_mw FLOAT); INSERT INTO solar_power_plants (id, name, region, capacity_mw) VALUES (1, 'Solar Plant A', 'north', 125.8); INSERT INTO solar_power_plants (id, name, region, capacity_mw) VALUES (2, 'Solar Plant B', 'south', 180.3); INSERT INTO solar_p...
Delete the solar power plant with the highest capacity in the 'east' region
DELETE FROM solar_power_plants WHERE id = (SELECT id FROM solar_power_plants WHERE region = 'east' ORDER BY capacity_mw DESC LIMIT 1);
gretelai_synthetic_text_to_sql
CREATE TABLE SafetyTests (ID INT, Vehicle TEXT, TestType TEXT, TestDate DATE); INSERT INTO SafetyTests (ID, Vehicle, TestType, TestDate) VALUES (1, 'Tesla Model 3', 'Crash Test', '2020-03-15'); INSERT INTO SafetyTests (ID, Vehicle, TestType, TestDate) VALUES (2, 'Ford F-150', 'Safety Inspection', '2020-07-22');
What is the total number of safety tests conducted in 2020?
SELECT COUNT(*) FROM SafetyTests WHERE YEAR(TestDate) = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, age INT, gender TEXT); INSERT INTO users (id, age, gender) VALUES (1, 25, 'male'), (2, 35, 'non-binary'), (3, 30, 'female'), (4, 45, 'male'), (5, 50, 'non-binary'), (6, 20, 'male'), (7, 40, 'non-binary'), (8, 33, 'female');
What is the total number of users and their average age?
SELECT COUNT(id) as total_users, AVG(age) as avg_age FROM users;
gretelai_synthetic_text_to_sql
CREATE TABLE user_ads (user_id INT, ad_date DATE); CREATE TABLE users (id INT, followers INT);
What is the average number of followers for users who engaged with at least 10 advertisements in the past month?
SELECT AVG(f.followers) FROM users f JOIN (SELECT user_id FROM user_ads WHERE ad_date >= CURRENT_DATE - INTERVAL '1 month' GROUP BY user_id HAVING COUNT(*) >= 10) t ON f.id = t.user_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, FirstName VARCHAR(50), LastName VARCHAR(50), Department VARCHAR(50), ManagerID INT); INSERT INTO Employees (EmployeeID, FirstName, LastName, Department, ManagerID) VALUES (1, 'Jane', 'Smith', 'Marketing', 2), (2, 'Bruce', 'Johnson', 'IT', NULL), (3, 'Alice', 'Williams', 'Marketin...
Identify employees who have not taken any training courses.
SELECT E.FirstName, E.LastName FROM Employees E LEFT JOIN EmployeeCourses EC ON E.EmployeeID = EC.EmployeeID WHERE EC.EmployeeID IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE Regions (region_id INT, region_name VARCHAR(50)); INSERT INTO Regions (region_id, region_name) VALUES (1, 'North'), (2, 'South'), (3, 'East'), (4, 'West'); CREATE TABLE Sales (sale_id INT, region_id INT, sale_date DATE, revenue DECIMAL(10,2)); INSERT INTO Sales (sale_id, region_id, sale_date, revenue) VALU...
What was the total revenue for each region in Q3 of 2021?
SELECT r.region_name, SUM(s.revenue) FROM Regions r JOIN Sales s ON r.region_id = s.region_id WHERE s.sale_date BETWEEN '2021-07-01' AND '2021-09-30' GROUP BY r.region_name;
gretelai_synthetic_text_to_sql
CREATE TABLE MedicalProfiles(astronaut_id INT, height INT, weight INT, nationality VARCHAR(50));
What is the total weight of astronauts from the USA?
SELECT SUM(weight) FROM MedicalProfiles WHERE nationality = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE ota_market_share (ota_id INT, region TEXT, market_share FLOAT, date DATE); INSERT INTO ota_market_share (ota_id, region, market_share, date) VALUES (1, 'UAE', 0.42, '2023-01-01'), (2, 'Saudi Arabia', 0.35, '2023-01-01'), (3, 'South Africa', 0.18, '2023-01-01'), (4, 'Egypt', 0.15, '2023-01-01');
What is the market share of the top 3 OTAs in the MEA region (Middle East and Africa) in Q1 2023?
SELECT SUM(market_share) FROM ota_market_share WHERE ota_id IN (1, 2, 3) AND region = 'MEA' AND date = '2023-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE supplier_data (supplier_name VARCHAR(50), material VARCHAR(50), industry VARCHAR(50)); INSERT INTO supplier_data (supplier_name, material, industry) VALUES ('SupplierH', 'Silicon', 'Renewable'), ('SupplierI', 'Nickel', 'Renewable'), ('SupplierJ', 'Lithium', 'Renewable'), ('SupplierK', 'Steel', 'Automotive'...
Which suppliers provide materials exclusively for the renewable energy sector?
SELECT supplier_name FROM supplier_data GROUP BY supplier_name HAVING COUNT(DISTINCT industry) = 1 AND MIN(industry) = 'Renewable';
gretelai_synthetic_text_to_sql
CREATE TABLE patients (id INT, name VARCHAR(50), age INT, gender VARCHAR(10), condition VARCHAR(50)); INSERT INTO patients (id, name, age, gender, condition) VALUES (3, 'Maria Garcia', 42, 'Female', 'Bipolar Disorder'); INSERT INTO patients (id, name, age, gender, condition) VALUES (4, 'Ahmed Khan', 30, 'Male', 'PTSD')...
What is the total number of patients and their average age, grouped by condition?
SELECT condition, COUNT(*) as num_patients, AVG(age) as avg_age FROM patients GROUP BY condition;
gretelai_synthetic_text_to_sql
CREATE TABLE departments (id INT, name VARCHAR(255)); INSERT INTO departments (id, name) VALUES (1, 'Human Resources'), (2, 'Public Works'), (3, 'Education'); CREATE TABLE employees (id INT, department_id INT, gender VARCHAR(10)); INSERT INTO employees (id, department_id, gender) VALUES (1, 1, 'Female'), (2, 2, 'Male')...
List all departments and the number of employees in each
SELECT d.name, COUNT(e.id) as employee_count FROM departments d LEFT JOIN employees e ON d.id = e.department_id GROUP BY d.id;
gretelai_synthetic_text_to_sql
CREATE TABLE Reports (Month VARCHAR(7), Count INT); INSERT INTO Reports (Month, Count) VALUES ('Jan-2021', 50), ('Feb-2021', 65), ('Mar-2021', 70), ('Apr-2021', 75), ('May-2021', 80), ('Jun-2021', 85), ('Jul-2021', 90), ('Aug-2021', 95), ('Sep-2021', 100), ('Oct-2021', 105), ('Nov-2021', 110), ('Dec-2021', 115);
How many threat intelligence reports were generated per month in 2021?
SELECT STR_TO_DATE(Month, '%b-%Y') AS Month, COUNT(*) FROM Reports GROUP BY Month;
gretelai_synthetic_text_to_sql
CREATE TABLE Events (EventID INT, EventDate DATE, TotalAttendees INT, CommunityType VARCHAR(255)); INSERT INTO Events (EventID, EventDate, TotalAttendees, CommunityType) VALUES (1, '2022-04-01', 75, 'Underrepresented'), (2, '2022-05-01', 30, 'Represented');
How many events had more than 50 attendees from historically underrepresented communities?
SELECT COUNT(*) FROM Events WHERE TotalAttendees > 50 AND CommunityType = 'Underrepresented';
gretelai_synthetic_text_to_sql
CREATE TABLE Vendors (VendorID INT, VendorName TEXT, Country TEXT);CREATE TABLE Products (ProductID INT, ProductName TEXT, Price DECIMAL, VendorID INT); INSERT INTO Vendors VALUES (1, 'VendorB', 'France'), (2, 'VendorC', 'Canada'), (3, 'VendorD', 'Brazil'); INSERT INTO Products VALUES (1, 'Shirt', 20, 1), (2, 'Pants', ...
What is the total revenue of products sold by vendors in France?
SELECT SUM(Price) FROM Products p JOIN Vendors v ON p.VendorID = v.VendorID WHERE v.Country = 'France';
gretelai_synthetic_text_to_sql
CREATE TABLE EmployeeTrainings (EmployeeID INT, Training VARCHAR(50), Country VARCHAR(50)); INSERT INTO EmployeeTrainings (EmployeeID, Training, Country) VALUES (1, 'Diversity and Inclusion', 'Canada'), (2, 'Cybersecurity', 'USA');
How many employees have completed diversity and inclusion training in Canada?
SELECT COUNT(*) FROM EmployeeTrainings WHERE Training = 'Diversity and Inclusion' AND Country = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE products(product_id INT, last_sale_date DATE); INSERT INTO products(product_id, last_sale_date) VALUES (1, '2022-01-01'), (2, '2021-12-01'), (3, NULL), (4, '2022-02-15');
Delete products with no sales in the last 6 months
DELETE FROM products WHERE last_sale_date < (CURRENT_DATE - INTERVAL '6 months');
gretelai_synthetic_text_to_sql
CREATE TABLE space_missions (country VARCHAR(30), launch_year INT, mission_name VARCHAR(50)); INSERT INTO space_missions VALUES ('USA', 2005, 'New Horizons'), ('China', 2003, 'Shenzhou 5'), ('India', 2014, 'Mangalyaan'), ('USA', 2011, 'Juno'), ('Russia', 2013, 'Mars Orbiter');
What is the earliest and latest launch year for space missions by each country in the space_missions table?
SELECT country, MIN(launch_year) OVER (PARTITION BY country) AS min_launch_year, MAX(launch_year) OVER (PARTITION BY country) AS max_launch_year FROM space_missions;
gretelai_synthetic_text_to_sql
CREATE TABLE smart_cities (city_id INT, city_name VARCHAR(50), country VARCHAR(50), population INT, smart_tech_adoption_date DATE);CREATE TABLE green_transportation (transportation_id INT, city_id INT, type VARCHAR(50), capacity INT, co2_emissions FLOAT, adoption_date DATE);CREATE VIEW smart_cities_transportation AS SE...
Calculate the average CO2 emissions per smart transportation type in smart cities, using a SQL query with a window function.
SELECT city_name, type, avg_emissions FROM smart_cities_transportation;
gretelai_synthetic_text_to_sql
CREATE TABLE species (id INT PRIMARY KEY, name VARCHAR(255), population INT, conservation_status VARCHAR(255)); INSERT INTO species (id, name, population, conservation_status) VALUES (1, 'Blue Whale', 10000, 'Endangered');
List species with conservation status
SELECT name, conservation_status FROM species;
gretelai_synthetic_text_to_sql
CREATE TABLE FarmingLocations (LocationID INT, LocationName VARCHAR(50)); INSERT INTO FarmingLocations (LocationID, LocationName) VALUES (1, 'Bay of Bengal'), (2, 'Mediterranean Sea'); CREATE TABLE DissolvedOxygen (MeasurementDate DATE, LocationID INT, DOLevel FLOAT);
What is the average dissolved oxygen level for each month in 2021, partitioned by farming location?
SELECT LocationID, AVG(DOLevel) OVER (PARTITION BY DATE_PART('year', MeasurementDate), DATE_PART('month', MeasurementDate), LocationID) AS AvgDOLevel, DATE_TRUNC('month', MeasurementDate) AS Month FROM DissolvedOxygen WHERE MeasurementDate >= '2021-01-01' AND MeasurementDate < '2022-01-01' ORDER BY LocationID, Month;
gretelai_synthetic_text_to_sql
CREATE TABLE monthly_fair_trade_sales (sale_id INT, product_id INT, quantity INT, revenue FLOAT, is_fair_trade BOOLEAN, sale_date DATE);
Show the monthly sales revenue trend of fair trade products in 2022
SELECT DATE_TRUNC('month', sale_date) as month, SUM(revenue) as monthly_revenue FROM monthly_fair_trade_sales WHERE is_fair_trade = TRUE AND sale_date BETWEEN '2022-01-01' AND '2022-12-31' GROUP BY month ORDER BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE FairnessAudits (audit_id INT, process_time FLOAT, audit_date DATE); INSERT INTO FairnessAudits (audit_id, process_time, audit_date) VALUES (1, 3.5, '2021-01-01'), (2, 4.2, '2021-02-01'), (3, 3.8, '2021-03-01');
What is the average processing time for fairness audits in the past year?
SELECT AVG(process_time) FROM FairnessAudits WHERE audit_date BETWEEN DATE_SUB('2022-01-01', INTERVAL 1 YEAR) AND '2022-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE music_albums (id INT, album_name VARCHAR(50), release_year INT);
Update the album name of record with id 1 in the music_albums table
UPDATE music_albums SET album_name = 'New Album' WHERE id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Spills (id INT, plant VARCHAR(255), spill_date DATE); INSERT INTO Spills (id, plant, spill_date) VALUES (1, 'PlantA', '2022-01-05'), (2, 'PlantB', '2022-02-12');
How many chemical spills occurred in the manufacturing plant in Q1 2022?
SELECT COUNT(*) FROM Spills WHERE spill_date >= '2022-01-01' AND spill_date < '2022-04-01' AND plant IN ('PlantA', 'PlantB')
gretelai_synthetic_text_to_sql
CREATE TABLE site (site_id INT, name TEXT, depth FLOAT); INSERT INTO site (site_id, name, depth) VALUES (1, 'Pacific', 123.45);
What is the minimum depth of all sites in the Pacific ocean?
SELECT MIN(depth) FROM site WHERE name = 'Pacific'
gretelai_synthetic_text_to_sql
CREATE TABLE marine_biomass (species VARCHAR(255), biomass FLOAT, location VARCHAR(255)); INSERT INTO marine_biomass (species, biomass, location) VALUES ('Tuna', 2500, 'Mediterranean Sea'), ('Squid', 1500, 'Mediterranean Sea');
What is the total biomass of all marine species in the Mediterranean Sea?
SELECT SUM(biomass) FROM marine_biomass WHERE location = 'Mediterranean Sea';
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (artist_id INT, city VARCHAR(50)); INSERT INTO Artists (artist_id, city) VALUES (1, 'Los Angeles'), (2, 'New York'), (3, 'Los Angeles'), (4, 'Miami'), (5, 'Chicago'); CREATE TABLE Concerts (concert_id INT, artist_id INT, city VARCHAR(50), revenue DECIMAL(10,2)); INSERT INTO Concerts (concert_id, ar...
Find the top 5 cities with the highest average concert revenue.
SELECT city, AVG(revenue) as avg_revenue FROM Concerts GROUP BY city ORDER BY avg_revenue DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE policies (id INT PRIMARY KEY, project_id INT, policy_name VARCHAR(255), description TEXT, FOREIGN KEY (project_id) REFERENCES projects(id)); INSERT INTO policies (id, project_id, policy_name, description) VALUES (3, 2, 'Carbon Tax', 'Implement a carbon tax for polluting industries.');
Which carbon offset programs have a policy_name associated with them?
SELECT projects.name, policies.policy_name FROM projects FULL OUTER JOIN policies ON projects.id = policies.project_id WHERE policies.policy_name IS NOT NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE PollutionAffectedSpecies (SpeciesID INT, PollutionID INT, FOREIGN KEY (SpeciesID) REFERENCES MarineSpecies(SpeciesID), FOREIGN KEY (PollutionID) REFERENCES PollutionSources(SourceID));
Which marine species are affected by pollution, according to the 'PollutionAffectedSpecies' table?
SELECT MarineSpecies.SpeciesName FROM MarineSpecies JOIN PollutionAffectedSpecies ON MarineSpecies.SpeciesID = PollutionAffectedSpecies.SpeciesID;
gretelai_synthetic_text_to_sql
CREATE TABLE Satellites (ID INT, Type VARCHAR(50), Lifespan INT); INSERT INTO Satellites (ID, Type, Lifespan) VALUES (1, 'Geostationary Satellite', 15), (2, 'Medium Earth Orbit Satellite', 10), (3, 'Low Earth Orbit Satellite', 5), (4, 'Polar Orbiting Satellite', 7), (5, 'Heliosynchronous Satellite', 8);
What is the average lifespan of geostationary satellites?
SELECT AVG(Lifespan) FROM Satellites WHERE Type = 'Geostationary Satellite';
gretelai_synthetic_text_to_sql
CREATE TABLE cybersecurity_incidents (id INT, country TEXT, incident_type TEXT, incident_date DATE); INSERT INTO cybersecurity_incidents (id, country, incident_type, incident_date) VALUES (1, 'France', 'Phishing', '2021-01-01'), (2, 'Japan', 'Malware', '2021-02-15');
List the cybersecurity incidents in Europe and Asia, along with the incident type and date.
SELECT c.country, c.incident_type, c.incident_date FROM cybersecurity_incidents c WHERE c.country IN ('Europe', 'Asia');
gretelai_synthetic_text_to_sql
CREATE TABLE manufacturers (manufacturer_id INT, manufacturer_name TEXT, region TEXT); INSERT INTO manufacturers (manufacturer_id, manufacturer_name, region) VALUES (1, 'ManufacturerA', 'North America'), (2, 'ManufacturerB', 'Europe'), (3, 'ManufacturerC', 'Asia'), (4, 'ManufacturerD', 'Asia'), (5, 'ManufacturerE', 'So...
Find the total number of employees trained on 'Lean Manufacturing' in the 'Europe' region.
SELECT m.region, SUM(wt.num_employees) as total_trained FROM manufacturers m JOIN workforce_training wt ON m.manufacturer_id = wt.manufacturer_id WHERE m.region = 'Europe' AND wt.training_topic = 'Lean Manufacturing' GROUP BY m.region;
gretelai_synthetic_text_to_sql
CREATE TABLE arctic_temperatures (year INT, avg_temperature FLOAT); INSERT INTO arctic_temperatures (year, avg_temperature) VALUES (2010, 1.5), (2011, 1.6), (2012, 1.7), (2013, 1.8), (2014, 1.9), (2015, 2.0), (2016, 2.1), (2017, 2.2), (2018, 2.3), (2019, 2.4), (2020, 2.5); CREATE TABLE global_temperatures (year INT, av...
What is the average temperature increase in the Arctic region between 2010 and 2020 compared to the global average temperature increase during the same period?
SELECT AVG(at.avg_temperature - gt.avg_temperature) * 100 AS arctic_global_temp_diff FROM arctic_temperatures at JOIN global_temperatures gt ON at.year = gt.year WHERE at.year BETWEEN 2010 AND 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE Programs (ProgramID INT, ProgramName VARCHAR(50), StartDate DATE); CREATE TABLE Volunteers (VolunteerID INT, ProgramID INT, SignUpDate DATE, Returned BOOLEAN); INSERT INTO Programs (ProgramID, ProgramName, StartDate) VALUES (1, 'ProgramA', '2024-01-01'), (2, 'ProgramB', '2024-01-01'), (3, 'ProgramC', '2024...
What is the percentage of volunteers who returned for a second time to each program in 2024, ordered by percentage in descending order?
SELECT p.ProgramName, COUNT(v.VolunteerID) * 100.0 / SUM(COUNT(v.VolunteerID)) OVER (PARTITION BY p.ProgramID) AS PercentageReturned FROM Programs p JOIN Volunteers v ON p.ProgramID = v.ProgramID WHERE YEAR(v.SignUpDate) = 2024 GROUP BY p.ProgramName, v.ProgramID, v.Returned ORDER BY PercentageReturned DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE software (id INT, name VARCHAR(50), version VARCHAR(50), vulnerability_count INT, vulnerability_date DATE); INSERT INTO software (id, name, version, vulnerability_count, vulnerability_date) VALUES (1, 'Windows 10', '21H2', 12, '2022-02-01'), (2, 'Windows 10', '20H2', 15, '2021-08-15'), (3, 'Google Chrome',...
Identify the top 3 most vulnerable software by the number of unique vulnerabilities in the last year.
SELECT name, SUM(vulnerability_count) as total_vulnerabilities FROM software WHERE vulnerability_date >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR) GROUP BY name ORDER BY total_vulnerabilities DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Dishes (DishID INT, DishName VARCHAR(50), CuisineType VARCHAR(50), CaloricContent INT); INSERT INTO Dishes VALUES (1, 'Pizza Margherita', 'Italian', 500), (2, 'Spaghetti Bolognese', 'Italian', 700), (3, 'Kung Pao Chicken', 'Chinese', 600), (4, 'Spring Rolls', 'Chinese', 300);
What is the average caloric content of dishes in the 'Italian' and 'Chinese' cuisine types?
SELECT AVG(CaloricContent) as AvgCaloricContent FROM Dishes WHERE CuisineType IN ('Italian', 'Chinese');
gretelai_synthetic_text_to_sql
CREATE TABLE menus (menu_id INT, item VARCHAR(255), category VARCHAR(255), is_meat BOOLEAN, price DECIMAL(10, 2)); INSERT INTO menus VALUES (1, 'Chicken Wings', 'Appetizers', false, 12.99); INSERT INTO menus VALUES (2, 'Beef Burger', 'Entrees', true, 15.99); INSERT INTO menus VALUES (3, 'Veggie Burger', 'Entrees', fals...
What is the total quantity of meat and non-meat entrees sold in each country?
SELECT s.country, SUM(CASE WHEN m.is_meat = true THEN s.quantity ELSE 0 END) as total_meat_quantity, SUM(CASE WHEN m.is_meat = false THEN s.quantity ELSE 0 END) as total_non_meat_quantity FROM sales s INNER JOIN menus m ON s.menu_id = m.menu_id GROUP BY s.country;
gretelai_synthetic_text_to_sql
CREATE TABLE water_usage (year INT, usage FLOAT); INSERT INTO water_usage (year, usage) VALUES (2018, 1234.56), (2019, 2345.67), (2020, 3456.78), (2021, 4567.89);
Determine the difference in water usage between the years 2019 and 2020
SELECT ABS(usage_2019.usage - usage_2020.usage) FROM (SELECT usage FROM water_usage WHERE year = 2019) AS usage_2019, (SELECT usage FROM water_usage WHERE year = 2020) AS usage_2020;
gretelai_synthetic_text_to_sql
CREATE TABLE projects (id INT, engineer_id INT, department VARCHAR(20), cost DECIMAL(10,2)); INSERT INTO projects (id, engineer_id, department, cost) VALUES (1, 1001, 'civil', 5000), (2, 1002, 'civil', 6000), (3, 1003, 'structural', 4000);
List all projects with their corresponding engineers, sorted by department and project cost.
SELECT p.id, p.engineer_id, p.department, p.cost FROM projects p ORDER BY department, cost;
gretelai_synthetic_text_to_sql
CREATE TABLE Auto_Sales (Vehicle_Type VARCHAR(20), Model VARCHAR(20), Battery_Range INT);
Which electric vehicles in the Auto_Sales table have a battery range greater than 300 miles?
SELECT Vehicle_Type, Model FROM Auto_Sales WHERE Vehicle_Type = 'Electric' AND Battery_Range > 300;
gretelai_synthetic_text_to_sql
CREATE TABLE Product_Ratings (rating_id INT, product_id INT, product_rating FLOAT, fair_trade_product BOOLEAN);
What is the average rating of fair trade products in each product category?
SELECT Product_Ratings.product_category, AVG(Product_Ratings.product_rating) as avg_rating FROM Product_Ratings INNER JOIN (SELECT product_id, product_category FROM Products WHERE Products.fair_trade_product = TRUE) as Fair_Trade_Products ON Product_Ratings.product_id = Fair_Trade_Products.product_id GROUP BY Product_R...
gretelai_synthetic_text_to_sql
CREATE TABLE ota_hotel_bookings_south_america (ota TEXT, country TEXT, has_hotel_bookings BOOLEAN); INSERT INTO ota_hotel_bookings_south_america (ota, country, has_hotel_bookings) VALUES ('Expedia', 'Brazil', true), ('Booking.com', 'Argentina', true), ('Agoda', 'Chile', true), ('MakeMyTrip', 'Brazil', false), ('Despega...
What is the number of OTAs that offer hotel bookings in 'South America'?
SELECT COUNT(*) FROM ota_hotel_bookings_south_america WHERE country IN ('Brazil', 'Argentina', 'Chile') AND has_hotel_bookings = true;
gretelai_synthetic_text_to_sql
CREATE TABLE city_listings (id INT, city VARCHAR(20), listing_price DECIMAL(10,2)); INSERT INTO city_listings (id, city, listing_price) VALUES (1, 'New York', 1200000.00), (2, 'Seattle', 800000.00), (3, 'Oakland', 500000.00), (4, 'Berkeley', 400000.00);
What is the average listing price for each city?
SELECT city, AVG(listing_price) FROM city_listings GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE subscribers (id INT, type VARCHAR(10), region VARCHAR(10)); INSERT INTO subscribers (id, type, region) VALUES (1, 'prepaid', 'tribal'), (2, 'postpaid', 'tribal'), (3, 'prepaid', 'tribal'); CREATE TABLE usage (subscriber_id INT, monthly_data_usage INT); INSERT INTO usage (subscriber_id, monthly_data_usage) ...
What is the maximum monthly mobile data usage for customers in the 'tribal' region?
SELECT MAX(monthly_data_usage) FROM usage JOIN subscribers ON usage.subscriber_id = subscribers.id WHERE subscribers.region = 'tribal';
gretelai_synthetic_text_to_sql
CREATE TABLE MusicTheater (concert_id INT, concert_name VARCHAR(50), date DATE, ticket_price DECIMAL(5,2), fan_age INT);
What is the average age and ticket price for concerts in 'MusicTheater' venue in 2022?
SELECT AVG(fan_age) AS avg_fan_age, AVG(ticket_price) AS avg_ticket_price FROM MusicTheater WHERE date >= '2022-01-01' AND date <= '2022-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID int, FirstName varchar(50), LastName varchar(50), Gender varchar(10), Salary int); INSERT INTO Employees (EmployeeID, FirstName, LastName, Gender, Salary) VALUES (1, 'John', 'Doe', 'Male', 50000); INSERT INTO Employees (EmployeeID, FirstName, LastName, Gender, Salary) VALUES (2, 'Jane...
What is the average salary for employees of each gender?
SELECT Gender, AVG(Salary) as AvgSalary FROM Employees GROUP BY Gender;
gretelai_synthetic_text_to_sql
CREATE TABLE artists (artist_id INT, country VARCHAR(50)); INSERT INTO artists (artist_id, country) VALUES (1, 'USA'), (2, 'Canada'), (3, 'Mexico'), (4, 'USA'), (5, 'Canada');
Count the number of artists from each country in the artists table.
SELECT country, COUNT(*) AS num_artists FROM artists GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE smart_contracts (contract_id serial, contract_name varchar(20), developer varchar(20)); INSERT INTO smart_contracts (contract_id, contract_name, developer) VALUES (1, 'ContractA', 'Alice'), (2, 'ContractB', 'Bob'), (3, 'ContractC', 'Carol');
Who are the developers for 'ContractA'?
SELECT developer FROM smart_contracts WHERE contract_name = 'ContractA';
gretelai_synthetic_text_to_sql
CREATE TABLE sales_history(drug varchar(10), year int, revenue int); INSERT INTO sales_history(drug, year, revenue) VALUES('DrugH', 2017, 3000), ('DrugH', 2018, 4000), ('DrugI', 2017, 2000), ('DrugI', 2018, 1500);
Which drugs had higher sales in '2018' than in '2017'?
SELECT drug FROM sales_history WHERE revenue IN (SELECT MAX(revenue) FROM sales_history GROUP BY year) GROUP BY drug HAVING COUNT(*) = 2
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_rates (state VARCHAR(20), year INT, recycling_rate FLOAT); INSERT INTO recycling_rates (state, year, recycling_rate) VALUES ('Texas', 2022, 45.0), ('Florida', 2022, 44.0), ('Georgia', 2022, 43.0);
Which state has the lowest recycling rate?
SELECT state, MIN(recycling_rate) FROM recycling_rates;
gretelai_synthetic_text_to_sql
CREATE TABLE network_towers (tower_id INT, city VARCHAR(20), investment_date DATE); INSERT INTO network_towers (tower_id, city, investment_date) VALUES (1, 'New York', '2018-01-01'), (2, 'New York', '2017-12-31'), (3, 'Texas', '2018-01-02');
List all network towers in the city of New York that have an investment date on or before 2017-12-31.
SELECT tower_id, city, investment_date FROM network_towers WHERE city = 'New York' AND investment_date <= '2017-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE Department (DepartmentID INT, DepartmentName VARCHAR(50)); INSERT INTO Department (DepartmentID, DepartmentName) VALUES (1, 'Bakery'); CREATE TABLE Items (ItemID INT, DepartmentID INT, ItemName VARCHAR(50), GlutenFree BOOLEAN); INSERT INTO Items (ItemID, DepartmentID, ItemName, GlutenFree) VALUES (1, 1, 'A...
How many gluten-free items are available in the bakery department?
SELECT COUNT(*) FROM Items WHERE GlutenFree = true AND DepartmentID = (SELECT DepartmentID FROM Department WHERE DepartmentName = 'Bakery');
gretelai_synthetic_text_to_sql
CREATE TABLE Infrastructure_Projects (id INT, name VARCHAR(100), province VARCHAR(50), type VARCHAR(50), cost FLOAT); INSERT INTO Infrastructure_Projects (id, name, province, type, cost) VALUES (1, 'Highway Expansion', 'Ontario', 'Transportation', 10000000); INSERT INTO Infrastructure_Projects (id, name, province, type...
What is the total cost of transportation projects in 'Ontario' and 'Quebec'?
SELECT SUM(cost) FROM Infrastructure_Projects WHERE province IN ('Ontario', 'Quebec') AND type = 'Transportation';
gretelai_synthetic_text_to_sql
CREATE TABLE attorneys (attorney_id INT, name TEXT, years_of_experience INT, gender TEXT); CREATE TABLE cases (case_id INT, attorney_id INT, outcome TEXT);
What is the average success rate of cases handled by attorneys who identify as female?
SELECT AVG(CASE WHEN cases.outcome = 'Success' THEN 1.0 ELSE 0.0 END) AS success_rate FROM cases INNER JOIN attorneys ON cases.attorney_id = attorneys.attorney_id WHERE attorneys.gender = 'Female';
gretelai_synthetic_text_to_sql
CREATE TABLE charging_stations (station_id INT, station_name VARCHAR(255), num_chargers INT, state VARCHAR(255), city VARCHAR(255));
what is the total number of charging stations in the state of California?
SELECT SUM(num_chargers) FROM charging_stations WHERE state = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name TEXT, industry TEXT, founding_year INT, funding FLOAT); INSERT INTO companies (id, name, industry, founding_year, funding) VALUES (1, 'Acme Inc', 'Fintech', 2010, 1000000.0); INSERT INTO companies (id, name, industry, founding_year, funding) VALUES (2, 'Beta Corp', 'Fintech', 2012, ...
List all companies that have not received any funding.
SELECT name FROM companies WHERE funding IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE Event (EventID INT, EventType VARCHAR(50), Region VARCHAR(50)); INSERT INTO Event (EventID, EventType, Region) VALUES (1, 'Conference', 'Northeast'), (2, 'Webinar', 'Southeast'), (3, 'Workshop', 'Midwest'), (4, 'Conference', 'West'), (5, 'Webinar', 'Northeast'), (6, 'Workshop', 'Southeast');
Determine the number of policy advocacy events by type in each region
SELECT Region, EventType, COUNT(EventID) as NumEvents FROM Event GROUP BY Region, EventType;
gretelai_synthetic_text_to_sql
CREATE TABLE drugs (drug_id INT, drug_name TEXT, sales_figure INT); INSERT INTO drugs (drug_id, drug_name, sales_figure) VALUES (1, 'DrugA', 500), (2, 'DrugB', 750);
What are the total sales figures for each drug in the 'drugs' table, grouped by drug name, including drugs with no sales?
SELECT d.drug_name, COALESCE(SUM(s.sales_figure), 0) AS total_sales FROM drugs d LEFT JOIN sales s ON d.drug_id = s.drug_id GROUP BY d.drug_name;
gretelai_synthetic_text_to_sql
CREATE TABLE articles (article_id INT PRIMARY KEY, title VARCHAR(255), content TEXT, publication_date DATE);
Delete all articles published before 2000 from the 'articles' table
DELETE FROM articles WHERE publication_date < '2000-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE digital_assets (asset_id INT PRIMARY KEY, asset_name VARCHAR(100), asset_type VARCHAR(50), circulating_supply INT);
Insert a new record into the 'digital_assets' table for the asset 'Ethereum' with an asset_type of 'Cryptocurrency' and a circulating_supply of 120000000
INSERT INTO digital_assets (asset_name, asset_type, circulating_supply) VALUES ('Ethereum', 'Cryptocurrency', 120000000);
gretelai_synthetic_text_to_sql
CREATE TABLE usa_tours (id INT, type VARCHAR(255), revenue FLOAT); INSERT INTO usa_tours (id, type, revenue) VALUES (1, 'Sustainable', 700.00), (2, 'Cultural', 800.00);
What is the minimum revenue generated from any sustainable tour in the USA?
SELECT MIN(revenue) FROM usa_tours WHERE type = 'Sustainable';
gretelai_synthetic_text_to_sql
CREATE TABLE ai_models (model_name TEXT, data_country TEXT); INSERT INTO ai_models (model_name, data_country) VALUES ('ModelA', 'USA'), ('ModelB', 'Germany'), ('ModelC', 'China'), ('ModelD', 'Brazil');
Which AI models were trained on data from which countries?
SELECT model_name, data_country FROM ai_models;
gretelai_synthetic_text_to_sql
CREATE TABLE military_sales (id INT, company VARCHAR(255), country VARCHAR(255), sale_value DECIMAL(10,2), sale_date DATE); INSERT INTO military_sales (id, company, country, sale_value, sale_date) VALUES (1, 'Lockheed Martin', 'Canada', 500000, '2018-01-01'); INSERT INTO military_sales (id, company, country, sale_value...
What is the total value of military equipment sales to the Canadian government by Lockheed Martin in the last 5 years?
SELECT SUM(sale_value) FROM military_sales WHERE company = 'Lockheed Martin' AND country = 'Canada' AND sale_date >= DATE_SUB(CURDATE(), INTERVAL 5 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE attorneys (id INT, office_location VARCHAR(50), name VARCHAR(50), years_of_experience INT, specialty VARCHAR(50)); INSERT INTO attorneys (id, office_location, name, years_of_experience, specialty) VALUES (1, 'New York', 'John Doe', 12, 'Criminal Law'); INSERT INTO attorneys (id, office_location, name, year...
How many cases were won by attorneys from the New York office?
SELECT COUNT(*) FROM cases JOIN attorneys ON cases.attorney_id = attorneys.id WHERE attorneys.office_location = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE HalalCosmetics (product_id INT, product_name TEXT, category TEXT, price DECIMAL(10, 2), country TEXT, is_halal BOOLEAN); CREATE VIEW MiddleEasternHalalCosmetics AS SELECT * FROM HalalCosmetics WHERE country LIKE 'Middle East%' AND is_halal = TRUE;
Which halal cosmetics have the lowest price point in the Middle Eastern market?
SELECT * FROM MiddleEasternHalalCosmetics ORDER BY price LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE mining_operations (id INT PRIMARY KEY, operation_name VARCHAR(50), location VARCHAR(50), num_employees INT);
What is the total number of employees in the 'mining_operations' table?
SELECT SUM(num_employees) FROM mining_operations;
gretelai_synthetic_text_to_sql
CREATE TABLE defense_diplomacy (id INT PRIMARY KEY, event_name VARCHAR(100), budget DECIMAL(10, 2), region VARCHAR(50)); INSERT INTO defense_diplomacy (id, event_name, budget, region) VALUES (1, 'Event 1', 50000, 'Asia-Pacific'), (2, 'Event 2', 75000, 'Asia-Pacific'), (3, 'Event 3', 30000, 'Asia-Pacific');
What is the minimum defense diplomacy budget for events in the Asia-Pacific region?
SELECT MIN(budget) FROM defense_diplomacy WHERE region = 'Asia-Pacific';
gretelai_synthetic_text_to_sql
CREATE TABLE brands (brand_id INT, brand_name VARCHAR(255)); INSERT INTO brands (brand_id, brand_name) VALUES (1, 'BrandA'), (2, 'BrandB'); CREATE TABLE products (product_id INT, brand_id INT, material VARCHAR(255), price DECIMAL(10, 2)); INSERT INTO products (product_id, brand_id, material, price) VALUES (1, 1, 'organ...
What is the average price of organic cotton products for each brand?
SELECT brand_name, AVG(price) as avg_price FROM products JOIN brands ON products.brand_id = brands.brand_id WHERE material = 'organic cotton' GROUP BY brand_name;
gretelai_synthetic_text_to_sql
CREATE TABLE wells (well_id INT, name VARCHAR(50), location VARCHAR(50), production FLOAT); INSERT INTO wells (well_id, name, location, production) VALUES (1, 'B1', 'Gulf of Mexico', 12000), (2, 'B2', 'Gulf of Mexico', 15000), (3, 'B3', 'Gulf of Mexico', 18000);
Which are the top three producing wells in the Gulf of Mexico?
SELECT name, production FROM wells WHERE location = 'Gulf of Mexico' ORDER BY production DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE sustainable_policies (id INT, policy_name VARCHAR(255), city VARCHAR(255)); INSERT INTO sustainable_policies (id, policy_name, city) VALUES (1, 'Policy A', 'City X'), (2, 'Policy B', 'City Y'), (3, 'Policy C', 'City Z'), (4, 'Policy D', 'City X'), (5, 'Policy E', 'City Y');
What is the total number of sustainable policies in sustainable_policies table?
SELECT COUNT(*) FROM sustainable_policies;
gretelai_synthetic_text_to_sql