context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE building_permits (permit_id INT); CREATE TABLE labor_stats (permit_id INT);
Delete all permits with no labor violations
DELETE FROM building_permits WHERE permit_id NOT IN (SELECT permit_id FROM labor_stats);
gretelai_synthetic_text_to_sql
CREATE TABLE habitat_preservation (habitat_type VARCHAR(255), location VARCHAR(255)); CREATE TABLE habitats (habitat_type VARCHAR(255), area_size FLOAT); CREATE TABLE endangered_species (species VARCHAR(255), habitat_type VARCHAR(255));
Calculate the percentage of endangered species for each habitat type in the "habitat_preservation", "habitats", and "endangered_species" tables
SELECT h1.habitat_type, (COUNT(e1.species) * 100.0 / (SELECT COUNT(*) FROM endangered_species e2 WHERE e2.habitat_type = h1.habitat_type)) as endangered_percentage FROM endangered_species e1 INNER JOIN habitat_preservation h1 ON e1.habitat_type = h1.habitat_type INNER JOIN habitats h2 ON h1.habitat_type = h2.habitat_ty...
gretelai_synthetic_text_to_sql
CREATE TABLE policy_advocacy (initiative_id INT, initiative_name VARCHAR(30), budget DECIMAL(10,2)); INSERT INTO policy_advocacy (initiative_id, initiative_name, budget) VALUES (1, 'Accessibility Laws', 50000), (2, 'Inclusive Education', 75000), (3, 'Employment Policies', 60000);
List all policy advocacy initiatives and their budgets
SELECT * FROM policy_advocacy;
gretelai_synthetic_text_to_sql
CREATE TABLE district (id INT, name TEXT); CREATE TABLE mine (id INT, name TEXT, district_id INT, num_employees INT); INSERT INTO district (id, name) VALUES (1, 'District A'), (2, 'District B'), (3, 'District C'); INSERT INTO mine (id, name, district_id, num_employees) VALUES (1, 'Gold Mine 1', 1, 1000), (2, 'Copper Mi...
What is the number of mines that have more than 500 employees and their corresponding district?
SELECT district.name, mine.name, mine.num_employees FROM district JOIN mine ON district.id = mine.district_id WHERE mine.num_employees > 500;
gretelai_synthetic_text_to_sql
CREATE TABLE science_accommodations (student_id INT, semester VARCHAR(10));CREATE TABLE math_accommodations (student_id INT, semester VARCHAR(10)); INSERT INTO science_accommodations VALUES (1, 'spring 2021'), (2, 'spring 2021'), (3, 'spring 2021'); INSERT INTO math_accommodations VALUES (2, 'spring 2021'), (3, 'spring...
What is the total number of students who received accommodations in the science department, and the total number who received accommodations in the math department, for the spring 2021 semester?
SELECT COUNT(*) FROM science_accommodations WHERE semester = 'spring 2021' UNION ALL SELECT COUNT(*) FROM math_accommodations WHERE semester = 'spring 2021';
gretelai_synthetic_text_to_sql
CREATE TABLE DefenseDiplomacy (Country VARCHAR(50), Year INT, Activities INT); INSERT INTO DefenseDiplomacy (Country, Year, Activities) VALUES ('USA', 2020, 30), ('China', 2020, 25), ('Japan', 2020, 20), ('USA', 2021, 35), ('China', 2021, 28), ('Japan', 2021, 23);
What is the average defense diplomacy activity count for each country in the last 2 years, ranked from highest to lowest?
SELECT Country, AVG(Activities) OVER (PARTITION BY Country ORDER BY Year ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS AvgActivities, RANK() OVER (ORDER BY AvgActivities DESC) AS Rank FROM DefenseDiplomacy GROUP BY Country ORDER BY Rank;
gretelai_synthetic_text_to_sql
CREATE TABLE forwarders(id INT, name VARCHAR(255), country VARCHAR(255)); INSERT INTO forwarders VALUES(1, 'ABC Logistics', 'USA'), (2, 'DEF Freight', 'Canada'), (3, 'GHI Shipping', 'USA');
List all freight forwarders in Canada
SELECT * FROM forwarders WHERE country = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE patients (patient_id INT, name VARCHAR(50), age INT, gender VARCHAR(10), condition VARCHAR(50)); INSERT INTO patients (patient_id, name, age, gender, condition) VALUES (1, 'John Doe', 30, 'Male', 'Anxiety Disorder'); INSERT INTO patients (patient_id, name, age, gender, condition) VALUES (2, 'Jane Smith', 3...
Find the youngest female patient in the 'patients' table.
SELECT * FROM patients WHERE gender = 'Female' ORDER BY age ASC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE precipitation (region VARCHAR(255), year INT, precipitation_amount INT); INSERT INTO precipitation (region, year, precipitation_amount) VALUES ('North', 2018, 800), ('North', 2019, 850), ('North', 2020, 900), ('South', 2018, 750), ('South', 2019, 700), ('South', 2020, 720); CREATE TABLE drought_info (regio...
Which regions had a precipitation amount higher than 850 in the years they experienced droughts in 2018 or 2019?
SELECT p.region FROM precipitation p JOIN drought_info d ON p.region = d.region WHERE (p.precipitation_amount > 850 AND d.year = p.year AND d.severity > 0) AND (d.year = 2018 OR d.year = 2019);
gretelai_synthetic_text_to_sql
CREATE TABLE people_per_household (household_id INT, people_count INT); CREATE TABLE water_consumption_by_household (household_id INT, water_consumption INT); CREATE TABLE household_info (household_id INT, city VARCHAR(20));
What is the average water consumption per person for households in Los Angeles?
SELECT AVG(water_consumption / people_count) FROM water_consumption_by_household JOIN household_info ON water_consumption_by_household.household_id = household_info.household_id JOIN people_per_household ON water_consumption_by_household.household_id = people_per_household.household_id WHERE household_info.city = 'Los ...
gretelai_synthetic_text_to_sql
CREATE TABLE tickets (ticket_id INT, team VARCHAR(50), event_date DATE, ticket_price DECIMAL(5, 2)); INSERT INTO tickets (ticket_id, team, event_date, ticket_price) VALUES (1, 'Basketball', '2022-03-01', 50.00), (2, 'Basketball', '2022-03-15', 75.00);
Update the ticket_price for all tickets of the basketball team events by 10%
UPDATE tickets SET ticket_price = ticket_price * 1.10 WHERE team = 'Basketball';
gretelai_synthetic_text_to_sql
CREATE TABLE water_conservation(state VARCHAR(20), year INT, amount_conserved INT); INSERT INTO water_conservation(state, year, amount_conserved) VALUES ('Rajasthan', 2015, 2500), ('Rajasthan', 2016, 3000), ('Rajasthan', 2017, 3500), ('Rajasthan', 2018, 4000), ('California', 2015, 4500), ('California', 2016, 5000), ('C...
Delete all the water conservation records for the state of Rajasthan in 2017.
DELETE FROM water_conservation WHERE state = 'Rajasthan' AND year = 2017;
gretelai_synthetic_text_to_sql
CREATE TABLE user_actions (user_id INT, user_country VARCHAR(50), action_date DATE, ad_clicks INT);
What is the maximum number of ads clicked by users in Canada on our platform in a single day?
SELECT MAX(ad_clicks) FROM user_actions WHERE user_country = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE FairTradeSuppliers (id INT, supplier_location VARCHAR(50)); INSERT INTO FairTradeSuppliers (id, supplier_location) VALUES (1, 'India'), (2, 'Bangladesh'), (3, 'China'), (4, 'Vietnam'), (5, 'Indonesia'), (6, 'Cambodia'), (7, 'Philippines');
How many fair trade certified suppliers are there in Asia?
SELECT COUNT(*) FROM FairTradeSuppliers WHERE supplier_location LIKE '%%Asia%%';
gretelai_synthetic_text_to_sql
CREATE TABLE policyholders (id INT, state VARCHAR(2));CREATE TABLE claims (id INT, policyholder_id INT, amount DECIMAL(10, 2));
What is the average claim amount for policyholders in Texas?
SELECT AVG(claims.amount) FROM claims JOIN policyholders ON claims.policyholder_id = policyholders.id WHERE policyholders.state = 'TX';
gretelai_synthetic_text_to_sql
CREATE VIEW defense_contracts AS SELECT contractor_name, contract_value FROM military_contracts;
Show the total value of defense contracts awarded to each contractor in the defense_contracts view, ordered by the contract value in descending order.
SELECT contractor_name, SUM(contract_value) AS total_contract_value FROM defense_contracts GROUP BY contractor_name ORDER BY total_contract_value DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Technology_Accessibility (region VARCHAR(255), income VARCHAR(255), score INT); INSERT INTO Technology_Accessibility (region, income, score) VALUES ('Asia', 'Low', 60), ('Asia', 'Medium', 70), ('Asia', 'High', 80), ('Africa', 'Low', 40), ('Africa', 'Medium', 50), ('Africa', 'High', 60);
What is the distribution of technology accessibility scores by region and income level?
SELECT region, income, AVG(score) as avg_score FROM Technology_Accessibility GROUP BY region, income;
gretelai_synthetic_text_to_sql
CREATE TABLE ResearchVessels (Id INT, Country VARCHAR(20), Status VARCHAR(10));
Update the "Status" column in the "ResearchVessels" table, setting the value to 'Active' for all records where "Country" is 'United States'
UPDATE ResearchVessels SET Status = 'Active' WHERE Country = 'United States';
gretelai_synthetic_text_to_sql
CREATE TABLE national_forests.forest_inventory (species VARCHAR(255), num_trees INT);
What is the total number of trees in the forest_inventory table, grouped by species, for the national_forests schema?
SELECT species, SUM(num_trees) FROM national_forests.forest_inventory GROUP BY species;
gretelai_synthetic_text_to_sql
CREATE TABLE hotel_tech_adoption (id INT, type TEXT, adoption BOOLEAN); INSERT INTO hotel_tech_adoption (id, type, adoption) VALUES (1, 'Eco', true), (2, 'Luxury', false), (3, 'Eco', false);
What is the 'hotel tech adoption' percentage for 'eco hotels'?
SELECT 100.0 * COUNT(*) / (SELECT COUNT(*) FROM hotel_tech_adoption WHERE type = 'Eco') FROM hotel_tech_adoption WHERE type = 'Eco' AND adoption = true;
gretelai_synthetic_text_to_sql
CREATE TABLE Trips (Month INT, City VARCHAR(255), Trips INT); INSERT INTO Trips (Month, City, Trips) VALUES (1, 'Los Angeles', 10000); INSERT INTO Trips (Month, City, Trips) VALUES (1, 'New York', 15000); INSERT INTO Trips (Month, City, Trips) VALUES (2, 'Los Angeles', 12000); INSERT INTO Trips (Month, City, Trips) VAL...
How many public transportation trips were taken in major cities during each month of 2021?
SELECT Month, City, SUM(Trips) as TotalTrips FROM Trips GROUP BY Month, City ORDER BY Month, City;
gretelai_synthetic_text_to_sql
CREATE TABLE dishes (dish_id INT, name VARCHAR(255), calories INT, reviews INT, region VARCHAR(255)); INSERT INTO dishes (dish_id, name, calories, reviews, region) VALUES (1, 'Pizza', 300, 7, 'America'), (2, 'Pasta', 400, 3, 'Europe'), (3, 'Salad', 200, 8, 'America'), (4, 'Burger', 500, 10, 'Europe'), (5, 'Sushi', 250,...
Identify the dish with the highest calorie count and more than 5 reviews in the European region.
SELECT name FROM (SELECT name, calories, region, ROW_NUMBER() OVER (PARTITION BY region ORDER BY calories DESC) rn FROM dishes WHERE reviews > 5) t WHERE rn = 1 AND region = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE shipment (id INT PRIMARY KEY, warehouse_id INT, carrier_id INT, pallet_count INT, shipped_date DATE);
Insert a new shipment record with ID 151, warehouse ID 2, carrier ID 4, pallet count 800, and shipped date '2022-02-10'.
INSERT INTO shipment (id, warehouse_id, carrier_id, pallet_count, shipped_date) VALUES (151, 2, 4, 800, '2022-02-10');
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (ArtistID int, Name varchar(100), Gender varchar(10), Country varchar(100));
Find the total value of artworks created by female artists from the USA.
SELECT SUM(Value) FROM ArtWorks
gretelai_synthetic_text_to_sql
CREATE TABLE dispensaries (id INT, name TEXT, state TEXT); CREATE TABLE sales (dispensary_id INT, strain_id INT, quantity INT, price DECIMAL(10,2), sale_date DATE); INSERT INTO dispensaries (id, name, state) VALUES (1, 'Dispensary A', 'New Mexico'); INSERT INTO sales (dispensary_id, strain_id, quantity, price, sale_dat...
Find the average price of cannabis sold by each dispensary in New Mexico in Q2 2022 and sort by average price in ascending order
SELECT d.name, AVG(s.price) as avg_price FROM dispensaries d JOIN sales s ON d.id = s.dispensary_id WHERE s.sale_date BETWEEN '2022-04-01' AND '2022-06-30' GROUP BY d.name ORDER BY avg_price ASC;
gretelai_synthetic_text_to_sql
CREATE TABLE public_transportation (city VARCHAR(50), trips INT); INSERT INTO public_transportation (city, trips) VALUES ('New York', 550000), ('Los Angeles', 320000), ('Chicago', 410000); CREATE TABLE vehicle_sales (manufacturer VARCHAR(50), autonomous BOOLEAN, sales INT); INSERT INTO vehicle_sales (manufacturer, auto...
Show the total number of public transportation trips and autonomous vehicle sales for each manufacturer
SELECT v.manufacturer, SUM(p.trips) as total_trips, SUM(CASE WHEN v.autonomous THEN v.sales ELSE 0 END) as autonomous_sales FROM vehicle_sales v JOIN public_transportation p ON v.manufacturer = p.city GROUP BY v.manufacturer;
gretelai_synthetic_text_to_sql
CREATE TABLE wildlife_habitats (habitat_id INT, state VARCHAR(255)); INSERT INTO wildlife_habitats (habitat_id, state) VALUES (1, 'California'), (2, 'Texas'), (3, 'New York'), (4, 'Florida');
How many wildlife habitats are present in each state of the USA?
SELECT state, COUNT(*) FROM wildlife_habitats GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_offsets (initiative_id INT, initiative_name VARCHAR(255), country VARCHAR(255), start_date DATE, end_date DATE);
List all carbon offset initiatives in India with their respective end dates.
SELECT initiative_name, end_date FROM carbon_offsets WHERE country = 'India';
gretelai_synthetic_text_to_sql
CREATE TABLE production (country VARCHAR(255), element VARCHAR(255), amount INT, year INT); INSERT INTO production (country, element, amount, year) VALUES ('China', 'Neodymium', 140000, 2020), ('Australia', 'Neodymium', 3000, 2020), ('United States', 'Neodymium', 5000, 2020);
What is the total production of Neodymium by country in 2020?
SELECT country, SUM(amount) as total_production FROM production WHERE element = 'Neodymium' AND year = 2020 GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE waste_generation_mumbai (year INT, total_waste INT); INSERT INTO waste_generation_mumbai (year, total_waste) VALUES (2017, 125000), (2019, 145000), (2021, 160000);
What was the waste generation in Mumbai in 2018 and 2020?
SELECT year, total_waste FROM waste_generation_mumbai WHERE year IN (2018, 2020);
gretelai_synthetic_text_to_sql
CREATE TABLE public.witnesses (id SERIAL PRIMARY KEY, name VARCHAR(255), age INT, ethnicity VARCHAR(255), testimony_date DATE); CREATE TABLE public.cases (id SERIAL PRIMARY KEY, witness_id INT, case_number VARCHAR(255), case_date DATE, case_type VARCHAR(255), court_location VARCHAR(255)); CREATE TABLE public.verdicts (...
What is the rank of each witness based on the number of cases they have testified in, partitioned by ethnicity?
SELECT w.ethnicity, w.name, rank() over (partition by w.ethnicity order by count(c.id) desc) as rank FROM public.witnesses w JOIN public.cases c ON w.id = c.witness_id GROUP BY w.ethnicity, w.name;
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_trenches_2 (trench_name TEXT, location TEXT, minimum_depth NUMERIC); INSERT INTO ocean_trenches_2 (trench_name, location, minimum_depth) VALUES ('Mariana Trench', 'Pacific Ocean', '10994'); INSERT INTO ocean_trenches_2 (trench_name, location, minimum_depth) VALUES ('Tonga Trench', 'Pacific Ocean', '1...
What is the minimum depth of all trenches in the Pacific Ocean?
SELECT MIN(minimum_depth) FROM ocean_trenches_2 WHERE location = 'Pacific Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE VolunteerSignUps (SignUpID INT, VolunteerID INT, SignUpDate DATE);
Count the number of volunteers who signed up in the year 2021
SELECT COUNT(*) FROM VolunteerSignUps WHERE YEAR(SignUpDate) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE co2_concentrations (location TEXT, date DATE, concentration REAL); INSERT INTO co2_concentrations (location, date, concentration) VALUES ('Barrow Observatory', '2019-01-01', 410.0), ('Barrow Observatory', '2019-01-02', 412.0);
What is the average CO2 concentration in the atmosphere at the Barrow Observatory in 2019?
SELECT AVG(concentration) FROM co2_concentrations WHERE location = 'Barrow Observatory' AND date BETWEEN '2019-01-01' AND '2019-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE Workouts (Id INT PRIMARY KEY, MemberId INT, Duration INT, Date DATE, City VARCHAR(50)); INSERT INTO Workouts (Id, MemberId, Duration, Date, City) VALUES (1, 1, 60, '2022-01-01', 'Sydney'); INSERT INTO Workouts (Id, MemberId, Duration, Date, City) VALUES (2, 2, 45, '2022-01-02', 'Melbourne');
What is the average workout duration for members from Sydney or Melbourne?
SELECT AVG(Duration) FROM Workouts WHERE City IN ('Sydney', 'Melbourne');
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers (supplier_id INT, supplier_name VARCHAR(50), fair_labor_certified BOOLEAN); INSERT INTO suppliers (supplier_id, supplier_name, fair_labor_certified) VALUES (1, 'Green Vendors', true), (2, 'Eco Supplies', false), (3, 'Sustainable Resources', true);
List all suppliers with fair labor certifications.
SELECT supplier_id, supplier_name FROM suppliers WHERE fair_labor_certified = true;
gretelai_synthetic_text_to_sql
CREATE TABLE military_sales (id INT PRIMARY KEY, region VARCHAR(20), year INT, equipment_name VARCHAR(30), quantity INT, value FLOAT); INSERT INTO military_sales (id, region, year, equipment_name, quantity, value) VALUES (1, 'Middle East', 2024, 'Fighter Jet', 12, 5000000), (2, 'Middle East', 2024, 'Tank', 25, 12000000...
Delete all military equipment sales records for 'Middle East' in the year '2024'
DELETE FROM military_sales WHERE region = 'Middle East' AND year = 2024;
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_subscribers_roaming (subscriber_id INT, roaming_country VARCHAR(255)); INSERT INTO mobile_subscribers_roaming (subscriber_id, roaming_country) VALUES (1, 'Canada'), (2, 'Mexico'), (3, 'Brazil'), (4, 'Argentina'), (5, 'United States'), (6, 'France');
What is the total number of mobile subscribers who have used roaming services in each continent?
SELECT CONTINENT(roaming_country), COUNT(DISTINCT subscriber_id) FROM mobile_subscribers_roaming GROUP BY CONTINENT(roaming_country);
gretelai_synthetic_text_to_sql
CREATE TABLE HPVVaccine (Gender VARCHAR(50), Age INT, Ethnicity VARCHAR(50)); INSERT INTO HPVVaccine (Gender, Age, Ethnicity) VALUES ('Female', 18, 'Indigenous'), ('Female', 19, 'Non-Indigenous'), ('Male', 20, 'Indigenous');
Percentage of Indigenous women aged 18-24 who received the HPV vaccine.
SELECT (COUNT(CASE WHEN Gender = 'Female' AND Age BETWEEN 18 AND 24 AND Ethnicity = 'Indigenous' THEN 1 END) * 100.0 / COUNT(*)) FROM HPVVaccine;
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (id INT PRIMARY KEY, name TEXT, country TEXT, stars INT); INSERT INTO hotels (id, name, country, stars) VALUES (1, 'Hotel Adlon', 'Germany', 5); INSERT INTO hotels (id, name, country, stars) VALUES (2, 'Bellagio', 'USA', 5);
Update the "stars" column for 'Hotel Adlon' in the "hotels" table
UPDATE hotels SET stars = 4 WHERE name = 'Hotel Adlon';
gretelai_synthetic_text_to_sql
CREATE TABLE explainable_ai (record_id INT, algorithm_name TEXT, interpretability_score REAL); INSERT INTO explainable_ai VALUES (1, 'SHAP', 0.85), (2, 'LIME', 0.7), (3, 'Anchors', 0.9);
Find the difference between the highest and lowest interpretability scores in the explainable_ai table.
SELECT MAX(interpretability_score) - MIN(interpretability_score) as interpretability_score_diff FROM explainable_ai;
gretelai_synthetic_text_to_sql
CREATE TABLE orders (id INT, product_id INT, quantity INT, price DECIMAL(5,2), fair_trade_certified BOOLEAN); INSERT INTO orders (id, product_id, quantity, price, fair_trade_certified) VALUES (1, 1, 2, 30.00, true), (2, 2, 1, 60.00, false); CREATE TABLE products (id INT, name VARCHAR(255), material VARCHAR(255), fair_t...
What is the total quantity of fair trade certified products ordered?
SELECT SUM(quantity) FROM orders WHERE fair_trade_certified = true;
gretelai_synthetic_text_to_sql
CREATE TABLE eu_ets (year INTEGER, price DECIMAL); INSERT INTO eu_ets (year, price) VALUES (2016, 5.84); INSERT INTO eu_ets (year, price) VALUES (2017, 7.14); CREATE TABLE california_cap (year INTEGER, price DECIMAL); INSERT INTO california_cap (year, price) VALUES (2016, 13.57); INSERT INTO california_cap (year, price...
Find the average carbon price for the California Cap-and-Trade Program and the European Union Emissions Trading System for the years 2015 and 2016.
SELECT AVG(eu_ets.price) AS avg_eu_price, AVG(california_cap.price) AS avg_california_price FROM eu_ets, california_cap WHERE eu_ets.year IN (2015, 2016) AND california_cap.year IN (2015, 2016);
gretelai_synthetic_text_to_sql
CREATE TABLE Infrastructure (id INT, category VARCHAR(20), cost FLOAT, completed DATE); INSERT INTO Infrastructure (id, category, cost, completed) VALUES (1, 'Transportation', 5000000, '2020-01-01'), (2, 'WaterSupply', 3000000, '2019-01-01'), (3, 'Transportation', 7000000, '2021-01-01'), (4, 'WaterSupply', 1000000, '20...
Find the total cost of bridge projects that have a completion date after 2020-01-01.
SELECT SUM(cost) FROM Infrastructure WHERE category = 'Bridges' AND completed > '2020-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE research_papers (id INT, title VARCHAR(100), publication_year INT, autonomous_driving BOOLEAN); INSERT INTO research_papers (id, title, publication_year, autonomous_driving) VALUES (1, 'Autonomous Driving and AI', 2020, true), (2, 'Hybrid Vehicle Efficiency', 2021, false), (3, 'EV Charging Infrastructure',...
Identify the number of autonomous driving research papers published per year
SELECT publication_year, COUNT(*) FROM research_papers WHERE autonomous_driving = true GROUP BY publication_year;
gretelai_synthetic_text_to_sql
CREATE TABLE DigitalAsset (AssetID INT, AssetName VARCHAR(100), IssuerCompany VARCHAR(100), IssuerLocation VARCHAR(50), AssetType VARCHAR(50)); INSERT INTO DigitalAsset (AssetID, AssetName, IssuerCompany, IssuerLocation, AssetType) VALUES (1, 'Asset1', 'CompanyA', 'USA', 'Security'), (2, 'Asset2', 'CompanyB', 'Canada',...
What are the total number of digital assets issued by companies based in North America, broken down by asset type?
SELECT IssuerLocation, AssetType, COUNT(*) as Total FROM DigitalAsset WHERE IssuerLocation IN ('USA', 'Canada', 'Mexico') GROUP BY IssuerLocation, AssetType;
gretelai_synthetic_text_to_sql
CREATE TABLE tourism_impact (year INT, country TEXT, economic_impact FLOAT); INSERT INTO tourism_impact (year, country, economic_impact) VALUES (2019, 'Costa Rica', 2.1), (2020, 'Costa Rica', 1.8), (2021, 'Costa Rica', 2.0);
How has the local economic impact of tourism in Costa Rica changed over the past 3 years?
SELECT year, economic_impact FROM tourism_impact WHERE country = 'Costa Rica' ORDER BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE CarbonOffsets (city VARCHAR(20), transport_type VARCHAR(20), offset FLOAT); INSERT INTO CarbonOffsets (city, transport_type, offset) VALUES ('CityA', 'Bus', 20.5), ('CityB', 'Train', 30.0), ('CityC', 'Bus', 18.0), ('CityD', 'Train', 25.0);
What is the average carbon offset of public transportation per city?
SELECT city, AVG(offset) FROM CarbonOffsets WHERE transport_type = 'Bus' GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE songs (song_name VARCHAR(255), artist VARCHAR(255), genre VARCHAR(255), release_year INT); INSERT INTO songs (song_name, artist, genre, release_year) VALUES ('Umbrella', 'Rihanna', 'Pop', 2007), ('Disturbia', 'Rihanna', 'Pop', 2008);
Insert a new record for a song by artist 'Rihanna' from genre 'Pop' released in 2022
INSERT INTO songs (song_name, artist, genre, release_year) VALUES ('Lift Me Up', 'Rihanna', 'Pop', 2022);
gretelai_synthetic_text_to_sql
CREATE TABLE sales_history_2(drug varchar(10), year int, revenue int); INSERT INTO sales_history_2(drug, year, revenue) VALUES('DrugJ', 2019, 5000), ('DrugJ', 2020, 6000), ('DrugJ', 2021, 7000);
What were the sales figures for 'DrugJ' in the last 3 years?
SELECT year, revenue FROM sales_history_2 WHERE drug = 'DrugJ' ORDER BY year DESC
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_floors (id INT, ocean VARCHAR(255), deepest_part FLOAT);
What is the minimum depth of the deepest part of each ocean?
SELECT ocean, MIN(deepest_part) FROM ocean_floors GROUP BY ocean;
gretelai_synthetic_text_to_sql
CREATE TABLE Farming_Sites (Site_ID INT, Site_Name TEXT, Location TEXT); INSERT INTO Farming_Sites (Site_ID, Site_Name, Location) VALUES (1, 'Site A', 'Pacific Ocean'), (2, 'Site B', 'Atlantic Ocean'); CREATE TABLE Fish_Stock (Site_ID INT, Fish_Type TEXT, Biomass FLOAT); INSERT INTO Fish_Stock (Site_ID, Fish_Type, Biom...
What is the total biomass of salmon in farming sites located in the Pacific Ocean?
SELECT SUM(Biomass) FROM Fish_Stock WHERE Fish_Type = 'Salmon' AND Location = 'Pacific Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE department (id INT, name TEXT, industry TEXT); INSERT INTO department (id, name, industry) VALUES (1, 'Mining Operations', 'Mining'), (2, 'Environment', 'Mining'), (3, 'Human Resources', 'Mining'); CREATE TABLE incident (id INT, department_id INT, date DATE); INSERT INTO incident (id, department_id, date) ...
How many safety incidents occurred in the mining operations department in the last 6 months?
SELECT department_id, COUNT(*) as incident_count FROM incident WHERE date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) AND CURRENT_DATE GROUP BY department_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Air_Quality_Control (project_id INT, project_name VARCHAR(50), location VARCHAR(50)); INSERT INTO Air_Quality_Control (project_id, project_name, location) VALUES (1, 'Air Pollution Control System', 'Colorado'); INSERT INTO Air_Quality_Control (project_id, project_name, location) VALUES (2, 'Emission Reduct...
How many projects are there in total in the 'Air_Quality_Control' and 'Transportation' tables?
SELECT COUNT(*) FROM Air_Quality_Control UNION SELECT COUNT(*) FROM Transportation;
gretelai_synthetic_text_to_sql
CREATE TABLE programs (program_id INT, program_name TEXT, num_volunteers INT); INSERT INTO programs (program_id, program_name, num_volunteers) VALUES (1, 'Feeding the Hungry', 100), (2, 'Tree Planting', 75);
Find the top 5 programs with the highest number of volunteers in '2022'?
SELECT program_name, num_volunteers FROM (SELECT program_name, COUNT(volunteer_id) AS num_volunteers, ROW_NUMBER() OVER (ORDER BY COUNT(volunteer_id) DESC) rn FROM volunteers GROUP BY program_name) t WHERE rn <= 5;
gretelai_synthetic_text_to_sql
CREATE TABLE game_sessions (session_id INT, player_id INT, game_mode VARCHAR(20), map_id INT); CREATE TABLE maps (map_id INT, map_name VARCHAR(20));
Update the game_mode column in the game_sessions table to 'Capture the Flag' for all sessions on the maps table with the name 'Stadium'
UPDATE game_sessions SET game_mode = 'Capture the Flag' WHERE map_id IN (SELECT map_id FROM maps WHERE map_name = 'Stadium');
gretelai_synthetic_text_to_sql
CREATE TABLE ota_bookings_4 (booking_id INT, ota_name TEXT, region TEXT, booking_amount DECIMAL(10,2), booking_date DATE); INSERT INTO ota_bookings_4 (booking_id, ota_name, region, booking_amount, booking_date) VALUES (1, 'Booking.com', 'APAC', 500.00, '2022-01-01'), (2, 'Expedia', 'APAC', 600.00, '2022-02-15'), (3, 'A...
What is the maximum revenue per OTA booking in the APAC region over the last 6 months?
SELECT MAX(booking_amount) FROM ota_bookings_4 WHERE region = 'APAC' AND booking_date >= DATEADD(month, -6, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE daily_ridership (date DATE, ridership INT); INSERT INTO daily_ridership (date, ridership) VALUES ('2022-01-01', 10000), ('2022-01-02', 11000), ('2022-01-03', 12000), ('2022-01-04', 9000), ('2022-01-05', 8000), ('2022-01-06', 7000), ('2022-01-07', 6000);
How many riders used the transit system each day for the past week?
SELECT date, ridership FROM daily_ridership ORDER BY date DESC LIMIT 7;
gretelai_synthetic_text_to_sql
CREATE TABLE patients (id INT, age INT, country VARCHAR(20)); INSERT INTO patients (id, age, country) VALUES (1, 28, 'UK'), (2, 42, 'Ireland'); CREATE TABLE support_groups (id INT, patient_id INT, group VARCHAR(20)); INSERT INTO support_groups (id, patient_id, group) VALUES (1, 1, 'Depression Support Group'), (2, 2, 'A...
What is the average age of patients who received support groups in the UK?
SELECT AVG(patients.age) FROM patients INNER JOIN support_groups ON patients.id = support_groups.patient_id WHERE support_groups.group LIKE '%Support Group%' AND patients.country = 'UK';
gretelai_synthetic_text_to_sql
CREATE TABLE sustainable_fabrics (id INT PRIMARY KEY, fabric_name TEXT, country_of_origin TEXT); INSERT INTO sustainable_fabrics (id, fabric_name, country_of_origin) VALUES (1, 'organic cotton', 'Brazil'), (2, 'hemp', 'China'), (3, 'recycled polyester', 'USA');
Delete all records in the sustainable_fabrics table that were sourced from country X.
DELETE FROM sustainable_fabrics WHERE country_of_origin = 'country X';
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_projects (id INT, project_name VARCHAR(255), project_type VARCHAR(255), energy_consumption FLOAT);
What is the total energy consumption (in kWh) of renewable energy projects for each type?
SELECT project_type, SUM(energy_consumption) FROM renewable_projects GROUP BY project_type;
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_sequestration (year INT, tree_type VARCHAR(255), region VARCHAR(255), sequestration_rate FLOAT);
insert a new record into the carbon_sequestration table for oak in the region 'West' with a carbon sequestration rate of 3 tons per hectare for the year 2019
INSERT INTO carbon_sequestration (year, tree_type, region, sequestration_rate) VALUES (2019, 'Oak', 'West', 3);
gretelai_synthetic_text_to_sql
CREATE TABLE heritage_revenue(site_id INT, site_name TEXT, year INT, revenue FLOAT); INSERT INTO heritage_revenue(site_id, site_name, year, revenue) VALUES (1, 'Neuschwanstein Castle', 2020, 15000000), (2, 'Brandenburg Gate', 2020, 20000000), (3, 'Neuschwanstein Castle', 2021, 16000000), (4, 'Brandenburg Gate', 2021, 2...
What is the change in revenue for the top 2 cultural heritage sites in Germany between 2020 and 2021?
SELECT site_name, (revenue_2021 - revenue_2020) change_in_revenue FROM (SELECT site_name, revenue AS revenue_2020 FROM heritage_revenue WHERE site_name IN ('Neuschwanstein Castle', 'Brandenburg Gate') AND year = 2020 UNION ALL SELECT site_name, revenue AS revenue_2021 FROM heritage_revenue WHERE site_name IN ('Neuschwa...
gretelai_synthetic_text_to_sql
CREATE TABLE UNESCO_Intangible_Heritage (id INT, country VARCHAR(50), element VARCHAR(100)); INSERT INTO UNESCO_Intangible_Heritage (id, country, element) VALUES (1, 'Japan', 'Noh Theatre'), (2, 'Spain', 'Flamenco'), (3, 'Colombia', 'Cultural space of Palenque de San Basilio');
What are the top 3 countries with the highest number of intangible heritage elements?
SELECT country, COUNT(element) as num_elements, ROW_NUMBER() OVER (ORDER BY COUNT(element) DESC) as rank FROM UNESCO_Intangible_Heritage GROUP BY country HAVING rank <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE epl_matches (match_id INT, team_a TEXT, team_b TEXT, goals_scored_a INT, goals_scored_b INT); INSERT INTO epl_matches (match_id, team_a, team_b, goals_scored_a, goals_scored_b) VALUES (1, 'Manchester City', 'West Ham United', 2, 0), (2, 'Liverpool', 'Fulham', 2, 2);
What is the difference between the most and least goals conceded by each team in the 2022-2023 EPL season?
SELECT team_a, team_b, ABS(goals_scored_a - goals_scored_b) AS difference FROM epl_matches;
gretelai_synthetic_text_to_sql
CREATE TABLE safety_rankings (id INT, vehicle VARCHAR(50), make VARCHAR(50), country VARCHAR(50), score INT); INSERT INTO safety_rankings VALUES (1, 'Model X', 'Tesla', 'USA', 90); INSERT INTO safety_rankings VALUES (2, 'Model 3', 'Tesla', 'USA', 95); INSERT INTO safety_rankings VALUES (3, 'Camry', 'Toyota', 'Japan', 8...
Show vehicle safety testing scores for vehicles manufactured in the USA
SELECT * FROM safety_rankings WHERE country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE research_projects (name VARCHAR(255), location VARCHAR(255), topic VARCHAR(255)); INSERT INTO research_projects (name, location, topic) VALUES ('Project A', 'Mediterranean', 'Ocean Acidification'), ('Project B', 'Atlantic Ocean', 'Coral Reefs');
List all research projects related to ocean acidification in the Mediterranean.
SELECT name FROM research_projects WHERE location = 'Mediterranean' AND topic = 'Ocean Acidification';
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (DonationID INT, DonationDate DATE, DonationAmount FLOAT, ProgramCategory TEXT); INSERT INTO Donations (DonationID, DonationDate, DonationAmount, ProgramCategory) VALUES (1, '2022-01-01', 75.00, 'Education'), (2, '2022-02-14', 125.00, 'Health'), (3, '2022-03-05', 25.00, 'Education');
Which program categories received more than 50% of the total donations?
SELECT ProgramCategory, SUM(DonationAmount) AS TotalDonation, (SUM(DonationAmount) / (SELECT SUM(DonationAmount) FROM Donations)) * 100 AS PercentageOfTotalDonation FROM Donations GROUP BY ProgramCategory HAVING PercentageOfTotalDonation > 50.0;
gretelai_synthetic_text_to_sql
CREATE TABLE donors (id INT, donation_date DATE, donation_amount FLOAT); INSERT INTO donors (id, donation_date, donation_amount) VALUES (1, '2022-04-01', 50.0), (2, '2022-05-15', 100.0), (3, '2022-06-30', 200.0);
What was the total amount donated by first-time donors in Q2 2022?
SELECT SUM(donation_amount) FROM (SELECT donation_amount FROM donors WHERE donation_date BETWEEN '2022-04-01' AND '2022-06-30' GROUP BY donation_amount HAVING COUNT(*) = 1) AS first_time_donors;
gretelai_synthetic_text_to_sql
CREATE TABLE workers (id INT, name VARCHAR(50), industry VARCHAR(50), salary FLOAT, country VARCHAR(50)); INSERT INTO workers (id, name, industry, salary, country) VALUES (1, 'John Doe', 'mining', 60000, 'Canada'); INSERT INTO workers (id, name, industry, salary, country) VALUES (2, 'Jane Smith', 'mining', 65000, 'Cana...
What is the average salary of workers in the 'mining' industry in Canada, grouped by province?
SELECT provinces.name, AVG(workers.salary) FROM workers INNER JOIN provinces ON workers.country = provinces.country WHERE workers.industry = 'mining' GROUP BY provinces.name;
gretelai_synthetic_text_to_sql
CREATE TABLE labor_violations (brand VARCHAR(50), violation_count INT); INSERT INTO labor_violations (brand, violation_count) VALUES ('Brand A', 15), ('Brand B', 5), ('Brand C', 2);
Find the number of labor practice violations for each brand in the ethical fashion database.
SELECT brand, SUM(violation_count) FROM labor_violations GROUP BY brand;
gretelai_synthetic_text_to_sql
CREATE TABLE circular_economy (location VARCHAR(50), year INT, initiatives INT); INSERT INTO circular_economy (location, year, initiatives) VALUES ('Germany', 2021, 1200), ('Germany', 2020, 1100), ('Germany', 2019, 1000), ('Germany', 2018, 900), ('Germany', 2017, 800);
Calculate the circular economy initiatives in Germany over the last 5 years.
SELECT location, year, initiatives FROM circular_economy WHERE location = 'Germany' AND year >= 2017 ORDER BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, country VARCHAR(50), revenue FLOAT, co2_emissions FLOAT);
Find the total revenue and CO2 emissions for products that are made in a specific country
SELECT SUM(revenue) as total_revenue, SUM(co2_emissions) as total_co2_emissions FROM products WHERE country = 'Brazil';
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tours (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), tour_type VARCHAR(255)); INSERT INTO virtual_tours (id, name, location, tour_type) VALUES (1, 'Paris Virtual Tour', 'Paris', 'museum_tour'); INSERT INTO virtual_tours (id, name, location, tour_type) VALUES (2, 'Rome Virtual Tour',...
Update the location of the virtual tour with an id of 1
UPDATE virtual_tours SET location = 'France' WHERE id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE dispensaries (id INT PRIMARY KEY, name VARCHAR(50), address VARCHAR(100), city VARCHAR(50), state VARCHAR(50));
Insert records for new dispensary locations in Portland, Oregon and Seattle, Washington into the dispensaries table.
INSERT INTO dispensaries (name, address, city, state) VALUES ('Rose City Remedies', '1234 SE Division St', 'Portland', 'OR'), ('Emerald City Emporium', '5678 1st Ave', 'Seattle', 'WA');
gretelai_synthetic_text_to_sql
CREATE TABLE emergency_calls (id INT, category VARCHAR(255), city VARCHAR(255)); INSERT INTO emergency_calls (id, category, city) VALUES (1, 'Medical', 'Miami'), (2, 'Fire', 'Miami'), (3, 'Medical', 'Miami');
What is the total number of emergency calls in each category in Miami?
SELECT category, COUNT(id) as total FROM emergency_calls WHERE city = 'Miami' GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists marine_species (id INT PRIMARY KEY, species VARCHAR(50), population INT, habitat VARCHAR(50));
What is the species with the minimum population in the marine_species table?
SELECT species FROM marine_species WHERE population = (SELECT MIN(population) FROM marine_species);
gretelai_synthetic_text_to_sql
CREATE TABLE provider (name TEXT, location TEXT);
What is the total number of healthcare providers in rural areas?
SELECT COUNT(*) FROM provider p1 WHERE p1.location IN (SELECT location FROM provider p2 WHERE p2.location LIKE '%rural%');
gretelai_synthetic_text_to_sql
CREATE TABLE Brands (BrandID INT, BrandName VARCHAR(50), Material VARCHAR(50), Quantity INT);INSERT INTO Brands (BrandID, BrandName, Material, Quantity) VALUES (1, 'BrandA', 'Organic Cotton', 3000), (2, 'BrandB', 'Recycled Polyester', 2500), (1, 'BrandA', 'Hemp', 1500), (3, 'BrandC', 'Organic Cotton', 2000), (2, 'Brand...
Identify the top 5 materials with the highest average quantity used by each brand?
SELECT Material, AVG(Quantity) as AvgQuantity FROM Brands GROUP BY Material ORDER BY AvgQuantity DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE warehouse_stock (product_name VARCHAR(255), stock_level INT);
Insert new record into 'warehouse_stock' table for product 'Organic Cotton Shirt' and stock level '100'
INSERT INTO warehouse_stock (product_name, stock_level) VALUES ('Organic Cotton Shirt', 100);
gretelai_synthetic_text_to_sql
CREATE TABLE customers (id INT, name VARCHAR(255), country VARCHAR(255), assets DECIMAL(10, 2)); INSERT INTO customers (id, name, country, assets) VALUES (1, 'John Doe', 'USA', 150000.00), (2, 'Jane Smith', 'Canada', 200000.00);
What is the total assets value for customers from the United States?
SELECT SUM(assets) FROM customers WHERE country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE JobApplications (ApplicationID INT, ApplicationSource VARCHAR(20)); INSERT INTO JobApplications (ApplicationID, ApplicationSource) VALUES (1, 'LinkedIn'), (2, 'Glassdoor'), (3, 'Indeed'), (4, 'LinkedIn');
What is the total number of job applicants from each source?
SELECT ApplicationSource, COUNT(*) FROM JobApplications GROUP BY ApplicationSource;
gretelai_synthetic_text_to_sql
CREATE TABLE tv_shows (id INT, title VARCHAR(255), release_year INT, viewership INT); INSERT INTO tv_shows (id, title, release_year, viewership) VALUES (1, 'TVShowA', 2021, 6000000); INSERT INTO tv_shows (id, title, release_year, viewership) VALUES (2, 'TVShowB', 2019, 4000000); INSERT INTO tv_shows (id, title, release...
Which TV shows have a release year higher than 2020 and viewership greater than 5 million?
SELECT title, release_year, viewership FROM tv_shows WHERE release_year > 2020 AND viewership > 5000000;
gretelai_synthetic_text_to_sql
CREATE TABLE cities (id INT, name VARCHAR(50), region VARCHAR(50)); CREATE TABLE ticket_sales (id INT, city_id INT, quantity INT, sale_price DECIMAL(10,2), sale_date DATE);
What is the total revenue generated from ticket sales for each city for the last financial year?
SELECT cities.name, SUM(ticket_sales.quantity * ticket_sales.sale_price) as total_revenue FROM cities INNER JOIN ticket_sales ON cities.id = ticket_sales.city_id WHERE ticket_sales.sale_date >= DATE_SUB(DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR), INTERVAL MOD(EXTRACT(MONTH FROM CURRENT_DATE), 12) MONTH) GROUP BY cities.na...
gretelai_synthetic_text_to_sql
CREATE TABLE Genders (GenderID INT, Gender VARCHAR(50)); CREATE TABLE MentalHealthScores (MH_ID INT, GenderID INT, MentalHealthScore INT); INSERT INTO Genders (GenderID, Gender) VALUES (1, 'Female'), (2, 'Male'), (3, 'Non-binary'); INSERT INTO MentalHealthScores (MH_ID, GenderID, MentalHealthScore) VALUES (1, 1, 85), (...
What is the maximum mental health score by gender?
SELECT g.Gender, MAX(mhs.MentalHealthScore) as Max_Score FROM MentalHealthScores mhs JOIN Genders g ON mhs.GenderID = g.GenderID GROUP BY g.Gender;
gretelai_synthetic_text_to_sql
CREATE TABLE agricultural_innovation (innovation_id INT, innovation_name TEXT, region TEXT, investment_amount INT, year INT); INSERT INTO agricultural_innovation (innovation_id, innovation_name, region, investment_amount, year) VALUES (1, 'Drought-Resistant Crops', 'Africa', 2000000, 2020); INSERT INTO agricultural_inn...
What was the minimum investment in agricultural innovation in 'Oceania' up to 2020?
SELECT MIN(investment_amount) FROM agricultural_innovation WHERE year <= 2020 AND region = 'Oceania';
gretelai_synthetic_text_to_sql
CREATE TABLE housing (city VARCHAR(20), type VARCHAR(20), units INT); INSERT INTO housing (city, type, units) VALUES ('Seattle', 'Inclusive', 1500); INSERT INTO housing (city, type, units) VALUES ('Portland', 'Inclusive', 1200);
How many inclusive housing units are available in Seattle?
SELECT SUM(units) FROM housing WHERE city = 'Seattle' AND type = 'Inclusive';
gretelai_synthetic_text_to_sql
CREATE TABLE fleet_management(ship_id INT, ship_name VARCHAR(50), age INT);
Find the average age of ships in the fleet_management table that are older than the average age of all ships in the table.
SELECT AVG(age) AS avg_age_older_than_mean FROM fleet_management FM WHERE age > (SELECT AVG(age) FROM fleet_management);
gretelai_synthetic_text_to_sql
CREATE TABLE astronauts (astronaut_id INT, name VARCHAR(255), gender VARCHAR(255), age INT, country VARCHAR(255), missions INT); INSERT INTO astronauts (astronaut_id, name, gender, age, country, missions) VALUES (1, 'John Glenn', 'Male', 95, 'USA', 3);
Which countries have the oldest and youngest astronauts?
SELECT country, MIN(age) as min_age, MAX(age) as max_age FROM astronauts GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE TechLeaders(country VARCHAR(255), gender VARCHAR(50), position VARCHAR(50));INSERT INTO TechLeaders(country, gender, position) VALUES('USA', 'Female', 'CTO'), ('USA', 'Male', 'CEO'), ('Canada', 'Female', 'VP'), ('Canada', 'Male', 'CTO'), ('India', 'Male', 'CEO'), ('India', 'Female', 'VP'), ('Germany', 'Mal...
Identify the top 3 countries with the highest percentage of women in tech leadership roles.
SELECT country, SUM(CASE WHEN gender = 'Female' THEN 1 ELSE 0 END) / COUNT(*) * 100 AS female_percentage FROM TechLeaders GROUP BY country ORDER BY female_percentage DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_floor_mapping (project_name TEXT, depth REAL, ocean TEXT); INSERT INTO ocean_floor_mapping (project_name, depth, ocean) VALUES ('Project_A', 5500.0, 'Atlantic'), ('Project_B', 6000.0, 'Atlantic'), ('Project_C', 4500.0, 'Indian');
What is the maximum depth of ocean floor mapping projects in the Atlantic?
SELECT MAX(depth) FROM ocean_floor_mapping WHERE ocean = 'Atlantic';
gretelai_synthetic_text_to_sql
CREATE TABLE SpaceMissions (MissionID INT, Commander VARCHAR, LaunchDate DATE);
What are the names and launch dates of all space missions that have had a female commander?
SELECT Commander, LaunchDate FROM SpaceMissions WHERE Commander LIKE '% female%' OR Commander LIKE 'female%';
gretelai_synthetic_text_to_sql
CREATE TABLE digital_divide_programs (id INT, program_name VARCHAR(255), location VARCHAR(255), budget DECIMAL(10,2), year INT); INSERT INTO digital_divide_programs (id, program_name, location, budget, year) VALUES (1, 'Connecting the Unconnected', 'Rural Texas', 10000, 2021), (2, 'Digital Skills for Seniors', 'Urban C...
Update the record of the digital divide program in rural Texas to have a budget of $12000 in 2022.
UPDATE digital_divide_programs SET budget = 12000 WHERE program_name = 'Connecting the Unconnected' AND location = 'Rural Texas' AND year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas (name text, depth integer); INSERT INTO marine_protected_areas (name, depth) VALUES ('Galapagos Islands', 2000), ('Great Barrier Reef', 1000);
What is the minimum and maximum depth of all marine protected areas?
SELECT MIN(depth), MAX(depth) FROM marine_protected_areas;
gretelai_synthetic_text_to_sql
CREATE TABLE gym_memberships (id INT, member_name VARCHAR(50), start_date DATE, end_date DATE, membership_type VARCHAR(50), price DECIMAL(5,2));
What is the average monthly revenue for each membership type in 2022?
SELECT membership_type, AVG(price/((DATEDIFF(end_date, start_date) + 1) * 12)) AS avg_monthly_revenue FROM gym_memberships WHERE start_date BETWEEN '2022-01-01' AND '2022-12-31' GROUP BY membership_type;
gretelai_synthetic_text_to_sql
CREATE TABLE community_education (program_id INT, budget INT, start_date DATE, end_date DATE);
Insert a new record into the 'community_education' table for a program with ID 4, budget 9000, and start and end dates of 2021-01-01 and 2021-12-31
INSERT INTO community_education (program_id, budget, start_date, end_date) VALUES (4, 9000, '2021-01-01', '2021-12-31');
gretelai_synthetic_text_to_sql
CREATE TABLE dental_clinics (id INT, region TEXT, clinic_type TEXT); INSERT INTO dental_clinics (id, region, clinic_type) VALUES (1, 'Northwest', 'Orthodontic Clinic'), (2, 'Northeast', 'Dental Clinic');
What is the total number of dental clinics in the Northeastern region?
SELECT COUNT(*) FROM dental_clinics WHERE region = 'Northeast';
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT, menu_id INT, sale_date DATETIME);
What are the total sales for the month of January 2022 for the 'Sustainable Seafood' category?
SELECT SUM(price) FROM menus INNER JOIN sales ON menus.id = sales.menu_id INNER JOIN (SELECT EXTRACT(MONTH FROM sale_date) AS month, EXTRACT(YEAR FROM sale_date) AS year FROM sales WHERE sale_date BETWEEN '2022-01-01' AND '2022-01-31' GROUP BY 1, 2) AS january_sales ON EXTRACT(MONTH FROM sales.sale_date) = january_sale...
gretelai_synthetic_text_to_sql
CREATE TABLE ElectricVehicles (id INT, make VARCHAR(50), model VARCHAR(50), horsepower INT);
What is the average horsepower of electric vehicles in the automotive schema?
SELECT AVG(horsepower) FROM automotive.ElectricVehicles;
gretelai_synthetic_text_to_sql
CREATE TABLE yearly_drought (year INT, score INT); INSERT INTO yearly_drought (year, score) VALUES (2010, 10), (2011, 8), (2012, 12), (2013, 9), (2014, 11);
What is the maximum drought impact score for each year?
SELECT year, MAX(score) FROM yearly_drought GROUP BY year;
gretelai_synthetic_text_to_sql