context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE articles (id INT, title VARCHAR(100), source VARCHAR(50), date DATE); INSERT INTO articles (id, title, source, date) VALUES (1, 'Article 1', 'Source A', '2021-01-01'); INSERT INTO articles (id, title, source, date) VALUES (2, 'Article 2', 'Source B', '2021-01-02'); INSERT INTO articles (id, title, source, date) VALUES (3, 'Article 3', 'Source C', '2021-01-03');
|
Find the earliest date of articles in 'Source C'
|
SELECT MIN(date) as earliest_date FROM articles WHERE source = 'Source C';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE projects (project_id INT, project_name VARCHAR(255)); CREATE TABLE donors (donor_id INT, project_id INT, donation_amount FLOAT); INSERT INTO projects (project_id, project_name) VALUES (1, 'Project A'), (2, 'Project B'), (3, 'Project C'), (4, 'Project D'), (5, 'Project E'); INSERT INTO donors (donor_id, project_id, donation_amount) VALUES (1, 1, 5000), (2, 2, 7000), (3, 1, 6000), (4, 3, 25000), (5, 5, 12000), (6, 1, 15000);
|
List all the projects in the 'projects' table that have received donations of more than $10,000, and display the project names and the total donation amounts.
|
SELECT p.project_name, SUM(d.donation_amount) as total_donation FROM projects p JOIN donors d ON p.project_id = d.project_id WHERE d.donation_amount > 10000 GROUP BY p.project_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE E_Bikes (id INT PRIMARY KEY, bike_id VARCHAR(255), bike_status VARCHAR(50), bike_latitude DECIMAL(10,8), bike_longitude DECIMAL(11,8), rental_time TIMESTAMP, return_time TIMESTAMP, trip_distance DECIMAL(10,2));
|
What is the average trip distance for electric bikes?
|
SELECT AVG(trip_distance) as avg_trip_distance FROM E_Bikes WHERE bike_status = 'rented';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE products (product_id INT, is_circular BOOLEAN, country VARCHAR(20), price INT); INSERT INTO products (product_id, is_circular, country, price) VALUES (1, true, 'Developed', 50), (2, false, 'Developing', 20), (3, true, 'Developed', 75);
|
What is the maximum price of a product that is part of a circular supply chain and is produced in a developed country?
|
SELECT MAX(products.price) FROM products WHERE products.is_circular = true AND products.country = 'Developed';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_protected_areas (region VARCHAR(20), name VARCHAR(50), size FLOAT); INSERT INTO marine_protected_areas (region, name, size) VALUES ('Pacific Ocean', 'Marianas Trench Marine National Monument', 193057); INSERT INTO marine_protected_areas (region, name, size) VALUES ('Pacific Ocean', 'Papahānaumokuākea Marine National Monument', 360000); INSERT INTO marine_protected_areas (region, name, size) VALUES ('Atlantic Ocean', 'Bermuda Parks and Nature Reserves', 78);
|
Which marine protected areas in the Pacific Ocean have a size larger than 200000?
|
SELECT name FROM marine_protected_areas WHERE region = 'Pacific Ocean' AND size > 200000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE virtual_tours (id INT, name VARCHAR(50), platform VARCHAR(50));
|
Delete all records from the "virtual_tours" table where the "platform" is "Oculus"
|
DELETE FROM virtual_tours WHERE platform = 'Oculus';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE tickets (ticket_id INT, event VARCHAR(50), price DECIMAL(5,2), quantity INT); INSERT INTO tickets (ticket_id, event, price, quantity) VALUES (1, 'Homecoming', 50.00, 1000); INSERT INTO tickets (ticket_id, event, price, quantity) VALUES (2, 'Season Finale', 75.00, 500);
|
How many tickets were sold for the 'Homecoming' event in the 'tickets' table?
|
SELECT SUM(quantity) FROM tickets WHERE event = 'Homecoming';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE satellites (satellite_id INT PRIMARY KEY, organization VARCHAR(50), launch_date DATE); INSERT INTO satellites (satellite_id, organization, launch_date) VALUES (1, 'NASA', '2020-01-01'), (2, 'SpaceX', '2019-05-22'), (3, 'Roscosmos', '2021-06-17'), (4, 'NASA', '2020-07-21'), (5, 'SpaceX', '2021-02-04');
|
How many satellites were launched by each organization?
|
SELECT organization, COUNT(*) AS num_satellites FROM satellites GROUP BY organization;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donations (donor_id INT, donation_amount DECIMAL(10,2), donation_date DATE); INSERT INTO Donations (donor_id, donation_amount, donation_date) VALUES (1, 5000, '2021-01-01'), (2, 3500, '2021-02-01'), (3, 7000, '2021-03-01'), (4, 2800, '2021-04-01'), (5, 6000, '2021-05-01');
|
What was the total amount donated by each top 5 donors in 2021?
|
SELECT donor_id, SUM(donation_amount) as total_donation FROM Donations WHERE donation_date BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY donor_id ORDER BY total_donation DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE case_hearing (case_id INT, county_name VARCHAR(50), court_type VARCHAR(20), case_date DATE); INSERT INTO case_hearing VALUES (1, 'County A', 'Community', '2021-01-01'), (2, 'County A', 'Community', '2021-01-05'), (3, 'County B', 'Traditional', '2021-01-02'), (4, 'County B', 'Traditional', '2021-01-06');
|
What is the total number of cases heard in each county and the case type?
|
SELECT county_name, court_type, COUNT(*) AS cases_heard FROM case_hearing GROUP BY county_name, court_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Restaurants (id INT, name TEXT, country TEXT); CREATE TABLE Meals (id INT, name TEXT, type TEXT, calories INT, RestaurantId INT, FOREIGN KEY (RestaurantId) REFERENCES Restaurants(id)); INSERT INTO Restaurants (id, name, country) VALUES (1, 'Restaurant A', 'USA'), (2, 'Restaurant B', 'USA'), (3, 'Restaurant C', 'Canada'); INSERT INTO Meals (id, name, type, calories, RestaurantId) VALUES (1, 'Meal 1', 'Vegan', 600, 1), (2, 'Meal 2', 'Vegan', 550, 1), (3, 'Meal 3', 'Non-vegan', 700, 1), (4, 'Meal 4', 'Vegan', 450, 2), (5, 'Meal 5', 'Non-vegan', 800, 2), (6, 'Meal 6', 'Vegan', 650, 3);
|
Calculate the average calorie count of vegan dishes in restaurants located in the USA.
|
SELECT AVG(Meals.calories) FROM Meals JOIN Restaurants ON Meals.RestaurantId = Restaurants.id WHERE Meals.type = 'Vegan' AND Restaurants.country = 'USA';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE coal_production (site VARCHAR(20), state VARCHAR(20), production INT); INSERT INTO coal_production (site, state, production) VALUES ('SiteD', 'SA', 1800), ('SiteE', 'VIC', 2200), ('SiteF', 'SA', 1900);
|
What is the average coal production per site in SA?
|
SELECT state, AVG(production) FROM coal_production WHERE state = 'SA';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hotels (id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255)); INSERT INTO hotels (id, name, country) VALUES (1, 'Eco-Friendly Hotel', 'Sweden'); INSERT INTO hotels (id, name, country) VALUES (2, 'Sustainable Resort', 'Costa Rica'); INSERT INTO hotels (id, name, country) VALUES (3, 'Heritage Hotel', 'India');
|
Delete the record with id 3 in the 'hotels' table
|
DELETE FROM hotels WHERE id = 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE albums (id INT, year INT, release_date DATE);
|
How many albums were released in 2022?
|
SELECT COUNT(*) FROM albums WHERE EXTRACT(YEAR FROM release_date) = 2022;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE organizations (id INT, name TEXT, location TEXT, donations DECIMAL(10,2)); INSERT INTO organizations (id, name, location, donations) VALUES (1, 'Aid for Africa', 'Africa', 50000.00), (2, 'Hope for Asia', 'Asia', 75000.00), (3, 'Charity for Europe', 'Europe', 100000.00), (4, 'Relief for North America', 'North America', 125000.00);
|
What is the sum of donations for organizations located in Europe or North America?
|
SELECT SUM(donations) FROM organizations WHERE location IN ('Europe', 'North America');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MitigationAfrica (Country TEXT, Investment_Amount NUMERIC); INSERT INTO MitigationAfrica (Country, Investment_Amount) VALUES ('Nigeria', 1000000), ('Kenya', 1500000), ('Ethiopia', 800000);
|
Which countries in Africa have invested in climate mitigation and what are the investment amounts?
|
SELECT Country, Investment_Amount FROM MitigationAfrica WHERE Investment_Amount IS NOT NULL;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_pollution (id INT, location TEXT, level FLOAT, region TEXT);
|
What is the average level of marine pollution in the Arctic, excluding areas with a level of over 50 ppm?
|
SELECT AVG(level) FROM marine_pollution WHERE region = 'Arctic' AND level < 50;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE country_sales (date DATE, country VARCHAR(50), revenue FLOAT, profit FLOAT); INSERT INTO country_sales (date, country, revenue, profit) VALUES ('2022-01-01', 'India', 6000, 2500);
|
What is the total revenue and profit for each country in Q1 2022?
|
SELECT EXTRACT(QUARTER FROM date) as quarter, country, SUM(revenue) as total_revenue, SUM(profit) as total_profit FROM country_sales WHERE date >= '2022-01-01' AND date <= '2022-03-31' GROUP BY quarter, country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donations (id INT, donor_name VARCHAR, donation_amount DECIMAL, donation_date DATE); INSERT INTO donations (id, donor_name, donation_amount, donation_date) VALUES (1, 'John Doe', 100, '2021-01-01');
|
How many unique donors have there been in each month?
|
SELECT EXTRACT(MONTH FROM donation_date) AS month, COUNT(DISTINCT donor_name) FROM donations GROUP BY month;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Sports_Cars (id INT, name VARCHAR(255), horsepower INT, release_year INT); INSERT INTO Sports_Cars (id, name, horsepower, release_year) VALUES (1, 'Corvette C4', 230, 1984); INSERT INTO Sports_Cars (id, name, horsepower, release_year) VALUES (2, 'Porsche 911', 217, 1983);
|
What is the average horsepower of sports cars released before 1990?
|
SELECT AVG(horsepower) FROM Sports_Cars WHERE release_year < 1990;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE workout_data (user_id INT, workout_type VARCHAR(20), duration INT); INSERT INTO workout_data (user_id, workout_type, duration) VALUES (1, 'Running', 30), (1, 'Cycling', 60), (2, 'Yoga', 45), (3, 'Pilates', 50), (1, 'Running', 45), (2, 'Yoga', 60), (3, 'Pilates', 75), (1, 'Running', 75), (2, 'Yoga', 90), (3, 'Pilates', 105);
|
What is the minimum duration of 'Pilates' workouts in the 'workout_data' table?
|
SELECT MIN(duration) as min_duration FROM workout_data WHERE workout_type = 'Pilates';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sourcing_audits (restaurant_name TEXT, location TEXT, audit_date DATE); INSERT INTO sourcing_audits (restaurant_name, location, audit_date) VALUES ('Restaurant A', 'California', '2021-06-01'), ('Restaurant B', 'California', '2021-07-15'), ('Restaurant C', 'New York', '2021-08-05');
|
How many sustainable sourcing audits were conducted in 'California'?
|
SELECT COUNT(*) FROM sourcing_audits WHERE location = 'California';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE client_accounts (account_id INT, client_id INT, balance DECIMAL(10, 2)); INSERT INTO client_accounts (account_id, client_id, balance) VALUES (1, 1, 5000.00), (2, 1, 7500.00), (3, 2, 3000.00), (4, 3, 10000.00); CREATE TABLE clients (client_id INT, name VARCHAR(50), region VARCHAR(50)); INSERT INTO clients (client_id, name, region) VALUES (1, 'Garcia', 'Latin America'), (2, 'Lee', 'Asia'), (3, 'Kim', 'Latin America');
|
What is the average account balance for clients in the Latin America region?
|
SELECT AVG(balance) FROM client_accounts ca JOIN clients c ON ca.client_id = c.client_id WHERE c.region = 'Latin America';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mining_operations (id INT, location VARCHAR(255), num_employees INT); INSERT INTO mining_operations (id, location, num_employees) VALUES (1, 'Canada', 300), (2, 'USA', 500); CREATE TABLE underrepresented_communities (id INT, community VARCHAR(255)); INSERT INTO underrepresented_communities (id, community) VALUES (1, 'Indigenous'), (2, 'Hispanic'), (3, 'African American');
|
What is the total number of employees from underrepresented communities in mining operations across Canada and the United States?
|
SELECT SUM(num_employees) FROM mining_operations JOIN (SELECT 1 AS id, 'Canada' AS location UNION ALL SELECT 2, 'USA') location_table ON mining_operations.location = location_table.location JOIN underrepresented_communities ON 'Indigenous' = underrepresented_communities.community OR 'Hispanic' = underrepresented_communities.community OR 'African American' = underrepresented_communities.community;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE waste_generation (year INT, sector TEXT, amount INT); INSERT INTO waste_generation (year, sector, amount) VALUES (2017, 'commercial', 1500), (2017, 'residential', 1200), (2018, 'commercial', 1600), (2018, 'residential', 1300), (2019, 'commercial', 1700), (2019, 'residential', 1400), (2020, 'commercial', 1800), (2020, 'residential', 1500);
|
Delete records with waste generation below 1000 in 'waste_generation' table for 2017.
|
DELETE FROM waste_generation WHERE year = 2017 AND amount < 1000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE videos_region (id INT, title TEXT, region TEXT, view_count INT); INSERT INTO videos_region (id, title, region, view_count) VALUES (1, 'Video1', 'Asia', 8000), (2, 'Video2', 'Europe', 5000);
|
What's the average view count of videos from the 'Asia' region?
|
SELECT AVG(view_count) FROM videos_region WHERE region = 'Asia';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE programs (id INT, name VARCHAR(255)); CREATE TABLE volunteers (id INT, program_id INT, signup_date DATE); INSERT INTO programs (id, name) VALUES (1, 'Education'), (2, 'Health'), (3, 'Mentorship'); INSERT INTO volunteers (id, program_id, signup_date) VALUES (1, 1, '2021-01-01'), (2, 1, '2020-12-31'), (3, 3, '2021-02-01'), (4, 3, '2021-03-01'), (5, 2, '2021-04-01');
|
Who are the volunteers that have signed up for the 'Mentorship' program in 2021?
|
SELECT v.id, v.program_id, p.name, v.signup_date FROM volunteers v JOIN programs p ON v.program_id = p.id WHERE p.name = 'Mentorship' AND v.signup_date >= '2021-01-01' AND v.signup_date < '2022-01-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE transactions (id INT, date DATE, country VARCHAR(50), coin VARCHAR(50), value DECIMAL(10, 2)); INSERT INTO transactions (id, date, country, coin, value) VALUES (1, '2022-01-01', 'Costa Rica', 'Monero', 100), (2, '2022-01-02', 'Guatemala', 'Zcash', 200), (3, '2022-01-03', 'El Salvador', 'Monero', 300);
|
What is the maximum and minimum number of transactions involving privacy coins in Central America?
|
SELECT MAX(value) as max_value, MIN(value) as min_value FROM transactions WHERE country IN ('Costa Rica', 'Guatemala', 'El Salvador') AND coin IN ('Monero', 'Zcash');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE victims (victim_id INT PRIMARY KEY, name VARCHAR(255), age INT, gender VARCHAR(50), race VARCHAR(50), ethnicity VARCHAR(50), date_of_birth DATE);
|
Add a new victim to the 'victims' table
|
INSERT INTO victims (victim_id, name, age, gender, race, ethnicity, date_of_birth) VALUES (1010, 'Jamila Jackson', 32, 'Female', 'African American', 'Afro-Caribbean', '1991-01-12');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE inventory (item TEXT, weight INT); INSERT INTO inventory (item, weight) VALUES ('Apples', 2500), ('Bananas', 1800), ('Carrots', 1200);
|
What is the total weight of fruits in the inventory?
|
SELECT SUM(weight) FROM inventory WHERE item LIKE 'Apples%' OR item LIKE 'Bananas%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vaccination_stats (id INT PRIMARY KEY, state VARCHAR(50), total_vaccinations INT);
|
Create a table named 'vaccination_stats'
|
CREATE TABLE vaccination_stats (id INT PRIMARY KEY, state VARCHAR(50), total_vaccinations INT);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE OrganicCottonGarments (manufacturer VARCHAR(255), production_cost DECIMAL(10,2), year INT);
|
What is the average production cost of garments made from organic cotton, per manufacturer, for the year 2020?
|
SELECT manufacturer, AVG(production_cost) FROM OrganicCottonGarments WHERE year = 2020 GROUP BY manufacturer;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE AgriculturalInnovations (id INT, country VARCHAR(50), project VARCHAR(50), start_date DATE, completion_date DATE, year INT); INSERT INTO AgriculturalInnovations (id, country, project, start_date, completion_date, year) VALUES (1, 'Senegal', 'Drip Irrigation Systems', '2017-04-01', '2017-12-31', 2017), (2, 'Senegal', 'Agroforestry Expansion', '2018-06-15', '2019-03-05', 2018), (3, 'Mali', 'Solar Powered Cold Storage', '2019-08-20', NULL, 2019);
|
How many agricultural innovation projects were completed in Senegal between 2017 and 2019?
|
SELECT COUNT(*) FROM AgriculturalInnovations WHERE country = 'Senegal' AND year BETWEEN 2017 AND 2019 AND completion_date IS NOT NULL;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE organization (id INT, name VARCHAR(255)); CREATE TABLE donor (id INT, name VARCHAR(255), organization_id INT);
|
Identify the top 3 organizations with the most unique donors.
|
SELECT o.name, COUNT(DISTINCT d.id) as num_donors FROM organization o JOIN donor d ON o.id = d.organization_id GROUP BY o.id ORDER BY num_donors DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mobile_plans (plan_id INT, plan_name VARCHAR(255), data_limit DECIMAL(10,2)); INSERT INTO mobile_plans (plan_id, plan_name, data_limit) VALUES (1, 'Basic', 2.00), (2, 'Premium', 10.00), (3, 'Ultra', 30.00);
|
What is the average data usage for each mobile plan in GB?
|
SELECT plan_name, data_limit/1024 AS data_usage_gb FROM mobile_plans;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE transportation_systems (id INT, system VARCHAR(50)); INSERT INTO transportation_systems (id, system) VALUES (1, 'Subway'), (2, 'Bus'), (3, 'Tram'), (4, 'Ferry'), (5, 'High-Speed Rail');
|
How many transportation systems are available in total?
|
SELECT COUNT(*) FROM transportation_systems;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE production_data (operation_name VARCHAR(50), year INT, production INT); INSERT INTO production_data (operation_name, year, production) VALUES ('Operation A', 2021, 150), ('Operation A', 2022, 180), ('Operation B', 2021, 120), ('Operation B', 2022, 135), ('Operation C', 2021, 200), ('Operation C', 2022, 210);
|
What is the production by mining operation and year, in ascending order of production?
|
SELECT operation_name, year, production FROM production_data ORDER BY production ASC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE egypt_virtual_tours (month INT, country TEXT, num_tours INT); INSERT INTO egypt_virtual_tours (month, country, num_tours) VALUES (1, 'Egypt', 100), (2, 'Egypt', 120), (3, 'Egypt', 140), (4, 'Egypt', 150), (5, 'Egypt', 170), (6, 'Egypt', 190), (7, 'Egypt', 210), (8, 'Egypt', 230), (9, 'Egypt', 250), (10, 'Egypt', 270), (11, 'Egypt', 290), (12, 'Egypt', 310);
|
How has the number of virtual tours in Egypt changed over the past year?
|
SELECT month, num_tours FROM egypt_virtual_tours;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE union_members (id INT, union_name VARCHAR(30), sector VARCHAR(20)); INSERT INTO union_members (id, union_name, sector) VALUES (1, 'Union A', 'government'), (2, 'Union B', 'education'), (3, 'Union C', 'government'), (4, 'Union D', 'technology'), (5, 'Union E', 'technology'); CREATE TABLE collective_bargaining (id INT, union_id INT, member_id INT); INSERT INTO collective_bargaining (id, union_id, member_id) VALUES (1, 1, 101), (2, 3, 102), (3, 4, 103), (4, 5, 104), (5, 1, 105), (6, 3, 106);
|
What is the total number of union members involved in collective bargaining in unions from the 'government' sector?
|
SELECT SUM(num_members) FROM (SELECT COUNT(*) AS num_members FROM union_members WHERE sector = 'government' AND id IN (SELECT union_id FROM collective_bargaining)) t;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donors (donor_id INT, donor_name TEXT); CREATE TABLE donor_demographics (donor_id INT, age INT, gender TEXT, state TEXT);
|
Show donor demographics, including age, gender, and state, from 'donors' and 'donor_demographics' tables
|
SELECT donors.donor_name, donor_demographics.age, donor_demographics.gender, donor_demographics.state FROM donors INNER JOIN donor_demographics ON donors.donor_id = donor_demographics.donor_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE farmers_market_vendors (vendor_id INT PRIMARY KEY, name VARCHAR(100), state VARCHAR(50), organic INT);
|
Update the 'organic' column in the 'farmers_market_vendors' table for all records with 'state' 'CA' and set the value to 1
|
UPDATE farmers_market_vendors SET organic = 1 WHERE state = 'CA';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE renewable_energy (id INT PRIMARY KEY, source VARCHAR(255), capacity_mw FLOAT, country VARCHAR(255));
|
Insert a new record into the 'renewable_energy' table with a 'source' value of 'Wind', 'capacity_mw' value of 50, and 'country' value of 'Germany'
|
INSERT INTO renewable_energy (source, capacity_mw, country) VALUES ('Wind', 50, 'Germany');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE blockchains (blockchain_id INT, blockchain_name VARCHAR(50), daily_transactions INT); INSERT INTO blockchains (blockchain_id, blockchain_name, daily_transactions) VALUES (1, 'Ethereum', 50000); INSERT INTO blockchains (blockchain_id, blockchain_name, daily_transactions) VALUES (2, 'Solana', 100000);
|
What is the maximum number of daily transactions for each blockchain network?
|
SELECT blockchain_name, MAX(daily_transactions) FROM blockchains GROUP BY blockchain_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CO2Emissions (country VARCHAR(20), emission INT, population INT); INSERT INTO CO2Emissions (country, emission, population) VALUES ('Germany', 700, 83), ('France', 450, 67), ('Italy', 420, 60), ('Spain', 380, 47);
|
What is the average CO2 emission for the top 3 most populous countries in Europe?
|
SELECT AVG(emission) FROM (SELECT emission FROM CO2Emissions WHERE country IN ('Germany', 'France', 'Italy') ORDER BY population DESC LIMIT 3) AS subquery;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Transportation (project_id INT, project_name VARCHAR(255), project_type VARCHAR(255), length FLOAT);
|
Show the number of bridges, tunnels, and other projects in the Transportation table
|
SELECT SUM(CASE WHEN project_type = 'Bridge' THEN 1 ELSE 0 END) AS bridges, SUM(CASE WHEN project_type = 'Tunnel' THEN 1 ELSE 0 END) AS tunnels, COUNT(*) - SUM(CASE WHEN project_type IN ('Bridge', 'Tunnel') THEN 1 ELSE 0 END) AS other FROM Transportation;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE AgriculturalInnovations (innovation VARCHAR(50), funding_date DATE, funding_amount FLOAT);
|
Which agricultural innovations received funding in the last three years?
|
SELECT innovation FROM (SELECT innovation, ROW_NUMBER() OVER(PARTITION BY YEAR(funding_date) ORDER BY funding_date DESC) as rn FROM AgriculturalInnovations) WHERE rn <= 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SpaceMissions (MissionID INT, Name VARCHAR(50), LaunchDate DATE); INSERT INTO SpaceMissions VALUES (1, 'Cassini-Huygens', '1997-10-15'), (2, 'Dawn', '2007-09-27'), (3, 'New Horizons', '2006-01-19');
|
How many space missions were there to Saturn between 2000 and 2010?
|
SELECT COUNT(*) FROM SpaceMissions WHERE YEAR(LaunchDate) BETWEEN 2000 AND 2010 AND Destination = 'Saturn';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MonitoringStations (StationID INT, StationName VARCHAR(50), MinDO DECIMAL(4,2)); INSERT INTO MonitoringStations VALUES (1, 'Station A', 5.8), (2, 'Station B', 5.5), (3, 'Station C', 6.2);
|
What is the minimum dissolved oxygen level recorded in each monitoring station?
|
SELECT StationName, MIN(MinDO) FROM MonitoringStations GROUP BY StationName;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE landfill_capacity(year INT, state VARCHAR(255), capacity INT); INSERT INTO landfill_capacity VALUES (2019, 'Texas', 4500), (2020, 'Texas', 5000);
|
Delete records of landfill capacity for 2019 in Texas.
|
DELETE FROM landfill_capacity WHERE year = 2019 AND state = 'Texas';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE rural_infrastructure (id INT, project_name VARCHAR(255), start_date DATE); INSERT INTO rural_infrastructure (id, project_name, start_date) VALUES (1, 'Road Construction', '2021-01-01'), (2, 'Bridge Building', '2020-06-15');
|
List the names of rural infrastructure projects that started after June 2020.
|
SELECT project_name FROM rural_infrastructure WHERE start_date > '2020-06-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Cultural_Events (id INT, city VARCHAR(50), attendance INT); CREATE VIEW Sydney_Events AS SELECT * FROM Cultural_Events WHERE city = 'Sydney';
|
What is the maximum number of visitors at a cultural event in Sydney?
|
SELECT MAX(attendance) FROM Sydney_Events;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE caribbean_projects (project_id INT, project_name TEXT, location TEXT, project_type TEXT, start_date DATE, end_date DATE);
|
What is the number of climate adaptation projects in the Caribbean that were started after 2010?
|
SELECT COUNT(project_id) FROM caribbean_projects WHERE location LIKE '%Caribbean%' AND project_type = 'climate_adaptation' AND start_date > '2010-01-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE programs (id INT, program_name VARCHAR(50), program_type VARCHAR(20), org_id INT, start_date DATE, end_date DATE, budget DECIMAL(10,2));
|
What are the total expenses for refugee support programs in Europe?
|
SELECT SUM(budget) FROM programs WHERE program_type = 'Refugee Support' AND country_code = 'EU';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE safety_incidents (incident_id INT, region TEXT, incident_count INT); INSERT INTO safety_incidents (incident_id, region, incident_count) VALUES (1, 'North America', 25), (2, 'Europe', 18), (3, 'Asia', 30), (4, 'Africa', 12), (5, 'South America', 9);
|
How many AI safety incidents were reported in each region in the 'safety_incidents' table?
|
SELECT region, SUM(incident_count) FROM safety_incidents GROUP BY region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE plants (id INT, name TEXT, type TEXT, monthly_disposables_cost DECIMAL); INSERT INTO plants (id, name, type, monthly_disposables_cost) VALUES (1, 'Plant-Based Cuisine', 'Meal Processing', 2500);
|
Show the monthly cost of disposables for our plant-based meal processing plants.
|
SELECT name, monthly_disposables_cost FROM plants WHERE type = 'Meal Processing';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE districts (district_id INT, district_name TEXT); CREATE TABLE students (student_id INT, district_id INT, mental_health_score INT); INSERT INTO districts VALUES (1, 'District A'), (2, 'District B'); INSERT INTO students VALUES (1, 1, 60), (2, 1, 75), (3, 2, 45), (4, 2, 30);
|
What is the average mental health score of students in each district, filtered by those with scores below 70?
|
SELECT d.district_name, AVG(s.mental_health_score) as avg_mental_health_score FROM students s JOIN districts d ON s.district_id = d.district_id GROUP BY s.district_id HAVING avg_mental_health_score < 70;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Residential_Buildings (BuildingID INT, BuildingType VARCHAR(50), State VARCHAR(50), Cost FLOAT);
|
What is the average cost of construction materials for residential buildings in the state of California?
|
SELECT AVG(Cost) FROM Residential_Buildings WHERE BuildingType = 'Residential' AND State = 'California';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE water_conservation (id INT PRIMARY KEY, location VARCHAR(50), water_savings FLOAT);
|
Add data to 'water_conservation' table
|
INSERT INTO water_conservation (id, location, water_savings) VALUES (1, 'San Francisco', 12.3);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE deep_sea_temperature (location text, temperature numeric); INSERT INTO deep_sea_temperature (location, temperature) VALUES ('Mariana Trench', -8.5), ('Java Trench', -7.8);
|
What is the minimum temperature recorded in the Mariana Trench?
|
SELECT MIN(temperature) FROM deep_sea_temperature WHERE location = 'Mariana Trench';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE economic_impact (year INT, revenue INT);
|
Delete all records from the "economic_impact" table where the "year" is 2020
|
DELETE FROM economic_impact WHERE year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customers (customer_id INT, country_code CHAR(2)); CREATE TABLE transactions (transaction_id INT, customer_id INT, transaction_amount DECIMAL(10,2), transaction_date DATE);
|
What is the daily average transaction amount for customers from each country in Q1 2022?
|
SELECT AVG(transaction_amount), country_code FROM transactions INNER JOIN customers ON transactions.customer_id = customers.customer_id WHERE transactions.transaction_date BETWEEN '2022-01-01' AND '2022-03-31' GROUP BY country_code;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE agricultural_innovation_projects (id INT, name TEXT, completion_date DATE); INSERT INTO agricultural_innovation_projects (id, name, completion_date) VALUES (1, 'Project C', '2020-03-15'); INSERT INTO agricultural_innovation_projects (id, name, completion_date) VALUES (2, 'Project D', '2019-12-30');
|
How many agricultural innovation projects were completed in Kenya in the year 2020?
|
SELECT COUNT(*) FROM agricultural_innovation_projects WHERE YEAR(completion_date) = 2020 AND country = 'Kenya';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE movies (id INT, title VARCHAR(100), genre VARCHAR(50), release_year INT, production_budget INT);
|
Insert a new record for a movie with title "MovieY", genre "Comedy", release year 2012, and production budget 12000000.
|
INSERT INTO movies (title, genre, release_year, production_budget) VALUES ('MovieY', 'Comedy', 2012, 12000000);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE FishHealth (id INT, fish_id INT, health_score INT, date_entered TIMESTAMP);
|
Insert a new 'FishHealth' record into the 'FishHealth' table with ID 1, fish ID 2, health score 80, and date entered '2022-07-30 15:00:00'
|
INSERT INTO FishHealth (id, fish_id, health_score, date_entered) VALUES (1, 2, 80, '2022-07-30 15:00:00');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Shipments (carrier varchar(20), shipment_date date); INSERT INTO Shipments (carrier, shipment_date) VALUES ('Carrier G', '2022-05-01'), ('Carrier H', '2022-05-02');
|
What is the total number of shipments made by 'Carrier G' in 'May 2022'?
|
SELECT COUNT(*) FROM Shipments WHERE carrier = 'Carrier G' AND EXTRACT(MONTH FROM shipment_date) = 5 AND EXTRACT(YEAR FROM shipment_date) = 2022;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE waste_generation (id INT, sector VARCHAR(20), location VARCHAR(20), amount DECIMAL(10,2), date DATE);
|
Insert records of waste generation from the commercial sector in Tokyo for the month of April 2022.
|
INSERT INTO waste_generation (id, sector, location, amount, date) VALUES (1, 'commercial', 'Tokyo', 700, '2022-04-01'), (2, 'commercial', 'Tokyo', 800, '2022-04-15'), (3, 'commercial', 'Tokyo', 600, '2022-04-30');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE r_and_d_expenditures (drug_name VARCHAR(255), r_and_d_cost FLOAT, year INT); INSERT INTO r_and_d_expenditures (drug_name, r_and_d_cost, year) VALUES ('DrugD', 7000000.00, 2019);
|
What is the average R&D cost for drugs approved after 2018?
|
SELECT AVG(r_and_d_cost) as avg_r_and_d_cost FROM r_and_d_expenditures e JOIN drug_approvals a ON e.drug_name = a.drug_name WHERE a.approval_date > '2018-12-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE biotech_funding (id INT PRIMARY KEY, startup_name VARCHAR(100), funding_round VARCHAR(50), funding_amount INT);
|
Insert a new record into the 'biotech_funding' table with 'startup_name' = 'CellVentures', 'funding_round' = 'Series B', and 'funding_amount' = 12000000
|
INSERT INTO biotech_funding (startup_name, funding_round, funding_amount) VALUES ('CellVentures', 'Series B', 12000000);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Oil_Production (well text, production_date date, quantity real); INSERT INTO Oil_Production (well, production_date, quantity) VALUES ('W005', '2021-01-01', 150.5), ('W005', '2021-01-02', 160.3), ('W005', '2021-01-15', 165.0);
|
What is the total production for well 'W005' for the month of January 2021 in the Oil_Production table?
|
SELECT SUM(quantity) FROM Oil_Production WHERE well = 'W005' AND production_date BETWEEN '2021-01-01' AND '2021-01-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE restaurant_revenue(restaurant_id INT, cuisine VARCHAR(255), quarterly_revenue DECIMAL(10,2), region VARCHAR(255), quarter_end DATE);
|
What is the total revenue for the 'Street Food' cuisine category in the 'Middle East' region for the quarter ending '2022-09-30'?
|
SELECT SUM(quarterly_revenue) FROM restaurant_revenue WHERE cuisine = 'Street Food' AND region = 'Middle East' AND quarter_end <= '2022-09-30' AND quarter_end >= '2022-07-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Companies (id INT, name TEXT, country TEXT); INSERT INTO Companies (id, name, country) VALUES (1, 'UK Co', 'UK'); INSERT INTO Companies (id, name, country) VALUES (2, 'Oz Inc', 'Australia'); CREATE TABLE Funding (id INT, company_id INT, investor_type TEXT, amount INT);
|
List the names of companies founded in the UK or Australia that have not yet received any funding.
|
SELECT Companies.name FROM Companies LEFT JOIN Funding ON Companies.id = Funding.company_id WHERE Funding.id IS NULL AND Companies.country IN ('UK', 'Australia')
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE forest_management (tree_id INT, species VARCHAR(50), age INT);
|
List all the trees in the forest_management table that are younger than 20 years or older than 80 years?
|
SELECT * FROM forest_management WHERE age < 20 OR age > 80;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cosmetics (product_id INT, product_name VARCHAR(50), is_natural BOOLEAN, price FLOAT, country VARCHAR(50));
|
What is the maximum price of natural cosmetics in Australia?
|
SELECT MAX(price) FROM cosmetics WHERE is_natural = TRUE AND country = 'Australia';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE team_members (id INT, name VARCHAR(50), team VARCHAR(50), join_date DATE); INSERT INTO team_members (id, name, team, join_date) VALUES (1, 'Dana', 'Ethical AI', '2021-12-01'), (2, 'Eliot', 'Data Science', '2022-02-01'), (3, 'Fiona', 'Ethical AI', '2021-11-15');
|
How many members are there in the Ethical AI team as of 2022-01-01?
|
SELECT COUNT(*) FROM team_members WHERE team = 'Ethical AI' AND join_date <= '2022-01-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sales_data (sale_id INT, dish_id INT, sale_date DATE, revenue DECIMAL(10, 2)); INSERT INTO sales_data (sale_id, dish_id, sale_date, revenue) VALUES (1, 1, '2022-01-01', 12.99), (2, 3, '2022-01-01', 8.99), (3, 2, '2022-01-02', 11.99), (4, 4, '2022-01-02', 7.99), (5, 5, '2022-01-03', 13.99), (6, 1, '2022-02-01', 15.99), (7, 2, '2022-02-01', 13.99), (8, 3, '2022-02-02', 9.99), (9, 4, '2022-02-02', 8.99), (10, 5, '2022-02-03', 14.99); CREATE TABLE menu (dish_id INT, dish_name VARCHAR(255), dish_type VARCHAR(255), dish_price DECIMAL(10, 2)); INSERT INTO menu (dish_id, dish_name, dish_type, dish_price) VALUES (1, 'Quinoa Salad', 'Vegetarian', 12.99), (2, 'Chicken Sandwich', 'Non-Vegetarian', 11.99), (3, 'Tofu Stir Fry', 'Vegetarian', 8.99), (4, 'Beef Burger', 'Non-Vegetarian', 7.99), (5, 'Carrot Cake', 'Dessert', 13.99);
|
Identify the dishes with the highest price increase since last month
|
SELECT m.dish_id, m.dish_name, (m.dish_price - s.max_price) AS price_increase FROM menu m JOIN (SELECT dish_id, MAX(dish_price) AS max_price FROM menu WHERE sale_date < DATE_SUB(CURDATE(), INTERVAL 1 MONTH) GROUP BY dish_id) s ON m.dish_id = s.dish_id ORDER BY price_increase DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE construction_labor_costs (cost_id INT, project_name VARCHAR(100), city VARCHAR(50), start_year INT, end_year INT, total_cost DECIMAL(10,2)); INSERT INTO construction_labor_costs (cost_id, project_name, city, start_year, end_year, total_cost) VALUES (1, 'CentralParkRevamp', 'New York City', 2019, 2020, 1500000), (2, 'BrooklynBridgeUpgrade', 'New York City', 2018, 2019, 1200000), (3, 'NYCLibraryUpgrade', 'New York City', 2018, 2020, 1800000);
|
What is the maximum total labor cost for construction projects in New York City between 2018 and 2020?
|
SELECT MAX(total_cost) FROM construction_labor_costs WHERE city = 'New York City' AND start_year >= 2018 AND end_year <= 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA if not exists aerospace;CREATE TABLE if not exists aerospace.aircraft (id INT PRIMARY KEY, name VARCHAR(50), model VARCHAR(50), manufacturer VARCHAR(50), accidents INT, launch_year INT); INSERT INTO aerospace.aircraft (id, name, model, manufacturer, accidents, launch_year) VALUES (1, 'Boeing', '737', 'Boeing', 3, 2000), (2, 'Boeing', '747', 'Boeing', 2, 2001), (3, 'Airbus', 'A320', 'Airbus', 6, 2002);
|
What is the number of accidents for each aircraft manufacturer per year?
|
SELECT manufacturer, launch_year, SUM(accidents) as total_accidents FROM aerospace.aircraft GROUP BY manufacturer, launch_year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE feedback (submission_id INT, submission_date DATE, service VARCHAR(50), city VARCHAR(50)); INSERT INTO feedback (submission_id, submission_date, service, city) VALUES (1, '2022-04-01', 'Transportation', 'Los Angeles'), (2, '2022-04-10', 'Transportation', 'Los Angeles'), (3, '2022-04-20', 'Parks and Recreation', 'Los Angeles');
|
How many citizen feedback submissions were made for transportation services in Los Angeles City in the month of April in the year 2022?
|
SELECT COUNT(*) FROM feedback WHERE service = 'Transportation' AND city = 'Los Angeles' AND EXTRACT(MONTH FROM submission_date) = 4 AND EXTRACT(YEAR FROM submission_date) = 2022;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE countries (country_code CHAR(2), country_name VARCHAR(50)); CREATE TABLE startups (startup_id INT, country_code CHAR(2), team_diversity DECIMAL(5,2)); INSERT INTO countries VALUES ('US', 'United States'), ('CA', 'Canada'), ('DE', 'Germany'); INSERT INTO startups VALUES (1, 'US', 75.5), (2, 'US', 82.3), (3, 'CA', 65.9), (4, 'DE', 80.1);
|
Which countries have the most diverse startup teams?
|
SELECT country_code, SUM(team_diversity) as total_diversity FROM startups GROUP BY country_code ORDER BY total_diversity DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE students (student_id INT, ethnicity VARCHAR(255), disability_status VARCHAR(255), hours_spent_on_mental_health_programs INT); INSERT INTO students (student_id, ethnicity, disability_status, hours_spent_on_mental_health_programs) VALUES (1, 'African American', 'Yes', 120), (2, 'Latino', 'No', 70), (3, 'Asian American', 'Yes', 90);
|
What is the maximum number of hours spent on mental health programs by students who identify as disabled, broken down by their ethnicity?
|
SELECT ethnicity, MAX(hours_spent_on_mental_health_programs) as max_hours FROM students WHERE disability_status = 'Yes' GROUP BY ethnicity;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE AI_Algorithms (algorithm_name TEXT, safety_evaluated BOOLEAN, safety_score INT); INSERT INTO AI_Algorithms (algorithm_name, safety_evaluated, safety_score) VALUES ('Algorithm X', TRUE, 85), ('Algorithm Y', FALSE, 90), ('Algorithm Z', TRUE, 75);
|
What is the average safety score for AI algorithms that have been evaluated for safety?
|
SELECT AVG(safety_score) FROM AI_Algorithms WHERE safety_evaluated = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE BeautyBrands (brand_id INT PRIMARY KEY, brand_name VARCHAR(100), sustainability_score INT, vegan_haircare BOOLEAN); INSERT INTO BeautyBrands (brand_id, brand_name, sustainability_score, vegan_haircare) VALUES (1, 'Lush', 85, TRUE), (2, 'The Body Shop', 82, TRUE);
|
Show beauty brands with a sustainability score above 80 and their vegan haircare product offerings.
|
SELECT brand_name, vegan_haircare FROM BeautyBrands WHERE sustainability_score > 80 AND vegan_haircare = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE risk_assessment (region VARCHAR(50), risk_score INT); INSERT INTO risk_assessment (region, risk_score) VALUES ('North America', 5), ('South America', 7), ('Europe', 6), ('Asia-Pacific', 8), ('Middle East', 9);
|
Show the total risk score and average risk score for the 'Asia-Pacific' region
|
SELECT total_risk_score, average_risk_score FROM risk_assessment_summary WHERE region = 'Asia-Pacific';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE workouts (id INT, user_id INT, workout_type VARCHAR(20)); CREATE TABLE members (id INT, name VARCHAR(50), membership_status VARCHAR(20), state VARCHAR(20)); INSERT INTO workouts (id, user_id, workout_type) VALUES (1, 1, 'Running'), (2, 1, 'Cycling'), (3, 2, 'Running'), (4, 3, 'Cycling'), (5, 3, 'Swimming'), (6, 4, 'Running'), (7, 4, 'Swimming'), (8, 5, 'Yoga'); INSERT INTO members (id, name, membership_status, state) VALUES (1, 'John Doe', 'Premium', 'Texas'), (2, 'Jane Doe', 'Basic', 'California'), (3, 'Bob Smith', 'Premium', 'Texas'), (4, 'Alice Johnson', 'Premium', 'California'), (5, 'Charlie Brown', 'Basic', 'New York');
|
Find the number of users who have completed a workout of each type and have a membership status of 'Premium'.
|
SELECT COUNT(*) FROM (SELECT user_id FROM workouts GROUP BY user_id INTERSECT SELECT id FROM members WHERE membership_status = 'Premium') AS user_set;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE security_incidents (id INT, timestamp TIMESTAMP, country VARCHAR(255), attack_vector VARCHAR(255), incident_type VARCHAR(255)); INSERT INTO security_incidents (id, timestamp, country, attack_vector, incident_type) VALUES (1, '2021-01-01 12:00:00', 'Germany', 'Network', 'Ransomware'), (2, '2021-02-05 10:30:00', 'France', 'Email', 'Phishing');
|
What is the percentage of security incidents caused by each attack vector for a specific country in the last year?
|
SELECT attack_vector, 100.0 * COUNT(*) / (SELECT COUNT(*) FROM security_incidents WHERE timestamp >= NOW() - INTERVAL 1 YEAR AND country = 'Germany') as percentage FROM security_incidents WHERE timestamp >= NOW() - INTERVAL 1 YEAR AND country = 'Germany' GROUP BY attack_vector;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE circular_investments (year INT, region TEXT, investment FLOAT); INSERT INTO circular_investments (year, region, investment) VALUES (2018, 'Latin America', 1500000), (2018, 'North America', 2500000), (2019, 'Latin America', NULL), (2019, 'North America', 3000000);
|
What is the average circular economy initiative investment in Latin America in USD?
|
SELECT AVG(investment) FROM circular_investments WHERE region = 'Latin America';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE fish_species (id INT, name VARCHAR(50), farm_location VARCHAR(50)); CREATE TABLE ocean_health_metrics (id INT, fish_species_id INT, metric VARCHAR(50), value FLOAT); INSERT INTO fish_species (id, name, farm_location) VALUES (1, 'Salmon', 'Norway'), (2, 'Tuna', 'Philippines'), (3, 'Shrimp', 'Thailand'); INSERT INTO ocean_health_metrics (id, fish_species_id, metric, value) VALUES (1, 1, 'Dissolved Oxygen', 6.5), (2, 1, 'PH Level', 8.2), (3, 2, 'Dissolved Oxygen', 5.8), (4, 2, 'PH Level', 7.9), (5, 3, 'Dissolved Oxygen', 7.1), (6, 3, 'PH Level', 7.8);
|
List all fish species with their corresponding farm locations and ocean health metrics?
|
SELECT fs.name, fl.farm_location, ohm.metric, ohm.value FROM fish_species fs INNER JOIN ocean_health_metrics ohm ON fs.id = ohm.fish_species_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE bank_sharia (bank_name TEXT, assets NUMERIC, region TEXT); INSERT INTO bank_sharia (bank_name, assets, region) VALUES ('Al Rajhi Bank', 104473, 'Middle East'); INSERT INTO bank_sharia (bank_name, assets, region) VALUES ('Kuwait Finance House', 63592, 'Middle East');
|
What is the total assets of banks offering Shariah-compliant finance in the Middle East?
|
SELECT SUM(assets) FROM bank_sharia WHERE region = 'Middle East' AND sharia_compliant = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE maintenance_requests (request_id INT, vendor_name TEXT, vendor_city TEXT, state TEXT); CREATE TABLE equipment_maintenance (request_id INT, equipment_type TEXT); INSERT INTO maintenance_requests (request_id, vendor_name, vendor_city, state) VALUES (1, 'XYZ Services', 'Los Angeles', 'California'), (2, 'LMN Co', 'Austin', 'Texas'); INSERT INTO equipment_maintenance (request_id, equipment_type) VALUES (1, 'Tank'), (2, 'Aircraft');
|
List all military equipment maintenance requests performed by vendors in a specific city
|
SELECT mr.vendor_name FROM maintenance_requests mr JOIN equipment_maintenance em ON mr.request_id = em.request_id WHERE mr.vendor_city = 'Los Angeles';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE underwater_volcanoes (id INT, name VARCHAR(255), region VARCHAR(50), depth INT); INSERT INTO underwater_volcanoes (id, name, region, depth) VALUES (1, 'Arctic Volcano 1', 'Arctic', 2500), (2, 'Arctic Volcano 2', 'Arctic', 2800);
|
What is the maximum depth of underwater volcanoes in the Arctic region?
|
SELECT MAX(depth) FROM underwater_volcanoes WHERE region = 'Arctic';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE wells (well_id VARCHAR(10), well_location VARCHAR(20)); CREATE TABLE production (well_id VARCHAR(10), production_count INT);
|
Insert a new record for well 'D04' in 'Sahara Desert' with a production count of 8000.
|
INSERT INTO wells (well_id, well_location) VALUES ('D04', 'Sahara Desert'); INSERT INTO production (well_id, production_count) VALUES ('D04', 8000);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customer (customer_id INT, name VARCHAR(100), country VARCHAR(50), assets_value DECIMAL(18,2)); INSERT INTO customer (customer_id, name, country, assets_value) VALUES (1, 'John Doe', 'USA', 50000.00), (2, 'Jane Smith', 'Canada', 75000.00);
|
What is the total assets value for customers from the USA as of 2022-01-01?
|
SELECT SUM(assets_value) FROM customer WHERE country = 'USA';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE OrganizationRisks (OrgID INT, Sector VARCHAR(50), RiskRating INT, Year INT); INSERT INTO OrganizationRisks (OrgID, Sector, RiskRating, Year) VALUES (1, 'Financial', 3, 2018), (2, 'Financial', 4, 2018), (3, 'Financial', 2, 2019), (4, 'Financial', 3, 2019), (5, 'Financial', 5, 2020), (6, 'Financial', 4, 2020);
|
Calculate the year-over-year change in risk ratings for organizations in the financial sector?
|
SELECT OrgID, Sector, Year, RiskRating, LAG(RiskRating) OVER (PARTITION BY Sector ORDER BY Year) as PreviousYearRating, (RiskRating - LAG(RiskRating) OVER (PARTITION BY Sector ORDER BY Year)) as YoYChange FROM OrganizationRisks WHERE Sector = 'Financial';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE City_Feedback (city_id INT, rating INT, comment TEXT); INSERT INTO City_Feedback (city_id, rating, comment) VALUES (1, 4, 'Good services'); INSERT INTO City_Feedback (city_id, rating, comment) VALUES (1, 5, 'Excellent waste management'); INSERT INTO City_Feedback (city_id, rating, comment) VALUES (2, 3, 'Average public transportation'); INSERT INTO City_Feedback (city_id, rating, comment) VALUES (2, 2, 'Poor street cleaning'); INSERT INTO City_Feedback (city_id, rating, comment) VALUES (3, 5, 'Excellent education');
|
What is the average citizen feedback rating for cities with more than three feedback records?
|
SELECT City_Feedback.city_id, AVG(rating) as 'Avg Citizen Feedback Rating' FROM City_Feedback GROUP BY City_Feedback.city_id HAVING COUNT(City_Feedback.city_id) > 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE prisons (prison_id INT, region VARCHAR(255), reentry_program BOOLEAN); INSERT INTO prisons (prison_id, region, reentry_program) VALUES (1, 'Northeast', FALSE), (2, 'Southeast', FALSE), (3, 'Midwest', TRUE), (4, 'Southwest', FALSE), (5, 'Northwest', FALSE), (6, 'Midwest', TRUE), (7, 'Midwest', TRUE);
|
Determine the number of prisons that offer reentry programs for inmates in the midwest
|
SELECT COUNT(*) FROM prisons WHERE region = 'Midwest' AND reentry_program = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE dish(category VARCHAR(255), ingredient VARCHAR(255), quantity INT); INSERT INTO dish(category, ingredient, quantity) VALUES ('Starter', 'Tofu', 100), ('Starter', 'Lentils', 150), ('Main', 'Chickpeas', 200), ('Main', 'Tofu', 250), ('Side', 'Quinoa', 120), ('Side', 'Lentils', 180);
|
What is the total quantity of vegetarian ingredients used in each dish category?
|
SELECT category, SUM(quantity) as total_veg_quantity FROM dish WHERE ingredient IN ('Tofu', 'Lentils', 'Chickpeas', 'Quinoa') GROUP BY category;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE security_incidents (id INT, sector VARCHAR(255), date DATE);
|
What is the maximum number of security incidents reported in a single day in the past month?
|
SELECT MAX(number_of_incidents_per_day) FROM (SELECT DATE(date) as date, COUNT(*) as number_of_incidents_per_day FROM security_incidents WHERE date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY date) as subquery;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE menu (restaurant_id INT, item_name TEXT, item_type TEXT, diet TEXT); INSERT INTO menu (restaurant_id, item_name, item_type, diet) VALUES (1, 'Spaghetti', 'Entree', 'Vegetarian'), (1, 'Quinoa Salad', 'Entree', 'Vegan'), (1, 'Garden Burger', 'Entree', 'Vegan'), (2, 'Tofu Stir Fry', 'Entree', 'Vegan'), (2, 'Vegetable Curry', 'Entree', 'Vegetarian'), (3, 'Eggplant Parmesan', 'Entree', 'Vegetarian'), (3, 'Vegetable Lasagna', 'Entree', 'Vegetarian'), (3, 'Lentil Soup', 'Entree', 'Vegan'), (4, 'Chickpea Salad', 'Entree', 'Vegan'), (4, 'Mushroom Risotto', 'Entree', 'Vegetarian'), (4, 'Spinach Stuffed Shells', 'Entree', 'Vegetarian');
|
How many vegan options are there on the menu for Restaurant D?
|
SELECT COUNT(*) as num_vegan_options FROM menu m WHERE m.restaurant_id = 4 AND m.diet = 'Vegan';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE RecyclingRates (year INT, material VARCHAR(20), rate FLOAT); INSERT INTO RecyclingRates (year, material, rate) VALUES (2018, 'plastic', 0.35), (2018, 'paper', NULL), (2019, 'plastic', 0.40), (2019, 'paper', 0.70);
|
What was the recycling rate for paper in 2018?
|
SELECT rate FROM RecyclingRates WHERE year = 2018 AND material = 'paper';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE animals (animal_id SERIAL PRIMARY KEY, name VARCHAR(255), species VARCHAR(255));
|
Drop the "species" column from the "animals" table
|
ALTER TABLE animals DROP COLUMN species;
|
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.