context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE menu (menu_id INT, menu_name TEXT, menu_type TEXT, price DECIMAL, daily_sales INT, is_organic BOOLEAN, region TEXT); CREATE VIEW organic_menu AS SELECT * FROM menu WHERE is_organic = TRUE;
What is the total revenue generated from organic menu items in the Midwest region?
SELECT SUM(price * daily_sales) AS total_revenue FROM organic_menu WHERE region = 'Midwest';
gretelai_synthetic_text_to_sql
CREATE TABLE bridges (id INT, name TEXT, region TEXT, resilience_score FLOAT); INSERT INTO bridges (id, name, region, resilience_score) VALUES (1, 'Golden Gate Bridge', 'West Coast', 85.2), (2, 'Brooklyn Bridge', 'East Coast', 76.3), (3, 'Bay Bridge', 'West Coast', 78.1);
Delete all records of bridges with a 'resilience_score' less than 80 in the 'West Coast' region.
DELETE FROM bridges WHERE region = 'West Coast' AND resilience_score < 80;
gretelai_synthetic_text_to_sql
CREATE TABLE sizes (id INT, product_id INT, size VARCHAR(10)); INSERT INTO sizes (id, product_id, size) VALUES (1, 1001, 'XS'), (2, 1001, 'S'), (3, 1001, 'M');
How many sizes does our fashion retailer offer in total?
SELECT COUNT(DISTINCT size) FROM sizes;
gretelai_synthetic_text_to_sql
CREATE TABLE cities (id INT, name VARCHAR(50), state VARCHAR(2), population INT);
Update the 'state' column in the 'cities' table for the city 'San Francisco' to 'CA'
UPDATE cities SET state = 'CA' WHERE name = 'San Francisco';
gretelai_synthetic_text_to_sql
CREATE TABLE songs (id INT PRIMARY KEY, title VARCHAR(255), artist VARCHAR(255), genre VARCHAR(255), added_date DATE);
Insert a new song into the 'songs' table
INSERT INTO songs (id, title, artist, genre, added_date) VALUES (1, 'La Gorce', 'Jacques Greene', 'Electronic', '2022-05-15');
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (species_name TEXT, affected_by_ocean_acidification BOOLEAN, conservation_status_score FLOAT);
What is the minimum conservation status score for all marine species affected by ocean acidification?
SELECT MIN(conservation_status_score) FROM marine_species WHERE affected_by_ocean_acidification = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE heritagesites (name VARCHAR(255), country VARCHAR(255), region VARCHAR(255)); INSERT INTO heritagesites (name, country, region) VALUES ('Taj Mahal', 'India', 'Asia'); INSERT INTO heritagesites (name, country, region) VALUES ('Angkor Wat', 'Cambodia', 'Asia');
What is the total number of heritage sites for each country in Asia?
SELECT country, COUNT(DISTINCT name) as num_sites FROM heritagesites WHERE region = 'Asia' GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE unclos_ratification (id INT, country TEXT, ratified BOOLEAN); INSERT INTO unclos_ratification (id, country, ratified) VALUES (1, 'United States', FALSE), (2, 'Russia', TRUE);
How many coastal countries have ratified the United Nations Convention on the Law of the Sea?
SELECT COUNT(*) FROM unclos_ratification WHERE ratified = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE cases (id INT, case_number VARCHAR(20), case_type VARCHAR(10)); INSERT INTO cases (id, case_number, case_type) VALUES (1, '12345', 'civil'); INSERT INTO cases (id, case_number, case_type) VALUES (2, '54321', 'criminal'); INSERT INTO cases (id, case_number, case_type) VALUES (3, '98765', 'civil');
List all unique case types
SELECT DISTINCT case_type FROM cases;
gretelai_synthetic_text_to_sql
CREATE TABLE cultivators (id INT, name TEXT, state TEXT); INSERT INTO cultivators (id, name, state) VALUES (1, 'Cultivator X', 'Oregon'); INSERT INTO cultivators (id, name, state) VALUES (2, 'Cultivator Y', 'Oregon'); CREATE TABLE strains (cultivator_id INT, name TEXT, year INT, potency INT, sales INT); INSERT INTO strains (cultivator_id, name, year, potency, sales) VALUES (1, 'Strain A', 2021, 25, 500); INSERT INTO strains (cultivator_id, name, year, potency, sales) VALUES (1, 'Strain B', 2021, 23, 700); INSERT INTO strains (cultivator_id, name, year, potency, sales) VALUES (2, 'Strain C', 2021, 28, 800);
What are the total sales and average potency for each strain produced by cultivators in Oregon in 2021?
SELECT s.name as strain_name, c.state as cultivator_state, SUM(s.sales) as total_sales, AVG(s.potency) as average_potency FROM strains s INNER JOIN cultivators c ON s.cultivator_id = c.id WHERE c.state = 'Oregon' AND s.year = 2021 GROUP BY s.name, c.state;
gretelai_synthetic_text_to_sql
CREATE TABLE water_treatment_plant (plant_id INT, state VARCHAR(50), year INT, month INT, water_consumption FLOAT); INSERT INTO water_treatment_plant (plant_id, state, year, month, water_consumption) VALUES (10, 'New York', 2021, 2, 12345.6), (11, 'New York', 2021, 2, 23456.7), (12, 'New York', 2021, 2, 34567.8);
What is the total water consumption by each water treatment plant in the state of New York in the month of February in the year 2021?
SELECT plant_id, SUM(water_consumption) as total_water_consumption FROM water_treatment_plant WHERE state = 'New York' AND year = 2021 AND month = 2 GROUP BY plant_id;
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (id INT, name TEXT, city TEXT, country TEXT, sustainable BOOLEAN, rating FLOAT); INSERT INTO hotels (id, name, city, country, sustainable, rating) VALUES (1, 'Eco Hotel New York', 'New York', 'USA', true, 4.2), (2, 'Green Hotel Los Angeles', 'Los Angeles', 'USA', true, 4.5);
What is the average rating of sustainable hotels in each city in the United States?
SELECT city, AVG(rating) FROM hotels WHERE country = 'USA' AND sustainable = true GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE top_tourist_attractions (country VARCHAR(30), attraction VARCHAR(50), visitors INT, year INT); INSERT INTO top_tourist_attractions (country, attraction, visitors, year) VALUES ('France', 'Eiffel Tower', 7000000, 2020), ('Spain', 'Sagrada Familia', 4500000, 2020), ('Italy', 'Colosseum', 5000000, 2020);
How many tourists visited each European country's top tourist attraction in 2020?
SELECT country, SUM(visitors) as total_visitors FROM top_tourist_attractions WHERE year = 2020 GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists aerospace;CREATE TABLE if not exists aerospace.aircraft (id INT PRIMARY KEY, manufacturer VARCHAR(50), model VARCHAR(50), accidents INT, launch_year INT); INSERT INTO aerospace.aircraft (id, manufacturer, model, accidents, launch_year) VALUES (1, 'Boeing', '737', 3, 2000), (2, 'Boeing', '747', 2, 2001), (3, 'Airbus', 'A320', 6, 2002), (4, 'Boeing', '787', 1, 2010), (5, 'SpaceX', 'Crew Dragon', 0, 2020);
What is the percentage of accidents for each aircraft model in a specific year?
SELECT model, launch_year, (SUM(accidents) OVER (PARTITION BY launch_year) * 100.0 / (SELECT SUM(accidents) FROM aerospace.aircraft WHERE launch_year = 2010)) as accident_percentage FROM aerospace.aircraft WHERE launch_year = 2010;
gretelai_synthetic_text_to_sql
CREATE TABLE inspections (inspection_id INT, restaurant_id INT, inspection_date DATE, violation_count INT);
Insert a new record for a food safety inspection
INSERT INTO inspections (inspection_id, restaurant_id, inspection_date, violation_count) VALUES (123, 456, '2022-03-01', 3);
gretelai_synthetic_text_to_sql
CREATE TABLE Terbium_Supply (id INT, year INT, supplier_id INT, supply_volume INT); CREATE VIEW distinct_suppliers AS SELECT DISTINCT supplier_id FROM Terbium_Supply WHERE country = 'Japan';
How many distinct suppliers provided Terbium to Japan?
SELECT COUNT(*) FROM distinct_suppliers;
gretelai_synthetic_text_to_sql
CREATE VIEW habitat_preservation AS SELECT 'lion' AS animal_name, 250 AS acres_preserved; CREATE TABLE animal_population (id INT, animal_name VARCHAR(50), population INT); INSERT INTO animal_population (id, animal_name, population) VALUES (1, 'tiger', 200), (2, 'elephant', 300), (3, 'giraffe', 150);
What is the combined population of animals that are present in both the 'animal_population' table and the 'habitat_preservation' view?
SELECT animal_name, SUM(population) FROM animal_population WHERE animal_name IN (SELECT animal_name FROM habitat_preservation) GROUP BY animal_name;
gretelai_synthetic_text_to_sql
CREATE TABLE CO2Concentration (location VARCHAR(50), year INT, avg_conc FLOAT); INSERT INTO CO2Concentration (location, year, avg_conc) VALUES ('Svalbard', 2021, 417.2);
What is the average CO2 concentration in the atmosphere in Svalbard in 2021?
SELECT avg_conc FROM CO2Concentration WHERE location = 'Svalbard' AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers (id INT, name TEXT, country TEXT, ethical_practices BOOLEAN); INSERT INTO suppliers (id, name, country, ethical_practices) VALUES (1, 'XYZ Supplies', 'USA', TRUE), (2, 'LMN Supplies', 'Canada', FALSE), (3, 'OPQ Supplies', 'USA', TRUE); CREATE TABLE purchases (id INT, supplier_id INT, company_id INT, ethical_manufacturing BOOLEAN); INSERT INTO purchases (id, supplier_id, company_id, ethical_manufacturing) VALUES (1, 1, 1, TRUE), (2, 2, 1, FALSE), (3, 3, 1, TRUE);
List all suppliers from the United States that provide materials to companies with ethical manufacturing practices.
SELECT s.name FROM suppliers s JOIN purchases p ON s.id = p.supplier_id WHERE s.country = 'USA' AND p.ethical_manufacturing = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE model_safety_scores (score_id INT PRIMARY KEY, model_id INT, score_date DATE, model_type VARCHAR(50), safety_score FLOAT); INSERT INTO model_safety_scores (score_id, model_id, score_date, model_type, safety_score) VALUES (1, 1, '2021-01-01', 'Deep Learning', 0.95), (2, 2, '2021-02-01', 'Tree Based', 0.92), (3, 1, '2021-03-01', 'Deep Learning', 0.98), (4, 3, '2021-04-01', 'Logistic Regression', 0.95), (5, 2, '2021-05-01', 'Tree Based', 0.98);
What is the maximum safety score for each AI model, grouped by model type?
SELECT model_type, MAX(safety_score) FROM model_safety_scores GROUP BY model_type;
gretelai_synthetic_text_to_sql
CREATE TABLE new_fish (id INT, species VARCHAR(255), water_temp FLOAT, date DATE); CREATE TABLE new_species (id INT, species VARCHAR(255), added_date DATE);
Insert records for new fish species that have been added to the aquarium in the past week.
INSERT INTO fish (id, species, water_temp, date) SELECT new_species.id, new_species.species, NULL, new_species.added_date FROM new_species WHERE new_species.added_date >= DATE_TRUNC('week', CURRENT_DATE) - INTERVAL '1 week';
gretelai_synthetic_text_to_sql
CREATE TABLE economic_diversification_efforts (id INT, name TEXT, completion_date DATE, budget FLOAT, country TEXT); INSERT INTO economic_diversification_efforts (id, name, completion_date, budget, country) VALUES (1, 'Project W', '2017-06-30', 35000.0, 'South Africa'); INSERT INTO economic_diversification_efforts (id, name, completion_date, budget, country) VALUES (2, 'Project X', '2017-12-31', 45000.0, 'South Africa');
What is the average budget, in dollars, of economic diversification efforts in South Africa that were completed in 2017?
SELECT AVG(budget) FROM economic_diversification_efforts WHERE YEAR(completion_date) = 2017 AND country = 'South Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE customers(id INT, name VARCHAR(50), age INT, has_mobile_subscription BOOLEAN, data_usage FLOAT);
What is the average monthly data usage for customers in the 18-25 age group with a mobile subscription?
SELECT AVG(data_usage) FROM customers WHERE age BETWEEN 18 AND 25 AND has_mobile_subscription = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE investments (id INT, project_id INT, investor_id INT, investor_location VARCHAR(255)); INSERT INTO investments (id, project_id, investor_id, investor_location) VALUES (1, 101, 301, 'Germany'); INSERT INTO investments (id, project_id, investor_id, investor_location) VALUES (2, 102, 302, 'France');
Which genetic research projects have received funding from investors based in Germany?
SELECT project_id FROM investments WHERE investor_location = 'Germany';
gretelai_synthetic_text_to_sql
CREATE TABLE region (region_id INT, region_name VARCHAR(50)); INSERT INTO region (region_id, region_name) VALUES (1, 'Northeast'), (2, 'Southeast'), (3, 'Midwest'), (4, 'Southwest'), (5, 'West'); CREATE TABLE community_health_workers (worker_id INT, worker_name VARCHAR(50), region_id INT); INSERT INTO community_health_workers (worker_id, worker_name, region_id) VALUES (1, 'Aisha', 1), (2, 'Ben', 3), (3, 'Claudia', 5), (4, 'Doug', 2), (5, 'Elena', 4);
What is the total number of community health workers by region?
SELECT r.region_name, COUNT(chw.worker_id) as total_workers FROM community_health_workers chw JOIN region r ON chw.region_id = r.region_id GROUP BY r.region_name;
gretelai_synthetic_text_to_sql
CREATE TABLE models_france (model_id INT, name VARCHAR(255), country VARCHAR(255), safety_score FLOAT); INSERT INTO models_france (model_id, name, country, safety_score) VALUES (1, 'Model1', 'France', 0.85), (2, 'Model2', 'France', 0.92), (3, 'Model3', 'France', 0.78), (4, 'Model4', 'France', 0.88), (5, 'Model5', 'France', 0.90);
What is the maximum safety score for models from France?
SELECT MAX(safety_score) FROM models_france WHERE country = 'France';
gretelai_synthetic_text_to_sql
CREATE TABLE forests (id INT, name VARCHAR(255), hectares FLOAT, country VARCHAR(255)); INSERT INTO forests (id, name, hectares, country) VALUES (1, 'Amazon Rainforest', 5500000.0, 'Brazil'), (2, 'Daintree Rainforest', 120000.0, 'Australia'), (3, 'Yellowstone', 894000.0, 'USA'), (4, 'Banff National Park', 664000.0, 'Canada'); CREATE TABLE trees (id INT, species VARCHAR(255), height FLOAT, forest_id INT); INSERT INTO trees (id, species, height, forest_id) VALUES (1, 'Brazilian Rosewood', 50.0, 1), (2, 'Southern Silky Oak', 70.0, 2), (3, 'Douglas Fir', 120.0, 3), (4, 'Lodgepole Pine', 40.0, 4); CREATE VIEW tallest_trees AS SELECT forest_id, MAX(height) as max_height FROM trees GROUP BY forest_id;
Find the forests with the tallest trees, but exclude forests with an area smaller than 200,000 hectares?
SELECT forests.name FROM forests INNER JOIN tallest_trees ON forests.id = tallest_trees.forest_id WHERE forests.hectares > 200000;
gretelai_synthetic_text_to_sql
CREATE TABLE donors (id INT, disaster_id INT, amount FLOAT); CREATE TABLE disasters (id INT, name VARCHAR(255));
List the number of unique donors and total amount donated for each disaster response.
SELECT d.name, COUNT(DISTINCT donors.id) as donor_count, SUM(donors.amount) as total_donated FROM disasters d LEFT JOIN donors ON d.id = donors.disaster_id GROUP BY d.id;
gretelai_synthetic_text_to_sql
CREATE TABLE labor_productivity (record_id INT PRIMARY KEY, mine_name VARCHAR(20), region VARCHAR(20), productivity_score INT);
Insert a new record into the "labor_productivity" table with the following data: 'Diamond Depot', 'East Coast', 93
INSERT INTO labor_productivity (mine_name, region, productivity_score) VALUES ('Diamond Depot', 'East Coast', 93);
gretelai_synthetic_text_to_sql
CREATE TABLE PlantBasedMilks (id INT, type VARCHAR(50), water_footprint INT); INSERT INTO PlantBasedMilks (id, type, water_footprint) VALUES (1, 'Almond Milk', 150), (2, 'Soy Milk', 250), (3, 'Oat Milk', 130), (4, 'Rice Milk', 240);
Get the average water footprint for each type of plant-based milk in our database.
SELECT type, AVG(water_footprint) FROM PlantBasedMilks GROUP BY type;
gretelai_synthetic_text_to_sql
CREATE TABLE charging_stations (id INT, country VARCHAR(255), charging_standard VARCHAR(255), quantity INT); INSERT INTO charging_stations (id, country, charging_standard, quantity) VALUES (1, 'India', 'CCS', 500), (2, 'India', 'CHAdeMO', 300);
What is the minimum number of charging stations required for electric vehicles in India?
SELECT MIN(quantity) FROM charging_stations WHERE country = 'India';
gretelai_synthetic_text_to_sql
CREATE TABLE company (id INT, name TEXT, founding_date DATE, industry TEXT, headquarters TEXT, lgbtq_founder BOOLEAN);
What is the total number of companies founded by LGBTQ+ founders in the renewable energy industry?
SELECT COUNT(*) FROM company WHERE lgbtq_founder = TRUE AND industry = 'renewable energy';
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (hotel_id INT, hotel_name TEXT, city TEXT, country TEXT, energy_consumption FLOAT); INSERT INTO hotels (hotel_id, hotel_name, city, country, energy_consumption) VALUES (1, 'Hotel A', 'Rome', 'Italy', 12000.0), (2, 'Hotel B', 'Paris', 'France', 15000.0);
What is the average energy consumption per month for each hotel?
SELECT hotel_name, AVG(energy_consumption) as avg_energy_consumption FROM hotels GROUP BY hotel_name, EXTRACT(MONTH FROM timestamp);
gretelai_synthetic_text_to_sql
CREATE TABLE population (country VARCHAR(50), year INT, population INT);
What is the population trend in 'population' table for China?
SELECT year, AVG(population) as avg_population FROM population WHERE country = 'China' GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists overtime (id INT PRIMARY KEY, worker_id INT, sector VARCHAR(255), overtime_hours INT); INSERT INTO overtime (id, worker_id, sector, overtime_hours) VALUES (1, 201, 'transportation', 5), (2, 202, 'transportation', 10), (3, 203, 'manufacturing', 7);
What is the average weekly overtime hours worked by workers in the 'transportation' sector?
SELECT AVG(overtime_hours) FROM overtime WHERE sector = 'transportation';
gretelai_synthetic_text_to_sql
CREATE TABLE donations (donation_id INT, donor_id INT, donation_amount FLOAT, donation_date DATE); INSERT INTO donations (donation_id, donor_id, donation_amount, donation_date) VALUES (1, 1, 50.00, '2020-01-01'); INSERT INTO donations (donation_id, donor_id, donation_amount, donation_date) VALUES (2, 2, 100.00, '2020-02-03');
What is the average donation amount for each donor in 2020?
SELECT donor_id, AVG(donation_amount) as avg_donation FROM donations WHERE EXTRACT(YEAR FROM donation_date) = 2020 GROUP BY donor_id;
gretelai_synthetic_text_to_sql
CREATE TABLE menu (menu_id INT, menu_item VARCHAR(50), ingredients_sourced_locally BOOLEAN, co2_emissions FLOAT); INSERT INTO menu (menu_id, menu_item, ingredients_sourced_locally, co2_emissions) VALUES (1, 'Cheese Pizza', FALSE, 2.5), (2, 'Margherita Pizza', TRUE, 1.8), (3, 'Veggie Delight', TRUE, 1.9);
Display the menu items and their CO2 emissions for items with local ingredients.
SELECT menu_item, co2_emissions FROM menu WHERE ingredients_sourced_locally = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE researcher (id INT, name VARCHAR(255), gender VARCHAR(10), department_id INT); CREATE TABLE grant_award (id INT, researcher_id INT, amount DECIMAL(10, 2));
What is the total funding awarded to female researchers in the Engineering department?
SELECT SUM(grant_award.amount) FROM grant_award INNER JOIN researcher ON grant_award.researcher_id = researcher.id WHERE researcher.gender = 'Female' AND researcher.department_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE counties (id INT, name VARCHAR(255), state VARCHAR(255)); INSERT INTO counties (id, name, state) VALUES (1, 'Alameda County', 'California'); CREATE TABLE mental_health_providers (id INT, name VARCHAR(255), county_id INT); INSERT INTO mental_health_providers (id, name, county_id) VALUES (1, 'Provider A', 1);
How many mental health providers are there in each county in California?
SELECT c.name, COUNT(m.id) FROM counties c JOIN mental_health_providers m ON c.id = m.county_id WHERE c.state = 'California' GROUP BY c.name;
gretelai_synthetic_text_to_sql
CREATE TABLE vendor_location (vendor_id INT, vendor_region VARCHAR(50)); INSERT INTO vendor_location (vendor_id, vendor_region) VALUES (1, 'European Union'), (2, 'United States'), (3, 'Canada');
What is the maximum price of products in the 'Fair Trade' category sold by vendors in the European Union?
SELECT MAX(price) FROM products JOIN sales ON products.product_id = sales.product_id JOIN vendors ON sales.vendor_id = vendors.vendor_id JOIN vendor_location ON vendors.vendor_id = vendor_location.vendor_id WHERE products.product_category = 'Fair Trade' AND vendor_location.vendor_region = 'European Union';
gretelai_synthetic_text_to_sql
CREATE TABLE BikeTrips (TripID INT, TripDate DATE);
What is the total number of bike trips per month?
SELECT COUNT(TripID), DATEPART(MONTH, TripDate) AS Month FROM BikeTrips GROUP BY DATEPART(MONTH, TripDate);
gretelai_synthetic_text_to_sql
CREATE TABLE food_items (id INT, name VARCHAR(50), category VARCHAR(50)); CREATE TABLE indigenous_food_systems (id INT, food_item_id INT); CREATE TABLE urban_agriculture_programs (id INT, food_item_id INT); INSERT INTO food_items (id, name, category) VALUES (1, 'Quinoa', 'Grains'), (2, 'Amaranth', 'Grains'), (3, 'Kale', 'Vegetables'), (4, 'Lettuce', 'Vegetables'), (5, 'Broccoli', 'Vegetables'); INSERT INTO indigenous_food_systems (id, food_item_id) VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); INSERT INTO urban_agriculture_programs (id, food_item_id) VALUES (1, 3), (2, 4), (3, 5);
Show the food items that are part of indigenous food systems but not urban agriculture programs.
SELECT name FROM food_items f WHERE f.category = 'Grains' AND id NOT IN (SELECT food_item_id FROM urban_agriculture_programs);
gretelai_synthetic_text_to_sql
CREATE TABLE cosmetics.product_certifications (product_id INT, brand VARCHAR(50), is_vegan BOOLEAN, country VARCHAR(50)); INSERT INTO cosmetics.product_certifications (product_id, brand, is_vegan, country) VALUES (1, 'Australis', true, 'Australia'), (2, 'Nude by Nature', false, 'Australia'), (3, 'modelspretty', true, 'Australia'), (4, ' innoxa', true, 'Australia'), (5, 'Ere Perez', true, 'Australia');
Which brand has the most products certified as vegan in Australia?
SELECT brand, SUM(is_vegan) as total_vegan_products FROM cosmetics.product_certifications WHERE country = 'Australia' GROUP BY brand ORDER BY total_vegan_products DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE TransportationBudget (Service VARCHAR(25), Budget INT); INSERT INTO TransportationBudget (Service, Budget) VALUES ('Bus', 3000000), ('Train', 5000000), ('Subway', 4000000);
What is the minimum budget allocated for transportation services?
SELECT MIN(Budget) FROM TransportationBudget;
gretelai_synthetic_text_to_sql
CREATE TABLE lifelong_learning (student_id INT, course_id INT, completion_date DATE); INSERT INTO lifelong_learning VALUES (1, 1001, '2015-01-01'), (1, 1002, '2016-01-01');
What is the lifelong learning progression for a randomly selected student?
SELECT student_id, course_id, LAG(completion_date, 1) OVER (PARTITION BY student_id ORDER BY completion_date) as previous_course_date FROM lifelong_learning WHERE student_id = 1;
gretelai_synthetic_text_to_sql
CREATE SCHEMA AI_Research;CREATE TABLE Safety_Papers (paper_id INT, publication_year INT, citations INT); INSERT INTO AI_Research.Safety_Papers (paper_id, publication_year, citations) VALUES (1, 2016, 20), (2, 2018, 30), (3, 2017, 15);
List AI safety research papers published before 2018 in descending order by the number of citations.
SELECT paper_id, citations FROM AI_Research.Safety_Papers WHERE publication_year < 2018 ORDER BY citations DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE cargo_handling (id INT PRIMARY KEY, cargo_id INT, port VARCHAR(20)); INSERT INTO cargo_handling (id, cargo_id, port) VALUES (1, 101, 'New York');
Delete all cargo records from port 'New York' in table cargo_handling
DELETE FROM cargo_handling WHERE port = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE solar_capacity (country VARCHAR(20), capacity FLOAT); INSERT INTO solar_capacity (country, capacity) VALUES ('Germany', 53.2), ('Germany', 54.1), ('Spain', 42.6), ('Spain', 43.7);
What is the total installed solar capacity in Germany and Spain?
SELECT SUM(capacity) as total_capacity, country FROM solar_capacity GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE events (event_id INT PRIMARY KEY, event_name VARCHAR(100), event_location VARCHAR(100), start_time DATETIME, end_time DATETIME, attendance INT);
Update the attendance for event_id 5001
UPDATE events SET attendance = 350 WHERE event_id = 5001;
gretelai_synthetic_text_to_sql
CREATE TABLE co_ownership (property_id INT, size FLOAT, city VARCHAR(20)); INSERT INTO co_ownership (property_id, size, city) VALUES (1, 1200.0, 'Seattle'), (2, 1500.0, 'NYC');
What is the average size of co-owned properties in Seattle?
SELECT AVG(size) FROM co_ownership WHERE city = 'Seattle';
gretelai_synthetic_text_to_sql
CREATE TABLE user_actions (user_id INT, action_type VARCHAR(50), hobby VARCHAR(50)); INSERT INTO user_actions (user_id, action_type, hobby) VALUES (1, 'clicked_ad', 'hiking'), (2, 'followed_account', 'photography'), (3, 'clicked_ad', 'camping'), (4, 'followed_account', 'yoga'), (5, 'clicked_ad', 'running'), (6, 'followed_account', 'gaming');
What are the unique hobbies of users who have clicked on ads about outdoor activities but have not followed any outdoor-related accounts?
SELECT hobby FROM user_actions WHERE action_type = 'clicked_ad' AND user_id NOT IN (SELECT user_id FROM user_actions WHERE action_type = 'followed_account' AND hobby LIKE '%outdoor%');
gretelai_synthetic_text_to_sql
CREATE TABLE operations (id INT, name TEXT); CREATE TABLE accidents (operation_id INT, year INT, reported BOOLEAN); INSERT INTO operations (id, name) VALUES (1, 'Operation A'), (2, 'Operation B'), (3, 'Operation C'); INSERT INTO accidents (operation_id, year, reported) VALUES (1, 2021, TRUE), (1, 2021, TRUE), (2, 2021, FALSE), (3, 2021, TRUE), (3, 2021, TRUE);
How many accidents were reported for each mining operation in the past year?
SELECT operations.name, COUNT(accidents.id) FROM operations LEFT JOIN accidents ON operations.id = accidents.operation_id AND accidents.year = 2021 GROUP BY operations.id;
gretelai_synthetic_text_to_sql
CREATE TABLE CulturalHeritageSites (site_id INT, site_name TEXT, country TEXT, has_virtual_tour BOOLEAN); INSERT INTO CulturalHeritageSites (site_id, site_name, country, has_virtual_tour) VALUES (1, 'Site A', 'Germany', TRUE), (2, 'Site B', 'Italy', FALSE);
Find the number of cultural heritage sites in Germany and Italy that have a virtual tour available.
SELECT country, COUNT(*) FROM CulturalHeritageSites WHERE country IN ('Germany', 'Italy') AND has_virtual_tour = TRUE GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE cerium_mines (country TEXT, num_mines INT); INSERT INTO cerium_mines (country, num_mines) VALUES ('Canada', 12), ('United States', 15);
Count the number of cerium mines in Canada and the United States.
SELECT SUM(num_mines) FROM cerium_mines WHERE country IN ('Canada', 'United States');
gretelai_synthetic_text_to_sql
CREATE TABLE air_force_discharge_data (airman_id INT, name VARCHAR(50), rank VARCHAR(50), discharge_type VARCHAR(50), discharge_date DATE);
Delete all records of airmen who were dismissed for misconduct from the air_force_discharge_data table
DELETE FROM air_force_discharge_data WHERE rank = 'Airman' AND discharge_type = 'misconduct';
gretelai_synthetic_text_to_sql
CREATE TABLE J_League_Matches (MatchID INT, HomeTeam VARCHAR(50), AwayTeam VARCHAR(50), HomeRuns INT, AwayRuns INT); INSERT INTO J_League_Matches (MatchID, HomeTeam, AwayTeam, HomeRuns, AwayRuns) VALUES (1, 'Kashima Antlers', 'Urawa Red Diamonds', 2, 1);
What is the average number of home runs hit in a single game in the J-League, excluding games with less than 3 home runs hit?
SELECT AVG(HomeRuns + AwayRuns) FROM J_League_Matches WHERE (HomeRuns + AwayRuns) >= 3 GROUP BY (HomeRuns + AwayRuns);
gretelai_synthetic_text_to_sql
CREATE TABLE subway_rides_sydney(ride_date DATE, num_rides INTEGER); INSERT INTO subway_rides_sydney (ride_date, num_rides) VALUES ('2022-01-01', 1200), ('2022-01-02', 1300);
How many subway rides were there per day in Sydney in Q1 2022?
SELECT ride_date, AVG(num_rides) AS avg_daily_rides FROM subway_rides_sydney WHERE ride_date BETWEEN '2022-01-01' AND '2022-03-31' GROUP BY ride_date;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, Name TEXT); CREATE TABLE Donations (DonationID INT, DonorID INT, DonationAmount DECIMAL);
What is the average amount donated per donation for each donor?
SELECT D.Name as DonorName, AVG(DonationAmount) as AvgDonationAmount FROM Donors D INNER JOIN Donations Don ON D.DonorID = Don.DonorID GROUP BY D.DonorID, D.Name;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists cybersecurity_budget (country VARCHAR(50), year INT, budget FLOAT);
What are the top 5 countries with the highest cybersecurity budget in the last 3 years?
SELECT country, AVG(budget) as avg_budget FROM cybersecurity_budget GROUP BY country ORDER BY avg_budget DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE readers (id INT, name VARCHAR(50), age INT, preference VARCHAR(50)); INSERT INTO readers (id, name, age, preference) VALUES (1, 'John Doe', 30, 'technology'), (2, 'Jane Smith', 45, 'sports'), (3, 'Bob Johnson', 28, 'politics'), (4, 'Alice Davis', 34, 'international');
Delete the record of the reader with the ID of 4 if it exists.
DELETE FROM readers WHERE id = 4;
gretelai_synthetic_text_to_sql
CREATE TABLE area (id INT, name VARCHAR(20)); INSERT INTO area (id, name) VALUES (1, 'North'), (2, 'South'), (3, 'East'), (4, 'West'), (5, 'Central'); CREATE TABLE incidents (id INT, area_id INT, incident_type VARCHAR(50), severity INT); INSERT INTO incidents (id, area_id, incident_type, severity) VALUES (1, 5, 'Theft', 3), (2, 3, 'Assault', 4), (3, 1, 'Vandalism', 2), (4, 5, 'Burglary', 4), (5, 2, 'Trespassing', 1);
List all crime incidents with a severity level of 3 in the Central area.
SELECT * FROM incidents WHERE area_id = (SELECT id FROM area WHERE name = 'Central') AND severity = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, PlayerName VARCHAR(50), Game VARCHAR(50), Wins INT); INSERT INTO Players (PlayerID, PlayerName, Game, Wins) VALUES (1, 'Sophia Garcia', 'Virtual Reality Chess Extreme', 35), (2, 'Daniel Kim', 'Rhythm Game 2023', 40), (3, 'Lila Hernandez', 'Racing Simulator 2022', 28), (4, 'Kenji Nguyen', 'Rhythm Game 2023', 45);
What is the average number of wins for players who play "Virtual Reality Chess Extreme" or "Rhythm Game 2023"?
SELECT AVG(Wins) FROM Players WHERE Game IN ('Virtual Reality Chess Extreme', 'Rhythm Game 2023');
gretelai_synthetic_text_to_sql
CREATE TABLE renewables (id INT, name VARCHAR(50), type VARCHAR(50), production FLOAT, created_at TIMESTAMP);
What is the change in monthly energy production for each hydroelectric power plant in the renewables table?
SELECT name, LAG(production, 1) OVER(PARTITION BY name ORDER BY created_at) as prev_month_production, production, production - LAG(production, 1) OVER(PARTITION BY name ORDER BY created_at) as monthly_change FROM renewables WHERE type = 'hydro' ORDER BY name, created_at;
gretelai_synthetic_text_to_sql
CREATE TABLE Player (PlayerID int, PlayerName varchar(50), TeamID int); CREATE TABLE Goal (GoalID int, PlayerID int, Goals int, MatchDate date, TournamentID int); INSERT INTO Player (PlayerID, PlayerName, TeamID) VALUES (1, 'James Rodriguez', 1), (2, 'Radamel Falcao', 1), (3, 'Thomas Muller', 2), (4, 'Miroslav Klose', 2); INSERT INTO Goal (GoalID, PlayerID, Goals, MatchDate, TournamentID) VALUES (1, 1, 2, '2022-06-01', 1), (2, 1, 3, '2022-06-05', 1), (3, 2, 1, '2022-06-01', 1), (4, 2, 2, '2022-06-05', 1), (5, 3, 4, '2022-06-01', 1), (6, 3, 5, '2022-06-05', 1), (7, 4, 2, '2022-06-01', 1), (8, 4, 3, '2022-06-05', 1);
Who is the top scorer for each team in a tournament?
SELECT p.TeamID, p.PlayerName, SUM(g.Goals) AS TotalGoals, ROW_NUMBER() OVER (PARTITION BY p.TeamID ORDER BY SUM(g.Goals) DESC) AS Ranking FROM Player p JOIN Goal g ON p.PlayerID = g.PlayerID WHERE g.TournamentID = 1 GROUP BY p.TeamID, p.PlayerName HAVING Ranking <= 1;
gretelai_synthetic_text_to_sql
CREATE TABLE orders(customer_id INT, items INT); INSERT INTO orders(customer_id, items) VALUES(1, 3), (2, 1), (3, 5), (4, 2);
What is the maximum number of items purchased in a single order for each customer?
SELECT customer_id, MAX(items) FROM orders GROUP BY customer_id;
gretelai_synthetic_text_to_sql
CREATE TABLE gaelic_football_teams (team_id INT, team_name VARCHAR(50), province VARCHAR(50)); INSERT INTO gaelic_football_teams (team_id, team_name, province) VALUES (1, 'Galway', 'Connacht'), (2, 'Mayo', 'Connacht'), (3, 'Roscommon', 'Connacht'); CREATE TABLE gaelic_football_ticket_sales (team_id INT, sale_date DATE, quantity INT, revenue DECIMAL(10,2));
List Gaelic football teams with their average ticket sales revenue per game in the Connacht province.
SELECT gft.team_name, AVG(gfts.revenue/gfts.quantity) as avg_revenue_per_game FROM gaelic_football_ticket_sales gfts JOIN gaelic_football_teams gft ON gfts.team_id = gft.team_id WHERE gft.province = 'Connacht' GROUP BY gft.team_name;
gretelai_synthetic_text_to_sql
CREATE TABLE drug_approval (company VARCHAR(255), country VARCHAR(255), approval_date DATE); INSERT INTO drug_approval (company, country, approval_date) VALUES ('PharmaB Inc.', 'Japan', '2021-03-15');
What are the drug approval dates for PharmaB Inc. in Japan?
SELECT company, approval_date FROM drug_approval WHERE company = 'PharmaB Inc.' AND country = 'Japan';
gretelai_synthetic_text_to_sql
CREATE TABLE economic_diversification (diversification_id INT PRIMARY KEY, diversification_name VARCHAR(100), country VARCHAR(50), region VARCHAR(50), year_introduced INT);
Update the 'rural_development' database's 'economic_diversification' table to include a new 'diversification_type' column with values 'Renewable Energy' and 'Tourism' for 'Europe' records
ALTER TABLE economic_diversification ADD diversification_type VARCHAR(50); UPDATE economic_diversification SET diversification_type = 'Renewable Energy' WHERE country = 'Europe'; UPDATE economic_diversification SET diversification_type = 'Tourism' WHERE country = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE cases (id INT, law_firm TEXT, won BOOLEAN); INSERT INTO cases (id, law_firm, won) VALUES (1, 'jones', TRUE), (2, 'jones', FALSE), (3, 'jones', TRUE);
How many cases were won by the 'jones' law firm?
SELECT COUNT(*) FROM cases WHERE law_firm = 'jones' AND won = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_rates (id INT PRIMARY KEY, location VARCHAR(255), recycling_type VARCHAR(255), rate DECIMAL(5,4), date DATE);
Add new record to recycling_rates table with location 'California', recycling_type 'Plastic', rate 0.20, date '2021-01-01'
INSERT INTO recycling_rates (location, recycling_type, rate, date) VALUES ('California', 'Plastic', 0.20, '2021-01-01');
gretelai_synthetic_text_to_sql
CREATE TABLE daily_streams (date DATE, genre VARCHAR(10), stream_count BIGINT);
Find the difference in average daily streams between weekdays and weekends for the pop genre.
SELECT (AVG(CASE WHEN DAYOFWEEK(date) IN (1,7) THEN stream_count ELSE 0 END) - AVG(CASE WHEN DAYOFWEEK(date) IN (2,3,4,5,6) THEN stream_count ELSE 0 END)) * 1000 AS weekend_vs_weekday_diff FROM daily_streams WHERE genre = 'pop' GROUP BY genre;
gretelai_synthetic_text_to_sql
CREATE TABLE Policy (id INT, name VARCHAR(50), category VARCHAR(50), description TEXT); INSERT INTO Policy (id, name, category, description) VALUES (1, 'Renewable Energy Standard', 'Energy', 'Standard to increase renewable energy production');
Identify evidence-based policy making related to climate change
SELECT Policy.name, Policy.category, Policy.description FROM Policy WHERE Policy.description LIKE '%climate change%' OR Policy.category = 'Climate Change';
gretelai_synthetic_text_to_sql
CREATE TABLE explainable_ai_applications (app_name TEXT, region TEXT, explainability_score FLOAT); INSERT INTO explainable_ai_applications (app_name, region, explainability_score) VALUES ('App13', 'Africa', 0.7), ('App14', 'Africa', 0.6), ('App15', 'Europe', 0.8);
Identify the explainable AI application with the lowest explainability score in Africa.
SELECT app_name, explainability_score FROM explainable_ai_applications WHERE region = 'Africa' ORDER BY explainability_score LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE energy_storage_3 (id INT, energy_type VARCHAR(50), location VARCHAR(50), capacity INT, installation_date DATE); INSERT INTO energy_storage_3 (id, energy_type, location, capacity, installation_date) VALUES (3, 'Lithium-ion', 'Alberta', 5000, '2020-03-01');
Find the minimum energy storage capacity for each energy_type installed in Alberta, Canada between 2020-01-01 and 2020-06-30, excluding energy_types with only one installation record.
SELECT energy_type, MIN(capacity) as min_capacity FROM energy_storage_3 WHERE installation_date BETWEEN '2020-01-01' AND '2020-06-30' AND location = 'Alberta' GROUP BY energy_type HAVING COUNT(*) > 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Visitors (id INT, name VARCHAR(100), country VARCHAR(50), visit_date DATE);
Insert new records for visitors from Australia and New Zealand.
INSERT INTO Visitors (id, name, country, visit_date) VALUES (1, 'Emma Watson', 'Australia', '2021-08-01'), (2, 'Sam Smith', 'New Zealand', '2021-09-01');
gretelai_synthetic_text_to_sql
CREATE TABLE water_conservation_goals (region VARCHAR(50) PRIMARY KEY, goal INT, year INT);
Insert a new record in the 'water_conservation_goals' table with the following data: region = 'Southeast', goal = 5, year = 2023
INSERT INTO water_conservation_goals (region, goal, year) VALUES ('Southeast', 5, 2023);
gretelai_synthetic_text_to_sql
CREATE TABLE movies (id INT, title VARCHAR(50), genre VARCHAR(20));CREATE TABLE characters (id INT, movie_id INT, name VARCHAR(50), gender VARCHAR(20), lines_spoken INT);
What is the total number of words spoken by non-binary characters in the 'Fantasy' genre in the last 3 years?
SELECT genre, SUM(CASE WHEN gender = 'non-binary' THEN lines_spoken ELSE 0 END) AS total_non_binary_lines FROM movies m JOIN characters c ON m.id = c.movie_id WHERE m.genre = 'Fantasy' AND publish_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 3 YEAR) AND CURRENT_DATE GROUP BY genre;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_aquaculture (id INT, name TEXT, region TEXT, water_depth INT); INSERT INTO marine_aquaculture (id, name, region, water_depth) VALUES (1, 'Facility A', 'North Sea', 50), (2, 'Facility B', 'North Sea', 60), (3, 'Facility C', 'South China Sea', 80);
What is the maximum water depth in marine aquaculture facilities in the North Sea?
SELECT MAX(water_depth) FROM marine_aquaculture WHERE region = 'North Sea';
gretelai_synthetic_text_to_sql
CREATE TABLE Countries (CountryID int, CountryName varchar(50)); CREATE TABLE Meals (MealID int, CountryID int, Calories int); INSERT INTO Countries VALUES (1, 'USA'), (2, 'Canada'), (3, 'Mexico'); INSERT INTO Meals VALUES (1, 1, 1000), (2, 1, 1500), (3, 2, 800), (4, 3, 1200);
Which countries have the highest average calorie intake per meal?
SELECT CountryName, AVG(Calories) as AvgCaloriesPerMeal FROM Meals m JOIN Countries c ON m.CountryID = c.CountryID GROUP BY CountryName ORDER BY AvgCaloriesPerMeal DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE crops (id INT PRIMARY KEY, name VARCHAR(50), yield INT, year INT, farmer_id INT, FOREIGN KEY (farmer_id) REFERENCES farmers(id)); INSERT INTO crops (id, name, yield, year, farmer_id) VALUES (3, 'Wheat', 120, 2021, 3);
Which crops were planted in 'Berlin' and in which year?
SELECT c.name, c.year FROM crops c JOIN farmers f ON c.farmer_id = f.id WHERE f.location = 'Berlin';
gretelai_synthetic_text_to_sql
CREATE TABLE CityData (resident_id INT, age INT, gender VARCHAR(10));
What is the average age of female residents in 'CityData' table?
SELECT AVG(age) FROM CityData WHERE gender = 'Female';
gretelai_synthetic_text_to_sql
CREATE TABLE Visitor_Interactions (ID INT, Visitor_ID INT, Start_Time TIMESTAMP, End_Time TIMESTAMP); INSERT INTO Visitor_Interactions (ID, Visitor_ID, Start_Time, End_Time) VALUES (1, 1001, '2022-01-01 10:00:00', '2022-01-01 12:00:00'), (2, 1002, '2022-01-01 14:00:00', '2022-01-01 15:00:00'), (3, 1003, '2022-01-01 16:00:00', '2022-01-01 18:00:00'); CREATE TABLE Exhibits (ID INT, Name VARCHAR(255), Type VARCHAR(255)); INSERT INTO Exhibits (ID, Name, Type) VALUES (1, 'Digital Art Display', 'Digital'), (2, 'Classic Art Exhibit', 'Physical');
What is the total duration (in hours) spent by visitors at the museum's digital exhibits?
SELECT SUM(TIMESTAMPDIFF(HOUR, Start_Time, End_Time)) FROM Visitor_Interactions INNER JOIN Exhibits ON Visitor_Interactions.ID = Exhibits.ID WHERE Type = 'Digital';
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name VARCHAR(255), category VARCHAR(255)); INSERT INTO products (product_id, product_name, category) VALUES (1, 'Phone 1', 'electronics'), (2, 'Laptop 1', 'electronics'); CREATE TABLE users (user_id INT, user_country VARCHAR(255)); INSERT INTO users (user_id, user_country) VALUES (1, 'India'), (2, 'Japan'); CREATE TABLE orders (order_id INT, user_id INT, product_id INT, order_date DATE, revenue DECIMAL(10, 2)); INSERT INTO orders (order_id, user_id, product_id, order_date, revenue) VALUES (1, 1, 1, '2023-01-01', 500), (2, 2, 1, '2023-01-05', 600);
What was the total revenue from users in India and Japan for the 'electronics' product category in Q1 2023?
SELECT SUM(revenue) FROM orders o JOIN products p ON o.product_id = p.product_id JOIN users u ON o.user_id = u.user_id WHERE u.user_country IN ('India', 'Japan') AND p.category = 'electronics' AND o.order_date BETWEEN '2023-01-01' AND '2023-03-31';
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT, city VARCHAR(50), year INT, weight INT); INSERT INTO sales (id, city, year, weight) VALUES (1, 'Los Angeles', 2020, 70000);
What was the total weight of cannabis sold in the city of Los Angeles in the year 2020?
SELECT SUM(weight) FROM sales WHERE city = 'Los Angeles' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE public_transportation (trip_id INT, fare INT, trip_duration INT); INSERT INTO public_transportation (trip_id, fare, trip_duration) VALUES (1, 5, 30), (2, 7, 45), (3, 9, 60), (4, 11, 75);
What is the average fare for public transportation in Melbourne?
SELECT AVG(fare) as avg_fare FROM public_transportation;
gretelai_synthetic_text_to_sql
CREATE TABLE fan_demographics (fan_id INT, fan_name VARCHAR(50), region VARCHAR(50)); INSERT INTO fan_demographics (fan_id, fan_name, region) VALUES (1, 'FanA', 'North America'), (2, 'FanB', 'South America'), (3, 'FanC', 'Asia'), (4, 'FanD', 'Europe');
How many fans are from each region in the fan_demographics table?
SELECT region, COUNT(*) as num_fans FROM fan_demographics GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, Name VARCHAR(50), Department VARCHAR(50), Position VARCHAR(50), Salary FLOAT, HireDate DATE); INSERT INTO Employees (EmployeeID, Name, Department, Position, Salary, HireDate) VALUES (1, 'John Doe', 'IT', 'Developer', 75000.00, '2021-02-14'), (2, 'Jane Smith', 'IT', 'Developer', 80000.00, '2021-05-11'), (3, 'Alice Johnson', 'Marketing', 'Marketing Specialist', 60000.00, '2021-08-01'), (4, 'Bob Brown', 'HR', 'HR Specialist', 65000.00, '2021-11-15');
How many employees were hired in each month of 2021?
SELECT DATE_FORMAT(HireDate, '%Y-%m') AS Month, COUNT(*) FROM Employees WHERE HireDate >= '2021-01-01' AND HireDate < '2022-01-01' GROUP BY Month;
gretelai_synthetic_text_to_sql
CREATE TABLE disability_services (service_id INT, service_name TEXT, category TEXT); INSERT INTO disability_services (service_id, service_name, category) VALUES (1, 'Wheelchair Ramp', 'Accommodation'); INSERT INTO disability_services (service_id, service_name, category) VALUES (2, 'Sign Language Interpreter', 'Accommodation');
Delete all records related to the 'Accommodation' category in the 'disability_services' table.
DELETE FROM disability_services WHERE category = 'Accommodation';
gretelai_synthetic_text_to_sql
CREATE TABLE CommunityHealthWorkers (WorkerID INT, Race VARCHAR(255), Score INT); INSERT INTO CommunityHealthWorkers (WorkerID, Race, Score) VALUES (1, 'Hispanic', 80), (2, 'African American', 85), (3, 'Caucasian', 90);
What is the minimum cultural competency score of community health workers in each race?
SELECT Race, MIN(Score) as MinScore FROM CommunityHealthWorkers GROUP BY Race;
gretelai_synthetic_text_to_sql
CREATE TABLE employees (id INT, name VARCHAR(50), gender VARCHAR(10), department VARCHAR(50)); INSERT INTO employees (id, name, gender, department) VALUES (1, 'John Doe', 'Male', 'Sales'), (2, 'Jane Smith', 'Female', 'Sales'), (3, 'Alice Johnson', 'Female', 'Marketing');
How many female employees are there in the sales department?
SELECT COUNT(*) FROM employees WHERE gender = 'Female' AND department = 'Sales';
gretelai_synthetic_text_to_sql
CREATE TABLE customers (id INT, name TEXT, age INT, country TEXT, assets FLOAT, investment_strategy TEXT); INSERT INTO customers (id, name, age, country, assets, investment_strategy) VALUES (1, 'John Doe', 45, 'USA', 250000.00, 'Conservative'); INSERT INTO customers (id, name, age, country, assets, investment_strategy) VALUES (2, 'Jane Smith', 34, 'Canada', 320000.00, 'Moderate'); INSERT INTO customers (id, name, age, country, assets, investment_strategy) VALUES (3, 'Alice Johnson', 29, 'UK', 450000.00, 'Aggressive'); INSERT INTO customers (id, name, age, country, assets, investment_strategy) VALUES (4, 'Bob Brown', 51, 'UK', 150000.00, 'Conservative'); INSERT INTO customers (id, name, age, country, assets, investment_strategy) VALUES (5, 'Charlie Davis', 48, 'USA', 800000.00, 'Aggressive'); INSERT INTO customers (id, name, age, country, assets, investment_strategy) VALUES (6, 'David Kim', 38, 'Singapore', 520000.00, 'Moderate');
What is the total number of customers and their total assets value for each investment strategy?
SELECT investment_strategy, COUNT(*), SUM(assets) FROM customers GROUP BY investment_strategy;
gretelai_synthetic_text_to_sql
CREATE TABLE drilling_platforms(location VARCHAR(255), platform_type VARCHAR(255), count INT);INSERT INTO drilling_platforms(location, platform_type, count) VALUES('Gulf of Mexico','Offshore',30),('North Sea','Offshore',25),('Baltic Sea','Offshore',10),('Gulf of Guinea','Onshore',15),('South China Sea','Offshore',20);
Identify the number of offshore drilling platforms in the Gulf of Mexico and the North Sea.
SELECT location, SUM(count) AS total_platforms FROM drilling_platforms WHERE platform_type = 'Offshore' AND location IN ('Gulf of Mexico', 'North Sea') GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE manufacturing_sector (id INT, country VARCHAR(50), industry VARCHAR(50), worker_count INT, avg_salary DECIMAL(10, 2), gender VARCHAR(10)); INSERT INTO manufacturing_sector (id, country, industry, worker_count, avg_salary, gender) VALUES (1, 'Mexico', 'Manufacturing', 500, 80000, 'Female'); INSERT INTO manufacturing_sector (id, country, industry, worker_count, avg_salary, gender) VALUES (2, 'Mexico', 'Manufacturing', 700, 85000, 'Male');
What is the average salary of female workers in the manufacturing sector in Mexico?
SELECT AVG(ms.avg_salary) as avg_salary FROM manufacturing_sector ms WHERE ms.country = 'Mexico' AND ms.gender = 'Female';
gretelai_synthetic_text_to_sql
CREATE TABLE treatments (id INT, patient_id INT, condition VARCHAR(50), treatment_date DATE); INSERT INTO treatments (id, patient_id, condition, treatment_date) VALUES (1, 1, 'Depression', '2019-03-05'); INSERT INTO treatments (id, patient_id, condition, treatment_date) VALUES (2, 2, 'Anxiety', '2019-06-12'); INSERT INTO treatments (id, patient_id, condition, treatment_date) VALUES (3, 3, 'Depression', '2019-09-25'); INSERT INTO treatments (id, patient_id, condition, treatment_date) VALUES (4, 4, 'Anxiety', '2019-12-31');
How many patients were treated for 'Anxiety' or 'Depression' per quarter in 2019?
SELECT condition, COUNT(*) as count, DATE_FORMAT(treatment_date, '%Y-%m') as quarter FROM treatments WHERE condition IN ('Anxiety', 'Depression') AND YEAR(treatment_date) = 2019 GROUP BY quarter;
gretelai_synthetic_text_to_sql
CREATE TABLE MakeupProducts(productId INT, productName VARCHAR(100), isCrueltyFree BOOLEAN, saleYear INT, country VARCHAR(50)); INSERT INTO MakeupProducts(productId, productName, isCrueltyFree, saleYear, country) VALUES (1, 'Matte Lipstick', true, 2021, 'UK'), (2, 'Liquid Eyeliner', false, 2020, 'UK');
How many cruelty-free makeup products were sold in the UK in 2021?
SELECT COUNT(*) FROM MakeupProducts WHERE isCrueltyFree = true AND saleYear = 2021 AND country = 'UK';
gretelai_synthetic_text_to_sql
CREATE TABLE community_health_workers (worker_id INT, name VARCHAR(50), cultural_competency_score INT);
List the community health workers and their cultural competency scores.
SELECT worker_id, name, cultural_competency_score FROM community_health_workers;
gretelai_synthetic_text_to_sql
CREATE TABLE forests (id INT, name TEXT, area REAL, country TEXT, category TEXT); INSERT INTO forests (id, name, area, country, category) VALUES (1, 'Kerinci Seblat National Park', 1379100.0, 'Indonesia', 'protected'), (2, 'Bukit Barisan Selatan National Park', 356800.0, 'Indonesia', 'protected');
What is the average total area of protected forests in Indonesia?
SELECT AVG(area) FROM forests WHERE country = 'Indonesia' AND category = 'protected';
gretelai_synthetic_text_to_sql
CREATE TABLE TechInitiatives (InitiativeID INT, InitiativeName TEXT, Country TEXT, Focus TEXT); INSERT INTO TechInitiatives (InitiativeID, InitiativeName, Country, Focus) VALUES (1, 'Initiative A', 'Japan', 'Social Good'); INSERT INTO TechInitiatives (InitiativeID, InitiativeName, Country, Focus) VALUES (2, 'Initiative B', 'South Korea', 'Healthcare'); INSERT INTO TechInitiatives (InitiativeID, InitiativeName, Country, Focus) VALUES (3, 'Initiative C', 'Singapore', 'Social Good');
List all technology initiatives focused on social good in Pacific Asian countries.
SELECT InitiativeName, Country FROM TechInitiatives WHERE Country IN ('Japan', 'South Korea', 'Singapore') AND Focus = 'Social Good';
gretelai_synthetic_text_to_sql
CREATE TABLE SustainableUrbanism (id INT, city VARCHAR(20), size FLOAT);
What is the maximum size of a sustainable urbanism project in the city of Berlin?
SELECT MAX(size) FROM SustainableUrbanism WHERE city = 'Berlin';
gretelai_synthetic_text_to_sql
CREATE TABLE regions (id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255)); INSERT INTO regions (id, name, country) VALUES (1, 'New York', 'USA'), (2, 'Ontario', 'Canada'); CREATE TABLE hospitals (id INT PRIMARY KEY, name VARCHAR(255), region_id INT, type VARCHAR(255)); INSERT INTO hospitals (id, name, region_id, type) VALUES (1, 'Hospital A', 1, 'Public'), (2, 'Hospital B', 1, 'Private');
How many public hospitals are in New York?
SELECT COUNT(*) FROM hospitals WHERE type = 'Public' AND region_id IN (SELECT id FROM regions WHERE name = 'New York');
gretelai_synthetic_text_to_sql