context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE eco_hotels (hotel_id INT, country VARCHAR(20), name VARCHAR(50)); INSERT INTO eco_hotels (hotel_id, country, name) VALUES (1, 'India', 'Green Resort'), (2, 'Mexico', 'Eco Retreat'), (3, 'Nepal', 'Sustainable Suites'); CREATE TABLE cultural_sites (site_id INT, country VARCHAR(20), type VARCHAR(20)); INSERT INTO cultural_sites (site_id, country, type) VALUES (1, 'India', 'heritage'), (2, 'Mexico', 'heritage'), (3, 'Nepal', 'heritage'); CREATE TABLE virtual_tours (tour_id INT, country VARCHAR(20), type VARCHAR(20)); INSERT INTO virtual_tours (tour_id, country, type) VALUES (1, 'India', 'virtual'), (2, 'Mexico', 'virtual'); CREATE TABLE museums (museum_id INT, country VARCHAR(20), type VARCHAR(20)); INSERT INTO museums (museum_id, country, type) VALUES (1, 'India', 'museum'), (2, 'Mexico', 'museum');
|
List the names of countries that have both eco-friendly hotels and cultural heritage sites, but no virtual tours or museums.
|
(SELECT country FROM eco_hotels WHERE name IS NOT NULL) INTERSECT (SELECT country FROM cultural_sites WHERE type = 'heritage') EXCEPT (SELECT country FROM (SELECT * FROM virtual_tours WHERE type = 'virtual' UNION ALL SELECT * FROM museums WHERE type = 'museum') AS combined_data);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE fish_stock (id INT, species VARCHAR, biomass FLOAT, country VARCHAR); INSERT INTO fish_stock (id, species, biomass, country) VALUES (1, 'Tilapia', 500.0, 'Indonesia'), (2, 'Salmon', 800.0, 'Norway'), (3, 'Trout', 300.0, 'New Zealand'), (4, 'Bass', 700.0, 'USA'), (5, 'Tilapia', 600.0, 'Thailand');
|
What is the minimum biomass of fish for each species in the Asia-Pacific region?
|
SELECT species, MIN(biomass) FROM fish_stock WHERE country IN ('Indonesia', 'Thailand', 'New Zealand') GROUP BY species;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE authors_articles (author_id INT, article_id INT); INSERT INTO authors_articles (author_id, article_id) VALUES (1, 1), (1, 2), (2, 3);CREATE TABLE authors (id INT, name VARCHAR(50)); INSERT INTO authors (id, name) VALUES (1, 'Alice'), (2, 'Bob');
|
What is the name of the author who has published the most articles?
|
SELECT authors.name FROM authors JOIN (SELECT author_id, COUNT(*) as article_count FROM authors_articles GROUP BY author_id ORDER BY article_count DESC LIMIT 1) as article_counts ON authors.id = article_counts.author_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mobile_subscribers (subscriber_id INT, region VARCHAR(50), compliant BOOLEAN); INSERT INTO mobile_subscribers (subscriber_id, region, compliant) VALUES (1, 'North', true), (2, 'North', false), (3, 'South', true), (4, 'East', true);
|
List the regions where mobile subscribers are not compliant with regulatory data retention policies.
|
SELECT region FROM mobile_subscribers WHERE compliant = false;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE esports_players (player_id INT, player_name TEXT, hours_played INT, game TEXT); INSERT INTO esports_players (player_id, player_name, hours_played, game) VALUES (1, 'FalleN', 1200, 'CS:GO'), (2, 's1mple', 1500, 'CS:GO'), (3, 'ZywOo', 1800, 'CS:GO'); CREATE TABLE games (game_id INT, game TEXT, genre TEXT); INSERT INTO games (game_id, game_name, genre) VALUES (1, 'League of Legends', 'MOBA'), (2, 'CS:GO', 'FPS'), (3, 'Dota 2', 'MOBA');
|
What is the total number of hours played by all esports players in 'CS:GO' tournaments?
|
SELECT SUM(esports_players.hours_played) FROM esports_players JOIN games ON esports_players.game = games.game WHERE games.game = 'CS:GO';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Teachers (id INT, name VARCHAR(20)); INSERT INTO Teachers (id, name) VALUES (1, 'Jane Doe'), (2, 'Robert Smith'), (3, 'Alice Johnson'); CREATE TABLE ProfessionalDevelopment (teacher_id INT, attended_date DATE); INSERT INTO ProfessionalDevelopment (teacher_id, attended_date) VALUES (1, '2022-01-01'), (2, '2022-02-15'), (3, '2021-06-20'), (4, '2022-06-01');
|
Identify teachers who have not attended any professional development in the last 6 months.
|
SELECT t.name FROM Teachers t LEFT JOIN ProfessionalDevelopment pd ON t.id = pd.teacher_id WHERE pd.teacher_id IS NULL OR pd.attended_date < DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sustainable_fashion_customers (id INT, customer_name VARCHAR(30), size VARCHAR(10)); INSERT INTO sustainable_fashion_customers (id, customer_name, size) VALUES (1, 'Alice', 'M'), (2, 'Bob', 'L'), (3, 'Charlie', 'S');
|
What is the average size of customers in the 'sustainable_fashion_customers' table?
|
SELECT AVG(CASE WHEN size = 'S' THEN 0 WHEN size = 'M' THEN 1 WHEN size = 'L' THEN 2 ELSE 3 END) AS avg_size FROM sustainable_fashion_customers;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE solar_plants (id INT, state VARCHAR(255), name VARCHAR(255), capacity FLOAT, start_date DATE, end_date DATE); INSERT INTO solar_plants (id, state, name, capacity, start_date, end_date) VALUES (6, 'California', 'Solar Plant D', 40.0, '2021-01-01', '2026-12-31'), (7, 'Nevada', 'Solar Plant E', 50.0, '2022-01-01', '2027-12-31');
|
What is the total installed capacity of solar plants in the 'solar_plants' table, and what is the average installed capacity of these solar plants, grouped by state?
|
SELECT state, SUM(capacity) as total_capacity, AVG(capacity) as avg_capacity FROM solar_plants GROUP BY state;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE dysprosium_prices (price_id INT, date DATE, dysprosium_price FLOAT); INSERT INTO dysprosium_prices (price_id, date, dysprosium_price) VALUES (1, '2022-01-01', 120), (2, '2022-01-08', 122), (3, '2022-01-15', 125), (4, '2022-01-22', 128), (5, '2022-01-29', 130);
|
What was the average price of Dysprosium in Q1 2022 by week?
|
SELECT AVG(dysprosium_price) FROM (SELECT dysprosium_price, DATE_TRUNC('week', date) AS week FROM dysprosium_prices WHERE date BETWEEN '2022-01-01' AND '2022-03-31' GROUP BY week, dysprosium_price ORDER BY week, dysprosium_price) AS subquery WHERE PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY dysprosium_price) = dysprosium_price;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Trainings (Training_ID INT, Training_Name VARCHAR(50), Training_Location VARCHAR(50), Training_Date DATE); INSERT INTO Trainings (Training_ID, Training_Name, Training_Location, Training_Date) VALUES (1, 'Cultural Competency', 'California', '2021-01-01'); INSERT INTO Trainings (Training_ID, Training_Name, Training_Location, Training_Date) VALUES (2, 'Cultural Competency', 'New York', '2021-02-15');
|
How many cultural competency trainings have been conducted in each state?
|
SELECT Training_Location, COUNT(*) FROM Trainings WHERE Training_Name = 'Cultural Competency' GROUP BY Training_Location;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE crimes (id INT, date DATE, location VARCHAR(20), reported BOOLEAN); INSERT INTO crimes (id, date, location, reported) VALUES (1, '2022-01-01', 'Central Park', TRUE), (2, '2022-01-05', 'Northside', TRUE), (3, '2022-01-10', 'Central Park', FALSE), (4, '2022-01-15', 'Central Park', TRUE), (5, '2022-01-20', 'Central Park', TRUE);
|
How many crimes were reported in 'Central Park' in the last 30 days?
|
SELECT COUNT(*) FROM crimes WHERE location = 'Central Park' AND date >= DATE_SUB(CURRENT_DATE, INTERVAL 30 DAY);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE company (id INT, name TEXT, industry TEXT, funding_quarter INT, funding_year INT); INSERT INTO company (id, name, industry, funding_quarter, funding_year) VALUES (1, 'HealPro', 'Healthcare', 3, 2019), (2, 'CareEasy', 'Healthcare', 1, 2019);
|
How many startups in the healthcare sector received funding in each quarter of 2019?
|
SELECT funding_quarter, COUNT(*) FROM company WHERE industry = 'Healthcare' AND funding_year = 2019 GROUP BY funding_quarter;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE tokyo_real_estate(id INT, city VARCHAR(50), size INT, price DECIMAL(10,2), affordable BOOLEAN); INSERT INTO tokyo_real_estate VALUES (1, 'Tokyo', 50, 200000, true);
|
What is the minimum and maximum size of properties in the city of Tokyo, Japan that are affordable?
|
SELECT MIN(size), MAX(size) FROM tokyo_real_estate WHERE city = 'Tokyo' AND affordable = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE suppliers (id INT PRIMARY KEY, name VARCHAR(255), sustainability_score INT); INSERT INTO suppliers (id, name, sustainability_score) VALUES (1, 'Supplier A', 80); INSERT INTO suppliers (id, name, sustainability_score) VALUES (2, 'Supplier B', 85); CREATE TABLE fabrics (id INT PRIMARY KEY, supplier_id INT, name VARCHAR(255), country_of_origin VARCHAR(255), sustainability_score INT); INSERT INTO fabrics (id, supplier_id, name, country_of_origin, sustainability_score) VALUES (1, 1, 'Fabric A', 'Country A', 70); INSERT INTO fabrics (id, supplier_id, name, country_of_origin, sustainability_score) VALUES (2, 2, 'Fabric B', 'Country B', 75); CREATE TABLE products (id INT PRIMARY KEY, name VARCHAR(255), fabric_id INT, sales_volume INT); INSERT INTO products (id, name, fabric_id, sales_volume) VALUES (1, 'Product A', 1, 600); INSERT INTO products (id, name, fabric_id, sales_volume) VALUES (2, 'Product B', 2, 550);
|
Which suppliers have provided fabrics for products with sales volumes greater than 500 and their average sustainability scores?
|
SELECT s.name AS supplier_name, AVG(f.sustainability_score) AS avg_sustainability_score FROM suppliers s INNER JOIN fabrics f ON s.id = f.supplier_id INNER JOIN products p ON f.id = p.fabric_id WHERE p.sales_volume > 500 GROUP BY s.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE dishes (dish_id INT, name VARCHAR(255), calories INT, reviews INT); INSERT INTO dishes (dish_id, name, calories, reviews) VALUES (1, 'Pizza', 300, 7), (2, 'Pasta', 400, 3), (3, 'Salad', 200, 8), (4, 'Burger', 500, 10), (5, 'Sushi', 250, 6);
|
Identify the dish with the lowest calorie count and more than 5 reviews?
|
SELECT name FROM (SELECT name, calories, ROW_NUMBER() OVER (ORDER BY calories ASC) rn FROM dishes WHERE reviews > 5) t WHERE rn = 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sustainable_revenue (activity_id INT, activity_name TEXT, country TEXT, year INT, revenue INT); INSERT INTO sustainable_revenue (activity_id, activity_name, country, year, revenue) VALUES (1, 'Whale Watching', 'Canada', 2021, 7000), (2, 'Polar Bear Tour', 'Canada', 2021, 9000);
|
Calculate the revenue generated from sustainable tourism activities in Canada in 2021.
|
SELECT SUM(revenue) FROM sustainable_revenue WHERE country = 'Canada' AND year = 2021 AND activity_name IN ('Whale Watching', 'Polar Bear Tour');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE events (id INT PRIMARY KEY, name VARCHAR(100), event_date DATE, country VARCHAR(50));
|
Add a new event to the "events" table that took place in Mexico
|
INSERT INTO events (id, name, event_date, country) VALUES (1, 'Día de los Muertos Festival', '2022-11-01', 'Mexico');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Circular_Economy_Garments_Country (id INT, country VARCHAR, quantity INT);
|
What is the percentage of garments produced in each country using circular economy principles?
|
SELECT country, (SUM(quantity) * 100.0 / (SELECT SUM(quantity) FROM Circular_Economy_Garments_Country)) AS percentage FROM Circular_Economy_Garments_Country GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vessels (id INT, name VARCHAR(255)); INSERT INTO vessels (id, name) VALUES (1, 'VesselA'), (2, 'VesselB'), (3, 'VesselC'); CREATE TABLE safety_records (id INT, vessel_id INT, inspection_date DATE, result ENUM('PASS', 'FAIL')); INSERT INTO safety_records (id, vessel_id, inspection_date, result) VALUES (1, 1, '2021-05-05', 'FAIL'), (2, 2, '2021-08-01', 'FAIL'), (3, 3, '2021-09-15', 'PASS'), (4, 1, '2020-02-12', 'FAIL'), (5, 2, '2020-05-19', 'PASS');
|
Show vessels with the most frequent safety inspection failures in the last two years.
|
SELECT vessel_id, COUNT(*) as fails_count FROM safety_records WHERE result = 'FAIL' AND inspection_date >= DATE_SUB(CURDATE(), INTERVAL 2 YEAR) GROUP BY vessel_id ORDER BY fails_count DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE movies (id INT, title VARCHAR(100), release_year INT, budget INT); INSERT INTO movies (id, title, release_year, budget) VALUES (1, 'Movie1', 2021, 5000000); INSERT INTO movies (id, title, release_year, budget) VALUES (2, 'Movie2', 2021, 7000000); INSERT INTO movies (id, title, release_year, budget) VALUES (3, 'Movie3', 2020, 8000000);
|
What's the average budget of movies produced in 2021?
|
SELECT AVG(budget) FROM movies WHERE release_year = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE users (id INT, age_group VARCHAR(20), language VARCHAR(20), preference VARCHAR(20));
|
What is the distribution of users by age group and preferred news language?
|
SELECT age_group, language, COUNT(*) FROM users GROUP BY age_group, language;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Guides (id INT, name TEXT, country TEXT, city TEXT);CREATE TABLE VirtualTours (id INT, guide_id INT, date DATE);
|
What is the average number of virtual tours conducted per month by each guide in Paris, France, for the year 2022, if the number of tours is greater than or equal to 10?
|
SELECT AVG(number_of_tours) FROM (SELECT guide_id, COUNT(*) AS number_of_tours FROM VirtualTours JOIN Guides ON VirtualTours.guide_id = Guides.id WHERE Guides.city = 'Paris' AND Guides.country = 'France' AND YEAR(VirtualTours.date) = 2022 GROUP BY guide_id HAVING COUNT(*) >= 10) AS Subquery
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE math_students (student_id INT, student_name VARCHAR(50), publications INT, department VARCHAR(50)); INSERT INTO math_students (student_id, student_name, publications, department) VALUES (1, 'Fatima Ahmed', 12, 'Mathematics'), (2, 'Brian Chen', 5, 'Mathematics'), (3, 'Carla Gonzales', 8, 'Mathematics'), (4, 'Daniel Lee', 6, 'Mathematics'), (5, 'Elizabeth Kim', 10, 'Mathematics'), (6, 'Fernando Nguyen', 7, 'Mathematics');
|
List the top 5 graduate students with the highest number of research publications in the Mathematics department, sorted by the number of publications in descending order.
|
SELECT student_id, student_name, publications FROM (SELECT student_id, student_name, publications, ROW_NUMBER() OVER (PARTITION BY department ORDER BY publications DESC) as rank FROM math_students WHERE department = 'Mathematics') as top5 WHERE rank <= 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE member_heart_rate (member_id INT, heart_rate INT); INSERT INTO member_heart_rate (member_id, heart_rate) VALUES (1, 180), (2, 170), (3, 160), (4, 190), (5, 150);
|
What is the maximum heart rate for each member?
|
SELECT member_id, MAX(heart_rate) AS max_heart_rate FROM member_heart_rate GROUP BY member_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE chemical_usage (id INT, chemical_name VARCHAR(50), usage_quantity INT, usage_date DATE);
|
Update 'chemical_name' to 'Potassium Carbonate' for records in 'chemical_usage' table where 'id' is 1
|
UPDATE chemical_usage SET chemical_name = 'Potassium Carbonate' WHERE id = 1;
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA emerging_markets; CREATE TABLE emerging_markets.digital_assets (asset_name VARCHAR(10), market_cap BIGINT, daily_transaction_volume BIGINT); INSERT INTO emerging_markets.digital_assets (asset_name, market_cap, daily_transaction_volume) VALUES ('AssetX', 20000000, 10000000), ('AssetY', 15000000, 7000000), ('AssetZ', 10000000, 5000000), ('AssetW', 5000000, 3000000), ('AssetV', 3000000, 2000000);
|
What is the average daily transaction volume for the top 3 digital assets by market capitalization in the 'emerging_markets' schema?
|
SELECT AVG(daily_transaction_volume) FROM (SELECT daily_transaction_volume FROM emerging_markets.digital_assets ORDER BY market_cap DESC FETCH NEXT 3 ROWS ONLY) t;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donations (id INT, donor_id INT, is_first_time_donor BOOLEAN, amount DECIMAL(10, 2), donation_date DATE);
|
What is the percentage of donations made by first-time donors in the last month?
|
SELECT 100.0 * SUM(CASE WHEN is_first_time_donor THEN amount ELSE 0 END) / SUM(amount) as pct_first_time_donors
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE drug_approval (drug VARCHAR(255), approval_date DATE); INSERT INTO drug_approval (drug, approval_date) VALUES ('DrugC', '2021-06-15'), ('DrugD', '2022-08-30'), ('DrugE', '2021-12-31'), ('DrugF', '2021-01-01');
|
Which drugs were approved in the second half of 2021?
|
SELECT drug FROM drug_approval WHERE approval_date BETWEEN '2021-07-01' AND '2021-12-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE company (id INT, name TEXT, industry TEXT); INSERT INTO company (id, name, industry) VALUES (1, 'FintechInnovations', 'Fintech'); INSERT INTO company (id, name, industry) VALUES (2, 'TechBoost', 'Technology'); CREATE TABLE funding_round (company_id INT, round_size INT); INSERT INTO funding_round (company_id, round_size) VALUES (1, 2000000); INSERT INTO funding_round (company_id, round_size) VALUES (2, 7000000);
|
What is the minimum funding round size in the fintech sector?
|
SELECT MIN(funding_round.round_size) FROM company INNER JOIN funding_round ON company.id = funding_round.company_id WHERE company.industry = 'Fintech';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_protected_areas (id INT, name VARCHAR(255), location VARCHAR(255), depth FLOAT); INSERT INTO marine_protected_areas (id, name, location, depth) VALUES (1, 'MPA 1', 'Pacific Ocean', 123.4), (2, 'MPA 2', 'Indian Ocean', 50.0), (3, 'MPA 3', 'Indian Ocean', 75.0);
|
What is the minimum depth of all marine protected areas in the Indian Ocean?
|
SELECT MIN(depth) FROM marine_protected_areas WHERE location = 'Indian Ocean';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE africa_subscribers (subscriber_id INT, subscriber_type VARCHAR(10), country VARCHAR(10));
|
Show the number of mobile and broadband subscribers in the Africa region
|
SELECT subscriber_type, COUNT(*), country FROM africa_subscribers GROUP BY subscriber_type, country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE supplier_data (supplier VARCHAR(25), element VARCHAR(2), quantity INT, year INT); INSERT INTO supplier_data VALUES ('SupplierX', 'Tb', 250, 2020), ('SupplierY', 'Gd', 350, 2020), ('SupplierX', 'Gd', 150, 2020);
|
What is the total quantity of Terbium (Tb) and Gadolinium (Gd) supplied by each supplier in 2020, ordered by supplier name?
|
SELECT supplier, SUM(quantity) AS total_quantity FROM supplier_data WHERE element IN ('Tb', 'Gd') AND year = 2020 GROUP BY supplier ORDER BY supplier;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE emergency_responses (id INT, region TEXT, incident_type TEXT, response_time INT); INSERT INTO emergency_responses (id, region, incident_type, response_time) VALUES (1, 'Region 1', 'Fire', 8), (2, 'Region 1', 'Medical', 10), (3, 'Region 2', 'Fire', 7), (4, 'Region 2', 'Medical', 9), (5, 'Region 3', 'Fire', 9), (6, 'Region 3', 'Medical', 11);
|
What is the average response time for emergency incidents in each region?
|
SELECT region, AVG(response_time) AS avg_response_time FROM emergency_responses GROUP BY region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE production_figures (field_id INT PRIMARY KEY, country VARCHAR(50), year INT, yearly_production FLOAT);
|
Update the 'production_figures' table and set the 'yearly_production' to null for any record where 'country' is 'Brazil'
|
UPDATE production_figures SET yearly_production = NULL WHERE country = 'Brazil';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Attorneys ( AttorneyID INT, Name VARCHAR(100), Region VARCHAR(50) ); INSERT INTO Attorneys (AttorneyID, Name, Region) VALUES (5, 'Davis', 'Northeast'), (6, 'Miller', 'Midwest'), (7, 'Thomas', 'South'), (8, 'Garcia', 'West');
|
What is the total billing amount for each attorney by region?
|
SELECT A.Region, A.AttorneyID, SUM(P.BillingAmount) AS Total_Billing_Amount FROM Attorneys A INNER JOIN Precedents P ON A.AttorneyID = P.CaseID GROUP BY A.Region, A.AttorneyID;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE funding (id INT, startup_name VARCHAR(50), funding_amount INT, date DATE); INSERT INTO funding (id, startup_name, funding_amount, date) VALUES ('Startup A', 1000000, '2022-01-01'); INSERT INTO funding (id, startup_name, funding_amount, date) VALUES ('Startup B', 2000000, '2022-02-01');
|
Display the names and funding amounts for startups that received funding on or after January 1, 2022 from the funding table
|
SELECT startup_name, funding_amount FROM funding WHERE date >= '2022-01-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE LandfillCapacity (country VARCHAR(50), year INT, capacity FLOAT); INSERT INTO LandfillCapacity (country, year, capacity) VALUES ('CountryA', 2018, 5000000.0), ('CountryA', 2019, 5500000.0), ('CountryA', 2020, 6000000.0), ('CountryB', 2018, 4000000.0), ('CountryB', 2019, 4500000.0), ('CountryB', 2020, 5000000.0);
|
What is the total landfill capacity in cubic meters for each country?
|
SELECT country, SUM(capacity) FROM LandfillCapacity WHERE year = 2020 GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE regulatory_frameworks (asset_id INT PRIMARY KEY, country TEXT, status TEXT); INSERT INTO regulatory_frameworks (asset_id, country, status) VALUES (3, 'United States', 'Under Review');
|
What is the regulatory status of digital asset 'Ripple' in the United States?
|
SELECT status FROM regulatory_frameworks WHERE asset_id = 3 AND country = 'United States';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Energy_Ratings (hotel_id INT, hotel_name VARCHAR(50), country VARCHAR(50), energy_rating FLOAT); INSERT INTO Energy_Ratings (hotel_id, hotel_name, country, energy_rating) VALUES (1, 'Hotel Sydney', 'Australia', 3.7), (2, 'Hotel Melbourne', 'Australia', 4.1), (3, 'Hotel Auckland', 'New Zealand', 4.5);
|
Find the average energy consumption rating for hotels in Australia and New Zealand.
|
SELECT AVG(energy_rating) FROM Energy_Ratings WHERE country IN ('Australia', 'New Zealand') GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Indigenous_Farmers (id INT PRIMARY KEY, name VARCHAR(50), age INT, location VARCHAR(50), tribe VARCHAR(50)); INSERT INTO Indigenous_Farmers (id, name, age, location, tribe) VALUES (1, 'Nina Sanchez', 40, 'Brazilian Rainforest', 'Yanomami'); INSERT INTO Indigenous_Farmers (id, name, age, location, tribe) VALUES (2, 'Ali El-Kareem', 50, 'Jordanian Desert', 'Bedouin'); CREATE TABLE Indigenous_Produce (id INT PRIMARY KEY, product_name VARCHAR(50), price DECIMAL(5,2), farmer_id INT, location VARCHAR(50), organic_certified BOOLEAN); INSERT INTO Indigenous_Produce (id, product_name, price, farmer_id, location, organic_certified) VALUES (1, 'Bananas', 0.75, 1, 'Brazilian Rainforest', true); INSERT INTO Indigenous_Produce (id, product_name, price, farmer_id, location, organic_certified) VALUES (2, 'Dates', 1.25, 2, 'Jordanian Desert', true);
|
Show the indigenous farmers' details and their organic produce.
|
SELECT if.name, if.location, ip.product_name, ip.price FROM Indigenous_Farmers if INNER JOIN Indigenous_Produce ip ON if.id = ip.farmer_id WHERE ip.organic_certified = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vessels (id INT, type VARCHAR(255)); INSERT INTO vessels (id, type) VALUES (1, 'Tanker'), (2, 'Bulk Carrier'), (3, 'Container Ship'); CREATE TABLE speed (vessel_id INT, speed INT, month VARCHAR(9)); INSERT INTO speed (vessel_id, speed, month) VALUES (1, 15, 'May 2021'), (1, 16, 'May 2021'), (2, 12, 'May 2021'), (2, 13, 'May 2021'), (3, 18, 'May 2021'), (3, 19, 'May 2021');
|
What was the average speed for each vessel type in May 2021?
|
SELECT v.type, AVG(s.speed) as avg_speed FROM speed s JOIN vessels v ON s.vessel_id = v.id WHERE s.month = 'May 2021' GROUP BY v.type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE humanitarian_assistance (org_name VARCHAR(255), mission_id INT);
|
Which organizations have been involved in more than 10 humanitarian assistance missions?
|
SELECT org_name, COUNT(*) FROM humanitarian_assistance GROUP BY org_name HAVING COUNT(*) > 10;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE wave_height (ocean TEXT, height FLOAT); INSERT INTO wave_height (ocean, height) VALUES ('Atlantic', 30.0), ('Pacific', 25.0), ('Indian', 28.0), ('Southern', 32.0);
|
What is the maximum wave height recorded in the Indian and Southern Oceans?
|
SELECT MAX(height) FROM wave_height WHERE ocean IN ('Indian', 'Southern');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE EsportsPrizes (EventID INT, Country VARCHAR(20), PrizeMoney DECIMAL(10, 2)); INSERT INTO EsportsPrizes (EventID, Country, PrizeMoney) VALUES (1, 'US', 50000.00);
|
What is the total amount of prize money awarded at esports events in the US?
|
SELECT SUM(PrizeMoney) FROM EsportsPrizes WHERE Country = 'US';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE esports_event (event_id INT, event_name VARCHAR(50), game_title VARCHAR(50), prize_pool INT, region VARCHAR(20)); INSERT INTO esports_event (event_id, event_name, game_title, prize_pool, region) VALUES (1, 'Worlds', 'League of Legends', 2500000, 'North America'); INSERT INTO esports_event (event_id, event_name, game_title, prize_pool, region) VALUES (2, 'The International', 'Dota 2', 40000000, 'Europe');
|
What is the average prize pool for esports events in North America?
|
SELECT AVG(prize_pool) FROM esports_event WHERE region = 'North America';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE chemical_manufacturers (manufacturer_id INT, name VARCHAR(255), last_updated_safety DATE); INSERT INTO chemical_manufacturers (manufacturer_id, name, last_updated_safety) VALUES (1, 'ManufacturerA', '2021-01-15'), (2, 'ManufacturerB', '2021-02-10'), (3, 'ManufacturerC', '2021-03-01');
|
Which chemical manufacturers have updated their safety protocols in the past month?
|
SELECT name FROM chemical_manufacturers WHERE last_updated_safety BETWEEN DATEADD(month, -1, GETDATE()) AND GETDATE()
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE races (race_id INT, race_name VARCHAR(255)); INSERT INTO races VALUES (1, 'Race 1'); INSERT INTO races VALUES (2, 'Race 2'); CREATE TABLE results (race_id INT, winner_id INT, season VARCHAR(10)); INSERT INTO results VALUES (1, 1, '2021'); INSERT INTO results VALUES (2, 2, '2021'); CREATE TABLE swimmers (swimmer_id INT, swimmer_name VARCHAR(255)); INSERT INTO swimmers VALUES (1, 'Swimmer 1'); INSERT INTO swimmers VALUES (2, 'Swimmer 2');
|
List all the races in the 2021 swimming season with their corresponding winners
|
SELECT races.race_name, swimmers.swimmer_name as winner FROM races JOIN results ON races.race_id = results.race_id JOIN swimmers ON results.winner_id = swimmers.swimmer_id WHERE races.season = '2021';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE carbon_prices (id INT, date DATE, price FLOAT);
|
Insert a new record with the date 2022-01-01 and a price of 24.75 into the "carbon_prices" table
|
INSERT INTO carbon_prices (id, date, price) VALUES (1, '2022-01-01', 24.75);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE funding_records (id INT PRIMARY KEY, startup_id INT, amount DECIMAL(10, 2), funding_date DATE);
|
Calculate the average funding amount for startups
|
SELECT AVG(amount) FROM funding_records;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE military_bases (id INT, name TEXT, country TEXT); INSERT INTO military_bases (id, name, country) VALUES (1, 'Fort Bragg', 'USA'), (2, 'CFB Trenton', 'Canada');
|
What is the total number of military bases located in the United States and Canada, and the number of personnel stationed in each?
|
SELECT m.country, m.name, COUNT(p.id) as personnel_count FROM military_bases m LEFT JOIN base_personnel p ON m.id = p.base_id GROUP BY m.country, m.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE daily_revenue (sale_date DATE, revenue DECIMAL(10,2)); INSERT INTO daily_revenue (sale_date, revenue) VALUES ('2022-01-01', 5000.00), ('2022-01-02', 6000.00), ('2022-01-03', 4000.00), ('2022-01-04', 7000.00), ('2022-01-05', 8000.00), ('2022-01-06', 3000.00), ('2022-01-07', 9000.00);
|
What was the total revenue for the past 7 days?
|
SELECT SUM(revenue) FROM daily_revenue WHERE sale_date BETWEEN DATEADD(day, -6, CURRENT_DATE) AND CURRENT_DATE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE staff (id INT PRIMARY KEY, name VARCHAR(255), role VARCHAR(255), department VARCHAR(255)); INSERT INTO staff (id, name, role, department) VALUES (1, 'Eve', 'Data Manager', 'climate_adaptation'), (2, 'Frank', 'Project Manager', 'climate_mitigation'), (3, 'Grace', 'Data Analyst', 'climate_finance'), (4, 'Hugo', 'Data Scientist', 'climate_communication');
|
Who is the data analyst for climate finance?
|
SELECT name FROM staff WHERE role = 'Data Analyst' AND department = 'climate_finance';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE developers (developer_id INT, name VARCHAR(255), country VARCHAR(255)); CREATE TABLE digital_assets (asset_id INT, name VARCHAR(255), total_supply INT, developer_id INT); INSERT INTO developers (developer_id, name, country) VALUES (1, 'Alice', 'USA'), (2, 'Bob', 'Canada'), (3, 'Charlie', 'India'), (4, 'Dave', 'Brazil'); INSERT INTO digital_assets (asset_id, name, total_supply, developer_id) VALUES (1, 'CryptoCoin', 21000000, 1), (2, 'DecentralizedApp', 1000000, 2), (3, 'SmartContract', 500000, 3), (4, 'DataToken', 100000000, 1), (5, 'AnotherAsset', 5000000, 4);
|
What is the name and country of the developers who created digital assets with a total supply greater than 10 million?
|
SELECT d.name, d.country FROM digital_assets da JOIN developers d ON da.developer_id = d.developer_id WHERE da.total_supply > 10000000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE feedback (id INT, created_at DATETIME); INSERT INTO feedback (id, created_at) VALUES (1, '2022-01-01 12:34:56'), (2, '2022-01-15 10:20:34'), (3, '2022-02-20 16:45:01');
|
How many citizen feedback records were created in January 2022?
|
SELECT COUNT(*) FROM feedback WHERE created_at BETWEEN '2022-01-01' AND '2022-01-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE art_exhibit (id INT, attendee_age INT, visit_date DATE); INSERT INTO art_exhibit (id, attendee_age, visit_date) VALUES (1, 34, '2021-06-01'), (2, 45, '2021-06-02'), (3, 28, '2021-06-03');
|
What was the average age of attendees at the art_exhibit in 2021?
|
SELECT AVG(attendee_age) FROM art_exhibit WHERE YEAR(visit_date) = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE wind_projects (id INT, country VARCHAR(20), installed_capacity FLOAT); INSERT INTO wind_projects (id, country, installed_capacity) VALUES (1, 'Spain', 75.0), (2, 'Spain', 85.2), (3, 'Spain', 95.3), (4, 'Canada', 65.0);
|
What is the maximum installed capacity of a wind energy project in Spain?
|
SELECT MAX(installed_capacity) FROM wind_projects WHERE country = 'Spain';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE public.cleaning (cleaning_id SERIAL PRIMARY KEY, cleaning_type VARCHAR(20), cleaning_date DATE, station_id INTEGER, FOREIGN KEY (station_id) REFERENCES public.station(station_id)); INSERT INTO public.cleaning (cleaning_type, cleaning_date, station_id) VALUES ('routine cleaning', '2022-03-03', 1), ('deep cleaning', '2022-03-15', 2);
|
What is the earliest date a 'subway' station was cleaned?
|
SELECT MIN(cleaning_date) FROM public.cleaning INNER JOIN public.station ON public.cleaning.station_id = public.station.station_id WHERE route_type = 'subway'
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE funding (id INT, program_id INT, source VARCHAR(255), amount DECIMAL(10, 2), date DATE);
|
Which programs had the most significant increase in funding between 2020 and 2021?
|
SELECT f1.program_id, p.name, f1.source, (f1.amount - f2.amount) AS funding_increase FROM funding f1 INNER JOIN funding f2 ON f1.program_id = f2.program_id AND f1.date = '2021-12-31' AND f2.date = '2020-12-31' INNER JOIN programs p ON f1.program_id = p.id ORDER BY funding_increase DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE national_security_meetings (id INT, meeting_date DATE, purpose VARCHAR(255)); INSERT INTO national_security_meetings (id, meeting_date, purpose) VALUES (1, '2019-01-10', 'Intelligence Sharing'), (2, '2019-04-20', 'Cybersecurity Threat Analysis');
|
How many national security meetings were held in H1 of 2019?
|
SELECT COUNT(*) FROM national_security_meetings WHERE meeting_date BETWEEN '2019-01-01' AND '2019-06-30';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donors (DonorID INT, DonorName TEXT, AmountDonated DECIMAL); INSERT INTO Donors (DonorID, DonorName, AmountDonated) VALUES (1, 'John Doe', 500.00), (2, 'Jane Smith', 300.00), (3, 'Bob Johnson', 700.00);
|
What is the maximum amount donated by a single donor?
|
SELECT MAX(AmountDonated) FROM Donors;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE train_stations (station_id INT, city VARCHAR(50), accessible BOOLEAN); INSERT INTO train_stations (station_id, city, accessible) VALUES (1, 'New York', true), (2, 'New York', false), (3, 'New York', true), (4, 'Boston', true), (5, 'Boston', true);
|
Add a new wheelchair-accessible train station in Chicago
|
INSERT INTO train_stations (station_id, city, accessible) VALUES (6, 'Chicago', true);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE movies_actors (id INT, movie_id INT, actor_name VARCHAR(255), rating FLOAT); INSERT INTO movies_actors (id, movie_id, actor_name, rating) VALUES (1, 1, 'ActorA', 7.5), (2, 2, 'ActorB', 8.2), (3, 3, 'ActorC', 9.0), (4, 4, 'ActorD', 6.5), (5, 5, 'ActorA', 9.5);
|
What are the names of all the actors who have acted in a movie with a rating greater than or equal to 9?
|
SELECT DISTINCT actor_name FROM movies_actors WHERE id IN (SELECT movie_id FROM movies WHERE rating >= 9);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE animal_population (species VARCHAR(10), population INT); INSERT INTO animal_population (species, population) VALUES ('tiger', 2000), ('lion', 1500), ('tiger', 2500), ('elephant', 5000);
|
Get the average population of 'tiger' and 'lion' species in the 'animal_population' table
|
SELECT AVG(population) FROM animal_population WHERE species IN ('tiger', 'lion');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE traffic_violations (id INT, city VARCHAR(255), amount FLOAT); INSERT INTO traffic_violations (id, city, amount) VALUES (1, 'San Francisco', 150.0), (2, 'San Francisco', 200.0), (3, 'Oakland', 120.0);
|
What is the average fine for traffic violations in the city of San Francisco?
|
SELECT AVG(amount) FROM traffic_violations WHERE city = 'San Francisco';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Marine_Protected_Areas (id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255), area_size FLOAT); INSERT INTO Marine_Protected_Areas (id, name, country, area_size) VALUES (1, 'Bonaire National Marine Park', 'Netherlands', 2700);
|
What is the total area of marine protected areas in the Caribbean?
|
SELECT SUM(area_size) FROM Marine_Protected_Areas WHERE country = 'Netherlands';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cultural_events (id INT, name TEXT, location TEXT, start_date DATE, end_date DATE);CREATE TABLE visitors (id INT, name TEXT, region TEXT);CREATE TABLE event_attendance (id INT, visitor_id INT, event_id INT);
|
How many cultural events were attended by visitors from a specific region?
|
SELECT c.location, COUNT(e.id) as num_events FROM cultural_events c JOIN event_attendance ea ON c.id = ea.event_id JOIN visitors v ON ea.visitor_id = v.id WHERE v.region = 'North America' GROUP BY c.location;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE charging_stations (id INT PRIMARY KEY, station_name VARCHAR(255), location VARCHAR(255), num_charging_ports INT, country VARCHAR(255));
|
Create a view with the total number of electric vehicle charging stations by country
|
CREATE VIEW total_charging_stations AS SELECT country, COUNT(*) as total_stations FROM charging_stations GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE materials (material_id INT, site_id INT, quantity INT, material_date DATE);
|
Identify the sites that have the highest total quantity of materials used, in the last six months.
|
SELECT site_id, SUM(quantity) as total_quantity FROM materials WHERE material_date >= DATEADD(month, -6, CURRENT_DATE) GROUP BY site_id ORDER BY total_quantity DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE volunteers (volunteer_id int, hours_served int, country varchar(50)); INSERT INTO volunteers (volunteer_id, hours_served, country) VALUES (1, 15, 'Germany'), (2, 5, 'Germany'), (3, 25, 'Germany');
|
What is the average number of hours served per volunteer in Germany, for volunteers who have served more than 10 hours?
|
SELECT AVG(hours_served) FROM volunteers WHERE country = 'Germany' GROUP BY volunteer_id HAVING COUNT(volunteer_id) > 10;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE revenue (restaurant_id INT, cuisine VARCHAR(255), revenue FLOAT); INSERT INTO revenue (restaurant_id, cuisine, revenue) VALUES (1, 'Italian', 5000), (1, 'Mexican', 7000), (2, 'Italian', 6000), (2, 'Chinese', 8000);
|
What is the total revenue for each cuisine type?
|
SELECT cuisine, SUM(revenue) as total_revenue FROM revenue GROUP BY cuisine;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SmartBuildings (id INT, city VARCHAR(20), type VARCHAR(20), capacity INT); INSERT INTO SmartBuildings (id, city, type, capacity) VALUES (1, 'Austin', 'Solar', 500), (2, 'Seattle', 'Wind', 600), (3, 'Austin', 'Geothermal', 400);
|
Delete records in the "SmartBuildings" table where the "city" is "Austin"
|
DELETE FROM SmartBuildings WHERE city = 'Austin';
|
gretelai_synthetic_text_to_sql
|
CREATE VIEW Resilience_Length_By_Type AS SELECT project_id, project_name, project_type, resilience_score, length FROM Infrastructure_Data JOIN Resilience_Scores ON Infrastructure_Data.project_id = Resilience_Scores.project_id WHERE year >= 2015; CREATE TABLE Infrastructure_Types (project_type VARCHAR(255), type_description VARCHAR(255));
|
Display the average resilience score and length for each type of infrastructure in the Resilience_Length_By_Type view
|
SELECT project_type, AVG(resilience_score), AVG(length) FROM Resilience_Length_By_Type JOIN Infrastructure_Types ON Resilience_Length_By_Type.project_type = Infrastructure_Types.project_type GROUP BY project_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE artworks (id INT, name VARCHAR(255), year INT, artist_name VARCHAR(255), artist_birthplace VARCHAR(255), category VARCHAR(255)); INSERT INTO artworks (id, name, year, artist_name, artist_birthplace, category) VALUES (1, 'Painting', 1920, 'John', 'England', 'painting'), (2, 'Sculpture', 1930, 'Sara', 'France', 'sculpture'), (3, 'Print', 1940, 'Alex', 'Germany', 'print'), (4, 'Painting', 1955, 'Maria', 'Spain', 'Indigenous'), (5, 'Ceremony Object', 1890, 'Anonymous', 'Peru', 'Indigenous');
|
What is the minimum year of creation for Indigenous artworks?
|
SELECT MIN(year) FROM artworks WHERE category = 'Indigenous';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE climate_communication (year INT, region VARCHAR(255), count INT); INSERT INTO climate_communication (year, region, count) VALUES (2020, 'Small Island Developing States', 120); INSERT INTO climate_communication (year, region, count) VALUES (2019, 'Small Island Developing States', 100);
|
How many climate communication campaigns were conducted in Small Island Developing States (SIDS) in the year 2020?
|
SELECT count FROM climate_communication WHERE year = 2020 AND region = 'Small Island Developing States';
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA likes;CREATE TABLE likes.post_likes (user_id INT, like_count INT);
|
What is the distribution of post likes for each user in the 'likes' schema?
|
SELECT user_id, AVG(like_count) FROM likes.post_likes GROUP BY user_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE teams (team_id INT, team_name VARCHAR(50)); CREATE TABLE games (game_id INT, home_team_id INT, attendance INT);
|
Determine the average attendance for each NHL team's home games.
|
SELECT home_team_id, AVG(attendance) AS avg_attendance FROM games WHERE home_team_id = teams.team_id GROUP BY home_team_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE rural_infrastructure (id INT, project_name VARCHAR(50), region VARCHAR(50), amount_spent DECIMAL(10,2)); INSERT INTO rural_infrastructure VALUES (1, 'Road Construction', 'North', 50000.00), (2, 'Bridge Building', 'South', 75000.00), (3, 'Water Supply', 'Central', 60000.00), (4, 'Electricity Distribution', 'East', 80000.00), (5, 'School Building', 'West', 45000.00);
|
What is the average amount of money spent on rural infrastructure projects in the 'rural_infrastructure' table, partitioned by the region and ordered by the average amount spent in ascending order?;
|
SELECT region, AVG(amount_spent) as avg_amount_spent FROM rural_infrastructure GROUP BY region ORDER BY avg_amount_spent ASC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mental_health_parity_region (region VARCHAR(10), violations INT); INSERT INTO mental_health_parity_region (region, violations) VALUES ('Northeast', 35), ('Midwest', 40), ('South', 25);
|
What is the total number of mental health parity violations in the Northeast and Midwest regions?
|
SELECT region, SUM(violations) FROM mental_health_parity_region WHERE region IN ('Northeast', 'Midwest') GROUP BY region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE union_membership (id INT, name VARCHAR(50), sector VARCHAR(50), is_member BOOLEAN); INSERT INTO union_membership (id, name, sector, is_member) VALUES (1, 'Alice', 'education', TRUE); INSERT INTO union_membership (id, name, sector, is_member) VALUES (2, 'Bob', 'technology', FALSE); INSERT INTO union_membership (id, name, sector, is_member) VALUES (3, 'Charlie', 'mining', TRUE);
|
What is the total number of union members in the 'education' and 'mining' sectors?
|
SELECT SUM(is_member) FROM union_membership WHERE sector IN ('education', 'mining');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE financial_institutions (institution_id INT, institution_name TEXT, region TEXT, offers_financial_capability BOOLEAN);
|
Find the number of financial institutions offering financial capability programs in the African region.
|
SELECT COUNT(institution_id) FROM financial_institutions WHERE region = 'African' AND offers_financial_capability = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE workers (id INT, industry VARCHAR(50), region VARCHAR(50), industry_4_0_training BOOLEAN);
|
What is the percentage of workers in the automotive industry who have received industry 4.0 training in North America?
|
SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM workers w WHERE industry = 'automotive' AND region = 'North America')) AS percentage FROM workers w WHERE industry = 'automotive' AND region = 'North America' AND industry_4_0_training = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE communities (community_id INT, community_name VARCHAR(50)); CREATE TABLE emergencies (emergency_id INT, community_id INT, emergency_type VARCHAR(50), responded_date DATE, response_time INT); INSERT INTO communities (community_id, community_name) VALUES (1, 'Community A'), (2, 'Community B'), (3, 'Community C'); INSERT INTO emergencies (emergency_id, community_id, emergency_type, responded_date, response_time) VALUES (1, 1, 'Fire', '2021-01-01', 15), (2, 2, 'Medical', '2021-02-01', 20), (3, 3, 'Police', '2021-03-01', 12), (4, 1, 'Fire', '2021-04-01', 18), (5, 2, 'Medical', '2021-05-01', 10);
|
What is the average response time for fire emergencies in each community?
|
SELECT e.community_id, c.community_name, AVG(e.response_time) AS avg_response_time FROM emergencies e JOIN communities c ON e.community_id = c.community_id WHERE e.emergency_type = 'Fire' GROUP BY e.community_id, c.community_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE volunteers (id INT, name TEXT, email TEXT, city TEXT);
|
How many volunteers are registered in the 'volunteers' table?
|
SELECT COUNT(*) FROM volunteers;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sales (id INT, brand VARCHAR(255), contains_parabens BOOLEAN, is_vegan BOOLEAN, country VARCHAR(255), sales_amount DECIMAL(10, 2), sale_date DATE);
|
What is the percentage of cosmetics sold in Canada in 2021 that were vegan?
|
SELECT 100.0 * SUM(CASE WHEN is_vegan THEN 1 ELSE 0 END) / COUNT(*) as percentage FROM sales WHERE country = 'Canada' AND sale_date BETWEEN '2021-01-01' AND '2021-12-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Humidity_L (field VARCHAR(50), date DATE, humidity FLOAT); INSERT INTO Humidity_L (field, date, humidity) VALUES ('Field L', '2022-06-01', 65.2), ('Field L', '2022-06-02', 62.1), ('Field L', '2022-06-03', 68.6);
|
What is the average humidity in field L during the last 3 days?
|
SELECT AVG(humidity) FROM Humidity_L WHERE field = 'Field L' AND date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 DAY);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE menu_items(id INT, name VARCHAR(255), rating INT, is_vegan BOOLEAN); INSERT INTO menu_items (id, name, rating, is_vegan) VALUES (1, 'Veggie Burger', 5, true), (2, 'Chicken Sandwich', 4, false), (3, 'Tofu Stir Fry', 5, true);
|
List all menu items that have a rating of 5 and are vegan-friendly.
|
SELECT name FROM menu_items WHERE rating = 5 AND is_vegan = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE clients (client_id INT, name TEXT, region TEXT, transaction_amount DECIMAL); INSERT INTO clients (client_id, name, region, transaction_amount) VALUES (1, 'John Doe', 'South America', 500.00); INSERT INTO clients (client_id, name, region, transaction_amount) VALUES (2, 'Jane Smith', 'Europe', 350.00); INSERT INTO clients (client_id, name, region, transaction_amount) VALUES (3, 'Mike Johnson', 'South America', 400.00); INSERT INTO clients (client_id, name, region, transaction_amount) VALUES (4, 'Sara Doe', 'South America', 600.00);
|
What is the standard deviation of transaction amounts for clients living in South America?
|
SELECT STDDEV(transaction_amount) FROM clients WHERE region = 'South America';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Programs (ProgramID int, ProgramName varchar(50), ProgramCategory varchar(50), ProgramImpactScore numeric(3,1)); INSERT INTO Programs (ProgramID, ProgramName, ProgramCategory, ProgramImpactScore) VALUES (1, 'Education', 'Children', 8.5), (2, 'Healthcare', 'Children', 7.8), (3, 'Nutrition', 'Elderly', 9.2);
|
What is the average program impact score for each program category?
|
SELECT ProgramCategory, AVG(ProgramImpactScore) as AverageScore FROM Programs GROUP BY ProgramCategory;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE co2_emissions (date DATE, garment_id INT, material VARCHAR(50), co2_emissions DECIMAL(10,2));
|
What is the average CO2 emission per garment by material type in 2021?
|
SELECT AVG(co2_emissions) AS avg_co2_emission, material FROM co2_emissions WHERE date >= '2021-01-01' AND date < '2022-01-01' GROUP BY material;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customer_network_data (customer_region VARCHAR(20), network_type VARCHAR(20), customer_count INT); INSERT INTO customer_network_data (customer_region, network_type, customer_count) VALUES ('Northeast', '4G', 2500), ('Southwest', '4G', 2000), ('Midwest', '4G', 2200), ('Northeast', '5G', 3000), ('Southwest', '5G', 2500), ('Midwest', '5G', 3300);
|
What is the percentage of customers using 4G and 5G networks in each customer region?
|
SELECT customer_region, ((SUM(CASE WHEN network_type = '5G' THEN customer_count ELSE 0 END) / SUM(customer_count)) * 100) AS pct_5g_customers, ((SUM(CASE WHEN network_type = '4G' THEN customer_count ELSE 0 END) / SUM(customer_count)) * 100) AS pct_4g_customers FROM customer_network_data GROUP BY customer_region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Players (PlayerID INT, Age INT, Gender VARCHAR(10), Country VARCHAR(50)); INSERT INTO Players (PlayerID, Age, Gender, Country) VALUES (1, 25, 'Male', 'South Africa'); INSERT INTO Players (PlayerID, Age, Gender, Country) VALUES (2, 30, 'Female', 'Egypt'); CREATE TABLE VRAdoption (PlayerID INT, VRPurchaseDate DATE);
|
What is the count of female players from Africa who have adopted VR technology?
|
SELECT COUNT(Players.PlayerID) FROM Players INNER JOIN VRAdoption ON Players.PlayerID = VRAdoption.PlayerID WHERE Players.Gender = 'Female' AND Players.Country LIKE 'Africa%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customers (customer_id INT, name VARCHAR(50), registration_date DATE); INSERT INTO customers VALUES (1, 'John Doe', '2020-01-01'); INSERT INTO customers VALUES (2, 'Jane Smith', '2020-02-01'); CREATE TABLE transactions (transaction_id INT, customer_id INT, amount DECIMAL(10, 2), transaction_date DATE); INSERT INTO transactions VALUES (1, 1, 100.00, '2021-03-15'); INSERT INTO transactions VALUES (2, 1, 200.00, '2021-03-20'); INSERT INTO transactions VALUES (3, 2, 50.00, '2021-03-18');
|
What is the total transaction amount and average transaction value for each customer in the past month?
|
SELECT c.customer_id, c.name, SUM(t.amount) AS total_amount, AVG(t.amount) AS avg_amount FROM customers c INNER JOIN transactions t ON c.customer_id = t.customer_ID WHERE t.transaction_date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH) GROUP BY c.customer_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE court_cases (case_id INT, defendant_id INT, court_date DATE); INSERT INTO court_cases (case_id, defendant_id, court_date) VALUES (1, 1001, '2020-02-01'), (2, 1002, '2019-03-15');
|
What is the total number of court cases in New York City in 2020?
|
SELECT COUNT(*) FROM court_cases WHERE YEAR(court_date) = 2020 AND city(court_date) = 'New York';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Forests (id INT, name VARCHAR(50), country VARCHAR(50), hectares INT, year_established INT); CREATE TABLE Species (id INT, name VARCHAR(50), forest_id INT, population INT); CREATE TABLE Employees (id INT, name VARCHAR(50), forest_id INT, role VARCHAR(50), year_hired INT); INSERT INTO Forests (id, name, country, hectares, year_established) VALUES (1, 'Bialowieza', 'Poland', 141000, 1921), (2, 'Amazon', 'Brazil', 340000, 1968), (3, 'Daintree', 'Australia', 12000, 1770); INSERT INTO Species (id, name, forest_id, population) VALUES (1, 'Bison', 1, 500), (2, 'Jaguar', 2, 150), (3, 'Cassowary', 3, 1000); INSERT INTO Employees (id, name, forest_id, role, year_hired) VALUES (1, 'John', 1, 'Forester', 2015), (2, 'Aisha', 2, 'Forester', 2000), (3, 'Pedro', 3, 'Forester', 2010), (4, 'Jane', 2, 'Biologist', 2018), (5, 'Raul', 3, 'Forester', 2012);
|
Which forests have more than one employee and have species data?
|
SELECT Forests.name FROM Forests WHERE id IN (SELECT forest_id FROM Employees GROUP BY forest_id HAVING COUNT(DISTINCT Employees.id) > 1) AND id IN (SELECT forest_id FROM Species);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hydroelectric_projects (id INT, name TEXT, year INT, investment FLOAT); CREATE VIEW southeast_asia AS SELECT * FROM regions WHERE name = 'Southeast Asia';
|
What was the total investment in hydroelectric projects in Southeast Asia in 2019?
|
SELECT SUM(investment) FROM hydroelectric_projects JOIN southeast_asia ON hydroelectric_projects.location = southeast_asia.id WHERE year = 2019;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Interviews (InterviewID int, InterviewDate date, CandidateName varchar(50), CandidateGender varchar(10), JobCategory varchar(50), Location varchar(50)); INSERT INTO Interviews (InterviewID, InterviewDate, CandidateName, CandidateGender, JobCategory, Location) VALUES (1, '2023-02-01', 'David Kim', 'Male', 'Software Engineer', 'Seattle'), (2, '2023-02-02', 'Sophia Lee', 'Female', 'Data Analyst', 'San Francisco'), (3, '2023-02-03', 'Daniel Park', 'Male', 'Software Engineer', 'Los Angeles'), (4, '2023-02-04', 'Olivia Choi', 'Female', 'Data Scientist', 'New York'), (5, '2023-02-05', 'William Han', 'Male', 'Software Engineer', 'Chicago'), (6, '2023-02-06', 'Ava Kim', 'Female', 'Data Analyst', 'Denver'), (7, '2023-02-07', 'Mohamed Ahmed', 'Male', 'Data Scientist', 'Cairo');
|
List the top 3 job categories with the highest number of candidates interviewed in the past month, including their respective locations and the number of candidates interviewed?
|
SELECT JobCategory, Location, COUNT(*) AS num_candidates FROM Interviews WHERE InterviewDate >= DATEADD(month, -1, GETDATE()) GROUP BY JobCategory, Location ORDER BY num_candidates DESC, JobCategory DESC, Location DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE if not exists eai_techniques (technique_id INT PRIMARY KEY, name TEXT); INSERT INTO eai_techniques (technique_id, name) VALUES (1, 'Feature Attribution'), (2, 'Model Simplification'), (3, 'Rule Extraction'); CREATE TABLE if not exists ai_applications (app_id INT PRIMARY KEY, name TEXT, technique_id INT); INSERT INTO ai_applications (app_id, name, technique_id) VALUES (1, 'DeepArt', 1), (2, 'DeepDream', NULL), (3, 'Shelley', 3);
|
Which explainable AI techniques are used in the creative AI application 'Shelley'?
|
SELECT eai_techniques.name FROM eai_techniques JOIN ai_applications ON eai_techniques.technique_id = ai_applications.technique_id WHERE ai_applications.name = 'Shelley';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE FieldB_Info (crop_type VARCHAR(50), area FLOAT); INSERT INTO FieldB_Info (crop_type, area) VALUES ('Corn', 500.5), ('Soybeans', 700.2);
|
List all the unique crop types in 'FieldB' and their total area?
|
SELECT DISTINCT crop_type, SUM(area) FROM FieldB_Info;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donations (DonationID INT, DonorID INT, DonationDate DATE, DonationAmount DECIMAL(10,2)); INSERT INTO Donations (DonationID, DonorID, DonationDate, DonationAmount) VALUES (15, 1, '2022-06-01', 700.00), (16, 2, '2022-06-15', 800.00), (17, 3, '2022-07-01', 900.00), (18, 4, '2022-07-15', 1000.00), (19, 5, '2022-07-01', 1100.00);
|
What is the percentage of donations made by each donor compared to the total donations made by all donors?
|
SELECT DonorID, SUM(DonationAmount) OVER (PARTITION BY DonorID ORDER BY DonorID) * 100.0 / SUM(DonationAmount) OVER (ORDER BY DonorID ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS DonationPercentage FROM Donations;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE funding (source VARCHAR(255), amount INT); INSERT INTO funding (source, amount) SELECT * FROM csv_file('funding.csv') AS t(source VARCHAR(255), amount INT);
|
Create a view named 'funding_summary' that displays the total funding for each funding source
|
CREATE VIEW funding_summary AS SELECT source, SUM(amount) AS total_funding FROM funding GROUP BY source;
|
gretelai_synthetic_text_to_sql
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.