context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28 values |
|---|---|---|---|
CREATE TABLE AutonomousVehicles (id INT, manufacturer VARCHAR(50), year INT, country VARCHAR(50)); INSERT INTO AutonomousVehicles (id, manufacturer, year, country) VALUES (1, 'ManufacturerA', 2018, 'Germany'), (2, 'ManufacturerB', 2019, 'France'), (3, 'ManufacturerC', 2020, 'Germany'), (4, 'ManufacturerD', 2021, 'France'); | List the number of autonomous vehicles in Germany and France, by manufacturer and year of production. | SELECT context.manufacturer, context.country, COUNT(context.id) FROM (SELECT * FROM AutonomousVehicles WHERE AutonomousVehicles.country IN ('Germany', 'France')) AS context GROUP BY context.manufacturer, context.country; | gretelai_synthetic_text_to_sql |
CREATE TABLE SpaceMissions (MissionID INT, MissionName VARCHAR(255), LaunchDate DATE); INSERT INTO SpaceMissions (MissionID, MissionName, LaunchDate) VALUES (100, 'Apollo 10', '1969-05-18'), (102, 'Apollo 12', '1969-11-14'); | Insert a new space mission record for the 'Apollo 11' mission, with a mission ID of 101 and a mission launch date of 1969-07-16. | INSERT INTO SpaceMissions (MissionID, MissionName, LaunchDate) VALUES (101, 'Apollo 11', '1969-07-16'); | gretelai_synthetic_text_to_sql |
CREATE TABLE cultural_events (id INT, name TEXT, location TEXT, start_date DATE, end_date DATE);CREATE TABLE event_attendance (id INT, visitor_id INT, event_id INT);CREATE TABLE visitors (id INT, name TEXT, community TEXT, country TEXT); | Find the number of visitors from Indigenous communities in Canada that attended cultural events in the last year. | SELECT COUNT(v.id) as num_visitors FROM visitors v JOIN event_attendance ea ON v.id = ea.visitor_id JOIN cultural_events ce ON ea.event_id = ce.id WHERE v.country = 'Canada' AND v.community LIKE '%Indigenous%' AND ce.start_date >= DATEADD(year, -1, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE Brand_Sustainable_Material_Usage(Brand_ID INT, Date DATE, Quantity INT); INSERT INTO Brand_Sustainable_Material_Usage(Brand_ID, Date, Quantity) VALUES (1, '2022-01-01', 100), (1, '2022-01-02', 200), (1, '2022-01-03', 300), (2, '2022-01-01', 400), (2, '2022-01-02', 500), (2, '2022-01-03', 600), (3, '2022-01-01', 700), (3, '2022-01-02', 800), (3, '2022-01-03', 900); | Find the moving average of sustainable material used by each brand over the last 3 months. | SELECT Brand_ID, AVG(Quantity) OVER (PARTITION BY Brand_ID ORDER BY Date ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) as Moving_Average FROM Brand_Sustainable_Material_Usage; | gretelai_synthetic_text_to_sql |
CREATE TABLE crimes (id INT, date DATE, neighborhood VARCHAR(20)); INSERT INTO crimes (id, date, neighborhood) VALUES (1, '2022-01-01', 'park'), (2, '2022-02-01', 'park'), (3, '2022-01-05', 'square'); | How many crimes were reported in 'park' neighborhood in January? | SELECT COUNT(*) FROM crimes WHERE neighborhood = 'park' AND date BETWEEN '2022-01-01' AND '2022-01-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE menu_category_revenue (menu_category VARCHAR(50), revenue INT); INSERT INTO menu_category_revenue (menu_category, revenue) VALUES ('Appetizers', 5000), ('Entrees', 10000), ('Desserts', 7000), ('Beverages', 8000); | Find the top 3 menu categories with the highest revenue. | SELECT menu_category, revenue FROM menu_category_revenue ORDER BY revenue DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE financial_wellbeing (id INT, program_name VARCHAR(255), budget DECIMAL(10,2), country VARCHAR(255)); | List all financial wellbeing programs in Japan with a budget over 100000. | SELECT program_name FROM financial_wellbeing WHERE country = 'Japan' AND budget > 100000; | gretelai_synthetic_text_to_sql |
CREATE TABLE waste_generation(year INT, sector VARCHAR(255), amount INT); INSERT INTO waste_generation VALUES (2018, 'Residential', 1000), (2018, 'Commercial', 1500), (2018, 'Industrial', 2000), (2019, 'Residential', 1100), (2019, 'Commercial', 1550), (2019, 'Industrial', 2100), (2020, 'Residential', 1200), (2020, 'Commercial', 1600), (2020, 'Industrial', 2200); | What was the total waste generation by sector in 2020? | SELECT sector, SUM(amount) FROM waste_generation WHERE year = 2020 GROUP BY sector; | gretelai_synthetic_text_to_sql |
CREATE TABLE organizations (id INT, name TEXT, city TEXT, num_volunteers INT); INSERT INTO organizations (id, name, city, num_volunteers) VALUES (1, 'Org A', 'City A', 120), (2, 'Org B', 'City B', 80), (3, 'Org C', 'City A', 100), (4, 'Org D', 'City C', 200), (5, 'Org E', 'City B', 180), (6, 'Org F', 'City A', 130); | What is the total number of volunteers for each organization, for organizations that have engaged volunteers in at least 5 different cities? | SELECT name, SUM(num_volunteers) as total_volunteers FROM organizations GROUP BY name HAVING COUNT(DISTINCT city) > 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE Regions (id INT, region_name VARCHAR(255)); INSERT INTO Regions (id, region_name) VALUES (1, 'RegionA'), (2, 'RegionB'); CREATE TABLE LandfillData (region_id INT, capacity_cubic_meters INT, date DATE); INSERT INTO LandfillData (region_id, capacity_cubic_meters, date) VALUES (1, 12000, '2021-01-01'), (1, 12500, '2021-01-02'), (2, 8000, '2021-01-01'), (2, 8500, '2021-01-02'); | What is the total landfill capacity in cubic meters for each region? | SELECT Regions.region_name, SUM(LandfillData.capacity_cubic_meters) FROM Regions INNER JOIN LandfillData ON Regions.id = LandfillData.region_id GROUP BY Regions.region_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artists (id INT, name VARCHAR(50), country VARCHAR(50)); INSERT INTO Artists (id, name, country) VALUES (1, 'Vincent Van Gogh', 'Netherlands'), (2, 'Pablo Picasso', 'Spain'), (3, 'Jackson Pollock', 'United States'); | How many artists are from a specific country? | SELECT COUNT(*) FROM Artists WHERE country = 'United States'; | gretelai_synthetic_text_to_sql |
CREATE TABLE capability_scores (customer_id INT, score INT, score_date DATE); | Identify customers who have improved their financial capability score in the last year. | SELECT customer_id FROM (SELECT customer_id, score, score_date, LAG(score, 12) OVER (PARTITION BY customer_id ORDER BY score_date) AS prev_score FROM capability_scores) WHERE score > prev_score; | gretelai_synthetic_text_to_sql |
CREATE TABLE habitats (name VARCHAR(255), animal_type VARCHAR(255), avg_age DECIMAL(5,2)); INSERT INTO habitats (name, animal_type, avg_age) VALUES ('san_diego', 'cheetah', 8.5); | What is the average age of all cheetahs in the 'san_diego' habitat? | SELECT avg_age FROM habitats WHERE name = 'san_diego' AND animal_type = 'cheetah'; | gretelai_synthetic_text_to_sql |
CREATE TABLE savings (customer_id INT, name TEXT, state TEXT, savings DECIMAL(10, 2)); | Insert a new customer 'Alice' from 'New York' with savings '7000'? | INSERT INTO savings (customer_id, name, state, savings) VALUES (456, 'Alice', 'New York', 7000.00); | gretelai_synthetic_text_to_sql |
CREATE TABLE standards (id INT, item_id INT, standard VARCHAR(255)); INSERT INTO standards (id, item_id, standard) VALUES (1, 1, 'sustainable'), (2, 1, 'ethical'), (3, 2, 'sustainable'), (4, 3, 'ethical'); | Show the total price of all items that are both sustainable and ethically made | SELECT SUM(price) FROM sales s JOIN methods m ON s.item_id = m.item_id JOIN standards st ON s.item_id = st.item_id WHERE m.method = 'circular' AND st.standard IN ('sustainable', 'ethical'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Military_Vehicles (Type VARCHAR(255), Price INT); INSERT INTO Military_Vehicles (Type, Price) VALUES ('Tank', 7000000), ('Humvee', 150000), ('Fighter_Jet', 120000000); | What is the average price of military vehicles by type? | SELECT Type, AVG(Price) FROM Military_Vehicles GROUP BY Type; | gretelai_synthetic_text_to_sql |
CREATE TABLE Accommodations(id INT, name TEXT, type TEXT, positive_review BOOLEAN); INSERT INTO Accommodations(id, name, type, positive_review) VALUES (1, 'Beach House', 'House', true), (2, 'Eco Lodge', 'Lodge', false), (3, 'Green Apartment', 'Apartment', true); | What is the total number of positive reviews for each type of accommodation? | SELECT type, COUNT(*) FROM Accommodations WHERE positive_review = true GROUP BY type; | gretelai_synthetic_text_to_sql |
CREATE TABLE cities (id INT, city_name VARCHAR(50), state VARCHAR(50)); INSERT INTO cities VALUES (1, 'Dallas', 'Texas'), (2, 'Houston', 'Texas'), (3, 'Austin', 'Texas'); CREATE TABLE rainfall (city_id INT, month INT, rainfall FLOAT); INSERT INTO rainfall VALUES (1, 1, 3.2), (1, 2, 4.5), (1, 3, 2.9), (2, 1, 5.1), (2, 2, 4.8), (2, 3, 3.6), (3, 1, 2.5), (3, 2, 3.1), (3, 3, 4.2); | What is the average monthly rainfall in Texas by city? | SELECT c.city_name, AVG(rainfall) as avg_rainfall FROM cities c JOIN rainfall r ON c.id = r.city_id GROUP BY c.city_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (id INT, garment_id INT, date DATE, quantity INT); CREATE VIEW sales_by_month AS SELECT YEAR(sales.date) AS sale_year, MONTH(sales.date) AS sale_month, SUM(sales.quantity) AS total_quantity FROM sales GROUP BY sale_year, sale_month; | What is the total quantity of sales for each month in 2021? | SELECT sales_by_month.sale_year, sales_by_month.sale_month, sales_by_month.total_quantity FROM sales_by_month WHERE sales_by_month.sale_year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE students (id INT, name VARCHAR(50), gender VARCHAR(10), department VARCHAR(50), grade DECIMAL(3,2)); INSERT INTO students (id, name, gender, department, grade) VALUES (1, 'Alice', 'Female', 'Computer Science', 3.80), (2, 'Bob', 'Male', 'Computer Science', 3.20), (3, 'Charlie', 'Non-binary', 'Computer Science', 3.90); | What is the average grade of all female graduate students in the Computer Science department? | SELECT AVG(grade) FROM students WHERE gender = 'Female' AND department = 'Computer Science'; | gretelai_synthetic_text_to_sql |
CREATE TABLE threat_intelligence (id INT, source VARCHAR(20), description TEXT, country VARCHAR(20)); INSERT INTO threat_intelligence (id, source, description, country) VALUES (1, 'NSA', 'Zero-day exploit', 'United States'), (2, 'DRDO', 'Ransomware attack', 'India'); | List all threat intelligence data related to India. | SELECT * FROM threat_intelligence WHERE country = 'India'; | gretelai_synthetic_text_to_sql |
CREATE TABLE articles (title VARCHAR(255), author VARCHAR(100), section VARCHAR(50), published_date DATE); CREATE VIEW women_journalists AS SELECT DISTINCT author FROM authors WHERE gender = 'female'; | Determine the number of articles written by women journalists in the sports section. | SELECT COUNT(*) FROM articles JOIN women_journalists ON articles.author = women_journalists.author WHERE section = 'sports'; | gretelai_synthetic_text_to_sql |
CREATE TABLE news.articles (article_id INT, title VARCHAR(100), author VARCHAR(100), language VARCHAR(10), word_count INT); INSERT INTO news.articles (article_id, title, author, language, word_count) VALUES (1, 'Article 1', 'Jean Dupont', 'Français', 500), (2, 'Article 2', 'Jean Dupont', 'Français', 600), (3, 'Article 3', 'Marie Curie', 'Français', 700); | What is the average word count for articles published in French in the 'news' schema, grouped by author? | SELECT author, AVG(word_count) FROM news.articles WHERE language = 'Français' GROUP BY author; | gretelai_synthetic_text_to_sql |
CREATE TABLE inventory (id INT, product VARCHAR(50), quantity INT, material VARCHAR(50), color VARCHAR(50), size VARCHAR(50)); INSERT INTO inventory (id, product, quantity, material, color, size) VALUES (1, 'Hemp T-Shirt', 150, 'Hemp', 'Natural', 'M'), (2, 'Organic Cotton Hoodie', 200, 'Organic Cotton', 'Grey Heather', 'L'), (3, 'Bamboo Viscose Scarf', 250, 'Bamboo Viscose', 'Cream', 'One Size'), (4, 'Recycled Polyester Jacket', 100, 'Recycled Polyester', 'Navy', 'M'); | Which 'Eco-friendly Fabrics' have the highest and lowest quantities in inventory as of '2022-02-01'? | SELECT material, quantity FROM (SELECT material, quantity, ROW_NUMBER() OVER (ORDER BY quantity DESC) AS rank FROM inventory WHERE material IN ('Hemp', 'Organic Cotton', 'Bamboo Viscose', 'Recycled Polyester') AND date = '2022-02-01') x WHERE rank = 1; SELECT material, quantity FROM (SELECT material, quantity, ROW_NUMBER() OVER (ORDER BY quantity ASC) AS rank FROM inventory WHERE material IN ('Hemp', 'Organic Cotton', 'Bamboo Viscose', 'Recycled Polyester') AND date = '2022-02-01') x WHERE rank = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE programs (program_id INT, program_name TEXT); INSERT INTO programs (program_id, program_name) VALUES (1, 'Youth Mentoring'), (2, 'Food Security'), (3, 'Elder Care'), (4, 'Arts Education'), (5, 'After School Program'), (6, 'Environmental Education'), (7, 'Sports'); | Delete the "Sports" program with ID 7? | DELETE FROM programs WHERE program_id = 7; | gretelai_synthetic_text_to_sql |
CREATE TABLE wells (well_id INT, well_name VARCHAR(50), region VARCHAR(20), production FLOAT, year INT); INSERT INTO wells (well_id, well_name, region, production, year) VALUES (1, 'Well A', 'onshore', 100.0, 2019); INSERT INTO wells (well_id, well_name, region, production, year) VALUES (2, 'Well B', 'offshore', 200.0, 2020); INSERT INTO wells (well_id, well_name, region, production, year) VALUES (3, 'Well C', 'onshore', 150.0, 2021); | What is the total production for wells in the 'offshore' region in 2020? | SELECT SUM(production) FROM wells WHERE region = 'offshore' AND year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE products(product_id INT, product_name TEXT, fair_trade BOOLEAN); INSERT INTO products(product_id, product_name, fair_trade) VALUES (1, 'ProductA', TRUE), (2, 'ProductB', FALSE), (3, 'ProductC', TRUE); | What is the total revenue from transactions with fair-trade products? | SELECT SUM(transactions.price) FROM transactions JOIN products ON transactions.product_id = products.product_id WHERE products.fair_trade = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE investments (name TEXT, type TEXT, socially_responsible BOOLEAN, performance NUMERIC, date DATE); INSERT INTO investments (name, type, socially_responsible, performance, date) VALUES ('ABC Socially Responsible Fund', 'Fund', TRUE, 1.23, '2023-01-01'), ('XYZ Traditional Fund', 'Fund', FALSE, 4.56, '2023-01-01'); | Which socially responsible investments have underperformed in the last 6 months? | SELECT name FROM investments WHERE socially_responsible = TRUE AND performance < (SELECT AVG(performance) FROM investments WHERE type = 'Fund' AND date >= (SELECT CURRENT_DATE - INTERVAL '6 months')); | gretelai_synthetic_text_to_sql |
CREATE TABLE WasteData (Country VARCHAR(50), Continent VARCHAR(50), WasteGeneration FLOAT, Year INT); INSERT INTO WasteData (Country, Continent, WasteGeneration, Year) VALUES ('USA', 'North America', 1234.56, 2020), ('Mexico', 'North America', 654.32, 2020), ('Brazil', 'South America', 789.10, 2020), ('Chile', 'South America', 456.23, 2020); | What is the average monthly waste generation for the top 5 countries with the highest generation rates, partitioned by continent, in the year 2020? | SELECT AVG(WasteGeneration) FROM (SELECT Country, Continent, WasteGeneration, ROW_NUMBER() OVER (PARTITION BY Continent ORDER BY WasteGeneration DESC) AS Rank FROM WasteData WHERE Year = 2020) tmp WHERE Rank <= 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_mammals (mammal_id INT, name VARCHAR(50), population INT, status VARCHAR(20)); INSERT INTO marine_mammals (mammal_id, name, population, status) VALUES (1, 'Blue Whale', 10000, 'Endangered'), (2, 'Fin Whale', 25000, 'Threatened'), (3, 'Sei Whale', 15000, 'Threatened'); | What is the maximum population size of marine mammals that are threatened or endangered? | SELECT MAX(population) FROM marine_mammals WHERE status = 'Endangered' OR status = 'Threatened'; | gretelai_synthetic_text_to_sql |
CREATE TABLE mutual_funds (fund_id INT, fund_name VARCHAR(50), agency_1_rating DECIMAL(3,1), agency_2_rating DECIMAL(3,1), agency_3_rating DECIMAL(3,1)); INSERT INTO mutual_funds (fund_id, fund_name, agency_1_rating, agency_2_rating, agency_3_rating) VALUES (1, 'Fund A', 4.5, 4.2, 4.0), (2, 'Fund B', 3.8, 3.9, 3.6), (3, 'Fund C', 4.7, 4.6, NULL); | Show the names of all mutual funds that have been rated highly by at least one rating agency. | SELECT fund_name FROM mutual_funds WHERE agency_1_rating IS NOT NULL AND agency_1_rating >= 4.5 OR agency_2_rating IS NOT NULL AND agency_2_rating >= 4.5 OR agency_3_rating IS NOT NULL AND agency_3_rating >= 4.5; | gretelai_synthetic_text_to_sql |
CREATE TABLE investments (id INT, investor VARCHAR(255), project_type VARCHAR(255), amount INT, date DATE); INSERT INTO investments (id, investor, project_type, amount, date) VALUES (4, 'SustainableFund', 'water_treatment', 600000, '2022-04-20'); INSERT INTO investments (id, investor, project_type, amount, date) VALUES (5, 'SustainableFund', 'renewable_energy', 800000, '2022-09-03'); | List all investments made by 'SustainableFund' in water projects. | SELECT * FROM investments WHERE investor = 'SustainableFund' AND project_type = 'water_projects'; | gretelai_synthetic_text_to_sql |
CREATE TABLE infrastructure_projects (id INT, project_name VARCHAR(50), location VARCHAR(50)); INSERT INTO infrastructure_projects (id, project_name, location) VALUES (1, 'Highway 101 Expansion', 'California'), (2, 'Bridge Replacement', 'New York'), (3, 'Transit System Upgrade', 'Texas'); | What is the total number of infrastructure projects? | SELECT COUNT(*) as num_projects FROM infrastructure_projects; | gretelai_synthetic_text_to_sql |
CREATE TABLE peacekeeping_operations (id INT, country VARCHAR(50), year INT, soldiers INT); | What is the average number of peacekeeping soldiers per country per year since 2015? | SELECT country, AVG(soldiers) FROM peacekeeping_operations WHERE year >= 2015 GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE cases (case_id INT, case_type VARCHAR(10), client_state VARCHAR(20)); INSERT INTO cases (case_id, case_type, client_state) VALUES (1, 'Civil', 'California'), (2, 'Criminal', 'New York'), (3, 'Civil', 'Texas'); | Show the number of cases for each case type where the client is from 'California'. | SELECT case_type, COUNT(*) FROM cases WHERE client_state = 'California' GROUP BY case_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE ArtCollection (ArtworkID INT, ArtistID INT, ArtworkMedium VARCHAR(50)); INSERT INTO ArtCollection (ArtworkID, ArtistID, ArtworkMedium) VALUES (1, 1, 'Painting'), (2, 1, 'Drawing'), (3, 2, 'Painting'), (4, 2, 'Sculpture'), (5, 3, 'Painting'), (6, 3, 'Print'), (7, 4, 'Painting'), (8, 4, 'Drawing'), (9, 5, 'Sculpture'), (10, 5, 'Painting'); | What is the total number of artworks in the 'ArtCollection' table, categorized by the medium of the artwork? | SELECT ArtworkMedium, COUNT(*) AS ArtworksByMedium FROM ArtCollection GROUP BY ArtworkMedium; | gretelai_synthetic_text_to_sql |
CREATE TABLE CarbonOffsetProjects (id INT, name VARCHAR(100), location VARCHAR(100), type VARCHAR(50), carbon_offset FLOAT); | List the top 3 projects with the highest carbon offset in the 'CarbonOffsetProjects' table. | SELECT name, carbon_offset FROM CarbonOffsetProjects ORDER BY carbon_offset DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE mental_health_parity (id INT PRIMARY KEY, incident_date DATE, incident_description TEXT, location TEXT, resolved BOOLEAN); | What is the total number of mental health parity violation incidents reported in the last quarter? | SELECT COUNT(*) FROM mental_health_parity WHERE incident_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH) AND resolved = FALSE; | gretelai_synthetic_text_to_sql |
CREATE TABLE pollution_control_initiatives (id INT, name VARCHAR(255), location VARCHAR(255), budget DECIMAL(10,2)); INSERT INTO pollution_control_initiatives (id, name, location, budget) VALUES (1, 'Arctic Ocean Cleanup', 'Arctic Ocean', 600000.00), (2, 'Atlantic Ocean Cleanup', 'Atlantic Ocean', 700000.00); | Delete all pollution control initiatives with a budget over 500,000 in the Arctic Ocean region. | DELETE FROM pollution_control_initiatives WHERE budget > 500000.00 AND location = 'Arctic Ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artists (ArtistID INT, ArtistName VARCHAR(50), Gender VARCHAR(50), Country VARCHAR(50)); CREATE TABLE ArtPieces (ArtPieceID INT, ArtistID INT, Value INT); INSERT INTO Artists VALUES (1, 'Artist 1', 'Female', 'Australia'), (2, 'Artist 2', 'Male', 'New Zealand'), (3, 'Artist 3', 'Female', 'Papua New Guinea'); INSERT INTO ArtPieces VALUES (1, 1, 5000), (2, 1, 7000), (3, 2, 8000), (4, 2, 9000), (5, 3, 11000), (6, 3, 13000); | What is the total number of artworks created by female artists in Oceania and their average value? | SELECT COUNT(ArtPieces.ArtPieceID) AS TotalArtPieces, AVG(ArtPieces.Value) AS AvgValue FROM ArtPieces INNER JOIN Artists ON ArtPieces.ArtistID = Artists.ArtistID WHERE Artists.Country = 'Oceania' AND Artists.Gender = 'Female'; | gretelai_synthetic_text_to_sql |
CREATE TABLE unions (union_id INT, union_name TEXT, advocacy TEXT, region TEXT, members INT); INSERT INTO unions (union_id, union_name, advocacy, region, members) VALUES (1001, 'United Steelworkers', 'labor rights', 'Northeast', 5000); INSERT INTO unions (union_id, union_name, advocacy, region, members) VALUES (1002, 'Transport Workers Union', 'collective bargaining', 'Southeast', 6000); | What is the total number of unions advocating for labor rights and their total number of members in the Northeast region? | SELECT u.advocacy, SUM(u.members), COUNT(u.union_id) FROM unions u WHERE u.advocacy = 'labor rights' AND u.region = 'Northeast' GROUP BY u.advocacy; | gretelai_synthetic_text_to_sql |
CREATE TABLE Cases (CaseID INT, ClientFirstName VARCHAR(50), ClientLastName VARCHAR(50), State VARCHAR(2), PracticeArea VARCHAR(50), CaseOutcome VARCHAR(20), OpenDate DATE, CloseDate DATE); INSERT INTO Cases (CaseID, ClientFirstName, ClientLastName, State, PracticeArea, CaseOutcome, OpenDate, CloseDate) VALUES (1, 'Daniel', 'Garcia', 'NY', 'Bankruptcy', 'closed', '2020-01-01', '2020-06-01'), (2, 'Avery', 'Washington', 'CA', 'Bankruptcy', 'open', '2019-01-01', NULL), (3, 'Jessica', 'Harris', 'NY', 'Family Law', 'closed', '2021-01-01', '2021-06-01'); | Find the client's first and last name, state, and the difference between the case closing date and the case opening date, for cases with a practice area of 'Family Law', partitioned by state and ordered by the difference in ascending order. | SELECT State, ClientFirstName, ClientLastName, DATEDIFF(CloseDate, OpenDate) AS DaysOpen FROM Cases WHERE PracticeArea = 'Family Law' ORDER BY State, DaysOpen; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (org_name TEXT, donation_amount INTEGER, donation_date DATE); INSERT INTO Donations (org_name, donation_amount, donation_date) VALUES ('Organization A', 4000, '2019-01-01'); INSERT INTO Donations (org_name, donation_amount, donation_date) VALUES ('Organization B', 6000, '2019-02-15'); | What is the average donation amount for each organization in 2019? | SELECT org_name, AVG(donation_amount) FROM Donations WHERE donation_date BETWEEN '2019-01-01' AND '2019-12-31' GROUP BY org_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE sector_year_consumption (year INT, sector INT, consumption FLOAT, PRIMARY KEY(year, sector)); INSERT INTO sector_year_consumption (year, sector, consumption) VALUES (2015, 1, 15000), (2015, 2, 20000), (2015, 3, 30000), (2016, 1, 16000), (2016, 2, 22000), (2016, 3, 32000), (2017, 1, 17000), (2017, 2, 24000), (2017, 3, 34000); | What is the maximum water consumption by any sector in any year? | SELECT MAX(syc.consumption) as max_consumption FROM sector_year_consumption syc; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotel_ai_usage (hotel_id INT, ai_usage INT); INSERT INTO hotel_ai_usage (hotel_id, ai_usage) VALUES (1, 500), (2, 300), (3, 700); | Determine hotels with the highest AI assistant usage | SELECT hotel_id FROM hotel_ai_usage WHERE ai_usage = (SELECT MAX(ai_usage) FROM hotel_ai_usage); | gretelai_synthetic_text_to_sql |
CREATE TABLE concerts (concert_id INT, concert_name VARCHAR(100), artist_id INT, country VARCHAR(50), revenue INT); INSERT INTO concerts VALUES (1, 'Concert A', 3, 'USA', 10000); INSERT INTO concerts VALUES (2, 'Concert B', 4, 'Canada', 15000); INSERT INTO concerts VALUES (3, 'Concert C', 5, 'Mexico', 20000); | What is the total revenue for all concerts held in the USA? | SELECT SUM(revenue) FROM concerts WHERE country = 'USA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE companies_and_departments (company VARCHAR(50), department VARCHAR(50), employees INTEGER); | What is the total number of employees working in AI ethics in 'companies_and_departments' table? | SELECT SUM(employees) FROM companies_and_departments WHERE department = 'AI Ethics'; | gretelai_synthetic_text_to_sql |
CREATE TABLE CosmeticsSales (sale_id INT, product_name TEXT, is_halal_certified BOOLEAN, sale_amount FLOAT, sale_date DATE, country TEXT); INSERT INTO CosmeticsSales (sale_id, product_name, is_halal_certified, sale_amount, sale_date, country) VALUES (1, 'Halal Lipstick', TRUE, 25.00, '2020-08-20', 'Malaysia'); INSERT INTO CosmeticsSales (sale_id, product_name, is_halal_certified, sale_amount, sale_date, country) VALUES (2, 'Non-Halal Eyeshadow', FALSE, 30.00, '2020-09-15', 'Indonesia'); | Determine the total sales of halal-certified cosmetics in Malaysia and Indonesia in 2020 | SELECT SUM(sale_amount) FROM CosmeticsSales WHERE is_halal_certified = TRUE AND (country = 'Malaysia' OR country = 'Indonesia') AND YEAR(sale_date) = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE departments (department_id INT, department_name TEXT); INSERT INTO departments (department_id, department_name) VALUES (1, 'Mathematics'), (2, 'Computer Science'), (3, 'Physics'), (4, 'Chemistry'); CREATE TABLE research_grants (grant_id INT, grant_amount INT, grant_title TEXT, department_id INT, grant_year INT); INSERT INTO research_grants (grant_id, grant_amount, grant_title, department_id, grant_year) VALUES (1, 250000, 'Data Science Research', 2, 2019), (2, 750000, 'Artificial Intelligence Research', 2, 2020), (3, 350000, 'Machine Learning Research', 2, 2018), (4, 450000, 'Natural Language Processing Research', 1, 2019), (5, 650000, 'Robotics Research', 3, 2020), (6, 850000, 'Computer Vision Research', 2, 2021); | How many research grants were awarded to each department in the year 2020? | SELECT departments.department_name, COUNT(research_grants.grant_id) AS grants_awarded FROM departments INNER JOIN research_grants ON departments.department_id = research_grants.department_id WHERE research_grants.grant_year = 2020 GROUP BY departments.department_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE employees (id INT, name VARCHAR(255), job_category VARCHAR(255), salary DECIMAL(10,2), ethnicity VARCHAR(255)); INSERT INTO employees (id, name, job_category, salary, ethnicity) VALUES (1, 'Taylor Johnson', 'Software Engineer', 95000.00, 'Black'), (2, 'Kofi Owusu', 'Product Manager', 115000.00, 'African American'), (3, 'Alice Davis', 'Data Analyst', 80000.00, 'Asian'), (4, 'Bob Smith', 'Sales Representative', 70000.00, 'White'), (5, 'Charlie Brown', 'UX Designer', 85000.00, 'Native American'); | What is the average salary by job category for employees who identify as African American or Black? | SELECT ethnicity, job_category, AVG(salary) as avg_salary FROM employees WHERE ethnicity = 'African American' OR ethnicity = 'Black' GROUP BY ethnicity, job_category; | gretelai_synthetic_text_to_sql |
CREATE TABLE news_reporters (reporter_id INT, name VARCHAR(50), age INT, gender VARCHAR(10), hire_date DATE); | Show the average age of all reporters in the 'news_reporters' table, grouped by gender. | SELECT gender, AVG(age) FROM news_reporters GROUP BY gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE articles (title VARCHAR(255), author VARCHAR(100), section VARCHAR(50), published_date DATE); CREATE VIEW underrepresented_authors AS SELECT DISTINCT author FROM authors WHERE is_underrepresented = true; | Count the number of articles published by underrepresented authors in the 'culture' section of our news platform. | SELECT COUNT(*) FROM articles JOIN underrepresented_authors ON articles.author = underrepresented_authors.author WHERE section = 'culture'; | gretelai_synthetic_text_to_sql |
CREATE TABLE safety (dept VARCHAR(20), year INT, incidents INT); INSERT INTO safety (dept, year, incidents) VALUES ('Manufacturing', 2018, 12), ('Manufacturing', 2019, 14), ('Manufacturing', 2020, 11), ('Research', 2018, 4), ('Research', 2019, 5), ('Research', 2020, 7); | Find the number of safety incidents in the 'Research' department for each year | SELECT year, SUM(incidents) FROM safety WHERE dept = 'Research' GROUP BY year; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (id INT, region VARCHAR(20), amount FLOAT); INSERT INTO Donations (id, region, amount) VALUES (1, 'Northeast', 25000.00), (2, 'Southeast', 30000.00), (3, 'Midwest', 20000.00), (4, 'Southwest', 15000.00), (5, 'Northwest', 35000.00); | What is the average donation amount in each region? | SELECT region, AVG(amount) as avg_donation FROM Donations GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE maps (map_id INT, map_name VARCHAR(20)); | Insert new records into the maps table with the following data: (1, 'Desert'), (2, 'Arctic'), (3, 'Tropical') | INSERT INTO maps (map_id, map_name) VALUES (1, 'Desert'), (2, 'Arctic'), (3, 'Tropical'); | gretelai_synthetic_text_to_sql |
CREATE TABLE investments (id INT, investor VARCHAR(255), amount FLOAT, date DATE, impact BOOLEAN); INSERT INTO investments (id, investor, amount, date, impact) VALUES (11, 'Impact Investors', 120000, '2021-07-01', TRUE); INSERT INTO investments (id, investor, amount, date, impact) VALUES (12, 'Impact Investors', 140000, '2021-10-31', TRUE); | How many impact investments were made in Q3 2021? | SELECT COUNT(*) FROM investments WHERE impact = TRUE AND date BETWEEN '2021-07-01' AND '2021-09-30'; | gretelai_synthetic_text_to_sql |
CREATE TABLE arctic_ocean (region VARCHAR(255), id INTEGER); INSERT INTO arctic_ocean (region, id) VALUES ('Arctic Ocean', 1); CREATE TABLE arctic_fish_species (id INTEGER, species VARCHAR(255)); INSERT INTO arctic_fish_species (id, species) VALUES (1, 'Capelin'), (2, 'Polar Cod'); CREATE TABLE arctic_feed_conversion (species_id INTEGER, region_id INTEGER, ratio FLOAT); | List all fish species and their feed conversion ratios in the Arctic Ocean. | SELECT f.species, c.ratio FROM arctic_feed_conversion c JOIN arctic_fish_species f ON c.species_id = f.id JOIN arctic_ocean o ON c.region_id = o.id WHERE o.region = 'Arctic Ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE art_pieces (piece_id INT, artist_name VARCHAR(50), artist_gender VARCHAR(10), movement VARCHAR(20)); INSERT INTO art_pieces (piece_id, artist_name, artist_gender, movement) VALUES (1, 'Claude Monet', 'Male', 'Impressionism'); INSERT INTO art_pieces (piece_id, artist_name, artist_gender, movement) VALUES (2, 'Berthe Morisot', 'Female', 'Impressionism'); | How many art pieces were created by female artists in the 'Impressionism' movement? | SELECT COUNT(*) FROM art_pieces WHERE artist_gender = 'Female' AND movement = 'Impressionism'; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteers (id INT, name TEXT, program TEXT, hours INT); INSERT INTO volunteers (id, name, program, hours) VALUES (1, 'John Doe', 'Food Distribution', 10), (2, 'Jane Smith', 'Education Support', 20); | What is the total number of volunteers in the Food Distribution and Education Support programs? | SELECT COUNT(*) FROM volunteers WHERE program IN ('Food Distribution', 'Education Support'); | gretelai_synthetic_text_to_sql |
CREATE TABLE ocean_floor_depths (location VARCHAR(255), depth INTEGER); | Find the maximum and minimum depths of the ocean floor in the 'southern_ocean'. | SELECT MAX(depth), MIN(depth) FROM ocean_floor_depths WHERE location = 'Southern Ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE nih_funding (project_id INT, project_name VARCHAR(100), funding_source VARCHAR(50)); INSERT INTO nih_funding VALUES (1, 'CRISPR Gene Editing', 'NIH'); INSERT INTO nih_funding VALUES (2, 'Stem Cell Research', 'NIH'); CREATE TABLE gates_foundation_funding (project_id INT, project_name VARCHAR(100), funding_source VARCHAR(50)); INSERT INTO gates_foundation_funding VALUES (1, 'CRISPR Gene Editing', 'Gates Foundation'); INSERT INTO gates_foundation_funding VALUES (3, 'Biofuel Research', 'Gates Foundation'); | Which genetic research projects received funding from both the NIH and Gates Foundation? | SELECT f1.project_name FROM nih_funding f1 INNER JOIN gates_foundation_funding f2 ON f1.project_name = f2.project_name WHERE f1.funding_source = 'NIH' AND f2.funding_source = 'Gates Foundation'; | gretelai_synthetic_text_to_sql |
CREATE TABLE brands (brand_id INT, brand_name TEXT, country TEXT); INSERT INTO brands (brand_id, brand_name, country) VALUES (1, 'EcoBrand', 'Germany'), (2, 'GreenFashion', 'France'), (3, 'SustainableStyle', 'USA'); CREATE TABLE material_usage (brand_id INT, material_type TEXT, quantity INT, co2_emissions INT); INSERT INTO material_usage (brand_id, material_type, quantity, co2_emissions) VALUES (1, 'recycled_polyester', 1200, 2000), (1, 'organic_cotton', 800, 1000), (3, 'recycled_polyester', 1500, 2500); | Update the CO2 emissions for recycled polyester used by EcoBrand to 1800. | UPDATE material_usage SET co2_emissions = 1800 WHERE brand_id = 1 AND material_type = 'recycled_polyester'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Tunnels (id INT, name VARCHAR(100), length FLOAT); INSERT INTO Tunnels (id, name, length) VALUES (1, 'Hawthorne Tunnel', 5670), (2, 'Barton Creek Tunnel', 2476), (3, 'Delaware Aqueduct', 8518); | How many tunnels are there in the database with a length greater than 5 miles? | SELECT COUNT(*) FROM Tunnels WHERE length > 5 * 5280; | gretelai_synthetic_text_to_sql |
CREATE TABLE Deliveries (id INT, delivered DATE, quantity INT); INSERT INTO Deliveries (id, delivered, quantity) VALUES (1, '2022-01-01', 20), (2, '2022-01-02', 30), (3, '2022-01-03', 25); | What is the maximum number of packages delivered per day? | SELECT MAX(quantity) FROM Deliveries | gretelai_synthetic_text_to_sql |
CREATE TABLE Companies (id INT, name VARCHAR(255), region VARCHAR(255)); INSERT INTO Companies (id, name, region) VALUES (1, 'CompanyA', 'Asia-Pacific'), (2, 'CompanyB', 'Europe'), (3, 'CompanyC', 'Asia-Pacific'); CREATE TABLE Materials (id INT, company_id INT, material VARCHAR(255), quantity INT); INSERT INTO Materials (id, company_id, material, quantity) VALUES (1, 1, 'Organic cotton', 500), (2, 1, 'Recycled polyester', 300), (3, 2, 'Organic linen', 400), (4, 3, 'Organic cotton', 600), (5, 3, 'Tencel', 700); | Find the number of companies in each region that have sustainable material usage. | SELECT Companies.region, COUNT(DISTINCT Companies.id) FROM Companies JOIN Materials ON Companies.id = Materials.company_id GROUP BY Companies.region; | gretelai_synthetic_text_to_sql |
CREATE TABLE ports_cargo (port_id INT, port_name TEXT, cargo_quantity INT, region TEXT); INSERT INTO ports_cargo VALUES (1, 'Port L', 1800, 'Asia Pacific'), (2, 'Port M', 1500, 'Americas'), (3, 'Port N', 2000, 'Asia Pacific'); | What is the total quantity of cargo handled by each port in the Asia Pacific region, sorted in ascending order? | SELECT ports_cargo.port_name, SUM(ports_cargo.cargo_quantity) FROM ports_cargo WHERE ports_cargo.region = 'Asia Pacific' GROUP BY ports_cargo.port_name ORDER BY SUM(ports_cargo.cargo_quantity) ASC; | gretelai_synthetic_text_to_sql |
CREATE TABLE country_scores (country TEXT, index_score INT); INSERT INTO country_scores (country, index_score) VALUES ('Country1', 70), ('Country2', 80), ('Country3', 60), ('Country4', 90), ('Country5', 50); | What is the distribution of digital divide index scores by country? | SELECT country, index_score, COUNT(*) FROM country_scores GROUP BY index_score ORDER BY index_score; | gretelai_synthetic_text_to_sql |
CREATE TABLE properties (id INT, city VARCHAR(20)); INSERT INTO properties (id, city) VALUES (1, 'Denver'), (2, 'Portland'), (3, 'NYC'), (4, 'Austin'); CREATE TABLE property (id INT, city VARCHAR(20)); INSERT INTO property (id, city) VALUES (1, 'Denver'), (2, 'Portland'), (3, 'NYC'), (4, 'Austin'); | What is the total number of properties in each city? | SELECT p.city, COUNT(*) FROM properties p JOIN property pr ON p.city = pr.city GROUP BY p.city; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_research (id INT, name VARCHAR(255), ocean VARCHAR(255), year INT); INSERT INTO marine_research (id, name, ocean, year) VALUES (1, 'Antarctic Wildlife Study', 'Southern Ocean', 2018), (2, 'Marine Life Census', 'Southern Ocean', 2020); | Add a new marine research project named 'Biodiversity Survey' in the Arctic Ocean in 2023. | INSERT INTO marine_research (name, ocean, year) VALUES ('Biodiversity Survey', 'Arctic Ocean', 2023); | gretelai_synthetic_text_to_sql |
CREATE TABLE gov_production (field VARCHAR(50), year INT, oil_production FLOAT, gas_production FLOAT); INSERT INTO gov_production (field, year, oil_production, gas_production) VALUES ('MC123', 2015, 1234.5, 678.9); INSERT INTO gov_production (field, year, oil_production, gas_production) VALUES ('MC456', 2016, 2345.6, 789.0); INSERT INTO gov_production (field, year, oil_production, gas_production) VALUES ('MC789', 2017, 3456.7, 890.1); INSERT INTO gov_production (field, year, oil_production, gas_production) VALUES ('MC111', 2018, 4567.8, 901.2); INSERT INTO gov_production (field, year, oil_production, gas_production) VALUES ('MC222', 2019, 5678.9, 1001.3); INSERT INTO gov_production (field, year, oil_production, gas_production) VALUES ('MC333', 2020, 6789.0, 1101.4); | What is the total production of oil and gas in the Gulf of Mexico from 2015 to 2020 | SELECT SUM(oil_production) + SUM(gas_production) as total_production FROM gov_production WHERE year BETWEEN 2015 AND 2020 AND field LIKE 'MC%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE mines (id INT, name TEXT, type TEXT, production INT); INSERT INTO mines (id, name, type, production) VALUES (1, 'Golden Mine', 'Gold', 1000), (2, 'Silver Mine', 'Silver', 500), (3, 'Bronze Mine', 'Bronze', 300), (4, 'Platinum Mine', 'Platinum', 800); | What is the total production of each mine type? | SELECT type, SUM(production) as total_production FROM mines GROUP BY type; | gretelai_synthetic_text_to_sql |
CREATE TABLE Volunteers (VolunteerID int, VolunteerName varchar(50), ProgramID int, VolunteerDate date); CREATE TABLE Programs (ProgramID int, ProgramName varchar(50), ProgramCategory varchar(50)); | Which programs have not had any volunteers in Q3 2022? | SELECT Programs.ProgramName FROM Programs LEFT JOIN Volunteers ON Programs.ProgramID = Volunteers.ProgramID WHERE VolunteerDate IS NULL AND QUARTER(VolunteerDate) = 3 AND YEAR(VolunteerDate) = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE news_agency (name VARCHAR(255), location VARCHAR(255));CREATE TABLE reporter (id INT, name VARCHAR(255), age INT, gender VARCHAR(10), news_agency_id INT); INSERT INTO news_agency (name, location) VALUES ('ABC News', 'New York'), ('CNN', 'Atlanta'), ('Fox News', 'New York'); INSERT INTO reporter (id, name, age, gender, news_agency_id) VALUES (1, 'Alice', 35, 'Female', 1), (2, 'Bella', 45, 'Female', 2), (3, 'Carol', 30, 'Female', 3), (4, 'Dave', 55, 'Male', 1), (5, 'Ella', 30, 'Female', 1), (6, 'Frank', 40, 'Male', 2); | List the names and locations of news agencies where at least one news reporter is older than 50. | SELECT news_agency.name, news_agency.location FROM news_agency INNER JOIN reporter ON news_agency.id = reporter.news_agency_id WHERE reporter.age > 50 GROUP BY news_agency.id; | gretelai_synthetic_text_to_sql |
CREATE TABLE animals (id INT PRIMARY KEY, species VARCHAR(255), population INT); | Update the population column for all entries in the animals table where the species is 'Elk' to 2000 | UPDATE animals SET population = 2000 WHERE species = 'Elk'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Manufacturing (product_id INT, material VARCHAR(20), quantity INT, manufacturing_date DATE); INSERT INTO Manufacturing (product_id, material, quantity, manufacturing_date) VALUES (1, 'Recycled Polyester', 50, '2022-01-01'); | What is the total quantity of recycled materials used in manufacturing, grouped by month? | SELECT DATE_FORMAT(manufacturing_date, '%Y-%m') as month, SUM(quantity) as total_quantity FROM Manufacturing WHERE material = 'Recycled Polyester' GROUP BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE RedShieldSales(id INT, contractor VARCHAR(255), region VARCHAR(255), equipment VARCHAR(255), quantity INT);INSERT INTO RedShieldSales(id, contractor, region, equipment, quantity) VALUES (1, 'Red Shield LLC', 'Asia', 'Artillery Systems', 45); | Delete the record for the sale of 'Artillery Systems' to 'Asia' by 'Red Shield LLC' if the sale quantity is less than 50. | DELETE FROM RedShieldSales WHERE contractor = 'Red Shield LLC' AND region = 'Asia' AND equipment = 'Artillery Systems' AND quantity < 50; | gretelai_synthetic_text_to_sql |
CREATE TABLE feedback (citizen_id INT, service_id INT, rating INT); INSERT INTO feedback (citizen_id, service_id, rating) VALUES (1, 123, 5), (2, 123, 4), (3, 123, 5), (4, 456, 3), (5, 456, 4), (6, 456, 5), (7, 789, 5), (8, 789, 5), (9, 789, 4), (10, 111, 5); | Find the top 3 services with the highest average rating | SELECT service_id, AVG(rating) as avg_rating FROM feedback GROUP BY service_id ORDER BY avg_rating DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE ai_applications (app_id INT, app_name VARCHAR(255), algorithm_id INT, is_fair BOOLEAN); INSERT INTO ai_applications (app_id, app_name, algorithm_id, is_fair) VALUES (1, 'App1', 1, true), (2, 'App2', 1, false), (3, 'App3', 2, true), (4, 'App4', 2, true), (5, 'App5', 3, false); | Calculate the percentage of fair AI applications out of the total number of AI applications, per algorithm. | SELECT algorithm_id, AVG(CASE WHEN is_fair THEN 1.0 ELSE 0.0 END) * 100.0 AS fairness_percentage FROM ai_applications GROUP BY algorithm_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE customers (id INT, name VARCHAR(255), country VARCHAR(255), balance DECIMAL(10, 2)); INSERT INTO customers (id, name, country, balance) VALUES (1, 'John Doe', 'Canada', 7000.00), (2, 'Jane Smith', 'Canada', 9000.00); | Update the balance of customers from Canada by 10%. | UPDATE customers SET balance = balance * 1.10 WHERE country = 'Canada'; | gretelai_synthetic_text_to_sql |
CREATE TABLE construction_labor_statistics (job_title VARCHAR(50), wage DECIMAL(5,2), region VARCHAR(50)); | Add a new record to 'construction_labor_statistics' table for the job title 'Electrician' with a wage of 27.50 and region 'South' | INSERT INTO construction_labor_statistics (job_title, wage, region) VALUES ('Electrician', 27.50, 'South'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Genders (gender_id INT, gender_name TEXT); CREATE TABLE CommunityHealthWorkers (worker_id INT, worker_gender INT, country_id INT); | What is the total number of community health workers by gender in the United States? | SELECT COUNT(*) as total_workers, g.gender_name FROM CommunityHealthWorkers chw JOIN Genders g ON chw.worker_gender = g.gender_id WHERE country_id = 1 GROUP BY chw.worker_gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (DonorID int, DonorName varchar(50), Country varchar(50), AmountDonated numeric(18,2)); CREATE TABLE Donations (DonationID int, DonorID int, DonationDate date); INSERT INTO Donors (DonorID, DonorName, Country) VALUES (1, 'John Doe', 'Japan'), (2, 'Jane Smith', 'Canada'); INSERT INTO Donations (DonationID, DonorID, DonationDate) VALUES (1, 1, '2021-01-01'), (2, 2, '2021-01-01'), (3, 1, '2021-03-15'), (4, 1, '2021-05-01'); | What is the number of donations made by donors from Japan in the last quarter? | SELECT COUNT(*) FROM Donations D INNER JOIN Donors DON ON D.DonorID = DON.DonorID WHERE Country = 'Japan' AND DonationDate >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE union_profiles (union_name VARCHAR(30), sector VARCHAR(20)); INSERT INTO union_profiles (union_name, sector) VALUES ('UnionA', 'Transportation'), ('UnionB', 'Transportation'), ('UnionC', 'Education'); | How many unions are there in the 'transportation' sector? | SELECT COUNT(*) FROM union_profiles WHERE sector = 'Transportation'; | gretelai_synthetic_text_to_sql |
CREATE TABLE pacific_plate (trench_name TEXT, location TEXT, average_depth FLOAT); INSERT INTO pacific_plate (trench_name, location, average_depth) VALUES ('Mariana Trench', 'Mariana Islands', 10994.0), ('Tonga Trench', 'Tonga', 10820.0); | What is the average depth of oceanic trenches in the Pacific plate? | SELECT AVG(average_depth) FROM pacific_plate WHERE trench_name = 'Mariana Trench' OR trench_name = 'Tonga Trench'; | gretelai_synthetic_text_to_sql |
CREATE TABLE countries (id INT, name TEXT); CREATE TABLE products (id INT, country_of_origin_id INT, is_non_gmo BOOLEAN, category TEXT, price FLOAT); CREATE TABLE sales (id INT, product_id INT, quantity INT); INSERT INTO countries (id, name) VALUES (1, 'USA'), (2, 'Mexico'), (3, 'Brazil'), (4, 'Canada'); INSERT INTO products (id, country_of_origin_id, is_non_gmo, category, price) VALUES (1, 1, true, 'fruit', 3.5), (2, 1, false, 'fruit', 2.5), (3, 2, true, 'fruit', 4.0), (4, 2, false, 'fruit', 3.0), (5, 3, true, 'vegetable', 1.5), (6, 4, false, 'vegetable', 1.0); INSERT INTO sales (id, product_id, quantity) VALUES (1, 1, 100), (2, 2, 75), (3, 3, 60), (4, 4, 80), (5, 5, 100), (6, 6, 120); | What is the average price of non-GMO fruits by country of origin? | SELECT c.name AS country_name, AVG(p.price) AS avg_price FROM products p JOIN countries c ON p.country_of_origin_id = c.id WHERE p.is_non_gmo = true GROUP BY c.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE gold_mines (id INT, name TEXT, country TEXT, depth FLOAT); INSERT INTO gold_mines (id, name, country, depth) VALUES (1, 'Gold Mine 1', 'Mexico', 1200.5); INSERT INTO gold_mines (id, name, country, depth) VALUES (2, 'Gold Mine 2', 'Mexico', 1500.3); | What is the average depth of all gold mines in the country "Mexico"? | SELECT AVG(depth) FROM gold_mines WHERE country = 'Mexico'; | gretelai_synthetic_text_to_sql |
CREATE TABLE initiatives (initiative_id INT, initiative_name VARCHAR(100), state VARCHAR(50));CREATE TABLE funding_sources (source_id INT, source_name VARCHAR(100), state VARCHAR(50));CREATE TABLE initiative_funding (funding_id INT, initiative_id INT, source_id INT, amount INT, year INT); | List all the water conservation initiatives in Texas along with their respective funding sources and the total amount of funds allocated for each initiative in 2021. | SELECT i.initiative_name, fs.source_name, SUM(if.amount) AS total_funding FROM initiatives i INNER JOIN initiative_funding if ON i.initiative_id = if.initiative_id INNER JOIN funding_sources fs ON if.source_id = fs.source_id WHERE i.state = 'Texas' AND if.year = 2021 GROUP BY i.initiative_name, fs.source_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_finance_lac (id INT, project VARCHAR(50), location VARCHAR(50), amount FLOAT); INSERT INTO climate_finance_lac (id, project, location, amount) VALUES (1, 'Adaptation Project', 'Latin America and Caribbean', 7000000.0); INSERT INTO climate_finance_lac (id, project, location, amount) VALUES (2, 'Mitigation Project', 'Latin America and Caribbean', 8000000.0); INSERT INTO climate_finance_lac (id, project, location, amount) VALUES (3, 'Communication Project', 'Europe', 4000000.0); INSERT INTO climate_finance_lac (id, project, location, amount) VALUES (4, 'Climate Finance Project', 'North America', 2000000.0); | What is the total climate finance committed to climate adaptation projects in the Latin America and Caribbean region? | SELECT SUM(amount) FROM climate_finance_lac WHERE location = 'Latin America and Caribbean' AND project = 'Adaptation Project'; | gretelai_synthetic_text_to_sql |
CREATE TABLE drugs (id INT, name VARCHAR(255), category_id INT); INSERT INTO drugs (id, name, category_id) VALUES (101, 'Paracetamol', 1), (102, 'Ibuprofen', 1), (103, 'Prozac', 2), (104, 'Zoloft', 2); CREATE TABLE sales (drug_id INT, category_id INT, amount INT); INSERT INTO sales (drug_id, category_id, amount) VALUES (101, 1, 5000), (102, 1, 7000), (103, 2, 3000), (104, 2, 4000); | List the drug names and their sales for a specific category. | SELECT d.name, s.amount FROM drugs d JOIN sales s ON d.id = s.drug_id WHERE d.category_id = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE cultural_heritage_sites (site_id INT, site_name VARCHAR(50), location VARCHAR(50)); INSERT INTO cultural_heritage_sites (site_id, site_name, location) VALUES (101, 'Petra', 'Jordan'), (102, 'Colosseum', 'Italy'), (103, 'Machu Picchu', 'Peru'), (104, 'Taj Mahal', 'India'), (105, 'Istanbul Bazaar', 'Turkey'); | Delete all cultural heritage sites from the database that are located in the Middle East. | DELETE FROM cultural_heritage_sites WHERE location = 'Turkey'; | gretelai_synthetic_text_to_sql |
CREATE TABLE publications (publication_id INT, title VARCHAR(50), journal VARCHAR(50)); INSERT INTO publications VALUES (1, 'Paper 1', 'Journal of Computer Science'); INSERT INTO publications VALUES (2, 'Paper 2', 'Journal of Computer Science'); INSERT INTO publications VALUES (3, 'Paper 3', 'IEEE Transactions on Pattern Analysis and Machine Intelligence'); | Delete all papers published in a given journal. | DELETE FROM publications WHERE journal = 'Journal of Computer Science'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Charging_Stations (country VARCHAR(50), quantity INT); INSERT INTO Charging_Stations (country, quantity) VALUES ('Spain', 3000); | How many electric vehicle charging stations are there in Spain? | SELECT MAX(quantity) FROM Charging_Stations WHERE country = 'Spain'; | gretelai_synthetic_text_to_sql |
CREATE TABLE technology_scores (country VARCHAR(50), region VARCHAR(20), score INT); INSERT INTO technology_scores (country, region, score) VALUES ('Nigeria', 'Africa', 70), ('Egypt', 'Africa', 80), ('South Africa', 'Africa', 90), ('Kenya', 'Africa', 75), ('Ethiopia', 'Africa', 60); | List the top 3 countries with the highest technology accessibility score in Africa. | SELECT country, score FROM technology_scores WHERE region = 'Africa' ORDER BY score DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE green_buildings (building_name TEXT, city TEXT, floor_area INTEGER); INSERT INTO green_buildings (building_name, city, floor_area) VALUES ('Green Tower', 'Toronto', 20000); | How many green buildings are there in the city of Toronto, and what is their total floor area? | SELECT COUNT(*), SUM(floor_area) FROM green_buildings WHERE city = 'Toronto'; | gretelai_synthetic_text_to_sql |
CREATE TABLE CityE_ScooterRides (ride_id INT, vehicle_type VARCHAR(20), is_electric BOOLEAN, trip_distance FLOAT); INSERT INTO CityE_ScooterRides (ride_id, vehicle_type, is_electric, trip_distance) VALUES (1, 'Scooter', true, 2.1), (2, 'Scooter', false, 3.6), (3, 'Scooter', true, 1.9), (4, 'Bike', false, 5.8); | What is the total number of trips made by electric scooters in CityE? | SELECT COUNT(*) FROM CityE_ScooterRides WHERE vehicle_type = 'Scooter' AND is_electric = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE explainable_ai_papers (author_id INT, author_name VARCHAR(255), paper_title VARCHAR(255), num_citations INT); INSERT INTO explainable_ai_papers (author_id, author_name, paper_title, num_citations) VALUES ('1', 'Jane Smith', 'Explainable AI: A Survey', '100'); | Who are the top 3 contributing authors in explainable AI area? | SELECT author_name, SUM(num_citations) as total_citations FROM explainable_ai_papers GROUP BY author_name ORDER BY total_citations DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE investment_strategies_extended (strategy_id INT, strategy_description TEXT); INSERT INTO investment_strategies_extended (strategy_id, strategy_description) VALUES (1, 'Impact first investing'), (2, 'Financial first investing with diversity and inclusion focus'), (3, 'Diversified investing with gender equality'); | List all the unique investment strategies that prioritize 'diversity and inclusion' in their descriptions. | SELECT DISTINCT strategy_id, strategy_description FROM investment_strategies_extended WHERE strategy_description LIKE '%diversity%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists nonprofits (id INT PRIMARY KEY, name TEXT, field TEXT, location TEXT, annual_budget DECIMAL(10,2)); INSERT INTO nonprofits (id, name, field, location, annual_budget) VALUES (1, 'Art for All', 'Arts & Culture', 'London', 150000.00); | What's the number of nonprofits and the total annual budget for nonprofits in the 'Arts & Culture' field? | SELECT field, COUNT(id) AS number_of_nonprofits, SUM(annual_budget) AS total_annual_budget FROM nonprofits GROUP BY field HAVING field = 'Arts & Culture'; | gretelai_synthetic_text_to_sql |
CREATE TABLE mining_operations (id INT, name TEXT, location TEXT, water_consumption FLOAT); INSERT INTO mining_operations (id, name, location, water_consumption) VALUES (1, 'Operation A', 'Canada-AB', 12000), (2, 'Operation B', 'Canada-BC', 15000), (3, 'Operation C', 'Canada-AB', 18000); | What is the average water consumption per mining operation in Canada, partitioned by province? | SELECT location, AVG(water_consumption) FROM mining_operations WHERE location LIKE 'Canada-%' GROUP BY location; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (id INT, donor_name VARCHAR(100), donation_amount DECIMAL(10,2), donation_date DATE, event_id INT, continent VARCHAR(50)); | What is the total donation amount by continent, for the year 2019? | SELECT continent, SUM(donation_amount) as total_donations FROM Donations WHERE DATE_TRUNC('year', donation_date) = DATE_TRUNC('year', '2019-01-01') GROUP BY continent; | 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.