context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE nba_teams (team_id INT, team_name VARCHAR(50)); INSERT INTO nba_teams (team_id, team_name) VALUES (1, 'Boston Celtics'), (2, 'Golden State Warriors'); CREATE TABLE nba_games (game_id INT, team_id INT, year INT, spectators INT);
What is the average number of spectators attending NBA games in the past decade, by team?
SELECT team_id, AVG(spectators) FROM nba_games WHERE year BETWEEN 2011 AND 2021 GROUP BY team_id;
gretelai_synthetic_text_to_sql
CREATE TABLE autonomous_trains (train_id INT, trip_duration INT, start_speed INT, end_speed INT, trip_date DATE); INSERT INTO autonomous_trains (train_id, trip_duration, start_speed, end_speed, trip_date) VALUES (1, 1500, 10, 20, '2022-01-01'), (2, 1200, 15, 25, '2022-01-02'); CREATE TABLE city_coordinates (city VARCHA...
What is the maximum trip duration for autonomous trains in New York City?
SELECT MAX(trip_duration) FROM autonomous_trains, city_coordinates WHERE city_coordinates.city = 'New York City';
gretelai_synthetic_text_to_sql
CREATE TABLE attorneys (attorney_id INT, office VARCHAR(50)); INSERT INTO attorneys VALUES (1, 'Toronto'); CREATE TABLE cases (case_id INT, attorney_id INT, billing_amount DECIMAL(10,2));
What is the average billing amount for cases handled by attorneys in the 'Toronto' office?
SELECT AVG(billing_amount) FROM cases INNER JOIN attorneys ON cases.attorney_id = attorneys.attorney_id WHERE attorneys.office = 'Toronto';
gretelai_synthetic_text_to_sql
CREATE TABLE donations (donor_id INT, donation_amount DECIMAL(10,2), donation_date DATE, cause VARCHAR(255)); INSERT INTO donations (donor_id, donation_amount, donation_date, cause) VALUES (1, 500, '2022-01-01', 'Education'); INSERT INTO donations (donor_id, donation_amount, donation_date, cause) VALUES (2, 250, '2022-...
What is the average donation amount for each cause, sorted in descending order?
SELECT cause, AVG(donation_amount) AS avg_donation_amount FROM donations GROUP BY cause ORDER BY avg_donation_amount DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE wells (well_id INT, well_type TEXT, location TEXT); INSERT INTO wells (well_id, well_type, location) VALUES (1, 'Onshore', 'USA'), (2, 'Offshore', 'USA'); CREATE TABLE production (prod_id INT, well_id INT, oil_prod INT, gas_prod INT); INSERT INTO production (prod_id, well_id, oil_prod, gas_prod) VALUES (1,...
What is the total number of onshore and offshore wells in the USA and their production figures?
SELECT well_type, SUM(oil_prod + gas_prod) FROM production JOIN wells ON production.well_id = wells.well_id GROUP BY well_type;
gretelai_synthetic_text_to_sql
CREATE TABLE electric_vehicles_grouped (id INT, vehicle_make VARCHAR(50), vehicle_range INT); INSERT INTO electric_vehicles_grouped (id, vehicle_make, vehicle_range) VALUES (1, 'Tesla', 373), (2, 'Tesla', 263), (3, 'Chevy', 259), (4, 'Nissan', 226), (5, 'Ford', 303), (6, 'Tesla', 299), (7, 'Ford', 230);
Get the minimum and maximum range of electric vehicles, grouped by make
SELECT vehicle_make, MIN(vehicle_range) as min_range, MAX(vehicle_range) as max_range FROM electric_vehicles_grouped GROUP BY vehicle_make;
gretelai_synthetic_text_to_sql
CREATE TABLE Spacecraft (Id INT, Name VARCHAR(50), Manufacturer VARCHAR(50), Mass FLOAT);
What is the total mass of spacecraft manufactured by Galactic Innovations?
SELECT SUM(Mass) FROM Spacecraft WHERE Manufacturer = 'Galactic Innovations';
gretelai_synthetic_text_to_sql
CREATE TABLE cities (id INT, city VARCHAR(50), population INT); INSERT INTO cities VALUES (1, 'CityX', 600000); INSERT INTO cities VALUES (2, 'CityY', 400000); INSERT INTO cities VALUES (3, 'CityZ', 550000); CREATE TABLE housing_policies (id INT, city VARCHAR(50), eco_friendly BOOLEAN); INSERT INTO housing_policies VAL...
List all cities with a population over 500,000 that have eco-friendly housing policies
SELECT a.city FROM cities a INNER JOIN housing_policies b ON a.city = b.city WHERE a.population > 500000 AND b.eco_friendly = TRUE GROUP BY a.city, b.city;
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (VolunteerID INT, SignUpDate DATE); INSERT INTO Volunteers (VolunteerID, SignUpDate) VALUES (1, '2021-01-15'), (2, '2021-02-20'), (3, '2021-03-05');
How many volunteers signed up each month in 2021?
SELECT EXTRACT(MONTH FROM SignUpDate) as Month, COUNT(*) as NumVolunteers FROM Volunteers WHERE SignUpDate >= '2021-01-01' AND SignUpDate < '2022-01-01' GROUP BY Month ORDER BY Month;
gretelai_synthetic_text_to_sql
CREATE TABLE community_education (id INT, program VARCHAR(50), location VARCHAR(50), date DATE);
Count the number of educational programs in 'community_education' table that took place in Brazil
SELECT COUNT(*) FROM community_education WHERE location = 'Brazil';
gretelai_synthetic_text_to_sql
CREATE TABLE ota_bookings (booking_id INT, ota_website VARCHAR(255), hotel_name VARCHAR(255), booking_date DATE, revenue DECIMAL(10,2)); CREATE TABLE hotels (hotel_id INT, hotel_name VARCHAR(255), country VARCHAR(255));
What is the revenue from hotel bookings made through OTA websites in the last month?
SELECT SUM(revenue) FROM ota_bookings INNER JOIN hotels ON ota_bookings.hotel_name = hotels.hotel_name WHERE booking_date >= DATEADD(month, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, customer_name VARCHAR(255), age INT, financial_wellbeing_score INT);CREATE VIEW young_adults AS SELECT * FROM customers WHERE age BETWEEN 25 AND 34;
What is the average financial wellbeing score for customers in the age range of 25-34?
SELECT AVG(c.financial_wellbeing_score) as avg_score FROM customers c INNER JOIN young_adults ya ON c.customer_id = ya.customer_id;
gretelai_synthetic_text_to_sql
CREATE TABLE chemicals (id INT, name TEXT, production_volume INT); INSERT INTO chemicals (id, name, production_volume) VALUES (1, 'Chemical A', 500), (2, 'Chemical B', 300), (3, 'Chemical C', 700);
What is the average production volume for each chemical?
SELECT name, AVG(production_volume) FROM chemicals GROUP BY name;
gretelai_synthetic_text_to_sql
CREATE TABLE events (id INT, event_type VARCHAR(50), city VARCHAR(50), attendance INT); INSERT INTO events (id, event_type, city, attendance) VALUES (1, 'Dance Performance', 'New York City', 100), (2, 'Music Concert', 'Los Angeles'), (3, 'Theater Play', 'Chicago', 75);
What was the total attendance at dance performances in New York City?
SELECT SUM(attendance) FROM events WHERE event_type = 'Dance Performance' AND city = 'New York City';
gretelai_synthetic_text_to_sql
CREATE TABLE farm_regions (id INT, farm_id INT, region VARCHAR(20)); INSERT INTO farm_regions (id, farm_id, region) VALUES (1, 1, 'rural'), (2, 2, 'urban'), (3, 3, 'rural'), (4, 4, 'indigenous'); CREATE VIEW organic_farms_by_region AS SELECT fr.region, SUM(f.acres) AS total_organic_acres FROM organic_farms f JOIN farm_...
Calculate the percentage of organic farming land in each region.
SELECT region, (SUM(CASE WHEN is_organic = 'true' THEN f.acres ELSE 0 END) / total_organic_acres) * 100 AS organic_percentage FROM farm_regions fr JOIN farms f ON fr.farm_id = f.id JOIN organic_farms_by_region org ON fr.region = org.region GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE prison (id INT, name TEXT, security_level TEXT, age INT); INSERT INTO prison (id, name, security_level, age) VALUES (1, 'Federal Correctional Institution Ashland', 'low_security', 45);
What is the average age of inmates in the low_security prison?
SELECT AVG(age) FROM prison WHERE security_level = 'low_security';
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_acidification (id INT, location TEXT, level FLOAT); INSERT INTO ocean_acidification (id, location, level) VALUES (1, 'North Atlantic', 7.9); INSERT INTO ocean_acidification (id, location, level) VALUES (2, 'South Atlantic', 7.8); INSERT INTO ocean_acidification (id, location, level) VALUES (3, 'North...
Find the average ocean acidification levels in the Atlantic and Indian Oceans.
SELECT AVG(level) FROM ocean_acidification WHERE location IN ('North Atlantic', 'South Atlantic', 'North Indian', 'South Indian');
gretelai_synthetic_text_to_sql
CREATE TABLE threat_actors (id INT, actor VARCHAR(255), group_name VARCHAR(255), incident_type VARCHAR(255)); INSERT INTO threat_actors (id, actor, group_name, incident_type) VALUES (1, 'APT28', 'APT', 'spear phishing'), (2, 'APT33', 'APT', 'DDoS'), (3, 'APT29', 'APT', 'malware'), (4, 'Lazarus', 'APT', 'ransomware');
What are the unique incident types for each threat actor in the 'APT' group?
SELECT actor, incident_type FROM threat_actors WHERE group_name = 'APT' GROUP BY actor, incident_type;
gretelai_synthetic_text_to_sql
CREATE TABLE human_spaceflight (id INT, mission_name VARCHAR(50), distance_from_earth INT); INSERT INTO human_spaceflight (id, mission_name, distance_from_earth) VALUES (1, 'Apollo 13', 400000), (2, 'Voyager 1', 1400000000), (3, 'New Horizons', 430000000);
What is the maximum distance from Earth traveled by a human spacecraft?
SELECT MAX(distance_from_earth) FROM human_spaceflight;
gretelai_synthetic_text_to_sql
CREATE TABLE companies_founded(id INT, name VARCHAR(50), founded_by_immigrant BOOLEAN, industry VARCHAR(20), funding FLOAT); INSERT INTO companies_founded(id, name, founded_by_immigrant, industry, funding) VALUES (1, 'CompanyA', TRUE, 'E-commerce', 1000000); INSERT INTO companies_founded(id, name, founded_by_immigrant,...
What is the percentage of funding received by companies founded by immigrants in the e-commerce industry?
SELECT ROUND(100.0 * SUM(CASE WHEN founded_by_immigrant THEN funding ELSE 0 END) / SUM(funding), 2) as percentage FROM companies_founded WHERE industry = 'E-commerce';
gretelai_synthetic_text_to_sql
CREATE TABLE LanguagePreservation (Location VARCHAR(50), Budget DECIMAL(10,2)); INSERT INTO LanguagePreservation (Location, Budget) VALUES ('Africa', 500000);
What is the average budget allocated for language preservation programs in Africa?
SELECT AVG(Budget) FROM LanguagePreservation WHERE Location = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE sales (sale_id INT, product_id INT, sale_date DATE, sale_quantity INT, sale_price FLOAT, country VARCHAR(50)); CREATE TABLE products (product_id INT, product_name VARCHAR(100), product_type VARCHAR(50), eco_friendly BOOLEAN);
What is the total revenue generated by eco-friendly nail polish sales in Q2 2022, excluding sales from the US?
SELECT SUM(sale_quantity * sale_price) AS total_revenue FROM sales JOIN products ON sales.product_id = products.product_id WHERE products.product_type = 'nail polish' AND eco_friendly = TRUE AND country != 'US' AND sale_date BETWEEN '2022-04-01' AND '2022-06-30';
gretelai_synthetic_text_to_sql
CREATE TABLE Exhibitions (exhibition_id INT, name VARCHAR(100), visitor_count INT);
Delete exhibitions with less than 100 visitors.
DELETE FROM Exhibitions WHERE visitor_count < 100;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists biotech;CREATE TABLE if not exists biotech.projects (id INT, name VARCHAR(100), status VARCHAR(20), completion_date DATE); INSERT INTO biotech.projects (id, name, status, completion_date) VALUES (1, 'Project5', 'Completed', '2021-02-15'), (2, 'Project6', 'In Progress', '2021-07-20'), (3, 'Pr...
How many genetic research projects were completed before June 2021?
SELECT COUNT(*) FROM biotech.projects WHERE status = 'Completed' AND completion_date < '2021-06-01';
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID int, Department varchar(20), Salary numeric(10,2)); INSERT INTO Employees (EmployeeID, Department, Salary) VALUES (1, 'IT', 75000.00), (2, 'IT', 70000.00), (3, 'HR', 60000.00), (4, 'Finance', 80000.00);
What is the total salary expense for the company broken down by department?
SELECT Department, SUM(Salary) FROM Employees GROUP BY Department;
gretelai_synthetic_text_to_sql
CREATE TABLE Artist (id INT, name VARCHAR(255), birth_date DATE, death_date DATE); CREATE TABLE Art (id INT, title VARCHAR(255), artist_id INT);
List the artworks by artists who were born in the 1800s and lived to be at least 80 years old.
SELECT Art.title FROM Art JOIN Artist ON Art.artist_id = Artist.id WHERE YEAR(Artist.birth_date) BETWEEN 1800 AND 1899 AND YEAR(Artist.death_date) - YEAR(Artist.birth_date) >= 80;
gretelai_synthetic_text_to_sql
CREATE TABLE investors (investor_id INT, investor_name TEXT, country TEXT); INSERT INTO investors (investor_id, investor_name, country) VALUES (1, 'Vanguard', 'USA'), (2, 'BlackRock', 'USA'), (3, 'State Street Global Advisors', 'USA'); CREATE TABLE socially_responsible_investments (investment_id INT, investor_id INT, i...
What is the total value of socially responsible investments made by each investor, in descending order?
SELECT investor_name, SUM(investment_value) AS total_investments FROM socially_responsible_investments JOIN investors ON socially_responsible_investments.investor_id = investors.investor_id GROUP BY investor_name ORDER BY total_investments DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE debris_type (debris_id INT, orbit_type VARCHAR(255), size FLOAT); INSERT INTO debris_type (debris_id, orbit_type, size) VALUES (1, 'LEO', 0.1); INSERT INTO debris_type (debris_id, orbit_type, size) VALUES (2, 'LES', 0.5); INSERT INTO debris_type (debris_id, orbit_type, size) VALUES (3, 'LES', 0.3);
What is the average size of debris objects in the LES orbit?
SELECT AVG(size) FROM debris_type WHERE orbit_type = 'LES';
gretelai_synthetic_text_to_sql
CREATE TABLE Highways (id INT, name TEXT, state TEXT, cost FLOAT); INSERT INTO Highways (id, name, state, cost) VALUES (1, 'New York State Thruway', 'New York', 1200000000.0); INSERT INTO Highways (id, name, state, cost) VALUES (2, 'Queens-Midtown Tunnel', 'New York', 81000000.0);
What is the maximum construction cost of a highway project in the state of New York?
SELECT MAX(cost) FROM Highways WHERE state = 'New York'
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT PRIMARY KEY, PlayerName VARCHAR(100), Country VARCHAR(50), Email VARCHAR(100)); INSERT INTO Players VALUES (1, 'Kenji', 'Japan', 'kenji@example.com');
Update the email of the top-earning player from Japan in VR games.
UPDATE Players SET Email = 'kenji.topplayer@example.com' WHERE PlayerID = (SELECT PlayerID FROM (SELECT PlayerID, SUM(VirtualCurrency) as TotalCurrencyEarned FROM Players JOIN VR_Games ON Players.PlayerID = VR_Games.PlayerID WHERE Country = 'Japan' GROUP BY PlayerID ORDER BY TotalCurrencyEarned DESC LIMIT 1));
gretelai_synthetic_text_to_sql
CREATE TABLE solar_power_plants (id INT, country VARCHAR(255), name VARCHAR(255), installed_capacity FLOAT); INSERT INTO solar_power_plants (id, country, name, installed_capacity) VALUES (1, 'Spain', 'Solar Plant 1', 30.5), (2, 'Spain', 'Solar Plant 2', 22.6), (3, 'Spain', 'Solar Plant 3', 35.9), (4, 'Spain', 'Solar Pl...
How many solar power plants are there in Spain with an installed capacity greater than 25 MW?
SELECT COUNT(*) FROM solar_power_plants WHERE country = 'Spain' AND installed_capacity > 25;
gretelai_synthetic_text_to_sql
CREATE TABLE region_sequestration (id INT, region VARCHAR(255), total_sequestration FLOAT); INSERT INTO region_sequestration (id, region, total_sequestration) VALUES (1, 'North', 5000.0), (2, 'South', 6000.0), (3, 'East', 4500.0), (4, 'West', 7000.0);
What is the total carbon sequestration potential for each region in the 'region_sequestration' table?
SELECT region, SUM(total_sequestration) FROM region_sequestration GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE food_inspection (date DATE, restaurant VARCHAR(255), score DECIMAL(3,1)); INSERT INTO food_inspection (date, restaurant, score) VALUES ('2021-01-01', 'Restaurant A', 92.0), ('2021-01-01', 'Restaurant B', 88.0), ('2021-01-02', 'Restaurant A', 94.0), ('2021-01-02', 'Restaurant B', 89.0);
What was the average food safety score for each restaurant in Q1 2021?
SELECT restaurant, AVG(score) as avg_score FROM food_inspection WHERE date BETWEEN '2021-01-01' AND '2021-03-31' GROUP BY restaurant;
gretelai_synthetic_text_to_sql
CREATE TABLE restaurant_inspections(location VARCHAR(255), score INT); INSERT INTO restaurant_inspections(location, score) VALUES ('San Francisco Restaurant', 75), ('Los Angeles Restaurant', 80), ('San Diego Restaurant', 90);
What is the lowest food safety score for restaurants in California?
SELECT MIN(score) FROM restaurant_inspections WHERE location LIKE '%California%';
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, name VARCHAR(50)); INSERT INTO users (id, name) VALUES (1, 'Alice'), (2, 'Bob'); CREATE TABLE posts (id INT, user_id INT, timestamp DATETIME); INSERT INTO posts (id, user_id, timestamp) VALUES (1, 1, '2022-01-01 10:00:00'), (2, 1, '2022-01-02 11:00:00'), (3, 2, '2022-01-03 12:00:00'), (4, 1,...
Find users who have made at least one post per day for the last 7 days.
SELECT users.name FROM users INNER JOIN posts ON users.id = posts.user_id WHERE posts.timestamp >= DATE_SUB(NOW(), INTERVAL 7 DAY) GROUP BY users.name HAVING COUNT(DISTINCT DATE(posts.timestamp)) = 7;
gretelai_synthetic_text_to_sql
CREATE TABLE oceans (id INT, name VARCHAR(50)); CREATE TABLE species (id INT, ocean_id INT, name VARCHAR(50), min_size FLOAT, survival_rate FLOAT); INSERT INTO oceans VALUES (1, 'Indian Ocean'); INSERT INTO species VALUES (1, 1, 'Whale Shark', 120, 0.85), (2, 1, 'Oceanic Manta Ray', 150, 0.9), (3, 1, 'Basking Shark', 2...
What is the survival rate of fish species in the Indian Ocean with a minimum size over 150 cm?
SELECT AVG(s.survival_rate) as avg_survival_rate FROM species s INNER JOIN oceans o ON s.ocean_id = o.id WHERE o.name = 'Indian Ocean' AND s.min_size > 150;
gretelai_synthetic_text_to_sql
CREATE TABLE SustainableFabrics (id INT, supplier VARCHAR(50), fabric VARCHAR(50), lead_time INT); INSERT INTO SustainableFabrics (id, supplier, fabric, lead_time) VALUES (1, 'GreenFabrics', 'Organic Cotton', 14), (2, 'EcoTextiles', 'Hemp', 21), (3, 'SustainableWeaves', 'Tencel', 10);
What is the minimum lead time for sustainable fabric suppliers?
SELECT MIN(lead_time) FROM SustainableFabrics;
gretelai_synthetic_text_to_sql
CREATE TABLE smart_contracts (smart_contract_id INT, name VARCHAR(255), version VARCHAR(255), jurisdiction VARCHAR(255), last_updated DATE); CREATE TABLE regulations (regulation_id INT, jurisdiction VARCHAR(255), subject VARCHAR(255), publication_date DATE, status VARCHAR(255));
What is the total number of smart contracts in the 'smart_contracts' table for each 'jurisdiction' in the 'regulations' table, ordered by the total number of smart contracts in descending order?
SELECT r.jurisdiction, COUNT(sc.smart_contract_id) as total_smart_contracts FROM smart_contracts sc JOIN regulations r ON sc.jurisdiction = r.jurisdiction GROUP BY r.jurisdiction ORDER BY total_smart_contracts DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE broadband_subscribers (region VARCHAR(50), subscriber_id INT, speed FLOAT); INSERT INTO broadband_subscribers VALUES ('Region A', 100, 50); INSERT INTO broadband_subscribers VALUES ('Region A', 200, 75); INSERT INTO broadband_subscribers VALUES ('Region B', 300, 100); INSERT INTO broadband_subscribers VALU...
What is the average speed and total number of broadband subscribers in each region?
SELECT region, AVG(speed) as avg_speed, COUNT(subscriber_id) as total_subscribers FROM broadband_subscribers GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE articles (id INT, title VARCHAR(255), publish_date DATE, topic VARCHAR(255)); INSERT INTO articles (id, title, publish_date, topic) VALUES (1, 'Investigative Article 1', '2022-01-01', 'investigative');
Find the number of articles published on investigative journalism topics in the last 6 months, grouped by month.
SELECT COUNT(*), DATE_FORMAT(publish_date, '%Y-%m') AS Month FROM articles WHERE topic = 'investigative' AND publish_date >= DATE_SUB(NOW(), INTERVAL 6 MONTH) GROUP BY Month;
gretelai_synthetic_text_to_sql
CREATE TABLE Northrop_Revenue (id INT, corporation VARCHAR(20), region VARCHAR(20), revenue DECIMAL(10,2)); INSERT INTO Northrop_Revenue (id, corporation, region, revenue) VALUES (1, 'Northrop Grumman', 'North America', 5000000.00);
What is the total revenue from naval equipment sales for Northrop Grumman in North America?
SELECT SUM(revenue) FROM Northrop_Revenue WHERE corporation = 'Northrop Grumman' AND region = 'North America' AND equipment = 'Naval';
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (id INT, name TEXT, country TEXT, age INT); INSERT INTO volunteers (id, name, country, age) VALUES (1, 'Jean Dupont', 'France', 65), (2, 'Marie Dupont', 'France', 30);
What percentage of volunteers in France are over the age of 60?
SELECT (COUNT(*) FILTER (WHERE age > 60) / COUNT(*)) * 100.0 FROM volunteers WHERE country = 'France';
gretelai_synthetic_text_to_sql
CREATE TABLE Regions (Region VARCHAR(50), CountryName VARCHAR(50)); CREATE TABLE Transactions (TransactionID INT, VisitorID INT, Amount DECIMAL(10,2));
What's the total revenue generated from visitors who reside in the 'North America' region?
SELECT SUM(t.Amount) FROM Transactions t JOIN Visitors v ON t.VisitorID = v.VisitorID JOIN Regions r ON v.Country = r.CountryName WHERE r.Region = 'North America';
gretelai_synthetic_text_to_sql
CREATE TABLE game_servers (server_id INT, region VARCHAR(10), player_capacity INT);
Update the player_capacity column in the game_servers table to 50 for all servers in the 'North America' region
UPDATE game_servers SET player_capacity = 50 WHERE region = 'North America';
gretelai_synthetic_text_to_sql
CREATE TABLE renewables.hydroelectric_plants (plant_id int, name varchar(50), capacity int); INSERT INTO renewables.hydroelectric_plants (plant_id, name, capacity) VALUES (1, 'Plant D', 1200), (2, 'Plant E', 900), (3, 'Plant F', 1100);
What are the names and capacities of hydroelectric power plants in the 'renewables' schema?
SELECT name, capacity FROM renewables.hydroelectric_plants;
gretelai_synthetic_text_to_sql
CREATE TABLE mine_production_sweden (id INT, mine_name VARCHAR(50), country VARCHAR(50), production_tonnes INT, year INT, PRIMARY KEY (id)); INSERT INTO mine_production_sweden (id, mine_name, country, production_tonnes, year) VALUES (1, 'Rammuldi', 'Sweden', 125000, 2021);
Update the production tonnes for the 'Rammuldi' mine in Sweden by 10% for the year 2021.
UPDATE mine_production_sweden SET production_tonnes = production_tonnes * 1.1 WHERE mine_name = 'Rammuldi' AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE InclusiveHousingUnits (Id INT, City VARCHAR(50), Units INT); INSERT INTO InclusiveHousingUnits (Id, City, Units) VALUES (1, 'Oakland', 150), (2, 'Seattle', 250), (3, 'Oakland', 200), (4, 'SanFrancisco', 300), (5, 'Portland', 225);
What is the total number of inclusive housing units in Oakland, CA?
SELECT SUM(Units) FROM InclusiveHousingUnits WHERE City = 'Oakland';
gretelai_synthetic_text_to_sql
CREATE TABLE warehouses (id VARCHAR(10), name VARCHAR(20), city VARCHAR(10), country VARCHAR(10)); CREATE TABLE inventory (item VARCHAR(10), warehouse_id VARCHAR(10), quantity INT); INSERT INTO warehouses (id, name, city, country) VALUES ('SEA-WH-01', 'Seattle Warehouse', 'Seattle', 'USA'), ('NYC-WH-01', 'New York City...
What is the average quantity of inventory in country 'USA'?
SELECT AVG(quantity) as avg_quantity FROM inventory i JOIN warehouses w ON i.warehouse_id = w.id WHERE w.country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE sales (sale_date DATE, region VARCHAR(255), revenue FLOAT);
What was the total revenue for each region in 2021?
SELECT region, SUM(revenue) AS total_revenue FROM sales WHERE sale_date BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE Games (GameID INT PRIMARY KEY, Name VARCHAR(50), Genre VARCHAR(50), ReleaseDate DATE); CREATE TABLE Players (PlayerID INT PRIMARY KEY, Name VARCHAR(50), Game VARCHAR(50), Score INT); CREATE VIEW GameScores AS SELECT Game, AVG(Score) AS AverageScore FROM Players GROUP BY Game; CREATE VIEW AboveAverage AS SE...
What is the average score for each game, and how many players have a score above the average?
SELECT GameScores.Game, GameScores.AverageScore, AboveAverage.AboveAverageCount FROM GameScores INNER JOIN AboveAverage ON GameScores.Game = AboveAverage.Game;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, DonorName TEXT, DonationAmount DECIMAL(10,2), DonationDate DATE);
How many donors contributed in the first quarter of 2021?
SELECT COUNT(DISTINCT DonorName) FROM Donors WHERE QUARTER(DonationDate) = 1 AND YEAR(DonationDate) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE production (id INT, country VARCHAR(255), production_amount FLOAT, production_date DATE);
Show the total number of chemical substances produced in India per month for the past 2 years.
SELECT country, DATE_FORMAT(production_date, '%Y-%m') as month, SUM(production_amount) as total_production FROM production WHERE country = 'India' AND production_date > DATE_SUB(CURDATE(), INTERVAL 2 YEAR) GROUP BY country, month;
gretelai_synthetic_text_to_sql
CREATE TABLE projects (id INT, name TEXT, capacity INT, location TEXT);
Add a new renewable energy project with id 5, name 'Geothermal Plant 1.0', capacity 2000, and location 'Nevada'
INSERT INTO projects (id, name, capacity, location) VALUES (5, 'Geothermal Plant 1.0', 2000, 'Nevada');
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name VARCHAR(100), sales INT, certification VARCHAR(20)); INSERT INTO products (product_id, product_name, sales, certification) VALUES (1, 'Lipstick A', 5000, 'cruelty-free'), (2, 'Mascara B', 7000, 'not_certified'), (3, 'Foundation C', 8000, 'cruelty-free'); CREATE TABLE ...
What are the top 3 cruelty-free certified cosmetic products by sales in the Canadian market?
SELECT product_name, sales FROM products WHERE certification = 'cruelty-free' AND country_code = 'CA' ORDER BY sales DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE district (did INT, name VARCHAR(255)); INSERT INTO district VALUES (1, 'Downtown'), (2, 'Uptown'); CREATE TABLE events (event_id INT, district_id INT, year INT, type VARCHAR(255));
Find the number of community policing events in each district in 2021.
SELECT d.name, COUNT(e.event_id) FROM district d JOIN events e ON d.did = e.district_id WHERE e.type = 'Community Policing' AND e.year = 2021 GROUP BY d.did;
gretelai_synthetic_text_to_sql
CREATE TABLE companies(id INT, name VARCHAR(50), founding_year INT, diversity_score INT); INSERT INTO companies VALUES (1, 'Alpha', 2010, 70); INSERT INTO companies VALUES (2, 'Beta', 2015, 80); CREATE TABLE founders(id INT, company_id INT, community VARCHAR(20)); INSERT INTO founders VALUES (1, 1, 'Minority'); INSERT ...
What is the average diversity score of companies founded by underrepresented communities?
SELECT AVG(companies.diversity_score) FROM companies INNER JOIN founders ON companies.id = founders.company_id WHERE founders.community IN ('Minority', 'Women', 'LGBTQ+');
gretelai_synthetic_text_to_sql
CREATE TABLE Inventory (StrainID INT, PricePerPound INT, Quantity INT);
Update the price of strain 'Sour Diesel' to $1200 per pound in the Inventory table.
UPDATE Inventory SET PricePerPound = 1200 WHERE StrainID = (SELECT StrainID FROM Strains WHERE StrainName = 'Sour Diesel');
gretelai_synthetic_text_to_sql
CREATE TABLE articles (id INT, title VARCHAR(255), author VARCHAR(255), content TEXT, date DATE); INSERT INTO articles (id, title, author, content, date) VALUES (1, 'Article Title 1', 'Jane Doe', 'Article Content 1', '2022-01-01'), (2, 'Article Title 2', 'Alice Smith', 'Article Content 2', '2022-02-01');
How many articles were published in each month of 2022 in the 'articles' table?
SELECT EXTRACT(MONTH FROM date) AS month, COUNT(*) AS article_count FROM articles WHERE date >= '2022-01-01' AND date < '2023-01-01' GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE hospitals (id INT, name TEXT, city TEXT, state TEXT, beds INT); INSERT INTO hospitals (id, name, city, state, beds) VALUES (1, 'General Hospital', 'Miami', 'Florida', 500); INSERT INTO hospitals (id, name, city, state, beds) VALUES (2, 'Memorial Hospital', 'Boston', 'Massachusetts', 600);
What is the total number of beds in hospitals for each state?
SELECT state, SUM(beds) as total_beds FROM hospitals GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE flight_records (id INT, aircraft_model VARCHAR(50), flight_count INT); INSERT INTO flight_records (id, aircraft_model, flight_count) VALUES (1, 'B747', 150), (2, 'A320', 120), (3, 'B787', 110);
Which aircraft models have more than 100 flights?
SELECT aircraft_model, flight_count FROM flight_records WHERE flight_count > 100;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, FirstName TEXT, LastName TEXT, RegistrationDate DATE, IsRecurring BOOLEAN); INSERT INTO Donors (DonorID, FirstName, LastName, RegistrationDate, IsRecurring) VALUES (1, 'John', 'Doe', '2021-01-15', true), (2, 'Jane', 'Doe', '2020-12-20', false), (3, 'Mike', 'Smith', '2021-03-01', true);...
What is the sum of donations for recurring donors in 2021?
SELECT SUM(Amount) as TotalDonations FROM Donations d JOIN Donors don ON d.DonorID = don.DonorID WHERE IsRecurring = true AND DonationDate BETWEEN '2021-01-01' AND '2021-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE Vehicles (id INT, make VARCHAR(50), model VARCHAR(50), safety_rating FLOAT, fuel_type VARCHAR(50));
What is the average safety rating of electric vehicles compared to gasoline vehicles?
SELECT AVG(safety_rating) FROM Vehicles WHERE fuel_type = 'Electric'; SELECT AVG(safety_rating) FROM Vehicles WHERE fuel_type = 'Gasoline';
gretelai_synthetic_text_to_sql
CREATE TABLE oil_reservoirs (reservoir_id INT, name VARCHAR(50), location VARCHAR(50), reserves_bbl INT);
What are the names of all fields in the 'oil_reservoirs' table?
DESCRIBE oil_reservoirs;
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name TEXT, region TEXT);CREATE TABLE cargo_ships (id INT, company_id INT, capacity INT); INSERT INTO companies (id, name, region) VALUES (1, 'ABC Shipping', 'Europe'); INSERT INTO companies (id, name, region) VALUES (2, 'XYZ Shipping', 'Asia'); INSERT INTO cargo_ships (id, company_id, ca...
What is the maximum capacity of all cargo ships owned by companies from Europe?
SELECT MAX(cs.capacity) FROM cargo_ships cs INNER JOIN companies c ON cs.company_id = c.id WHERE c.region = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE temperature_readings (reading_date DATE, temperature FLOAT, country TEXT);
What is the average temperature per month in each country in the 'temperature_readings' table?
SELECT DATE_TRUNC('month', reading_date) AS month, country, AVG(temperature) FROM temperature_readings GROUP BY month, country;
gretelai_synthetic_text_to_sql
CREATE TABLE sites (name VARCHAR(255), location VARCHAR(255), language VARCHAR(255)); INSERT INTO sites (name, location, language) VALUES ('Site A', 'Country A', 'Language A'); INSERT INTO sites (name, location, language) VALUES ('Site B', 'Country B', 'Language B');
What are the names and languages of all the cultural heritage sites in Africa?
SELECT name, language FROM sites WHERE location LIKE 'Africa%'
gretelai_synthetic_text_to_sql
CREATE TABLE Events (EventID int, EventDate date, TicketsSold int, Country varchar(50)); INSERT INTO Events (EventID, EventDate, TicketsSold, Country) VALUES (1, '2019-01-01', 200, 'Mexico'), (2, '2019-06-01', 300, 'Mexico'), (3, '2020-01-01', 150, 'Mexico');
How many total tickets were sold for events held in Mexico between January 1, 2019 and December 31, 2019?
SELECT SUM(TicketsSold) FROM Events WHERE EventDate BETWEEN '2019-01-01' AND '2019-12-31' AND Country = 'Mexico';
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID int, FirstName varchar(50), LastName varchar(50), Race varchar(20), HireDate date); INSERT INTO Employees (EmployeeID, FirstName, LastName, Race, HireDate) VALUES (1, 'John', 'Doe', 'White', '2010-01-01'); INSERT INTO Employees (EmployeeID, FirstName, LastName, Race, HireDate) VALUES ...
What is the racial composition of employees who joined after 2015, ordered by hire date?
SELECT Race, HireDate FROM (SELECT Race, HireDate, ROW_NUMBER() OVER (PARTITION BY Race ORDER BY HireDate) as rn FROM Employees WHERE HireDate > '2015-12-31') x WHERE rn = 1 ORDER BY HireDate;
gretelai_synthetic_text_to_sql
CREATE TABLE consumer_preferences (id INT PRIMARY KEY, customer_id INT, product VARCHAR(100), preference INT, FOREIGN KEY (customer_id) REFERENCES customers(id)); CREATE TABLE beauty_products (id INT PRIMARY KEY, product VARCHAR(100), category VARCHAR(100), price FLOAT); CREATE TABLE suppliers (id INT PRIMARY KEY, name...
Which beauty products in the 'makeup' category have a preference count of over 200 and are sold by suppliers with a sustainability score of 85 or higher?
SELECT bp.product, bp.category FROM beauty_products bp JOIN consumer_preferences cp ON bp.product = cp.product JOIN suppliers s ON bp.product = s.product WHERE bp.category = 'makeup' AND cp.preference > 200 AND s.sustainability_score >= 85;
gretelai_synthetic_text_to_sql
CREATE TABLE peacekeeping_operations (operation_id INT, name TEXT, location TEXT); INSERT INTO peacekeeping_operations (operation_id, name, location) VALUES (1, 'MINUSCA', 'Central African Republic'), (2, 'MONUSCO', 'Democratic Republic of the Congo'), (3, 'UNAMID', 'Darfur, Sudan'), (4, 'UNMISS', 'South Sudan'), (5, '...
What are the peacekeeping operations in African countries?
SELECT * FROM peacekeeping_operations WHERE location IN ('Central African Republic', 'Democratic Republic of the Congo', 'Darfur, Sudan', 'South Sudan', 'Mali');
gretelai_synthetic_text_to_sql
CREATE TABLE visitor_workshops (visitor_id INT, language VARCHAR(20), workshop_name VARCHAR(50)); INSERT INTO visitor_workshops (visitor_id, language, workshop_name) VALUES (1, 'English', 'Painting'), (2, 'Spanish', 'Sculpture'), (3, 'French', 'Digital Art');
How many visitors engaged with the digital museum's online workshops, categorized by their preferred language?
SELECT language, COUNT(*) as num_visitors FROM visitor_workshops GROUP BY language;
gretelai_synthetic_text_to_sql
CREATE TABLE MilitaryEquipment (id INT, region VARCHAR(20), manufacturer VARCHAR(50), equipment_type VARCHAR(50), maintenance_date DATE, maintenance_type VARCHAR(50)); INSERT INTO MilitaryEquipment (id, region, manufacturer, equipment_type, maintenance_date, maintenance_type) VALUES (1, 'Pacific', 'Boeing', 'Aircraft',...
What is the total number of military aircraft that underwent maintenance in the Pacific region in Q1 2021, grouped by manufacturer and maintenance type?
SELECT manufacturer, maintenance_type, COUNT(*) as total_maintenance FROM MilitaryEquipment WHERE region = 'Pacific' AND maintenance_date BETWEEN '2021-01-01' AND '2021-03-31' GROUP BY manufacturer, maintenance_type;
gretelai_synthetic_text_to_sql
CREATE TABLE Factories (Factory_ID INT, Country TEXT, Labor_Standards_Rating INT); CREATE TABLE Countries (Country TEXT, Continent TEXT);
Which factories have the lowest labor standards rating in each country?
SELECT F.Country, MIN(F.Labor_Standards_Rating) AS Lowest_Labor_Standards_Rating FROM Factories F
gretelai_synthetic_text_to_sql
CREATE TABLE startups (id INT, name TEXT, founded_year INT, industry TEXT, country TEXT, funding FLOAT);
What is the total funding raised by startups from Canada in 2020?
SELECT SUM(funding) FROM startups WHERE country = 'Canada' AND founded_year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE garments(id INT, garment_name VARCHAR(50), rating FLOAT, manufacturer_country VARCHAR(50)); INSERT INTO garments(id, garment_name, rating, manufacturer_country) VALUES (1, 'T-Shirt', 4.5, 'France'), (2, 'Jeans', 4.2, 'Italy');
What is the average rating of garments manufactured in France?
SELECT AVG(rating) FROM garments WHERE manufacturer_country = 'France';
gretelai_synthetic_text_to_sql
CREATE TABLE sales (sale_id INT, dish_name TEXT, category TEXT, quantity INT); INSERT INTO sales (sale_id, dish_name, category, quantity) VALUES (1, 'Spicy Quinoa', 'Vegan', 30), (2, 'Tofu Stir Fry', 'Vegan', 25), (3, 'Chickpea Curry', 'Vegan', 40), (4, 'Beef Burrito', 'Non-Veg', 50), (5, 'Chicken Alfredo', 'Non-Veg', ...
What are the total sales for each category?
SELECT category, SUM(quantity) FROM sales GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE restaurants (restaurant_id INT, name VARCHAR(50), cuisine VARCHAR(50), revenue INT); INSERT INTO restaurants VALUES (1, 'Asian Fusion', 'Asian', 5000), (2, 'Tuscan Bistro', 'Italian', 7000), (3, 'Baja Coast', 'Mexican', 4000), (4, 'Sushi House', 'Asian', 8000), (5, 'Pizzeria Rustica', 'Italian', 6000);
What is the minimum revenue earned by a restaurant in the 'Italian' cuisine category?
SELECT cuisine, MIN(revenue) FROM restaurants WHERE cuisine = 'Italian';
gretelai_synthetic_text_to_sql
CREATE TABLE CyberIncidents (company TEXT, incident_date DATE, state TEXT); INSERT INTO CyberIncidents (company, incident_date, state) VALUES ('Contractor X', '2021-02-01', 'California'), ('Contractor Y', '2021-10-15', 'California'), ('Contractor Z', '2021-12-30', 'New York');
How many cybersecurity incidents were reported by defense contractors in California in 2021?
SELECT COUNT(*) FROM CyberIncidents WHERE company LIKE '%defense%' AND state = 'California' AND incident_date BETWEEN '2021-01-01' AND '2021-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, Department VARCHAR(255), Salary INT); INSERT INTO Employees (EmployeeID, Department, Salary) VALUES (1, 'Marketing', 50000); INSERT INTO Employees (EmployeeID, Department, Salary) VALUES (2, 'Sales', 60000); INSERT INTO Employees (EmployeeID, Department, Salary) VALUES (3, 'Marke...
What is the total salary cost for each department, and the number of employees in that department?
SELECT E.Department, SUM(E.Salary) AS Total_Salary_Cost, COUNT(E.EmployeeID) AS Num_Employees FROM Employees E GROUP BY E.Department;
gretelai_synthetic_text_to_sql
CREATE SCHEMA IF NOT EXISTS public_transport;CREATE TABLE IF NOT EXISTS public_transport.passenger_count (count_id SERIAL PRIMARY KEY, route_id INTEGER, passenger_count INTEGER, count_date DATE);INSERT INTO public_transport.passenger_count (route_id, passenger_count, count_date) VALUES (101, 500, '2021-12-01'), (102, 3...
Display the passenger count for each route and day of the week in the 'passenger_count' table
SELECT EXTRACT(DOW FROM count_date) AS day_of_week, route_id, passenger_count FROM public_transport.passenger_count;
gretelai_synthetic_text_to_sql
CREATE TABLE ArtSales (artist VARCHAR(255), sale_price DECIMAL(10,2)); INSERT INTO ArtSales (artist, sale_price) VALUES ('Artist A', 5000), ('Artist A', 7000), ('Artist B', 6000), ('Artist B', 8000), ('Artist C', 9000), ('Artist C', 10000);
Find the artist with the highest total revenue from art sales.
SELECT artist, SUM(sale_price) as total_revenue FROM ArtSales GROUP BY artist ORDER BY total_revenue DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE AircraftProductionCost ( id INT, model VARCHAR(255), country VARCHAR(255), quantity INT, unit_cost DECIMAL(5,2)); INSERT INTO AircraftProductionCost (id, model, country, quantity, unit_cost) VALUES (1, 'F-15', 'USA', 100, 120.50), (2, 'F-16', 'France', 200, 145.20), (3, 'F-35', 'UK', 300, 189.90);
Which countries have the highest total production cost for aircraft models?
SELECT country, SUM(quantity * unit_cost) AS total_cost FROM AircraftProductionCost GROUP BY country ORDER BY total_cost DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE teacher_pd_courses (teacher_id INT, course_id INT, district_id INT); INSERT INTO teacher_pd_courses (teacher_id, course_id, district_id) VALUES (1, 1001, 101), (2, 1002, 101), (3, 1003, 101), (4, 1004, 102), (5, 1005, 103); CREATE TABLE courses (course_id INT, course_name VARCHAR(255)); INSERT INTO courses...
Which open pedagogy courses have been taken by teachers in district 102?
SELECT c.course_name FROM teacher_pd_courses t JOIN courses c ON t.course_id = c.course_id JOIN district_info d ON t.district_id = d.district_id WHERE t.district_id = 102 AND c.course_name LIKE 'Open%';
gretelai_synthetic_text_to_sql
CREATE TABLE Incidents (incident_id INT, incident_type VARCHAR(50), year INT, region_id INT); INSERT INTO Incidents (incident_id, incident_type, year, region_id) VALUES (1, 'Cybersecurity incident', 2020, 5), (2, 'Natural disaster', 2021, 5);
How many cybersecurity incidents were mitigated by the South American region in 2020?
SELECT COUNT(*) FROM Incidents WHERE incident_type = 'Cybersecurity incident' AND year = 2020 AND region_id = (SELECT region_id FROM Regions WHERE region_name = 'South American');
gretelai_synthetic_text_to_sql
CREATE TABLE players (player_id INT, name VARCHAR(50), age INT, position VARCHAR(50), team VARCHAR(50), assists INT);
What is the average number of assists for each position?
SELECT position, AVG(assists) FROM players GROUP BY position;
gretelai_synthetic_text_to_sql
CREATE TABLE crops (id INT, name VARCHAR(50), is_organic BOOLEAN); INSERT INTO crops (id, name, is_organic) VALUES (1, 'Corn', FALSE);
Insert new records into 'crops' table for organic corn and wheat varieties
INSERT INTO crops (id, name, is_organic) VALUES (2, 'Organic Corn', TRUE), (3, 'Organic Wheat', TRUE);
gretelai_synthetic_text_to_sql
CREATE TABLE marine_aquaculture_sites (site_id INT, certification VARCHAR(50)); INSERT INTO marine_aquaculture_sites VALUES (1, 'ASC'), (2, 'MSC'), (3, 'ASC'), (4, 'MSC'), (5, 'ASC'), (6, 'ASC');
Which sustainable seafood certifications are most common in marine aquaculture sites?
SELECT certification, COUNT(*) AS certification_count FROM marine_aquaculture_sites GROUP BY certification ORDER BY certification_count DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE eu_finance_ethical_ai (org_name TEXT, sector TEXT, budget_ethical_ai INT); INSERT INTO eu_finance_ethical_ai (org_name, sector, budget_ethical_ai) VALUES ('OrgE1', 'finance', 400000), ('OrgE2', 'finance', 500000), ('OrgE3', 'finance', 600000);
What is the average budget allocated for ethical AI initiatives by organizations in the financial sector in Europe?
SELECT AVG(budget_ethical_ai) FROM eu_finance_ethical_ai WHERE sector = 'finance';
gretelai_synthetic_text_to_sql
CREATE TABLE farm_certifications (id INT, farm_id INT, certification_type TEXT); INSERT INTO farm_certifications (id, farm_id, certification_type) VALUES (1, 1, 'Organic'), (2, 2, 'Conventional');
What is the percentage of organic farms in each country?
SELECT provinces.country, 100.0 * COUNT(farm_certifications.farm_id) FILTER (WHERE farm_certifications.certification_type = 'Organic') / COUNT(farm_certifications.farm_id) as organic_percentage FROM farm_certifications JOIN farms ON farm_certifications.farm_id = farms.id JOIN provinces ON farms.id = provinces.id GROUP ...
gretelai_synthetic_text_to_sql
CREATE TABLE battery_storage (id INT PRIMARY KEY, capacity FLOAT, warranty INT, manufacturer VARCHAR(255));
Delete records in the "battery_storage" table where the capacity is less than 50 kWh
DELETE FROM battery_storage WHERE capacity < 50;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_communication_initiatives (initiative_id INT, initiative_name VARCHAR(255), location VARCHAR(255), budget DECIMAL(10,2)); INSERT INTO climate_communication_initiatives (initiative_id, initiative_name, location, budget) VALUES (1, 'Climate Education in Brazil', 'Brazil', 2000000.00), (2, 'Public Awa...
What is the total budget for climate communication initiatives in South America?
SELECT SUM(budget) FROM climate_communication_initiatives WHERE location = 'South America';
gretelai_synthetic_text_to_sql
CREATE TABLE species (id INT, name VARCHAR(255), conservation_status VARCHAR(255));
List all marine species with a conservation status of 'Endangered' or 'Critically Endangered'
SELECT name FROM species WHERE conservation_status IN ('Endangered', 'Critically Endangered');
gretelai_synthetic_text_to_sql
CREATE TABLE posts (id INT, post_date DATE, comments INT); INSERT INTO posts (id, post_date, comments) VALUES (1, '2022-01-01', 10), (2, '2022-01-01', 20), (3, '2022-01-02', 30), (4, '2022-01-03', 40), (5, '2022-01-04', 50), (6, '2022-01-05', 60), (7, '2022-01-06', 70), (8, '2022-01-07', 80), (9, '2022-01-08', 90), (10...
What is the minimum number of comments for posts on 'Friday'?
SELECT MIN(comments) FROM posts WHERE DATE_FORMAT(post_date, '%W') = 'Friday';
gretelai_synthetic_text_to_sql
CREATE TABLE climate_communication_initiatives (initiative_id INT, initiative_name VARCHAR(255), location VARCHAR(255), budget DECIMAL(10,2)); INSERT INTO climate_communication_initiatives (initiative_id, initiative_name, location, budget) VALUES (1, 'Climate Education in USA', 'USA', 5000000.00), (2, 'Public Awareness...
What is the maximum budget for a climate communication initiative in North America?
SELECT MAX(budget) FROM climate_communication_initiatives WHERE location = 'North America';
gretelai_synthetic_text_to_sql
CREATE TABLE JobApplications (ApplicationID INT, JobTitle VARCHAR(50), Location VARCHAR(50), ApplicantName VARCHAR(50)); INSERT INTO JobApplications (ApplicationID, JobTitle, Location, ApplicantName) VALUES (1, 'Software Engineer', 'New York', 'John Doe'), (2, 'Software Engineer', 'Los Angeles', 'Jane Doe');
What is the total number of job applications received, broken down by job title and location?
SELECT JobTitle, Location, COUNT(*) FROM JobApplications GROUP BY JobTitle, Location;
gretelai_synthetic_text_to_sql
CREATE TABLE sea_ice_extent (month INT, year INT, extent FLOAT);
What is the minimum and maximum sea ice extent for each month?
SELECT month, MIN(extent), MAX(extent) FROM sea_ice_extent GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE Loans (LoanID int, LenderID int, Location varchar(50)); INSERT INTO Loans (LoanID, LenderID, Location) VALUES (1, 1, 'Africa'); CREATE TABLE Lenders (LenderID int, Name varchar(50), SociallyResponsible bit); INSERT INTO Lenders (LenderID, Name, SociallyResponsible) VALUES (1, 'Lender A', 1);
How many loans have been issued by socially responsible lenders in Africa?
SELECT COUNT(*) FROM Loans L INNER JOIN Lenders LE ON L.LenderID = LE.LenderID WHERE LE.SociallyResponsible = 1 AND L.Location = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species_at_risk (id INT, species VARCHAR(255), region VARCHAR(255)); INSERT INTO marine_species_at_risk (id, species, region) VALUES (1, 'Narwhal', 'Arctic'); INSERT INTO marine_species_at_risk (id, species, region) VALUES (2, 'Polar Bear', 'Arctic');
What is the total number of marine species at risk in the Arctic Ocean?
SELECT COUNT(DISTINCT species) FROM marine_species_at_risk WHERE region = 'Arctic';
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels (ID INT, Name VARCHAR(255), SafetyScore INT, Arrival DATETIME);
Insert a new record of the vessel 'Antarctic Pioneer' with a safety score of 97 and arrival date of '2022-02-27' if it doesn't exist.
INSERT INTO Vessels (Name, SafetyScore, Arrival) SELECT 'Antarctic Pioneer', 97, '2022-02-27' FROM (SELECT 1) AS Sub WHERE NOT EXISTS (SELECT 1 FROM Vessels WHERE Name = 'Antarctic Pioneer');
gretelai_synthetic_text_to_sql
CREATE TABLE health_data (region VARCHAR(50), Cancer INT, Heart_Disease INT); INSERT INTO health_data (region, Cancer, Heart_Disease) VALUES ('Northeast', 500, 700), ('Midwest', 400, 600), ('South', 800, 900), ('West', 300, 400);
Insert new records into the "health_data" table, unpivoting the data by region
INSERT INTO health_data (region, disease, cases) SELECT region, 'Cancer' AS disease, Cancer AS cases FROM health_data UNION ALL SELECT region, 'Heart Disease' AS disease, Heart_Disease AS cases FROM health_data;
gretelai_synthetic_text_to_sql