context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE sizes (country VARCHAR(10), product VARCHAR(20), size DECIMAL(3,2)); INSERT INTO sizes (country, product, size) VALUES ('USA', 'shirt', 42.5), ('USA', 'pants', 34.0), ('UK', 'shirt', 46.0), ('UK', 'pants', 38.0);
What is the average size of clothing products sold to customers in the USA and UK?
SELECT AVG(size) FROM sizes WHERE country IN ('USA', 'UK');
gretelai_synthetic_text_to_sql
CREATE TABLE matches (match_id INT, home_team_id INT, away_team_id INT, home_team_score INT, away_team_score INT, match_date DATE);
What is the highest scoring match in the current season?
SELECT home_team_id, away_team_id, home_team_score + away_team_score as total_score FROM matches WHERE match_date >= DATEADD(year, -1, GETDATE()) ORDER BY total_score DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE player_scores (player_id INT, total_score INT);
Delete player records with a total score less than 1000 from the 'player_scores' table
DELETE FROM player_scores WHERE total_score < 1000;
gretelai_synthetic_text_to_sql
CREATE TABLE mental_health_visits (id INT, age_group VARCHAR(255), year INT, visits INT); INSERT INTO mental_health_visits VALUES (1, '0-10', 2021, 5), (2, '11-20', 2021, 10), (3, '21-30', 2021, 15);
What is the number of mental health visits by age group in 2021?
SELECT age_group, COUNT(*) AS visits FROM mental_health_visits WHERE year = 2021 GROUP BY age_group;
gretelai_synthetic_text_to_sql
CREATE TABLE accommodation_types (type_id INT, type_name VARCHAR(255));CREATE TABLE accommodations (accommodation_id INT, accommodation_name VARCHAR(255), type_id INT);
What is the number of disability accommodations provided by each accommodation type?
SELECT at.type_name, COUNT(a.accommodation_id) as total_accommodations FROM accommodation_types at INNER JOIN accommodations a ON at.type_id = a.type_id GROUP BY at.type_name;
gretelai_synthetic_text_to_sql
CREATE TABLE cargo_movements (id INT PRIMARY KEY, vessel_id INT, cargo_type VARCHAR(255), quantity INT, loading_port VARCHAR(255), unloading_port VARCHAR(255), movement_date DATE);
Insert records into the cargo_movements table for the vessel with an id of 3, with the following data: (cargo_type, quantity, loading_port, unloading_port, movement_date) = ('Coal', 10000, 'Sydney', 'Melbourne', '2021-01-01')
INSERT INTO cargo_movements (vessel_id, cargo_type, quantity, loading_port, unloading_port, movement_date) VALUES (3, 'Coal', 10000, 'Sydney', 'Melbourne', '2021-01-01');
gretelai_synthetic_text_to_sql
CREATE TABLE EnvironmentalImpact (id INT, facility VARCHAR(255), year INT, impact_score FLOAT); INSERT INTO EnvironmentalImpact (id, facility, year, impact_score) VALUES (1, 'facility A', 2022, 80), (2, 'facility B', 2022, 90);
Which facility has the highest environmental impact in 2022?
SELECT facility, MAX(impact_score) FROM EnvironmentalImpact WHERE year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE indigenous_communities (community_name VARCHAR(50), region VARCHAR(50), year INT, population INT); INSERT INTO indigenous_communities (community_name, region, year, population) VALUES ('Inuit', 'Arctic North America', 2000, 50000), ('Inuit', 'Arctic North America', 2001, 50500);
How many indigenous communities are in each Arctic region and what is their population trend since 2000?
SELECT i.region, i.community_name, i.year, i.population, LAG(i.population) OVER (PARTITION BY i.region, i.community_name ORDER BY i.year) as prev_year_population FROM indigenous_communities i;
gretelai_synthetic_text_to_sql
CREATE TABLE graduate_students (student_id INT, name TEXT, gpa DECIMAL(3,2), department TEXT);
How many graduate students are enrolled in each department?
SELECT gs.department, COUNT(gs.student_id) FROM graduate_students gs GROUP BY gs.department;
gretelai_synthetic_text_to_sql
CREATE TABLE shark_attacks (id INT PRIMARY KEY, country VARCHAR(255), year INT, type VARCHAR(255)); INSERT INTO shark_attacks (id, country, year, type) VALUES (1, 'South Africa', 2018, 'Attack'), (2, 'Australia', 2019, 'Attack'); CREATE TABLE research_expeditions (id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255), year INT, type VARCHAR(255)); INSERT INTO research_expeditions (id, name, country, year, type) VALUES (1, 'Deep Sea Dive', 'South Africa', 2018, 'Research');
What are the types of research expeditions that have taken place in the same countries as major shark attacks?
SELECT re.name, re.type FROM research_expeditions re INNER JOIN shark_attacks sa ON re.country = sa.country WHERE sa.type = 'Attack';
gretelai_synthetic_text_to_sql
CREATE TABLE audience (id INT, age INT, gender VARCHAR(10));
Insert a new record into the 'audience' table with the age 35 and gender 'Female'
INSERT INTO audience (age, gender) VALUES (35, 'Female');
gretelai_synthetic_text_to_sql
CREATE TABLE water_consumption (city VARCHAR(50), consumption FLOAT, month INT, year INT); INSERT INTO water_consumption (city, consumption, month, year) VALUES ('San Francisco', 200.5, 7, 2021), ('San Francisco', 210.3, 8, 2021), ('Los Angeles', 190.2, 7, 2021);
Find the top 2 cities with the highest water consumption in July 2021.
SELECT city, consumption FROM (SELECT city, consumption, ROW_NUMBER() OVER (ORDER BY consumption DESC) rn FROM water_consumption WHERE month = 7) tmp WHERE rn <= 2;
gretelai_synthetic_text_to_sql
CREATE VIEW circular_economy_initiatives AS SELECT * FROM waste_generation_metrics WHERE generation_metric < 100;
List all circular economy initiatives
SELECT * FROM circular_economy_initiatives;
gretelai_synthetic_text_to_sql
CREATE TABLE green_buildings (id INT, state VARCHAR(20), construction_year INT, type VARCHAR(20)); INSERT INTO green_buildings (id, state, construction_year, type) VALUES (1, 'California', 2014, 'residential'), (2, 'California', 2012, 'commercial'), (3, 'Oregon', 2016, 'residential');
What is the average number of green buildings per state in the US, constructed before 2015?
SELECT AVG(cnt) FROM (SELECT COUNT(*) AS cnt FROM green_buildings WHERE state = state_name AND construction_year < 2015 GROUP BY state) AS subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE platforms (platform_id INT, platform VARCHAR(50)); INSERT INTO platforms VALUES (1, 'Spotify'), (2, 'Apple Music'), (3, 'Tidal'); CREATE TABLE song_platforms (song_id INT, platform_id INT); INSERT INTO song_platforms VALUES (1, 1), (1, 2), (2, 2), (3, 3); CREATE TABLE songs (song_id INT, song VARCHAR(50), artist VARCHAR(50)); INSERT INTO songs VALUES (1, 'Blackbird', 'The Beatles'), (2, 'Bohemian Rhapsody', 'Queen'), (3, 'So What', 'Miles Davis');
Find the number of unique artists who have released songs on 'Spotify' and 'Apple Music'.
SELECT COUNT(DISTINCT s.artist) as artist_count FROM songs s JOIN song_platforms sp ON s.song_id = sp.song_id JOIN platforms p ON sp.platform_id = p.platform_id WHERE p.platform IN ('Spotify', 'Apple Music');
gretelai_synthetic_text_to_sql
CREATE TABLE funding (source VARCHAR(255), amount INT); INSERT INTO funding (source, amount) SELECT * FROM csv_file('funding.csv') AS t(source VARCHAR(255), amount INT);
Delete all records from the 'funding' table
DELETE FROM funding;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas (id INT, name TEXT); CREATE TABLE ocean_acidification (id INT, area_id INT, level FLOAT); INSERT INTO marine_protected_areas (id, name) VALUES (1, 'Galapagos Marine Reserve'), (2, 'Great Barrier Reef Marine Park'); INSERT INTO ocean_acidification (id, area_id, level) VALUES (1, 1, 7.5), (2, 1, 7.8), (3, 2, 8.0), (4, 2, 8.2);
Which marine protected areas have the highest ocean acidification levels?
SELECT marine_protected_areas.name, MAX(ocean_acidification.level) FROM marine_protected_areas INNER JOIN ocean_acidification ON marine_protected_areas.id = ocean_acidification.area_id GROUP BY marine_protected_areas.name;
gretelai_synthetic_text_to_sql
CREATE TABLE production_data (year INT, element VARCHAR(10), quantity INT); INSERT INTO production_data (year, element, quantity) VALUES (2018, 'Erbium', 15), (2019, 'Erbium', 17), (2020, 'Erbium', 20), (2021, 'Erbium', 25);
What is the maximum production of Erbium in a single year?
SELECT MAX(quantity) FROM production_data WHERE element = 'Erbium';
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species_taxonomy (species_id INTEGER, species_name VARCHAR(255), class VARCHAR(50));
What is the total number of marine species in each taxonomic class?
SELECT class, COUNT(species_id) FROM marine_species_taxonomy GROUP BY class;
gretelai_synthetic_text_to_sql
CREATE TABLE articles (id INT, title TEXT, category TEXT, published_at DATETIME, word_count INT);
What is the earliest date an article about 'corruption' was published, for articles that have at least 1000 words?
SELECT MIN(published_at) FROM articles WHERE articles.category = 'corruption' AND articles.word_count >= 1000;
gretelai_synthetic_text_to_sql
CREATE TABLE hotel_reviews (hotel_id INT, review_date DATE, review_score INT); CREATE VIEW hotel_review_summary AS SELECT hotel_id, COUNT(*), AVG(review_score) FROM hotel_reviews GROUP BY hotel_id;
What is the average review score for hotel_id 789 from the "hotel_review_summary" view?
SELECT avg_review_score FROM hotel_review_summary WHERE hotel_id = 789;
gretelai_synthetic_text_to_sql
CREATE TABLE project (id INT, name TEXT, country TEXT, type TEXT); INSERT INTO project (id, name, country, type) VALUES (7, 'Hanover Wind', 'France', 'Wind'), (8, 'Marseille Solar', 'France', 'Solar');
Find the number of renewable energy projects in France
SELECT COUNT(*) FROM project WHERE country = 'France';
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (customer_id INT, transaction_amount DECIMAL(10,2), country VARCHAR(50)); INSERT INTO transactions (customer_id, transaction_amount, country) VALUES (1, 120.50, 'Canada'), (2, 75.30, 'Germany'), (3, 150.00, 'Canada'), (4, 200.00, 'Germany');
What is the average transaction amount for all customers from Canada and Germany?
SELECT AVG(transaction_amount) FROM transactions WHERE country IN ('Canada', 'Germany');
gretelai_synthetic_text_to_sql
CREATE TABLE paris_metro_entries (id INT, station_name VARCHAR(255), entries INT); INSERT INTO paris_metro_entries (id, station_name, entries) VALUES (1, 'Station 1', 120000), (2, 'Station 2', 80000);
Which metro stations in Paris have had more than 100,000 entries in the past week?
SELECT station_name FROM paris_metro_entries WHERE entries > 100000 AND entries_date >= DATEADD(week, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE Publications (ID INT, Author VARCHAR(50), Journal VARCHAR(50), Year INT); INSERT INTO Publications (ID, Author, Journal, Year) VALUES (1, 'John Doe', 'Journal of Computer Science', 2020), (2, 'Jane Smith', 'Journal of Mathematics', 2019);
Which author has the highest number of publications in the 'Journal of Computer Science'?
SELECT Author, COUNT(*) AS PublicationCount FROM Publications WHERE Journal = 'Journal of Computer Science' GROUP BY Author ORDER BY PublicationCount DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE mining_sites (site_id INT, job_title VARCHAR(20), productivity FLOAT);
What is the average productivity of workers in the 'mining_sites' table, grouped by their 'job_title'?
SELECT job_title, AVG(productivity) as avg_productivity FROM mining_sites GROUP BY job_title;
gretelai_synthetic_text_to_sql
CREATE TABLE patients (id INT, name VARCHAR(50), age INT, diagnosis VARCHAR(50)); INSERT INTO patients (id, name, age, diagnosis) VALUES (1, 'John Doe', 68, 'Heart Disease'); INSERT INTO patients (id, name, age, diagnosis) VALUES (2, 'Jane Smith', 55, 'Hypertension'); INSERT INTO patients (id, name, age, diagnosis) VALUES (3, 'Bob Johnson', 70, 'Heart Disease'); INSERT INTO patients (id, name, age, diagnosis) VALUES (4, 'Alice Williams', 66, 'Heart Disease'); CREATE TABLE county (name VARCHAR(50), population INT); INSERT INTO county (name, population) VALUES ('Elmfield', 27000);
What is the number of patients diagnosed with heart disease in the rural county of "Elmfield" who are also over the age of 65?
SELECT COUNT(*) FROM patients WHERE diagnosis = 'Heart Disease' AND age > 65 AND (SELECT name FROM county WHERE population = (SELECT population FROM county WHERE name = 'Elmfield')) = 'Elmfield';
gretelai_synthetic_text_to_sql
CREATE TABLE departments (id INT, name VARCHAR(20)); CREATE TABLE workers (id INT, department INT, salary FLOAT); INSERT INTO departments (id, name) VALUES (1, 'Engineering'), (2, 'Marketing'), (3, 'Human Resources'); INSERT INTO workers (id, department, salary) VALUES (1, 1, 70000), (2, 1, 80000), (3, 2, 60000), (4, 2, 65000), (5, 3, 75000);
Get the number of workers and total salary for each department
SELECT d.name, COUNT(w.id) AS num_workers, SUM(w.salary) AS total_salary FROM departments d JOIN workers w ON d.id = w.department GROUP BY d.name;
gretelai_synthetic_text_to_sql
CREATE TABLE Genres (Genre VARCHAR(20)); CREATE TABLE Albums (AlbumID INT, Genre VARCHAR(20), ReleaseYear INT); INSERT INTO Genres VALUES ('Rock'), ('Pop'), ('Jazz'), ('Blues'), ('Folk'); INSERT INTO Albums VALUES (1, 'Rock', 2022), (2, 'Jazz', 2020), (3, 'Blues', 2022), (4, 'Folk', 2022), (5, 'Pop', 2022), (6, 'Rock', 2022), (7, 'Jazz', 2021), (8, 'Blues', 2022), (9, 'Folk', 2022), (10, 'Pop', 2022), (11, 'Rock', 2022);
List the genres that have at least 3 albums released in 2022.
SELECT Genre FROM Albums WHERE ReleaseYear = 2022 GROUP BY Genre HAVING COUNT(*) >= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE refugee_support.shelters (id INT, name VARCHAR(50), capacity INT, location VARCHAR(50));
What is the total number of shelters for the 'refugee_support' schema?
SELECT COUNT(*) FROM refugee_support.shelters;
gretelai_synthetic_text_to_sql
CREATE TABLE incidents (id INT, country VARCHAR(255), region VARCHAR(255), risk_score INT, date DATE); INSERT INTO incidents (id, country, region, risk_score, date) VALUES (1, 'Japan', 'APAC', 7, '2021-01-01'); INSERT INTO incidents (id, country, region, risk_score, date) VALUES (2, 'China', 'APAC', 5, '2021-01-02');
Calculate the average risk score for each country in the APAC region in the past year
SELECT region, AVG(risk_score) as avg_risk_score FROM incidents WHERE region = 'APAC' AND date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE MuseumTrends (id INT, region VARCHAR(20), trend VARCHAR(50)); INSERT INTO MuseumTrends (id, region, trend) VALUES (1, 'South America', 'Interactive Exhibits'), (2, 'South America', 'Digital Preservation'), (3, 'Europe', 'Virtual Tours');
List all digital museum trends in South America.
SELECT trend FROM MuseumTrends WHERE region = 'South America';
gretelai_synthetic_text_to_sql
CREATE TABLE cases (id INT, open_date DATE); INSERT INTO cases (id, open_date) VALUES (1, '2022-01-05'), (2, '2022-07-10'), (3, '2022-07-20'), (4, '2022-12-31');
How many cases were opened in the month of July in the year 2022?
SELECT COUNT(*) FROM cases WHERE MONTH(open_date) = 7 AND YEAR(open_date) = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists smart_contracts (id INT PRIMARY KEY, name TEXT, language TEXT, version TEXT); INSERT INTO smart_contracts (id, name, language, version) VALUES (1, 'CryptoKitties', 'Solidity', '0.4.24'), (2, 'UniswapV2', 'Vyper', '0.2.6'), (3, 'Gnosis', 'Solidity', '0.5.12');
Update the version of smart contracts written in Vyper to the next minor version.
UPDATE smart_contracts SET version = CONCAT(SUBSTRING_INDEX(version, '.', 1), '.', SUBSTRING_INDEX(version, '.', 2) + 1) WHERE language = 'Vyper';
gretelai_synthetic_text_to_sql
CREATE TABLE economic_diversification (id INT, initiative_name VARCHAR(50), location VARCHAR(50), implementation_date DATE); INSERT INTO economic_diversification (id, initiative_name, location, implementation_date) VALUES (1, 'Eco-tourism', 'Jamaica', '2012-04-02');
List the economic diversification initiatives in the 'economic_diversification' table that were implemented between 2010 and 2015.
SELECT initiative_name, location FROM economic_diversification WHERE implementation_date BETWEEN '2010-01-01' AND '2015-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE Brands (brand_id INT, brand_name VARCHAR(50)); CREATE TABLE Brand_Materials (brand_id INT, material_id INT, quantity INT); INSERT INTO Brands (brand_id, brand_name) VALUES (1, 'EcoWear'), (2, 'GreenTrends'), (3, 'SustainableStyle'); INSERT INTO Brand_Materials (brand_id, material_id, quantity) VALUES (1, 1, 500), (1, 2, 300), (2, 1, 700), (2, 2, 400), (3, 1, 800), (3, 2, 600);
What is the total quantity of sustainable material usage by each brand?
SELECT b.brand_name, SUM(bm.quantity) FROM Brands b INNER JOIN Brand_Materials bm ON b.brand_id = bm.brand_id GROUP BY b.brand_name;
gretelai_synthetic_text_to_sql
CREATE TABLE Crimes (crime_id INT, crime_type VARCHAR(10), neighborhood VARCHAR(20), date DATE); INSERT INTO Crimes VALUES (1, 'Burglary', 'Parkside', '2022-01-01'), (2, 'Theft', 'Parkside', '2022-01-03'), (3, 'Burglary', 'Downtown', '2022-01-05'), (4, 'Theft', 'Downtown', '2022-01-07'), (5, 'Assault', 'Parkside', '2022-01-09'), (6, 'Assault', 'Downtown', '2022-01-11');
List the unique neighborhoods where both 'Burglary' and 'Theft' occurred in the last month, excluding neighborhoods with fewer than 2 total crimes.
SELECT neighborhood FROM Crimes WHERE crime_type IN ('Burglary', 'Theft') AND date >= DATEADD(month, -1, CURRENT_TIMESTAMP) GROUP BY neighborhood HAVING COUNT(DISTINCT crime_type) = 2 AND COUNT(*) >= 2;
gretelai_synthetic_text_to_sql
CREATE TABLE mines (id INT, name TEXT, location TEXT, production_volume INT, product TEXT, year INT); INSERT INTO mines (id, name, location, production_volume, product, year) VALUES (1, 'Golden Mine', 'Canada', 12000, 'Gold', 2020); INSERT INTO mines (id, name, location, production_volume, product, year) VALUES (2, 'Yukon Mine', 'Canada', 15000, 'Gold', 2020);
What is the average production volume of gold per mine in Canada in 2020?'
SELECT AVG(production_volume) FROM mines WHERE location = 'Canada' AND product = 'Gold' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name VARCHAR(50), price DECIMAL(5,2), category VARCHAR(50)); INSERT INTO products (product_id, product_name, price, category) VALUES (1, 'T-Shirt', 20.99, 'clothing'), (2, 'Jeans', 55.99, 'clothing'), (3, 'Sneakers', 79.99, 'footwear'), (4, 'Backpack', 49.99, 'accessories');
What is the minimum price of products in the 'accessories' category?
SELECT MIN(price) FROM products WHERE category = 'accessories';
gretelai_synthetic_text_to_sql
CREATE TABLE EducationMeetings (Location VARCHAR(50), MeetingType VARCHAR(50), NoOfAttendees INT, MeetingDate DATE); INSERT INTO EducationMeetings (Location, MeetingType, NoOfAttendees, MeetingDate) VALUES ('India', 'Education', 120, '2021-02-01'), ('India', 'Education', 80, '2021-03-15'), ('India', 'Education', 150, '2021-01-10');
How many public 'Education' meetings were held in India in 2021, with at least 100 attendees?
SELECT COUNT(*) FROM EducationMeetings WHERE MeetingType = 'Education' AND Location = 'India' AND MeetingDate >= '2021-01-01' AND NoOfAttendees >= 100;
gretelai_synthetic_text_to_sql
CREATE TABLE union_memberships (id INT, name VARCHAR(50), sector VARCHAR(10), joined_date DATE); INSERT INTO union_memberships (id, name, sector, joined_date) VALUES (1, 'John Doe', 'Public', '2020-01-01'); INSERT INTO union_memberships (id, name, sector, joined_date) VALUES (2, 'Jane Smith', 'Private', '2019-06-15'); INSERT INTO union_memberships (id, name, sector, joined_date) VALUES (3, 'Maria Rodriguez', 'Private', '2018-12-21'); INSERT INTO union_memberships (id, name, sector, joined_date) VALUES (4, 'David Kim', 'Public', '2019-04-10'); INSERT INTO union_memberships (id, name, sector, joined_date) VALUES (5, 'Alex Brown', 'Public', '2019-07-25');
What is the difference in union membership between public and private sectors in the US?
SELECT COUNT(CASE WHEN sector = 'Public' THEN 1 END) - COUNT(CASE WHEN sector = 'Private' THEN 1 END) FROM union_memberships;
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (VolunteerID INT, Name TEXT); INSERT INTO Volunteers (VolunteerID, Name) VALUES (1, 'Jamal Smith'), (2, 'Sophia Rodriguez'); CREATE TABLE Donors (DonorID INT, VolunteerID INT, Amount DECIMAL(10, 2)); INSERT INTO Donors (DonorID, VolunteerID, Amount) VALUES (1, 1, 500.00), (2, 1, 300.00), (3, 2, 200.00);
What's the total number of volunteers and their respective donation amounts?
SELECT Volunteers.Name, SUM(Donors.Amount) AS TotalDonationAmount FROM Volunteers INNER JOIN Donors ON Volunteers.VolunteerID = Donors.VolunteerID GROUP BY Volunteers.Name;
gretelai_synthetic_text_to_sql
CREATE TABLE space_debris_monitoring (id INT, object_name VARCHAR(50), launch_country VARCHAR(50), launch_date DATE, latitude FLOAT, longitude FLOAT);
Insert a new space debris record into the "space_debris_monitoring" table for an object launched by Brazil in 2010.
INSERT INTO space_debris_monitoring (object_name, launch_country, launch_date, latitude, longitude) VALUES ('Debris_2010_Brazil', 'Brazil', '2010-01-01', -15.123456, -50.123456);
gretelai_synthetic_text_to_sql
CREATE TABLE Peacekeeping_Operations (Operation_ID INT PRIMARY KEY, Year INT, Leader VARCHAR(100));
How many peacekeeping operations were led by each leader in 2022?
SELECT Leader, COUNT(*) FROM Peacekeeping_Operations WHERE Year = 2022 GROUP BY Leader;
gretelai_synthetic_text_to_sql
CREATE TABLE hospitals (id INT, name TEXT, location TEXT, workers INT); INSERT INTO hospitals (id, name, location, workers) VALUES (1, 'Hospital A', 'urban', 50), (2, 'Hospital B', 'urban', 75), (3, 'Hospital C', 'rural', 60), (4, 'Hospital D', 'rural', 80), (5, 'Hospital E', 'suburban', 65), (6, 'Hospital F', 'suburban', 70);
What is the average number of healthcare workers per hospital in urban areas?
SELECT AVG(workers) FROM hospitals WHERE location = 'urban';
gretelai_synthetic_text_to_sql
CREATE TABLE donation (donation_id INT, donor_id INT, donation_date DATE, amount DECIMAL(10,2)); INSERT INTO donation (donation_id, donor_id, donation_date, amount) VALUES (1, 1, '2022-01-01', 50.00), (2, 1, '2022-01-02', 100.00), (3, 2, '2022-02-01', 75.00);
What is the maximum donation amount per donor for the year 2022?
SELECT donor_id, MAX(amount) FROM donation WHERE donation_date >= '2022-01-01' AND donation_date < '2023-01-01' GROUP BY donor_id;
gretelai_synthetic_text_to_sql
CREATE TABLE spacecrafts (manufacturer VARCHAR(255), mass FLOAT); INSERT INTO spacecrafts (manufacturer, mass) VALUES ('SpaceCorp', 10000); INSERT INTO spacecrafts (manufacturer, mass) VALUES ('AstroCorp', 18000); INSERT INTO spacecrafts (manufacturer, mass) VALUES ('Galactic Inc', 15000);
What is the average mass of spacecrafts manufactured by each company?
SELECT manufacturer, AVG(mass) FROM spacecrafts GROUP BY manufacturer;
gretelai_synthetic_text_to_sql
CREATE TABLE drought_impact_scores (id INT, region VARCHAR(50), year INT, score INT); INSERT INTO drought_impact_scores (id, region, year, score) VALUES (1, 'Region A', 2021, 70); INSERT INTO drought_impact_scores (id, region, year, score) VALUES (2, 'Region B', 2021, 80);
What is the average drought impact score for each region in 2021?
SELECT d.region, AVG(d.score) FROM drought_impact_scores d WHERE d.year = 2021 GROUP BY d.region;
gretelai_synthetic_text_to_sql
CREATE TABLE ingredients (ingredient_id INT, product_id INT, region VARCHAR(50)); INSERT INTO ingredients VALUES (1, 1, 'Amazon Rainforest'), (2, 2, 'Canada'), (3, 3, 'Mexico'), (4, 4, 'Amazon Rainforest'), (5, 5, 'Amazon Rainforest'); CREATE TABLE sales (product_id INT, sales_amount DECIMAL(5,2)); INSERT INTO sales VALUES (1, 10.99), (2, 15.49), (3, 12.35), (4, 18.99), (5, 14.55);
What is the total sales of products with ingredients sourced from the Amazon rainforest?
SELECT SUM(s.sales_amount) FROM sales s JOIN ingredients i ON s.product_id = i.product_id WHERE i.region = 'Amazon Rainforest';
gretelai_synthetic_text_to_sql
CREATE TABLE Dysprosium_Production (id INT, year INT, country VARCHAR(20), production_volume INT);
How many Tb dysprosium were produced in China in 2020?
SELECT SUM(production_volume) FROM Dysprosium_Production WHERE country = 'China' AND element = 'Tb' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE concert_tours (concert_id INT, concert_name TEXT, artist_id INT, location TEXT, date DATE, price DECIMAL(5,2)); CREATE TABLE ticket_sales (sale_id INT, concert_id INT, quantity INT, price DECIMAL(5,2));
What is the total revenue for concert tickets sold for all concerts in the 'concert_tours' table?
SELECT SUM(ticket_sales.quantity * concert_tours.price) FROM concert_tours JOIN ticket_sales ON concert_tours.concert_id = ticket_sales.concert_id;
gretelai_synthetic_text_to_sql
CREATE TABLE all_items (id INT, item_name VARCHAR(255), category VARCHAR(255), is_organic BOOLEAN, quantity INT, unit_price DECIMAL(5,2)); INSERT INTO all_items (id, item_name, category, is_organic, quantity, unit_price) VALUES (1, 'Quinoa', 'Grains', true, 50, 3.99), (2, 'Chicken', 'Proteins', false, 100, 1.99), (3, 'Almond Milk', 'Dairy Alternatives', true, 40, 2.59), (4, 'Rice', 'Grains', false, 75, 0.99), (5, 'Potatoes', 'Starchy Vegetables', false, 60, 0.79), (6, 'Tofu', 'Proteins', true, 30, 2.99);
What is the total inventory value for all items?
SELECT SUM(quantity * unit_price) FROM all_items;
gretelai_synthetic_text_to_sql
CREATE TABLE fabrics (id INT, name VARCHAR(255), sustainability_rating FLOAT); INSERT INTO fabrics (id, name, sustainability_rating) VALUES (1, 'Organic Cotton', 4.2), (2, 'Recycled Polyester', 3.8), (3, 'Hemp', 4.5);
Update the rating of 'Organic Cotton' to 4.3 in the fabrics table.
UPDATE fabrics SET sustainability_rating = 4.3 WHERE name = 'Organic Cotton';
gretelai_synthetic_text_to_sql
CREATE TABLE climate_finance_provider (bank VARCHAR(50), year INT, amount FLOAT); INSERT INTO climate_finance_provider VALUES ('World Bank', 2010, 1000000000);
What is the total amount of climate finance provided by each multilateral development bank?
SELECT bank, SUM(amount) AS total_climate_finance FROM climate_finance_provider GROUP BY bank
gretelai_synthetic_text_to_sql
CREATE TABLE factory_scores(factory_name VARCHAR(20), country VARCHAR(20), sustainability_score INT); INSERT INTO factory_scores VALUES('Factory C', 'Germany', 80);
List the 'Sustainability Score' for factories in 'Germany'.
SELECT sustainability_score FROM factory_scores WHERE country = 'Germany';
gretelai_synthetic_text_to_sql
CREATE TABLE PlantSafety (id INT, plant_location VARCHAR(50), incident_date DATE); INSERT INTO PlantSafety (id, plant_location, incident_date) VALUES (1, 'Texas', '2020-01-15'), (2, 'California', '2019-12-21'), (3, 'Texas', '2020-06-05');
How many safety incidents were reported in the chemical manufacturing plant located in Texas in 2020?
SELECT COUNT(*) FROM PlantSafety WHERE plant_location = 'Texas' AND EXTRACT(YEAR FROM incident_date) = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE smart_contracts (contract_id INT, creation_date DATE); INSERT INTO smart_contracts (contract_id, creation_date) VALUES (1, '2021-01-01'), (2, '2021-01-15'), (3, '2021-02-03'), (4, '2021-03-07'), (5, '2021-03-20');
How many smart contracts were created per month in the 'smart_contracts' table?
SELECT MONTH(creation_date) AS Month, COUNT(contract_id) AS NumberOfContracts FROM smart_contracts GROUP BY Month;
gretelai_synthetic_text_to_sql
CREATE TABLE department_data (id INT, department VARCHAR(255), salary DECIMAL(10, 2)); INSERT INTO department_data (id, department, salary) VALUES (1, 'HR', 70000), (2, 'IT', 80000), (3, 'Finance', 65000), (4, 'HR', 75000), (5, 'IT', 85000), (6, 'Finance', 60000);
Identify the top 3 departments with the highest average salary.
SELECT department, AVG(salary) as avg_salary FROM department_data GROUP BY department ORDER BY avg_salary DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE OrganicCottonClothing (item VARCHAR(50), production_cost DECIMAL(5,2)); INSERT INTO OrganicCottonClothing VALUES ('T-Shirt', 15.99), ('Pants', 34.99), ('Dress', 56.99);
What is the average production cost of organic cotton clothing items?
SELECT AVG(production_cost) FROM OrganicCottonClothing;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists biotech;CREATE TABLE if not exists biotech.startups(id INT, name VARCHAR(50), country VARCHAR(50), funding DECIMAL(10,2));INSERT INTO biotech.startups(id, name, country, funding) VALUES (1, 'StartupA', 'US', 1500000.00), (2, 'StartupB', 'Canada', 2000000.00), (3, 'StartupC', 'Mexico', 500000.00);
What is the average funding amount per biotech startup by country?
SELECT country, AVG(funding) avg_funding FROM biotech.startups GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE explainable_ai_papers (paper_id INT, paper_title VARCHAR(255), author_name VARCHAR(255), num_citations INT); INSERT INTO explainable_ai_papers (paper_id, paper_title, author_name, num_citations) VALUES ('1', 'Explainable AI: A Survey', 'Jane Smith', '200');
What is the rank of each explainable AI paper based on the number of citations?
SELECT paper_id, paper_title, author_name, num_citations, RANK() OVER (ORDER BY num_citations DESC) as citation_rank FROM explainable_ai_papers;
gretelai_synthetic_text_to_sql
CREATE TABLE art_pieces (museum VARCHAR(255), quantity INT, price DECIMAL(5,2)); INSERT INTO art_pieces (museum, quantity, price) VALUES ('Museum of Modern Art, NY', 2500, 50.00), ('Guggenheim Museum, NY', 1500, 100.00);
What is the total revenue of all art pieces in the Museum of Modern Art in NY?
SELECT SUM(quantity * price) FROM art_pieces WHERE museum = 'Museum of Modern Art, NY';
gretelai_synthetic_text_to_sql
CREATE TABLE european_startups (id INT, name VARCHAR(50), funding_amount DECIMAL(10, 2));
Display the names and funding amounts of startups based in 'Europe'.
SELECT name, funding_amount FROM european_startups WHERE location = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE research_grants (grant_id INT, title VARCHAR(50), amount DECIMAL(10, 2), year INT, faculty_id INT, department VARCHAR(50)); INSERT INTO research_grants VALUES (1, 'Grant1', 50000, 2019, 456, 'Engineering'); CREATE TABLE faculty (faculty_id INT, name VARCHAR(50), department VARCHAR(50), gender VARCHAR(10)); INSERT INTO faculty VALUES (456, 'John Doe', 'Engineering', 'Male');
What is the total grant amount awarded to faculty members in the Engineering department in the last 5 years?
SELECT SUM(amount) FROM research_grants rg JOIN faculty f ON rg.faculty_id = f.faculty_id WHERE f.department = 'Engineering' AND year BETWEEN YEAR(CURRENT_DATE) - 5 AND YEAR(CURRENT_DATE);
gretelai_synthetic_text_to_sql
CREATE TABLE Manufacturer (MID INT, Name VARCHAR(50)); INSERT INTO Manufacturer (MID, Name) VALUES (1, 'Lockheed Martin'), (2, 'Boeing'); CREATE TABLE Aircraft (AID INT, Type VARCHAR(50), ManufacturerID INT, MaintenanceStatus VARCHAR(20)); INSERT INTO Aircraft (AID, Type, ManufacturerID, MaintenanceStatus) VALUES (1, 'F-35', 1, 'Inactive'), (2, 'F-15', 1, 'Active'), (3, 'F/A-18', 2, 'Active');
What is the total number of military aircrafts by type, grouped by their manufacturer and maintenance status?
SELECT m.Name, a.MaintenanceStatus, COUNT(a.AID) as Total FROM Aircraft a JOIN Manufacturer m ON a.ManufacturerID = m.MID GROUP BY m.Name, a.MaintenanceStatus;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (drug_id VARCHAR(10), country VARCHAR(10), sales_amount NUMERIC(12,2));
What are the total sales for drug 'D001' in the USA?
SELECT SUM(sales_amount) FROM sales WHERE drug_id = 'D001' AND country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE raw_materials (id INT, product_line VARCHAR(50), amount INT); INSERT INTO raw_materials (id, product_line, amount) VALUES (1, 'product1', 10000); INSERT INTO raw_materials (id, product_line, amount) VALUES (2, 'product2', 15000);
What is the total amount spent on raw materials for each product line?
SELECT product_line, SUM(amount) FROM raw_materials GROUP BY product_line;
gretelai_synthetic_text_to_sql
CREATE TABLE us_sales_data (region VARCHAR(30), sales INT, organic BOOLEAN); INSERT INTO us_sales_data (region, sales, organic) VALUES ('Northeast', 1000, TRUE), ('Southeast', 1500, FALSE), ('Midwest', 2000, TRUE), ('Southwest', 1200, FALSE), ('West', 2500, TRUE);
What is the distribution of organic and non-organic food sales across different regions in the US?
SELECT region, SUM(sales) FILTER (WHERE organic) AS organic_sales, SUM(sales) FILTER (WHERE NOT organic) AS non_organic_sales FROM us_sales_data GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE Manufacturer (name VARCHAR(50), country VARCHAR(50), domain VARCHAR(20)); INSERT INTO Manufacturer (name, country, domain) VALUES ('Mitsubishi Heavy Industries', 'Japan', 'Aerospace'); INSERT INTO Manufacturer (name, country, domain) VALUES ('Nissan Space Agency', 'Japan', 'Aerospace'); INSERT INTO Manufacturer (name, country, domain) VALUES ('ISRO', 'India', 'Aerospace');
Which companies have manufactured more than 3 satellites with the type 'Earth Observation'?
SELECT m.name, m.country, COUNT(s.id) as satellite_count FROM Manufacturer m INNER JOIN Satellite s ON m.name = s.manufacturer WHERE s.type = 'Earth Observation' GROUP BY m.name, m.country HAVING COUNT(s.id) > 3;
gretelai_synthetic_text_to_sql
CREATE TABLE properties (property_id INT, neighborhood_id INT, co_owned BOOLEAN, walkability_score INT); INSERT INTO properties (property_id, neighborhood_id, co_owned, walkability_score) VALUES (1, 1, true, 85), (2, 2, false, 92), (3, 3, true, 78), (4, 4, true, 95), (5, 1, false, 88);
Find the number of co-owned properties in neighborhoods with a high walkability score (90 or above).
SELECT COUNT(*) FROM properties WHERE walkability_score >= 90 AND co_owned = true
gretelai_synthetic_text_to_sql
CREATE TABLE Dam_Safety_Monitoring (monitoring_id INT, dam_name VARCHAR(50), dam_type VARCHAR(50), monitoring_date DATE);
Display the names and types of all dams in the Dam_Safety_Monitoring table
SELECT dam_name, dam_type FROM Dam_Safety_Monitoring WHERE dam_type = 'Dam';
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, age INT, gender VARCHAR(10), height INT, weight INT); INSERT INTO users (id, age, gender, height, weight) VALUES (1, 45, 'Male', 175, 80); INSERT INTO users (id, age, gender, height, weight) VALUES (2, 35, 'Female', 165, 60); INSERT INTO users (id, age, gender, height, weight) VALUES (3, 50, 'Male', 180, 90); INSERT INTO users (id, age, gender, height, weight) VALUES (4, 48, 'Female', 170, 70);
What is the minimum BMI of users aged 40-50?
SELECT MIN(weight / POW(height / 100.0, 2)) as min_bmi FROM users WHERE age BETWEEN 40 AND 50;
gretelai_synthetic_text_to_sql
CREATE TABLE smart_contracts (id INT, name VARCHAR(255)); INSERT INTO smart_contracts (id, name) VALUES (6, 'ETH-20'); CREATE TABLE daily_limits (smart_contract_id INT, max_transactions INT); INSERT INTO daily_limits (smart_contract_id, max_transactions) VALUES (6, 1000);
What is the maximum number of transactions allowed for the 'ETH-20' smart contract in a day?
SELECT max_transactions FROM daily_limits WHERE smart_contract_id = (SELECT id FROM smart_contracts WHERE name = 'ETH-20');
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels (ID VARCHAR(10), Name VARCHAR(20), Type VARCHAR(20), Fuel_Consumption FLOAT); INSERT INTO Vessels (ID, Name, Type, Fuel_Consumption) VALUES ('1', 'Vessel A', 'Cargo', 5.5), ('2', 'Vessel B', 'Tanker', 7.0), ('3', 'Vessel C', 'Bulk Carrier', 6.5), ('4', 'Vessel D', 'Container', 5.0), ('5', 'Vessel E', 'Bulk Carrier', 6.0);
What is the maximum and minimum fuel consumption of vessels with Type 'Bulk Carrier'?
SELECT MAX(Fuel_Consumption), MIN(Fuel_Consumption) FROM Vessels WHERE Type = 'Bulk Carrier';
gretelai_synthetic_text_to_sql
CREATE TABLE EthicalBrands (BrandID INT, Country VARCHAR(50)); INSERT INTO EthicalBrands (BrandID, Country) VALUES (1, 'USA'), (2, 'India'), (3, 'Bangladesh'), (4, 'France'), (5, 'Nepal'), (6, 'Italy'), (7, 'Spain');
What is the distribution of ethical fashion brands by country?
SELECT Country, COUNT(*) AS NumBrands FROM EthicalBrands GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE sustainable_garment_sales (id INT, garment_type VARCHAR(50), material VARCHAR(50), sustainable BOOLEAN, price DECIMAL(5,2), country VARCHAR(50)); INSERT INTO sustainable_garment_sales (id, garment_type, material, sustainable, price, country) VALUES (1, 'Shirt', 'Organic Silk', true, 50.00, 'India');
How many garments made of sustainable materials are sold in India?
SELECT COUNT(*) FROM sustainable_garment_sales WHERE sustainable = true AND country = 'India';
gretelai_synthetic_text_to_sql
CREATE TABLE student_mental_health_measurements (student_id INT, date DATE, score INT);
What is the difference in mental health score between the first and last measurement for each student?
SELECT student_id, FIRST_VALUE(score) OVER (PARTITION BY student_id ORDER BY date) - LAST_VALUE(score) OVER (PARTITION BY student_id ORDER BY date ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) as difference FROM student_mental_health_measurements;
gretelai_synthetic_text_to_sql
CREATE TABLE signups (id INT, signup_date DATE); INSERT INTO signups (id, signup_date) VALUES (1, '2021-01-01'), (2, '2021-01-15'), (3, '2021-02-30');
Which month had the most signups?
SELECT DATE_FORMAT(signup_date, '%Y-%m') AS month, COUNT(*) AS signups_per_month FROM signups GROUP BY month ORDER BY signups_per_month DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE AgriculturalProjects (id INT, name VARCHAR(50), location VARCHAR(20), budget FLOAT, completion_date DATE);
Insert new records into the 'AgriculturalProjects' table, representing projects in the 'Asia' region
INSERT INTO AgriculturalProjects (id, name, location, budget, completion_date) VALUES (1, 'Solar Irrigation', 'Asia', 50000, '2025-01-01'), (2, 'Vertical Farming', 'Asia', 75000, '2024-12-31'), (3, 'Precision Agriculture', 'Asia', 60000, '2025-06-30');
gretelai_synthetic_text_to_sql
CREATE TABLE covid_cases (state VARCHAR(20), date DATE, cases INT);
How many confirmed COVID-19 cases were there in Texas on January 1, 2022?
SELECT cases FROM covid_cases WHERE state = 'Texas' AND date = '2022-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE water_consumption (state VARCHAR(20), year INT, consumption FLOAT);
What is the maximum water consumption in each state in 2020?
SELECT state, MAX(consumption) FROM water_consumption WHERE year=2020 GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (id INT, name TEXT, organization TEXT); INSERT INTO Volunteers (id, name, organization) VALUES (1, 'Alex', 'Red Cross'), (2, 'Jamie', 'Doctors Without Borders'), (3, 'Sophia', 'World Vision'); CREATE TABLE Trainers (id INT, name TEXT, organization TEXT); INSERT INTO Trainers (id, name, organization) VALUES (4, 'Mark', 'Red Cross'), (5, 'Emily', 'Doctors Without Borders'), (6, 'Oliver', 'World Vision'); CREATE TABLE Training_Programs (id INT, trainer_id INT, volunteer_id INT, program TEXT, date DATE); INSERT INTO Training_Programs (id, trainer_id, volunteer_id, program, date) VALUES (1, 4, 1, 'Disaster Response', '2022-02-15'), (2, 5, 2, 'Disaster Response', '2022-02-16'), (3, 6, 3, 'Disaster Response', '2022-02-17');
List the names of the volunteers who have participated in disaster response training programs and their respective trainers, including the organization they represent.
SELECT V.name as volunteer_name, T.name as trainer_name, T.organization as trainer_organization FROM Volunteers V INNER JOIN Training_Programs TP ON V.id = TP.volunteer_id INNER JOIN Trainers T ON TP.trainer_id = T.id WHERE TP.program = 'Disaster Response';
gretelai_synthetic_text_to_sql
CREATE TABLE environmental_impact (site_id INT, date DATE, co2_emissions FLOAT, water_consumption FLOAT); INSERT INTO environmental_impact (site_id, date, co2_emissions, water_consumption) VALUES (3, '2021-01-01', 150.5, 30000), (3, '2021-01-02', 160.3, 32000), (4, '2021-01-01', 125.8, 28000), (4, '2021-01-02', 130.2, 29000);
What is the water consumption for site 3 and site 4 combined?
SELECT SUM(water_consumption) FROM environmental_impact WHERE site_id IN (3, 4);
gretelai_synthetic_text_to_sql
CREATE TABLE climate_funding_mn (id INT, region VARCHAR(50), category VARCHAR(50), year INT, funding FLOAT); INSERT INTO climate_funding_mn (id, region, category, year, funding) VALUES (1, 'Middle East', 'Climate Communication', 2018, 400000); INSERT INTO climate_funding_mn (id, region, category, year, funding) VALUES (2, 'North Africa', 'Climate Adaptation', 2019, 500000); INSERT INTO climate_funding_mn (id, region, category, year, funding) VALUES (3, 'Middle East', 'Climate Communication', 2020, 600000);
What is the total funding for climate communication in the Middle East and North Africa in 2020?
SELECT SUM(funding) FROM climate_funding_mn WHERE category = 'Climate Communication' AND (region = 'Middle East' OR region = 'North Africa') AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE SCHEMA infectious_disease_data; CREATE TABLE tuberculosis_cases (id INT, clinic_id INT, location TEXT, cases INT); INSERT INTO infectious_disease_data.tuberculosis_cases (id, clinic_id, location, cases) VALUES (1, 1001, 'Location A', 10), (2, 1001, 'Location B', 15), (3, 1002, 'Location A', 5), (4, 1002, 'Location C', 20), (5, 1003, 'Location B', 12), (6, 1003, 'Location D', 18);
How many tuberculosis cases were reported in 'infectious_disease_data' for each location?
SELECT location, SUM(cases) FROM infectious_disease_data.tuberculosis_cases GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE Programs (ProgramID int, ProgramName varchar(50), FundingSource varchar(50)); INSERT INTO Programs VALUES (1, 'Art Education', 'US Foundation'), (2, 'Theater Workshop', 'European Union'), (3, 'Music Camp', 'Local Sponsor');
Which programs received funding from sources outside of the US?
SELECT ProgramName FROM Programs WHERE FundingSource NOT LIKE 'US%'
gretelai_synthetic_text_to_sql
CREATE TABLE irrigation_water_usage ( id INT, country_id INT, year INT, water_consumption FLOAT ); INSERT INTO irrigation_water_usage (id, country_id, year, water_consumption) VALUES (1, 1, 2017, 1200), (2, 1, 2018, 1300), (3, 1, 2019, 1400), (4, 2, 2017, 900), (5, 2, 2018, 950), (6, 2, 2019, 1000), (7, 3, 2017, 1600), (8, 3, 2018, 1700), (9, 3, 2019, 1800);
What is the minimum water consumption for irrigation in Australia from 2017 to 2019?
SELECT MIN(water_consumption) FROM irrigation_water_usage WHERE country_id = 1 AND year BETWEEN 2017 AND 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE Fleets (id INT, name VARCHAR(255)); INSERT INTO Fleets (id, name) VALUES (1, 'Eco-friendly'); CREATE TABLE Vessels (id INT, name VARCHAR(255), fleet_id INT); INSERT INTO Vessels (id, name, fleet_id) VALUES (1, 'Eco Warrior', 1);
Add a new vessel 'Green Challenger' to the 'Eco-friendly' fleet.
INSERT INTO Vessels (id, name, fleet_id) SELECT 2, 'Green Challenger', id FROM Fleets WHERE name = 'Eco-friendly';
gretelai_synthetic_text_to_sql
CREATE TABLE policy_compliance (id INT, country VARCHAR(255), policy_name VARCHAR(255), compliance_percentage DECIMAL(5,2)); INSERT INTO policy_compliance (id, country, policy_name, compliance_percentage) VALUES (1, 'China', 'Data Encryption', 90.5), (2, 'India', 'Access Control', 85.2), (3, 'USA', 'Incident Response', 92.7), (4, 'Indonesia', 'Security Awareness', 88.3), (5, 'Pakistan', 'Incident Response', 91.1);
What is the policy compliance rate for the top 5 most populous countries in the world?
SELECT country, AVG(compliance_percentage) AS avg_compliance_rate FROM policy_compliance WHERE country IN ('China', 'India', 'USA', 'Indonesia', 'Pakistan') GROUP BY country ORDER BY avg_compliance_rate DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE inventory(id INT PRIMARY KEY, product VARCHAR(50), quantity INT, country VARCHAR(50)); INSERT INTO inventory(id, product, quantity, country) VALUES (1, 'conventional apples', 100, 'USA'), (2, 'organic apples', 200, 'Mexico'), (3, 'organic oranges', 150, 'Spain');
Find the total quantity of "organic apples" in the inventory, grouped by country of origin.
SELECT country, SUM(quantity) FROM inventory WHERE product = 'organic apples' GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE ota_bookings (booking_id INT, hotel_name TEXT, region TEXT, revenue FLOAT); INSERT INTO ota_bookings (booking_id, hotel_name, region, revenue) VALUES (1, 'Hotel D', 'Worldwide', 500), (2, 'Hotel E', 'Worldwide', 700), (3, 'Hotel F', 'Worldwide', 400);
What is the total revenue for OTA bookings worldwide?
SELECT SUM(revenue) FROM ota_bookings;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists worker_region2 (worker_id INT, industry TEXT, region TEXT);INSERT INTO worker_region2 (worker_id, industry, region) VALUES (1, 'construction', 'east'), (2, 'retail', 'west'), (3, 'manufacturing', 'west'), (4, 'construction', 'west');
What is the total number of workers in the 'construction' industry and 'west' region?
SELECT COUNT(*) FROM worker_region2 WHERE industry = 'construction' AND region = 'west';
gretelai_synthetic_text_to_sql
CREATE TABLE smart_contracts (id INT, name TEXT, risk_score INT); INSERT INTO smart_contracts (id, name, risk_score) VALUES (1, 'Contract1', 80); INSERT INTO smart_contracts (id, name, risk_score) VALUES (2, 'Contract2', 60);
List all smart contracts with a risk score above 75.
SELECT * FROM smart_contracts WHERE risk_score > 75;
gretelai_synthetic_text_to_sql
CREATE TABLE water_conservation (id INT PRIMARY KEY, location VARCHAR(20), savings INT);
Add a new record to the 'water_conservation' table with an 'id' of 6, 'location' of 'San Francisco', and 'savings' of 15
INSERT INTO water_conservation (id, location, savings) VALUES (6, 'San Francisco', 15);
gretelai_synthetic_text_to_sql
CREATE TABLE Music_Videos (artist VARCHAR(255), viewership INT); INSERT INTO Music_Videos (artist, viewership) VALUES ('Artist1', 10000000), ('Artist2', 15000000), ('Artist3', 20000000), ('Artist4', 12000000), ('Artist5', 18000000);
What is the total viewership for a specific artist's music videos?
SELECT SUM(viewership) FROM Music_Videos WHERE artist = 'Artist1';
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (id INT, volunteer_name VARCHAR, program VARCHAR); INSERT INTO volunteers (id, volunteer_name, program) VALUES (1, 'Alice', 'Youth Mentoring'), (2, 'Bob', 'Women Empowerment'); CREATE TABLE programs (id INT, program VARCHAR, community VARCHAR); INSERT INTO programs (id, program, community) VALUES (1, 'Youth Mentoring', 'Underrepresented'), (2, 'Women Empowerment', 'Underrepresented');
How many volunteers have participated in programs for underrepresented communities?
SELECT COUNT(*) FROM volunteers v INNER JOIN programs p ON v.program = p.program WHERE p.community = 'Underrepresented';
gretelai_synthetic_text_to_sql
CREATE TABLE Trains (type VARCHAR(10), num_seats INT); INSERT INTO Trains (type, num_seats) VALUES ('Suburban', 100), ('High Speed', 250), ('Regional', 150);
display the number of available seats in trains of type 'Suburban' and 'High Speed'
SELECT type, SUM(num_seats) FROM Trains WHERE type IN ('Suburban', 'High Speed') GROUP BY type;
gretelai_synthetic_text_to_sql
CREATE TABLE departments (id INT, name VARCHAR(255)); CREATE TABLE workers (id INT, department_id INT, factory_id INT); INSERT INTO departments (id, name) VALUES (1, 'Production'), (2, 'Engineering'), (3, 'Management'); INSERT INTO workers (id, department_id, factory_id) VALUES (1, 1, 1), (2, 2, 1), (3, 1, 2), (4, 3, 2), (5, 1, 3);
How many workers are employed in each department?
SELECT d.name, COUNT(w.id) FROM departments d INNER JOIN workers w ON d.id = w.department_id GROUP BY d.name;
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, donor_size VARCHAR(10), cause_area VARCHAR(20), amount INT); INSERT INTO donations (id, donor_size, cause_area, amount) VALUES (1, 'large', 'education', 5500), (2, 'small', 'health', 4000), (3, 'medium', 'children', 3000);
List all cause areas that have had at least one donation greater than $5,000.
SELECT cause_area FROM donations WHERE amount > 5000 GROUP BY cause_area;
gretelai_synthetic_text_to_sql
CREATE TABLE hotel_investments (investment_id INT, investment_amount INT, hotel_type TEXT); INSERT INTO hotel_investments (investment_id, investment_amount, hotel_type) VALUES (1, 2000000, 'Eco-Friendly'), (2, 1500000, 'Luxury'), (3, 1000000, 'Budget');
What is the average investment in eco-friendly hotels in Brazil?
SELECT AVG(investment_amount) FROM hotel_investments WHERE hotel_type = 'Eco-Friendly' AND country = 'Brazil';
gretelai_synthetic_text_to_sql