context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28 values |
|---|---|---|---|
CREATE TABLE customers (id INT, name VARCHAR(255), credit_score INT, investment_risk VARCHAR(255)); INSERT INTO customers (id, name, credit_score, investment_risk) VALUES (1, 'Alice', 700, 'high'), (2, 'Bob', 650, 'medium'), (3, 'Charlie', 800, 'low'), (4, 'Diana', 600, 'high'); | What is the average credit score of customers with high-risk investment portfolios? | SELECT AVG(c.credit_score) FROM customers c WHERE c.investment_risk = 'high'; | gretelai_synthetic_text_to_sql |
CREATE TABLE social_impact_bonds (id INT, organization_name VARCHAR(255), sector VARCHAR(255), issue_year INT, value FLOAT); INSERT INTO social_impact_bonds (id, organization_name, sector, issue_year, value) VALUES (1, 'Acme Corp', 'Technology', 2018, 2000000), (2, 'XYZ Foundation', 'Healthcare', 2019, 3000000), (3, 'Global Giving', 'Education', 2018, 1500000), (4, 'Tech for Good', 'Technology', 2019, 2500000), (5, 'Medical Research Institute', 'Healthcare', 2018, 1000000); | What is the total value of social impact bonds issued by organizations in the technology sector? | SELECT sector, SUM(value) as total_value FROM social_impact_bonds WHERE sector = 'Technology' GROUP BY sector; | gretelai_synthetic_text_to_sql |
CREATE TABLE satellite_deployment (id INT PRIMARY KEY, country VARCHAR(100), launch_date DATE, satellite_name VARCHAR(100)); | Display the total number of satellites launched by each country in descending order from the satellite_deployment table | SELECT country, COUNT(*) as total_launches FROM satellite_deployment GROUP BY country ORDER BY total_launches DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE satellites (id INT, country VARCHAR(255), launch_date DATE); | What is the percentage of satellites launched by the US out of the total number of satellites launched? | SELECT (US_launches * 100.0 / total_launches) AS percentage FROM (SELECT COUNT(*) AS US_launches FROM satellites WHERE country = 'US') AS subquery1, (SELECT COUNT(*) AS total_launches FROM satellites) AS subquery2; | gretelai_synthetic_text_to_sql |
CREATE TABLE cases (id INT PRIMARY KEY, case_number VARCHAR(50), date_reported DATE, status VARCHAR(10)); | Create a view for 'open_cases' | CREATE VIEW open_cases AS SELECT * FROM cases WHERE status = 'open'; | gretelai_synthetic_text_to_sql |
CREATE TABLE public.judges (id SERIAL PRIMARY KEY, name VARCHAR(255), age INT, ethnicity VARCHAR(255), appointment_date DATE); CREATE TABLE public.cases (id SERIAL PRIMARY KEY, judge_id INT, case_number VARCHAR(255), case_date DATE, case_type VARCHAR(255), court_location VARCHAR(255)); | What is the average time taken for cases to be resolved for each ethnicity of judges? | SELECT j.ethnicity, AVG(c.case_date - j.appointment_date) as average_time_to_resolve FROM public.judges j JOIN public.cases c ON j.id = c.judge_id GROUP BY j.ethnicity; | gretelai_synthetic_text_to_sql |
CREATE TABLE customers (customer_id INT, customer_name VARCHAR(50), country VARCHAR(50), sustainable_fashion BOOLEAN); INSERT INTO customers VALUES (1, 'Customer A', 'Canada', true); INSERT INTO customers VALUES (2, 'Customer B', 'Canada', false); INSERT INTO customers VALUES (3, 'Customer C', 'Canada', true); INSERT INTO customers VALUES (4, 'Customer D', 'Canada', true); INSERT INTO customers VALUES (5, 'Customer E', 'Canada', false); | What is the percentage of customers in Canada who prefer sustainable fashion, and how many customers are there in total? | SELECT (COUNT(*) FILTER (WHERE sustainable_fashion = true)) * 100.0 / COUNT(*) as percentage, COUNT(*) as total_customers FROM customers WHERE country = 'Canada'; | gretelai_synthetic_text_to_sql |
CREATE TABLE security_incidents (id INT, sector VARCHAR(20), incident VARCHAR(50)); INSERT INTO security_incidents (id, sector, incident) VALUES (1, 'Education', 'Phishing Attack'); | What is the total number of security incidents in the education sector? | SELECT COUNT(*) FROM security_incidents WHERE sector = 'Education'; | gretelai_synthetic_text_to_sql |
CREATE TABLE solar(id INT, project_name VARCHAR(50), capacity_mw FLOAT, country VARCHAR(50));CREATE TABLE solar_farms(id INT, project_name VARCHAR(50), capacity_mw FLOAT, country VARCHAR(50)); | What are the total installed solar capacities for projects in the solar and solar_farms tables, grouped by country? | SELECT s.country, SUM(s.capacity_mw + sf.capacity_mw) AS total_capacity FROM solar s INNER JOIN solar_farms sf ON s.project_name = sf.project_name GROUP BY s.country; | gretelai_synthetic_text_to_sql |
CREATE TABLE materials (material_id INT, is_recycled BOOLEAN); INSERT INTO materials (material_id, is_recycled) VALUES (1, TRUE), (2, FALSE); CREATE TABLE production (production_id INT, material_id INT, quantity INT); INSERT INTO production (production_id, material_id, quantity) VALUES (1, 1, 100), (2, 2, 50); | Get the total quantity of recycled materials used in production | SELECT SUM(production.quantity) FROM production INNER JOIN materials ON production.material_id = materials.material_id WHERE materials.is_recycled = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (DonorID INT, DonorName TEXT, DonationAmount DECIMAL, DonationDate DATE); INSERT INTO Donors (DonorID, DonorName, DonationAmount, DonationDate) VALUES (1, 'John Doe', 50.00, '2022-01-01'), (2, 'Jane Smith', 100.00, '2022-01-05'), (3, 'Mike Johnson', 75.00, '2022-01-10'), (4, 'Sara Brown', 150.00, '2022-01-15'), (5, 'David Williams', 25.00, '2022-01-20'), (1, 'John Doe', 75.00, '2022-02-01'), (2, 'Jane Smith', 50.00, '2022-02-05'), (3, 'Mike Johnson', 100.00, '2022-02-10'), (4, 'Sara Brown', 25.00, '2022-02-15'), (5, 'David Williams', 150.00, '2022-02-20'); | What is the average donation amount per month for a specific donor? | SELECT DonorName, AVG(DonationAmount) AS AverageDonationAmount FROM Donors GROUP BY DonorName, DATE_TRUNC('month', DonationDate) ORDER BY DonorName; | gretelai_synthetic_text_to_sql |
CREATE TABLE employees (id INT, name VARCHAR(50), department VARCHAR(50), salary FLOAT); INSERT INTO employees (id, name, department, salary) VALUES (1, 'John Doe', 'IT', 85000.00), (2, 'Jane Smith', 'HR', 68000.00), (3, 'Alice Johnson', 'IT', 90000.00); | What is the minimum salary for employees? | SELECT MIN(salary) FROM employees; | gretelai_synthetic_text_to_sql |
CREATE TABLE ports (port_id INT, port_name VARCHAR(20)); INSERT INTO ports VALUES (1, 'Seattle'), (2, 'New_York'); CREATE TABLE cargo (cargo_id INT, port_id INT, container_weight FLOAT); INSERT INTO cargo VALUES (1, 1, 2000.5), (2, 1, 3000.2), (3, 2, 1500.3); | What is the average weight of containers handled by port 'Seattle'? | SELECT AVG(container_weight) FROM cargo WHERE port_id = (SELECT port_id FROM ports WHERE port_name = 'Seattle'); | gretelai_synthetic_text_to_sql |
CREATE TABLE shariah_compliant_finance (id INT, country VARCHAR(255), asset_value DECIMAL(10,2)); | What is the sum of all Shariah-compliant finance assets in the African continent? | SELECT SUM(asset_value) FROM shariah_compliant_finance WHERE country IN (SELECT country FROM (SELECT DISTINCT country FROM shariah_compliant_finance WHERE region = 'Africa') t); | gretelai_synthetic_text_to_sql |
CREATE TABLE Highways (id INT, name TEXT, location TEXT, state TEXT, lanes INT); INSERT INTO Highways (id, name, location, state, lanes) VALUES (1, 'Highway A', 'Location A', 'Florida', 4), (2, 'Highway B', 'Location B', 'Georgia', 6); | What is the minimum number of lanes for highways in Florida? | SELECT MIN(lanes) FROM Highways WHERE state = 'Florida'; | gretelai_synthetic_text_to_sql |
CREATE TABLE posts (id INT, user_id INT, post_date DATE, post_text VARCHAR(255)); CREATE TABLE users (id INT, country VARCHAR(50)); | What is the maximum number of unique hashtags used in a single post by users in India? | SELECT MAX(hashtag_cnt) FROM (SELECT COUNT(DISTINCT hashtag) hashtag_cnt FROM (SELECT user_id, TRIM(LEADING '#' FROM SPLIT_PART(post_text, ' ', n)) hashtag FROM posts, GENERATE_SERIES(1, ARRAY_LENGTH(STRING_TO_ARRAY(post_text, ' '))) n WHERE user_id IN (SELECT id FROM users WHERE country = 'India')) t GROUP BY user_id) s; | gretelai_synthetic_text_to_sql |
CREATE TABLE MiningOperations (OperationID INT, OperationName VARCHAR(50), Country VARCHAR(50), ProductionRate FLOAT); INSERT INTO MiningOperations (OperationID, OperationName, Country, ProductionRate) VALUES (1, 'Operation A', 'Canada', 5000); INSERT INTO MiningOperations (OperationID, OperationName, Country, ProductionRate) VALUES (2, 'Operation B', 'USA', 7000); | What is the total production rate of mining operations located in the Americas region? | SELECT SUM(ProductionRate) FROM MiningOperations WHERE Country IN (SELECT Country FROM Countries WHERE Region = 'Americas'); | gretelai_synthetic_text_to_sql |
CREATE TABLE coral_reefs (id INT, name VARCHAR(255), avg_depth FLOAT, region VARCHAR(255)); INSERT INTO coral_reefs (id, name, avg_depth, region) VALUES (1, 'Elkhorn Reef', 15, 'Caribbean'); | What is the minimum depth at which coral reefs are found in the Caribbean Sea? | SELECT MIN(avg_depth) FROM coral_reefs WHERE region = 'Caribbean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Policyholders (PolicyholderID INT, Country VARCHAR(50), Cancelled BOOLEAN, CancellationDate DATE); INSERT INTO Policyholders VALUES (1, 'Brazil', TRUE, '2022-01-01'); INSERT INTO Policyholders VALUES (2, 'Brazil', FALSE, '2022-01-15'); INSERT INTO Policyholders VALUES (3, 'Brazil', FALSE, '2022-02-01'); | Calculate the policy cancellation rate for policyholders from Brazil, calculated as the percentage of policyholders who cancelled their policies within the first month, for each month. | SELECT EXTRACT(MONTH FROM CancellationDate) AS Month, COUNT(*) * 100.0 / SUM(CASE WHEN EXTRACT(MONTH FROM CancellationDate) = EXTRACT(MONTH FROM CancellationDate) THEN 1 ELSE 0 END) OVER (PARTITION BY EXTRACT(MONTH FROM CancellationDate)) AS PolicyCancellationRate FROM Policyholders WHERE Country = 'Brazil' AND FirstMonth = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE water_treatment_plant (plant_id INT, state VARCHAR(50), year INT, month INT, water_consumption FLOAT); INSERT INTO water_treatment_plant (plant_id, state, year, month, water_consumption) VALUES (13, 'California', 2022, 7, 12345.6), (14, 'California', 2022, 7, 23456.7), (15, 'California', 2022, 7, 34567.8); | What is the total water consumption by each water treatment plant in the state of California in the month of July in the year 2022? | SELECT plant_id, SUM(water_consumption) as total_water_consumption FROM water_treatment_plant WHERE state = 'California' AND year = 2022 AND month = 7 GROUP BY plant_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE certified_suppliers (id INT, certification VARCHAR(20), region VARCHAR(20)); INSERT INTO certified_suppliers (id, certification, region) VALUES (1, 'Fair Trade', 'Oceania'), (2, 'GOTS', 'Europe'), (3, 'Fair Trade', 'Oceania'); | Determine the number of fair trade certified suppliers in Oceania. | SELECT COUNT(*) FROM certified_suppliers WHERE certification = 'Fair Trade' AND region = 'Oceania'; | gretelai_synthetic_text_to_sql |
CREATE TABLE sustainable_materials (material_id INT, material TEXT, co2_emissions FLOAT); | Which sustainable materials have a lower CO2 emissions than linen in the 'sustainable_materials' table? | SELECT * FROM sustainable_materials WHERE co2_emissions < (SELECT co2_emissions FROM sustainable_materials WHERE material = 'linen'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Spacecraft (name VARCHAR(30), duration INT); INSERT INTO Spacecraft (name, duration) VALUES ('Voyager 1', 43827), ('Voyager 2', 42554); | What is the name of the spacecraft with the longest duration in space? | SELECT name FROM Spacecraft ORDER BY duration DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Weight_Tracking (id INT, user_id INT, date DATE, weight_lost INT); INSERT INTO Weight_Tracking (id, user_id, date, weight_lost) VALUES (1, 1, '2021-10-01', 2), (2, 2, '2021-11-01', 3), (3, 3, '2021-11-02', 4), (4, 4, '2021-11-03', 5), (5, 5, '2021-11-04', 6), (6, 1, '2021-11-05', 1), (7, 2, '2021-11-06', 2), (8, 3, '2021-11-07', 3), (9, 4, '2021-11-08', 4), (10, 5, '2021-11-09', 5); | Calculate the total weight lost by users who have joined in the past 3 months. | SELECT SUM(weight_lost) FROM Weight_Tracking wt JOIN Memberships m ON wt.user_id = m.user_id WHERE m.start_date >= DATEADD(MONTH, -3, CURRENT_DATE); | gretelai_synthetic_text_to_sql |
CREATE TABLE Organizations (id INT, organization_name TEXT, country TEXT); CREATE TABLE Organization_Donations (organization_id INT, cause_id INT, donation_amount DECIMAL(10, 2), donation_date DATE); CREATE TABLE Causes (id INT, cause_name TEXT, cause_category TEXT); | What was the total amount donated by organizations based in Germany to education-focused causes in 2019? | SELECT SUM(od.donation_amount) FROM Organization_Donations od JOIN Organizations o ON od.organization_id = o.id WHERE o.country = 'Germany' AND EXTRACT(YEAR FROM od.donation_date) = 2019 AND od.cause_id IN (SELECT id FROM Causes WHERE cause_category = 'Education'); | gretelai_synthetic_text_to_sql |
CREATE TABLE cosmetics (product_id INT, product_name VARCHAR(50), is_organic BOOLEAN, has_recycling_program BOOLEAN, rating FLOAT); | What is the average rating of organic cosmetics with a recycling program? | SELECT AVG(rating) FROM cosmetics WHERE is_organic = TRUE AND has_recycling_program = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE agricultural_innovation (country VARCHAR(50), project_name VARCHAR(50), project_start_date DATE); | What are the top 3 countries with the most agricultural innovation projects in the last 5 years, and how many projects are there in each country? | SELECT country, COUNT(*) as project_count FROM agricultural_innovation WHERE project_start_date >= DATEADD(year, -5, GETDATE()) GROUP BY country ORDER BY project_count DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE manufacturer (id INT, name VARCHAR(255)); INSERT INTO manufacturer (id, name) VALUES (1, 'Lockheed Martin'); CREATE TABLE aircraft (id INT, name VARCHAR(255), manufacturer_id INT); INSERT INTO aircraft (id, name, manufacturer_id) VALUES (1, 'F-35', 1), (2, 'F-16', 1); | What is the total number of military aircrafts manufactured by Lockheed Martin? | SELECT COUNT(*) FROM aircraft WHERE manufacturer_id = (SELECT id FROM manufacturer WHERE name = 'Lockheed Martin'); | gretelai_synthetic_text_to_sql |
CREATE TABLE impact (id INT PRIMARY KEY, site_id INT, impact_score INT); | Delete environmental impact records for site 2 | DELETE FROM impact WHERE site_id = 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE athlete_performance (athlete_id INT, name VARCHAR(50), age INT, position VARCHAR(50)); INSERT INTO athlete_performance (athlete_id, name, age, position) VALUES (1, 'John Doe', 25, 'Goalie'); INSERT INTO athlete_performance (athlete_id, name, age, position) VALUES (2, 'Jane Smith', 30, 'Forward'); | What is the average age of athletes in the 'athlete_performance' table? | SELECT AVG(age) FROM athlete_performance; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA fitness; CREATE TABLE memberships (id INT, member_name VARCHAR(50), start_date DATE, end_date DATE, membership_type VARCHAR(50), price DECIMAL(5, 2)); INSERT INTO memberships VALUES (1, 'John Doe', '2022-01-01', '2022-03-31', 'Premium', 50.00), (2, 'Jane Smith', '2022-01-15', '2022-06-30', 'Basic', 25.00); | What was the total revenue generated from memberships in the first quarter of 2022?' | SELECT SUM(price) FROM fitness.memberships WHERE start_date <= '2022-03-31' AND end_date >= '2022-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE animals (animal_id SERIAL PRIMARY KEY, name VARCHAR(255)); | Insert data into the "animals" table from the previous row | INSERT INTO animals (name) VALUES ('Lion'), ('Tiger'), ('Bear'); | gretelai_synthetic_text_to_sql |
CREATE TABLE aircraft_produced (aircraft_id INT, manufacturer VARCHAR(50)); | Who are the top 5 manufacturers with the most aircraft produced? | SELECT manufacturer, COUNT(aircraft_id) as num_aircraft FROM aircraft_produced GROUP BY manufacturer ORDER BY num_aircraft DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_projects (id INT PRIMARY KEY, title VARCHAR(255), description TEXT, start_date DATE, end_date DATE, funding_source VARCHAR(255)); INSERT INTO climate_projects (id, title, description, start_date, end_date, funding_source) VALUES (1, 'Solar Farm Construction', 'Construction of a 100 MW solar farm.', '2022-01-01', '2022-12-31', 'Government Grant'), (2, 'Wind Turbine Installation', 'Installation of wind turbines for a community.', '2022-04-01', '2023-03-31', 'Private Investment'); | What climate mitigation projects have been funded by the private sector? | SELECT * FROM climate_projects WHERE funding_source = 'Private Investment'; | gretelai_synthetic_text_to_sql |
CREATE TABLE waste_generation_by_area (id INT, country VARCHAR(255), area VARCHAR(255), year INT, amount INT); INSERT INTO waste_generation_by_area (id, country, area, year, amount) VALUES (1, 'India', 'Urban', 2015, 10000), (2, 'India', 'Rural', 2015, 8000), (3, 'India', 'Urban', 2016, 11000), (4, 'India', 'Rural', 2016, 9000); | What is the waste generation in urban and rural areas in India, grouped by year? | SELECT area, year, SUM(amount) as total_waste FROM waste_generation_by_area WHERE country = 'India' GROUP BY area, year; | gretelai_synthetic_text_to_sql |
CREATE TABLE Teachers (TeacherID INT PRIMARY KEY, Mentor BOOLEAN, Hours INT); INSERT INTO Teachers (TeacherID, Mentor, Hours) VALUES (1, 1, 20); | What is the average number of hours of professional development completed by teachers who are also mentors? | SELECT AVG(Hours) FROM Teachers WHERE Mentor = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE product_transparency (product_id INT, product_name VARCHAR(50), circular_supply_chain BOOLEAN, recycled_content DECIMAL(4,2), COUNTRY VARCHAR(50)); | What is the average 'recycled_content' for 'product_transparency' records from 'India'? | SELECT AVG(recycled_content) FROM product_transparency WHERE country = 'India'; | gretelai_synthetic_text_to_sql |
CREATE TABLE humanitarian_assistance (assistance_id INT, donor TEXT, recipient TEXT, amount DECIMAL(10,2), date DATE); INSERT INTO humanitarian_assistance (assistance_id, donor, recipient, amount, date) VALUES (1, 'USA', 'Somalia', 200000, '2020-04-01'), (2, 'Germany', 'Nigeria', 300000, '2019-05-01'); | Who are the top 2 contributors of humanitarian assistance to African countries in the last 2 years? | SELECT humanitarian_assistance.donor, SUM(humanitarian_assistance.amount) as total_assistance FROM humanitarian_assistance WHERE humanitarian_assistance.recipient LIKE 'Africa%' AND humanitarian_assistance.date BETWEEN DATE_SUB(CURDATE(), INTERVAL 2 YEAR) AND CURDATE() GROUP BY humanitarian_assistance.donor ORDER BY total_assistance DESC LIMIT 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE ResponseTimes (ID INT, Service VARCHAR(50), Day VARCHAR(15), Time INT); INSERT INTO ResponseTimes (ID, Service, Day, Time) VALUES (5, 'Fire', 'Monday', 7), (6, 'Fire', 'Tuesday', 6), (7, 'Ambulance', 'Wednesday', 8), (8, 'Ambulance', 'Thursday', 7), (9, 'Police', 'Friday', 9), (10, 'Police', 'Saturday', 8); | What is the average response time for emergency services, categorized by day of the week, for the current month? | SELECT Service, AVG(Time) OVER (PARTITION BY Service ORDER BY Day) AS AvgResponseTime FROM ResponseTimes WHERE Day IN (SELECT TO_CHAR(Date, 'Day') FROM generate_series(DATE_TRUNC('month', CURRENT_DATE), CURRENT_DATE, '1 day') Date); | gretelai_synthetic_text_to_sql |
CREATE TABLE subscriber_data (subscriber_id INT, subscriber_type VARCHAR(10), data_usage FLOAT, region VARCHAR(20)); INSERT INTO subscriber_data (subscriber_id, subscriber_type, data_usage, region) VALUES (1, 'postpaid', 3.5, 'East'), (2, 'prepaid', 4.2, 'West'), (3, 'postpaid', 200.5, 'North'), (4, 'prepaid', 3.8, 'South'), (5, 'postpaid', 250.0, 'East'); | What is the average monthly data usage for postpaid and prepaid mobile subscribers in the region of East? | SELECT subscriber_type, AVG(data_usage) FROM subscriber_data WHERE region = 'East' GROUP BY subscriber_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE attorneys (attorney_id INT, attorney_name TEXT, office_location TEXT); INSERT INTO attorneys (attorney_id, attorney_name, office_location) VALUES (1, 'John Doe', 'San Francisco'), (2, 'Jane Smith', 'New York'); CREATE TABLE cases (case_id INT, attorney_id INT, billable_hours INT); INSERT INTO cases (case_id, attorney_id, billable_hours) VALUES (1, 1, 10), (2, 1, 15), (3, 2, 20), (4, 2, 25); | What is the average billable hours per case for attorneys in the New York office? | SELECT AVG(c.billable_hours) as avg_billable_hours FROM attorneys a JOIN cases c ON a.attorney_id = c.attorney_id WHERE a.office_location = 'New York'; | gretelai_synthetic_text_to_sql |
CREATE TABLE digital_assets (asset_id INT, asset_name VARCHAR(255), network VARCHAR(255)); INSERT INTO digital_assets (asset_id, asset_name, network) VALUES (1, 'ETH', 'Ethereum'), (2, 'DAI', 'Ethereum'); CREATE TABLE transactions (transaction_id INT, asset_id INT, transaction_time TIMESTAMP); INSERT INTO transactions (transaction_id, asset_id) VALUES (1, 1), (2, 1), (3, 2), (4, 1), (5, 2); | What is the total number of transactions and their combined volume for each digital asset on the Ethereum network, grouped by month? | SELECT DATE_FORMAT(transaction_time, '%Y-%m') AS month, asset_name, COUNT(*) AS transactions, SUM(1) AS volume FROM transactions JOIN digital_assets ON transactions.asset_id = digital_assets.asset_id GROUP BY month, asset_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (id INT, state VARCHAR(50), quarter VARCHAR(10), strain VARCHAR(50)); | How many unique strains were sold in the state of Colorado in Q2 2022? | SELECT COUNT(DISTINCT strain) FROM sales WHERE state = 'Colorado' AND quarter = 'Q2'; | gretelai_synthetic_text_to_sql |
CREATE TABLE market_trends (element VARCHAR(255), price DECIMAL(10,2), quantity INT); INSERT INTO market_trends (element, price, quantity) VALUES ('Neodymium', 92.50, 5000), ('Praseodymium', 85.20, 3000), ('Dysprosium', 120.00, 2000); | List all the distinct rare earth elements in the market trends data. | SELECT DISTINCT element FROM market_trends; | gretelai_synthetic_text_to_sql |
CREATE TABLE articles (article_id INT PRIMARY KEY, title VARCHAR(255), content TEXT, publish_date DATE); CREATE TABLE ethics (ethics_id INT PRIMARY KEY, article_id INT, ethical_issue VARCHAR(255), resolution TEXT); | Get all articles with their corresponding media ethics information from 'articles' and 'ethics' tables | SELECT articles.title, ethics.ethical_issue FROM articles LEFT JOIN ethics ON articles.article_id = ethics.article_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Operations (Company VARCHAR(50), Operation VARCHAR(50), Location VARCHAR(10)); INSERT INTO Operations (Company, Operation, Location) VALUES ('GHI Mines', 'Coal', 'Asia'), ('JKL Mining', 'Gold', 'Australia'), ('MNO Drilling', 'Oil', 'Pacific'); | What are the different mining operations in the Asia-Pacific region? | SELECT DISTINCT Operation FROM Operations WHERE Location LIKE 'Asia%' OR Location LIKE 'Pacific%' | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (id INT, name VARCHAR(50)); CREATE TABLE donations (id INT, donor_id INT, amount DECIMAL(10,2)); | List all donations and their corresponding donor names | SELECT donors.name, donations.amount FROM donors JOIN donations ON donors.id = donations.donor_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE deep_sea_temperature_southern (location text, temperature numeric); INSERT INTO deep_sea_temperature_southern (location, temperature) VALUES ('Southern Ocean', -2), ('Atlantic Ocean', 25); | What is the maximum temperature recorded in the Southern Ocean? | SELECT MAX(temperature) FROM deep_sea_temperature_southern WHERE location = 'Southern Ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (id INT, name TEXT, country TEXT, amount_donated DECIMAL(10,2)); | What is the average amount donated per donor from the United States in the year 2021? | SELECT AVG(amount_donated) FROM donors WHERE country = 'United States' AND YEAR(donation_date) = 2021 AND id NOT IN (SELECT id FROM organizations); | gretelai_synthetic_text_to_sql |
CREATE TABLE fish_farms (id INT, name TEXT, country TEXT, latitude DECIMAL(9,6), longitude DECIMAL(9,6)); INSERT INTO fish_farms (id, name, country, latitude, longitude) VALUES (1, 'Farm X', 'Indonesia', -8.123456, 114.78901); INSERT INTO fish_farms (id, name, country, latitude, longitude) VALUES (2, 'Farm Y', 'Indonesia', -7.54321, 113.23456); CREATE TABLE water_quality (date DATE, farm_id INT, dissolved_oxygen DECIMAL(5,2)); INSERT INTO water_quality (date, farm_id, dissolved_oxygen) VALUES ('2022-01-01', 1, 5.8); INSERT INTO water_quality (date, farm_id, dissolved_oxygen) VALUES ('2022-01-01', 2, 6.2); | What is the minimum dissolved oxygen level recorded for fish farms in Indonesia? | SELECT MIN(dissolved_oxygen) FROM water_quality wq JOIN fish_farms ff ON wq.farm_id = ff.id WHERE ff.country = 'Indonesia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Vendors (VendorID INT, VendorName VARCHAR(50), Country VARCHAR(50)); INSERT INTO Vendors (VendorID, VendorName, Country) VALUES (1, 'GreenVacations', 'Australia'), (2, 'EcoTours', 'New Zealand'), (3, 'SustainableJourneys', 'Fiji'), (4, 'BluePlanetTours', 'USA'); CREATE TABLE Packages (PackageID INT, VendorID INT, PackageType VARCHAR(20), Sales INT); INSERT INTO Packages (PackageID, VendorID, PackageType, Sales) VALUES (1, 1, 'Sustainable', 500), (2, 1, 'Virtual', 300), (3, 2, 'Sustainable', 700), (4, 2, 'Virtual', 600), (5, 3, 'Sustainable', 800), (6, 3, 'Virtual', 400), (7, 4, 'Sustainable', 50), (8, 4, 'Virtual', 60); | What is the total number of sustainable tour packages sold by vendors from Oceania? | SELECT V.Country, SUM(P.Sales) as TotalSales FROM Vendors V INNER JOIN Packages P ON V.VendorID = P.VendorID WHERE V.Country LIKE 'Oceania%' AND P.PackageType = 'Sustainable' GROUP BY V.Country; | gretelai_synthetic_text_to_sql |
CREATE TABLE Hospitals (HospitalID INT, Name VARCHAR(50), Location VARCHAR(50), Region VARCHAR(20)); INSERT INTO Hospitals (HospitalID, Name, Location, Region) VALUES (1, 'Hospital A', 'Location A', 'Rural Alabama'); INSERT INTO Hospitals (HospitalID, Name, Location, Region) VALUES (2, 'Hospital B', 'Location B', 'Rural Georgia'); | What is the total number of hospitals in the "Alabama" and "Georgia" rural regions? | SELECT COUNT(*) FROM Hospitals WHERE Region IN ('Rural Alabama', 'Rural Georgia'); | gretelai_synthetic_text_to_sql |
CREATE TABLE world_cities (city VARCHAR(50), population INT); INSERT INTO world_cities (city, population) VALUES ('New York', 8500000), ('Los Angeles', 4000000), ('Tokyo', 9000000), ('Sydney', 5000000), ('Berlin', 3500000); | Find the top 3 cities with the highest population in the 'world_cities' database. | SELECT city, population FROM world_cities ORDER BY population DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE animals (id INT PRIMARY KEY, name VARCHAR(50), species VARCHAR(50), population INT); | Update the 'population' field for the 'Giant Panda' species in the 'animals' table | UPDATE animals SET population = 1864 WHERE species = 'Giant Panda'; | gretelai_synthetic_text_to_sql |
CREATE TABLE buildings (building_id INT, name VARCHAR(255), city VARCHAR(255), energy_efficiency FLOAT); INSERT INTO buildings (building_id, name, city, energy_efficiency) VALUES (1, 'Building 1', 'Tokyo', 0.5), (2, 'Building 2', 'Tokyo', 0.75), (3, 'Building 3', 'Paris', 1.0), (4, 'Building 4', 'Paris', 1.25); | Show the average energy efficiency (kWh/m^2) of buildings in Paris | SELECT AVG(energy_efficiency) FROM buildings WHERE city = 'Paris'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Companies (id INT, name VARCHAR(255)); INSERT INTO Companies (id, name) VALUES (1, 'CompanyA'), (2, 'CompanyB'), (3, 'CompanyC'); CREATE TABLE Materials (id INT, company_id INT, material VARCHAR(255)); INSERT INTO Materials (id, company_id, material) VALUES (1, 1, 'Organic cotton'), (2, 1, 'Recycled polyester'), (3, 2, 'Organic cotton'), (4, 2, 'Tencel'), (5, 3, 'Organic cotton'), (6, 3, 'Recycled polyester'), (7, 3, 'Hemp'); | Find the number of unique materials used by each company in the circular economy. | SELECT Companies.name, COUNT(DISTINCT Materials.material) AS unique_materials FROM Companies JOIN Materials ON Companies.id = Materials.company_id GROUP BY Companies.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE agri_innovation_tanzania (project VARCHAR(50), country VARCHAR(50), start_year INT, end_year INT, investment FLOAT); INSERT INTO agri_innovation_tanzania (project, country, start_year, end_year, investment) VALUES ('Conservation Agriculture', 'Tanzania', 2015, 2017, 1000000), ('Crop Diversification', 'Tanzania', 2015, 2017, 1500000); | What was the total investment in agricultural innovation projects in Tanzania between 2015 and 2017, and how many were implemented? | SELECT SUM(investment), COUNT(*) FROM agri_innovation_tanzania WHERE country = 'Tanzania' AND start_year BETWEEN 2015 AND 2017 AND end_year BETWEEN 2015 AND 2017; | gretelai_synthetic_text_to_sql |
CREATE TABLE digital_assets (asset_id INT, asset_name VARCHAR(50), network VARCHAR(50)); INSERT INTO digital_assets (asset_id, asset_name, network) VALUES (1, 'Tether', 'ETH'), (2, 'USD Coin', 'ETH'); CREATE TABLE transactions (transaction_id INT, asset_id INT, quantity DECIMAL(10, 2)); INSERT INTO transactions (transaction_id, asset_id, quantity) VALUES (1, 1, 500), (2, 1, 750), (3, 2, 300), (4, 2, 1000); | What is the total number of transactions for each digital asset in the 'ETH' network? | SELECT d.asset_name, SUM(t.quantity) as total_transactions FROM digital_assets d JOIN transactions t ON d.asset_id = t.asset_id WHERE d.network = 'ETH' GROUP BY d.asset_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE academic_papers (id INT, title VARCHAR(50), department VARCHAR(50), publication_year INT); | What is the total number of academic papers published by the Mathematics department in the last 5 years? | SELECT SUM(1) FROM academic_papers WHERE department = 'Mathematics' AND publication_year BETWEEN YEAR(CURRENT_DATE) - 5 AND YEAR(CURRENT_DATE); | gretelai_synthetic_text_to_sql |
CREATE TABLE customers (customer_id INT, service_length INT, plan_type VARCHAR(10)); INSERT INTO customers (customer_id, service_length, plan_type) VALUES (1, 25, 'postpaid'), (2, 18, 'prepaid'); CREATE TABLE plan_types (plan_type VARCHAR(10), retention_rate FLOAT); INSERT INTO plan_types (plan_type, retention_rate) VALUES ('postpaid', 0.85), ('prepaid', 0.75); | What is the retention rate for customers who have been with the company for over 24 months? | SELECT COUNT(c.customer_id) FROM customers c JOIN plan_types pt ON c.plan_type = pt.plan_type WHERE c.service_length > 24 * 12 AND pt.retention_rate = (SELECT MAX(pt.retention_rate) FROM plan_types pt); | gretelai_synthetic_text_to_sql |
CREATE TABLE Regions (id INT, name VARCHAR(255)); INSERT INTO Regions (id, name) VALUES (1, 'Asia'), (2, 'Europe'), (3, 'Africa'), (4, 'North America'), (5, 'South America'); CREATE TABLE Businesses (id INT, region_id INT, type VARCHAR(255), revenue INT); INSERT INTO Businesses (id, region_id, type, revenue) VALUES (1, 1, 'Sustainable', 10000), (2, 1, 'Sustainable', 12000), (3, 2, 'Sustainable', 15000), (4, 2, 'Non-Sustainable', 8000), (5, 3, 'Sustainable', 9000), (6, 3, 'Non-Sustainable', 7000), (7, 4, 'Sustainable', 11000), (8, 4, 'Non-Sustainable', 13000), (9, 5, 'Sustainable', 14000), (10, 5, 'Non-Sustainable', 16000); | What is the total revenue generated by sustainable tourism businesses in Asia in Q1 2023? | SELECT SUM(b.revenue) as total_revenue FROM Businesses b JOIN Regions r ON b.region_id = r.id WHERE r.name = 'Asia' AND b.type = 'Sustainable' AND b.revenue IS NOT NULL AND QUARTER(b.revenue_date) = 1 AND YEAR(b.revenue_date) = 2023; | gretelai_synthetic_text_to_sql |
CREATE TABLE ports (id INT, name TEXT); INSERT INTO ports (id, name) VALUES (1, 'Port of Los Angeles'); CREATE TABLE container_events (id INT, port_id INT, event_date DATE, event_type TEXT, quantity INT); INSERT INTO container_events (id, port_id, event_date, event_type, quantity) VALUES (1, 1, '2022-01-01', 'unload', 500), (2, 1, '2022-01-05', 'load', 300); | How many containers were unloaded at the Port of Los Angeles in January 2022? | SELECT SUM(quantity) FROM container_events WHERE port_id = (SELECT id FROM ports WHERE name = 'Port of Los Angeles') AND event_type = 'unload' AND event_date BETWEEN '2022-01-01' AND '2022-01-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE labor_stats (state VARCHAR(20), occupation VARCHAR(20), number_of_employees INT); INSERT INTO labor_stats (state, occupation, number_of_employees) VALUES ('Florida', 'Construction laborer', 12000); INSERT INTO labor_stats (state, occupation, number_of_employees) VALUES ('Georgia', 'Construction laborer', 9000); | What is the total number of construction laborers in Florida and Georgia combined? | SELECT SUM(number_of_employees) FROM labor_stats WHERE (state = 'Florida' OR state = 'Georgia') AND occupation = 'Construction laborer'; | gretelai_synthetic_text_to_sql |
CREATE TABLE workers (id INT, name VARCHAR(50), department VARCHAR(50)); INSERT INTO workers (id, name, department) VALUES (1, 'Rajesh Patel', 'Assembly'), (2, 'Sophia Rodriguez', 'Quality Control'); CREATE TABLE parts (id INT, worker_id INT, quantity INT, date DATE); INSERT INTO parts (id, worker_id, quantity, date) VALUES (1, 1, 120, '2021-02-01'), (2, 1, 130, '2021-02-02'), (3, 2, 110, '2021-02-01'); | What was the total quantity of parts produced by workers from the 'assembly' department for February 2021? | SELECT w.department, SUM(p.quantity) as total_quantity FROM workers w JOIN parts p ON w.id = p.worker_id WHERE w.department = 'Assembly' AND p.date BETWEEN '2021-02-01' AND '2021-02-28' GROUP BY w.department; | gretelai_synthetic_text_to_sql |
CREATE TABLE ethical_brands (brand_id INT, brand_name TEXT, product_category TEXT); INSERT INTO ethical_brands (brand_id, brand_name, product_category) VALUES (1, 'BrandA', 'Clothing'), (2, 'BrandB', 'Electronics'), (3, 'BrandC', 'Clothing'); CREATE TABLE sales (sale_id INT, brand_id INT, product_quantity INT, country TEXT); INSERT INTO sales (sale_id, brand_id, product_quantity, country) VALUES (1, 1, 50, 'Germany'), (2, 2, 75, 'France'), (3, 3, 30, 'Germany'), (4, 1, 100, 'France'); | What is the total quantity of clothing products sold by ethical brands in Germany and France? | SELECT SUM(product_quantity) FROM sales JOIN ethical_brands ON sales.brand_id = ethical_brands.brand_id WHERE country IN ('Germany', 'France') AND ethical_brands.product_category = 'Clothing'; | gretelai_synthetic_text_to_sql |
CREATE TABLE accommodation (accommodation_id INT, accommodation_name TEXT, disability_type TEXT); INSERT INTO accommodation (accommodation_id, accommodation_name, disability_type) VALUES (1, 'Wheelchair Ramp', 'Mobility'); INSERT INTO accommodation (accommodation_id, accommodation_name, disability_type) VALUES (2, 'Sign Language Interpreter', 'Hearing'); INSERT INTO accommodation (accommodation_id, accommodation_name, disability_type) VALUES (3, 'Braille Materials', 'Visual'); | Update the accommodation name for 'Mobility' type to 'Adaptive Equipment'. | UPDATE accommodation SET accommodation_name = 'Adaptive Equipment' WHERE disability_type = 'Mobility'; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_development_initiatives (id INT, country VARCHAR(255), year INT, cost FLOAT); INSERT INTO community_development_initiatives (id, country, year, cost) VALUES (1, 'Brazil', 2018, 25000.00); | What was the average cost of community development initiatives in Brazil in 2018?' | SELECT AVG(cost) FROM community_development_initiatives WHERE country = 'Brazil' AND year = 2018; | gretelai_synthetic_text_to_sql |
CREATE TABLE dishes (id INT, name TEXT, vegan BOOLEAN, calories INT); INSERT INTO dishes (id, name, vegan, calories) VALUES (1, 'Quinoa Salad', TRUE, 350), (2, 'Pizza Margherita', FALSE, 500); | Find the average calorie count for all vegetarian dishes | SELECT AVG(calories) FROM dishes WHERE vegan = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (id INT, product VARCHAR(50), is_organic BOOLEAN, sale_date DATE); INSERT INTO sales (id, product, is_organic, sale_date) VALUES (1, 'Apples', true, '2021-01-01'), (2, 'Bananas', false, '2021-01-02'); | How many organic products were sold in the US in 2021? | SELECT COUNT(*) FROM sales WHERE is_organic = true AND EXTRACT(YEAR FROM sale_date) = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE vaccinations (id INT, gender VARCHAR(255), fully_vaccinated BOOLEAN); INSERT INTO vaccinations VALUES (1, 'Male', true), (2, 'Female', false), (3, 'Non-binary', true); | What is the percentage of the population that is fully vaccinated by gender? | SELECT gender, (COUNT(*) FILTER (WHERE fully_vaccinated) * 100.0 / COUNT(*)) AS pct_fully_vaccinated FROM vaccinations GROUP BY gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotel_ai (hotel_id INT, hotel_name TEXT, city TEXT, has_adopted_ai BOOLEAN); | Find the number of hotels that have not adopted AI technology in the city of New York | SELECT COUNT(*) FROM hotel_ai WHERE city = 'New York' AND has_adopted_ai = FALSE; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_policing (id INT, neighborhood VARCHAR(20), event_type VARCHAR(20), date DATE); INSERT INTO community_policing (id, neighborhood, event_type, date) VALUES (1, 'Compton', 'meeting', '2021-01-01'); INSERT INTO community_policing (id, neighborhood, event_type, date) VALUES (2, 'Watts', 'patrol', '2021-01-02'); INSERT INTO community_policing (id, neighborhood, event_type, date) VALUES (3, 'Boyle Heights', 'workshop', '2021-01-03'); | What is the count of community policing events in the neighborhoods of Compton and Watts, compared to the number of events in the neighborhood of Boyle Heights? | SELECT neighborhood, SUM(event_count) FROM (SELECT neighborhood, COUNT(*) AS event_count FROM community_policing WHERE neighborhood IN ('Compton', 'Watts') GROUP BY neighborhood UNION ALL SELECT 'Boyle Heights' AS neighborhood, COUNT(*) AS event_count FROM community_policing WHERE neighborhood = 'Boyle Heights' GROUP BY neighborhood) AS events GROUP BY neighborhood | gretelai_synthetic_text_to_sql |
CREATE TABLE CityEnergyData (City VARCHAR(50), EnergyConsumption INT); | Identify the top 2 cities with the highest total energy consumption in the "CityEnergyData" table. | SELECT City, SUM(EnergyConsumption) AS TotalEnergyConsumption, RANK() OVER (ORDER BY SUM(EnergyConsumption) DESC) AS Rank FROM CityEnergyData GROUP BY City HAVING Rank <= 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE sustainable_tourism (id INT, name TEXT, country TEXT, is_certified BOOLEAN); INSERT INTO sustainable_tourism (id, name, country, is_certified) VALUES (1, 'Eco Hotel', 'Italy', true), (2, 'Green Tourism', 'Italy', true), (3, 'Sustainable Travel Italy', 'Italy', false); | What is the total number of certified sustainable tourism businesses in Italy? | SELECT COUNT(*) FROM sustainable_tourism WHERE country = 'Italy' AND is_certified = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE Cosmetics (product_id INT, name VARCHAR(50), price DECIMAL(5,2), is_cruelty_free BOOLEAN, type VARCHAR(50)); | Minimum price of lipsticks with cruelty-free certification | SELECT MIN(price) FROM Cosmetics WHERE type = 'Lipstick' AND is_cruelty_free = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE clinical_trials (clinical_trial_id INT, drug_id INT, trial_name TEXT, trial_status TEXT, year INT); INSERT INTO clinical_trials (clinical_trial_id, drug_id, trial_name, trial_status, year) VALUES (1, 1, 'TrialA', 'Completed', 2018), (2, 1, 'TrialB', 'Ongoing', 2019), (3, 2, 'TrialC', 'Completed', 2018), (4, 3, 'TrialD', 'Completed', 2017), (5, 3, 'TrialE', 'Ongoing', 2019); | How many clinical trials were conducted for each drug in the clinical_trials table, grouped by drug name? | SELECT drug_id, COUNT(*) AS total_trials FROM clinical_trials GROUP BY drug_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Transactions (TransactionID INT, TransactionDate DATE, Amount DECIMAL(10,2)); INSERT INTO Transactions (TransactionID, TransactionDate, Amount) VALUES (1, '2022-01-01', 500.00), (2, '2022-01-02', 250.00), (3, '2022-01-03', 750.00), (4, '2022-01-04', 1500.00); | Find the transaction date with the highest total transaction amount. | SELECT TransactionDate, SUM(Amount) FROM Transactions GROUP BY TransactionDate ORDER BY SUM(Amount) DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE countries (id INT, name VARCHAR(50), sport VARCHAR(20)); CREATE TABLE athletes (id INT, name VARCHAR(50), country VARCHAR(50), medals INT); INSERT INTO countries (id, name, sport) VALUES (1, 'United States', 'Olympics'); INSERT INTO countries (id, name, sport) VALUES (2, 'China', 'Olympics'); INSERT INTO athletes (id, name, country, medals) VALUES (1, 'Michael Phelps', 'United States', 28); INSERT INTO athletes (id, name, country, medals) VALUES (2, 'Li Na', 'China', 5); | Find the total number of medals won by each country in the Olympics. | SELECT countries.name, SUM(athletes.medals) FROM countries INNER JOIN athletes ON countries.name = athletes.country GROUP BY countries.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE ca_projects (project_id INT, project_name VARCHAR(100), state VARCHAR(50), carbon_offset INT); INSERT INTO ca_projects (project_id, project_name, state, carbon_offset) VALUES (1, 'CA Project A', 'California', 5000), (2, 'CA Project B', 'California', 7000), (3, 'CA Project C', 'California', 6000); CREATE TABLE ca_renewable_projects (project_id INT, project_type VARCHAR(50)); INSERT INTO ca_renewable_projects (project_id, project_type) VALUES (1, 'Wind'), (2, 'Solar'), (3, 'Wind'); | What is the average carbon offset per renewable energy project in the state of California? | SELECT AVG(carbon_offset) FROM ca_projects JOIN ca_renewable_projects ON ca_projects.project_id = ca_renewable_projects.project_id WHERE state = 'California'; | gretelai_synthetic_text_to_sql |
CREATE TABLE RetailSales (country VARCHAR(50), TotalSales DECIMAL(10,2)); INSERT INTO RetailSales (country, TotalSales) VALUES ('USA', 12500.00), ('Canada', 7000.00), ('Mexico', 5000.00), ('Brazil', 9000.00); | List all countries with retail sales less than 8000, based on the 'TotalSales' column in the 'RetailSales' table. | SELECT country FROM RetailSales WHERE TotalSales < 8000; | gretelai_synthetic_text_to_sql |
CREATE TABLE space_missions (mission_id INT, country VARCHAR(50), launch_year INT); INSERT INTO space_missions (mission_id, country, launch_year) VALUES (1, 'USA', 2010), (2, 'China', 2012), (3, 'Russia', 2015), (4, 'India', 2016), (5, 'Japan', 2017); | What were the top 3 countries with the most space missions launched between 2010 and 2020? | SELECT country, COUNT(*) as mission_count FROM space_missions WHERE launch_year BETWEEN 2010 AND 2020 GROUP BY country ORDER BY mission_count DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE water_usage (state TEXT, sector TEXT, consumption INTEGER); INSERT INTO water_usage (state, sector, consumption) VALUES ('California', 'Agriculture', 12000), ('Texas', 'Agriculture', 18000), ('Nebraska', 'Agriculture', 9000), ('Oklahoma', 'Agriculture', 10000), ('Florida', 'Agriculture', 15000); | Find the top 3 water-consuming states in the agricultural sector. | SELECT state, consumption FROM water_usage WHERE sector = 'Agriculture' ORDER BY consumption DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE cosmetics (id INT, name TEXT, price DECIMAL, is_vegan BOOLEAN, country TEXT); INSERT INTO cosmetics (id, name, price, is_vegan, country) VALUES (1, 'Lipstick', 15.99, true, 'USA'); INSERT INTO cosmetics (id, name, price, is_vegan, country) VALUES (2, 'Eyeshadow', 25.99, false, 'USA'); INSERT INTO cosmetics (id, name, price, is_vegan, country) VALUES (3, 'Mascara', 12.49, true, 'USA'); | What is the average price of vegan cosmetics sold in the US? | SELECT AVG(price) FROM cosmetics WHERE is_vegan = true AND country = 'USA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE clients (client_id INT, name VARCHAR(50), account_balance DECIMAL(10,2)); | Update the account balance of clients who have recently received financial support from charitable organizations. | UPDATE clients SET account_balance = account_balance + 500 WHERE client_id IN (SELECT client_id FROM (SELECT client_id, ROW_NUMBER() OVER(ORDER BY client_id) AS rn FROM clients WHERE account_balance < 1000) AS sq WHERE rn <= 10); | gretelai_synthetic_text_to_sql |
CREATE TABLE cybersecurity_strategies (agency_name VARCHAR(255), strategy_type VARCHAR(255), adoption_year INT, implementation_status VARCHAR(255)); | Present the cybersecurity strategies implemented by each government agency, the strategy type, and the year it was adopted, along with the status of its implementation. | SELECT agency_name, strategy_type, adoption_year, COUNT(*) as num_implemented FROM cybersecurity_strategies WHERE implementation_status = 'Implemented' GROUP BY agency_name, strategy_type, adoption_year; | gretelai_synthetic_text_to_sql |
CREATE TABLE artworks (id INT PRIMARY KEY, title VARCHAR(255), artist VARCHAR(255), year INT); CREATE VIEW gogh_artworks AS SELECT * FROM artworks WHERE artist = 'Vincent van Gogh'; | Drop the 'gogh_artworks' view | DROP VIEW gogh_artworks; | gretelai_synthetic_text_to_sql |
CREATE TABLE donors(id INT, gender TEXT, donation FLOAT); INSERT INTO donors(id, gender, donation) VALUES (1, 'Female', 50.00), (2, 'Male', 100.00), (3, 'Female', 25.00); | What is the average monetary donation amount received from female donors for the 'Education for Girls' project? | SELECT AVG(donation) FROM donors WHERE gender = 'Female' AND project = 'Education for Girls'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artist (id INT, name VARCHAR(255)); CREATE TABLE Album (id INT, artist_id INT, title VARCHAR(255), year INT); | Determine the number of unique artists and albums in the database | SELECT COUNT(DISTINCT A.id) as artist_count, COUNT(DISTINCT AL.id) as album_count FROM Artist A INNER JOIN Album AL ON A.id = AL.artist_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE digital_assets (asset_id INT, name VARCHAR(255), sector VARCHAR(255), market_cap DECIMAL(18,2)); INSERT INTO digital_assets (asset_id, name, sector, market_cap) VALUES (1, 'Bitcoin', 'Store of Value', 1000000000), (2, 'Ethereum', 'Energy', 300000000), (3, 'SolarCoin', 'Energy', 50000); | What are the top 3 digital assets by market capitalization in the Energy sector? | SELECT asset_id, name, sector, market_cap, ROW_NUMBER() OVER (PARTITION BY sector ORDER BY market_cap DESC) AS sector_market_cap_rank FROM digital_assets WHERE sector = 'Energy' FETCH FIRST 3 ROWS ONLY; | gretelai_synthetic_text_to_sql |
CREATE TABLE LowMarketCapitalization (asset_id INT, asset_name VARCHAR(255), regulatory_status VARCHAR(255), market_capitalization DECIMAL(18,2)); INSERT INTO LowMarketCapitalization (asset_id, asset_name, regulatory_status, market_capitalization) VALUES (1, 'DOGE', 'approved', 100.00), (2, 'ADA', 'pending', 200.00), (3, 'LINK', 'rejected', 30.00), (4, 'XLM', 'approved', 40.00), (5, 'BNB', 'pending', 50.00); | What is the regulatory status (approved, pending, rejected) of the digital assets with the lowest market capitalization, and what is their market capitalization? | SELECT regulatory_status, market_capitalization FROM (SELECT regulatory_status, market_capitalization, RANK() OVER (ORDER BY market_capitalization ASC) as rank FROM LowMarketCapitalization WHERE regulatory_status IN ('approved', 'pending', 'rejected')) AS ranked_assets WHERE rank <= 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE green_buildings_residential (building_id INT, city VARCHAR(50), year INT, co2_reduction_tons INT); | What is the average CO2 emissions reduction (in metric tons) from green building projects in the residential sector, grouped by city and year, where the average reduction is greater than 50 metric tons? | SELECT city, year, AVG(co2_reduction_tons) FROM green_buildings_residential GROUP BY city, year HAVING AVG(co2_reduction_tons) > 50; | gretelai_synthetic_text_to_sql |
CREATE TABLE vessel_performance (id INT, vessel_id INT, timestamp DATETIME, speed FLOAT); | Delete records in the vessel_performance table where the vessel_id is 101 | DELETE FROM vessel_performance WHERE vessel_id = 101; | gretelai_synthetic_text_to_sql |
CREATE TABLE Players (PlayerID INT, PlayerName VARCHAR(50), Age INT, Country VARCHAR(50), GamesPlayed INT); INSERT INTO Players (PlayerID, PlayerName, Age, Country, GamesPlayed) VALUES (1, 'John Doe', 25, 'USA', 100); INSERT INTO Players (PlayerID, PlayerName, Age, Country, GamesPlayed) VALUES (2, 'Jane Smith', 30, 'Canada', 200); INSERT INTO Players (PlayerID, PlayerName, Age, Country, GamesPlayed) VALUES (3, 'Mohamed Ahmed', 24, 'Egypt', 80); INSERT INTO Players (PlayerID, PlayerName, Age, Country, GamesPlayed) VALUES (4, 'Fatima Hassan', 28, 'Egypt', 150); | Delete all players from Egypt who have played less than 100 games. | DELETE FROM Players WHERE Country = 'Egypt' AND GamesPlayed < 100; | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists regions (id INT, name VARCHAR(20)); INSERT INTO regions (id, name) VALUES (1, 'South Asia'), (2, 'East Asia'), (3, 'Southeast Asia'); CREATE TABLE if not exists advisories (id INT, region_id INT, level INT); | What is the average travel advisory level for each region in Asia? | SELECT r.name, AVG(a.level) FROM advisories a JOIN regions r ON a.region_id = r.id GROUP BY r.name; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA Grants; CREATE TABLE ResearchGrants (grant_id INT, grant_amount DECIMAL(10,2), grant_year INT); INSERT INTO ResearchGrants (grant_id, grant_amount, grant_year) VALUES (1, 50000.00, 2020), (2, 75000.00, 2019), (3, 30000.00, 2020); | List all marine life research grants awarded in the 'Grants' schema from 2020. | SELECT * FROM Grants.ResearchGrants WHERE grant_year = 2020 AND grant_type = 'MarineLifeResearch'; | gretelai_synthetic_text_to_sql |
CREATE TABLE teams (id INT, name VARCHAR(50), sport VARCHAR(20)); CREATE TABLE stadiums (id INT, name VARCHAR(50), capacity INT, team_id INT); INSERT INTO teams (id, name, sport) VALUES (1, 'New York Giants', 'Football'); INSERT INTO teams (id, name, sport) VALUES (2, 'New York Jets', 'Football'); INSERT INTO stadiums (id, name, capacity, team_id) VALUES (1, 'MetLife Stadium', 82500, 1); INSERT INTO stadiums (id, name, capacity, team_id) VALUES (2, 'MetLife Stadium', 82500, 2); | List all the football teams and their respective stadium capacities. | SELECT teams.name, stadiums.capacity FROM teams INNER JOIN stadiums ON teams.id = stadiums.team_id WHERE teams.sport = 'Football'; | gretelai_synthetic_text_to_sql |
CREATE TABLE infrastructure_projects (project_id INT, project_name TEXT, location TEXT, completion_year INT); INSERT INTO infrastructure_projects (project_id, project_name, location, completion_year) VALUES (1, 'Bridge Construction', 'Rural Area', 2018); INSERT INTO infrastructure_projects (project_id, project_name, location, completion_year) VALUES (2, 'Road Paving', 'Urban Area', 2019); INSERT INTO infrastructure_projects (project_id, project_name, location, completion_year) VALUES (3, 'Water Supply System', 'Rural Area', 2020); | Which rural infrastructure projects were completed between 2018 and 2020? | SELECT * FROM infrastructure_projects WHERE completion_year BETWEEN 2018 AND 2020 AND location LIKE 'rural%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ocean_health_metrics (country VARCHAR(255), water_quality_index INT); INSERT INTO ocean_health_metrics (country, water_quality_index) VALUES ('Canada', 85), ('USA', 78), ('Mexico', 62), ('Peru', 82); | Identify the number of countries in the ocean_health_metrics table with a water_quality_index above 80. | SELECT COUNT(*) FROM ocean_health_metrics WHERE water_quality_index > 80; | gretelai_synthetic_text_to_sql |
CREATE TABLE buildings (building_id INT, city VARCHAR(255), energy_efficiency FLOAT); INSERT INTO buildings (building_id, city, energy_efficiency) VALUES (1, 'Berlin', 150), (2, 'Berlin', 160), (3, 'Berlin', 140), (4, 'Berlin', 170), (5, 'Berlin', 130), (6, 'Paris', 180), (7, 'Paris', 170), (8, 'Paris', 160), (9, 'London', 190), (10, 'London', 180), (11, 'London', 170); | What is the average energy efficiency (in kWh/m2) of buildings in the city of Berlin, Germany? | SELECT AVG(energy_efficiency) FROM buildings WHERE city = 'Berlin'; | gretelai_synthetic_text_to_sql |
CREATE TABLE indigenous_food_systems (id INT, name TEXT, country TEXT); INSERT INTO indigenous_food_systems (id, name, country) VALUES (1, 'System 1', 'Australia'), (2, 'System 2', 'New Zealand'); | How many indigenous food systems exist in Australia and New Zealand? | SELECT COUNT(*) as count FROM indigenous_food_systems WHERE country IN ('Australia', 'New Zealand'); | 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.