context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE agri_innovation_africa(id INT, project TEXT, location TEXT, budget INT, year INT); INSERT INTO agri_innovation_africa (id, project, location, budget, year) VALUES (1, 'Smart Irrigation Project', 'Africa', 800000, 2022);
|
What is the average budget for agricultural innovation projects in 'Africa' in '2022'?
|
SELECT AVG(budget) FROM agri_innovation_africa WHERE location = 'Africa' AND year = 2022;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE green_building_certifications (certification_id INTEGER, city TEXT, certification_date DATE); INSERT INTO green_building_certifications VALUES (1, 'CityA', '2022-01-10'), (2, 'CityB', '2022-02-20'), (3, 'CityA', '2022-03-05'), (4, 'CityC', '2022-04-10');
|
What is the number of green building certifications issued per quarter in each city?
|
SELECT DATE_TRUNC('quarter', certification_date) AS quarter, city, COUNT(certification_id) AS certifications, RANK() OVER (PARTITION BY city ORDER BY DATE_TRUNC('quarter', certification_date)) AS rank FROM green_building_certifications GROUP BY quarter, city;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE labor_stats (site_id VARCHAR(10) PRIMARY KEY, total_employees INT, turnover_rate DECIMAL(5,2));
|
Update labor_stats table to set 'total_employees' to 300 for 'site_id' 010
|
UPDATE labor_stats SET total_employees = 300 WHERE site_id = '010';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE products (product_id INT, product_name VARCHAR(20), cruelty_free BOOLEAN, sale_date DATE); INSERT INTO products (product_id, product_name, cruelty_free, sale_date) VALUES (1, 'Lipstick', true, '2020-01-01'), (2, 'Eyeshadow', false, '2020-01-01'), (3, 'Blush', true, '2020-02-01'), (4, 'Mascara', true, '2020-03-01');
|
How many cruelty-free products were sold in each month of 2020?
|
SELECT EXTRACT(MONTH FROM sale_date) AS month, COUNT(*) FROM products WHERE cruelty_free = true GROUP BY month;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE bus_trips (trip_id INT, has_air_conditioning BOOLEAN, city VARCHAR(50)); INSERT INTO bus_trips (trip_id, has_air_conditioning, city) VALUES (1, true, 'Mexico City'), (2, false, 'Mexico City'), (3, true, 'Mexico City');
|
What is the total number of bus trips in Mexico City without air conditioning?
|
SELECT COUNT(*) FROM bus_trips WHERE has_air_conditioning = false AND city = 'Mexico City';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE american_football_stats (player VARCHAR(255), year INT, touchdowns INT); INSERT INTO american_football_stats (player, year, touchdowns) VALUES ('Tom Brady', 2017, 32);
|
How many touchdowns did Tom Brady throw in 2017?
|
SELECT touchdowns FROM american_football_stats WHERE player = 'Tom Brady' AND year = 2017;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE rural_infrastructure (id INT, project_name VARCHAR(50), sector VARCHAR(50), start_date DATE, end_date DATE, budget FLOAT); INSERT INTO rural_infrastructure (id, project_name, sector, start_date, end_date, budget) VALUES (1, 'Precision Farming Initiative', 'Agriculture', '2019-04-01', '2022-12-31', 500000);
|
What are the names of all the agricultural innovation projects in the 'rural_infrastructure' table?
|
SELECT project_name FROM rural_infrastructure WHERE sector = 'Agriculture';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE labor_costs (id INT, project_state TEXT, project_type TEXT, labor_cost DECIMAL(10,2)); INSERT INTO labor_costs (id, project_state, project_type, labor_cost) VALUES (1, 'Arizona', 'Sustainable', 22000.00), (2, 'Arizona', 'Conventional', 18000.00), (3, 'California', 'Sustainable', 12000.00);
|
What is the total labor cost for all sustainable building projects in Arizona?
|
SELECT SUM(labor_cost) FROM labor_costs WHERE project_state = 'Arizona' AND project_type = 'Sustainable';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE districts (id INT, name VARCHAR(255)); INSERT INTO districts (id, name) VALUES (1, 'District1'), (2, 'District2'), (3, 'District3'); CREATE TABLE water_consumption (district_id INT, consumption INT, date DATE); INSERT INTO water_consumption (district_id, consumption, date) VALUES (1, 1000, '2021-05-01'), (1, 1100, '2021-05-02'), (2, 800, '2021-05-01'), (2, 900, '2021-05-02'), (3, 1200, '2021-05-01'), (3, 1300, '2021-05-02');
|
What is the average water consumption (in gallons) for each district in New York in the month of May 2021?
|
SELECT district_id, AVG(consumption) as avg_consumption FROM water_consumption WHERE date BETWEEN '2021-05-01' AND '2021-05-31' GROUP BY district_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE wildlife_habitat (id INT, name VARCHAR(50), area FLOAT); INSERT INTO wildlife_habitat (id, name, area) VALUES (1, 'Habitat1', 250.3), (2, 'Habitat2', 150.8), (3, 'Habitat3', 300.5);
|
How many wildlife habitat records were inserted for areas greater than 200 sq. km?
|
SELECT COUNT(*) FROM wildlife_habitat WHERE area > 200;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Buses (route_id INT, region VARCHAR(20), fare DECIMAL(5,2)); INSERT INTO Buses (route_id, region, fare) VALUES (1, 'Southside', 1.50), (2, 'Northpoint', 2.00), (3, 'Southside', 2.50);
|
What is the average fare for buses in the 'Southside' region?
|
SELECT AVG(fare) FROM Buses WHERE region = 'Southside';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customer_transactions_2 (customer_id INT, customer_name VARCHAR(20), transaction_id INT, transaction_amount DECIMAL(10,2)); INSERT INTO customer_transactions_2 (customer_id, customer_name, transaction_id, transaction_amount) VALUES (1, 'Ravi Patel', 1, 1000.00), (2, 'Sophia Lee', 2, 500.00), (3, 'Hugo Chen', 3, 2000.00);
|
Who are the customers with a transaction amount higher than the average transaction amount?
|
SELECT customer_name FROM customer_transactions_2 WHERE transaction_amount > (SELECT AVG(transaction_amount) FROM customer_transactions_2);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ProgramExpenses (ExpenseID INT, ExpenseDate DATE, ExpenseAmount DECIMAL, ExpenseCategory TEXT);
|
What is the total amount spent on program expenses in the year 2018, broken down by program category?
|
SELECT EXPENSECATEGORY, SUM(EXPENSEAMOUNT) as TotalExpense FROM ProgramExpenses WHERE YEAR(ExpenseDate) = 2018 GROUP BY ExpenseCategory;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE solar_plants_australia (id INT, name VARCHAR(100), country VARCHAR(50), efficiency_rating FLOAT); INSERT INTO solar_plants_australia (id, name, country, efficiency_rating) VALUES (1, 'Solar Plant 1', 'Australia', 0.75), (2, 'Solar Plant 2', 'Australia', 0.90), (3, 'Solar Plant 3', 'Australia', 0.65);
|
Identify the Solar Power Plants in Australia with an efficiency rating below 0.8
|
SELECT name, efficiency_rating FROM solar_plants_australia WHERE country = 'Australia' AND efficiency_rating < 0.8;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE fleet (id INT, model VARCHAR(50), year_manufactured INT); INSERT INTO fleet (id, model, year_manufactured) VALUES (1, 'B747', 1990), (2, 'A320', 2010), (3, 'B787', 2015);
|
What is the average age of aircraft in the fleet?
|
SELECT AVG(YEAR_MANUFACTURED) FROM fleet;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE users (id INT, username VARCHAR(255), created_at DATETIME, last_post_at DATETIME); INSERT INTO users (id, username, created_at, last_post_at) VALUES (1, 'user1', '2020-12-31 23:59:59', '2021-01-01 00:00:00'), (2, 'user2', '2021-06-01 12:00:00', NULL);
|
Delete all user accounts that were created before January 1, 2021 and have not posted any content since then.
|
DELETE FROM users WHERE created_at < '2021-01-01' AND last_post_at IS NULL;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SustainableAccommodations (id INT, country VARCHAR(20)); INSERT INTO SustainableAccommodations (id, country) VALUES (1, 'Japan'), (2, 'Korea'), (3, 'China');
|
How many sustainable accommodations are there in Japan, Korea, and China?
|
SELECT COUNT(*) FROM SustainableAccommodations WHERE country IN ('Japan', 'Korea', 'China');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vessels (vessel_id INT, vessel_name VARCHAR(255), length INT, year_built INT); CREATE TABLE vessel_inspections (vessel_id INT, inspection_date DATE, inspection_type VARCHAR(255), inspection_results VARCHAR(255));
|
Display vessels that did not have any inspections in 2022 and their corresponding details.
|
SELECT v.vessel_id, v.vessel_name, v.length, v.year_built FROM vessels v LEFT JOIN vessel_inspections vi ON v.vessel_id = vi.vessel_id WHERE vi.vessel_id IS NULL;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Exhibitions (exhibition_id INT, gallery_name VARCHAR(255), artist_id INT, artwork_id INT); INSERT INTO Exhibitions (exhibition_id, gallery_name, artist_id, artwork_id) VALUES (1, 'Gallery A', 101, 201), (2, 'Gallery A', 102, 202), (3, 'Gallery B', 103, 203);
|
Which artists have their artwork exhibited in 'Gallery A'?
|
SELECT DISTINCT artist_id FROM Exhibitions WHERE gallery_name = 'Gallery A';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE meals (id INT, name TEXT, customer_type TEXT); INSERT INTO meals (id, name, customer_type) VALUES (1, 'Veggie Delight', 'vegan'), (2, 'Chef Salad', 'non-vegan'), (3, 'Tofu Stir Fry', 'vegan'); CREATE TABLE nutrition (meal_id INT, calorie_count INT); INSERT INTO nutrition (meal_id, calorie_count) VALUES (1, 400), (2, 600), (3, 500);
|
What is the average calorie intake per meal for vegan customers?
|
SELECT AVG(nutrition.calorie_count) FROM nutrition JOIN meals ON nutrition.meal_id = meals.id WHERE meals.customer_type = 'vegan';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE accommodations_per_student (accommodation_id INT, student_id INT, student_name TEXT, accommodation_year INT); INSERT INTO accommodations_per_student (accommodation_id, student_id, student_name, accommodation_year) VALUES (1, 1, 'Isabella', 2018), (2, 2, 'Liam', 2018), (3, 3, 'Olivia', 2019), (4, 4, 'Elijah', 2019), (5, 5, 'Ava', 2020), (6, 6, 'Ethan', 2020);
|
What is the average number of accommodations received per student with disabilities in 2020?
|
SELECT accommodation_year, AVG(COUNT(*)) AS avg_accommodations_per_student FROM accommodations_per_student WHERE student_id IN (SELECT student_id FROM students WHERE disability = true) GROUP BY accommodation_year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MilitaryEquipment (OrderID INT, Equipment VARCHAR(50), Quantity INT, Company VARCHAR(50), OrderDate DATE); INSERT INTO MilitaryEquipment (OrderID, Equipment, Quantity, Company, OrderDate) VALUES (3, 'Radar Systems', 15, 'Raytheon', '2022-03-20'); INSERT INTO MilitaryEquipment (OrderID, Equipment, Quantity, Company, OrderDate) VALUES (4, 'Missile Defense', 8, 'Northrop Grumman', '2022-02-05');
|
What is the most recent order from Raytheon?
|
SELECT OrderID, Equipment, Quantity, Company, OrderDate, ROW_NUMBER() OVER(ORDER BY OrderDate DESC) AS RecentOrder FROM MilitaryEquipment WHERE Company = 'Raytheon'
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE teachers (teacher_id INT, last_pd_course_date DATE); INSERT INTO teachers (teacher_id, last_pd_course_date) VALUES (1, '2022-01-01'), (2, '2021-12-15'), (3, NULL);
|
How many teachers have completed professional development courses in the last year?
|
SELECT COUNT(teacher_id) FROM teachers WHERE last_pd_course_date >= DATEADD(year, -1, GETDATE());
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mexico_city_water_consumption (id INT, date DATE, neighborhood VARCHAR(20), water_consumption FLOAT); INSERT INTO mexico_city_water_consumption (id, date, neighborhood, water_consumption) VALUES (1, '2021-01-01', 'Polanco', 600.0), (2, '2021-01-02', 'Coyoacan', 700.0);
|
What is the total water consumption for each neighborhood in Mexico City in the month with the highest consumption?
|
SELECT neighborhood, SUM(water_consumption) FROM mexico_city_water_consumption WHERE date = (SELECT MAX(date) FROM mexico_city_water_consumption) GROUP BY neighborhood;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE circular_economy_initiatives (id INT, region VARCHAR(50), year INT, initiative VARCHAR(100));
|
Insert new circular economy initiatives in the West region for 2023.
|
INSERT INTO circular_economy_initiatives (id, region, year, initiative) VALUES (1, 'West', 2023, 'Implementing a region-wide e-waste recycling program'), (2, 'West', 2023, 'Promoting local composting and organic waste reduction');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donations (id INT, donor_id INT, amount DECIMAL(10,2), donor_country VARCHAR(50)); INSERT INTO donations (id, donor_id, amount, donor_country) VALUES (1, 1, 1000.00, 'USA'); INSERT INTO donations (id, donor_id, amount, donor_country) VALUES (2, 2, 2000.00, 'Canada'); INSERT INTO donations (id, donor_id, amount, donor_country) VALUES (3, 3, 500.00, 'USA');
|
Find the total amount donated by donors from the USA
|
SELECT donor_country, SUM(amount) as total_donated FROM donations WHERE donor_country = 'USA' GROUP BY donor_country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE regions (region_id INT, region_name VARCHAR(255)); INSERT INTO regions (region_id, region_name) VALUES (1, 'North'), (2, 'South'), (3, 'East'), (4, 'West'); CREATE TABLE cultural_sites (site_id INT, site_name VARCHAR(255), region_id INT); INSERT INTO cultural_sites (site_id, site_name, region_id) VALUES (1, 'Museum A', 1), (2, 'Historic House B', 2), (3, 'Theater C', 3), (4, 'Gallery D', 4);
|
How many cultural heritage sites are in each region?
|
SELECT region_name, COUNT(*) as num_sites FROM cultural_sites JOIN regions ON cultural_sites.region_id = regions.region_id GROUP BY region_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE if not exists asset (asset_id INT PRIMARY KEY, name VARCHAR(255), type VARCHAR(255), issuer VARCHAR(255)); CREATE TABLE if not exists transaction (transaction_id INT PRIMARY KEY, sender VARCHAR(255), receiver VARCHAR(255), amount INT, asset_id INT, FOREIGN KEY (asset_id) REFERENCES asset(asset_id));
|
What transactions were made with asset ID 2?
|
SELECT * FROM transaction WHERE asset_id = 2;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE daily_revenue (date DATE, revenue FLOAT); INSERT INTO daily_revenue (date, revenue) VALUES ('2022-01-01', 5000), ('2022-01-02', 6000), ('2022-01-03', 4000);
|
What was the revenue for each day in the first week of January 2022?
|
SELECT date, revenue FROM daily_revenue WHERE date BETWEEN '2022-01-01' AND '2022-01-07';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE production (element VARCHAR(10), year INT, month INT, quantity INT);
|
Get the total production quantity of Terbium for each month in 2021 from the 'production' table.
|
SELECT month, SUM(quantity) as total_quantity FROM production WHERE element = 'Terbium' AND year = 2021 GROUP BY month;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE funding_records (company_id INT, funding FLOAT, date DATE); CREATE TABLE companies (id INT, name TEXT, industry TEXT, founders_gender TEXT, funding FLOAT);
|
Delete funding records for companies that have received no funding in the gaming industry.
|
DELETE FROM funding_records WHERE company_id NOT IN (SELECT id FROM companies WHERE funding > 0) AND industry = 'gaming';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE funding(startup_id INT, funding_amount DECIMAL(10, 2)); INSERT INTO funding(startup_id, funding_amount) VALUES (1, 25000.00), (2, 75000.00); CREATE TABLE startups(id INT, name TEXT, industry TEXT); INSERT INTO startups(id, name, industry) VALUES (1, 'HealthInnovate', 'Health'), (2, 'TechBoost', 'Technology');
|
What is the minimum funding amount received by a startup in the health sector?
|
SELECT MIN(funding_amount) FROM funding JOIN startups ON startups.id = funding.startup_id WHERE startups.industry = 'Health';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE community_health_centers_2 (id INT, name TEXT, location TEXT); INSERT INTO community_health_centers_2 (id, name, location) VALUES (1, 'Center A', 'urban'), (2, 'Center B', 'rural'), (3, 'Center C', 'suburban');
|
What is the total number of community health centers in urban and suburban areas?
|
SELECT COUNT(*) FROM community_health_centers_2 WHERE location IN ('urban', 'suburban');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Cyber_Threats (ID INT, Region VARCHAR(50), Quarter VARCHAR(50), Year INT, Threats INT); INSERT INTO Cyber_Threats (ID, Region, Quarter, Year, Threats) VALUES (1, 'Asia', 'Q2', 2019, 500), (2, 'Asia', 'Q2', 2020, 700), (3, 'Europe', 'Q1', 2020, 600);
|
What was the total number of cyber threats detected in Asia in Q2 of 2020?
|
SELECT Threats FROM Cyber_Threats WHERE Region = 'Asia' AND Quarter = 'Q2' AND Year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customers (customer_id INT, name VARCHAR(255), data_usage_gb FLOAT, state VARCHAR(255)); INSERT INTO customers (customer_id, name, data_usage_gb, state) VALUES (1, 'John Doe', 10.5, 'New York');
|
What is the average monthly data usage for customers in New York?
|
SELECT AVG(data_usage_gb) FROM customers WHERE state = 'New York';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE InclusiveHousing (id INT PRIMARY KEY, city VARCHAR(50), state VARCHAR(50), policy VARCHAR(100)); INSERT INTO InclusiveHousing (id, city, state, policy) VALUES (1, 'Chicago', 'IL', 'Affordable Housing Ordinance'), (2, 'Atlanta', 'GA', 'Inclusionary Zoning');
|
Create a view for inclusive housing policies
|
CREATE VIEW InclusiveHousingView AS SELECT * FROM InclusiveHousing WHERE state IN ('IL', 'GA');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE community_engagement_initiatives_continent (id INT, initiative_name VARCHAR(100), budget INT, continent VARCHAR(50)); INSERT INTO community_engagement_initiatives_continent (id, initiative_name, budget, continent) VALUES (1, 'Youth Arts Festival', 50000, 'North America'), (2, 'Elder Cultural Exchange', 30000, 'Europe');
|
What is the maximum budget for community engagement initiatives by continent?
|
SELECT continent, MAX(budget) as max_budget FROM community_engagement_initiatives_continent GROUP BY continent;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE advertisers (id INT PRIMARY KEY, name TEXT NOT NULL); CREATE TABLE ad_revenue (advertiser_id INT, revenue DECIMAL(10, 2), date DATE);
|
Show total revenue for each advertiser, grouped by the quarter
|
SELECT advertisers.name, CONCAT(QUARTER(ad_revenue.date), '/', YEAR(ad_revenue.date)) as quarter, SUM(ad_revenue.revenue) as total_revenue FROM advertisers INNER JOIN ad_revenue ON advertisers.id = ad_revenue.advertiser_id GROUP BY advertisers.name, quarter;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ship (id INT, name TEXT, type TEXT, year_built INT); INSERT INTO ship (id, name, type, year_built) VALUES (1, 'Sea Giant', 'Cargo', 2010), (2, 'Ocean Titan', 'Cargo', 2015), (3, 'Star Explorer', 'Tugboat', 2008), (4, 'Harbor Master', 'Tugboat', 2012);
|
What is the average age of all tugboats in the fleet?
|
SELECT AVG(DATEDIFF(year, s.year_built, GETDATE())) FROM ship s WHERE s.type = 'Tugboat';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE eco_accommodations (id INT, country VARCHAR(255), type VARCHAR(255)); INSERT INTO eco_accommodations (id, country, type) VALUES (1, 'France', 'Eco Lodge'), (2, 'Germany', 'Green Hotel'), (3, 'Italy', 'Eco Hotel');
|
What is the total number of eco-friendly accommodations in Europe?
|
SELECT COUNT(*) FROM eco_accommodations WHERE country IN ('Europe');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Crimes (id INT, date DATE, age INT, neighborhood VARCHAR(20));
|
How many crimes were committed by juveniles (age < 18) in the "southside" neighborhood in the last month?
|
SELECT COUNT(*) FROM Crimes WHERE age < 18 AND neighborhood = 'southside' AND date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Investments (InvestmentID INT, InvestorID INT, Country VARCHAR(20), Amount INT); INSERT INTO Investments (InvestmentID, InvestorID, Country, Amount) VALUES (1, 1, 'USA', 4000), (2, 1, 'Canada', 3000), (3, 2, 'Mexico', 5000), (4, 2, 'Brazil', 6000), (5, 3, 'USA', 7000), (6, 3, 'Canada', 8000); CREATE TABLE Investors (InvestorID INT, Name VARCHAR(20), Gender VARCHAR(10)); INSERT INTO Investors (InvestorID, Name, Gender) VALUES (1, 'John Doe', 'Male'), (2, 'Jane Smith', 'Female'), (3, 'Jim Brown', 'Male');
|
Who are the investors who made investments in a specific country?
|
SELECT Investors.Name FROM Investors JOIN Investments ON Investors.InvestorID = Investments.InvestorID WHERE Investments.Country = 'USA';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE museums (id INT, name VARCHAR(255), city VARCHAR(255)); INSERT INTO museums (id, name, city) VALUES (1, 'Metropolitan Museum of Art', 'New York'), (2, 'British Museum', 'London'), (3, 'Louvre Museum', 'Paris');
|
List all unique cities from the 'museums' table.
|
SELECT DISTINCT city FROM museums;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE projects (id INT, name TEXT, category TEXT, location TEXT, start_date DATE, end_date DATE); INSERT INTO projects (id, name, category, location, start_date, end_date) VALUES (1, 'Refugee Support Project', 'Refugee', 'Africa', '2020-01-01', '2020-12-31'), (2, 'Disaster Relief Project', 'Disaster', 'Asia', '2019-01-01', '2020-12-31'), (3, 'Community Development Project', 'Community', 'Africa', '2018-01-01', '2018-12-31');
|
How many refugee support projects were carried out in Africa in the year 2020?
|
SELECT COUNT(*) FROM projects WHERE category = 'Refugee' AND location = 'Africa' AND YEAR(start_date) = 2020 AND YEAR(end_date) = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mental_health_parity (patient_id INT, race VARCHAR(25)); INSERT INTO mental_health_parity (patient_id, race) VALUES (1, 'Hispanic'), (2, 'African American'), (3, 'Asian'), (4, 'Caucasian'), (5, 'Native American'), (6, 'Hispanic'), (7, 'African American'), (8, 'Asian'), (9, 'Caucasian'), (10, 'Native American');
|
What is the racial breakdown of patients who have experienced mental health parity violations?
|
SELECT race, COUNT(patient_id) as num_patients FROM mental_health_parity GROUP BY race;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ai_researchers (id INT, name VARCHAR(100), published_papers INT); INSERT INTO ai_researchers (id, name, published_papers) VALUES (1, 'Alice', 3), (2, 'Bob', 0), (3, 'Charlotte', 2), (4, 'David', 1), (5, 'Eva', 0);
|
Delete AI researchers who haven't published any papers.
|
DELETE FROM ai_researchers WHERE published_papers = 0;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE crimes (id INT, date DATE, location VARCHAR(20)); INSERT INTO crimes (id, date, location) VALUES (1, '2022-01-01', 'downtown'), (2, '2022-02-01', 'uptown'), (3, '2022-01-10', 'downtown');
|
How many crimes were committed in the "downtown" area in the month of January?
|
SELECT COUNT(*) FROM crimes WHERE EXTRACT(MONTH FROM date) = 1 AND location = 'downtown';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sites (country VARCHAR(255), num_sites INTEGER); INSERT INTO sites (country, num_sites) VALUES ('Country1', 12), ('Country2', 8), ('Country3', 15), ('Country4', 6), ('Country5', 20), ('Country6', 9);
|
What are the top 5 countries with the most heritage sites and their respective counts?
|
SELECT country, num_sites FROM sites ORDER BY num_sites DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE volunteers (volunteer_id INT, city VARCHAR(20), ethnicity VARCHAR(20)); INSERT INTO volunteers (volunteer_id, city, ethnicity) VALUES (1, 'toronto', 'Indigenous'), (2, 'montreal', 'South Asian'), (3, 'vancouver', 'Indigenous'), (4, 'toronto', 'Latinx');
|
What is the total number of volunteers who identify as Indigenous in 'toronto' and 'vancouver'?
|
SELECT COUNT(*) FROM volunteers WHERE city IN ('toronto', 'vancouver') AND ethnicity = 'Indigenous';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE companies (id INT, name TEXT, industry TEXT); CREATE TABLE funding (company_id INT, amount INT); INSERT INTO companies (id, name, industry) VALUES (1, 'MoveFast', 'Transportation'); INSERT INTO funding (company_id, amount) VALUES (1, 2000000);
|
Find the company in the transportation sector with the highest total funding, and list its name, industry, and total funding amount.
|
SELECT companies.name, companies.industry, SUM(funding.amount) AS total_funding FROM companies INNER JOIN funding ON companies.id = funding.company_id WHERE companies.industry = 'Transportation' GROUP BY companies.name, companies.industry ORDER BY total_funding DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE stations (id INT, station_name VARCHAR(20), bikes INT, docks INT); INSERT INTO stations (id, station_name, bikes, docks) VALUES (1, 'Station 1', 10, 20), (2, 'Station 2', 15, 20), (3, 'Station 3', 20, 20);
|
What is the average number of bikes available at each station?
|
SELECT AVG(bikes) FROM stations;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Accounts (AccountID INT, ClientID INT, AccountBalance FLOAT, State VARCHAR(20)); INSERT INTO Accounts (AccountID, ClientID, AccountBalance, State) VALUES (1, 1, 5000, 'NY'), (2, 1, 7000, 'CA'), (3, 2, 12000, 'NY'), (4, 3, 3000, 'CA'), (5, 4, 15000, 'NY');
|
What is the average account balance for clients with accounts in New York and California?
|
SELECT AVG(AccountBalance) FROM Accounts WHERE State IN ('NY', 'CA') GROUP BY ClientID HAVING COUNT(DISTINCT State) = 2;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donors (donor_id INT, donor_name VARCHAR(50), donation_date DATE, amount INT); INSERT INTO Donors (donor_id, donor_name, donation_date, amount) VALUES (1, 'John Doe', '2021-01-01', 100), (2, 'Jane Smith', '2020-01-01', 50), (3, 'Jim Brown', '2019-01-01', 200);
|
What is the total donation amount by each donor in the last year?
|
SELECT donor_name, SUM(amount) AS Total_Donations FROM Donors D WHERE donation_date >= DATE(NOW()) - INTERVAL 1 YEAR GROUP BY donor_name
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE FishCaught (year INT, ocean VARCHAR(50), quantity INT); INSERT INTO FishCaught (year, ocean, quantity) VALUES (2020, 'Pacific Ocean', 500), (2020, 'Pacific Ocean', 550), (2020, 'Pacific Ocean', 600), (2021, 'Pacific Ocean', 650), (2021, 'Pacific Ocean', 700), (2021, 'Pacific Ocean', 750);
|
What is the total quantity of fish caught in the Pacific Ocean in 2020 and 2021?
|
SELECT SUM(quantity) as total_quantity FROM FishCaught WHERE ocean = 'Pacific Ocean' AND year IN (2020, 2021);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE PuzzleGame (playerID INT, region VARCHAR(5), level INT); INSERT INTO PuzzleGame (playerID, region, level) VALUES (1, 'SA', 12), (2, 'SA', 15), (3, 'SA', 8), (4, 'EU', 20);
|
Find the number of players who achieved level 10 or above in 'PuzzleGame' in 'SA' region.
|
SELECT COUNT(*) FROM PuzzleGame WHERE region = 'SA' AND level >= 10;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donors (id INT, name VARCHAR(50), amount INT, sector VARCHAR(20)); INSERT INTO donors (id, name, amount, sector) VALUES (1, 'John', 75, 'education'), (2, 'Jane', 120, 'health'), (3, 'Mike', 30, 'education'), (4, 'Olivia', 80, 'healthcare'), (5, 'Patrick', 180, 'healthcare');
|
What is the average donation size by individual donors in the healthcare sector?
|
SELECT AVG(amount) FROM donors WHERE sector = 'healthcare' AND id NOT IN (SELECT DISTINCT org_id FROM grants);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE exit (id INT, company_id INT, exit_year INT); CREATE TABLE company (id INT, name TEXT, founding_year INT, founder_gender TEXT, founder_race TEXT); INSERT INTO exit (id, company_id, exit_year) VALUES (1, 1, 2019); INSERT INTO company (id, name, founding_year, founder_gender, founder_race) VALUES (1, 'Acme Inc', 2010, 'female', 'Asian');
|
What is the earliest year a startup founded by a woman of color was successful?
|
SELECT MIN(exit.exit_year) FROM exit JOIN company ON exit.company_id = company.id WHERE company.founder_gender = 'female' AND company.founder_race = 'Asian';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE exit (id INT, company_name TEXT, industry TEXT); INSERT INTO exit (id, company_name, industry) VALUES (1, 'GamingCo', 'Gaming'); INSERT INTO exit (id, company_name, industry) VALUES (2, 'TechStart', 'Tech');
|
List all exits that occurred in the gaming industry.
|
SELECT company_name FROM exit WHERE industry = 'Gaming';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE DefenseProjects (id INT PRIMARY KEY, project VARCHAR(50), start_date DATE, end_date DATE); INSERT INTO DefenseProjects (id, project, start_date, end_date) VALUES (1, 'Project D', '2023-01-01', '2022-12-31');
|
Which defense projects have an end date before their start date?
|
SELECT project FROM DefenseProjects WHERE end_date < start_date;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Artworks (id INT, art_category VARCHAR(255), artist_name VARCHAR(255), year INT, art_medium VARCHAR(255), price DECIMAL(10,2));
|
What is the average price of artworks created by each artist in the 'Artworks' table, ordered by the average price in descending order?
|
SELECT artist_name, AVG(price) as avg_price FROM Artworks GROUP BY artist_name ORDER BY avg_price DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE patents (id INT, title VARCHAR(50), technology VARCHAR(50), location VARCHAR(50)); INSERT INTO patents (id, title, technology, location) VALUES (1, 'BioSensor 1000', 'Biosensor', 'Germany'), (2, 'BioSensor Pro', 'Biosensor', 'Asia'), (3, 'BioSensor X', 'Biosensor', 'Australia');
|
List all biosensor technology patents filed in Australia.
|
SELECT title FROM patents WHERE technology = 'Biosensor' AND location = 'Australia';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Customers (CustomerID INT, CustomerName VARCHAR(100), Country VARCHAR(50));CREATE TABLE Shipments (ShipmentID INT, CustomerID INT, ShippingType VARCHAR(50), TotalCost DECIMAL(10,2)); INSERT INTO Customers VALUES (1, 'John Doe', 'USA'); INSERT INTO Shipments VALUES (1, 1, 'Refrigerated', 500);
|
What are the customer names and their corresponding total spent on refrigerated shipping in the US for the year 2021?
|
SELECT Customers.CustomerName, SUM(Shipments.TotalCost) as TotalSpent FROM Customers INNER JOIN Shipments ON Customers.CustomerID = Shipments.CustomerID WHERE Customers.Country = 'USA' AND ShippingType = 'Refrigerated' AND YEAR(ShipmentDate) = 2021 GROUP BY Customers.CustomerName;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE player_game_stats (player_name TEXT, week INT, games_won INT); INSERT INTO player_game_stats (player_name, week, games_won) VALUES ('Jamal', 1, 5); INSERT INTO player_game_stats (player_name, week, games_won) VALUES ('Jamal', 2, 6); INSERT INTO player_game_stats (player_name, week, games_won) VALUES ('Amina', 1, 4); INSERT INTO player_game_stats (player_name, week, games_won) VALUES ('Amina', 2, 7);
|
What is the maximum number of games won by a player in a week?
|
SELECT player_name, MAX(games_won) FROM player_game_stats;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE energy_storage (id INT, project VARCHAR(50), technology VARCHAR(50), location VARCHAR(50), capacity FLOAT); INSERT INTO energy_storage (id, project, technology, location, capacity) VALUES (1, 'Battery Park', 'Lithium-ion', 'New York', 100.0), (2, 'Tesla Gigafactory', 'Lithium-ion', 'Nevada', 350.0), (3, 'La Grange', 'Pumped hydro', 'Texas', 900.0);
|
List the top 3 energy storage projects in terms of MWh, with their respective technologies and locations.
|
SELECT technology, location, capacity FROM energy_storage ORDER BY capacity DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE species (id INT, name VARCHAR(255), population INT); INSERT INTO species (id, name, population) VALUES (1, 'polar_bear', 25000); INSERT INTO species (id, name, population) VALUES (2, 'arctic_fox', 30000); INSERT INTO species (id, name, population) VALUES (3, 'walrus', 50000);
|
What is the name and population of the species with the highest population?
|
SELECT name, population FROM species ORDER BY population DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customers (id INT, name VARCHAR(50), region VARCHAR(50), balance DECIMAL(10,2)); INSERT INTO customers (id, name, region, balance) VALUES (1, 'John Doe', 'Southeast', 5000.00), (2, 'Jane Smith', 'Northwest', 7000.00);
|
What is the total balance of all customers from the Southeast region?
|
SELECT SUM(balance) FROM customers WHERE region = 'Southeast';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE protected_areas (area_name TEXT, ocean TEXT, size_km INTEGER); INSERT INTO protected_areas (area_name, ocean, size_km) VALUES ('Franz Josef Land Marine Reserve', 'Arctic Ocean', 48820), ('Gulf of Boothia National Marine Conservation Area', 'Arctic Ocean', 97198);
|
Identify the number of marine protected areas in the Arctic Ocean
|
SELECT COUNT(*) FROM protected_areas WHERE ocean = 'Arctic Ocean';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE permit_data (permit_number INT, state VARCHAR(20), cost FLOAT); INSERT INTO permit_data (permit_number, state, cost) VALUES (1, 'California', 8000); INSERT INTO permit_data (permit_number, state, cost) VALUES (2, 'California', 9000);
|
What is the maximum cost of permits in California?
|
SELECT MAX(cost) FROM permit_data WHERE state = 'California';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE diagnoses (id INT, patient_id INT, condition VARCHAR(255)); CREATE TABLE patients (id INT, age INT, condition VARCHAR(255)); INSERT INTO diagnoses (id, patient_id, condition) VALUES (1, 1, 'Depression'), (2, 2, 'Anxiety'), (3, 3, 'Bipolar'), (4, 4, 'Depression'); INSERT INTO patients (id, age, condition) VALUES (1, 35, 'Anxiety'), (2, 42, 'Depression'), (3, 28, 'Bipolar'), (4, 31, 'Depression');
|
What is the most common mental health condition diagnosed in Nigeria?
|
SELECT diagnoses.condition, COUNT(*) FROM diagnoses JOIN patients ON diagnoses.patient_id = patients.id GROUP BY diagnoses.condition ORDER BY COUNT(*) DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE smart_contracts (contract_id INT, name VARCHAR(20), language VARCHAR(20)); INSERT INTO smart_contracts (contract_id, name, language) VALUES (1, 'Crowdfund', 'Solidity'), (2, 'Voting', 'Vyper');
|
Update the language of smart contract 'Voting' to 'Michelson'
|
UPDATE smart_contracts SET language = 'Michelson' WHERE name = 'Voting';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE military_sales_3 (supplier VARCHAR(255), buyer VARCHAR(255), equipment VARCHAR(255), year INTEGER, quantity INTEGER, cost DECIMAL(10,2)); INSERT INTO military_sales_3 (supplier, buyer, equipment, year, quantity, cost) VALUES ('Airbus', 'German Government', 'A400M Transport Aircraft', 2020, 4, 20000000), ('Rheinmetall', 'German Government', 'Puma Infantry Fighting Vehicle', 2020, 6, 8000000);
|
Who are the top 3 military equipment suppliers to the German government?
|
SELECT supplier, SUM(cost) AS total_cost FROM military_sales_3 WHERE buyer = 'German Government' GROUP BY supplier ORDER BY total_cost DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Species_Growth_Weight (Species_Name TEXT, Year INT, Growth_Rate FLOAT, Fish_Weight FLOAT); INSERT INTO Species_Growth_Weight (Species_Name, Year, Growth_Rate, Fish_Weight) VALUES ('Tuna', 2019, 0.05, 1200000), ('Cod', 2019, 0.04, 800000), ('Herring', 2019, 0.03, 600000), ('Tuna', 2020, 0.06, 1400000), ('Cod', 2020, 0.05, 900000), ('Herring', 2020, 0.04, 700000);
|
What is the growth rate and total fish weight for each species over time?
|
SELECT Species_Name, Growth_Rate, SUM(Fish_Weight) OVER (PARTITION BY Species_Name) AS Total_Fish_Weight FROM Species_Growth_Weight;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE algorithm (algorithm_id INT, algorithm_name VARCHAR(50), safety_score INT, explainability_score INT); INSERT INTO algorithm (algorithm_id, algorithm_name, safety_score, explainability_score) VALUES (1, 'AlgorithmA', 80, 70); INSERT INTO algorithm (algorithm_id, algorithm_name, safety_score, explainability_score) VALUES (2, 'AlgorithmB', 90, 60); INSERT INTO algorithm (algorithm_id, algorithm_name, safety_score, explainability_score) VALUES (3, 'AlgorithmC', 75, 85);
|
What are the names and safety scores of all algorithms with an explainability score greater than 75?
|
SELECT algorithm_name, safety_score FROM algorithm WHERE explainability_score > 75;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Attorneys (AttorneyID int, Disability varchar(20)); INSERT INTO Attorneys (AttorneyID, Disability) VALUES (1, 'No Disability'), (2, 'Physical Disability'), (3, 'Visual Impairment'), (4, 'Hearing Impairment'), (5, 'Cognitive Disability'); CREATE TABLE Cases (CaseID int, AttorneyID int); INSERT INTO Cases (CaseID, AttorneyID) VALUES (1, 1), (2, 2), (3, 3), (4, 5), (5, 1), (6, 4);
|
How many cases were handled by attorneys with disabilities?
|
SELECT COUNT(*) AS NumberOfCases FROM Cases JOIN Attorneys ON Cases.AttorneyID = Attorneys.AttorneyID WHERE Disability != 'No Disability';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE accessibility (station_id INT, wheelchair_accessible BOOLEAN, elevator_availability BOOLEAN);
|
Create a table named 'accessibility' with columns 'station_id', 'wheelchair_accessible', 'elevator_availability
|
CREATE TABLE accessibility (station_id INT, wheelchair_accessible BOOLEAN, elevator_availability BOOLEAN);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Players (PlayerID INT, Gender VARCHAR(6), GameGenre VARCHAR(10)); INSERT INTO Players (PlayerID, Gender, GameGenre) VALUES (1, 'Female', 'Action'), (2, 'Male', 'Strategy'), (3, 'Female', 'Action'), (4, 'Male', 'Simulation');
|
What is the most common genre of games played by female players?
|
SELECT GameGenre, COUNT(*) AS Count FROM Players WHERE Gender = 'Female' GROUP BY GameGenre ORDER BY Count DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donors (DonorID int, DonorName varchar(50), City varchar(50), Amount decimal(10,2)); INSERT INTO Donors (DonorID, DonorName, City, Amount) VALUES (1, 'John Doe', 'Seattle', 500.00), (2, 'Jane Smith', 'New York', 300.00);
|
What was the average donation amount by individual donors from the city of "Seattle" in the year 2020?
|
SELECT AVG(Amount) FROM Donors WHERE City = 'Seattle' AND YEAR(DonationDate) = 2020 AND DonorType = 'Individual';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE movies (title varchar(255), release_year int, female_lead boolean); INSERT INTO movies (title, release_year, female_lead) VALUES ('Erin Brockovich', 2000, true); INSERT INTO movies (title, release_year, female_lead) VALUES ('The Help', 2011, true); INSERT INTO movies (title, release_year, female_lead) VALUES ('Juno', 2007, true); INSERT INTO movies (title, release_year, female_lead) VALUES ('The Blind Side', 2009, true); INSERT INTO movies (title, release_year, female_lead) VALUES ('The Devil Wears Prada', 2006, true);
|
What is the percentage of films featuring female leads released between 2000 and 2010?
|
SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM movies WHERE release_year BETWEEN 2000 AND 2010)) AS percentage FROM movies WHERE female_lead = true AND release_year BETWEEN 2000 AND 2010;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE farmer (id INT PRIMARY KEY, name VARCHAR(50), gender VARCHAR(10), is_indigenous BOOLEAN, area_in_hectares INT); INSERT INTO farmer (id, name, gender, is_indigenous, area_in_hectares) VALUES (1, 'Jamal', 'Male', FALSE, 3000), (2, 'Aisha', 'Female', FALSE, 2500), (3, 'Samir', 'Male', FALSE, 2000), (4, 'Nina', 'Female', TRUE, 5000);
|
What is the average area of land used for farming by indigenous farmers?
|
SELECT gender, AVG(area_in_hectares) FROM farmer WHERE is_indigenous = TRUE GROUP BY gender;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE museums (museum_id INT, location TEXT, visitors INT, date DATE); INSERT INTO museums (museum_id, location, visitors, date) VALUES (1, 'Prado Museum', 1500, '2021-10-01'), (2, 'Reina Sofia Museum', 1000, '2021-11-01');
|
What is the minimum number of visitors to museums in Spain in the last month?
|
SELECT MIN(visitors) FROM museums WHERE location = 'Spain' AND date >= DATEADD(month, -1, GETDATE());
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE production (id INT, well VARCHAR(255), location VARCHAR(255), production_type VARCHAR(255), production_volume INT, production_date DATE); INSERT INTO production (id, well, location, production_type, production_volume, production_date) VALUES (1, 'WellA', 'North Sea', 'Oil', 1000, '2020-01-01'), (2, 'WellB', 'North Sea', 'Gas', 2000, '2020-01-01'), (3, 'WellA', 'North Sea', 'Oil', 1200, '2020-01-02');
|
What is the total production of oil and gas in the North Sea for the year 2020?
|
SELECT SUM(production_volume) FROM production WHERE location = 'North Sea' AND production_type IN ('Oil', 'Gas') AND production_date BETWEEN '2020-01-01' AND '2020-12-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE security_incidents (id INT, region VARCHAR(255), incident_date DATE, incident_type VARCHAR(255)); INSERT INTO security_incidents (id, region, incident_date, incident_type) VALUES (1, 'North America', '2022-01-01', 'Malware'); INSERT INTO security_incidents (id, region, incident_date, incident_type) VALUES (2, 'South America', '2022-01-05', 'Phishing'); INSERT INTO security_incidents (id, region, incident_date, incident_type) VALUES (3, 'Europe', '2022-01-09', 'Unauthorized Access');
|
Display the number of security incidents that have been reported in each region in the last month, excluding any incidents related to phishing.
|
SELECT region, COUNT(*) as total_incidents FROM security_incidents WHERE incident_date >= DATEADD(month, -1, GETDATE()) AND incident_type != 'Phishing' GROUP BY region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE player_scores (player_id INT, game_name VARCHAR(255), score INT, date DATE);
|
Update player scores for the "RPG Quest" game with a 3% decrease
|
UPDATE player_scores SET score = score * 0.97 WHERE game_name = 'RPG Quest';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE campaigns (campaign_id INT, launch_date DATE); INSERT INTO campaigns (campaign_id, launch_date) VALUES (1, '2019-01-01'), (2, '2020-05-15'), (3, '2018-12-31'), (4, '2021-03-20'), (5, '2021-07-01'), (6, '2022-01-10');
|
How many public awareness campaigns were launched in January and July in the 'campaigns' schema?
|
SELECT EXTRACT(MONTH FROM launch_date) AS month, COUNT(*) AS campaigns_launched FROM campaigns WHERE EXTRACT(MONTH FROM launch_date) IN (1, 7) GROUP BY month;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donors (id INT, name TEXT, country TEXT, amount_donated DECIMAL(10,2)); INSERT INTO donors (id, name, country, amount_donated) VALUES (1, 'Alice', 'United States', 5000.00), (2, 'Bob', 'Canada', 6000.00), (3, 'Charlie', 'India', 3000.00);
|
What is the total amount donated by all donors in the table?
|
SELECT SUM(amount_donated) FROM donors;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE TeacherHours (TeacherID INT, State VARCHAR(10), Subject VARCHAR(10), Hours DECIMAL(5,2)); INSERT INTO TeacherHours (TeacherID, State, Subject, Hours) VALUES (1, 'AL', 'Science', 20.0);
|
Calculate the average teaching hours for all teachers who teach 'Science' and work in 'Alabama'
|
SELECT AVG(Hours) FROM TeacherHours WHERE Subject = 'Science' AND State = 'Alabama';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE contract_negotiations (id INT, company VARCHAR, country VARCHAR, negotiation_date DATE);
|
Find countries involved in negotiations with company X
|
SELECT country FROM contract_negotiations WHERE company = 'Company X';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Factories (FactoryID INT, FactoryName VARCHAR(50), Location VARCHAR(50)); CREATE TABLE Production (ProductionID INT, FactoryID INT, Material VARCHAR(50), Quantity INT, ProductionDate DATE); INSERT INTO Factories VALUES (1,'Factory A','Country A'),(2,'Factory B','Country B'),(3,'Factory C','Country A'); INSERT INTO Production VALUES (1,1,'Eco-Friendly Material',100,'2022-01-01'),(2,1,'Eco-Friendly Material',150,'2022-02-01'),(3,2,'Eco-Friendly Material',200,'2022-03-01'),(4,3,'Regular Material',50,'2022-04-01');
|
List all countries with factories that have not produced any sustainable materials in the last 6 months.
|
SELECT DISTINCT f.Location FROM Factories f LEFT JOIN Production p ON f.FactoryID = p.FactoryID AND p.ProductionDate >= DATEADD(month, -6, GETDATE()) WHERE p.ProductionID IS NULL;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE AnimalPopulation (id INT PRIMARY KEY, species VARCHAR(50), population INT);
|
Calculate the total number of animals of each species in the 'AnimalPopulation' table, grouped by species, and display the results in descending order.
|
SELECT species, SUM(population) FROM AnimalPopulation GROUP BY species ORDER BY SUM(population) DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_species_status (id INT, species_name VARCHAR(255), conservation_status VARCHAR(255)); INSERT INTO marine_species_status (id, species_name, conservation_status) VALUES (1, 'Green Sea Turtle', 'Endangered'); CREATE TABLE oceanography (id INT, species_name VARCHAR(255), location VARCHAR(255)); INSERT INTO oceanography (id, species_name, location) VALUES (1, 'Green Sea Turtle', 'Atlantic Ocean'), (2, 'Green Sea Turtle', 'Pacific Ocean');
|
What are the conservation statuses of marine species that are found in both the Atlantic and Pacific Oceans?
|
SELECT conservation_status FROM marine_species_status WHERE species_name IN (SELECT species_name FROM oceanography WHERE location IN ('Atlantic Ocean', 'Pacific Ocean') GROUP BY species_name HAVING COUNT(*) = 2);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cranes (crane_id VARCHAR(10), weight_tonnes FLOAT); INSERT INTO cranes (crane_id, weight_tonnes) VALUES ('crane_1', 35.6), ('crane_2', 42.9), ('crane_3', 50.1);
|
What is the average weight of containers handled by crane_3?
|
SELECT AVG(weight_tonnes) FROM cranes WHERE crane_id = 'crane_3';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE habitats (id INT, name TEXT, size_km2 FLOAT); INSERT INTO habitats (id, name, size_km2) VALUES (1, 'Forest', 50.3), (2, 'Wetlands', 32.1), (3, 'Grasslands', 87.6);
|
What is the maximum and minimum size of protected habitats in square kilometers?
|
SELECT MAX(size_km2) as max_size, MIN(size_km2) as min_size FROM habitats;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SpacecraftManufacturing(id INT, country VARCHAR(50), cost FLOAT); INSERT INTO SpacecraftManufacturing(id, country, cost) VALUES (1, 'France', 30000000), (2, 'Germany', 35000000), (3, 'France', 28000000), (4, 'UK', 40000000);
|
Update the cost of spacecraft with id 3 to 32000000 if it was manufactured in Europe.
|
UPDATE SpacecraftManufacturing SET cost = 32000000 WHERE id = 3 AND country = 'France';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Weekly_Production_2 (week INT, neodymium_production FLOAT);
|
What is the minimum weekly production of Neodymium in 2019 from the Weekly_Production_2 table?
|
SELECT MIN(neodymium_production) FROM Weekly_Production_2 WHERE EXTRACT(YEAR FROM to_date(week, 'IW')) = 2019;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_species (id INT, species_name VARCHAR(50), habitat_depth FLOAT); INSERT INTO marine_species (id, species_name, habitat_depth) VALUES (1, 'Green Sea Turtle', 50.0), (2, 'Clownfish', 20.0), (3, 'Humpback Whale', 400.0);
|
Update the 'Humpback Whale' record in the 'marine_species' table to have a maximum depth of 500 meters if it is less than 500 meters.
|
UPDATE marine_species SET habitat_depth = 500.0 WHERE species_name = 'Humpback Whale' AND habitat_depth < 500.0;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Claims (ClaimID INT, PolicyID INT, ClaimAmount DECIMAL(10,2)); CREATE TABLE Policy (PolicyID INT, PolicyType VARCHAR(20), CustomerID INT, CustomerPostalCode VARCHAR(7), Country VARCHAR(20)); INSERT INTO Claims (ClaimID, PolicyID, ClaimAmount) VALUES (1, 1, 1500.00), (2, 2, 250.00), (3, 3, 500.00), (4, 3, 1200.00), (5, 5, 100.00); INSERT INTO Policy (PolicyID, PolicyType, CustomerID, CustomerPostalCode, Country) VALUES (1, 'Homeowners', 101, 'M1M1M1', 'Canada'), (2, 'Auto', 102, 'A1A1A1', 'Canada'), (3, 'Renters', 103, 'M2M2M2', 'France'), (4, 'Life', 104, 'N1N1N1', 'Germany'), (5, 'Auto', 105, 'Z1Z1Z1', 'France');
|
Display total claim amounts and policy types for policyholders residing in France with an 'Auto' policy.
|
SELECT Policy.PolicyType, SUM(Claims.ClaimAmount) AS TotalClaimAmount FROM Policy INNER JOIN Claims ON Policy.PolicyID = Claims.PolicyID WHERE Policy.PolicyType = 'Auto' AND Policy.Country = 'France' GROUP BY Policy.PolicyType;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE athletes (athlete_id INT, athlete_name VARCHAR(50), conference VARCHAR(50), wellbeing_score INT); INSERT INTO athletes (athlete_id, athlete_name, conference, wellbeing_score) VALUES (1, 'Athlete A', 'Western Conference', 80), (2, 'Athlete B', 'Western Conference', 85), (3, 'Athlete C', 'Western Conference', 75), (4, 'Athlete D', 'Eastern Conference', 90), (5, 'Athlete E', 'Western Conference', 95), (6, 'Athlete F', 'Eastern Conference', 70), (7, 'Athlete G', 'Western Conference', 88), (8, 'Athlete H', 'Western Conference', 92);
|
What is the minimum wellbeing score for athletes in the 'Western Conference'?
|
SELECT MIN(wellbeing_score) FROM athletes WHERE conference = 'Western Conference';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Regions (id INT, name VARCHAR(50)); INSERT INTO Regions (id, name) VALUES (1, 'North'), (2, 'South'), (3, 'East'), (4, 'West'); CREATE TABLE Healthcare_Budget (region_id INT, year INT, amount INT); INSERT INTO Healthcare_Budget (region_id, year, amount) VALUES (1, 2021, 150000), (2, 2021, 180000), (3, 2021, 200000), (4, 2021, 170000), (1, 2022, 160000), (2, 2022, 190000), (3, 2022, 210000), (4, 2022, 180000);
|
What is the total budget allocated for healthcare services in each region for the year 2021?
|
SELECT R.name, SUM(HB.amount) as Total_Budget FROM Healthcare_Budget HB JOIN Regions R ON HB.region_id = R.id WHERE HB.year = 2021 GROUP BY R.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE teacher_professional_development (teacher_id INT, teacher_region VARCHAR(20), course_completed INT); INSERT INTO teacher_professional_development (teacher_id, teacher_region, course_completed) VALUES (1, 'Northeast', 3), (2, 'Southeast', 5), (3, 'Midwest', 4), (4, 'Southwest', 2), (5, 'Northwest', 6);
|
How many professional development courses were completed by teachers in each region?
|
SELECT teacher_region, SUM(course_completed) FROM teacher_professional_development GROUP BY teacher_region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE news_articles (article_id INT PRIMARY KEY, title TEXT, topic TEXT, author TEXT, publication_date DATE);
|
Update the author of all articles with the topic "Investigative Journalism" to "Jane Smith".
|
UPDATE news_articles SET author = 'Jane Smith' WHERE topic = 'Investigative Journalism';
|
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.