context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE clients (client_id INT, region VARCHAR(20), currency VARCHAR(10)); INSERT INTO clients (client_id, region, currency) VALUES (1, 'Europe', 'EUR'), (2, 'Asia', 'USD'), (3, 'Africa', 'USD'), (4, 'Americas', 'USD'), (5, 'Americas', 'CAD'); CREATE TABLE assets (asset_id INT, client_id INT, value INT); INSERT INTO assets (asset_id, client_id, value) VALUES (1, 1, 5000), (2, 1, 7000), (3, 2, 3000), (4, 3, 10000), (5, 4, 2000), (6, 5, 3000), (7, 4, 4000), (8, 5, 5000);
What is the total value of assets for clients in the 'Americas' region, grouped by currency?
SELECT clients.currency, SUM(assets.value) AS total_assets FROM clients INNER JOIN assets ON clients.client_id = assets.client_id WHERE clients.region = 'Americas' GROUP BY clients.currency;
gretelai_synthetic_text_to_sql
CREATE TABLE landfill_capacity (location TEXT, current_capacity INTEGER, total_capacity INTEGER); INSERT INTO landfill_capacity (location, current_capacity, total_capacity) VALUES ('site3', 90000, 120000);
Update the current capacity of landfill 'site3' by a specified amount.
UPDATE landfill_capacity SET current_capacity = current_capacity - 2000 WHERE location = 'site3';
gretelai_synthetic_text_to_sql
CREATE TABLE program_donations (program_id INT, donation_id INT, donation_amount DECIMAL(10,2)); INSERT INTO program_donations (program_id, donation_id, donation_amount) VALUES (1, 1, 50.00); INSERT INTO program_donations (program_id, donation_id, donation_amount) VALUES (1, 2, 50.00); INSERT INTO program_donations (program_id, donation_id, donation_amount) VALUES (2, 3, 100.00); INSERT INTO program_donations (program_id, donation_id, donation_amount) VALUES (3, 4, 75.00); INSERT INTO program_donations (program_id, donation_id, donation_amount) VALUES (3, 5, 25.00); INSERT INTO program_donations (program_id, donation_id, donation_amount) VALUES (4, 6, 150.00);
What is the average donation amount for each program?
SELECT program_id, AVG(donation_amount) FROM program_donations GROUP BY program_id;
gretelai_synthetic_text_to_sql
CREATE TABLE vessel_types (vessel_type VARCHAR(50), min_speed DECIMAL(5,2)); CREATE TABLE vessel_performance (vessel_id INT, vessel_type VARCHAR(50), speed DECIMAL(5,2));
What is the minimum speed for vessels of type 'container ship'?
SELECT min_speed FROM vessel_types WHERE vessel_type = 'container ship';
gretelai_synthetic_text_to_sql
CREATE TABLE policy_info (policy_id INT, policy_holder TEXT, coverage_amount INT); INSERT INTO policy_info (policy_id, policy_holder, coverage_amount) VALUES (1, 'John Smith', 600000), (2, 'Jane Doe', 400000), (3, 'Mike Johnson', 700000);
Update 'John Smith's' policy coverage amount to $750,000 in the policy_info table
UPDATE policy_info SET coverage_amount = 750000 WHERE policy_holder = 'John Smith';
gretelai_synthetic_text_to_sql
CREATE TABLE EcoFriendlyTours (tour_id INT, tour_name TEXT, country TEXT, local_economic_impact FLOAT); INSERT INTO EcoFriendlyTours (tour_id, tour_name, country, local_economic_impact) VALUES (1, 'Rainforest Adventure', 'Costa Rica', 11000.0), (2, 'Volcano Hike', 'Costa Rica', 10000.0);
What is the average local economic impact of eco-friendly tours in Costa Rica?
SELECT AVG(local_economic_impact) FROM EcoFriendlyTours WHERE country = 'Costa Rica';
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, name VARCHAR(50), region VARCHAR(20), account_balance DECIMAL(10,2)); INSERT INTO customers (customer_id, name, region, account_balance) VALUES (1, 'John Doe', 'South', 5000.00), (2, 'Jane Smith', 'North', 7000.00);
What is the average account balance for the top 25% of socially responsible lending customers in the South region?
SELECT AVG(account_balance) FROM (SELECT account_balance FROM customers WHERE region = 'South' AND product_type = 'Socially Responsible Lending' ORDER BY account_balance DESC LIMIT 25) AS top_customers;
gretelai_synthetic_text_to_sql
CREATE TABLE Cases (CaseID INT, AttorneyID INT, OfficeLocation VARCHAR(20)); INSERT INTO Cases (CaseID, AttorneyID, OfficeLocation) VALUES (101, 1, 'Downtown'), (102, 3, 'Uptown'), (103, 2, 'Downtown'); CREATE TABLE Attorneys (AttorneyID INT, OfficeLocation VARCHAR(20)); INSERT INTO Attorneys (AttorneyID, OfficeLocation) VALUES (1, 'Downtown'), (2, 'Uptown'), (3, 'Uptown');
How many cases were won by attorneys from the 'Downtown' office location?
SELECT COUNT(*) FROM Cases JOIN Attorneys ON Cases.AttorneyID = Attorneys.AttorneyID WHERE OfficeLocation = 'Downtown';
gretelai_synthetic_text_to_sql
CREATE TABLE patients (id INT, name TEXT); CREATE TABLE therapy_sessions (id INT, patient_id INT); CREATE TABLE medication_management (id INT, patient_id INT); INSERT INTO patients (id, name) VALUES (1, 'John Doe'); INSERT INTO patients (id, name) VALUES (2, 'Jane Smith'); INSERT INTO therapy_sessions (id, patient_id) VALUES (1, 1); INSERT INTO therapy_sessions (id, patient_id) VALUES (2, 2); INSERT INTO medication_management (id, patient_id) VALUES (1, 1);
List all patients who received both therapy and medication management?
SELECT patients.name FROM patients INNER JOIN therapy_sessions ON patients.id = therapy_sessions.patient_id INNER JOIN medication_management ON patients.id = medication_management.patient_id;
gretelai_synthetic_text_to_sql
CREATE TABLE inventory (warehouse_id VARCHAR(5), total_quantity INT); INSERT INTO inventory (warehouse_id, total_quantity) VALUES ('W01', 600), ('W02', 450), ('W03', 700), ('W04', 300);
Which warehouse has the least inventory?
SELECT warehouse_id FROM inventory ORDER BY total_quantity LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE factories (factory_id INT, name VARCHAR(100), location VARCHAR(100), sector VARCHAR(100), production_output INT); INSERT INTO factories (factory_id, name, location, sector, production_output) VALUES (1, 'ABC Factory', 'New York', 'Wind', 5500), (2, 'XYZ Factory', 'California', 'Solar', 4000), (3, 'LMN Factory', 'Texas', 'Wind', 6000), (4, 'PQR Factory', 'Canada', 'Hydro', 7000);
What is the average production output of factories in the wind energy sector?
SELECT AVG(production_output) FROM factories WHERE sector = 'Wind';
gretelai_synthetic_text_to_sql
CREATE TABLE temperature_data (crop_type VARCHAR(50), measurement_date DATE, temperature DECIMAL(5,2));
Determine the maximum temperature for soybeans in the last week
SELECT MAX(temperature) FROM temperature_data WHERE crop_type = 'soybeans' AND measurement_date >= NOW() - INTERVAL '7 days';
gretelai_synthetic_text_to_sql
CREATE TABLE Chemicals (Id INT, Name VARCHAR(255), Manufacturing_Country VARCHAR(255)); CREATE TABLE Safety_Protocols (Id INT, Chemical_Id INT, Safety_Measure VARCHAR(255)); INSERT INTO Chemicals (Id, Name, Manufacturing_Country) VALUES (1, 'Hydrochloric Acid', 'USA'); INSERT INTO Safety_Protocols (Id, Chemical_Id, Safety_Measure) VALUES (1, 1, 'Respirator');
Which chemicals require 'Respirator' safety measures in the USA?
SELECT Chemicals.Name FROM Chemicals INNER JOIN Safety_Protocols ON Chemicals.Id = Safety_Protocols.Chemical_Id WHERE Safety_Protocols.Safety_Measure = 'Respirator';
gretelai_synthetic_text_to_sql
CREATE TABLE SeafoodAustraliaNZ (id INT, country VARCHAR(50), year INT, tons_produced INT); INSERT INTO SeafoodAustraliaNZ (id, country, year, tons_produced) VALUES (1, 'Australia', 2018, 1800), (2, 'New Zealand', 2018, 1900), (3, 'Australia', 2018, 1700), (4, 'New Zealand', 2018, 1600);
What is the maximum amount of seafood (in tons) produced by aquaculture farms in Australia and New Zealand, for the year 2018?
SELECT MAX(tons_produced) FROM SeafoodAustraliaNZ WHERE country IN ('Australia', 'New Zealand') AND year = 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE salesperson_sales (salesperson_id INT, salesperson_name VARCHAR(255), sale_date DATE, revenue DECIMAL(10,2)); INSERT INTO salesperson_sales (salesperson_id, salesperson_name, sale_date, revenue) VALUES (1, 'John Doe', '2022-01-02', 100.00), (2, 'Jane Smith', '2022-01-03', 150.00), (3, 'Bob Johnson', '2022-01-04', 200.00);
What was the total revenue for each salesperson in the first quarter of 2022?
SELECT salesperson_name, SUM(revenue) as total_revenue FROM salesperson_sales WHERE sale_date BETWEEN '2022-01-01' AND '2022-03-31' GROUP BY salesperson_name;
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, donor_name TEXT, campaign TEXT, amount INT, donation_date DATE); INSERT INTO donations (id, donor_name, campaign, amount, donation_date) VALUES (1, 'John Doe', 'Housing for All', 25, '2021-01-01'); INSERT INTO donations (id, donor_name, campaign, amount, donation_date) VALUES (2, 'Jane Smith', 'Housing for All', 50, '2021-03-12'); INSERT INTO donations (id, donor_name, campaign, amount, donation_date) VALUES (3, 'Michael Lee', 'Housing for All', 75, '2021-05-25');
What is the minimum donation amount received for the 'Housing for All' campaign?
SELECT MIN(amount) FROM donations WHERE campaign = 'Housing for All';
gretelai_synthetic_text_to_sql
CREATE TABLE production_time(garment VARCHAR(20), region VARCHAR(20), production_time INT); INSERT INTO production_time VALUES('Jackets', 'North America', 20);
Find the 'Production Time' for 'Jackets' in 'North America'.
SELECT production_time FROM production_time WHERE garment = 'Jackets' AND region = 'North America';
gretelai_synthetic_text_to_sql
CREATE TABLE reo_production (id INT PRIMARY KEY, reo_type VARCHAR(50), production_quantity INT, production_year INT);
Get the total production quantity of Dysprosium Oxide in 2022 from the reo_production table
SELECT SUM(production_quantity) FROM reo_production WHERE reo_type = 'Dysprosium Oxide' AND production_year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE TuberculosisInfections (ID INT, PatientName VARCHAR(50), Region VARCHAR(50), InfectionDate DATE); INSERT INTO TuberculosisInfections (ID, PatientName, Region, InfectionDate) VALUES (1, 'John', 'North', '2021-01-01');
What is the infection rate for Tuberculosis in each region, ordered by the infection rate?
SELECT Region, COUNT(*) * 100000 / (SELECT COUNT(*) FROM TuberculosisInfections) AS InfectionRate FROM TuberculosisInfections GROUP BY Region ORDER BY InfectionRate DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE LandfillCapacity (year INT, region VARCHAR(50), landfill VARCHAR(50), capacity FLOAT, filled_volume FLOAT); INSERT INTO LandfillCapacity (year, region, landfill, capacity, filled_volume) VALUES (2018, 'North America', 'Landfill A', 100000, 95000), (2018, 'Europe', 'Landfill B', 120000, 110000), (2018, 'Asia', 'Landfill C', 150000, 145000), (2018, 'South America', 'Landfill D', 80000, 78000), (2018, 'Africa', 'Landfill E', 70000, 68000);
How many landfills had reached their capacity in 2018, including only data from South America and Africa?
SELECT COUNT(*) FROM LandfillCapacity WHERE year = 2018 AND region IN ('South America', 'Africa') AND filled_volume >= capacity;
gretelai_synthetic_text_to_sql
CREATE TABLE subscribers (id INT, name TEXT, data_usage FLOAT, region TEXT); INSERT INTO subscribers (id, name, data_usage, region) VALUES (1, 'John Doe', 15.0, 'rural'); INSERT INTO subscribers (id, name, data_usage, region) VALUES (2, 'Jane Smith', 20.0, 'rural');
What is the average monthly data usage for customers in the 'rural' region?
SELECT AVG(data_usage) FROM subscribers WHERE region = 'rural';
gretelai_synthetic_text_to_sql
CREATE TABLE VolunteerPrograms (VolunteerID INT, ProgramID INT, VolunteerName TEXT);
What are the names of the volunteers who have participated in both the Education and Health programs from the VolunteerPrograms table?
SELECT VolunteerName FROM VolunteerPrograms WHERE ProgramID IN (1, 2) GROUP BY VolunteerName HAVING COUNT(DISTINCT ProgramID) = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT, brand VARCHAR(255), revenue FLOAT, return_reason VARCHAR(255));
What is the total revenue for each brand, excluding returns?
SELECT brand, SUM(revenue) FROM sales WHERE return_reason IS NULL GROUP BY brand;
gretelai_synthetic_text_to_sql
CREATE TABLE forests_carbon_trend (id INT, type VARCHAR(20), year INT, carbon FLOAT); INSERT INTO forests_carbon_trend (id, type, year, carbon) VALUES (1, 'Temperate', 2020, 1200000), (2, 'Temperate', 2021, 1300000);
Determine the yearly increase in carbon sequestration for all forest types
SELECT type, YEAR(creation_date) AS year, SUM(carbon) - LAG(SUM(carbon)) OVER (PARTITION BY type ORDER BY YEAR(creation_date)) AS yearly_increase FROM forests_carbon_trend GROUP BY type, year;
gretelai_synthetic_text_to_sql
CREATE TABLE startups(id INT, name TEXT, industry TEXT, founder_ability TEXT); INSERT INTO startups (id, name, industry, founder_ability) VALUES (1, 'RetailAbility', 'Retail', 'Disabled');
What is the count of startups founded by people with disabilities in the retail sector?
SELECT COUNT(*) FROM startups WHERE industry = 'Retail' AND founder_ability = 'Disabled';
gretelai_synthetic_text_to_sql
CREATE TABLE OrganicProducts (product VARCHAR(255), country VARCHAR(255), revenue DECIMAL(10,2)); INSERT INTO OrganicProducts (product, country, revenue) VALUES ('Cleanser', 'UK', 500), ('Toner', 'UK', 700), ('Moisturizer', 'UK', 800), ('Cleanser', 'UK', 600);
What is the total revenue of organic skincare products in the UK?
SELECT SUM(revenue) FROM OrganicProducts WHERE product LIKE 'Cleanser%' OR product LIKE 'Toner%' OR product LIKE 'Moisturizer%' AND country = 'UK';
gretelai_synthetic_text_to_sql
CREATE TABLE health_metrics (id INT, species VARCHAR(50), metric FLOAT); INSERT INTO health_metrics (id, species, metric) VALUES (1, 'Tilapia', 75.0), (2, 'Catfish', 80.0), (3, 'Salmon', 60.0);
Which aquatic species have health metrics below average?
SELECT species FROM health_metrics WHERE metric < (SELECT AVG(metric) FROM health_metrics);
gretelai_synthetic_text_to_sql
CREATE TABLE mitigation_projects (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), budget FLOAT, start_date DATE, end_date DATE);
Create a table named 'mitigation_projects'
CREATE TABLE mitigation_projects (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), budget FLOAT, start_date DATE, end_date DATE);
gretelai_synthetic_text_to_sql
CREATE TABLE teacher_pd (teacher_id INT, name TEXT, pd_hours INT, pd_date DATE); INSERT INTO teacher_pd (teacher_id, name, pd_hours, pd_date) VALUES (1, 'John Doe', 15, '2022-01-01'), (2, 'Jane Smith', 25, '2022-01-15'), (3, 'Mike Johnson', 10, '2022-02-01');
List the names and professional development hours of teachers who have completed more than 20 hours of professional development in the last 6 months.
SELECT name, pd_hours FROM teacher_pd WHERE pd_date >= DATEADD(month, -6, GETDATE()) AND pd_hours > 20;
gretelai_synthetic_text_to_sql
CREATE TABLE Excavations (ExcavationID INT, Site VARCHAR(50)); INSERT INTO Excavations (ExcavationID, Site) VALUES (1, 'Ancient City'); INSERT INTO Excavations (ExcavationID, Site) VALUES (2, 'Lost Village'); CREATE TABLE Artifacts (ArtifactID INT, ExcavationID INT, Type VARCHAR(50), Quantity INT); INSERT INTO Artifacts (ArtifactID, ExcavationID, Type, Quantity) VALUES (1, 1, 'Pottery', 35); INSERT INTO Artifacts (ArtifactID, ExcavationID, Type, Quantity) VALUES (2, 1, 'Tools', 18); INSERT INTO Artifacts (ArtifactID, ExcavationID, Type, Quantity) VALUES (3, 2, 'Pottery', 22); INSERT INTO Artifacts (ArtifactID, ExcavationID, Type, Quantity) VALUES (4, 2, 'Beads', 45);
How many artifacts of each type were found during the 'Ancient City' excavation?
SELECT E.Site, A.Type, SUM(A.Quantity) FROM Artifacts A INNER JOIN Excavations E ON A.ExcavationID = E.ExcavationID GROUP BY E.Site, A.Type;
gretelai_synthetic_text_to_sql
CREATE TABLE trades (id INT, asset VARCHAR(20), volume DECIMAL(20,2), trade_date DATE); INSERT INTO trades VALUES (1, 'BTC', 1000000, '2022-01-01'); INSERT INTO trades VALUES (2, 'ETH', 2000000, '2022-01-01'); INSERT INTO trades VALUES (3, 'USDT', 500000, '2022-01-01'); INSERT INTO trades VALUES (4, 'ADA', 800000, '2022-01-01'); INSERT INTO trades VALUES (5, 'SOL', 1200000, '2022-01-01');
What is the daily trading volume for the top 5 digital assets?
SELECT asset, SUM(volume) as daily_volume FROM trades WHERE trade_date = '2022-01-01' GROUP BY asset ORDER BY daily_volume DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE stellar_network (network_name VARCHAR(20), total_market_cap DECIMAL(10,2)); INSERT INTO stellar_network (network_name, total_market_cap) VALUES ('Stellar', 15000000.56);
What is the total market capitalization of all digital assets on the Stellar network?
SELECT total_market_cap FROM stellar_network WHERE network_name = 'Stellar';
gretelai_synthetic_text_to_sql
CREATE TABLE Aircraft (id INT, name VARCHAR(50), manufacturer VARCHAR(50), safety_score INT); INSERT INTO Aircraft (id, name, manufacturer, safety_score) VALUES (1, 'F-16', 'AeroCorp', 80), (2, 'F-35', 'AeroCorp', 95), (3, 'A-10', 'EagleTech', 88), (4, 'A-11', 'EagleTech', 82), (5, 'A-12', 'EagleTech', 90);
What are the names and safety scores of aircraft manufactured by 'EagleTech' with safety scores greater than 85?
SELECT name, safety_score FROM Aircraft WHERE manufacturer = 'EagleTech' AND safety_score > 85;
gretelai_synthetic_text_to_sql
CREATE TABLE factories (factory_id INT, name TEXT, location TEXT, diversity_score DECIMAL(3,2)); INSERT INTO factories VALUES (1, 'ABC Factory', 'New York', 0.75), (2, 'XYZ Factory', 'California', 0.82), (3, 'LMN Factory', 'Texas', 0.68);
What are the names and locations of all factories with a workforce diversity score above 0.8?
SELECT name, location FROM factories WHERE diversity_score > 0.8;
gretelai_synthetic_text_to_sql
CREATE TABLE exhibitions (id INT, name TEXT, start_date DATE, end_date DATE);
Update the exhibitions table with start dates for all exhibitions
UPDATE exhibitions SET start_date = CURDATE();
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas (name TEXT, location TEXT, depth FLOAT); INSERT INTO marine_protected_areas (name, location, depth) VALUES ('Bermuda Ridge', 'Atlantic', 4000.0), ('Sargasso Sea', 'Atlantic', 2000.0), ('Great Barrier Reef', 'Pacific', 344.0);
What is the average depth of marine protected areas in the Atlantic Ocean?
SELECT AVG(depth) FROM marine_protected_areas WHERE location = 'Atlantic';
gretelai_synthetic_text_to_sql
CREATE TABLE space_debris (id INT PRIMARY KEY, debris_name VARCHAR(100), launch_date DATE, type VARCHAR(50));
Drop the space_debris table
DROP TABLE space_debris;
gretelai_synthetic_text_to_sql
CREATE TABLE Restaurants (id INT, name TEXT, type TEXT, revenue FLOAT); INSERT INTO Restaurants (id, name, type, revenue) VALUES (1, 'Restaurant A', 'Italian', 5000.00), (2, 'Restaurant B', 'Vietnamese', 8000.00), (3, 'Restaurant C', 'Vietnamese', 9000.00), (4, 'Restaurant D', 'Vietnamese', 10000.00);
What is the maximum revenue for restaurants serving Vietnamese food?
SELECT MAX(revenue) FROM Restaurants WHERE type = 'Vietnamese';
gretelai_synthetic_text_to_sql
CREATE TABLE inspections (restaurant_id INT, violation_date DATE, description VARCHAR(255)); INSERT INTO inspections VALUES (1, '2021-01-01', 'Fly infestation'), (1, '2021-02-01', 'Missing date markers'), (2, '2021-01-01', 'Cleanliness issues'), (2, '2021-03-01', 'Improper food storage');
How many violations were recorded per restaurant?
SELECT restaurant_id, COUNT(*) as num_violations FROM inspections GROUP BY restaurant_id;
gretelai_synthetic_text_to_sql
CREATE TABLE company (id INT, name VARCHAR(255), refinery_id INT, country VARCHAR(255)); INSERT INTO company (id, name, refinery_id, country) VALUES (1, 'ABC Corp', 1, 'Africa'), (2, 'XYZ Corp', 2, 'Asia');
List the names of each company, their associated refinery, and the refinery's continent.
SELECT c.name AS company_name, r.name AS refinery_name, CONCAT(SUBSTRING(r.location, 1, 1), ' continent') AS continent FROM company c JOIN refinery r ON c.refinery_id = r.id;
gretelai_synthetic_text_to_sql
CREATE TABLE matches (match_id INT, match_name VARCHAR(50), goals INT); INSERT INTO matches (match_id, match_name, goals) VALUES (1, 'Match 1', 1), (2, 'Match 2', 3), (3, 'Match 3', 0), (4, 'Match 4', 2), (5, 'Match 5', 4);
Delete all soccer matches that had less than 2 goals scored.
DELETE FROM matches WHERE goals < 2;
gretelai_synthetic_text_to_sql
CREATE TABLE ports (port_id INT, name VARCHAR(50), un_locode VARCHAR(10)); INSERT INTO ports (port_id, name, un_locode) VALUES (1, 'Port of Los Angeles', 'USLAX'), (2, 'Port of Long Beach', 'USLGB'), (3, 'Port of New York', 'USNYC');
How many ports are in the 'ports' table?
SELECT COUNT(*) FROM ports;
gretelai_synthetic_text_to_sql
CREATE TABLE Funding (Year INT, Region VARCHAR(20), Initiative VARCHAR(30), Funding DECIMAL(10,2)); INSERT INTO Funding (Year, Region, Initiative, Funding) VALUES (2018, 'Oceania', 'Climate Adaptation', 150000.00); INSERT INTO Funding (Year, Region, Initiative, Funding) VALUES (2019, 'Oceania', 'Climate Adaptation', 200000.00); INSERT INTO Funding (Year, Region, Initiative, Funding) VALUES (2020, 'Oceania', 'Climate Adaptation', 250000.00);
What is the total funding allocated for climate adaptation projects in Oceania between 2018 and 2020?
SELECT SUM(Funding) FROM Funding WHERE Year BETWEEN 2018 AND 2020 AND Region = 'Oceania' AND Initiative = 'Climate Adaptation';
gretelai_synthetic_text_to_sql
CREATE TABLE artifacts (artifact_id INT, excavation_year INT, weight DECIMAL(5,2)); INSERT INTO artifacts (artifact_id, excavation_year, weight) VALUES (1, 2005, 5.2);
What was the difference in average artifact weight before and after 2010?
SELECT AVG(CASE WHEN excavation_year < 2010 THEN weight ELSE NULL END) as avg_weight_before_2010, AVG(CASE WHEN excavation_year >= 2010 THEN weight ELSE NULL END) as avg_weight_after_2010 FROM artifacts;
gretelai_synthetic_text_to_sql
CREATE TABLE ProductRatings (ProductID INT, ProductType VARCHAR(20), HasNaturalIngredients BOOLEAN, Rating INT, ReviewDate DATE); INSERT INTO ProductRatings (ProductID, ProductType, HasNaturalIngredients, Rating, ReviewDate) VALUES (1, 'Facial Cleanser', TRUE, 4, '2022-04-10'); INSERT INTO ProductRatings (ProductID, ProductType, HasNaturalIngredients, Rating, ReviewDate) VALUES (2, 'Toner', TRUE, 5, '2022-05-18'); INSERT INTO ProductRatings (ProductID, ProductType, HasNaturalIngredients, Rating, ReviewDate) VALUES (3, 'Moisturizer', FALSE, 3, '2022-06-01');
What is the average rating of beauty products with natural ingredients in the skincare category?
SELECT AVG(Rating) FROM ProductRatings WHERE ProductType = 'Skincare' AND HasNaturalIngredients = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE oceanography_data (id INT, location VARCHAR(50), depth INT, temperature FLOAT, salinity FLOAT); INSERT INTO oceanography_data (id, location, depth, temperature, salinity) VALUES (1, 'Mariana Trench', 10994, 1.48, 34.6); INSERT INTO oceanography_data (id, location, depth, temperature, salinity) VALUES (2, 'Puerto Rico Trench', 8605, 4.28, 34.9);
Which oceanography data locations have a depth greater than 4000 meters?
SELECT location, depth FROM oceanography_data WHERE depth > 4000;
gretelai_synthetic_text_to_sql
CREATE TABLE Districts (DId INT, Name VARCHAR(50)); CREATE TABLE Crimes (CrimeId INT, DId INT, CrimeType VARCHAR(50), Date DATE);
What is the total number of crimes committed in each district, separated by crime type and sorted by total number of crimes in descending order?
SELECT D.Name, C.CrimeType, COUNT(C.CrimeId) AS TotalCrimes FROM Districts D INNER JOIN Crimes C ON D.DId = C.DId GROUP BY D.Name, C.CrimeType ORDER BY TotalCrimes DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE organizations (id INT PRIMARY KEY, name VARCHAR(50), type VARCHAR(50), location VARCHAR(50)); INSERT INTO organizations (id, name, type, location) VALUES (1, 'Greenpeace', 'Non-profit', 'India'); INSERT INTO organizations (id, name, type, location) VALUES (2, 'The Climate Group', 'Non-profit', 'UK'); INSERT INTO organizations (id, name, type, location) VALUES (4, 'Centre for Science and Environment', 'Non-profit', 'India');
Which organizations have a location in 'India' and are of type 'Non-profit'?
SELECT organizations.name, organizations.type, organizations.location FROM organizations WHERE organizations.location = 'India' AND organizations.type = 'Non-profit';
gretelai_synthetic_text_to_sql
CREATE TABLE UnionCB (Union VARCHAR(50), Region VARCHAR(50), Agreements INT); INSERT INTO UnionCB (Union, Region, Agreements) VALUES ('UnionO', 'Europe', 250), ('UnionP', 'Europe', 300), ('UnionQ', 'Europe', 200);
What is the maximum number of collective bargaining agreements negotiated by unions in the European region?
SELECT MAX(Agreements) FROM UnionCB WHERE Region = 'Europe'
gretelai_synthetic_text_to_sql
CREATE TABLE student_demographics (id INT, student_id INT, country VARCHAR(50), department VARCHAR(50)); INSERT INTO student_demographics (id, student_id, country, department) VALUES (1, 1, 'USA', 'Engineering'), (2, 2, 'Canada', 'Engineering'), (3, 3, 'Mexico', 'Engineering');
How many graduate students in the Engineering department come from each country?
SELECT country, COUNT(DISTINCT student_id) FROM student_demographics WHERE department = 'Engineering' GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE Research_Papers (id INT, title VARCHAR(255), author_country VARCHAR(50), publication_year INT); INSERT INTO Research_Papers (id, title, author_country, publication_year) VALUES (1, 'Autonomous Vehicles and Traffic Flow', 'USA', 2021); INSERT INTO Research_Papers (id, title, author_country, publication_year) VALUES (2, 'Deep Learning for Autonomous Driving', 'China', 2021);
How many autonomous vehicle research papers were published by authors from the United States and China in 2021?
SELECT COUNT(*) FROM Research_Papers WHERE author_country IN ('USA', 'China') AND publication_year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE SustainablePractices (PracticeID INT, PracticeName VARCHAR(50), Description VARCHAR(255), ProjectID INT, FOREIGN KEY (ProjectID) REFERENCES Projects(ProjectID));
Add a new sustainable practice to the SustainablePractices table.
INSERT INTO SustainablePractices (PracticeID, PracticeName, Description, ProjectID) VALUES (2, 'Geothermal Heating', 'Installation of geothermal heating systems', 2);
gretelai_synthetic_text_to_sql
CREATE TABLE warehouse (warehouse_id VARCHAR(5), name VARCHAR(10), location VARCHAR(10)); INSERT INTO warehouse (warehouse_id, name, location) VALUES ('W001', 'LAX', 'Los Angeles'), ('W002', 'JFK', 'New York'); CREATE TABLE shipment (shipment_id VARCHAR(5), warehouse_id VARCHAR(5), cargo_weight INT, arrival_date DATE); INSERT INTO shipment (shipment_id, warehouse_id, cargo_weight, arrival_date) VALUES ('S001', 'W001', 15000, '2021-02-10'), ('S002', 'W002', 20000, '2021-03-15');
What are the names and total cargo weights for all shipments that arrived at the 'LAX' warehouse between '2021-01-01' and '2021-03-31'?
SELECT w.name, SUM(s.cargo_weight) FROM shipment s INNER JOIN warehouse w ON s.warehouse_id = w.warehouse_id WHERE w.location = 'LAX' AND s.arrival_date BETWEEN '2021-01-01' AND '2021-03-31' GROUP BY w.name;
gretelai_synthetic_text_to_sql
CREATE TABLE Scores (PlayerID int, PlayerName varchar(50), Game varchar(50), Score int); INSERT INTO Scores (PlayerID, PlayerName, Game, Score) VALUES (1, 'Player1', 'Game1', 1000), (2, 'Player2', 'Game1', 1200), (3, 'Player3', 'Game1', 1500), (4, 'Player4', 'Game1', 800);
Who are the top 3 players with the highest scores in the 'Action' game category?
SELECT * FROM (SELECT PlayerID, PlayerName, Game, Score, ROW_NUMBER() OVER (PARTITION BY Game ORDER BY Score DESC) as Rank FROM Scores) T WHERE T.Game = 'Game1' AND T.Rank <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Holmium_Market_Prices (id INT, year INT, country VARCHAR(20), market_price DECIMAL(10,2));
What is the maximum market price of Holmium in Germany?
SELECT MAX(market_price) FROM Holmium_Market_Prices WHERE country = 'Germany';
gretelai_synthetic_text_to_sql
CREATE TABLE articles (title VARCHAR(255), topic VARCHAR(255));
What is the total number of articles published on topics related to media literacy?
SELECT COUNT(*) FROM articles WHERE topic LIKE '%media literacy%';
gretelai_synthetic_text_to_sql
CREATE TABLE genres (genre_id INT, genre VARCHAR(50)); INSERT INTO genres (genre_id, genre) VALUES (1, 'Pop'), (2, 'Rock'), (3, 'Hip Hop'), (4, 'Jazz'), (5, 'K-Pop'); CREATE TABLE collaborations (collab_id INT, track_name VARCHAR(100), artist_id1 INT, artist_id2 INT, genre_id INT); INSERT INTO collaborations (collab_id, track_name, artist_id1, artist_id2, genre_id) VALUES (1, 'Gangnam Style', 6, 7, 5), (2, 'Born Sinner', 3, 8, 3), (3, 'Numb', 2, 8, 3), (4, 'Gentleman', 6, NULL, 5), (5, 'One Shot', 9, NULL, 5);
What is the total number of collaborations between 'K-Pop' artists and 'Hip Hop' artists?
SELECT COUNT(*) FROM collaborations c INNER JOIN genres g1 ON c.genre_id = g1.genre_id INNER JOIN genres g2 ON c.genre_id = g2.genre_id WHERE g1.genre = 'K-Pop' AND g2.genre = 'Hip Hop';
gretelai_synthetic_text_to_sql
CREATE TABLE player_sessions (session_id INT, player_id INT, game_id INT, date_played DATE, start_time TIME, end_time TIME, playtime TIME, country VARCHAR(20), game_genre VARCHAR(20));
What is the total number of hours played by users in Japan for action games?
SELECT SUM(TIMESTAMPDIFF(MINUTE, start_time, end_time)) FROM player_sessions WHERE country = 'Japan' AND game_genre = 'action';
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists program (id INT, name VARCHAR(50), category VARCHAR(50)); CREATE TABLE if not exists funding (id INT, program_id INT, year INT, amount DECIMAL(10, 2), source VARCHAR(50)); INSERT INTO program (id, name, category) VALUES (1, 'Jazz Ensemble', 'Music'), (2, 'Classical Orchestra', 'Music'), (3, 'Rock Band', 'Music'); INSERT INTO funding (id, program_id, year, amount, source) VALUES (1, 1, 2020, 15000, 'City Grant'), (2, 1, 2021, 17500, 'Private Donor'), (3, 2, 2020, 12000, 'Corporate Sponsor'), (4, 2, 2021, 14000, 'Government Grant'), (5, 3, 2020, 16000, 'Private Donor'), (6, 3, 2021, 18500, 'City Grant'), (7, 1, 2022, 20000, 'Private Donor');
List all funding sources for 'Music' programs in 2022.
SELECT DISTINCT source FROM funding f JOIN program p ON f.program_id = p.id WHERE p.category = 'Music' AND f.year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE public.physicians (id SERIAL PRIMARY KEY, name TEXT, hospital TEXT); INSERT INTO public.physicians (name, hospital) VALUES ('Dr. Smith', 'Florida General Hospital'), ('Dr. Johnson', 'Florida Children''s Hospital'); CREATE TABLE public.admissions (id SERIAL PRIMARY KEY, physician TEXT, hospital TEXT, admission_date DATE); INSERT INTO public.admissions (physician, hospital, admission_date) VALUES ('Dr. Smith', 'Florida General Hospital', '2022-01-01'), ('Dr. Johnson', 'Florida Children''s Hospital', '2022-01-02'), ('Dr. Smith', 'Florida General Hospital', '2022-01-03');
What is the total number of hospital admissions for each primary care physician in the state of Florida?
SELECT p.name, COUNT(*) FROM public.admissions a JOIN public.physicians p ON a.physician = p.name GROUP BY p.name;
gretelai_synthetic_text_to_sql
CREATE TABLE city_complaints (city varchar(50), year int, category varchar(50), num_complaints int); INSERT INTO city_complaints (city, year, category, num_complaints) VALUES ('Chicago', 2024, 'Utilities', 2000), ('Chicago', 2024, 'Parks', 1000), ('Chicago', 2024, 'Sanitation', 1500);
What was the total number of citizen complaints received by the city of Chicago in 2024, categorized by utilities, parks, and sanitation?
SELECT SUM(num_complaints) FROM city_complaints WHERE city = 'Chicago' AND (category = 'Utilities' OR category = 'Parks' OR category = 'Sanitation') AND year = 2024;
gretelai_synthetic_text_to_sql
CREATE TABLE hotel_features (hotel_id INT, location VARCHAR(20), feature VARCHAR(30));
Identify hotel features that are not AI-related in Africa.
SELECT feature FROM hotel_features WHERE location = 'Africa' AND feature NOT LIKE '%AI%' GROUP BY feature
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists companies (company_id INT, sector VARCHAR(50), esg_score DECIMAL(3,2), quarter INT, year INT); INSERT INTO companies (company_id, sector, esg_score, quarter, year) VALUES (1, 'Technology', 8.2, 2, 2021), (2, 'Technology', 7.8, 2, 2021), (3, 'Technology', 9.1, 2, 2021);
Find the top 3 ESG scores for companies in the technology sector in Q2 2021, ordered by the scores in descending order.
SELECT company_id, sector, esg_score FROM companies WHERE sector = 'Technology' AND quarter = 2 AND year = 2021 ORDER BY esg_score DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE species (id INT, name VARCHAR(255), habitat VARCHAR(255), depth FLOAT); INSERT INTO species (id, name, habitat, depth) VALUES (1, 'Clownfish', 'Coral Reef', 20.0); INSERT INTO species (id, name, habitat, depth) VALUES (2, 'Blue Whale', 'Open Ocean', 2000.0); INSERT INTO species (id, name, habitat, depth) VALUES (3, 'Sea Otter', 'Kelp Forest', 50.0);
How many marine species live at a depth less than or equal to 100 meters?
SELECT COUNT(*) FROM species WHERE depth <= 100;
gretelai_synthetic_text_to_sql
CREATE TABLE incidents (id INT, incident_type VARCHAR(255), location VARCHAR(255), occurred_on DATE);
Delete all incidents recorded after 2022-12-31 from the 'incidents' table
DELETE FROM incidents WHERE occurred_on > '2022-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE threat_intelligence (id INT, country VARCHAR(50), year INT, threat_level FLOAT); INSERT INTO threat_intelligence (id, country, year, threat_level) VALUES (1, 'USA', 2022, 4.5); INSERT INTO threat_intelligence (id, country, year, threat_level) VALUES (2, 'YZ', 2022, 5.2);
What is the maximum threat level reported in country YZ in 2022?
SELECT MAX(threat_level) FROM threat_intelligence WHERE country = 'YZ' AND year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE Universities (UniversityID int, UniversityName varchar(255)); CREATE TABLE GraduateStudents (StudentID int, StudentName varchar(255), UniversityID int); CREATE TABLE Publications (PublicationID int, StudentID int, Title varchar(255));
Calculate the average number of research publications for graduate students from each university.
SELECT UniversityName, AVG(NumPublications) as AvgPublicationsPerStudent FROM (SELECT UniversityName, StudentName, COUNT(*) as NumPublications FROM GraduateStudents gs JOIN Publications p ON gs.StudentID = p.StudentID JOIN Universities u ON gs.UniversityID = u.UniversityID GROUP BY UniversityName, StudentName) subquery GROUP BY UniversityName;
gretelai_synthetic_text_to_sql
CREATE TABLE cities (city_name TEXT, population INTEGER); INSERT INTO cities (city_name, population) VALUES ('New York', 8500000), ('Los Angeles', 4000000), ('Toronto', 2700000), ('Montreal', 1700000); CREATE TABLE climate_communication (city_name TEXT); INSERT INTO climate_communication (city_name) VALUES ('New York'), ('Los Angeles');
List the names of all cities with a population over 1 million that have no records in the 'climate_communication' table.
SELECT city_name FROM cities WHERE population > 1000000 AND city_name NOT IN (SELECT city_name FROM climate_communication);
gretelai_synthetic_text_to_sql
CREATE TABLE prison (id INT, name TEXT, security_level TEXT, age INT); INSERT INTO prison (id, name, security_level, age) VALUES (1, 'John Doe', 'low_security', 35);
Update the age of the inmate with ID 1 to 40 in the prison table.
UPDATE prison SET age = 40 WHERE id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE drug_approval_rates(country VARCHAR(255), approval_count INT, total_drugs INT, year INT, semester INT); INSERT INTO drug_approval_rates(country, approval_count, total_drugs, year, semester) VALUES ('USA', 50, 100, 2021, 1), ('Canada', 30, 80, 2021, 1), ('Japan', 40, 90, 2021, 1);
Which countries had the highest and lowest drug approval rates in H1 2021?
SELECT country, approval_count/total_drugs as approval_rate FROM drug_approval_rates WHERE year = 2021 AND semester = 1 ORDER BY approval_rate DESC, country ASC;
gretelai_synthetic_text_to_sql
CREATE TABLE MemberWorkouts (MemberID INT, WorkoutDate DATE, HeartRate INT); INSERT INTO MemberWorkouts (MemberID, WorkoutDate, HeartRate) VALUES (1, '2023-02-01', 165), (2, '2023-02-02', 150), (3, '2023-02-03', 170);
What is the maximum heart rate achieved by a female member?
SELECT MAX(HeartRate) FROM MemberWorkouts WHERE MemberID IN (SELECT MemberID FROM Members WHERE Gender = 'Female');
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists water_demand (id INT PRIMARY KEY, city VARCHAR(50), water_demand FLOAT, usage_date DATE); CREATE TABLE if not exists water_price (id INT PRIMARY KEY, city VARCHAR(50), price FLOAT, usage_date DATE); CREATE VIEW if not exists water_demand_price AS SELECT wd.city, wd.water_demand, wp.price FROM water_demand wd JOIN water_price wp ON wd.city = wp.city AND wd.usage_date = wp.usage_date;
What is the change in water demand and price for each city over time?
SELECT city, usage_date, LAG(water_demand) OVER (PARTITION BY city ORDER BY usage_date) as prev_water_demand, water_demand, LAG(price) OVER (PARTITION BY city ORDER BY usage_date) as prev_price, price FROM water_demand_price ORDER BY city, usage_date;
gretelai_synthetic_text_to_sql
CREATE TABLE member_demographics (member_id INT, country VARCHAR(50), heart_rate INT); INSERT INTO member_demographics (member_id, country, heart_rate) VALUES (1, 'USA', 70), (2, 'Canada', 80), (3, 'Mexico', 65), (4, 'Brazil', 75), (5, 'Argentina', 78), (6, 'USA', 75), (7, 'Canada', 70), (8, 'Mexico', 80), (9, 'Brazil', 85), (10, 'Argentina', 72);
What is the average heart rate for members from each country?
SELECT country, AVG(heart_rate) FROM member_demographics GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE field_temperature (field_id INT, date DATE, temperature FLOAT); INSERT INTO field_temperature (field_id, date, temperature) VALUES (4, '2021-06-01', 28.5), (4, '2021-06-02', 29.3), (4, '2021-06-03', 30.1);
What is the maximum temperature in field 4 over the last month?
SELECT MAX(temperature) FROM field_temperature WHERE field_id = 4 AND date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE subscribers (subscriber_id INT, name VARCHAR(50), data_usage FLOAT);
Delete the record with the 'subscriber_id' 5 from the 'subscribers' table.
DELETE FROM subscribers WHERE subscriber_id = 5;
gretelai_synthetic_text_to_sql
CREATE TABLE games (game_id INT, game_genre VARCHAR(255), player_id INT, playtime_mins INT); CREATE TABLE players (player_id INT, player_country VARCHAR(255));
What is the total playtime, in hours, for all players from Canada, for games in the 'RPG' genre?
SELECT SUM(playtime_mins / 60) FROM games JOIN players ON games.player_id = players.player_id WHERE players.player_country = 'Canada' AND game_genre = 'RPG';
gretelai_synthetic_text_to_sql
CREATE TABLE ports (id INT PRIMARY KEY, name VARCHAR(50), country_id INT); CREATE TABLE countries (id INT PRIMARY KEY, name VARCHAR(50));
List the ports and their respective countries from the 'ports' and 'countries' tables.
SELECT ports.name, countries.name AS country_name FROM ports INNER JOIN countries ON ports.country_id = countries.id;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_adaptation_max (project_id INT, project_name TEXT, allocation DECIMAL(10, 2), year INT); INSERT INTO climate_adaptation_max (project_id, project_name, allocation, year) VALUES (7, 'Sea Level Rise G', 13000000, 2020), (8, 'Heatwave Resilience H', 10000000, 2020), (9, 'Biodiversity Protection I', 14000000, 2020);
What is the maximum allocation for a climate adaptation project in the year 2020?
SELECT MAX(allocation) FROM climate_adaptation_max WHERE year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE shipments (id INT, shipment_date DATE, country VARCHAR(10)); INSERT INTO shipments (id, shipment_date, country) VALUES (1001, '2022-01-03', 'Canada'), (1002, '2022-01-15', 'Mexico'), (1003, '2022-02-01', 'US'), (1004, '2022-02-15', 'Canada');
How many shipments were sent to country 'US' in February 2022?
SELECT COUNT(*) FROM shipments WHERE MONTH(shipment_date) = 2 AND country = 'US';
gretelai_synthetic_text_to_sql
CREATE TABLE firewall_logs (id INT, ip TEXT, country TEXT, timestamp TIMESTAMP); INSERT INTO firewall_logs (id, ip, country, timestamp) VALUES (1, '192.168.0.11', 'US', '2021-02-01 12:00:00'), (2, '192.168.0.10', 'FR', '2021-02-04 14:30:00'), (3, '192.168.0.12', 'CN', '2021-02-05 10:15:00');
How many times has the firewall blocked traffic from country FR in the last month?
SELECT COUNT(*) FROM firewall_logs WHERE country = 'FR' AND timestamp >= NOW() - INTERVAL '1 month';
gretelai_synthetic_text_to_sql
CREATE TABLE Sustainable_Sources (id INT, vendor VARCHAR(255), product VARCHAR(255), sustainable BOOLEAN); INSERT INTO Sustainable_Sources (id, vendor, product, sustainable) VALUES ((SELECT MAX(id) FROM Sustainable_Sources) + 1, 'Eco-Friendly Farms', 'Organic Chicken', TRUE);
Insert a new record into the 'Sustainable_Sources' table with id 1, vendor 'Eco-Friendly Farms', product 'Organic Chicken', and sustainable BOOLEAN as TRUE.
INSERT INTO Sustainable_Sources (vendor, product, sustainable) VALUES ('Eco-Friendly Farms', 'Organic Chicken', TRUE);
gretelai_synthetic_text_to_sql
CREATE TABLE HairCareSales (sale_id INT, product_name VARCHAR(100), category VARCHAR(50), price DECIMAL(10,2), quantity INT, sale_date DATE, country VARCHAR(50), sustainable BOOLEAN);
Delete all records of sales of non-sustainable hair care products in Australia.
DELETE FROM HairCareSales WHERE category = 'Hair Care' AND country = 'Australia' AND sustainable = FALSE;
gretelai_synthetic_text_to_sql
CREATE TABLE dispensaries (dispensary_id INT, name TEXT, state TEXT); INSERT INTO dispensaries (dispensary_id, name, state) VALUES (1, 'Dispensary A', 'Arizona'), (2, 'Dispensary B', 'Arizona'), (3, 'Dispensary C', 'California'); CREATE TABLE sales (sale_id INT, dispensary_id INT, revenue INT); INSERT INTO sales (sale_id, dispensary_id, revenue) VALUES (1, 1, 500), (2, 1, 700), (3, 2, 300);
What is the total revenue generated by each dispensary in Arizona, grouped by dispensary and ordered by revenue from highest to lowest?
SELECT d.name, SUM(s.revenue) AS total_revenue FROM dispensaries d JOIN sales s ON d.dispensary_id = s.dispensary_id WHERE d.state = 'Arizona' GROUP BY d.name ORDER BY total_revenue DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE hospitals (id INT, name TEXT, state TEXT); CREATE TABLE infectious_diseases (id INT, hospital_id INT, disease TEXT); INSERT INTO hospitals (id, name, state) VALUES (1, 'Hospital X', 'New York'), (2, 'Hospital Y', 'New Jersey'); INSERT INTO infectious_diseases (id, hospital_id, disease) VALUES (1, 1, 'Measles'), (2, 1, 'Tuberculosis'), (3, 2, 'Hepatitis B');
List all infectious diseases recorded in hospitals located in New York and New Jersey
SELECT i.disease FROM hospitals h INNER JOIN infectious_diseases i ON h.id = i.hospital_id WHERE h.state IN ('New York', 'New Jersey');
gretelai_synthetic_text_to_sql
CREATE TABLE hotel_tech_adoption (hotel_id INT, ai_powered_features INT); INSERT INTO hotel_tech_adoption (hotel_id, ai_powered_features) VALUES (1, 5), (2, 3), (3, 4), (4, 6);
What is the average number of AI-powered features offered by hotels in the 'hotel_tech_adoption' table?
SELECT AVG(ai_powered_features) FROM hotel_tech_adoption;
gretelai_synthetic_text_to_sql
CREATE TABLE movies (id INT, title VARCHAR(100), release_year INT);
Which movies in the "movies" table were released in the 2010s?
SELECT * FROM movies WHERE release_year BETWEEN 2010 AND 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name VARCHAR(50), region VARCHAR(20), cruelty_free BOOLEAN); INSERT INTO products (product_id, product_name, region, cruelty_free) VALUES (1, 'Lipstick', 'Canada', TRUE), (2, 'Foundation', 'US', FALSE), (3, 'Eyeshadow', 'US', TRUE);
Determine the cosmetic products that are NOT certified as cruelty-free in the US region.
SELECT * FROM products WHERE region = 'US' AND cruelty_free = FALSE;
gretelai_synthetic_text_to_sql
CREATE TABLE community_health_workers (id INT, name TEXT, zip TEXT, consultations INT); INSERT INTO community_health_workers (id, name, zip, consultations) VALUES (1, 'John Doe', '60001', 40), (2, 'Jane Smith', '60601', 20); CREATE VIEW il_workers AS SELECT * FROM community_health_workers WHERE zip BETWEEN '60001' AND '62999';
What is the ZIP code of the community health worker who conducted the least mental health parity consultations in Illinois?
SELECT zip FROM il_workers WHERE consultations = (SELECT MIN(consultations) FROM il_workers);
gretelai_synthetic_text_to_sql
CREATE TABLE boston_housing (id INT, quarter INT, year INT, affordability FLOAT); INSERT INTO boston_housing (id, quarter, year, affordability) VALUES (1, 1, 2021, 90), (2, 2, 2021, 85), (3, 1, 2021, 95), (4, 2, 2021, 80);
What is the change in housing affordability in Boston from Q1 2021 to Q2 2021?
SELECT (MAX(affordability) FILTER (WHERE year = 2021 AND quarter = 2) - MAX(affordability) FILTER (WHERE year = 2021 AND quarter = 1)) FROM boston_housing;
gretelai_synthetic_text_to_sql
CREATE TABLE org_volunteers (org_id INT, org_name VARCHAR(50), num_volunteers INT, country VARCHAR(50)); CREATE TABLE donations (donation_id INT, org_id INT, donation_amount FLOAT, donation_date DATE); INSERT INTO org_volunteers (org_id, org_name, num_volunteers, country) VALUES (1, 'Australian Red Cross', 50, 'Australia'), (2, 'New Zealand Greenpeace', 30, 'New Zealand'), (3, 'Pacific Save the Children', 20, 'Fiji'); INSERT INTO donations (donation_id, org_id, donation_amount, donation_date) VALUES (1, 1, 200, '2022-01-01'), (2, 2, 150, '2022-02-01');
Delete all volunteer records for organizations located in Oceania with no donations in 2022.
DELETE FROM org_volunteers WHERE org_id NOT IN (SELECT org_id FROM donations WHERE donation_date BETWEEN '2022-01-01' AND '2022-12-31') AND country IN ('Australia', 'New Zealand', 'Fiji', 'Papua New Guinea', 'Solomon Islands');
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (id INT, customer_id INT, value DECIMAL(10, 2), transaction_date DATE); INSERT INTO transactions (id, customer_id, value, transaction_date) VALUES (1, 1, 100, '2022-01-01'), (2, 1, 200, '2022-01-15'), (3, 2, 50, '2022-01-05'), (4, 2, 150, '2022-01-30'), (5, 3, 300, '2022-01-20');
What is the maximum transaction value for each customer in the last year?
SELECT c.id, MAX(t.value) FROM customers c INNER JOIN transactions t ON c.id = t.customer_id WHERE t.transaction_date >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR) GROUP BY c.id;
gretelai_synthetic_text_to_sql
CREATE TABLE fares (fare_id INT, route_id INT, fare FLOAT, fare_currency VARCHAR(3), fare_date DATE); INSERT INTO fares (fare_id, route_id, fare, fare_currency, fare_date) VALUES (1, 1, 3.0, 'USD', '2022-05-01'), (2, 2, 4.0, 'USD', '2022-05-02'), (3, 1, 3.5, 'USD', '2022-05-03');
What is the average fare and its corresponding currency for each route, along with the fare of the previous record, ordered by fare date?
SELECT route_id, fare, fare_currency, fare_date, LAG(fare) OVER (PARTITION BY route_id ORDER BY fare_date) as prev_fare FROM fares;
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers (id INT, name VARCHAR(255), country VARCHAR(255)); CREATE TABLE products (id INT, name VARCHAR(255), organic BOOLEAN, weight FLOAT, supplier_id INT);
What is the total weight of non-organic products sourced from local suppliers?
SELECT SUM(p.weight) as total_weight FROM suppliers s INNER JOIN products p ON s.id = p.supplier_id WHERE p.organic = 'f' AND s.country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE students (student_id INT, mental_health_score INT, participated_in_lifelong_learning BOOLEAN); INSERT INTO students (student_id, mental_health_score, participated_in_lifelong_learning) VALUES (1, 80, FALSE), (2, 70, FALSE), (3, 90, FALSE), (4, 60, TRUE);
Update the mental health score of the student with the highest ID who has not participated in lifelong learning activities.
UPDATE students SET mental_health_score = 85 WHERE student_id = (SELECT MAX(student_id) FROM students WHERE participated_in_lifelong_learning = FALSE);
gretelai_synthetic_text_to_sql
CREATE TABLE disputes_2020 (id INT, dispute_count INT, date DATE); INSERT INTO disputes_2020 (id, dispute_count, date) VALUES (1, 50, '2020-01-01'), (2, 35, '2020-04-15'), (3, 40, '2020-07-01');
What is the total number of labor disputes in each quarter for the year 2020, based on the 'disputes_2020' table?
SELECT QUARTER(date) as quarter, SUM(dispute_count) as total_disputes FROM disputes_2020 GROUP BY quarter;
gretelai_synthetic_text_to_sql
CREATE TABLE public_parks (name VARCHAR(255), state VARCHAR(255), acres DECIMAL(10,2)); INSERT INTO public_parks (name, state, acres) VALUES ('Central Park', 'New York', 843), ('Prospect Park', 'New York', 585), ('Golden Gate Park', 'California', 1017);
What is the total number of public parks in New York and California?
SELECT SUM(acres) FROM public_parks WHERE state IN ('New York', 'California');
gretelai_synthetic_text_to_sql
CREATE TABLE mine_stats (country VARCHAR(20), mineral VARCHAR(20), quantity INT); INSERT INTO mine_stats (country, mineral, quantity) VALUES ('USA', 'gold', 500), ('USA', 'silver', 2000), ('Canada', 'gold', 800), ('Canada', 'silver', 1500);
What are the total quantities of gold and silver mined in the USA and Canada?
SELECT country, SUM(quantity) FROM mine_stats WHERE mineral IN ('gold', 'silver') GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE Threats (threat_id INT, threat_type VARCHAR(50), year INT, region_id INT); INSERT INTO Threats (threat_id, threat_type, year, region_id) VALUES (1, 'Cybersecurity threat', 2022, 1), (2, 'Terrorism', 2021, 1);
What is the sum of cybersecurity threats reported in the North American region in 2022?
SELECT SUM(threat_id) FROM Threats WHERE threat_type = 'Cybersecurity threat' AND year = 2022 AND region_id = (SELECT region_id FROM Regions WHERE region_name = 'North American');
gretelai_synthetic_text_to_sql
CREATE TABLE ai_safety (id INT, model_name VARCHAR(255), country VARCHAR(255), confidence_score FLOAT); INSERT INTO ai_safety (id, model_name, country, confidence_score) VALUES (1, 'SafeModelA', 'China', 0.75), (2, 'SafeModelB', 'Japan', 0.90), (3, 'SafeModelC', 'India', 0.85);
What are the maximum and minimum confidence scores for AI models in AI safety in Asia?
SELECT MAX(confidence_score), MIN(confidence_score) FROM ai_safety WHERE country IN ('China', 'Japan', 'India');
gretelai_synthetic_text_to_sql
CREATE TABLE traffic_court_fines (id INT, fine_amount DECIMAL(5,2), fine_date DATE);
What is the average fine amount issued in traffic court, broken down by the day of the week?
SELECT DATE_FORMAT(fine_date, '%W') AS day_of_week, AVG(fine_amount) FROM traffic_court_fines GROUP BY day_of_week;
gretelai_synthetic_text_to_sql