context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE donations (id INT, donation_date DATE); INSERT INTO donations (id, donation_date) VALUES (1, '2021-01-01'), (2, '2021-01-15'), (3, '2021-02-01');
How many donations were made in January 2021?
SELECT COUNT(*) FROM donations WHERE donation_date BETWEEN '2021-01-01' AND '2021-01-31';
gretelai_synthetic_text_to_sql
CREATE TABLE dapp (dapp_name VARCHAR(50)); CREATE TABLE dapp_transactions (dapp_name VARCHAR(50), tx_hash VARCHAR(64));
What is the total number of transactions for each decentralized application on the Solana network?
SELECT dapp.dapp_name, COUNT(dapp_tx.tx_hash) as tx_count FROM dapp LEFT JOIN dapp_transactions dapp_tx ON dapp.dapp_name = dapp_tx.dapp_name GROUP BY dapp.dapp_name;
gretelai_synthetic_text_to_sql
CREATE TABLE concert_events (event_id INT, artist_id INT, event_date DATE, event_location VARCHAR(255), sold_out BOOLEAN); INSERT INTO concert_events (event_id, artist_id, event_date, event_location, sold_out) VALUES (1, 1, '2022-01-01', 'NYC', FALSE); CREATE TABLE artist_demographics (artist_id INT, artist_name VARCHAR(255), gender VARCHAR(50)); INSERT INTO artist_demographics (artist_id, artist_name, gender) VALUES (1, 'Jane Doe', 'non-binary');
How many concerts were sold out in 2021 for artists who identify as non-binary?
SELECT COUNT(*) FROM concert_events ce JOIN artist_demographics ad ON ce.artist_id = ad.artist_id WHERE ce.sold_out = TRUE AND ad.gender = 'non-binary' AND ce.event_date BETWEEN '2021-01-01' AND '2021-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE journalists (id INT, name VARCHAR(30)); CREATE TABLE articles (id INT, journalist_id INT, views INT, category VARCHAR(20)); INSERT INTO journalists VALUES (1, 'Jane Doe'); INSERT INTO articles VALUES (1, 1, 1000, 'investigative');
Who are the top 3 investigative journalists in terms of article views, and what are their respective total views?
SELECT journalists.name, SUM(articles.views) AS total_views FROM journalists INNER JOIN articles ON journalists.id = articles.journalist_id WHERE articles.category = 'investigative' GROUP BY journalists.name ORDER BY total_views DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Dams (id INT, name VARCHAR(100), design_pressure FLOAT); INSERT INTO Dams (id, name, design_pressure) VALUES (1, 'Hoover Dam', 4500), (2, 'Glen Canyon Dam', 2000), (3, 'Oroville Dam', 3500);
What is the average design pressure for all dams in the database?
SELECT AVG(design_pressure) FROM Dams;
gretelai_synthetic_text_to_sql
CREATE TABLE events (event_id INT, name VARCHAR(255), city VARCHAR(255), sport VARCHAR(255), price DECIMAL(5,2)); INSERT INTO events (event_id, name, city, sport, price) VALUES (1, 'Basketball Game', 'California', 'Basketball', 120.50), (2, 'Baseball Game', 'New York', 'Baseball', 50.00), (3, 'Soccer Game', 'California', 'Soccer', 30.00), (4, 'Basketball Game', 'New York', 'Basketball', 150.00); INSERT INTO ticket_sales (sale_id, event_id, quantity) VALUES (1, 1, 1000), (2, 1, 500), (3, 2, 750), (4, 3, 1500), (5, 4, 2000);
What is the total number of tickets sold for basketball games and the average ticket price?
SELECT sport, COUNT(event_id), AVG(price) FROM events JOIN ticket_sales ON events.event_id = ticket_sales.event_id WHERE sport = 'Basketball' GROUP BY sport;
gretelai_synthetic_text_to_sql
CREATE TABLE Highway (id INT, name VARCHAR(50), length FLOAT, country VARCHAR(50)); INSERT INTO Highway (id, name, length, country) VALUES (1, 'Golden Quadrilateral', 5846, 'India');
What is the total length of highways in India?
SELECT SUM(length) FROM Highway WHERE country = 'India';
gretelai_synthetic_text_to_sql
CREATE TABLE districts (id INT, name VARCHAR(255)); INSERT INTO districts (id, name) VALUES (5, 'Riverview'); CREATE TABLE neighborhoods (id INT, district_id INT, name VARCHAR(255)); INSERT INTO neighborhoods (id, district_id, name) VALUES (501, 5, 'Northriver'); INSERT INTO neighborhoods (id, district_id, name) VALUES (502, 5, 'Southriver'); CREATE TABLE disaster_preparedness (id INT, neighborhood_id INT, supplies_stock INT);
Insert new disaster preparedness data for district 5 neighborhoods
INSERT INTO disaster_preparedness (id, neighborhood_id, supplies_stock) VALUES (5001, 501, 100), (5002, 501, 200), (5003, 502, 150);
gretelai_synthetic_text_to_sql
CREATE TABLE building_permits (permit_number TEXT, contractor TEXT); INSERT INTO building_permits (permit_number, contractor) VALUES ('2021-003', 'Contractor B');
Remove permit 2021-003 from the database
WITH cte AS (DELETE FROM building_permits WHERE permit_number = '2021-003') SELECT * FROM cte;
gretelai_synthetic_text_to_sql
CREATE TABLE FarmStock (farm_id INT, stock_change INT, stock_date DATE); INSERT INTO FarmStock (farm_id, stock_change, stock_date) VALUES (1, 300, '2021-10-25'), (1, 250, '2021-10-30'), (2, 100, '2021-10-24');
How many fish were added to each farm in the last week of October 2021, ordered by the number of fish added?
SELECT farm_id, SUM(stock_change) as total_stock_change FROM FarmStock WHERE stock_date >= '2021-10-25' AND stock_date < '2021-11-01' GROUP BY farm_id ORDER BY SUM(stock_change) DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE properties (id INT, price FLOAT, city VARCHAR(20), walkability_score INT); INSERT INTO properties (id, price, city, walkability_score) VALUES (1, 750000, 'Portland', 85), (2, 850000, 'Portland', 75), (3, 650000, 'Portland', 90), (4, 950000, 'Seattle', 60), (5, 550000, 'Portland', 80);
What is the median property price for properties in the city of Portland with a walkability score of 80 or above?
SELECT AVG(price) FROM (SELECT price FROM properties WHERE city = 'Portland' AND walkability_score >= 80 ORDER BY price LIMIT 2 OFFSET 1) AS subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE countries (country_id INT, name VARCHAR(255), marine_protected_area BOOLEAN); INSERT INTO countries (country_id, name, marine_protected_area) VALUES (1, 'Australia', TRUE), (2, 'Canada', FALSE), (3, 'France', TRUE);
How many countries have marine protected areas in the ocean?
SELECT COUNT(*) FROM countries WHERE marine_protected_area = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE energy_efficiency_stats (country VARCHAR(255), year INT, energy_efficiency_index FLOAT);
Show the energy efficiency statistics of the top 3 countries in Asia
SELECT country, energy_efficiency_index FROM energy_efficiency_stats WHERE country IN (SELECT country FROM (SELECT country, AVG(energy_efficiency_index) as avg_efficiency FROM energy_efficiency_stats WHERE country IN ('Asia') GROUP BY country ORDER BY avg_efficiency DESC LIMIT 3) as temp) ORDER BY energy_efficiency_index DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE MentalHealthProviders (ProviderID INT, Region VARCHAR(255), Language VARCHAR(255)); INSERT INTO MentalHealthProviders (ProviderID, Region, Language) VALUES (1, 'North', 'English'), (2, 'South', 'Spanish'), (3, 'East', 'Mandarin'), (4, 'West', 'English');
Calculate the percentage of mental health providers who speak a language other than English, by region.
SELECT Region, COUNT(*) * 100.0 / (SELECT COUNT(*) FROM MentalHealthProviders WHERE Language <> 'English') as Percentage FROM MentalHealthProviders WHERE Language <> 'English' GROUP BY Region;
gretelai_synthetic_text_to_sql
game_stats(player_id, game_id, score, date_played)
Get the total score of each player in the last week
SELECT player_id, SUM(score) as total_score FROM game_stats WHERE date_played >= CURDATE() - INTERVAL 1 WEEK GROUP BY player_id;
gretelai_synthetic_text_to_sql
CREATE TABLE projects (id INT, region VARCHAR(50), type VARCHAR(50), budget INT); INSERT INTO projects (id, region, type, budget) VALUES (1, 'Cascadia', 'sustainable urbanism', 2000000), (2, 'Pacific Northwest', 'sustainable urbanism', 3000000), (3, 'Cascadia', 'affordable housing', 1000000);
Which regions have more than 10 sustainable urbanism projects?
SELECT region FROM projects WHERE type = 'sustainable urbanism' GROUP BY region HAVING COUNT(*) > 10;
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, donor_name VARCHAR(50), donation_amount DECIMAL(10,2), donation_date DATE, is_volunteer BOOLEAN, program_name VARCHAR(50)); INSERT INTO donations (id, donor_name, donation_amount, donation_date, is_volunteer, program_name) VALUES (1, 'Carlos Hernandez', 100.00, '2022-04-01', true, 'Program A'), (2, 'Ana Garcia', 200.00, '2022-07-01', true, 'Program B'), (3, 'Luis Rodriguez', 150.00, '2022-10-01', false, 'Program C'), (4, 'Mariana Sanchez', 50.00, '2022-01-01', true, 'Program A'); CREATE TABLE programs (id INT, program_name VARCHAR(50)); INSERT INTO programs (id, program_name) VALUES (1, 'Program A'), (2, 'Program B'), (3, 'Program C');
What is the total donation amount by volunteers in Mexico, for each program, in the fiscal year 2022?
SELECT p.program_name, DATE_FORMAT(d.donation_date, '%Y-%V') AS fiscal_year, SUM(d.donation_amount) FROM donations d JOIN programs p ON d.program_name = p.program_name WHERE d.is_volunteer = true AND d.donor_country = 'Mexico' GROUP BY p.program_name, fiscal_year;
gretelai_synthetic_text_to_sql
CREATE TABLE initiatives (id INT, country VARCHAR(255), initiative_name VARCHAR(255), initiative_type VARCHAR(255)); INSERT INTO initiatives (id, country, initiative_name, initiative_type) VALUES (1, 'USA', 'National Parks Conservation', 'Environment'), (2, 'Canada', 'Wildlife Protection Program', 'Animal Welfare'), (3, 'Mexico', 'Sustainable Tourism Certification', 'Tourism'), (4, 'USA', 'Green Cities Initiative', 'Urban Development');
List all sustainable tourism initiatives in North America
SELECT country, initiative_name, initiative_type FROM initiatives WHERE country IN ('USA', 'Canada', 'Mexico');
gretelai_synthetic_text_to_sql
CREATE TABLE donors (id INT, name TEXT, city TEXT, amount DECIMAL(10,2)); INSERT INTO donors (id, name, city, amount) VALUES (1, 'Anna', 'Seattle', 500.00), (2, 'Brendan', 'New York', 300.00);
What is the total amount donated by individuals in the city of Seattle?
SELECT SUM(amount) FROM donors WHERE city = 'Seattle';
gretelai_synthetic_text_to_sql
CREATE TABLE community_engagement (id INT, program VARCHAR(50), region VARCHAR(50)); INSERT INTO community_engagement (id, program, region) VALUES (1, 'Cultural Festival', 'Africa'), (2, 'Art Exhibition', 'Europe');
Show community engagement programs in Africa.
SELECT * FROM community_engagement WHERE region = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE negotiations(id INT, negotiation VARCHAR(50), contractor VARCHAR(50), amount NUMERIC);
What was the total contract value for arms reduction negotiations?
SELECT SUM(amount) FROM negotiations WHERE negotiation = 'Arms Reduction';
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (id INT, name TEXT, city TEXT, country TEXT, review_score FLOAT); INSERT INTO hotels (id, name, city, country, review_score) VALUES (1, 'Hotel Ritz', 'Paris', 'France', 4.8);
What is the average review score for hotels in Paris, France?
SELECT AVG(review_score) FROM hotels WHERE city = 'Paris' AND country = 'France';
gretelai_synthetic_text_to_sql
CREATE TABLE Revenue (id INT, organization VARCHAR(50), revenue DECIMAL(5,2), month VARCHAR(10), year INT); INSERT INTO Revenue (id, organization, revenue, month, year) VALUES (1, 'Equal Tech', 15000.00, 'January', 2021), (2, 'Tech Learning', 20000.00, 'February', 2021), (3, 'Global Connect', 10000.00, 'March', 2021);
What is the total revenue generated by organizations working on technology for social good in the first quarter of 2021?
SELECT SUM(revenue) FROM Revenue WHERE organization IN (SELECT DISTINCT organization FROM Revenue WHERE category = 'Social Good') AND month IN ('January', 'February', 'March') AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE Policyholders (PolicyID INT, PolicyholderName TEXT, State TEXT); INSERT INTO Policyholders (PolicyID, PolicyholderName, State) VALUES (1, 'Maria Garcia', 'CA'), (2, 'James Lee', 'NY'); CREATE TABLE Claims (ClaimID INT, PolicyID INT, ClaimAmount INT); INSERT INTO Claims (ClaimID, PolicyID, ClaimAmount) VALUES (1, 1, 10000), (2, 1, 7000), (3, 2, 3000);
Who are the policyholders in 'CA' with the highest claim amount?
SELECT PolicyholderName, MAX(ClaimAmount) AS MaxClaimAmount FROM Policyholders INNER JOIN Claims ON Policyholders.PolicyID = Claims.PolicyID WHERE Policyholders.State = 'CA' GROUP BY PolicyholderName;
gretelai_synthetic_text_to_sql
CREATE TABLE production_by_mine (id INT, mine VARCHAR(20), min_production DECIMAL(10, 2)); INSERT INTO production_by_mine (id, mine, min_production) VALUES (1, 'gold', 900.00), (2, 'silver', 700.00), (3, 'coal', 800.00);
What is the minimum production in the 'gold' mine?
SELECT MIN(min_production) FROM production_by_mine WHERE mine = 'gold';
gretelai_synthetic_text_to_sql
CREATE TABLE members_2020 (id INT, name VARCHAR(50), country VARCHAR(50), joined DATE); INSERT INTO members_2020 (id, name, country, joined) VALUES (1, 'John Doe', 'USA', '2020-01-01'); INSERT INTO members_2020 (id, name, country, joined) VALUES (2, 'Jane Smith', 'Canada', '2019-06-15'); INSERT INTO members_2020 (id, name, country, joined) VALUES (3, 'Pedro Alvarez', 'Mexico', '2021-02-20'); CREATE TABLE workout_sessions_2020 (id INT, member_id INT, activity VARCHAR(50), duration INT); INSERT INTO workout_sessions_2020 (id, member_id, activity, duration) VALUES (1, 1, 'Running', 60); INSERT INTO workout_sessions_2020 (id, member_id, activity, duration) VALUES (2, 1, 'Cycling', 45); INSERT INTO workout_sessions_2020 (id, member_id, activity, duration) VALUES (3, 2, 'Yoga', 90);
Find the total number of members who joined in 2020 and the number of workout sessions they had.
SELECT m.id, COUNT(ws.id) as total_sessions FROM members_2020 m INNER JOIN workout_sessions_2020 ws ON m.id = ws.member_id GROUP BY m.id;
gretelai_synthetic_text_to_sql
CREATE TABLE Manufacturers (ManufacturerID INT, ManufacturerName VARCHAR(50), Region VARCHAR(50), FairTrade VARCHAR(5)); INSERT INTO Manufacturers (ManufacturerID, ManufacturerName, Region, FairTrade) VALUES (1, 'EcoFriendlyFabrics', 'Europe', 'Yes'), (2, 'GreenYarns', 'Asia', 'No');
Update the 'FairTrade' status of the manufacturer 'GreenYarns' to 'Yes'.
UPDATE Manufacturers SET FairTrade = 'Yes' WHERE ManufacturerName = 'GreenYarns';
gretelai_synthetic_text_to_sql
CREATE TABLE astrophysics_research (research_id INT, location VARCHAR(50), distance FLOAT); INSERT INTO astrophysics_research (research_id, location, distance) VALUES (1, 'Mars', 50.3), (2, 'Venus', 10.2), (3, 'Mars', 40.1), (4, 'Jupiter', 70.5), (5, 'Mars', 60.0), (6, 'Venus', 11.5), (7, 'Venus', 12.1);
What is the average distance from Earth for astrophysics research on Venus?
SELECT AVG(distance) FROM astrophysics_research WHERE location = 'Venus';
gretelai_synthetic_text_to_sql
CREATE TABLE customers (id INT, name VARCHAR(50), age INT, account_balance DECIMAL(10, 2), country VARCHAR(50)); INSERT INTO customers (id, name, age, account_balance, country) VALUES (1, 'Jane Smith', 50, 10000.00, 'United States'), (2, 'Marie Jones', 45, 20000.00, 'Canada');
What is the maximum account balance for customers in each country?
SELECT country, MAX(account_balance) as max_account_balance FROM customers GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE cafe (cafe_id INT, name VARCHAR(50), country VARCHAR(50)); INSERT INTO cafe VALUES (1, 'Cafe Central', 'USA'); INSERT INTO cafe VALUES (2, 'Green Cafe', 'USA'); CREATE TABLE dishes (dish_id INT, name VARCHAR(50), type VARCHAR(20), calorie_count INT); INSERT INTO dishes VALUES (1, 'Quinoa Salad', 'organic', 350); INSERT INTO dishes VALUES (2, 'Chickpea Curry', 'organic', 500);
What is the average calorie count for organic dishes served in cafes located in the US?
SELECT AVG(d.calorie_count) FROM dishes d JOIN cafe c ON d.name = c.name WHERE c.country = 'USA' AND d.type = 'organic';
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_offset_initiatives (initiative_id INT, initiative_name VARCHAR(100), participants INT); INSERT INTO carbon_offset_initiatives (initiative_id, initiative_name, participants) VALUES (1, 'Tree Planting', 5000), (2, 'Energy Efficiency Program', 7000), (3, 'Public Transportation', 6000);
List the top 2 carbon offset initiatives by number of participants in descending order.
SELECT initiative_name, participants FROM (SELECT initiative_name, participants, ROW_NUMBER() OVER (ORDER BY participants DESC) rn FROM carbon_offset_initiatives) WHERE rn <= 2
gretelai_synthetic_text_to_sql
CREATE TABLE policy_impact (city VARCHAR(255), policy_id INT, impact TEXT); INSERT INTO policy_impact
What is the total number of policy impact records for 'City N' and 'City O'?
SELECT COUNT(*) FROM policy_impact WHERE (city = 'City N' OR city = 'City O')
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (id INT PRIMARY KEY, species_name VARCHAR(255), conservation_status VARCHAR(255)); INSERT INTO marine_species (id, species_name, conservation_status) VALUES (1, 'Blue Whale', 'Vulnerable'); INSERT INTO marine_species (id, species_name, conservation_status) VALUES (2, 'Dolphin', 'Least Concern');
Delete all records from the "marine_species" table where the "conservation_status" is "Least Concern"
DELETE FROM marine_species WHERE conservation_status = 'Least Concern';
gretelai_synthetic_text_to_sql
CREATE TABLE Initiatives (InitiativeID INT, InitiativeName VARCHAR(50), Sector VARCHAR(50)); INSERT INTO Initiatives (InitiativeID, InitiativeName, Sector) VALUES (1, 'Accessible Coding Curriculum', 'Education'); INSERT INTO Initiatives (InitiativeID, InitiativeName, Sector) VALUES (2, 'Digital Literacy for All', 'Healthcare');
List all the initiatives related to technology accessibility in the education sector.
SELECT InitiativeName FROM Initiatives WHERE Sector = 'Education';
gretelai_synthetic_text_to_sql
CREATE TABLE WeatherStation (ID INT, Name TEXT, Location TEXT, Country TEXT); INSERT INTO WeatherStation (ID, Name, Location, Country) VALUES (1, 'Station1', 'Location1', 'Canada'); INSERT INTO WeatherStation (ID, Name, Location, Country) VALUES (2, 'Station2', 'Location2', 'Russia'); CREATE TABLE Temperature (ID INT, WeatherStationID INT, Date DATE, Temperature FLOAT); INSERT INTO Temperature (ID, WeatherStationID, Date, Temperature) VALUES (1, 1, '2020-01-01', -10.0);
What is the average temperature recorded for each month in 2020 across all arctic weather stations?
SELECT AVG(Temperature) as Avg_Temperature, DATE_FORMAT(Date, '%M') as Month FROM Temperature JOIN WeatherStation ON Temperature.WeatherStationID = WeatherStation.ID WHERE Country IN ('Canada', 'Russia') AND Date LIKE '2020-%' GROUP BY Month;
gretelai_synthetic_text_to_sql
CREATE TABLE sensors (id INT, location VARCHAR(255), temperature FLOAT, reading_date DATE); INSERT INTO sensors (id, location, temperature, reading_date) VALUES (1, 'Field1', -5, '2021-12-01'); INSERT INTO sensors (id, location, temperature, reading_date) VALUES (2, 'Field2', -3, '2022-01-15'); INSERT INTO sensors (id, location, temperature, reading_date) VALUES (3, 'Field1', -6, '2022-02-01');
What was the minimum temperature recorded in 'Winter' for each location?
SELECT location, MIN(temperature) FROM sensors WHERE reading_date BETWEEN '2021-12-01' AND '2022-02-28' GROUP BY location
gretelai_synthetic_text_to_sql
CREATE TABLE education_aid (id INT, location VARCHAR(50), aid_type VARCHAR(50), amount FLOAT, date DATE); INSERT INTO education_aid (id, location, aid_type, amount, date) VALUES (1, 'South Sudan', 'education', 300000, '2022-02-01');
What is the total amount of education aid sent to South Sudan in the past year?
SELECT SUM(amount) as total_education_aid FROM education_aid WHERE location = 'South Sudan' AND date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE route (route_id INT, name VARCHAR(255)); CREATE TABLE trip (trip_id INT, route_id INT, fare DECIMAL(10,2), departure_time TIME); INSERT INTO route (route_id, name) VALUES (1, 'Route A'), (2, 'Route B'); INSERT INTO trip (trip_id, route_id, fare, departure_time) VALUES (1, 1, 2.00, '06:00:00'), (2, 1, 3.00, '07:00:00'), (3, 2, 4.00, '08:00:00'), (4, 2, 5.00, '09:00:00');
What is the total fare collected for each route by time of day?
SELECT EXTRACT(HOUR FROM departure_time) AS hour_of_day, route.route_id, route.name, SUM(fare) AS total_fare FROM trip JOIN route ON trip.route_id = route.route_id GROUP BY hour_of_day, route.route_id;
gretelai_synthetic_text_to_sql
CREATE TABLE brands (brand_id INT, brand VARCHAR(255), cruelty_free BOOLEAN); INSERT INTO brands (brand_id, brand, cruelty_free) VALUES (1, 'Loreal', FALSE), (2, 'The Body Shop', TRUE), (3, 'Estee Lauder', FALSE), (4, 'Urban Decay', TRUE);
How many cruelty-free certifications does each brand have, ordered by the number of certifications?
SELECT brand, SUM(cruelty_free) as certifications FROM brands GROUP BY brand ORDER BY certifications DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE volcanoes (id INT, ocean VARCHAR(50), year INT, num_volcanoes INT); INSERT INTO volcanoes (id, ocean, year, num_volcanoes) VALUES (1, 'Atlantic Ocean', 2018, 120), (2, 'Atlantic Ocean', 2019, 125), (3, 'Atlantic Ocean', 2020, NULL);
How many underwater volcanoes are there in the Atlantic Ocean as of 2020?
SELECT num_volcanoes FROM volcanoes WHERE ocean = 'Atlantic Ocean' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE age_distribution (event_name VARCHAR(50), city VARCHAR(50), age_group VARCHAR(10), attendees INT); INSERT INTO age_distribution (event_name, city, age_group, attendees) VALUES ('Youth Arts Showcase', 'Chicago', 'Under 18', 200);
What was the percentage of attendees under 18 years old at the 'Youth Arts Showcase' in Chicago?
SELECT (attendees * 100.0 / (SELECT SUM(attendees) FROM age_distribution WHERE event_name = 'Youth Arts Showcase' AND city = 'Chicago')) AS percentage FROM age_distribution WHERE event_name = 'Youth Arts Showcase' AND city = 'Chicago' AND age_group = 'Under 18';
gretelai_synthetic_text_to_sql
CREATE TABLE Flight_Safety (ID INT, Airline VARCHAR(50), Region VARCHAR(50), Safety_Record INT); INSERT INTO Flight_Safety (ID, Airline, Region, Safety_Record) VALUES (1, 'Air China', 'Asia-Pacific', 98), (2, 'Singapore Airlines', 'Asia-Pacific', 99), (3, 'Qantas', 'Asia-Pacific', 99.5), (4, 'Japan Airlines', 'Asia-Pacific', 98.5), (5, 'Garuda Indonesia', 'Asia-Pacific', 97);
What is the average flight safety record per airline in the Asia-Pacific region?
SELECT Region, AVG(Safety_Record) FROM Flight_Safety WHERE Region = 'Asia-Pacific' GROUP BY Region;
gretelai_synthetic_text_to_sql
CREATE TABLE Buildings (building_id INT, state VARCHAR(20), energy_efficiency_rating FLOAT); INSERT INTO Buildings (building_id, state, energy_efficiency_rating) VALUES (1, 'California', 85.2), (2, 'Oregon', 82.7), (3, 'California', 87.9), (4, 'Oregon', 89.1);
What is the average energy efficiency rating of buildings in each state?
SELECT state, AVG(energy_efficiency_rating) FROM Buildings GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE attendance (id INT, game_id INT, attendees INT); INSERT INTO attendance (id, game_id, attendees) VALUES (1, 1, 12000); INSERT INTO attendance (id, game_id, attendees) VALUES (2, 2, 9000);
How many football games had more than 10000 attendees?
SELECT COUNT(*) FROM attendance WHERE attendees > 10000 AND game_id IN (SELECT id FROM games WHERE sport = 'Football');
gretelai_synthetic_text_to_sql
CREATE TABLE vessel_details (vessel_id INT, vessel_name VARCHAR(50)); CREATE TABLE safety_records (vessel_id INT, inspection_status VARCHAR(10));
Delete vessels with no safety inspection records from the vessel_details table
DELETE FROM vessel_details WHERE vessel_id NOT IN (SELECT vessel_id FROM safety_records);
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_floors (ocean TEXT, trench_name TEXT, minimum_depth INTEGER); INSERT INTO ocean_floors (ocean, trench_name, minimum_depth) VALUES ('Pacific Ocean', 'Mariana Trench', 10994), ('Atlantic Ocean', 'Puerto Rico Trench', 8380), ('Indian Ocean', 'Java Trench', 7290);
Find the minimum depth of the Atlantic Ocean
SELECT MIN(minimum_depth) FROM ocean_floors WHERE ocean = 'Atlantic Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE media_content (id INT, title VARCHAR(255), release_year INT, runtime INT, genre VARCHAR(255), format VARCHAR(50), country VARCHAR(255), director VARCHAR(255));
What is the total runtime of movies and TV shows produced in Canada, and how many unique directors are there?
SELECT country, SUM(runtime) AS total_runtime, COUNT(DISTINCT director) AS unique_directors FROM media_content WHERE country = 'Canada' GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE philanthropy.organizations (organization_id INT, organization_name TEXT, total_donations DECIMAL);
What is the total donation amount per organization in the 'philanthropy.organizations' table?
SELECT organization_id, SUM(d.amount) FROM philanthropy.donations d JOIN philanthropy.organizations o ON d.organization_id = o.organization_id GROUP BY organization_id;
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (vessel_id INT, vessel_name VARCHAR(50), flag_state VARCHAR(50)); CREATE TABLE ports_visited (id INT, vessel_id INT, port_id INT, visit_date DATE);
Identify vessels that visited multiple ports in a single journey, and provide their journey start and end dates.
SELECT v1.vessel_name, v1.visit_date as journey_start, v2.visit_date as journey_end FROM ports_visited v1 JOIN ports_visited v2 ON v1.vessel_id = v2.vessel_id AND v1.visit_date < v2.visit_date WHERE NOT EXISTS (SELECT 1 FROM ports_visited v3 WHERE v3.vessel_id = v1.vessel_id AND v3.visit_date > v1.visit_date AND v3.visit_date < v2.visit_date);
gretelai_synthetic_text_to_sql
CREATE TABLE europe_suppliers(name VARCHAR(50), location VARCHAR(50), sustainability_rating INT); INSERT INTO europe_suppliers (name, location, sustainability_rating) VALUES ('GreenFabrics', 'France', 97); INSERT INTO europe_suppliers (name, location, sustainability_rating) VALUES ('EcoWeave', 'Germany', 95); INSERT INTO europe_suppliers (name, location, sustainability_rating) VALUES ('SustainSupply', 'Italy', 94);
List the top 2 most sustainable fabric suppliers in 'Europe' based on the sustainability_rating?
SELECT name, sustainability_rating FROM europe_suppliers WHERE location = 'Europe' ORDER BY sustainability_rating DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE contract_negotiations(id INT, country VARCHAR(50), contractor VARCHAR(50), negotiation_date DATE, status VARCHAR(50)); INSERT INTO contract_negotiations(id, country, contractor, negotiation_date, status) VALUES (1, 'Saudi Arabia', 'ABC Corp', '2015-01-01', 'Successful'); INSERT INTO contract_negotiations(id, country, contractor, negotiation_date, status) VALUES (2, 'Saudi Arabia', 'XYZ Inc.', '2016-01-01', 'Successful');
Find the number of successful contract negotiations with Saudi Arabia for each year since 2015.
SELECT YEAR(negotiation_date), COUNT(*) FROM contract_negotiations WHERE country = 'Saudi Arabia' AND status = 'Successful' GROUP BY YEAR(negotiation_date);
gretelai_synthetic_text_to_sql
CREATE TABLE OilWells (WellID VARCHAR(10), Production FLOAT, Location VARCHAR(50));
What is the minimum production of a well in 'Saudi Arabia'?
SELECT MIN(Production) FROM OilWells WHERE Location = 'Saudi Arabia';
gretelai_synthetic_text_to_sql
CREATE TABLE EnergyTypes (TypeID int, TypeName varchar(50)); CREATE TABLE RenewableProjects (ProjectID int, TypeID int, InstalledCapacity int);
What is the total number of renewable energy projects and their total installed capacity for each energy type?
SELECT EnergyTypes.TypeName, COUNT(RenewableProjects.ProjectID) as TotalProjects, SUM(RenewableProjects.InstalledCapacity) as TotalCapacity FROM EnergyTypes INNER JOIN RenewableProjects ON EnergyTypes.TypeID = RenewableProjects.TypeID GROUP BY EnergyTypes.TypeName;
gretelai_synthetic_text_to_sql
CREATE TABLE TextileSuppliers (SupplierID INT, SupplierName VARCHAR(255), Continent VARCHAR(255), CO2Emission INT); INSERT INTO TextileSuppliers (SupplierID, SupplierName, Continent, CO2Emission) VALUES (1, 'Supplier1', 'Asia', 500);
What is the average CO2 emission of textile suppliers, per continent?
SELECT AVG(CO2Emission) as AverageCO2Emission, Continent FROM TextileSuppliers GROUP BY Continent;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (sale_id INT, product_id INT, brand VARCHAR(100), sales_volume INT); CREATE TABLE products (product_id INT, product_name VARCHAR(100), is_natural BOOLEAN, product_type VARCHAR(50));
Which brands have the highest sales of natural hair care products?
SELECT brand, SUM(sales_volume) as total_sales FROM sales JOIN products ON sales.product_id = products.product_id WHERE is_natural = TRUE AND product_type = 'hair care' GROUP BY brand ORDER BY total_sales DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE sourcing (restaurant_id INT, certification TEXT); INSERT INTO sourcing (restaurant_id, certification) VALUES (1, 'Seafood Watch'), (1, 'Fair Trade'), (2, 'Rainforest Alliance'), (2, 'Marine Stewardship Council'), (3, 'Seafood Watch'), (3, 'Fair Trade'), (4, 'Rainforest Alliance'), (4, 'Marine Stewardship Council'), (4, 'Seafood Watch');
Which sustainable sourcing certifications are most common among the restaurants?
SELECT certification, COUNT(*) FROM sourcing GROUP BY certification ORDER BY COUNT(*) DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels (VesselID INT, VesselName VARCHAR(255)); CREATE TABLE Journeys (JourneyID INT, VesselID INT, JourneySpeed DECIMAL(5,2), JourneyDate DATETIME); INSERT INTO Vessels (VesselID, VesselName) VALUES (1, 'Oceanus'), (2, 'Neptune'), (3, 'Poseidon'); INSERT INTO Journeys (JourneyID, VesselID, JourneySpeed, JourneyDate) VALUES (1, 1, 15.5, '2021-07-01 10:00:00'), (2, 1, 17.2, '2021-07-05 14:00:00'), (3, 2, 19.8, '2021-07-03 08:00:00'), (4, 2, 20.0, '2021-07-10 16:00:00'), (5, 3, 18.5, '2021-07-07 11:00:00'), (6, 3, 18.0, '2021-07-15 09:00:00');
What was the average journey speed (in knots) for all vessels in the month of July 2021?
SELECT AVG(JourneySpeed) AS AvgJourneySpeed FROM Journeys WHERE MONTH(JourneyDate) = 7;
gretelai_synthetic_text_to_sql
CREATE TABLE jakarta_wastewater (year INT, treatment_volume INT); INSERT INTO jakarta_wastewater (year, treatment_volume) VALUES (2019, 500000), (2020, 550000);
What is the total volume of wastewater treated in Jakarta, Indonesia in 2019 and 2020?
SELECT jakarta_wastewater.year, SUM(jakarta_wastewater.treatment_volume) as total_treatment_volume FROM jakarta_wastewater WHERE jakarta_wastewater.year IN (2019, 2020) GROUP BY jakarta_wastewater.year;
gretelai_synthetic_text_to_sql
CREATE TABLE smart_cities (id INT, name VARCHAR(100), location VARCHAR(50), description TEXT, region VARCHAR(10)); INSERT INTO smart_cities (id, name, location, description, region) VALUES (1, 'Smart City A', 'Buenos Aires', 'Smart city project', 'South America'); INSERT INTO smart_cities (id, name, location, description, region) VALUES (2, 'Smart City B', 'Rio de Janeiro', 'Smart city initiative', 'South America');
Get the total number of smart city projects in 'South America'
SELECT COUNT(*) FROM smart_cities WHERE region = 'South America';
gretelai_synthetic_text_to_sql
CREATE SCHEMA Aerospace;CREATE TABLE Aerospace.AircraftManufacturing (manufacturer VARCHAR(50), country VARCHAR(50), delivery_time INT);INSERT INTO Aerospace.AircraftManufacturing (manufacturer, country, delivery_time) VALUES ('Boeing', 'USA', 18), ('Airbus', 'Europe', 24), ('Comac', 'China', 30);
What is the average delivery time for aircraft manufactured by country?
SELECT country, AVG(delivery_time) FROM Aerospace.AircraftManufacturing GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE accommodations (id INT, student_id INT, type TEXT, cost INT); INSERT INTO accommodations (id, student_id, type, cost) VALUES (1, 1, 'screen reader', 200); INSERT INTO accommodations (id, student_id, type, cost) VALUES (2, 2, 'note taker', 500);
What is the average cost of disability accommodations per student for students with visual impairments?
SELECT AVG(cost) FROM accommodations WHERE type IN ('screen reader', 'braille display', 'large print materials') GROUP BY student_id;
gretelai_synthetic_text_to_sql
CREATE TABLE financial_literacy (individual_id TEXT, financial_literacy TEXT, wellbeing_score NUMERIC); INSERT INTO financial_literacy (individual_id, financial_literacy, wellbeing_score) VALUES ('33333', 'high', 85); INSERT INTO financial_literacy (individual_id, financial_literacy, wellbeing_score) VALUES ('44444', 'high', 90);
What is the average financial wellbeing score of individuals in the United States who have a high financial literacy level?
SELECT AVG(wellbeing_score) FROM financial_literacy WHERE financial_literacy = 'high' AND country = 'United States';
gretelai_synthetic_text_to_sql
CREATE TABLE lenders (lender_id INT, name VARCHAR(255), address VARCHAR(255)); CREATE TABLE loans (loan_id INT, lender_id INT, date DATE, amount DECIMAL(10,2), socially_responsible BOOLEAN, gender VARCHAR(255));
How many socially responsible loans were issued to women in the last year?
SELECT lenders.name, COUNT(loans.loan_id) as count FROM lenders INNER JOIN loans ON lenders.lender_id = loans.lender_id WHERE loans.date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) AND CURRENT_DATE AND loans.socially_responsible = TRUE AND loans.gender = 'Female' GROUP BY lenders.name;
gretelai_synthetic_text_to_sql
CREATE TABLE treatment (treatment_id INT, patient_id INT, condition VARCHAR(50), provider VARCHAR(50), date DATE); INSERT INTO treatment (treatment_id, patient_id, condition, provider, date) VALUES (1, 1, 'Anxiety Disorder', 'Dr. Jane', '2021-01-01'); INSERT INTO treatment (treatment_id, patient_id, condition, provider, date) VALUES (2, 1, 'PTSD', 'Dr. Bob', '2021-02-01'); INSERT INTO treatment (treatment_id, patient_id, condition, provider, date) VALUES (3, 2, 'Anxiety Disorder', 'Dr. Bob', '2021-03-01'); INSERT INTO treatment (treatment_id, patient_id, condition, provider, date) VALUES (4, 3, 'Depression', 'Dr. Jane', '2022-01-15');
List the number of unique mental health providers in the 'treatment' table who treated patients in January 2022.
SELECT COUNT(DISTINCT provider) FROM treatment WHERE date BETWEEN '2022-01-01' AND '2022-01-31';
gretelai_synthetic_text_to_sql
CREATE TABLE ai_models (model_name TEXT, fairness_score INTEGER, sector TEXT); INSERT INTO ai_models (model_name, fairness_score, sector) VALUES ('Model1', 90, 'Healthcare'), ('Model2', 80, 'Education'), ('Model3', 88, 'Finance');
Find the number of AI models with a fairness score above 85, excluding those from the education sector.
SELECT COUNT(*) FROM ai_models WHERE fairness_score > 85 AND sector != 'Education';
gretelai_synthetic_text_to_sql
CREATE TABLE accessible_tech_projects (id INT, country VARCHAR(2), project_accessibility VARCHAR(10)); INSERT INTO accessible_tech_projects (id, country, project_accessibility) VALUES (1, 'CN', 'yes'), (2, 'IN', 'no'), (3, 'JP', 'yes'), (4, 'KR', 'yes'), (5, 'SG', 'no'), (6, 'VN', 'yes'), (7, 'ID', 'no'), (8, 'TH', 'yes'), (9, 'PH', 'no'), (10, 'MY', 'yes');
What is the total number of accessible technology projects in Asia?
SELECT COUNT(*) FROM accessible_tech_projects WHERE country IN ('CN', 'IN', 'JP', 'KR', 'SG', 'VN', 'ID', 'TH', 'PH', 'MY') AND project_accessibility = 'yes';
gretelai_synthetic_text_to_sql
CREATE TABLE pollution_control_initiatives (id INT, initiative VARCHAR(50), last_updated TIMESTAMP);
Delete all pollution control initiatives that have not been updated in the last 2 years.
DELETE FROM pollution_control_initiatives WHERE last_updated < NOW() - INTERVAL 2 YEAR;
gretelai_synthetic_text_to_sql
CREATE TABLE heritagesites (id INT, site_name VARCHAR(100), location VARCHAR(50)); INSERT INTO heritagesites (id, site_name, location) VALUES (1, 'Machu Picchu', 'South America'), (2, 'Great Zimbabwe', 'Africa');
Compare the number of heritage sites in Africa and South America.
SELECT COUNT(*) FROM heritagesites WHERE location = 'Africa' INTERSECT SELECT COUNT(*) FROM heritagesites WHERE location = 'South America';
gretelai_synthetic_text_to_sql
CREATE TABLE TVShows (ShowId INT, ShowName VARCHAR(50), Seasons INT, Genre VARCHAR(50), Viewers INT); INSERT INTO TVShows (ShowId, ShowName, Seasons, Genre, Viewers) VALUES (1, 'ShowA', 3, 'Drama', 500000), (2, 'ShowB', 2, 'Comedy', 700000), (3, 'ShowC', 4, 'Drama', 600000);
Which TV shows have the highest and lowest viewership within their genre?
SELECT ShowName, Genre, Viewers, RANK() OVER(PARTITION BY Genre ORDER BY Viewers DESC) AS Rank FROM TVShows;
gretelai_synthetic_text_to_sql
CREATE TABLE clean_energy_policy (id INT PRIMARY KEY, policy_name VARCHAR(100), country VARCHAR(50), year_implemented INT);
Add a new record to the 'clean_energy_policy' table with id 6001, policy_name 'Feed-in Tariff', country 'Spain', and year_implemented 2007
INSERT INTO clean_energy_policy (id, policy_name, country, year_implemented) VALUES (6001, 'Feed-in Tariff', 'Spain', 2007);
gretelai_synthetic_text_to_sql
CREATE TABLE lifelong_learning (student_name VARCHAR(20), learning_hours INT, learning_date DATE); INSERT INTO lifelong_learning (student_name, learning_hours, learning_date) VALUES ('Student A', 10, '2017-09-01'), ('Student A', 8, '2018-02-14'), ('Student B', 12, '2019-06-22'), ('Student B', 15, '2020-12-31'), ('Student C', 11, '2021-07-04'), ('Student C', 7, '2022-02-15');
What is the average number of lifetime learning hours per student up to '2022'?
SELECT AVG(total_hours) as avg_hours FROM (SELECT student_name, SUM(learning_hours) as total_hours FROM lifelong_learning WHERE learning_date <= '2022-12-31' GROUP BY student_name) as subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE subway_lines (id INT PRIMARY KEY, line_number INT, line_name VARCHAR(255), city VARCHAR(255), total_passengers INT);
Update the total number of passengers for the NYC subway line 6
UPDATE subway_lines SET total_passengers = 850000 WHERE line_number = 6 AND city = 'NYC';
gretelai_synthetic_text_to_sql
CREATE TABLE art_pieces (piece_id INT, title VARCHAR(50), year_created INT, artist_id INT, medium VARCHAR(20));
What is the most common art medium in the 'art_pieces' table?
SELECT medium, COUNT(medium) as count FROM art_pieces GROUP BY medium ORDER BY count DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE members(id INT, join_date DATE); INSERT INTO members(id, join_date) VALUES (1,'2021-01-03'),(2,'2021-02-15'),(3,'2021-03-27'),(4,'2021-05-09'),(5,'2021-06-21'),(6,'2021-07-04'),(7,'2021-08-12'),(8,'2021-09-26'),(9,'2021-10-08'),(10,'2021-11-20'),(11,'2021-12-31'),(12,'2022-02-14');
How many new members joined each month in the past year?
SELECT MONTH(join_date) AS month, COUNT(*) AS members_joined FROM members WHERE join_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY month ORDER BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE Policyholders (PolicyholderID INT, Address VARCHAR(100), State VARCHAR(2)); CREATE TABLE HomeInsurance (PolicyholderID INT, HomeAddress VARCHAR(100), InsuranceType VARCHAR(50)); CREATE TABLE AutoInsurance (PolicyholderID INT, AutoAddress VARCHAR(100), InsuranceType VARCHAR(50));
Update the insurance type of policyholders who have both a home and auto insurance policy, and live in Florida to Comprehensive.
UPDATE HomeInsurance SET InsuranceType = 'Comprehensive' WHERE PolicyholderID IN (SELECT PolicyholderID FROM Policyholders WHERE State = 'FL'); UPDATE AutoInsurance SET InsuranceType = 'Comprehensive' WHERE PolicyholderID IN (SELECT PolicyholderID FROM Policyholders WHERE State = 'FL');
gretelai_synthetic_text_to_sql
CREATE TABLE investments (id INT, region VARCHAR(10), year INT, amount INT); INSERT INTO investments (id, region, year, amount) VALUES (1, 'rural', 2020, 80000), (2, 'urban', 2019, 110000), (3, 'suburban', 2021, 120000), (4, 'rural', 2019, 70000), (5, 'rural', 2021, 90000);
What is the average network infrastructure investment per year for the 'rural' region?
SELECT region, AVG(amount) FROM investments WHERE region = 'rural' GROUP BY region, year HAVING COUNT(*) > 1;
gretelai_synthetic_text_to_sql
CREATE TABLE mines (id INT, state VARCHAR(20), machine_type VARCHAR(20), coal_production FLOAT); INSERT INTO mines (id, state, machine_type, coal_production) VALUES (1, 'Queensland', 'TypeA', 120.5), (2, 'Queensland', 'TypeB', 150.3), (3, 'NewSouthWales', 'TypeA', 135.0);
What is the average coal production per machine in Queensland?
SELECT state, AVG(coal_production) as avg_production FROM mines WHERE state = 'Queensland' GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE claims (id INT, policy_number INT, claim_amount INT, issue_date DATE); INSERT INTO claims VALUES (1, 1234, 5000, '2021-01-01'); INSERT INTO claims VALUES (2, 5678, 7000, '2021-02-01'); INSERT INTO claims VALUES (3, 9012, 3000, '2020-01-01');
What is the minimum claim amount for policies issued in '2021'?
SELECT MIN(claim_amount) FROM claims WHERE EXTRACT(YEAR FROM issue_date) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (id INT, name VARCHAR(255), gender VARCHAR(6)); CREATE TABLE ArtWork (id INT, title VARCHAR(255), artist_id INT, price DECIMAL(10,2), type VARCHAR(255)); INSERT INTO Artists (id, name, gender) VALUES (1, 'ArtistX', 'Female'); INSERT INTO ArtWork (id, title, artist_id, price, type) VALUES (1, 'Painting1', 1, 12000, 'Painting');
What is the total value of paintings sold by female artists in Germany?
SELECT SUM(ArtWork.price) FROM ArtWork INNER JOIN Artists ON ArtWork.artist_id = Artists.id WHERE ArtWork.type = 'Painting' AND Artists.gender = 'Female' AND Artists.name LIKE '%Germany%';
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_projects (id INT, technology VARCHAR(50), location VARCHAR(50), capacity_mw FLOAT);
Find the total installed capacity (in MW) for each technology type in the 'renewable_projects' table
SELECT technology, SUM(capacity_mw) FROM renewable_projects GROUP BY technology;
gretelai_synthetic_text_to_sql
CREATE TABLE electric_buses (bus_id int, city varchar(20), avg_speed decimal(5,2)); INSERT INTO electric_buses (bus_id, city, avg_speed) VALUES (1, 'Los Angeles', 25.6), (2, 'Los Angeles', 27.3), (3, 'Los Angeles', 28.1);
What is the average speed of electric buses in the City of Los Angeles?
SELECT AVG(avg_speed) FROM electric_buses WHERE city = 'Los Angeles' AND bus_id <> 2;
gretelai_synthetic_text_to_sql
CREATE TABLE Precedents ( PrecedentID INT, CaseID INT, BillingAmount DECIMAL(10,2) ); INSERT INTO Precedents (PrecedentID, CaseID, BillingAmount) VALUES (1, 1, 500.00), (2, 1, 750.00), (3, 2, 800.00), (4, 3, 900.00), (5, 4, 1000.00), (6, 5, 400.00), (7, 6, 350.00), (8, 7, 1200.00), (9, 8, 1500.00), (10, 9, 1100.00);
What is the total billing amount by legal precedent?
SELECT PrecedentID, SUM(BillingAmount) AS Total_Billing_Amount FROM Precedents GROUP BY PrecedentID;
gretelai_synthetic_text_to_sql
CREATE TABLE electric_bikes (bike_id INT, ride_id INT, start_time TIMESTAMP, end_time TIMESTAMP, city VARCHAR(255));
What is the total number of electric bike rides in Berlin in the first half of 2022?
SELECT COUNT(*) FROM electric_bikes WHERE city = 'Berlin' AND start_time >= '2022-01-01 00:00:00' AND start_time < '2022-07-01 00:00:00';
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (id INT, name TEXT, year INT, sector TEXT); INSERT INTO volunteers (id, name, year, sector) VALUES (1, 'John Doe', 2019, 'disaster response'); INSERT INTO volunteers (id, name, year, sector) VALUES (2, 'Jane Doe', 2020, 'refugee support'); INSERT INTO volunteers (id, name, year, sector) VALUES (3, 'Jim Smith', 2020, 'disaster response');
What was the total number of volunteers in 2020?
SELECT COUNT(*) FROM volunteers WHERE year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE LaborCosts (CostID int, ProjectID int, LaborCost money, Date date, IsSustainable bit); CREATE TABLE Projects (ProjectID int, ProjectName varchar(255), State varchar(255), StartDate date, EndDate date);
What is the total labor cost for sustainable construction projects in Texas in the past month?
SELECT SUM(LaborCost) as TotalLaborCost FROM LaborCosts JOIN Projects ON LaborCosts.ProjectID = Projects.ProjectID WHERE State = 'Texas' AND Date >= DATEADD(month, -1, GETDATE()) AND IsSustainable = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE clicks (click_id INT, user_id INT, ad_id INT, click_date DATE);
What is the number of users who clicked on an ad promoting renewable energy in Germany, in the past week, and have never clicked on an ad before?
SELECT COUNT(DISTINCT c.user_id) FROM clicks c JOIN ads a ON c.ad_id = a.ad_id JOIN users u ON c.user_id = u.user_id WHERE a.content LIKE '%renewable energy%' AND c.click_date >= DATEADD(day, -7, GETDATE()) AND u.lifetime_clicks = 0;
gretelai_synthetic_text_to_sql
CREATE TABLE ingredients (id INT PRIMARY KEY, name VARCHAR(255), supplier_id INT); CREATE TABLE nutrition (ingredient_id INT, calories INT, protein INT, carbohydrates INT, fat INT);
Find the average protein content for ingredients from specific suppliers
SELECT AVG(nutrition.protein) FROM ingredients INNER JOIN nutrition ON ingredients.id = nutrition.ingredient_id WHERE ingredients.supplier_id IN (1, 2);
gretelai_synthetic_text_to_sql
CREATE TABLE electric_vehicles (id INT, city VARCHAR(20), type VARCHAR(20), daily_distance INT); INSERT INTO electric_vehicles VALUES (1, 'vancouver', 'sedan', 40); INSERT INTO electric_vehicles VALUES (2, 'vancouver', 'suv', 50); INSERT INTO electric_vehicles VALUES (3, 'toronto', 'truck', 60);
What is the minimum distance traveled by an electric vehicle in Vancouver?
SELECT MIN(daily_distance) FROM electric_vehicles WHERE city = 'vancouver';
gretelai_synthetic_text_to_sql
CREATE TABLE investment_strategies (id INT, strategy TEXT, risk_score FLOAT); INSERT INTO investment_strategies (id, strategy, risk_score) VALUES (1, 'Equity Investment', 6.5), (2, 'Real Estate Investment', 4.8), (3, 'Bond Investment', 3.2);
What is the lowest risk investment strategy and its associated risk score?
SELECT strategy, MIN(risk_score) FROM investment_strategies;
gretelai_synthetic_text_to_sql
CREATE TABLE animal_population (id INT, species VARCHAR(50), population INT);INSERT INTO animal_population (id, species, population) VALUES (1, 'Tiger', 250), (2, 'Elephant', 500);
What is the total number of animals in 'animal_population' table?
SELECT SUM(population) FROM animal_population;
gretelai_synthetic_text_to_sql
CREATE TABLE production_lines (id INT, name TEXT); INSERT INTO production_lines (id, name) VALUES (1, 'Line 1'), (2, 'Line 2'), (3, 'Line 3'); CREATE TABLE production (line_id INT, production_date DATE, units INT); INSERT INTO production (line_id, production_date, units) VALUES (1, '2022-05-01', 500), (1, '2022-05-02', 550), (1, '2022-05-03', 600), (2, '2022-05-01', 400), (2, '2022-05-02', 450), (2, '2022-05-03', 500), (3, '2022-05-01', 650), (3, '2022-05-02', 700), (3, '2022-05-03', 750);
What is the maximum number of units produced per day by each production line in the last month?
SELECT line_id, MAX(units) as max_units_per_day FROM production WHERE production_date BETWEEN DATE_SUB(NOW(), INTERVAL 1 MONTH) AND NOW() GROUP BY line_id;
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_offset_programs (project_type VARCHAR(255), carbon_offsets INT);
What is the total carbon offset of carbon offset programs in the 'carbon_offset_programs' table, grouped by project type?
SELECT project_type, SUM(carbon_offsets) FROM carbon_offset_programs GROUP BY project_type;
gretelai_synthetic_text_to_sql
CREATE TABLE ExcavationSites (SiteID int, Name varchar(50), Country varchar(50), StartDate date);
Insert a new excavation site into the ExcavationSites table
INSERT INTO ExcavationSites (SiteID, Name, Country, StartDate) VALUES (4, 'Site D', 'Peru', '2008-08-08');
gretelai_synthetic_text_to_sql
CREATE TABLE patient_outcomes (patient_id INT, condition_id INT, improvement_score INT, follow_up_date DATE); INSERT INTO patient_outcomes (patient_id, condition_id, improvement_score, follow_up_date) VALUES (13, 1, 12, '2022-04-01'); INSERT INTO patient_outcomes (patient_id, condition_id, improvement_score, follow_up_date) VALUES (14, 1, 15, '2022-05-01'); INSERT INTO patient_outcomes (patient_id, condition_id, improvement_score, follow_up_date) VALUES (15, 2, 8, '2022-06-01'); INSERT INTO patient_outcomes (patient_id, condition_id, improvement_score, follow_up_date) VALUES (16, 2, 10, '2022-07-01');
What is the 3-month rolling average of patient outcomes by condition?
SELECT condition_id, AVG(improvement_score) OVER (PARTITION BY condition_id ORDER BY follow_up_date ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) as rolling_avg FROM patient_outcomes;
gretelai_synthetic_text_to_sql
CREATE TABLE labor_costs_ie (worker_id INT, city VARCHAR(20), sector VARCHAR(20), hourly_wage DECIMAL(5,2), hours_worked INT, record_date DATE); INSERT INTO labor_costs_ie (worker_id, city, sector, hourly_wage, hours_worked, record_date) VALUES (3, 'Dublin', 'Plumbing', 40.5, 200, '2018-01-01'); INSERT INTO labor_costs_ie (worker_id, city, sector, hourly_wage, hours_worked, record_date) VALUES (4, 'Dublin', 'Plumbing', 41.8, 196, '2018-02-15');
Calculate the sum of labor costs for 'Plumbing' workers in 'Dublin' for the year 2018.
SELECT SUM(hourly_wage * hours_worked) FROM labor_costs_ie WHERE city = 'Dublin' AND sector = 'Plumbing' AND EXTRACT(YEAR FROM record_date) = 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE drivers (driver_id INT, name TEXT, origin TEXT);CREATE TABLE route_drivers (driver_id INT, route_id INT);CREATE TABLE routes (route_id INT, route_name TEXT); INSERT INTO drivers VALUES (1, 'John Doe', 'New York'); INSERT INTO drivers VALUES (2, 'Jane Smith', 'Los Angeles'); INSERT INTO route_drivers VALUES (1, 123); INSERT INTO route_drivers VALUES (2, 123); INSERT INTO routes VALUES (123, 'Route 123');
What are the names and origins of all drivers who have driven on route 123?
SELECT drivers.name, drivers.origin FROM drivers INNER JOIN route_drivers ON drivers.driver_id = route_drivers.driver_id INNER JOIN routes ON route_drivers.route_id = routes.route_id WHERE routes.route_name = 'Route 123';
gretelai_synthetic_text_to_sql
CREATE TABLE Inspections (id INT, restaurant_id INT, inspection_date DATE, score INT, country VARCHAR); INSERT INTO Inspections (id, restaurant_id, inspection_date, score, country) VALUES (1, 1, '2021-01-01', 95, 'US'); INSERT INTO Inspections (id, restaurant_id, inspection_date, score, country) VALUES (2, 2, '2021-01-02', 85, 'Italy');
What is the average score for food safety inspections in the US?
SELECT AVG(score) FROM Inspections WHERE country = 'US';
gretelai_synthetic_text_to_sql
CREATE TABLE Patients (PatientID INT, MentalHealth TEXT, HospitalVisits INT, State TEXT); INSERT INTO Patients (PatientID, MentalHealth, HospitalVisits, State) VALUES (1, 'Depression', 5, 'Texas');
What is the maximum number of hospital visits for patients with mental health issues in Texas?
SELECT MAX(HospitalVisits) FROM Patients WHERE MentalHealth IS NOT NULL AND State = 'Texas';
gretelai_synthetic_text_to_sql
CREATE TABLE Brands (id INT, name VARCHAR(255)); INSERT INTO Brands (id, name) VALUES (1, 'Brand A'), (2, 'Brand B'), (3, 'Brand C'), (4, 'Brand D'); CREATE TABLE Vegan_Leather_Sales (id INT, brand_id INT, quarter INT, year INT, units INT); INSERT INTO Vegan_Leather_Sales (id, brand_id, quarter, year, units) VALUES (1, 1, 2, 2021, 150), (2, 2, 2, 2021, 200), (3, 3, 2, 2021, 250), (4, 4, 2, 2021, 300);
How many units of vegan leather garments were sold by each brand in Q2 of 2021?
SELECT b.name, SUM(v.units) FROM Vegan_Leather_Sales v JOIN Brands b ON v.brand_id = b.id WHERE v.quarter = 2 AND v.year = 2021 GROUP BY b.name;
gretelai_synthetic_text_to_sql
CREATE TABLE Movies (id INT, title VARCHAR(100), release_year INT, rating FLOAT, language VARCHAR(20));
What's the average rating of non-English movies released in 2010 or later?
SELECT AVG(rating) FROM Movies WHERE language <> 'English' AND release_year >= 2010;
gretelai_synthetic_text_to_sql