context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE farming_transactions (id INT, organic BOOLEAN, region TEXT); INSERT INTO farming_transactions (id, organic, region) VALUES (1, true, 'Europe'), (2, false, 'North America');
What is the total number of organic farming transactions in 'Europe'?
SELECT COUNT(*) FROM farming_transactions WHERE organic = true AND region = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE waste_generation (id INT PRIMARY KEY, waste_type_id INT, generation_rate FLOAT); INSERT INTO waste_generation (id, waste_type_id, generation_rate) VALUES (1, 1, 50.5), (2, 2, 40.3);
Display the waste generation rate for a specific type
SELECT generation_rate FROM waste_generation WHERE waste_type_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE military_expenditure (country VARCHAR(255), year INT, expenditure DECIMAL(10,2)); INSERT INTO military_expenditure (country, year, expenditure) VALUES ('USA', 2020, 7780000000), ('China', 2020, 2520000000);
What was the total spending on military innovation by the US and China in 2020?
SELECT SUM(expenditure) as total_expenditure FROM military_expenditure WHERE country IN ('USA', 'China') AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE rare_earth_market_trends ( id INT PRIMARY KEY, year INT, country VARCHAR(255), element VARCHAR(255), price_usd FLOAT);
Update the rare_earth_market_trends table to reflect the increased europium price in South Korea
WITH updated_price AS (UPDATE rare_earth_market_trends SET price_usd = 20.1 WHERE year = 2022 AND country = 'South Korea' AND element = 'Europium') SELECT * FROM rare_earth_market_trends WHERE country = 'South Korea' AND element = 'Europium';
gretelai_synthetic_text_to_sql
CREATE TABLE trees (id INT, region VARCHAR(255), carbon_sequestered DECIMAL(10,2));
What is the average carbon sequestered by trees in each region?
SELECT region, AVG(carbon_sequestered) as avg_carbon_sequestered FROM trees GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE unions (id INT, name TEXT, domain TEXT, members INT); INSERT INTO unions (id, name, domain, members) VALUES (1, 'United Auto Workers', 'Automobiles, Aerospace', 400000); INSERT INTO unions (id, name, domain, members) VALUES (2, 'International Association of Machinists and Aerospace Workers', 'Aerospace, Defense, Machinists', 350000);
Which union has the most members in the 'Automobiles' domain?
SELECT name FROM unions WHERE domain = 'Automobiles' GROUP BY name ORDER BY SUM(members) DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT, size VARCHAR(10), region VARCHAR(20)); INSERT INTO sales (id, size, region) VALUES (1, 'plus', 'Asia'); -- additional rows removed for brevity;
What is the number of plus size garments sold in the Asian market?
SELECT COUNT(*) FROM sales WHERE size = 'plus' AND region = 'Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE defense_contractors (id INT, name VARCHAR(255)); INSERT INTO defense_contractors (id, name) VALUES (1, 'Lockheed Martin'), (2, 'Boeing'), (3, 'Raytheon'); CREATE TABLE defense_contracts (id INT, contractor_id INT, contract_value FLOAT); INSERT INTO defense_contracts (id, contractor_id, contract_value) VALUES (1, 1, 1500000), (2, 2, 800000), (3, 1, 3000000);
Which defense contractors have been awarded contracts worth over 1 million dollars?
SELECT defense_contractors.name, SUM(defense_contracts.contract_value) as total_contract_value FROM defense_contractors INNER JOIN defense_contracts ON defense_contractors.id = defense_contracts.contractor_id GROUP BY defense_contractors.name HAVING total_contract_value > 1000000;
gretelai_synthetic_text_to_sql
CREATE TABLE cars (id INT, type VARCHAR(255), country VARCHAR(255), avg_co2_emission FLOAT); INSERT INTO cars VALUES (1, 'Electric', 'Germany', 100);
What is the average CO2 emission of electric cars in Germany?
SELECT avg_co2_emission FROM cars WHERE type = 'Electric' AND country = 'Germany';
gretelai_synthetic_text_to_sql
CREATE TABLE Indian_Manufacturers (id INT, name TEXT, safety_rating FLOAT, production_country TEXT); INSERT INTO Indian_Manufacturers (id, name, safety_rating, production_country) VALUES (1, 'Manufacturer3', 3.2, 'India'); INSERT INTO Indian_Manufacturers (id, name, safety_rating, production_country) VALUES (2, 'Manufacturer4', 3.8, 'India');
Who is the manufacturer with the lowest safety rating for vehicles produced in India?
SELECT name FROM Indian_Manufacturers WHERE production_country = 'India' ORDER BY safety_rating ASC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Cases (CaseID INT, ClientID INT, Outcome TEXT); CREATE TABLE CaseAttorneys (CaseID INT, AttorneyID INT); CREATE TABLE Attorneys (AttorneyID INT, Name TEXT); INSERT INTO Cases (CaseID, ClientID, Outcome) VALUES (1, 1, 'Settled'); INSERT INTO CaseAttorneys (CaseID, AttorneyID) VALUES (1, 1); INSERT INTO Attorneys (AttorneyID, Name) VALUES (1, 'Jane Doe'); INSERT INTO Cases (CaseID, ClientID, Outcome) VALUES (2, 2, 'Dismissed'); INSERT INTO CaseAttorneys (CaseID, AttorneyID) VALUES (2, 2); INSERT INTO Attorneys (AttorneyID, Name) VALUES (2, 'John Smith');
List all cases with a 'Dismissed' outcome and the corresponding attorney's name.
SELECT Attorneys.Name, Cases.Outcome FROM Cases INNER JOIN CaseAttorneys ON Cases.CaseID = CaseAttorneys.CaseID INNER JOIN Attorneys ON CaseAttorneys.AttorneyID = Attorneys.AttorneyID WHERE Cases.Outcome = 'Dismissed';
gretelai_synthetic_text_to_sql
CREATE TABLE projects (id INT, name TEXT, state TEXT, budget FLOAT, start_date DATE); INSERT INTO projects (id, name, state, budget, start_date) VALUES (1, 'CA Freeway Widening', 'CA', 5000000, '2020-01-05');
What is the total budget for projects in California with a start date after 2019-01-01?
SELECT SUM(budget) FROM projects WHERE state = 'CA' AND start_date > '2019-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE hotel_chains (chain_id INT, chain_name TEXT, region TEXT, revenue FLOAT); INSERT INTO hotel_chains (chain_id, chain_name, region, revenue) VALUES (1, 'Chain 1', 'Europe', 2500000), (2, 'Chain 2', 'Europe', 1900000);
What are the top 5 hotel chains by total revenue in Europe in Q1 2022?
SELECT chain_name, SUM(revenue) FROM hotel_chains WHERE region = 'Europe' GROUP BY chain_name ORDER BY SUM(revenue) DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE biosensor_development (id INT, biosensor_name VARCHAR(50), year INT, status VARCHAR(50)); INSERT INTO biosensor_development (id, biosensor_name, year, status) VALUES (1, 'BioSensor1', 2021, 'Developing'), (2, 'BioSensor2', 2022, 'Released'), (3, 'BioSensor3', 2021, 'Released'), (4, 'BioSensor4', 2022, 'Developing');
How many biosensors were developed in '2021' and '2022' in the 'biosensor_development' database?
SELECT COUNT(*) FROM biosensor_development WHERE year IN (2021, 2022);
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, Age INT, Gender VARCHAR(10), Country VARCHAR(20), TotalHoursPlayed INT, FavoriteGame VARCHAR(10)); INSERT INTO Players (PlayerID, Age, Gender, Country, TotalHoursPlayed, FavoriteGame) VALUES (1, 35, 'Male', 'USA', 70, 'Strategy'); INSERT INTO Players (PlayerID, Age, Gender, Country, TotalHoursPlayed, FavoriteGame) VALUES (2, 28, 'Female', 'Canada', 60, 'Strategy'); INSERT INTO Players (PlayerID, Age, Gender, Country, TotalHoursPlayed, FavoriteGame) VALUES (3, 45, 'Male', 'Mexico', 55, 'Strategy');
Find the average age of players who have spent more than 50 hours on Strategy games.
SELECT AVG(Age) FROM Players WHERE FavoriteGame = 'Strategy' AND TotalHoursPlayed > 50;
gretelai_synthetic_text_to_sql
CREATE TABLE permits (id INT, dispensary_id INT, expiration_date DATE); INSERT INTO permits (id, dispensary_id, expiration_date) VALUES (1, 1, '2021-01-01'), (2, 2, '2022-02-01');
Find all dispensaries with expired permits in Michigan.
SELECT d.name FROM dispensaries d INNER JOIN permits p ON d.id = p.dispensary_id WHERE p.expiration_date < CURDATE() AND d.state = 'MI';
gretelai_synthetic_text_to_sql
MUSEUM_STORES(store_id, name, location, daily_revenue, date); DATES(date)
Show the total revenue of museum stores in the last 3 months
SELECT SUM(ms.daily_revenue) FROM MUSEUM_STORES ms INNER JOIN DATES d ON ms.date = d.date WHERE d.date BETWEEN DATEADD(month, -3, GETDATE()) AND GETDATE();
gretelai_synthetic_text_to_sql
CREATE TABLE IF NOT EXISTS public.roads (id SERIAL PRIMARY KEY, name TEXT, length REAL); INSERT INTO public.roads (name, length) SELECT 'ExampleRoad1', 1000.0 FROM generate_series(1, 15); INSERT INTO public.roads (name, length) SELECT 'ExampleRoad2', 500.0 FROM generate_series(1, 5);
List all roads in the "roads" table that have a length greater than the average length of all roads?
SELECT name, length FROM public.roads WHERE length > (SELECT AVG(length) FROM public.roads);
gretelai_synthetic_text_to_sql
CREATE TABLE charging_stations(id INT, station_number INT, city VARCHAR(20), charger_type VARCHAR(20), operational BOOLEAN);
How many charging stations are there in Beijing for electric cars?
SELECT COUNT(*) FROM charging_stations WHERE city = 'Beijing' AND charger_type = 'DC Fast Charger' AND operational = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE Policyholders (PolicyID INT, PolicyholderName TEXT, State TEXT); INSERT INTO Policyholders (PolicyID, PolicyholderName, State) VALUES (1, 'Luz Rodriguez', 'LA'), (2, 'Daniel Kim', 'NY'); CREATE TABLE Claims (ClaimID INT, PolicyID INT, ClaimAmount INT); INSERT INTO Claims (ClaimID, PolicyID, ClaimAmount) VALUES (1, 1, 1000), (2, 1, 2000), (3, 1, 3000), (4, 2, 5000);
Find the policyholder with the most claims in 'LA'.
SELECT PolicyholderName, COUNT(*) AS NumClaims FROM Claims INNER JOIN Policyholders ON Claims.PolicyID = Policyholders.PolicyID WHERE Policyholders.State = 'LA' GROUP BY PolicyholderName ORDER BY NumClaims DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE finance_projects (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), description TEXT, start_date DATE, end_date DATE, budget FLOAT); INSERT INTO finance_projects (id, name, location, description, start_date, end_date, budget) VALUES (1, 'Green Bonds Issuance', 'London', 'Financing green infrastructure projects', '2017-01-01', '2019-12-31', 5000000);
How many climate finance projects were completed before '2019' from the 'finance_projects' table?
SELECT COUNT(*) FROM finance_projects WHERE end_date < '2019-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (VolunteerID INT, VolunteerName TEXT, Country TEXT, Continent TEXT, JoinYear INT); INSERT INTO Volunteers (VolunteerID, VolunteerName, Country, Continent, JoinYear) VALUES (1, 'Alice', 'USA', 'North America', 2021), (2, 'Bob', 'Mexico', 'North America', 2021), (3, 'Carlos', 'Brazil', 'South America', 2021);
How many volunteers joined from each continent in 2021?
SELECT Continent, COUNT(*) FROM Volunteers WHERE JoinYear = 2021 GROUP BY Continent;
gretelai_synthetic_text_to_sql
CREATE TABLE ImpactInvestments (InvestmentID INT, ROI DECIMAL(5,2), Region VARCHAR(50));
What is the average impact investment return in Africa?
SELECT AVG(ROI) FROM ImpactInvestments WHERE Region = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE content (content_id INT, content_type VARCHAR(20), country VARCHAR(50), watch_time FLOAT); INSERT INTO content VALUES (1, 'educational', 'United States', 123.45);
What is the total watch time for educational content in the United States?
SELECT SUM(watch_time) FROM content WHERE country = 'United States' AND content_type = 'educational';
gretelai_synthetic_text_to_sql
CREATE SCHEMA LawEnforcement; CREATE TABLE Violations (violation_id INT, violation_date DATE, violation_type VARCHAR(255)); INSERT INTO Violations (violation_id, violation_date, violation_type) VALUES (1, '2021-01-01', 'Speeding'), (2, '2021-02-15', 'Illegal Fishing'), (3, '2021-03-05', 'Pollution'), (4, '2022-04-20', 'Speeding');
List all maritime law violations in the 'LawEnforcement' schema from the past year.
SELECT * FROM LawEnforcement.Violations WHERE violation_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE green_buildings_commercial (building_id INT, city VARCHAR(50), year INT, co2_reduction_tons INT);
What is the average CO2 emissions reduction (in metric tons) from green building projects in the commercial sector, grouped by city and year, where the average reduction is greater than 100 metric tons?
SELECT city, year, AVG(co2_reduction_tons) FROM green_buildings_commercial GROUP BY city, year HAVING AVG(co2_reduction_tons) > 100;
gretelai_synthetic_text_to_sql
CREATE TABLE animal_habitats (id INT PRIMARY KEY, habitat_name VARCHAR, num_animals INT); INSERT INTO animal_habitats (id, habitat_name, num_animals) VALUES (1, 'Rainforest', 600), (2, 'Savannah', 300), (3, 'Mountains', 200);
Delete habitats from 'animal_habitats' with num_animals less than 200
DELETE FROM animal_habitats WHERE num_animals < 200;
gretelai_synthetic_text_to_sql
CREATE TABLE clinics (clinic_id INT, clinic_name VARCHAR(50)); CREATE TABLE appointments (appointment_id INT, patient_id INT, appointment_date DATE, clinic_id INT, chronic_condition BOOLEAN);
What is the average time between appointments for patients with chronic conditions in rural health clinic B?
SELECT AVG(DATEDIFF(appointments.appointment_date, LAG(appointments.appointment_date) OVER (PARTITION BY appointments.patient_id ORDER BY appointments.appointment_date))) as avg_time_between_appointments FROM appointments WHERE appointments.clinic_id = (SELECT clinic_id FROM clinics WHERE clinic_name = 'rural health clinic B') AND appointments.chronic_condition = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE digital_assets (asset_name TEXT, regulatory_status TEXT, country TEXT);
What is the total number of unique digital assets with a regulatory status of "regulated" in each country?
SELECT country, COUNT(DISTINCT asset_name) FROM digital_assets WHERE regulatory_status = 'regulated' GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE wells (id INT, well_name VARCHAR(255), location VARCHAR(255), drill_year INT, company VARCHAR(255), daily_production_rate DECIMAL(5,2)); INSERT INTO wells (id, well_name, location, drill_year, company, daily_production_rate) VALUES (1, 'Well001', 'Texas', 2020, 'CompanyA', 100.50); INSERT INTO wells (id, well_name, location, drill_year, company, daily_production_rate) VALUES (2, 'Well002', 'Colorado', 2019, 'CompanyB', 150.25); INSERT INTO wells (id, well_name, location, drill_year, company, daily_production_rate) VALUES (3, 'Well003', 'California', 2019, 'CompanyC', 200.00);
Display the daily production rate for Well003
SELECT daily_production_rate FROM wells WHERE well_name = 'Well003';
gretelai_synthetic_text_to_sql
CREATE TABLE shipments (id INT, transportation_mode VARCHAR(50), delivery_time INT); INSERT INTO shipments (id, transportation_mode, delivery_time) VALUES (1, 'Air', 5), (2, 'Sea', 7), (3, 'Rail', 6), (4, 'Air', 4);
What is the average delivery time for each transportation mode, computed across all shipments?
SELECT transportation_mode, AVG(delivery_time) as avg_delivery_time FROM shipments GROUP BY transportation_mode;
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers (supplier_id INT, supplier TEXT, ethical_score INT); INSERT INTO suppliers (supplier_id, supplier, ethical_score) VALUES (1, 'Supplier X', 85); INSERT INTO suppliers (supplier_id, supplier, ethical_score) VALUES (2, 'Supplier Y', 90); INSERT INTO suppliers (supplier_id, supplier, ethical_score) VALUES (3, 'Supplier Z', 80); INSERT INTO suppliers (supplier_id, supplier, ethical_score) VALUES (4, 'Supplier W', 95); INSERT INTO suppliers (supplier_id, supplier, ethical_score) VALUES (5, 'Supplier V', 75);
Which suppliers have the highest ethical labor scores?
SELECT supplier, MAX(ethical_score) FROM suppliers GROUP BY supplier;
gretelai_synthetic_text_to_sql
CREATE TABLE teams (team_id INT, team_name TEXT, city TEXT); CREATE TABLE games (game_id INT, team_id INT, home BOOLEAN, attendance INT);
What is the average attendance at home games for each team?
SELECT t.team_name, AVG(g.attendance) as avg_attendance FROM games g JOIN teams t ON g.team_id = t.team_id WHERE g.home = TRUE GROUP BY t.team_name;
gretelai_synthetic_text_to_sql
CREATE TABLE veteran_employment (state TEXT, veteran_unemployment FLOAT); INSERT INTO veteran_employment (state, veteran_unemployment) VALUES ('California', 3.2), ('Texas', 2.8), ('Florida', 4.1);
What is the veteran unemployment rate in Texas and Florida?
SELECT state, veteran_unemployment FROM veteran_employment WHERE state IN ('Texas', 'Florida');
gretelai_synthetic_text_to_sql
CREATE TABLE marine_research_expeditions (id INT, expedition_name VARCHAR(50), ocean VARCHAR(50), expedition_count INT); INSERT INTO marine_research_expeditions (id, expedition_name, ocean, expedition_count) VALUES (1, 'Expedition A', 'Arctic Ocean', 1), (2, 'Expedition B', 'Arctic Ocean', 2), (3, 'Expedition C', 'Atlantic Ocean', 1);
What is the total number of marine research expeditions conducted in the Arctic Ocean?
SELECT SUM(expedition_count) FROM marine_research_expeditions WHERE ocean = 'Arctic Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE ClinicalTrial (ID INT, Name TEXT, Mutations TEXT); INSERT INTO ClinicalTrial (ID, Name, Mutations) VALUES (4, 'Trial_D', 'MT4,MT5');
Which genetic mutations were discovered in the clinical trial 'Trial_D'?
SELECT Mutations FROM ClinicalTrial WHERE Name = 'Trial_D';
gretelai_synthetic_text_to_sql
CREATE TABLE Spacecraft (ID INT, Name VARCHAR(50), ManufacturingDate DATE, Country VARCHAR(50), DurationInSpace INT); INSERT INTO Spacecraft VALUES (1, 'Spacecraft A', '2010-01-01', 'USA', 2500), (2, 'Spacecraft B', '2012-05-15', 'China', 3000), (3, 'Spacecraft C', '2005-09-27', 'Russia', 1800), (4, 'Spacecraft D', '2015-02-20', 'USA', 1200), (5, 'Spacecraft E', '2008-07-06', 'China', 1500);
Calculate the percentage of spacecraft from each country that have a duration in space greater than 1500.
SELECT Country, AVG(CASE WHEN DurationInSpace > 1500 THEN 1.0 ELSE 0.0 END) * 100.0 AS Percentage FROM Spacecraft GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE claim (claim_id INT, claim_state VARCHAR(20), claim_status VARCHAR(20)); INSERT INTO claim VALUES (1, 'Illinois', 'Pending'); INSERT INTO claim VALUES (2, 'Texas', 'Paid');
Delete all claim records with a claim state of 'Illinois'
DELETE FROM claim WHERE claim_state = 'Illinois';
gretelai_synthetic_text_to_sql
CREATE TABLE wells (well_id INT, well_type TEXT, location TEXT); INSERT INTO wells (well_id, well_type, location) VALUES (1, 'Onshore', 'Canada'), (2, 'Offshore', 'Canada'); CREATE TABLE production (prod_id INT, well_id INT, oil_prod INT, gas_prod INT); INSERT INTO production (prod_id, well_id, oil_prod, gas_prod) VALUES (1, 1, 5000, 2000), (2, 1, 5500, 2500), (3, 2, 4500, 1500);
What is the total number of onshore and offshore wells in Canada and their production figures?
SELECT well_type, SUM(oil_prod + gas_prod) FROM production JOIN wells ON production.well_id = wells.well_id WHERE wells.location = 'Canada' GROUP BY well_type;
gretelai_synthetic_text_to_sql
CREATE TABLE Songs (SongID INT, SongName VARCHAR(100), Genre VARCHAR(50), ReleaseDate DATE); INSERT INTO Songs (SongID, SongName, Genre, ReleaseDate) VALUES (1, 'Bohemian Rhapsody', 'Rock', '1975-11-01'); INSERT INTO Songs (SongID, SongName, Genre, ReleaseDate) VALUES (2, 'Shape of You', 'Pop', '2017-01-01');
Show the number of unique genres for songs released in 2019.
SELECT COUNT(DISTINCT Genre) FROM Songs WHERE ReleaseDate BETWEEN '2019-01-01' AND '2019-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE EsportsEvents (EventID INT, EventName VARCHAR(50), Location VARCHAR(50), Year INT); INSERT INTO EsportsEvents (EventID, EventName, Location, Year) VALUES (1, 'Event1', 'USA', 2021), (2, 'Event2', 'Canada', 2021), (3, 'Event3', 'UK', 2020), (4, 'Event4', 'Australia', 2021), (5, 'Event5', 'New Zealand', 2020);
How many esports events were held in North America, Europe, and Oceania last year?
SELECT COUNT(*) FROM EsportsEvents WHERE Year = 2021 AND Location IN ('USA', 'Canada', 'UK', 'Australia', 'New Zealand');
gretelai_synthetic_text_to_sql
CREATE TABLE climate_finance (id INT, region TEXT, project_type TEXT, finance_amount FLOAT);
What is the maximum and minimum finance amount spent on climate mitigation projects in each region, for the last 3 years?
SELECT region, MAX(finance_amount) as max_finance, MIN(finance_amount) as min_finance FROM climate_finance WHERE project_type = 'mitigation' AND year BETWEEN (YEAR(CURRENT_DATE) - 3) AND YEAR(CURRENT_DATE) GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, country VARCHAR(2), clicked_ad BOOLEAN); INSERT INTO users (id, country, clicked_ad) VALUES (1, 'CA', true), (2, 'CA', false), (3, 'CA', true), (4, 'DE', false);
What is the percentage of users in Canada who have clicked on an ad?
SELECT 100.0 * SUM(CASE WHEN clicked_ad = true THEN 1 ELSE 0 END) / COUNT(*) as percentage_clicked_ad FROM users WHERE country = 'CA';
gretelai_synthetic_text_to_sql
CREATE TABLE Events (EventID INT PRIMARY KEY, EventName VARCHAR(255), Attendance INT); CREATE TABLE Audience (AudienceID INT PRIMARY KEY, Age INT, Gender VARCHAR(10), Occupation VARCHAR(255), EventID INT, FOREIGN KEY (EventID) REFERENCES Events(EventID)); INSERT INTO Events (EventID, EventName, Attendance) VALUES (1, 'Indigenous Art', 700); INSERT INTO Audience (AudienceID, Age, Gender, Occupation, EventID) VALUES (1, 32, 'Female', 'Art Student', 1), (2, 45, 'Male', 'Art Historian', 1), (3, 28, 'Non-binary', 'Graphic Designer', 1), (4, 40, 'Female', 'Indigenous Artist', 1);
How many unique occupations are represented in the audience for the 'Indigenous Art' event?
SELECT COUNT(DISTINCT Audience.Occupation) FROM Audience INNER JOIN Events ON Audience.EventID = Events.EventID WHERE Events.EventName = 'Indigenous Art';
gretelai_synthetic_text_to_sql
CREATE TABLE workshops (id INT, name TEXT, type TEXT, participation_rate FLOAT); INSERT INTO workshops (id, name, type, participation_rate) VALUES (1, 'WorkA', 'WomenInTech', 0.68), (2, 'WorkB', 'General', 0.92), (3, 'WorkC', 'WomenInTech', 0.75);
What is the minimum participation_rate in AI workshops for women in tech?
SELECT MIN(participation_rate) FROM workshops WHERE type = 'WomenInTech';
gretelai_synthetic_text_to_sql
CREATE TABLE fabric_sourcing (sourcing_id INT PRIMARY KEY, material_name VARCHAR(50), units_sourced INT); INSERT INTO fabric_sourcing (sourcing_id, material_name, units_sourced) VALUES (1, 'Organic Cotton', 5000), (2, 'Hemp', 3000), (3, 'Bamboo', 2000);
How many units of organic cotton fabric have been sourced by textile manufacturers?
SELECT SUM(units_sourced) FROM fabric_sourcing WHERE material_name = 'Organic Cotton';
gretelai_synthetic_text_to_sql
CREATE TABLE clinical_trials (country TEXT, trial_success_rate REAL, therapeutic_area TEXT); INSERT INTO clinical_trials (country, trial_success_rate, therapeutic_area) VALUES ('US', 0.75, 'oncology'), ('UK', 0.68, 'oncology'), ('Germany', 0.72, 'oncology'), ('France', 0.71, 'oncology'), ('Japan', 0.65, 'oncology');
Which countries have the highest average clinical trial success rate in oncology?
SELECT country, AVG(trial_success_rate) as avg_trial_success_rate FROM clinical_trials WHERE therapeutic_area = 'oncology' GROUP BY country ORDER BY avg_trial_success_rate DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE menus (menu_id INT, dish_name VARCHAR(50), dish_type VARCHAR(50), price DECIMAL(5,2), sales INT);
Update the price of all 'Vegetarian' dishes by 10%
UPDATE menus SET price = price * 1.1 WHERE dish_type = 'Vegetarian';
gretelai_synthetic_text_to_sql
CREATE TABLE beauty_products(product_id INT, product_type VARCHAR(20), halal_certified BOOLEAN, price DECIMAL(10,2)); INSERT INTO beauty_products(product_id, product_type, halal_certified, price) VALUES(1, 'Cleanser', TRUE, 30.00), (2, 'Toner', FALSE, 15.00);
Find the average price of halal-certified skincare products
SELECT AVG(price) FROM beauty_products WHERE product_type LIKE 'Skincare%' AND halal_certified = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE broadband_revenue (revenue_id INT, revenue_date DATE, revenue_amount FLOAT); INSERT INTO broadband_revenue (revenue_id, revenue_date, revenue_amount) VALUES (1, '2022-01-01', 28000); INSERT INTO broadband_revenue (revenue_id, revenue_date, revenue_amount) VALUES (2, '2022-02-15', 32000);
Display the total revenue generated from broadband services for each month in the year 2022.
SELECT DATE_TRUNC('month', revenue_date) AS month, SUM(revenue_amount) AS total_revenue FROM broadband_revenue WHERE revenue_date >= '2022-01-01' GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE Plant_Waste (Plant VARCHAR(255), Waste_Amount INT, Waste_Date DATE); INSERT INTO Plant_Waste (Plant, Waste_Amount, Waste_Date) VALUES ('Plant1', 50, '2022-06-01'), ('Plant2', 30, '2022-06-01'), ('Plant3', 70, '2022-06-01'), ('Plant4', 60, '2022-06-01'), ('Plant5', 40, '2022-06-01');
Identify the top five manufacturing plants with the highest waste production, along with their total waste production, in the past month.
SELECT Plant, SUM(Waste_Amount) AS Total_Waste, RANK() OVER (ORDER BY SUM(Waste_Amount) DESC) AS Rank FROM Plant_Waste WHERE Waste_Date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY Plant ORDER BY Rank LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE shariah_compliant_finance (id INT, value DECIMAL(10, 2), client_id INT, client_country VARCHAR(50), date DATE);
List all Shariah-compliant finance transactions for clients residing in Indonesia in H1 2022.
SELECT shariah_compliant_finance.* FROM shariah_compliant_finance WHERE client_country = 'Indonesia' AND date BETWEEN '2022-01-01' AND '2022-06-30';
gretelai_synthetic_text_to_sql
CREATE TABLE Station (sid INT, name VARCHAR(255), type VARCHAR(255)); CREATE TABLE Employee (eid INT, sid INT, role VARCHAR(255));
What is the average number of police officers and firefighters in each station?
SELECT Station.name, AVG(CASE WHEN Employee.role = 'police officer' THEN 1 ELSE 0 END + CASE WHEN Employee.role = 'firefighter' THEN 1 ELSE 0 END) as avg_employees FROM Station INNER JOIN Employee ON Station.sid = Employee.sid GROUP BY Station.name;
gretelai_synthetic_text_to_sql
CREATE TABLE player_scores (player_id INT, game_name VARCHAR(255), score INT, date DATE);
Update player's scores with a 10% increase for the "Fantasy Battle" game
UPDATE player_scores SET score = score * 1.1 WHERE game_name = 'Fantasy Battle';
gretelai_synthetic_text_to_sql
CREATE TABLE Customers(id INT, customer_name VARCHAR(50), returned_items INT); INSERT INTO Customers(id, customer_name, returned_items) VALUES (1, 'John Smith', 10), (2, 'Jane Doe', 5), (3, 'Mike Johnson', 15);
Who are the top 3 customers with the highest number of returned items?
SELECT customer_name, ROW_NUMBER() OVER (ORDER BY returned_items DESC) as rank FROM Customers WHERE rank <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE ArtExhibitions (exhibition_date DATE, num_pieces INT); INSERT INTO ArtExhibitions (exhibition_date, num_pieces) VALUES ('2022-01-01', 120), ('2022-01-02', 150), ('2022-01-03', 80), ('2022-01-04', 90), ('2022-02-01', 120), ('2022-02-02', 150), ('2022-02-03', 80), ('2022-02-04', 90), ('2022-03-01', 120), ('2022-03-02', 150), ('2022-03-03', 80), ('2022-03-04', 90);
What is the minimum and maximum number of pieces in art exhibitions in the last year?
SELECT MIN(num_pieces), MAX(num_pieces) FROM ArtExhibitions WHERE exhibition_date >= DATEADD(YEAR, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE athletes (athlete_id INT, name VARCHAR(50), sport VARCHAR(50)); INSERT INTO athletes (athlete_id, name, sport) VALUES (1, 'John Doe', 'Basketball'), (2, 'Jane Smith', 'Soccer'); CREATE TABLE events (event_id INT, event_name VARCHAR(50), year INT); INSERT INTO events (event_id, event_name, year) VALUES (1, 'FIFA World Cup', 2022), (2, 'NBA Finals', 2023);
Insert new records of athletes who participated in the 2022 FIFA World Cup
INSERT INTO athletes (athlete_id, name, sport) SELECT 3, 'Ronaldo', 'Soccer' WHERE NOT EXISTS (SELECT 1 FROM athletes WHERE name = 'Ronaldo'); INSERT INTO athletes (athlete_id, name, sport, event_id) SELECT 4, 'Messi', 'Soccer', (SELECT event_id FROM events WHERE event_name = 'FIFA World Cup' AND year = 2022) WHERE NOT EXISTS (SELECT 1 FROM athletes WHERE name = 'Messi');
gretelai_synthetic_text_to_sql
CREATE TABLE Accommodations (StudentID INT, DisabilityType VARCHAR(50), Gender VARCHAR(50), Region VARCHAR(50), AccommodationYear INT); INSERT INTO Accommodations (StudentID, DisabilityType, Gender, Region, AccommodationYear) VALUES (1, 'Visual Impairment', 'Male', 'Pacific', 2023), (2, 'Visual Impairment', 'Female', 'Pacific', 2023), (3, 'Visual Impairment', 'Non-binary', 'Pacific', 2023);
How many students with visual impairments received accommodations in the Pacific region in 2023, grouped by gender?
SELECT Gender, COUNT(StudentID) FROM Accommodations WHERE DisabilityType = 'Visual Impairment' AND Region = 'Pacific' AND AccommodationYear = 2023 GROUP BY Gender;
gretelai_synthetic_text_to_sql
CREATE TABLE initiatives (id INT, name VARCHAR(50), country VARCHAR(50));
Which countries have the highest number of social good technology initiatives?
SELECT country, COUNT(*) as count FROM initiatives WHERE name LIKE '%social good%' GROUP BY country ORDER BY count DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID int, DonorName text); INSERT INTO Donors VALUES (1, 'John Doe'); INSERT INTO Donors VALUES (2, 'Jane Smith');CREATE TABLE Donations (DonationID int, DonorID int, DonationAmount numeric, Cause text); INSERT INTO Donations VALUES (1, 1, 500, 'Education'); INSERT INTO Donations VALUES (2, 2, 1000, 'Health');CREATE TABLE Causes (CauseID int, Cause text); INSERT INTO Causes VALUES (1, 'Education'); INSERT INTO Causes VALUES (2, 'Health');
What's the minimum donation amount for each cause?
SELECT C.Cause, MIN(D.DonationAmount) FROM Donors D INNER JOIN Donations DD ON D.DonorID = DD.DonorID INNER JOIN Causes C ON DD.Cause = C.Cause GROUP BY C.Cause;
gretelai_synthetic_text_to_sql
CREATE TABLE yttrium_production (year INT, country TEXT, volume INT); INSERT INTO yttrium_production (year, country, volume) VALUES (2017, 'Australia', 125), (2018, 'Australia', 130), (2019, 'Australia', 135), (2020, 'Australia', 140), (2017, 'Brazil', 90), (2018, 'Brazil', 95), (2019, 'Brazil', 100), (2020, 'Brazil', 105);
Calculate the total yttrium production volume in Australia and Brazil for 2017-2020.
SELECT SUM(volume) FROM yttrium_production WHERE country IN ('Australia', 'Brazil') AND year BETWEEN 2017 AND 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE menus (menu_id INT, dish_name VARCHAR(50), dish_type VARCHAR(50), price DECIMAL(5,2), sales INT, date DATE);
What is the total sales for 'Sushi' dishes in the last week?
SELECT SUM(sales) FROM menus WHERE dish_type = 'Sushi' AND date >= CURDATE() - INTERVAL 7 DAY;
gretelai_synthetic_text_to_sql
CREATE TABLE rural_hospitals (hospital_id INT, beds INT, location VARCHAR(20));
What is the total number of beds in rural_hospitals for hospitals in Canada and Australia?
SELECT SUM(beds) FROM rural_hospitals WHERE location IN ('Canada', 'Australia');
gretelai_synthetic_text_to_sql
CREATE TABLE ExcavationSites (SiteID INT, SiteName VARCHAR(50), Country VARCHAR(50), Year INT, ArtifactWeight FLOAT, ArtifactType VARCHAR(50)); INSERT INTO ExcavationSites (SiteID, SiteName, Country, Year, ArtifactWeight, ArtifactType) VALUES (1, 'SiteA', 'USA', 2020, 23.5, 'Pottery'), (2, 'SiteB', 'Mexico', 2020, 14.2, 'Stone Tool'), (3, 'SiteC', 'USA', 2019, 34.8, 'Bone Tool'), (4, 'SiteD', 'Canada', 2019, 45.6, 'Ceramic Figurine'), (5, 'SiteE', 'Canada', 2019, 56.7, 'Metal Artifact');
List the excavation sites with the highest artifact weight for each year, along with the artifact type and weight.
SELECT SiteName, Year, ArtifactType, ArtifactWeight FROM (SELECT SiteName, Year, ArtifactType, ArtifactWeight, ROW_NUMBER() OVER (PARTITION BY Year ORDER BY ArtifactWeight DESC) rn FROM ExcavationSites) x WHERE rn = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE DefenseProjects (project_name VARCHAR(255), start_date DATE, end_date DATE, budget FLOAT); INSERT INTO DefenseProjects (project_name, start_date, end_date, budget) VALUES ('Project C', '2022-01-01', '2024-12-31', 700000000);
Update the name of defense project 'Project C' to 'Project D'.
UPDATE DefenseProjects SET project_name = 'Project D' WHERE project_name = 'Project C';
gretelai_synthetic_text_to_sql
CREATE TABLE energy_efficiency (id INT, country VARCHAR(50), sector VARCHAR(50), efficiency FLOAT, year INT); INSERT INTO energy_efficiency (id, country, sector, efficiency, year) VALUES (1, 'Japan', 'Industrial', 0.65, 2022), (2, 'Australia', 'Industrial', 0.62, 2022);
Which country in the Asia Pacific region has the highest energy efficiency in the industrial sector for the year 2022?
SELECT country, MAX(efficiency) as max_efficiency FROM energy_efficiency WHERE sector = 'Industrial' AND year = 2022 AND country IN ('Japan', 'Australia') GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE artists (id INT, name VARCHAR(255), gender VARCHAR(10), genre VARCHAR(255)); INSERT INTO artists (id, name, gender, genre) VALUES (1, 'Taylor Swift', 'Female', 'Pop'); CREATE TABLE songs (id INT, title VARCHAR(255), length INT, artist_id INT); INSERT INTO songs (id, title, length, artist_id) VALUES (1, 'Shake it Off', 223, 1);
What is the average length of songs (in seconds) by female artists in the pop genre released since 2010?
SELECT AVG(length) FROM songs JOIN artists ON songs.artist_id = artists.id WHERE artists.gender = 'Female' AND artists.genre = 'Pop' AND songs.length > 0 AND songs.id > 0 AND YEAR(songs.id) >= 2010;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (id INT, species_name TEXT, ocean TEXT); INSERT INTO marine_species (id, species_name, ocean) VALUES (1, 'Clownfish', 'Pacific'), (2, 'Dolphin', 'Atlantic'), (3, 'Starfish', 'Pacific'), (4, 'Shark', 'Atlantic');
What is the total number of marine species recorded in the Pacific and Atlantic oceans, grouped by ocean?
SELECT ocean, COUNT(*) FROM marine_species GROUP BY ocean;
gretelai_synthetic_text_to_sql
CREATE TABLE developers (id INT, name VARCHAR(50), salary FLOAT, department VARCHAR(50)); INSERT INTO developers (id, name, salary, department) VALUES (1, 'Alice', 70000, 'AI Research'), (2, 'Bob', 75000, 'AI Research'), (3, 'Charlie', 80000, 'Accessibility'), (4, 'Dave', 85000, 'Accessibility'), (5, 'Eve', 90000, 'Social Good');
What is the average salary of developers in the "tech4good" company, grouped by their department and only for those departments with more than 10 developers?
SELECT department, AVG(salary) FROM developers GROUP BY department HAVING COUNT(*) > 10;
gretelai_synthetic_text_to_sql
CREATE TABLE clients (id INT, name TEXT, age INT, state TEXT, transaction_amount DECIMAL(10,2)); INSERT INTO clients (id, name, age, state, transaction_amount) VALUES (1, 'John Doe', 35, 'Michigan', 800.00); INSERT INTO clients (id, name, age, state, transaction_amount) VALUES (2, 'Jane Smith', 40, 'Michigan', 750.50);
What is the maximum transaction amount for clients living in Michigan?
SELECT MAX(transaction_amount) FROM clients WHERE state = 'Michigan';
gretelai_synthetic_text_to_sql
CREATE TABLE permits (id INT, project_id INT, agency VARCHAR(255), permit_type VARCHAR(255), date DATE, expiration_date DATE, status VARCHAR(255));
Update the status column to 'inactive' for permits that have expired in the permits table.
UPDATE permits SET status = 'inactive' WHERE expiration_date < CURDATE();
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists attackers (attacker_id INT, name VARCHAR, volume INT); INSERT INTO attackers (attacker_id, name, volume) VALUES (1, 'A', 500), (2, 'B', 600), (3, 'C', 700), (4, 'D', 800), (5, 'E', 900);
Identify the top 5 attackers by total attack volume in the past month
SELECT attacker_id, name, SUM(volume) as total_volume FROM attackers WHERE attack_date >= DATEADD(month, -1, GETDATE()) GROUP BY attacker_id, name ORDER BY total_volume DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE budgets (fiscal_year INT, category VARCHAR(255), amount DECIMAL(10,2));
What was the total budget for military innovation in the last fiscal year?
SELECT SUM(amount) FROM budgets WHERE fiscal_year = EXTRACT(YEAR FROM NOW()) - EXTRACT(YEAR FROM LAST_DAY(DATE_SUB(NOW(), INTERVAL 1 YEAR))) AND category = 'Military Innovation';
gretelai_synthetic_text_to_sql
CREATE TABLE accommodations (id INT, name VARCHAR(50), country VARCHAR(50), sustainability_score INT); INSERT INTO accommodations (id, name, country, sustainability_score) VALUES (1, 'Hotel XYZ', 'Canada', 70);
Update the sustainability score for 'Hotel XYZ' in 'Canada'.
UPDATE accommodations SET sustainability_score = 80 WHERE name = 'Hotel XYZ' AND country = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE RestorativeJustice (ProgramID INT, ProgramName VARCHAR(50), Country VARCHAR(20)); INSERT INTO RestorativeJustice VALUES (1, 'RJ Program 1', 'Canada'); INSERT INTO RestorativeJustice VALUES (2, 'RJ Program 2', 'Canada'); INSERT INTO RestorativeJustice VALUES (3, 'RJ Program 3', 'Australia');
What is the total number of restorative justice programs in Canada and Australia?
SELECT COUNT(*) FROM RestorativeJustice WHERE Country IN ('Canada', 'Australia');
gretelai_synthetic_text_to_sql
CREATE TABLE species (id INT PRIMARY KEY, name VARCHAR(255), group VARCHAR(255), conservation_status VARCHAR(255), habitat VARCHAR(255)); INSERT INTO species (id, name, group, conservation_status, habitat) VALUES (1, 'Beluga Whale', 'Mammal', 'Least Concern', 'Arctic Ocean');
List the conservation statuses of all marine mammal species in the Arctic Ocean.
SELECT species.conservation_status FROM species WHERE species.group = 'Mammal' AND species.habitat = 'Arctic Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE restaurant_menu (restaurant_id INT, cuisine VARCHAR(255)); INSERT INTO restaurant_menu (restaurant_id, cuisine) VALUES (1, 'Italian'), (1, 'Mexican'), (2, 'Chinese'), (3, 'Italian');
Which restaurants serve a specific cuisine type?
SELECT restaurant_id FROM restaurant_menu WHERE cuisine = 'Italian';
gretelai_synthetic_text_to_sql
CREATE TABLE rd_expenditures (country VARCHAR(50), year INT, amount FLOAT); INSERT INTO rd_expenditures (country, year, amount) VALUES ('USA', 2020, 70000000), ('China', 2020, 40000000), ('Germany', 2020, 30000000);
What was the average R&D expenditure per country in 2020?
SELECT AVG(amount) FROM rd_expenditures WHERE year = 2020 GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE States (state_id INT, state_name TEXT, state_population INT); CREATE TABLE Providers (provider_id INT, provider_type TEXT, state_id INT);
What is the minimum number of mental health providers per capita in each state?
SELECT MIN(providers_per_capita) as min_providers_per_capita FROM (SELECT COUNT(*) / state_population as providers_per_capita FROM Providers p JOIN States s ON p.state_id = s.state_id GROUP BY p.state_id);
gretelai_synthetic_text_to_sql
CREATE TABLE CountryCybersecurity (Country VARCHAR(50) PRIMARY KEY, Strategy VARCHAR(50), SuccessRate DECIMAL(3,2));
Reveal countries with cybersecurity strategies having a lower success rate than 30%
SELECT Country FROM CountryCybersecurity WHERE SuccessRate < 0.3 GROUP BY Country HAVING COUNT(*) > 1;
gretelai_synthetic_text_to_sql
CREATE TABLE MarineLife (LifeID INT, LifeName VARCHAR(255), Species VARCHAR(255), Habitat VARCHAR(255), ConservationStatus VARCHAR(255));
Insert new data into the 'MarineLife' table
INSERT INTO MarineLife (LifeID, LifeName, Species, Habitat, ConservationStatus) VALUES (1, 'Blue Whale', 'Balaenoptera musculus', 'Ocean', 'Endangered');
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, Department VARCHAR(25), Salary DECIMAL(10, 2), HireDate DATE, PromotionDate DATE); INSERT INTO Employees (EmployeeID, Department, Salary, HireDate, PromotionDate) VALUES (1, 'IT', 60000, '2018-01-01', '2021-01-01'), (2, 'Marketing', 70000, '2019-06-15', NULL), (3, 'IT', 65000, '2019-09-01', NULL), (4, 'HR', 75000, '2016-05-01', '2021-05-01');
What is the average salary for employees in the IT department who have been with the company for more than three years and have not received a promotion in the last year?
SELECT Department, AVG(Salary) FROM Employees WHERE Department = 'IT' AND DATEDIFF(year, HireDate, GETDATE()) > 3 AND PromotionDate IS NULL GROUP BY Department;
gretelai_synthetic_text_to_sql
CREATE TABLE dishes (dish_id INT, dish_name VARCHAR(255), price DECIMAL(5,2), category VARCHAR(255)); INSERT INTO dishes (dish_id, dish_name, price, category) VALUES (1, 'Margherita Pizza', 12.99, 'Pizza'), (2, 'Chicken Alfredo', 15.99, 'Pasta'), (3, 'Caesar Salad', 9.99, 'Salad');
Select the top 3 most ordered dishes by customers
SELECT dish_name, COUNT(*) as order_count FROM dishes GROUP BY dish_name ORDER BY order_count DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE shariah_compliant_accounts (id INT, balance FLOAT, region VARCHAR(255));
Minimum Shariah-compliant account balance in the Central region
SELECT MIN(balance) FROM shariah_compliant_accounts WHERE region = 'Central';
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists aerospace;CREATE TABLE if not exists aerospace.satellites (id INT PRIMARY KEY, country VARCHAR(50), name VARCHAR(50), launch_date DATE); INSERT INTO aerospace.satellites (id, country, name, launch_date) VALUES (1, 'USA', 'Sat1', '2000-01-01'), (2, 'USA', 'Sat2', '2001-01-01'), (3, 'China', 'Sat3', '2002-01-01');
What is the earliest launch date for each country's satellites?
SELECT country, MIN(launch_date) as earliest_launch_date FROM aerospace.satellites GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE menu_items (menu_item_id INT, name VARCHAR(255), description TEXT, price DECIMAL(5,2), category VARCHAR(255), sustainability_rating INT);
List the average price of menu items in the vegetarian category
SELECT AVG(price) FROM menu_items WHERE category = 'vegetarian';
gretelai_synthetic_text_to_sql
CREATE TABLE heavy_equipment (equipment_model VARCHAR(50), equipment_type VARCHAR(50)); INSERT INTO heavy_equipment (equipment_model, equipment_type) VALUES ('Bulldozer 5000', 'Earth Mover'), ('Excavator 3000', 'Digging'), ('Dump Truck 2000', 'Transport');
List all 'equipment_models' and their corresponding 'equipment_type' from the 'heavy_equipment' table.
SELECT equipment_model, equipment_type FROM heavy_equipment;
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, PlayerName VARCHAR(50), Country VARCHAR(50)); INSERT INTO Players (PlayerID, PlayerName, Country) VALUES (1, 'John Smith', 'Canada'); INSERT INTO Players (PlayerID, PlayerName, Country) VALUES (2, 'Jane Doe', 'USA'); CREATE TABLE VRAdoption (PlayerID INT, VRAdopted DATE); INSERT INTO VRAdoption (PlayerID, VRAdopted) VALUES (1, '2021-08-01'); INSERT INTO VRAdoption (PlayerID, VRAdopted) VALUES (2, '2021-09-01');
Get the number of players who adopted VR technology in each country
SELECT p.Country, COUNT(*) FROM Players p INNER JOIN VRAdoption va ON p.PlayerID = va.PlayerID GROUP BY p.Country;
gretelai_synthetic_text_to_sql
CREATE TABLE market_trends (element VARCHAR(255), year INT, quantity INT); INSERT INTO market_trends (element, year, quantity) VALUES ('Neodymium', 2019, 5000), ('Praseodymium', 2019, 3000), ('Dysprosium', 2019, 2000);
How many rare earth elements were traded in total in 2019?
SELECT SUM(quantity) FROM market_trends WHERE year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE ingredient_sourcing (id INT, region VARCHAR(255), country VARCHAR(255), incidents INT); INSERT INTO ingredient_sourcing (id, region, country, incidents) VALUES (1, 'Rose Valley', 'Canada', 0);
How many incidents of product contamination have been reported in Canadian ingredient sourcing regions?
SELECT SUM(incidents) FROM ingredient_sourcing WHERE country = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE MiningOperations (OperationID INT, MineName VARCHAR(100), OperationType VARCHAR(50), Country VARCHAR(50), StartDate DATE, EndDate DATE); INSERT INTO MiningOperations (OperationID, MineName, OperationType, Country, StartDate, EndDate) VALUES (1, 'Golden Mine', 'Exploration', 'Australia', '2015-01-01', '2015-12-31'), (2, 'Silver Ridge', 'Extraction', 'USA', '2016-01-01', '2016-12-31'); CREATE TABLE EnvironmentalImpact (OperationID INT, CO2Emissions INT, WaterUsage INT, WasteGeneration INT); INSERT INTO EnvironmentalImpact (OperationID, CO2Emissions, WaterUsage, WasteGeneration) VALUES (1, 5000, 10000, 2000), (2, 7000, 12000, 2500);
List the mining operations with CO2 emissions greater than a specific value in Australia.
SELECT mo.OperationID, mo.MineName, ei.CO2Emissions FROM MiningOperations mo JOIN EnvironmentalImpact ei ON mo.OperationID = ei.OperationID WHERE ei.CO2Emissions > 6000 AND mo.Country = 'Australia';
gretelai_synthetic_text_to_sql
CREATE TABLE Spacecrafts (id INT, name VARCHAR(50), manufacturer VARCHAR(50), weight FLOAT, manufacture_year INT); INSERT INTO Spacecrafts (id, name, manufacturer, weight, manufacture_year) VALUES (1, 'Voyager 1', 'AstroInnovations', 770.0, 2021), (2, 'Voyager 2', 'AstroInnovations', 775.0, 2022), (3, 'Voyager 3', 'AstroInnovations', 800.0, 2022);
What is the total weight of spacecrafts manufactured in 2022 by 'AstroInnovations'?
SELECT SUM(weight) FROM Spacecrafts WHERE manufacturer = 'AstroInnovations' AND manufacture_year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE covid_vaccinations (id INT, name TEXT, race TEXT, county TEXT); INSERT INTO covid_vaccinations (id, name, race, county) VALUES (1, 'John Doe', 'Hispanic', 'Los Angeles County'); INSERT INTO covid_vaccinations (id, name, race, county) VALUES (2, 'Jane Smith', 'Asian', 'Los Angeles County');
What is the racial/ethnic breakdown of COVID-19 vaccinations in Los Angeles County?
SELECT race, COUNT(*) FROM covid_vaccinations WHERE county = 'Los Angeles County' GROUP BY race;
gretelai_synthetic_text_to_sql
CREATE TABLE movies (title VARCHAR(255), genre VARCHAR(50), budget INT, release_year INT, rating INT); INSERT INTO movies (title, genre, budget, release_year, rating) VALUES ('Movie1', 'Comedy', 20000000, 2010, 8), ('Movie2', 'Comedy', 30000000, 2012, 7), ('Movie3', 'Drama', 40000000, 2015, 9);
Update the ratings of all movies with a genre of 'Comedy' to be 0.5 points lower
UPDATE movies SET rating = rating - 0.5 WHERE genre = 'Comedy';
gretelai_synthetic_text_to_sql
CREATE TABLE vehicle_maintenance_by_day (facility_location VARCHAR(50), day_of_year INT, num_vehicles INT); INSERT INTO vehicle_maintenance_by_day (facility_location, day_of_year, num_vehicles) VALUES ('East Bay', 1, 30), ('East Bay', 2, 35), ('East Bay', 3, 32);
How many vehicles were maintained in the 'East Bay' facility in the first half of the year?
SELECT SUM(num_vehicles) FROM vehicle_maintenance_by_day WHERE facility_location = 'East Bay' AND day_of_year <= 182;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, Name VARCHAR(50), Gender VARCHAR(10), Department VARCHAR(50), Age INT); INSERT INTO Employees (EmployeeID, Name, Gender, Department, Age) VALUES (1, 'John Doe', 'Male', 'Mining Operations', 35); INSERT INTO Employees (EmployeeID, Name, Gender, Department, Age) VALUES (2, 'Jane Smith', 'Female', 'Human Resources', 40); INSERT INTO Employees (EmployeeID, Name, Gender, Department, Age) VALUES (3, 'David Johnson', 'Male', 'Finance', 25);
What is the minimum age of employees in the 'Mining Operations' department?
SELECT MIN(Age) FROM Employees WHERE Department = 'Mining Operations';
gretelai_synthetic_text_to_sql
CREATE TABLE farmers (id INT, name VARCHAR(30), participation VARCHAR(20));
List the names of all farmers who have participated in 'food justice' initiatives.
SELECT name FROM farmers WHERE participation = 'food justice';
gretelai_synthetic_text_to_sql
CREATE TABLE veteran_employment (id INT PRIMARY KEY, name VARCHAR(255), position VARCHAR(255), years_of_service INT);
Add a new column 'salary' to the veteran_employment table
ALTER TABLE veteran_employment ADD COLUMN salary NUMERIC(10, 2);
gretelai_synthetic_text_to_sql
CREATE TABLE athlete_injuries (athlete_id INT, injury_date DATE); CREATE TABLE athletes (athlete_id INT PRIMARY KEY);
Find athletes who have never been injured in the 'athlete_injuries' table
SELECT athletes.athlete_id FROM athletes WHERE athletes.athlete_id NOT IN (SELECT athlete_id FROM athlete_injuries);
gretelai_synthetic_text_to_sql
CREATE TABLE MovieViews (ViewID INT, Movie VARCHAR(100), Country VARCHAR(50), Views INT);
Views per movie per country?
SELECT Country, Movie, SUM(Views) as Total_Views FROM MovieViews GROUP BY Country, Movie;
gretelai_synthetic_text_to_sql