context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE water_usage (sector VARCHAR(20), usage INT); INSERT INTO water_usage (sector, usage) VALUES ('residential', 12000), ('commercial', 15000), ('industrial', 20000);
What is the total water usage in the residential sector?
SELECT usage FROM water_usage WHERE sector = 'residential';
gretelai_synthetic_text_to_sql
CREATE TABLE auto_show (id INT PRIMARY KEY, city VARCHAR(255), start_date DATE, end_date DATE);
Insert a new record into the 'auto_show' table with the following details: 'Detroit', '2023-01-09', '2023-01-23'
INSERT INTO auto_show (city, start_date, end_date) VALUES ('Detroit', '2023-01-09', '2023-01-23');
gretelai_synthetic_text_to_sql
CREATE TABLE RenewableEnergy (id INT, project_name VARCHAR(20), energy_source VARCHAR(20), capacity INT);
Insert a new record into the "RenewableEnergy" table for a new "WindFarm2" project in "Beijing" with a capacity of 7000
INSERT INTO RenewableEnergy (project_name, energy_source, capacity) VALUES ('WindFarm2', 'wind', 7000);
gretelai_synthetic_text_to_sql
CREATE TABLE cargo_fleet (id INT, ship_name VARCHAR(50), type VARCHAR(50), capacity INT); INSERT INTO cargo_fleet (id, ship_name, type, capacity) VALUES (1, 'Aquamarine', 'Container', 5000), (2, 'Bluewhale', 'Bulk', 8000), (3, 'Starfish', 'Tanker', 3000), (4, 'Seahorse', 'Container', 6000), (5, 'Jellyfish', 'Container'...
What is the maximum capacity of a cargo ship in the 'cargo_fleet' table?
SELECT MAX(capacity) FROM cargo_fleet WHERE type = 'Cargo Ship';
gretelai_synthetic_text_to_sql
CREATE TABLE workouts (id INT, user_id INT, type VARCHAR(50), duration INT, date DATE); INSERT INTO workouts (id, user_id, type, duration, date) VALUES (1, 1, 'HIIT', 30, '2022-03-01'), (2, 2, 'Yoga', 60, '2022-02-15'), (3, 1, 'HIIT', 45, '2022-03-10');
Count the number of high-intensity interval training (HIIT) workouts completed by users in the last month.
SELECT COUNT(*) FROM workouts WHERE type = 'HIIT' AND date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE Support_Programs (id INT, participant_id INT, age INT, gender VARCHAR(10)); INSERT INTO Support_Programs (id, participant_id, age, gender) VALUES (1, 1001, 25, 'Female'), (2, 1002, 30, 'Male');
What is the distribution of support program participants by age and gender?
SELECT Support_Programs.age, Support_Programs.gender, COUNT(*) as total FROM Support_Programs GROUP BY Support_Programs.age, Support_Programs.gender;
gretelai_synthetic_text_to_sql
CREATE SCHEMA IF NOT EXISTS sustainable_buildings;CREATE TABLE IF NOT EXISTS sustainable_buildings.green_buildings (id INT, name VARCHAR(50), certification VARCHAR(20), built_up_area INT);INSERT INTO sustainable_buildings.green_buildings (id, name, certification, built_up_area) VALUES (1, 'Green Building A', 'Platinum'...
What is the total built-up area (in square meters) for Green Buildings with a Platinum LEED certification in the 'sustainable_buildings' schema?
SELECT SUM(built_up_area) FROM sustainable_buildings.green_buildings WHERE certification = 'Platinum';
gretelai_synthetic_text_to_sql
CREATE TABLE production(id INT, country VARCHAR(255), material VARCHAR(255), usage INT); INSERT INTO production(id, country, material, usage) VALUES (1, 'China', 'recycled polyester', 800), (2, 'India', 'recycled polyester', 600), (3, 'Bangladesh', 'viscose', 400), (4, 'Vietnam', 'recycled polyester', 700);
Which countries in the 'production' table have a total usage of all materials greater than 1500?
SELECT country FROM production GROUP BY country HAVING SUM(usage) > 1500;
gretelai_synthetic_text_to_sql
CREATE TABLE Astronauts (astronaut_name TEXT, mission_name TEXT, days_in_space INT); INSERT INTO Astronauts (astronaut_name, mission_name, days_in_space) VALUES ('Serena Auñón-Chancellor', 'ISS Expedition 56/57', 197), ('Alexander Gerst', 'ISS Expedition 40/41', 165), ('Reid Wiseman', 'ISS Expedition 40/41', 165), ('Ma...
List all astronauts who have been on the ISS and their total number of days in space.
SELECT astronaut_name, SUM(days_in_space) as total_days_in_space FROM Astronauts WHERE mission_name LIKE '%ISS%' GROUP BY astronaut_name;
gretelai_synthetic_text_to_sql
CREATE TABLE tv_show (id INT, title VARCHAR(100), production_country VARCHAR(50)); INSERT INTO tv_show (id, title, production_country) VALUES (1, 'Breaking Bad', 'United States');
Find the number of TV shows produced in each country and the percentage of total shows.
SELECT production_country, COUNT(*), 100.0 * COUNT(*) / (SELECT COUNT(*) FROM tv_show) AS percentage FROM tv_show GROUP BY production_country;
gretelai_synthetic_text_to_sql
CREATE TABLE smart_city_initiatives (id INT, initiative_name VARCHAR(50), state VARCHAR(50), start_date DATE); INSERT INTO smart_city_initiatives (id, initiative_name, state, start_date) VALUES (1, 'California Smart Grid', 'California', '2015-01-01');
List all smart city initiatives in the state of California, along with their start dates.
SELECT initiative_name, start_date FROM smart_city_initiatives WHERE state = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE user_ratings (user_id INT, movie_title VARCHAR(50), rating INT, rating_date DATE); CREATE TABLE show_views (user_id INT, show_name VARCHAR(50), views_date DATE);
Find the number of users who have rated movies or watched shows in each month of 2019.
SELECT MONTH(rating_date) AS month, COUNT(DISTINCT user_id) FROM user_ratings WHERE YEAR(rating_date) = 2019 GROUP BY month UNION SELECT MONTH(views_date) AS month, COUNT(DISTINCT user_id) FROM show_views WHERE YEAR(views_date) = 2019 GROUP BY month ORDER BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, name TEXT, is_natural BOOLEAN, price DECIMAL, country TEXT); INSERT INTO products (product_id, name, is_natural, price, country) VALUES (1, 'Lipstick', TRUE, 10.99, 'Germany'); INSERT INTO products (product_id, name, is_natural, price, country) VALUES (2, 'Eye Shadow', TRUE, 8.49,...
What is the minimum price of natural cosmetics sold in Germany?
SELECT MIN(price) FROM products WHERE is_natural = TRUE AND country = 'Germany';
gretelai_synthetic_text_to_sql
CREATE TABLE mine_carbon_emissions (mine_id INT, total_carbon_emissions FLOAT); INSERT INTO mine_carbon_emissions (mine_id, total_carbon_emissions) VALUES (1, 5000), (2, 4500), (3, 4000), (4, 3500), (5, 3000);
Calculate the percentage of total carbon emissions by each mine.
SELECT mine_id, total_carbon_emissions, total_carbon_emissions * 100.0 / SUM(total_carbon_emissions) OVER () as carbon_emissions_percentage FROM mine_carbon_emissions;
gretelai_synthetic_text_to_sql
CREATE TABLE military_innovation (innovation_id INT, innovation_name TEXT, innovation_description TEXT, country TEXT, start_date DATE, end_date DATE); INSERT INTO military_innovation (innovation_id, innovation_name, innovation_description, country, start_date, end_date) VALUES (1, 'Stealth Technology', 'Invisible aircr...
Who are the top 3 countries with the highest number of military innovation projects in the last decade?
SELECT military_innovation.country, COUNT(military_innovation.innovation_id) as innovation_count FROM military_innovation WHERE military_innovation.start_date >= DATE_SUB(CURDATE(), INTERVAL 10 YEAR) GROUP BY military_innovation.country ORDER BY innovation_count DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE online_travel_agencies (id INT, hotel_id INT, revenue INT, booking_date DATE); CREATE TABLE hotels (id INT, name TEXT, city TEXT, country TEXT);
What is the average number of online travel agency bookings per day for hotels in Tokyo, Japan?
SELECT AVG(1.0 * COUNT(*)) FROM online_travel_agencies ota INNER JOIN hotels h ON ota.hotel_id = h.id WHERE h.city = 'Tokyo' AND h.country = 'Japan' GROUP BY booking_date;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT, state VARCHAR(50), year INT, strain VARCHAR(50));
How many unique strains were sold in total in the state of Nevada in 2022?
SELECT COUNT(DISTINCT strain) FROM sales WHERE state = 'Nevada' AND year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE trip_segments (segment_id INT, route_id INT, fare DECIMAL(5,2), passenger_count INT); INSERT INTO trip_segments (segment_id, route_id, fare, passenger_count) VALUES (1, 101, 2.50, 1000), (2, 101, 2.00, 1200), (3, 102, 3.00, 800), (4, 103, 1.50, 1500), (5, 104, 4.00, 600), (6, 105, 1.75, 500), (7, 106, 2.25...
What is the average fare per trip segment for the bottom 5 least frequently traveled segments?
SELECT AVG(fare) FROM (SELECT fare, ROW_NUMBER() OVER (ORDER BY passenger_count ASC) rn FROM trip_segments) t WHERE rn <= 5;
gretelai_synthetic_text_to_sql
CREATE TABLE community_development (id INT, country VARCHAR(50), year INT, initiative VARCHAR(50), completed BOOLEAN); INSERT INTO community_development (id, country, year, initiative, completed) VALUES (1, 'Peru', 2018, 'Education', FALSE);
What is the number of community development initiatives in Peru that were not completed in 2018?
SELECT COUNT(*) FROM community_development WHERE country = 'Peru' AND year = 2018 AND completed = FALSE;
gretelai_synthetic_text_to_sql
CREATE TABLE TextileSources (source_id INT, source_country VARCHAR(20), sustainability_rating INT, price DECIMAL(5,2)); INSERT INTO TextileSources VALUES (1, 'India', 5, 12.50), (2, 'Bangladesh', 3, 8.00), (3, 'China', 2, 6.25);
What is the average price of sustainable textiles sourced from India?
SELECT AVG(price) FROM TextileSources WHERE source_country = 'India' AND sustainability_rating >= 4;
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (hotel_id INT, hotel_name TEXT, city TEXT, rating FLOAT, ai_adoption BOOLEAN); INSERT INTO hotels (hotel_id, hotel_name, city, rating, ai_adoption) VALUES (1, 'Hotel A', 'Toronto', 4.5, false), (2, 'Hotel B', 'Montreal', 4.2, true);
What is the average rating of hotels in Canada that have not adopted AI technology?
SELECT AVG(rating) FROM hotels WHERE city = 'Toronto' AND ai_adoption = false;
gretelai_synthetic_text_to_sql
CREATE TABLE military_sales (id INT, year INT, region VARCHAR(50), value FLOAT); INSERT INTO military_sales (id, year, region, value) VALUES (1, 2020, 'North America', 5000000), (2, 2020, 'Europe', 6000000), (3, 2020, 'Asia', 7000000), (4, 2020, 'Africa', 4000000), (5, 2020, 'South America', 3000000);
What is the average value of military equipment sales by region in 2020?
SELECT region, AVG(value) FROM military_sales WHERE year = 2020 GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE shariah_compliant_finance (account_number INT, open_date DATE); INSERT INTO shariah_compliant_finance (account_number, open_date) VALUES (1, '2021-01-01'), (2, '2021-04-01'), (3, '2021-07-01'), (4, '2021-10-01');
How many Shariah-compliant finance accounts were opened in each quarter of 2021?
SELECT DATE_FORMAT(open_date, '%Y-%m') AS quarter, COUNT(*) FROM shariah_compliant_finance WHERE YEAR(open_date) = 2021 GROUP BY quarter;
gretelai_synthetic_text_to_sql
CREATE TABLE cybersecurity_strategies (id INT, title VARCHAR(255), description TEXT, agency VARCHAR(255), date DATE); INSERT INTO cybersecurity_strategies (id, title, description, agency, date) VALUES (1, 'Active Cyber Defense Certainty Act', 'Creates a legal safe harbor for businesses to defend themselves against cybe...
Which cybersecurity strategies were implemented right after the ones introduced by the European Union?
SELECT title, description, agency, date, LEAD(date) OVER (ORDER BY date) as next_date FROM cybersecurity_strategies WHERE agency = 'European Union';
gretelai_synthetic_text_to_sql
CREATE TABLE worker_salary (id INT, sector VARCHAR(20), wage FLOAT); INSERT INTO worker_salary (id, sector, wage) VALUES (1, 'service', 15.25), (2, 'service', 17.50), (3, 'service', 13.00), (4, 'service', 18.00);
What is the total number of workers earning more than the average wage in the 'service' sector?
SELECT COUNT(*) FROM worker_salary WHERE sector = 'service' AND wage > (SELECT AVG(wage) FROM worker_salary WHERE sector = 'service');
gretelai_synthetic_text_to_sql
CREATE TABLE Products (ProductID INT, ProductName VARCHAR(50), Category VARCHAR(50), Price DECIMAL(5,2), Organic BOOLEAN); INSERT INTO Products (ProductID, ProductName, Category, Price, Organic) VALUES (1, 'Aloe Vera Gel', 'Skincare', 12.99, TRUE), (2, 'Vitamin C Serum', 'Skincare', 29.99, FALSE), (3, 'Argan Oil', 'Ski...
What is the average price of organic products in the Skincare category?
SELECT Category, AVG(Price) FROM Products WHERE Category = 'Skincare' AND Organic = TRUE GROUP BY Category;
gretelai_synthetic_text_to_sql
CREATE TABLE EsportsEvents (EventID INT, Country VARCHAR(20), Year INT); INSERT INTO EsportsEvents (EventID, Country, Year) VALUES (1, 'Japan', 2022);
How many esports events were held in Japan in 2022?
SELECT COUNT(*) FROM EsportsEvents WHERE Country = 'Japan' AND Year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE public.inclusive_housing_policies (id SERIAL PRIMARY KEY, policy_name VARCHAR(255), policy_description TEXT, city_name VARCHAR(255), state_name VARCHAR(255));
Insert a new inclusive housing policy into the inclusive_housing_policies table
INSERT INTO public.inclusive_housing_policies (policy_name, policy_description, city_name, state_name) VALUES ('Affordable Housing Act', 'Provides tax incentives for developers building affordable housing units', 'Denver', 'Colorado');
gretelai_synthetic_text_to_sql
CREATE TABLE species (id INT PRIMARY KEY, common_name TEXT, scientific_name TEXT, region TEXT);
Add a new record to the species table for 'Black Spruce' in 'Canada'
INSERT INTO species (id, common_name, scientific_name, region) VALUES (1, 'Black Spruce', 'Picea mariana', 'Canada');
gretelai_synthetic_text_to_sql
CREATE TABLE restaurants (id INT, name VARCHAR(255), type VARCHAR(255), revenue FLOAT, rating INT); INSERT INTO restaurants (id, name, type, revenue, rating) VALUES (1, 'Restaurant A', 'Italian', 5000.00, 3), (2, 'Restaurant B', 'Asian', 8000.00, 5), (3, 'Restaurant C', 'Mexican', 3000.00, 4), (4, 'Restaurant D', 'Ital...
What is the average revenue for restaurants in the 'Italian' category that have a rating of at least 4?
SELECT AVG(revenue) FROM restaurants WHERE type = 'Italian' AND rating >= 4;
gretelai_synthetic_text_to_sql
CREATE TABLE Routes (RouteId INT, OriginWarehouseId INT, DestinationWarehouseId INT, CarrierId INT, Distance INT, DeliveryTime INT); INSERT INTO Routes (RouteId, OriginWarehouseId, DestinationWarehouseId, CarrierId, Distance, DeliveryTime) VALUES (1, 1, 2, 1, 500, 240); INSERT INTO Routes (RouteId, OriginWarehouseId, D...
What is the total distance of packages delivered by DHL?
SELECT SUM(Distance) AS TotalDistance FROM Routes WHERE CarrierId = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE waste_treatment_methods (id INT, name VARCHAR(255), year INT); INSERT INTO waste_treatment_methods (id, name, year) VALUES (1, 'Landfill', 2019), (2, 'Incineration', 2020), (3, 'Recycling', 2020), (4, 'Composting', 2018); CREATE TABLE co2_emissions (treatment_method_id INT, emissions INT, year INT); INSERT...
How can I delete the landfill data for the year 2020 from the co2_emissions table?
DELETE FROM co2_emissions WHERE treatment_method_id = 1 AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE green_buildings (id INT, price FLOAT, city VARCHAR(20)); INSERT INTO green_buildings (id, price, city) VALUES (1, 500000, 'Seattle'), (2, 700000, 'Portland');
What is the average price of green-certified buildings in the city of Seattle?
SELECT AVG(price) FROM green_buildings WHERE city = 'Seattle';
gretelai_synthetic_text_to_sql
CREATE TABLE consumers (consumer_id INT); CREATE TABLE purchases (purchase_id INT, consumer_id INT, supplier_id INT, is_ethical BOOLEAN); INSERT INTO consumers (consumer_id) VALUES (1), (2), (3), (4), (5); INSERT INTO purchases (purchase_id, consumer_id, supplier_id, is_ethical) VALUES (1, 1, 1, TRUE), (2, 1, 2, FALSE)...
How many consumers have made purchases from both ethical and unethical suppliers?
SELECT consumers.consumer_id FROM consumers INNER JOIN purchases purch1 ON consumers.consumer_id = purch1.consumer_id INNER JOIN purchases purch2 ON consumers.consumer_id = purch2.consumer_id WHERE purch1.is_ethical = TRUE AND purch2.is_ethical = FALSE GROUP BY consumers.consumer_id HAVING COUNT(DISTINCT purch1.supplie...
gretelai_synthetic_text_to_sql
CREATE TABLE water_temperature (farm_id INT, water_type VARCHAR(10), year INT, temperature FLOAT); INSERT INTO water_temperature VALUES (1, 'Marine', 2021, 25.5), (2, 'Marine', 2022, 26.0), (3, 'Brackish', 2021, 24.5), (4, 'Freshwater', 2022, 23.0);
What is the maximum water temperature recorded in brackish water farms in the year 2021?
SELECT MAX(temperature) FROM water_temperature WHERE water_type = 'Brackish' AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE socially_responsible_lending (id INT, country VARCHAR(255), loan_amount DECIMAL(10,2));
What is the average loan amount for socially responsible lending in the United Kingdom?
SELECT AVG(loan_amount) FROM socially_responsible_lending WHERE country = 'United Kingdom';
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (hotel_id INT, hotel_name TEXT, country TEXT); INSERT INTO hotels (hotel_id, hotel_name, country) VALUES (1, 'Eco Hotel London', 'United Kingdom'), (2, 'Green Hotel New York', 'United States'), (3, 'Sustainable Hotel Tokyo', 'Japan'); CREATE TABLE bookings (booking_id INT, hotel_id INT, revenue INT)...
What is the total revenue generated by eco-friendly hotels in the United Kingdom and the United States?
SELECT SUM(bookings.revenue) FROM bookings INNER JOIN hotels ON bookings.hotel_id = hotels.hotel_id WHERE hotels.country IN ('United Kingdom', 'United States') AND hotels.hotel_name LIKE '%eco%' OR hotels.hotel_name LIKE '%green%';
gretelai_synthetic_text_to_sql
CREATE TABLE beauty_products_germany (palm_oil_free BOOLEAN, sale_date DATE, sales_quantity INT, unit_price DECIMAL(5,2)); INSERT INTO beauty_products_germany (palm_oil_free, sale_date, sales_quantity, unit_price) VALUES (TRUE, '2022-01-01', 120, 22.99), (FALSE, '2022-01-01', 180, 18.99);
What are the total sales and average sales per transaction for beauty products with a palm oil-free label in Germany?
SELECT SUM(sales_quantity * unit_price) AS total_sales, AVG(sales_quantity) AS avg_sales_per_transaction FROM beauty_products_germany WHERE palm_oil_free = TRUE AND sale_date BETWEEN '2022-01-01' AND '2022-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE threats (threat_type VARCHAR(255), organization VARCHAR(255), threat_date DATE); INSERT INTO threats (threat_type, organization, threat_date) VALUES ('Phishing', 'Org789', '2022-01-01'), ('Malware', 'Org789', '2022-01-05'), ('Ransomware', 'Org789', '2022-01-10'), ('Phishing', 'Org789', '2022-02-01'), ('Phi...
Identify the top 3 most frequent types of threats and their frequency for the organization 'Org789' for the current year?
SELECT threat_type, COUNT(threat_type) as frequency FROM threats WHERE organization = 'Org789' AND threat_date >= DATEADD(year, -1, GETDATE()) GROUP BY threat_type ORDER BY frequency DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE highways (id INT, highway_name VARCHAR(255), location VARCHAR(255), length FLOAT, construction_cost INT); INSERT INTO highways (id, highway_name, location, length, construction_cost) VALUES (1, 'I-70 Expansion', 'Midwest', 32.1, 120000000), (2, 'I-80 Reconstruction', 'Midwest', 45.9, 200000000), (3, 'I-35 ...
Compute the average construction cost per mile for highways in the Midwest, and the total cost for highways constructed since 2015.
SELECT location, AVG(construction_cost / length) AS avg_cost_per_mile, SUM(construction_cost) AS total_cost FROM highways WHERE location = 'Midwest' AND construction_cost > 0 AND length > 0 GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE user_demographics (user_id INT, ethnicity VARCHAR(255), interest VARCHAR(255)); INSERT INTO user_demographics (user_id, ethnicity, interest) VALUES (1, 'Hispanic', 'Politics'), (2, 'African American', 'Sports'), (3, 'Asian', 'Tech');
Determine the distribution of user interests based on their ethnicity.
SELECT ethnicity, interest, COUNT(*) as count FROM user_demographics GROUP BY ethnicity, interest;
gretelai_synthetic_text_to_sql
CREATE TABLE ServiceBudget (Year INT, Service VARCHAR(255), Budget FLOAT); INSERT INTO ServiceBudget (Year, Service, Budget) VALUES (2021, 'Education', 200000), (2021, 'Transportation', 150000), (2021, 'Healthcare', 180000), (2021, 'Public Safety', 250000), (2021, 'Housing', 120000);
What is the total budget allocated for education and transportation services in the year 2021?
SELECT SUM(Budget) FROM ServiceBudget WHERE Year = 2021 AND (Service = 'Education' OR Service = 'Transportation');
gretelai_synthetic_text_to_sql
CREATE TABLE BrandSustainability (brand VARCHAR(30), water_usage DECIMAL(4,2), energy_efficiency DECIMAL(4,2), customer_satisfaction INT); INSERT INTO BrandSustainability VALUES ('EcoFashions', 1.25, 0.80, 4), ('GreenThreads', 1.10, 0.90, 5), ('SustainaClothes', 1.05, 0.70, 3);
Which sustainable fashion brands have a lower energy efficiency score than the industry average (0.75)?
SELECT brand FROM BrandSustainability WHERE energy_efficiency < 0.75;
gretelai_synthetic_text_to_sql
CREATE TABLE cybersecurity_incidents (id INT, incident_date DATE, incident_type VARCHAR(255)); INSERT INTO cybersecurity_incidents (id, incident_date, incident_type) VALUES (3, '2021-04-12', 'Ransomware Attack');
What is the most recent cybersecurity incident reported?
SELECT * FROM cybersecurity_incidents ORDER BY incident_date DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE content_providers (id INT, name VARCHAR(255), location VARCHAR(64), is_indigenous BOOLEAN); CREATE TABLE content (id INT, title VARCHAR(255), duration INT, provider_id INT, PRIMARY KEY (id), FOREIGN KEY (provider_id) REFERENCES content_providers(id)); INSERT INTO content_providers (id, name, location, is_i...
What is the total number of minutes of content produced by indigenous creators in Canada?
SELECT SUM(content.duration) FROM content INNER JOIN content_providers ON content.provider_id = content_providers.id WHERE content_providers.location = 'Canada' AND content_providers.is_indigenous = true;
gretelai_synthetic_text_to_sql
CREATE TABLE employees (id INT, name TEXT, department TEXT, salary FLOAT); INSERT INTO employees (id, name, department, salary) VALUES (1, 'John Doe', 'metalwork', 50000.0), (2, 'Jane Smith', 'textiles', 40000.0), (3, 'Mike Johnson', 'metalwork', 55000.0);
Who are the top 3 employees with the highest salaries in the 'metalwork' department?
SELECT name, salary FROM employees WHERE department = 'metalwork' ORDER BY salary DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE deep_sea_missions (id INT, mission_name TEXT, start_date DATE); INSERT INTO deep_sea_missions (id, mission_name, start_date) VALUES (1, 'Project Nereus', '2008-03-01'); INSERT INTO deep_sea_missions (id, mission_name, start_date) VALUES (2, 'Challenger Deep Expedition', '2012-03-25');
List all deep-sea exploration missions and their start dates.
SELECT mission_name, start_date FROM deep_sea_missions;
gretelai_synthetic_text_to_sql
CREATE TABLE different_cities_visitors (id INT, name TEXT, city TEXT); INSERT INTO different_cities_visitors VALUES (1, 'Mike', 'LA');
Find the number of visitors who attended events in different cities.
SELECT COUNT(DISTINCT different_cities_visitors.name) FROM different_cities_visitors WHERE different_cities_visitors.city IN ('NY', 'LA', 'Chicago');
gretelai_synthetic_text_to_sql
CREATE TABLE cultivation_sites (id INT, state TEXT, site_name TEXT);CREATE TABLE cultivation (id INT, site_id INT, plant_weight DECIMAL, plant_type TEXT, cultivation_date DATE);
What is the total weight of cannabis flowers produced by each cultivation site in Colorado in the last 6 months?
SELECT cs.site_name, SUM(c.plant_weight) as total_weight FROM cultivation_sites cs INNER JOIN cultivation c ON cs.id = c.site_id WHERE cs.state = 'Colorado' AND c.plant_type = 'flowers' AND c.cultivation_date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) GROUP BY cs.site_name;
gretelai_synthetic_text_to_sql
CREATE TABLE ai_fairness (model_name TEXT, region TEXT, fairness_score INTEGER); INSERT INTO ai_fairness (model_name, region, fairness_score) VALUES ('ModelX', 'Europe', 75), ('ModelY', 'Europe', 80), ('ModelZ', 'Asia', 70);
What is the minimum fairness score for AI models in the Europe region?
SELECT MIN(fairness_score) FROM ai_fairness WHERE region = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE interpreter_budget (state VARCHAR(20), budget INT); INSERT INTO interpreter_budget (state, budget) VALUES ('California', 5000); INSERT INTO interpreter_budget (state, budget) VALUES ('Texas', 7000); INSERT INTO interpreter_budget (state, budget) VALUES ('Florida', 8000);
What is the maximum budget allocated for sign language interpreters in each state?
SELECT state, MAX(budget) FROM interpreter_budget GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (hotel_id INT, hotel_name TEXT, country TEXT, revenue FLOAT); INSERT INTO hotels (hotel_id, hotel_name, country, revenue) VALUES (1, 'Hotel A', 'Indonesia', 1000000), (2, 'Hotel B', 'Malaysia', 1200000), (3, 'Hotel C', 'Thailand', 1400000), (4, 'Hotel D', 'Singapore', 1600000);
What is the average revenue generated by hotels in Southeast Asia?
SELECT country, AVG(revenue) as avg_revenue FROM hotels WHERE country IN ('Indonesia', 'Malaysia', 'Thailand', 'Singapore') GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE products (id INT, name VARCHAR(255), category VARCHAR(255), price DECIMAL(5,2), vegan BOOLEAN);
Insert a new record of a vegan lip balm product in the 'natural' category with a price of $4.99.
INSERT INTO products (name, category, price, vegan) VALUES ('Lip Balm', 'natural', 4.99, true);
gretelai_synthetic_text_to_sql
CREATE TABLE ai_ethics (company TEXT, region TEXT, guidelines TEXT); INSERT INTO ai_ethics (company, region, guidelines) VALUES ('Microsoft', 'North America', 'Ethical AI guidelines for AI development'); INSERT INTO ai_ethics (company, region, guidelines) VALUES ('Google', 'Europe', 'AI ethical guidelines for AI usage'...
Update the "guidelines" for the "IBM" record in the "ai_ethics" table to "AI ethical guidelines for AI integration"
UPDATE ai_ethics SET guidelines = 'AI ethical guidelines for AI integration' WHERE company = 'IBM';
gretelai_synthetic_text_to_sql
CREATE TABLE UnderwritingData (PolicyID INT, Team VARCHAR(20), RiskAssessment DECIMAL(5,2), State VARCHAR(20)); INSERT INTO UnderwritingData VALUES (1, 'Global Team', 0.35, 'California'), (2, 'Diverse Team', 0.20, 'California'), (3, 'Global Team', 0.15, 'Texas'), (4, 'Global Team', 0.45, 'New Mexico'), (5, 'Global Team...
What is the average risk assessment for policies in 'New Mexico' and 'Oklahoma' by 'Global' teams?
SELECT Team, AVG(RiskAssessment) FROM UnderwritingData WHERE State IN ('New Mexico', 'Oklahoma') AND Team LIKE 'Global%' GROUP BY Team;
gretelai_synthetic_text_to_sql
CREATE TABLE museums (museum_id INT, country VARCHAR(50), annual_visitors INT); INSERT INTO museums (museum_id, country, annual_visitors) VALUES (1, 'Senegal', 30000), (2, 'Senegal', 40000), (3, 'Nigeria', 50000);
What is the average number of annual visitors to museums in Senegal?
SELECT AVG(m.annual_visitors) FROM museums m WHERE m.country = 'Senegal';
gretelai_synthetic_text_to_sql
CREATE TABLE rehabilitated_animals (id INT, species VARCHAR(255), population INT);
What is the total number of unique species in 'rehabilitated_animals' table?
SELECT species FROM rehabilitated_animals GROUP BY species;
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (id INT, user_id INT, program_id INT, volunteer_date DATE); INSERT INTO Volunteers (id, user_id, program_id, volunteer_date) VALUES (1, 1001, 101, '2021-04-10'); INSERT INTO Volunteers (id, user_id, program_id, volunteer_date) VALUES (2, 1002, 102, '2021-06-15'); INSERT INTO Volunteers (id, user...
How many volunteers engaged in environmental programs in 2021?
SELECT COUNT(*) FROM Volunteers WHERE program_id BETWEEN 101 AND 110 AND volunteer_date >= '2021-01-01' AND volunteer_date < '2022-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE GreenBuildings (id INT, building_name VARCHAR(20), material VARCHAR(20), size INT); INSERT INTO GreenBuildings (id, building_name, material, size) VALUES (1, 'EcoHouse', 'wood', 1500), (2, 'GreenOffice', 'steel', 2000), (3, 'SolarTower', 'concrete', 3000);
Update the "size" of the "EcoHouse" building in the "GreenBuildings" table to 2000
UPDATE GreenBuildings SET size = 2000 WHERE building_name = 'EcoHouse';
gretelai_synthetic_text_to_sql
CREATE TABLE animal_population (animal_id INT, animal_region VARCHAR(255)); INSERT INTO animal_population (animal_id, animal_region) VALUES (1, 'Africa'), (2, 'Asia'), (3, 'South America');
What is the total number of animals in the African habitat preservation initiative?
SELECT COUNT(*) FROM animal_population WHERE animal_region = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE paris_agreement (country TEXT, region TEXT); INSERT INTO paris_agreement (country, region) VALUES ('USA', 'North America'), ('Canada', 'North America'), ('Mexico', 'North America'), ('Brazil', 'South America'), ('Argentina', 'South America'), ('Australia', 'Oceania'), ('New Zealand', 'Oceania'), ('India', ...
How many countries have ratified the Paris Agreement by region?
SELECT region, COUNT(DISTINCT country) FROM paris_agreement GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE production (year INT, element TEXT, volume INT); INSERT INTO production (year, element, volume) VALUES (2015, 'neodymium', 10000), (2016, 'neodymium', 12000), (2017, 'neodymium', 14000), (2018, 'neodymium', 15000), (2015, 'dysprosium', 5000), (2016, 'dysprosium', 6000), (2017, 'dysprosium', 7000), (2018, '...
How many rare earth elements were produced in each year since 2015?
SELECT p.year, COUNT(DISTINCT e.element) AS element_count FROM production p JOIN elements e ON e.element = p.element GROUP BY p.year;
gretelai_synthetic_text_to_sql
CREATE TABLE production_data (element VARCHAR(2), country VARCHAR(15), quantity INT, year INT); INSERT INTO production_data VALUES ('La', 'India', 8000, 2020), ('Ce', 'Brazil', 7000, 2020), ('La', 'India', 9000, 2021), ('Ce', 'Brazil', 8000, 2021), ('La', 'India', 10000, 2022), ('Ce', 'Brazil', 9000, 2022);
What is the total quantity of Lanthanum (La) and Cerium (Ce) produced by each country in the last three years, ordered by year and country?
SELECT country, YEAR(production_data.year) AS year, SUM(quantity) AS total_quantity FROM production_data WHERE element IN ('La', 'Ce') AND production_data.year BETWEEN YEAR(CURRENT_DATE) - 3 AND YEAR(CURRENT_DATE) GROUP BY country, year ORDER BY year, country;
gretelai_synthetic_text_to_sql
CREATE TABLE garments (garment_id INT, recycled BOOLEAN, manufacture_location VARCHAR(255)); INSERT INTO garments (garment_id, recycled, manufacture_location) VALUES (1, TRUE, 'Nigeria'); INSERT INTO garments (garment_id, recycled, manufacture_location) VALUES (2, FALSE, 'Egypt'); INSERT INTO garments (garment_id, recy...
Find the total number of garments manufactured using recycled materials in Africa.
SELECT COUNT(*) FROM garments WHERE recycled = TRUE AND manufacture_location LIKE 'Africa%';
gretelai_synthetic_text_to_sql
CREATE TABLE EmployeeData (EmployeeID int, Race varchar(50)); INSERT INTO EmployeeData (EmployeeID, Race) VALUES (1, 'White'), (2, 'Asian'), (3, 'Hispanic'), (4, 'Black');
What is the percentage of employees who are from underrepresented racial or ethnic groups?
SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM EmployeeData)) AS Percentage FROM EmployeeData WHERE Race IN ('Hispanic', 'Black');
gretelai_synthetic_text_to_sql
CREATE TABLE tourism_stats (country VARCHAR(255), year INT, visitors INT, continent VARCHAR(255)); INSERT INTO tourism_stats (country, year, visitors, continent) VALUES ('Japan', 2020, 12000000, 'Asia'); INSERT INTO tourism_stats (country, year, visitors, continent) VALUES ('Japan', 2021, 15000000, 'Asia');
What is the total number of tourists who visited Japan in 2020 and 2021, grouped by continent?
SELECT continent, SUM(visitors) as total_visitors FROM tourism_stats WHERE country = 'Japan' AND year IN (2020, 2021) GROUP BY continent;
gretelai_synthetic_text_to_sql
CREATE TABLE songs (id INT, title VARCHAR(255), length DECIMAL(5,2), genre_id INT); CREATE TABLE genres (id INT, genre VARCHAR(255)); INSERT INTO genres VALUES (1, 'Rock'); INSERT INTO songs VALUES (1, 'Bohemian Rhapsody', 545, 1);
What is the average length of songs in the 'Rock' genre?
SELECT AVG(s.length) as avg_length FROM songs s JOIN genres g ON s.genre_id = g.id WHERE g.genre = 'Rock';
gretelai_synthetic_text_to_sql
CREATE TABLE SpaceDebris (DebrisID INT, ObjectType VARCHAR(50), IsTrackedBySSN BOOLEAN, LastObservationDate DATETIME);
How many space debris objects are currently being tracked by the Space Surveillance Network (SSN)?
SELECT COUNT(*) FROM SpaceDebris WHERE IsTrackedBySSN = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE Songs (song_id INT, title TEXT, genre TEXT, release_date DATE, price DECIMAL(5,2));
Insert a new pop song released in 2022 into the Songs table
INSERT INTO Songs (song_id, title, genre, release_date, price) VALUES (1001, 'New Pop Song', 'pop', '2022-10-15', 0.99);
gretelai_synthetic_text_to_sql
CREATE TABLE schools (id INT, project_id INT, location VARCHAR(255), construction_date DATE); INSERT INTO schools (id, project_id, location, construction_date) VALUES (1, 3001, 'India', '2019-05-01'); INSERT INTO schools (id, project_id, location, construction_date) VALUES (2, 3002, 'Nepal', '2018-02-01');
Count the number of schools constructed in "Asia" before 2021.
SELECT COUNT(*) FROM schools WHERE location = 'Asia' AND YEAR(construction_date) < 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE suburbs_revenue (revenue int); INSERT INTO suburbs_revenue (revenue) VALUES (5000), (6000), (7000);
What is the total revenue generated from 'Suburbs'?
SELECT SUM(revenue) FROM suburbs_revenue;
gretelai_synthetic_text_to_sql
CREATE TABLE Farmers (id INT PRIMARY KEY, name VARCHAR(50), age INT, country VARCHAR(50)); INSERT INTO Farmers (id, name, age, country) VALUES (1, 'John Doe', 35, 'USA'); INSERT INTO Farmers (id, name, age, country) VALUES (2, 'Jane Smith', 40, 'Canada'); CREATE TABLE Crops (id INT PRIMARY KEY, name VARCHAR(50), growth...
Find the number of farmers who grow crops in the same country as the farmer with the id of 1.
SELECT COUNT(*) FROM Farmers INNER JOIN Crops ON Farmers.id = Crops.farmer_id WHERE Farmers.country = (SELECT country FROM Farmers WHERE id = 1);
gretelai_synthetic_text_to_sql
CREATE TABLE ai_safety_principles (principle_name TEXT, ethical_concerns INT); INSERT INTO ai_safety_principles (principle_name, ethical_concerns) VALUES ('Beneficence', 12), ('Nonmaleficence', 8), ('Autonomy', 15), ('Justice', 10);
How many ethical concerns were raised for each AI safety principle?
SELECT principle_name, ethical_concerns FROM ai_safety_principles;
gretelai_synthetic_text_to_sql
CREATE TABLE state_facts (state VARCHAR(2), capital VARCHAR(50), population INT, area_sq_miles INT);
Update the 'area_sq_miles' column in the 'state_facts' table for the state of 'NY' to 54_556
UPDATE state_facts SET area_sq_miles = 54556 WHERE state = 'NY';
gretelai_synthetic_text_to_sql
CREATE TABLE ethical_ai (tool_id INT, tool_name VARCHAR(50), region VARCHAR(50), rating FLOAT); INSERT INTO ethical_ai (tool_id, tool_name, region, rating) VALUES (1, 'EAITool1', 'APAC', 4.4), (2, 'EAITool2', 'EMEA', 4.7), (3, 'EAITool3', 'AMER', 4.6);
Which ethical AI tools have a higher rating than the average rating of AI tools in their respective regions?
SELECT tool_name, region, rating FROM (SELECT tool_name, region, rating, AVG(rating) OVER (PARTITION BY region) as avg_rating FROM ethical_ai) subquery WHERE rating > avg_rating;
gretelai_synthetic_text_to_sql
CREATE TABLE memberships (id INT, member_country VARCHAR(50), membership_start_date DATE, membership_fee FLOAT); INSERT INTO memberships (id, member_country, membership_start_date, membership_fee) VALUES (1, 'United States', '2022-01-05', 50.0), (2, 'Canada', '2022-01-10', 75.0);
What is the minimum membership fee in each country?
SELECT member_country, MIN(membership_fee) FROM memberships GROUP BY member_country;
gretelai_synthetic_text_to_sql
CREATE TABLE Product_Sales (product_id INT, sale_date DATE, product_category VARCHAR(255), product_color VARCHAR(255)); INSERT INTO Product_Sales (product_id, sale_date, product_category, product_color) VALUES (1, '2021-01-01', 'Tops', 'Red'), (2, '2021-01-15', 'Trousers', 'Blue'), (3, '2021-02-01', 'Tops', 'Black'), (...
Identify the most popular color for each product category in the last year.
SELECT product_category, product_color, COUNT(*) as count FROM Product_Sales WHERE sale_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) AND CURRENT_DATE GROUP BY product_category, product_color ORDER BY count DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name TEXT, region TEXT, num_workforce_programs INT); INSERT INTO companies (id, name, region, num_workforce_programs) VALUES (1, 'Empowerment Enterprises', 'Europe', 3); INSERT INTO companies (id, name, region, num_workforce_programs) VALUES (2, 'Skillset Solutions', 'Europe', 2); INSERT...
What is the maximum number of workforce development programs offered by companies in the 'europe' region?
SELECT MAX(num_workforce_programs) AS max_programs FROM companies WHERE region = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE Spacecraft_Manufacturers (Manufacturer_ID INT, Name VARCHAR(50), Country VARCHAR(50)); CREATE TABLE Satellite_Networks (Network_ID INT, Name VARCHAR(50), Satellite_Count INT, Agency_ID INT);
What are the spacecraft manufacturing countries and the number of satellites in their networks?
SELECT Spacecraft_Manufacturers.Country, SUM(Satellite_Networks.Satellite_Count) FROM Spacecraft_Manufacturers INNER JOIN Satellite_Networks ON Spacecraft_Manufacturers.Country = Satellite_Networks.Location GROUP BY Spacecraft_Manufacturers.Country;
gretelai_synthetic_text_to_sql
CREATE TABLE green_building_projects (project_id INT, project_name VARCHAR(100), country VARCHAR(50), total_budget FLOAT); INSERT INTO green_building_projects (project_id, project_name, country, total_budget) VALUES (1, 'EcoTower', 'Kenya', 20000000), (2, 'SustainableVillage', 'South Africa', 30000000), (3, 'GreenCity'...
List the top 2 green building projects by total budget in Africa in descending order.
SELECT project_name, total_budget FROM (SELECT project_name, total_budget, ROW_NUMBER() OVER (ORDER BY total_budget DESC) rn FROM green_building_projects WHERE country IN ('Kenya', 'South Africa', 'Egypt')) WHERE rn <= 2
gretelai_synthetic_text_to_sql
CREATE TABLE production_yearly (year INT, country VARCHAR(50), production INT); INSERT INTO production_yearly (year, country, production) VALUES (2018, 'China', 60000), (2018, 'USA', 25000), (2018, 'Australia', 15000), (2019, 'China', 70000), (2019, 'USA', 30000), (2019, 'Australia', 18000), (2020, 'China', 105000), (2...
What is the total rare earth element production for the year 2020?
SELECT SUM(production) FROM production_yearly WHERE year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE machine_data (machine_type VARCHAR(50), industry VARCHAR(50), production_rate FLOAT); INSERT INTO machine_data (machine_type, industry, production_rate) VALUES ('Surface Mount Technology Machine', 'Electronics', 150), ('Automated Optical Inspection Machine', 'Electronics', 130), ('Selective Soldering Machi...
Show production rates for machines in the electronics manufacturing industry, ordered from highest to lowest.
SELECT machine_type, production_rate FROM machine_data WHERE industry = 'Electronics' ORDER BY production_rate DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE creators (id INT, followers INT); INSERT INTO creators (id, followers) VALUES (1, 10000), (2, 25000), (3, 15000), (4, 30000), (5, 5000); CREATE TABLE content (creator_id INT, followers INT); INSERT INTO content (creator_id, followers) VALUES (1, 12000), (2, 28000), (3, 16000), (4, 32000), (5, 5500);
Who are the top 5 creators by number of followers, and what is their total number of followers?
SELECT c.id, c.followers + COALESCE(content.followers, 0) AS total_followers FROM creators c LEFT JOIN (SELECT creator_id, SUM(followers) AS followers FROM content GROUP BY creator_id) content ON c.id = content.creator_id ORDER BY total_followers DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE Patients (ID INT, Gender VARCHAR(10), Disease VARCHAR(20), Country VARCHAR(30), Diagnosis_Date DATE); INSERT INTO Patients (ID, Gender, Disease, Country, Diagnosis_Date) VALUES (1, 'Male', 'Dengue Fever', 'India', '2021-01-01');
What is the total number of patients diagnosed with Dengue Fever in India in 2021?
SELECT COUNT(*) FROM Patients WHERE Disease = 'Dengue Fever' AND Country = 'India' AND YEAR(Diagnosis_Date) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE hydro_energy_projects (id INT PRIMARY KEY, project_name VARCHAR(255), state VARCHAR(2), capacity FLOAT, status VARCHAR(50));
Insert a new hydroelectric project 'Rocky Dam' with 350 MW capacity in Washington state
INSERT INTO hydro_energy_projects (project_name, state, capacity, status) VALUES ('Rocky Dam', 'Washington', 350.0, 'Planning');
gretelai_synthetic_text_to_sql
CREATE TABLE Manufacturing_Costs (manufacturer VARCHAR(50), model VARCHAR(50), cost FLOAT); INSERT INTO Manufacturing_Costs (manufacturer, model, cost) VALUES ('Boeing', '787 Dreamliner', 2500000000);
What was the total cost of manufacturing the Boeing 787 Dreamliner?
SELECT cost FROM Manufacturing_Costs WHERE manufacturer = 'Boeing' AND model = '787 Dreamliner';
gretelai_synthetic_text_to_sql
CREATE TABLE rural_innovation (id INT, name VARCHAR(50), location VARCHAR(50));
What are the names and locations of all agricultural innovation projects in the 'rural_innovation' table?
SELECT name, location FROM rural_innovation;
gretelai_synthetic_text_to_sql
CREATE TABLE org_z (campaign_id INT, organization VARCHAR(10), launch_date DATE); INSERT INTO org_z (campaign_id, organization, launch_date) VALUES (5, 'org_z', '2021-01-01'), (6, 'org_z', '2022-01-01');
What is the earliest launch date of campaigns by 'org_z'?
SELECT MIN(launch_date) FROM org_z WHERE organization = 'org_z';
gretelai_synthetic_text_to_sql
CREATE TABLE WaterUsage (Id INT, Location VARCHAR(100), Usage INT, Month INT, Year INT); INSERT INTO WaterUsage (Id, Location, Usage, Month, Year) VALUES (1, 'Mumbai', 1500, 1, 2019); INSERT INTO WaterUsage (Id, Location, Usage, Month, Year) VALUES (2, 'Mumbai', 1700, 2, 2019); INSERT INTO WaterUsage (Id, Location, Usa...
What was the average water usage in Mumbai per month in 2019?
SELECT Location, AVG(Usage) FROM WaterUsage WHERE Location = 'Mumbai' AND Year = 2019 GROUP BY Location, Month;
gretelai_synthetic_text_to_sql
CREATE TABLE student_demographics (student_id INT, gender VARCHAR(10), participation_rate DECIMAL(5,2)); INSERT INTO student_demographics (student_id, gender, participation_rate) VALUES (1, 'Male', 0.85), (2, 'Female', 0.90), (3, 'Non-binary', 0.75), (4, 'Genderqueer', 0.80), (5, 'Female', 0.95);
What is the minimum lifelong learning participation rate for students in each gender category that has more than 10 students?
SELECT gender, MIN(participation_rate) as min_participation_rate FROM student_demographics GROUP BY gender HAVING COUNT(student_id) > 10;
gretelai_synthetic_text_to_sql
CREATE TABLE CommunityDevelopmentInitiatives (InitiativeID INT, ProgramName VARCHAR(255), State VARCHAR(255), Budget DECIMAL(10,2)); INSERT INTO CommunityDevelopmentInitiatives (InitiativeID, ProgramName, State, Budget) VALUES (1, 'Parks Improvement', 'New York', 500000.00), (2, 'Education Grants', 'New York', 800000.0...
What is the average budget allocation per program for community development initiatives in the state of New York?
SELECT AVG(Budget) FROM CommunityDevelopmentInitiatives WHERE State = 'New York' AND ProgramName LIKE '%community development%';
gretelai_synthetic_text_to_sql
CREATE TABLE Properties (id INT, price INT, city TEXT); INSERT INTO Properties (id, price, city) VALUES (1, 600000, 'Portland'), (2, 500000, 'Seattle'), (3, 800000, 'Portland'), (4, 700000, 'Denver');
What is the minimum and maximum property price in the city of Portland?
SELECT MIN(price) AS min_price, MAX(price) AS max_price FROM Properties WHERE city = 'Portland';
gretelai_synthetic_text_to_sql
CREATE TABLE SalesData (drug_name VARCHAR(255), sales_quantity INT, sales_amount DECIMAL(10,2)); INSERT INTO SalesData (drug_name, sales_quantity, sales_amount) VALUES ('DrugA', 150, 25000.00), ('DrugB', 200, 30000.00), ('DrugC', 100, 12000.00);
What are the total sales figures for each drug in the 'SalesData' table, grouped by drug name?
SELECT drug_name, SUM(sales_quantity) as total_sales_quantity, SUM(sales_amount) as total_sales_amount FROM SalesData GROUP BY drug_name;
gretelai_synthetic_text_to_sql
CREATE TABLE Continent (id INT, name VARCHAR(50)); CREATE TABLE Farm (id INT, name VARCHAR(50), country VARCHAR(50), continent_id INT); CREATE TABLE Species (id INT, name VARCHAR(50), scientific_name VARCHAR(50)); CREATE TABLE FarmSpecies (farm_id INT, species_id INT, biomass INT);
Calculate the total biomass of fish for each species, categorized by the farm's continent.
SELECT c.name, s.name, SUM(fs.biomass) FROM Species s JOIN FarmSpecies fs ON s.id = fs.species_id JOIN Farm f ON fs.farm_id = f.id JOIN Continent c ON f.continent_id = c.id GROUP BY c.name, s.name;
gretelai_synthetic_text_to_sql
CREATE TABLE health_equity_metrics (metric_id INT, measurement_date DATE, value INT); INSERT INTO health_equity_metrics (metric_id, measurement_date, value) VALUES (1, '2022-01-01', 70), (2, '2022-02-01', 75), (3, '2022-03-01', 80), (4, '2022-04-01', 85), (5, '2022-05-01', 90);
What is the trend of health equity metrics over time?
SELECT measurement_date, AVG(value) as avg_value FROM health_equity_metrics GROUP BY measurement_date;
gretelai_synthetic_text_to_sql
CREATE TABLE public_schools (id INT, name TEXT, location TEXT, num_students INT, avg_teacher_age FLOAT); INSERT INTO public_schools (id, name, location, num_students, avg_teacher_age) VALUES (1, 'School 1', 'MI', 500, 45.3), (2, 'School 2', 'MI', 600, NULL), (3, 'School 3', 'MI', 700, 47.1);
Delete all public schools from the table that have a missing average teacher age.
DELETE FROM public_schools WHERE avg_teacher_age IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE news_articles (id INT, title VARCHAR(100), section VARCHAR(50), rating INT); INSERT INTO news_articles (id, title, section, rating) VALUES (1, 'Article 1', 'technology', 3), (2, 'Article 2', 'politics', 5), (3, 'Article 3', 'sports', 4); CREATE TABLE news_ratings (article_id INT, rating INT); INSERT INTO n...
What is the lowest-rated news article in the 'technology' section?
SELECT title FROM news_articles WHERE id = (SELECT article_id FROM news_ratings WHERE rating = (SELECT MIN(rating) FROM news_ratings));
gretelai_synthetic_text_to_sql
CREATE TABLE company (id INT, name TEXT, industry TEXT, founding_year INT); INSERT INTO company (id, name, industry, founding_year) VALUES (1, 'GreenTech', 'Renewable Energy', 2005), (2, 'EcoInnovations', 'Renewable Energy', 2012); CREATE TABLE funding (id INT, company_id INT, amount INT); INSERT INTO funding (id, comp...
What is the total funding received by startups in the renewable energy sector that were founded before 2010?
SELECT SUM(funding.amount) FROM funding INNER JOIN company ON funding.company_id = company.id WHERE company.industry = 'Renewable Energy' AND company.founding_year < 2010;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (id INT, name VARCHAR(50), data_usage FLOAT, region VARCHAR(20)); INSERT INTO customers (id, name, data_usage, region) VALUES (1, 'John Doe', 15.0, 'Rural');
What is the average monthly data usage for customers in the 'Rural' region?
SELECT AVG(data_usage) FROM customers WHERE region = 'Rural';
gretelai_synthetic_text_to_sql
CREATE TABLE PlayerMatches (PlayerID int, GameID int, MatchesPlayed int); INSERT INTO PlayerMatches (PlayerID, GameID, MatchesPlayed) VALUES (1, 1, 1200), (2, 1, 800), (3, 1, 500), (4, 1, 700), (5, 1, 1500), (6, 2, 900), (7, 2, 1100), (8, 3, 1300), (9, 3, 1700), (10, 4, 1900);
Who are the players that have played more than 1000 matches in 'GameA'?
SELECT PlayerID FROM PlayerMatches WHERE GameID = 1 AND MatchesPlayed > 1000;
gretelai_synthetic_text_to_sql