context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE carbon_price ( year INT, country VARCHAR(20), price FLOAT ); INSERT INTO carbon_price (year, country, price) VALUES (2020, 'US', 20.5), (2020, 'Canada', 12.3), (2021, 'Mexico', 18.9); | Delete records in the 'carbon_price' table where price is below 15 for the year 2020 | WITH cte AS (DELETE FROM carbon_price WHERE year = 2020 AND price < 15) DELETE FROM cte; | gretelai_synthetic_text_to_sql |
CREATE TABLE security_incidents (id INT, actor VARCHAR(255), incident_count INT); CREATE VIEW incident_view AS SELECT actor, COUNT(*) as incident_count FROM security_incidents GROUP BY actor; | How many security incidents were attributed to each threat actor in the past month? | SELECT actor, incident_count FROM incident_view WHERE incident_count >= (SELECT AVG(incident_count) FROM incident_view) AND incident_at >= DATE_SUB(NOW(), INTERVAL 1 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE vendors (vendor_id INT, vendor_name VARCHAR(50), state VARCHAR(50)); INSERT INTO vendors VALUES (1, 'VendorA', 'Florida'); INSERT INTO vendors VALUES (2, 'VendorB', 'Texas'); CREATE TABLE products (product_id INT, product_name VARCHAR(50), vendor_id INT); INSERT INTO products VALUES (1, 'Product1', 1); INS... | Which vendors in Florida sell more than one product? | SELECT DISTINCT vendors.vendor_id, vendors.vendor_name FROM vendors JOIN products ON vendors.vendor_id = products.vendor_id GROUP BY vendors.vendor_id, vendors.vendor_name HAVING COUNT(DISTINCT products.product_id) > 1 AND vendors.state = 'Florida'; | gretelai_synthetic_text_to_sql |
CREATE TABLE education_programs (id INT, program_name VARCHAR(50), year INT, attendees INT); INSERT INTO education_programs (id, program_name, year, attendees) VALUES (1, 'Wildlife Conservation', 2021, 250), (2, 'Habitat Protection', 2020, 120); | What is the total number of community education programs conducted in '2020' and '2021' with more than 100 attendees? | SELECT COUNT(*) FROM education_programs WHERE year IN (2020, 2021) AND attendees > 100; | gretelai_synthetic_text_to_sql |
CREATE TABLE investments (investment_id INT, investor_id INT, org_id INT, investment_amount INT); INSERT INTO investments (investment_id, investor_id, org_id, investment_amount) VALUES (1, 1, 13, 25000), (2, 2, 14, 35000), (3, 1, 15, 45000), (4, 3, 16, 30000), (5, 2, 15, 50000); CREATE TABLE investors (investor_id INT,... | What is the total investment in the education sector by each investor? | SELECT investors.investor_name, SUM(investments.investment_amount) AS total_invested FROM investments JOIN investors ON investments.investor_id = investors.investor_id JOIN organizations ON investments.org_id = organizations.org_id WHERE organizations.focus_topic = 'Education' GROUP BY investors.investor_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE military_sales (id INT, company VARCHAR(255), country VARCHAR(255), sale_value DECIMAL(10,2), sale_date DATE); INSERT INTO military_sales (id, company, country, sale_value, sale_date) VALUES (1, 'Lockheed Martin', 'China', 700000, '2017-01-01'); INSERT INTO military_sales (id, company, country, sale_value,... | Find the number of military equipment sales to the Chinese government by all defense contractors in 2017. | SELECT COUNT(*) FROM military_sales WHERE country = 'China' AND YEAR(sale_date) = 2017; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (DonationID INT PRIMARY KEY, DonorID INT, Amount INT, DonationDate DATETIME); INSERT INTO Donations (DonationID, DonorID, Amount, DonationDate) VALUES (1, 1, 5000, '2022-01-01 10:00:00'); | What's the average donation amount for donors from India who have donated more than once? | SELECT AVG(Donations.Amount) FROM Donations INNER JOIN Donors ON Donations.DonorID = Donors.DonorID WHERE Donors.Country = 'India' GROUP BY Donations.DonorID HAVING COUNT(Donations.DonationID) > 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE carbon_offset_initiatives (initiative_id INT, initiative_name VARCHAR(100), launch_date DATE, city VARCHAR(100)); INSERT INTO carbon_offset_initiatives (initiative_id, initiative_name, launch_date, city) VALUES (1, 'Tree Planting', '2022-01-01', 'Paris'), (2, 'Bicycle Sharing Expansion', '2021-07-01', 'Par... | How many carbon offset initiatives have been launched by the city government of Paris in the last 2 years? | SELECT COUNT(*) FROM carbon_offset_initiatives WHERE city = 'Paris' AND launch_date >= DATE_SUB(CURRENT_DATE, INTERVAL 2 YEAR); | gretelai_synthetic_text_to_sql |
CREATE TABLE Spacecraft (SpacecraftID INT, Name VARCHAR(50), FirstGravityAssist DATE); INSERT INTO Spacecraft VALUES (1, 'Voyager 1', '1979-01-01'); INSERT INTO Spacecraft VALUES (2, 'Voyager 2', '1979-06-09'); | What is the average speed of all spacecraft that have performed a gravity assist maneuver, ordered by the date of their first gravity assist? | SELECT AVG(Speed) FROM (SELECT Speed, LAG(Speed) OVER (ORDER BY FirstGravityAssist) PrevSpeed, ROW_NUMBER() OVER (ORDER BY FirstGravityAssist) RN FROM SpacecraftGravityAssists JOIN Spacecraft ON SpacecraftGravityAssists.SpacecraftID = Spacecraft.SpacecraftID) T WHERE RN > 1 AND PrevSpeed IS NOT NULL | gretelai_synthetic_text_to_sql |
CREATE TABLE water_treatment_facilities (location VARCHAR(50), last_update DATE); INSERT INTO water_treatment_facilities (location, last_update) VALUES ('Mumbai', '2021-01-01'), ('Delhi', '2021-02-03'), ('Bangalore', '2021-04-05'); | How many water treatment facilities have been updated in India in 2021? | SELECT COUNT(*) FROM water_treatment_facilities WHERE last_update >= '2021-01-01' AND last_update <= '2021-12-31' AND location = 'India'; | gretelai_synthetic_text_to_sql |
CREATE TABLE travel_advisories (country VARCHAR(20), year INT, advisory VARCHAR(50)); INSERT INTO travel_advisories (country, year, advisory) VALUES ('Japan', 2022, 'avoid non-essential travel'), ('Japan', 2021, 'exercise caution'), ('New Zealand', 2022, 'avoid all travel'), ('New Zealand', 2021, 'exercise caution'); | Delete all records related to travel advisories issued for New Zealand in 2022. | DELETE FROM travel_advisories WHERE country = 'New Zealand' AND year = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE us_sales (id INT, garment_size INT);INSERT INTO us_sales (id, garment_size) VALUES (1, 6), (2, 8), (3, 10); | What is the minimum garment size sold to 'US'? | SELECT MIN(garment_size) FROM us_sales; | gretelai_synthetic_text_to_sql |
CREATE TABLE military_equipment_contracts (contract_id INT, cost FLOAT, signing_date DATE); INSERT INTO military_equipment_contracts (contract_id, cost, signing_date) VALUES (1, 5000000, '2021-01-01'); | Find the average cost of military equipment contracts signed in the last 12 months | SELECT AVG(cost) FROM military_equipment_contracts WHERE signing_date >= DATE_SUB(CURDATE(), INTERVAL 12 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE City (id INT, name VARCHAR(50)); INSERT INTO City (id, name) VALUES (1, 'New York'); INSERT INTO City (id, name) VALUES (2, 'Los Angeles'); INSERT INTO City (id, name) VALUES (3, 'Paris'); INSERT INTO City (id, name) VALUES (4, 'Berlin'); INSERT INTO City (id, name) VALUES (5, 'Tokyo'); CREATE TABLE Policy... | What is the average budget allocated for healthcare policies in 'Paris' and 'Berlin'? | SELECT AVG(budget) FROM Policy WHERE city_id IN (3, 4) AND category = 'Healthcare'; | gretelai_synthetic_text_to_sql |
CREATE TABLE clinics (clinic_id INT, clinic_name VARCHAR(50), city VARCHAR(50), state VARCHAR(50)); INSERT INTO clinics (clinic_id, clinic_name, city, state) VALUES (1, 'ClinicA', 'Miami', 'FL'), (2, 'ClinicB', 'Los Angeles', 'CA'); CREATE TABLE patients (patient_id INT, patient_name VARCHAR(50), clinic_id INT); INSERT... | What is the total number of patients treated in mental health clinics located in Florida? | SELECT COUNT(*) FROM patients p JOIN clinics c ON p.clinic_id = c.clinic_id WHERE c.state = 'FL'; | gretelai_synthetic_text_to_sql |
CREATE TABLE avengers_viewers (id INT, viewer_id INT, age INT, movie VARCHAR(255)); INSERT INTO avengers_viewers (id, viewer_id, age, movie) VALUES (1, 1, 22, 'The Avengers'), (2, 2, 30, 'The Avengers'), (3, 3, 35, 'The Avengers'), (4, 4, 18, 'The Avengers'); | What's the minimum and maximum age of viewers who watched 'The Avengers'? | SELECT MIN(age), MAX(age) FROM avengers_viewers WHERE movie = 'The Avengers'; | gretelai_synthetic_text_to_sql |
CREATE TABLE flu_cases(id INT, patient_id INT, area TEXT, date DATE); CREATE VIEW rural_areas AS SELECT * FROM areas WHERE population < 50000; | What is the number of flu cases in rural areas? | SELECT COUNT(*) FROM flu_cases JOIN rural_areas USING(area); | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists genetics;CREATE TABLE if not exists genetics.studies (id INT, name VARCHAR(100), location VARCHAR(100)); INSERT INTO genetics.studies (id, name, location) VALUES (1, 'StudyA', 'Cape Town'), (2, 'StudyB', 'Nairobi'), (3, 'StudyC', 'Alexandria'); | Which genetic research studies have been conducted in Africa? | SELECT name FROM genetics.studies WHERE location = 'Africa'; | gretelai_synthetic_text_to_sql |
CREATE TABLE workshops (id INT, region VARCHAR(20), revenue DECIMAL(10,2)); INSERT INTO workshops (id, region, revenue) VALUES (1, 'Los Angeles', 500.00), (2, 'New York', 700.00); CREATE TABLE users (id INT, age INT, joined DATE); INSERT INTO users (id, age, joined) VALUES (1, 26, '2021-01-01'), (2, 30, '2020-01-01'); | What is the total revenue generated from workshops in the Los Angeles region, for users aged 25-34, in the year 2021? | SELECT SUM(workshops.revenue) FROM workshops INNER JOIN users ON workshops.region = 'Los Angeles' AND users.age BETWEEN 25 AND 34 AND YEAR(users.joined) = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE recycling_initiatives (year INT, city VARCHAR(255), initiative_type VARCHAR(255)); | Insert new records of recycling initiatives in Mumbai in 2023 | INSERT INTO recycling_initiatives (year, city, initiative_type) VALUES (2023, 'Mumbai', 'Plastic Recycling'), (2023, 'Mumbai', 'Paper Recycling'), (2023, 'Mumbai', 'Glass Recycling'); | gretelai_synthetic_text_to_sql |
CREATE TABLE startups(id INT, name TEXT, industry TEXT, founder_ethnicity TEXT); INSERT INTO startups(id, name, industry, founder_ethnicity) VALUES (1, 'RetailEmpower', 'Retail', 'Latinx'), (2, 'TechBoost', 'Technology', 'Asian'); | What is the number of startups founded by Latinx individuals in the retail sector? | SELECT COUNT(*) FROM startups WHERE industry = 'Retail' AND founder_ethnicity = 'Latinx'; | gretelai_synthetic_text_to_sql |
CREATE TABLE bbc_news (article_id INT, title TEXT, category TEXT, publisher TEXT); INSERT INTO bbc_news (article_id, title, category, publisher) VALUES (1, 'Article 1', 'Politics', 'BBC News'), (2, 'Article 2', 'Business', 'BBC News'); | List all the articles published by 'BBC News' in the politics category. | SELECT * FROM bbc_news WHERE category = 'Politics'; | gretelai_synthetic_text_to_sql |
CREATE TABLE permit (permit_id INT, permit_type TEXT, state TEXT, cost INT, sqft INT); INSERT INTO permit (permit_id, permit_type, state, cost, sqft) VALUES (1, 'Residential', 'California', 50000, 2000), (2, 'Commercial', 'California', 200000, 5000); | What is the average permit cost per square foot for all permit types in the state of California? | SELECT AVG(cost/sqft) FROM permit WHERE state = 'California'; | gretelai_synthetic_text_to_sql |
CREATE TABLE teams (team_id INT, team_name VARCHAR(50));CREATE TABLE games (game_id INT, team_id INT, home_team BOOLEAN, price DECIMAL(5,2), attendance INT);INSERT INTO teams (team_id, team_name) VALUES (1, 'Red Sox'), (2, 'Yankees');INSERT INTO games (game_id, team_id, home_team, price, attendance) VALUES (1, 1, 1, 35... | What is the maximum ticket price for home games of each team, excluding games with attendance less than 10000? | SELECT t.team_name, MAX(g.price) AS max_price FROM teams t INNER JOIN games g ON t.team_id = g.team_id AND g.home_team = t.team_id WHERE g.attendance >= 10000 GROUP BY t.team_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (id INT, name VARCHAR(50), department VARCHAR(50), hire_date DATE, country VARCHAR(50)); INSERT INTO Employees (id, name, department, hire_date, country) VALUES (1, 'John Doe', 'HR', '2021-01-15', 'USA'); INSERT INTO Employees (id, name, department, hire_date, country) VALUES (2, 'Jane Smith', 'I... | What is the total number of employees hired from each country? | SELECT country, COUNT(*) AS total_hired FROM Employees GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE companies (id INT, sector VARCHAR(20), ESG_score FLOAT); INSERT INTO companies (id, sector, ESG_score) VALUES (1, 'Energy', 85.2), (2, 'Energy', 76.3), (3, 'Energy', 88.1), (4, 'Healthcare', 69.9); | How many companies in the energy sector have an ESG score above 80? | SELECT COUNT(*) FROM companies WHERE sector = 'Energy' AND ESG_score > 80; | gretelai_synthetic_text_to_sql |
CREATE TABLE energy_consumption_2018 (country VARCHAR(50), year INT, energy_consumption FLOAT, population INT); INSERT INTO energy_consumption_2018 (country, year, energy_consumption, population) VALUES ('United States', 2018, 2868.6, 329.09), ('China', 2018, 3079.4, 1434.2), ('India', 2018, 1109.8, 1366.0), ('Germany'... | What is the top 10 energy-efficient countries by energy consumption per capita in 2018? | SELECT country, (energy_consumption / population) AS energy_consumption_per_capita FROM energy_consumption_2018 WHERE year = 2018 ORDER BY energy_consumption_per_capita ASC LIMIT 10; | gretelai_synthetic_text_to_sql |
CREATE TABLE charging_stations (id INT, system_type VARCHAR(20), city VARCHAR(20), num_stations INT); INSERT INTO charging_stations (id, system_type, city, num_stations) VALUES (1, 'Public Transportation', 'Tokyo', 600), (2, 'Highway', 'Tokyo', 800); | how many charging stations are there in the public transportation system in Tokyo? | SELECT num_stations FROM charging_stations WHERE system_type = 'Public Transportation' AND city = 'Tokyo'; | gretelai_synthetic_text_to_sql |
CREATE TABLE wnba (player_id INT, name VARCHAR(50), points INT); INSERT INTO wnba (player_id, name, points) VALUES (1, 'Brittney Griner', 40), (2, 'Diana Taurasi', 37), (3, 'Sue Bird', 22); | What is the maximum number of points scored by a player in a single game of the WNBA? | SELECT MAX(points) FROM wnba; | gretelai_synthetic_text_to_sql |
CREATE TABLE CountyVegetableYield (county VARCHAR(20), vegetable VARCHAR(20), quantity INT, price FLOAT); | What was the total production of 'Tomatoes' and 'Cucumbers' in 'CountyVegetableYield' table? | SELECT county, SUM(CASE WHEN vegetable = 'Tomatoes' THEN quantity ELSE 0 END) + SUM(CASE WHEN vegetable = 'Cucumbers' THEN quantity ELSE 0 END) as total_tomatoes_cucumbers FROM CountyVegetableYield GROUP BY county; | gretelai_synthetic_text_to_sql |
CREATE TABLE Customers (CustomerID INT, Size VARCHAR(10), Country VARCHAR(255)); INSERT INTO Customers (CustomerID, Size, Country) VALUES (1, 'XS', 'Brazil'), (2, 'S', 'Argentina'), (3, 'M', 'Chile'), (4, 'L', 'Peru'), (5, 'XL', 'Colombia'), (6, 'XS', 'Nigeria'), (7, 'L', 'Egypt'); | How many customers are there for each size in the 'Africa' region? | SELECT Size, COUNT(*) FROM Customers WHERE Country = 'Africa' GROUP BY Size; | gretelai_synthetic_text_to_sql |
CREATE TABLE artists (artist_id INT, artist_name VARCHAR(100), revenue INT, year INT); INSERT INTO artists (artist_id, artist_name, revenue, year) VALUES (1, 'Taylor Swift', 1200000, 2020); INSERT INTO artists (artist_id, artist_name, revenue, year) VALUES (2, 'BTS', 1000000, 2020); INSERT INTO artists (artist_id, arti... | Rank artists by their total revenue in 2020, assigning a rank of 1 to the artist with the highest revenue. | SELECT artist_name, RANK() OVER (ORDER BY revenue DESC) as artist_rank FROM artists WHERE year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE crop_data (id INT, crop_type VARCHAR(255), temperature INT, humidity INT, timestamp DATETIME); INSERT INTO crop_data (id, crop_type, temperature, humidity, timestamp) VALUES (1, 'Corn', 25, 60, '2022-01-01 10:00:00'); | Calculate the average temperature and humidity for each crop type in the past week. | SELECT crop_type, AVG(temperature) as avg_temp, AVG(humidity) as avg_humidity FROM crop_data WHERE timestamp >= DATE_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 WEEK) GROUP BY crop_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE vessels (id INT, name VARCHAR(255), imo INT); CREATE TABLE events (id INT, vessel_id INT, event_type VARCHAR(255), event_date DATE); | Which vessels had a speeding event in the last 30 days? | SELECT v.name FROM vessels v JOIN events e ON v.id = e.vessel_id WHERE e.event_type = 'Speeding' AND e.event_date >= CURDATE() - INTERVAL 30 DAY; | gretelai_synthetic_text_to_sql |
CREATE TABLE accounts (account_id INT, account_type VARCHAR(20), region VARCHAR(20), risk_level VARCHAR(10)); INSERT INTO accounts (account_id, account_type, region, risk_level) VALUES (1, 'Checking', 'Europe', 'High'), (2, 'Savings', 'Asia', 'Low'); | How many high-risk accounts are present in the European region? | SELECT COUNT(*) FROM accounts WHERE region = 'Europe' AND risk_level = 'High'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Salaries (EmployeeID int, Name varchar(50), Position varchar(50), Salary decimal(10,2), Country varchar(50)); INSERT INTO Salaries (EmployeeID, Name, Position, Salary, Country) VALUES (1, 'John Doe', 'Engineer', 60000.00, 'USA'), (2, 'Jane Smith', 'Manager', 70000.00, 'USA'), (3, 'Peter Lee', 'Operator', 3... | What is the salary difference between the highest paid employee and the lowest paid employee in each country? | SELECT Country, MAX(Salary) - MIN(Salary) as SalaryDifference FROM Salaries GROUP BY Country; | gretelai_synthetic_text_to_sql |
CREATE TABLE public_works_projects (project VARCHAR(50)); INSERT INTO public_works_projects (project) VALUES ('Road Repair'); INSERT INTO public_works_projects (project) VALUES ('Drainage System Installation'); INSERT INTO public_works_projects (project) VALUES ('Street Lighting'); | What is the total number of projects in the 'public_works_projects' table? | SELECT COUNT(*) FROM public_works_projects; | gretelai_synthetic_text_to_sql |
CREATE TABLE vulnerabilities (id INT, severity VARCHAR(255)); INSERT INTO vulnerabilities (id, severity) VALUES (1, 'critical'), (2, 'high'); | List all vulnerabilities that have been assigned a severity rating of 'critical'. | SELECT * FROM vulnerabilities WHERE severity = 'critical'; | gretelai_synthetic_text_to_sql |
CREATE TABLE sites (site_id INT, site_name VARCHAR(100), state VARCHAR(50)); INSERT INTO sites (site_id, site_name, state) VALUES (1, 'Golden Mining Site', 'California'); INSERT INTO sites (site_id, site_name, state) VALUES (2, 'Silver Peak Mine', 'Nevada'); INSERT INTO sites (site_id, site_name, state) VALUES (3, 'Uta... | What is the total amount of gold extracted from each mining site in Utah? | SELECT sites.site_name, SUM(extraction.quantity) as total_gold_extracted FROM sites JOIN extraction ON sites.site_id = extraction.site_id WHERE sites.state = 'Utah' AND extraction.mineral = 'Gold' GROUP BY sites.site_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE ProtectedSpecies(species_id INT, species_name TEXT, region TEXT); INSERT INTO ProtectedSpecies (species_id, species_name, region) VALUES (151, 'Lynx', 'Region E'), (152, 'Seal', 'Region F'), (153, 'Otter', 'Region G'); | Show the species names and regions of all protected species with an ID less than 150. | SELECT species_name, region FROM ProtectedSpecies WHERE species_id < 150; | gretelai_synthetic_text_to_sql |
CREATE TABLE Volunteers (VolunteerID INT, VolunteerName TEXT, ProgramCategory TEXT, HoursWorked FLOAT); INSERT INTO Volunteers (VolunteerID, VolunteerName, ProgramCategory, HoursWorked) VALUES (1, 'Alice', 'Youth', 5.0), (2, 'Bob', 'Seniors', 10.0); | What is the total number of volunteers and total number of volunteer hours for each program category? | SELECT ProgramCategory, COUNT(DISTINCT VolunteerID) as TotalVolunteers, SUM(HoursWorked) as TotalHours FROM Volunteers GROUP BY ProgramCategory; | gretelai_synthetic_text_to_sql |
CREATE TABLE building_permits (permit_type TEXT, state TEXT, cost INTEGER, year INTEGER);INSERT INTO building_permits (permit_type, state, cost, year) VALUES ('Residential', 'Texas', 250000, 2018), ('Commercial', 'Texas', 600000, 2018), ('Industrial', 'Texas', 400000, 2018); | What are the total construction costs for each type of building permit in the state of Texas for the year 2018, excluding industrial permits? | SELECT permit_type, SUM(cost) FROM building_permits WHERE state = 'Texas' AND year = 2018 AND permit_type != 'Industrial' GROUP BY permit_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE ingredients (ingredient_id INT, ingredient_name VARCHAR(255), supplier_id INT, is_organic BOOLEAN); | What is the total number of organic and non-organic ingredients in the database? | SELECT SUM(is_organic) AS total_organic, SUM(NOT is_organic) AS total_non_organic FROM ingredients; | gretelai_synthetic_text_to_sql |
CREATE TABLE disaster_response_training (session_id INT, organization_id INT, affected_region VARCHAR(20), training_date DATE); INSERT INTO disaster_response_training (session_id, organization_id, affected_region, training_date) VALUES (1001, 101, 'Asia', '2020-02-03'), (1002, 101, 'Africa', '2020-11-15'), (1003, 102, ... | How many disaster response training sessions were conducted by each organization for each affected region in 2020? | SELECT organization_id, affected_region, COUNT(*) as training_sessions_count FROM disaster_response_training WHERE EXTRACT(YEAR FROM training_date) = 2020 GROUP BY organization_id, affected_region; | gretelai_synthetic_text_to_sql |
CREATE TABLE RenewableCapacities (country TEXT, capacity INT); INSERT INTO RenewableCapacities (country, capacity) VALUES ('United States', 250000), ('China', 500000); | What is the total installed renewable energy capacity for each country in the RenewableCapacities table? | SELECT country, SUM(capacity) FROM RenewableCapacities GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE animals (animal_id SERIAL PRIMARY KEY, name VARCHAR(255), species VARCHAR(255)); INSERT INTO animals (animal_id, name, species) VALUES (1, 'Lion', 'Feline'), (2, 'Tiger', 'Feline'), (3, 'Bear', 'Ursidae'); | List all animals and their species from the "animals" table | SELECT animal_id, name, species FROM animals; | gretelai_synthetic_text_to_sql |
CREATE TABLE company (id INT, name TEXT, founder TEXT, industry TEXT, funding FLOAT); INSERT INTO company (id, name, founder, industry, funding) VALUES (1, 'Acme Inc', 'Female', 'Tech', 2000000); | What is the average funding amount per industry category for companies founded by women? | SELECT industry, AVG(funding) FROM company WHERE founder = 'Female' GROUP BY industry; | gretelai_synthetic_text_to_sql |
CREATE TABLE donor_retention_data (id INT, age INT, donor INT, retained INT); INSERT INTO donor_retention_data (id, age, donor, retained) VALUES (1, 25, 100, 85), (2, 35, 120, 90), (3, 45, 150, 100), (4, 55, 180, 120); | What is the donation retention rate by age group? | SELECT age_group, AVG(retained/donor*100) as retention_rate FROM (SELECT CASE WHEN age < 30 THEN 'Under 30' WHEN age < 50 THEN '30-49' ELSE '50+' END as age_group, donor, retained FROM donor_retention_data) AS subquery GROUP BY age_group; | gretelai_synthetic_text_to_sql |
CREATE TABLE garment_sales (id INT PRIMARY KEY, garment_id INT, quantity INT, sale_date DATE); | What was the total quantity of garment 001 sold in 2022? | SELECT SUM(quantity) FROM garment_sales WHERE garment_id = 1 AND sale_date BETWEEN '2022-01-01' AND '2022-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE projects (project_id INT PRIMARY KEY, project_name VARCHAR(100), sector VARCHAR(50), country VARCHAR(50), region VARCHAR(50), start_date DATE, end_date DATE); | Insert new records for rural infrastructure projects in 'Asia' in the 'rural_development' database's 'projects' table | INSERT INTO projects (project_id, project_name, sector, country, region, start_date, end_date) VALUES (1, 'Asian Rural Connectivity Initiative', 'Infrastructure', 'India', 'South Asia', '2022-01-01', '2025-12-31'), (2, 'Asian Agricultural Infrastructure Development', 'Infrastructure', 'China', 'East Asia', '2023-01-01'... | gretelai_synthetic_text_to_sql |
CREATE TABLE public.monthly_trips_by_micro_mobility (id SERIAL PRIMARY KEY, vehicle_type TEXT, city TEXT, month_start DATE, month_trips INTEGER); INSERT INTO public.monthly_trips_by_micro_mobility (vehicle_type, city, month_start, month_trips) VALUES ('shared_scooter', 'Rio de Janeiro', '2022-02-01', 20000), ('shared_s... | What is the minimum number of trips taken by shared scooters in Rio de Janeiro in a month? | SELECT MIN(month_trips) FROM public.monthly_trips_by_micro_mobility WHERE vehicle_type = 'shared_scooter' AND city = 'Rio de Janeiro'; | gretelai_synthetic_text_to_sql |
CREATE TABLE social_media_posts (post_id INT, likes INT, topic VARCHAR(255), platform VARCHAR(50)); CREATE VIEW climate_change_posts AS SELECT DISTINCT post_id FROM social_media_posts WHERE topic = 'climate change'; | Find the top 5 most liked social media posts about climate change. | SELECT post_id, likes FROM climate_change_posts WHERE topic = 'climate change' ORDER BY likes DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE Ingredients (IngredientID INT, Name VARCHAR(50), Quantity INT, VendorID INT, Local BOOLEAN); INSERT INTO Ingredients (IngredientID, Name, Quantity, VendorID, Local) VALUES (1, 'Lettuce', 10, 1, true), (2, 'Tomato', 20, 1, true), (3, 'Cheese', 30, 2, false); | What is the total quantity of locally sourced ingredients used by each vendor? | SELECT VendorID, SUM(Quantity) FROM Ingredients WHERE Local = true GROUP BY VendorID; | gretelai_synthetic_text_to_sql |
CREATE TABLE countries (country_id INT, country_name VARCHAR(255)); CREATE TABLE metrics (metric_id INT, metric_name VARCHAR(255), country_id INT); | What is the total number of agricultural innovation metrics in each country, sorted by metric count in descending order? | SELECT c.country_name, COUNT(m.metric_id) as metric_count FROM countries c JOIN metrics m ON c.country_id = m.country_id GROUP BY c.country_name ORDER BY metric_count DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE wastewater_plants (id INT, name VARCHAR(50), location VARCHAR(50), capacity INT); | Update the location of a wastewater plant in the wastewater_plants table | UPDATE wastewater_plants SET location = 'City B' WHERE id = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Site (SiteID VARCHAR(10), SiteName VARCHAR(20)); INSERT INTO Site (SiteID, SiteName) VALUES ('A', 'Site A'), ('B', 'Site B'); CREATE TABLE Artifact (ArtifactID VARCHAR(10), SiteID VARCHAR(10), Weight FLOAT); INSERT INTO Artifact (ArtifactID, SiteID, Weight) VALUES ('1', 'A', 12.3), ('2', 'A', 15.6), ('3', ... | What is the average weight of artifacts excavated from 'Site A' and 'Site B'? | SELECT AVG(Weight) FROM Artifact WHERE SiteID IN ('A', 'B'); | gretelai_synthetic_text_to_sql |
CREATE TABLE green_buildings (building_id INT, building_name VARCHAR(255), country VARCHAR(255), rating VARCHAR(255)); | What is the total number of green buildings in the UK with a gold rating? | SELECT COUNT(*) FROM green_buildings WHERE country = 'UK' AND rating = 'gold'; | gretelai_synthetic_text_to_sql |
CREATE TABLE country_power_plants (country VARCHAR(255), power_plant VARCHAR(255), monthly_production FLOAT); INSERT INTO country_power_plants VALUES ('Country X', 'Plant 1', 1000), ('Country X', 'Plant 2', 1200), ('Country Y', 'Plant 3', 1500), ('Country Y', 'Plant 4', 1700), ('Country Z', 'Plant 5', 1300), ('Country ... | List the top 2 countries with the highest average energy production per power plant in descending order. | SELECT country, AVG(monthly_production) AS avg_monthly_production FROM country_power_plants GROUP BY country ORDER BY avg_monthly_production DESC LIMIT 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE basins (id INT, name VARCHAR(255), max_depth FLOAT); INSERT INTO basins (id, name, max_depth) VALUES (1, 'Pacific Ocean', 36000.0), (2, 'Atlantic Ocean', 36000.0), (3, 'Indian Ocean', 7000.0); CREATE TABLE habitats (id INT, depth FLOAT, location VARCHAR(255)); INSERT INTO habitats (id, depth, location) VAL... | What is the maximum depth of the ocean in each ocean basin? | SELECT * FROM max_depths; | gretelai_synthetic_text_to_sql |
CREATE TABLE country_circular_chains (country VARCHAR(255), product_id INT, quantity INT, FOREIGN KEY (product_id) REFERENCES circular_supply_chains(product_id)); | What is the total quantity of products manufactured in each country using circular supply chains? | SELECT country, SUM(quantity) FROM country_circular_chains GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE hospitals (id INT, name TEXT, location TEXT, num_beds INT); INSERT INTO hospitals (id, name, location, num_beds) VALUES (1, 'General Hospital', 'City A', 500), (2, 'Community Clinic', 'City B', 50); CREATE TABLE clinics (id INT, name TEXT, location TEXT, num_doctors INT); INSERT INTO clinics (id, name, loc... | What is the ratio of hospital beds to doctors in each city? | SELECT h.location, h.num_beds / c.num_doctors AS bed_to_doctor_ratio FROM hospitals h JOIN clinics c ON h.location = c.location; | gretelai_synthetic_text_to_sql |
CREATE TABLE match_results (MatchID INT, PlayerID INT, Result VARCHAR(5)); INSERT INTO match_results (MatchID, PlayerID, Result) VALUES (1, 1, 'Win'); INSERT INTO match_results (MatchID, PlayerID, Result) VALUES (2, 2, 'Loss'); INSERT INTO match_results (MatchID, PlayerID, Result) VALUES (3, 1, 'Win'); | Count the number of wins and losses for each player in 'match_results' table. | SELECT PlayerID, SUM(CASE WHEN Result = 'Win' THEN 1 ELSE 0 END) AS Wins, SUM(CASE WHEN Result = 'Loss' THEN 1 ELSE 0 END) AS Losses FROM match_results GROUP BY PlayerID; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA IF NOT EXISTS rural_development;CREATE TABLE IF NOT EXISTS rural_development.community_development (name VARCHAR(255), location VARCHAR(255));INSERT INTO rural_development.community_development (name, location) VALUES ('youth_center', 'Chicago'), ('community_garden', 'Boston'), ('cultural_festival', 'New ... | What are the names of all community development initiatives in the 'rural_development' schema that have a 'location' starting with the letter 'C'? | SELECT name FROM rural_development.community_development WHERE location LIKE 'C%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Virtual_Tourism (Experience VARCHAR(50), Platform VARCHAR(50), User_Experience INT); INSERT INTO Virtual_Tourism (Experience, Platform, User_Experience) VALUES ('Great Wall of China Tour', 'Google Arts & Culture', 4800), ('Eiffel Tower Tour', 'AirPano', 3500), ('Vatican City Tour', 'Yandex', 5200); | Retrieve all sites from the Virtual_Tourism table that have a User_Experience value above 4000. | SELECT Experience FROM Virtual_Tourism WHERE User_Experience > 4000; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_reserves (reserve_name VARCHAR(255), region VARCHAR(255), reserve_area FLOAT); INSERT INTO marine_reserves (reserve_name, region, reserve_area) VALUES ('Bermuda', 'Atlantic', 500.0), ('Azores', 'Atlantic', 600.0); | What is the total area of all marine reserves in the Atlantic region? | SELECT SUM(reserve_area) FROM marine_reserves WHERE region = 'Atlantic'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Players (PlayerID INT, Age INT, Gender VARCHAR(10), LastPurchaseDate DATE); INSERT INTO Players (PlayerID, Age, Gender, LastPurchaseDate) VALUES (1, 25, 'Male', '2021-01-15'), (2, 30, 'Female', '2021-02-03'), (3, 22, 'Male', '2021-03-10'); | What is the average age of players who have made a purchase in the last month from the 'Gaming' category? | SELECT AVG(Age) FROM Players WHERE LastPurchaseDate >= DATEADD(month, -1, GETDATE()) AND Category = 'Gaming'; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (product_category VARCHAR(255), sales_amount NUMERIC, sale_date DATE); INSERT INTO sales (product_category, sales_amount, sale_date) VALUES ('men_shirts', 500, '2021-04-01'); INSERT INTO sales (product_category, sales_amount, sale_date) VALUES ('men_shirts', 700, '2021-05-01'); INSERT INTO sales (pro... | What was the total revenue for men's shirts in Q2 2021? | SELECT SUM(sales_amount) FROM sales WHERE product_category = 'men_shirts' AND sale_date BETWEEN '2021-04-01' AND '2021-06-30'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Shipments (id INT, warehouse_id INT, shipped_date DATE, packages INT); INSERT INTO Shipments (id, warehouse_id, shipped_date, packages) VALUES (1, 1, '2022-01-01', 50), (2, 1, '2022-01-02', 75), (3, 2, '2022-01-03', 100); | What is the maximum number of packages shipped in a single day? | SELECT MAX(s.packages) FROM Shipments s; | gretelai_synthetic_text_to_sql |
CREATE TABLE labor_productivity (year INT, mine_name TEXT, workers INT, productivity FLOAT); INSERT INTO labor_productivity (year, mine_name, workers, productivity) VALUES (2015, 'Aggromine A', 50, 32.4), (2016, 'Borax Bravo', 80, 45.6), (2017, 'Carbon Cat', 100, 136.7), (2017, 'Carbon Cat', 110, 142.3), (2018, 'Diamon... | What is the average labor productivity of the Krypton Kite mine for each year? | SELECT year, mine_name, AVG(productivity) as avg_productivity FROM labor_productivity WHERE mine_name = 'Krypton Kite' GROUP BY year; | gretelai_synthetic_text_to_sql |
CREATE TABLE public_transportation (id INT, city VARCHAR(50), users INT, country VARCHAR(50), year INT); INSERT INTO public_transportation (id, city, users, country, year) VALUES (1, 'Sydney', 800000, 'Australia', 2019), (2, 'Melbourne', 700000, 'Australia', 2019), (3, 'Brisbane', 600000, 'Australia', 2019), (4, 'Sydne... | Number of public transportation users in Australia in 2019 and 2020. | SELECT year, SUM(users) FROM public_transportation WHERE country = 'Australia' GROUP BY year; | gretelai_synthetic_text_to_sql |
CREATE TABLE New_Extractions_2 (country TEXT, mineral TEXT, quantity INTEGER, region TEXT); | Insert records of new mineral extractions in the 'South America' region. | INSERT INTO New_Extractions_2 (country, mineral, quantity, region) VALUES ('Brazil', 'Diamond', 120, 'South America'); INSERT INTO New_Extractions_2 (country, mineral, quantity, region) VALUES ('Peru', 'Emerald', 90, 'South America'); | gretelai_synthetic_text_to_sql |
CREATE TABLE autonomous_buses (bus_id INT, license_plate TEXT, model TEXT, production_year INT, in_service BOOLEAN, city TEXT); | How many autonomous buses are operating in Tokyo, Japan? | SELECT COUNT(*) FROM autonomous_buses WHERE city = 'Tokyo' AND in_service = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE faculty_grants (faculty_id INT, faculty_name VARCHAR(255), gender VARCHAR(10), department VARCHAR(255), grant_amount DECIMAL(10, 2)); INSERT INTO faculty_grants (faculty_id, faculty_name, gender, department, grant_amount) VALUES (1, 'Sophia Rodriguez', 'Female', 'Computer Science', 50000), (2, 'John Kim', ... | What is the total amount of research grants obtained by female faculty members in the Computer Science department, ranked by the total amount in descending order? | SELECT faculty_name, SUM(grant_amount) AS total_grant_amount FROM faculty_grants WHERE department = 'Computer Science' AND gender = 'Female' GROUP BY faculty_name ORDER BY total_grant_amount DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE region (region_id INT, name VARCHAR(255)); INSERT INTO region (region_id, name) VALUES (1, 'east_asia'); CREATE TABLE shelter (shelter_id INT, name VARCHAR(255), region_id INT, capacity INT); INSERT INTO shelter (shelter_id, name, region_id, capacity) VALUES (1, 'Shelter1', 1, 50), (2, 'Shelter2', 1, 75); | How many shelters are there with a capacity greater than 70 in 'east_asia' region? | SELECT COUNT(*) FROM shelter WHERE region_id = (SELECT region_id FROM region WHERE name = 'east_asia') AND capacity > 70; | gretelai_synthetic_text_to_sql |
CREATE TABLE otas (ota_id INT, hotel_id INT, bookings INT); CREATE TABLE hotels (hotel_id INT, name TEXT, category TEXT); INSERT INTO otas (ota_id, hotel_id, bookings) VALUES (1, 1, 100), (2, 2, 150), (3, 3, 75); INSERT INTO hotels (hotel_id, name, category) VALUES (1, 'Hotel A', 'Boutique'), (2, 'Hotel B', 'Luxury'), ... | List the number of OTA bookings made for each hotel in the 'Boutique' category. | SELECT hotels.name, SUM(otas.bookings) FROM otas INNER JOIN hotels ON otas.hotel_id = hotels.hotel_id WHERE hotels.category = 'Boutique' GROUP BY hotels.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE OrgDonations (OrgID INT, DonationAmount INT); | Find total donations for each org in '2021' with cross join | SELECT o.OrgName, SUM(d.DonationAmount) FROM Organizations o CROSS JOIN OrgDonations d WHERE o.OrgID = d.OrgID AND YEAR(d.DonationDate) = 2021 GROUP BY o.OrgName; | gretelai_synthetic_text_to_sql |
CREATE TABLE countries (id INT, name TEXT); CREATE TABLE categories (id INT, name TEXT); CREATE TABLE articles (id INT, title TEXT, content TEXT, category_id INT, country_id INT); INSERT INTO countries (id, name) VALUES (1, 'USA'), (2, 'Canada'), (3, 'Mexico'); INSERT INTO categories (id, name) VALUES (1, 'Politics'), ... | What is the average word count of articles in each country, for articles published in the 'politics' category? | SELECT countries.name, AVG(LENGTH(articles.content) - LENGTH(REPLACE(articles.content, ' ', '')) + 1) as avg_word_count FROM articles INNER JOIN countries ON articles.country_id = countries.id INNER JOIN categories ON articles.category_id = categories.id WHERE categories.name = 'Politics' GROUP BY countries.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Vehicle (VehicleID INT, VehicleType VARCHAR(255)); INSERT INTO Vehicle (VehicleID, VehicleType) VALUES (1, 'Bus'), (2, 'Tram'), (3, 'Train'), (4, 'Ferry'); CREATE TABLE Maintenance (MaintenanceID INT, VehicleID INT, MaintenanceCost DECIMAL(5,2)); INSERT INTO Maintenance (MaintenanceID, VehicleID, Maintenan... | What is the total cost of vehicle maintenance for each type of public transportation? | SELECT Vehicle.VehicleType, SUM(MaintenanceCost) FROM Vehicle JOIN Maintenance ON Vehicle.VehicleID = Maintenance.VehicleID GROUP BY Vehicle.VehicleType; | gretelai_synthetic_text_to_sql |
CREATE TABLE shared_ebikes (ebike_id INT, trip_id INT, trip_start_time TIMESTAMP, trip_end_time TIMESTAMP, start_latitude DECIMAL(9,6), start_longitude DECIMAL(9,6), end_latitude DECIMAL(9,6), end_longitude DECIMAL(9,6), availability INT); | What is the maximum number of electric bikes available in a shared fleet in Sao Paulo at any given time? | SELECT MAX(availability) FROM shared_ebikes WHERE start_longitude BETWEEN -46.8 AND -46.2 AND start_latitude BETWEEN -23.9 AND -23.3; | gretelai_synthetic_text_to_sql |
CREATE TABLE finance (region VARCHAR(255), sector VARCHAR(255), amount FLOAT); INSERT INTO finance (region, sector, amount) VALUES ('North America', 'Energy Efficiency', 9000000), ('South America', 'Energy Efficiency', 7000000), ('Europe', 'Energy Efficiency', 11000000); | What is the total climate finance investment in energy efficiency in North America? | SELECT SUM(amount) FROM finance WHERE region = 'North America' AND sector = 'Energy Efficiency'; | gretelai_synthetic_text_to_sql |
CREATE TABLE regions (region_id INT, region_name VARCHAR(50)); INSERT INTO regions (region_id, region_name) VALUES (1, 'West'), (2, 'East'), (3, 'North'), (4, 'South'); CREATE TABLE pallet_movements (pallet_id INT, movement_date DATE, region_id INT); INSERT INTO pallet_movements (pallet_id, movement_date, region_id) VA... | How many pallets were moved through the west region last month? | SELECT COUNT(pallet_id) FROM pallet_movements WHERE movement_date >= '2021-10-01' AND movement_date <= LAST_DAY('2021-10-01') AND region_id = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Infrastructure (id INT, name VARCHAR(100), type VARCHAR(50), state VARCHAR(50)); INSERT INTO Infrastructure (id, name, type, state) VALUES (7, 'University of Texas', 'School', 'Texas'), (8, 'Oklahoma State University', 'School', 'Oklahoma'); | Get the number of schools in each state | SELECT state, COUNT(*) FROM Infrastructure WHERE type = 'School' GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE team_info (id INT, team_name VARCHAR(50), region VARCHAR(30), wins INT, losses INT); INSERT INTO team_info (id, team_name, region, wins, losses) VALUES (1, 'Northern Lights', 'North America', 15, 5); INSERT INTO team_info (id, team_name, region, wins, losses) VALUES (2, 'Quantum Knights', 'Europe', 10, 8);... | What is the total number of wins for teams from North America that have participated in the "Cybernetic Showdown" eSports tournament? | SELECT SUM(wins) FROM team_info WHERE region = 'North America'; | gretelai_synthetic_text_to_sql |
CREATE TABLE threat_monthly (id INT, record_date DATE, source VARCHAR(10)); INSERT INTO threat_monthly (id, record_date, source) VALUES (1, '2022-02-01', 'TI5'), (2, '2022-02-15', 'TI6'), (3, '2022-03-01', 'TI7'), (4, '2022-04-01', 'TI8'), (5, '2022-04-15', 'TI5'), (6, '2022-05-01', 'TI6'); | Display the number of threat intelligence records and their source by month | SELECT EXTRACT(MONTH FROM record_date) as month, source, COUNT(*) as records FROM threat_monthly GROUP BY month, source; | gretelai_synthetic_text_to_sql |
CREATE TABLE mental_health_parity (state VARCHAR(20), violations INT); INSERT INTO mental_health_parity (state, violations) VALUES ('California', 15), ('Texas', 12), ('New York', 8); | What is the number of mental health parity violations by state? | SELECT state, SUM(violations) FROM mental_health_parity GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE founders (id INT, company_id INT, gender VARCHAR(10)); CREATE TABLE companies (id INT, industry VARCHAR(255), funding_round VARCHAR(255)); INSERT INTO founders SELECT 1, 1, 'Female'; INSERT INTO founders SELECT 2, 2, 'Male'; INSERT INTO founders SELECT 3, 3, 'Female'; INSERT INTO companies (id, industry, f... | List the number of women-led startups in the healthcare sector with Series A funding or higher | SELECT COUNT(DISTINCT companies.id) FROM founders JOIN companies ON founders.company_id = companies.id WHERE companies.industry = 'Healthcare' AND founders.gender = 'Female' AND companies.funding_round >= 'Series A'; | gretelai_synthetic_text_to_sql |
CREATE TABLE teachers (teacher_id INT, country VARCHAR(50), led_open_pedagogy_workshop BOOLEAN); INSERT INTO teachers (teacher_id, country, led_open_pedagogy_workshop) VALUES (1, 'USA', true), (2, 'Canada', false), (3, 'Mexico', true); | Find the number of unique teachers who have led open pedagogy workshops in each country. | SELECT country, COUNT(DISTINCT teacher_id) FROM teachers WHERE led_open_pedagogy_workshop = true GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE donations (id INT, donor_id INT, organization_id INT, amount FLOAT, date DATE); INSERT INTO donations (id, donor_id, organization_id, amount, date) VALUES (1, 1, 101, 250.00, '2020-01-01'); INSERT INTO donations (id, donor_id, organization_id, amount, date) VALUES (2, 2, 102, 150.00, '2020-02-01'); | What is the total amount donated by donors from Canada? | SELECT SUM(amount) FROM donations WHERE country = 'Canada'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Players (PlayerID INT, PlayerName VARCHAR(50), Age INT, Country VARCHAR(50), GamesPlayed INT); INSERT INTO Players (PlayerID, PlayerName, Age, Country, GamesPlayed) VALUES (1, 'John Doe', 25, 'USA', 100); INSERT INTO Players (PlayerID, PlayerName, Age, Country, GamesPlayed) VALUES (2, 'Jane Smith', 30, 'Ca... | How many players from each country have played more than 100 games? | SELECT Country, COUNT(*) FROM Players WHERE GamesPlayed > 100 GROUP BY Country; | gretelai_synthetic_text_to_sql |
CREATE TABLE rural_infrastructure (id INT, country VARCHAR(255), sector VARCHAR(255), allocated_budget INT, year INT); INSERT INTO rural_infrastructure (id, country, sector, allocated_budget, year) VALUES (1, 'Nepal', 'Transport', 800000, 2017), (2, 'Nepal', 'Education', 350000, 2017), (3, 'Pakistan', 'Healthcare', 150... | Infrastructure budget allocation for rural development initiatives, by country and sector, for the year 2017? | SELECT country, sector, SUM(allocated_budget) as total_allocated_budget FROM rural_infrastructure WHERE year = 2017 GROUP BY country, sector; | gretelai_synthetic_text_to_sql |
CREATE TABLE decentralized_applications (app_id INT, name VARCHAR(255), tvl DECIMAL(20, 2)); | What is the total value locked in a specific decentralized application? | SELECT name, tvl FROM decentralized_applications WHERE name = 'Aave'; | gretelai_synthetic_text_to_sql |
CREATE TABLE mine_sites (site_id INT PRIMARY KEY, site_name VARCHAR(255), region VARCHAR(255)); | Delete all records from 'mine_sites' table where 'region' is 'Rocky Mountains' | DELETE FROM mine_sites WHERE region = 'Rocky Mountains'; | gretelai_synthetic_text_to_sql |
CREATE TABLE concerts (id INT, artist_name VARCHAR(255), tickets_sold INT); INSERT INTO concerts (id, artist_name, tickets_sold) VALUES (1, 'Taylor Swift', 12000), (2, 'BTS', 15000); | Find the number of tickets sold per concert by the artist 'Taylor Swift' | SELECT artist_name, SUM(tickets_sold) as total_tickets_sold FROM concerts WHERE artist_name = 'Taylor Swift' GROUP BY artist_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Infrastructure_Projects (id INT, name VARCHAR(100), state VARCHAR(50), cost FLOAT); INSERT INTO Infrastructure_Projects (id, name, state, cost) VALUES (1, 'Floodgate Construction', 'Texas', 12000000); INSERT INTO Infrastructure_Projects (id, name, state, cost) VALUES (2, 'Road Repaving', 'California', 2000... | How many projects in 'Texas' and 'California' have a cost less than $5 million? | SELECT COUNT(*) FROM Infrastructure_Projects WHERE state IN ('Texas', 'California') AND cost < 5000000; | gretelai_synthetic_text_to_sql |
CREATE TABLE american_archaeology (id INT, site_name VARCHAR(50), artifact_name VARCHAR(50)); | How many sites in 'american_archaeology' have more than 10 artifacts? | SELECT site_name, COUNT(artifact_name) FROM american_archaeology GROUP BY site_name HAVING COUNT(artifact_name) > 10; | gretelai_synthetic_text_to_sql |
CREATE TABLE military_patents (patent_name VARCHAR(255), country VARCHAR(255), year INT); INSERT INTO military_patents (patent_name, country, year) VALUES ('Patent 1', 'USA', 2021), ('Patent 2', 'China', 2021), ('Patent 3', 'Russia', 2021); | What is the number of military innovation patents filed by country in 2021? | SELECT country, COUNT(patent_name) FROM military_patents WHERE year = 2021 GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE packages (id INT, weight FLOAT, shipped_date DATE); INSERT INTO packages (id, weight, shipped_date) VALUES (1, 15.3, '2022-01-01'), (2, 22.1, '2022-01-15'); CREATE TABLE freight_methods (id INT, method VARCHAR(50), speed VARCHAR(50)); INSERT INTO freight_methods (id, method, speed) VALUES (1, 'expedited', ... | How many packages were shipped to Asia using standard freight in the last month? | SELECT COUNT(*) FROM packages JOIN freight_methods ON packages.id = freight_methods.id WHERE shipped_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) AND destination = 'Asia' AND method = 'standard'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Vessels (VesselID int, Name varchar(50), Type varchar(50), AverageSpeed float, ComplianceStatus varchar(50)); INSERT INTO Vessels VALUES (1, 'Vessel1', 'Transport', 15, 'Compliant'); | What is the maximum speed of vessels that complied with safety regulations in the last quarter? | SELECT MAX(V.AverageSpeed) FROM Vessels V WHERE V.ComplianceStatus = 'Compliant' AND V.AverageSpeed <= (SELECT AVG(AverageSpeed) FROM Vessels WHERE ComplianceStatus = 'Compliant') AND V.LastInspectionDate >= DATEADD(quarter, -1, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE students (id INT, name VARCHAR(20), grade INT); INSERT INTO students (id, name, grade) VALUES (1, 'John', 95); INSERT INTO students (id, name, grade) VALUES (2, 'Jane', 85); INSERT INTO students (id, name, grade) VALUES (3, 'Bob', 90); INSERT INTO students (id, name, grade) VALUES (4, 'Alice', 80); INSERT ... | List the top 3 students with the highest grades in 'Math' | SELECT students.name, courses.name, students.grade FROM students JOIN courses ON students.grade = courses.grade WHERE courses.name = 'Math' ORDER BY students.grade DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE Contractors (contractor_id INT, name VARCHAR(255), location VARCHAR(255), license_number VARCHAR(50)); | Create a table named "Contractors" with columns "contractor_id", "name", "location", and "license_number". | CREATE TABLE Contractors (contractor_id INT, name VARCHAR(255), location VARCHAR(255), license_number VARCHAR(50)); | 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.