context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE young_forest (id INT, tree_type VARCHAR(255), planted_date DATE, age INT);
Find the minimum and maximum age of trees in the young_forest table.
SELECT MIN(age), MAX(age) FROM young_forest;
gretelai_synthetic_text_to_sql
CREATE TABLE tv_shows (id INT, name VARCHAR(100), genre VARCHAR(50), runtime INT);
What is the average runtime of all TV shows in the "tv_shows" table?
SELECT AVG(runtime) FROM tv_shows;
gretelai_synthetic_text_to_sql
CREATE TABLE DispensaryProducts (dispensary VARCHAR(255), city VARCHAR(255), organic BOOLEAN); INSERT INTO DispensaryProducts (dispensary, city, organic) VALUES ('Dispensary A', 'Los Angeles', TRUE), ('Dispensary A', 'Denver', FALSE), ('Dispensary B', 'Los Angeles', TRUE), ('Dispensary B', 'Denver', TRUE);
What is the percentage of dispensaries in each city that sell organic cannabis products?
SELECT city, COUNT(*) * 100.0 / (SELECT COUNT(*) FROM DispensaryProducts WHERE organic = TRUE) as percentage FROM DispensaryProducts WHERE organic = TRUE GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, FirstName VARCHAR(20), LastName VARCHAR(20), Department VARCHAR(20), Salary FLOAT); INSERT INTO Employees (EmployeeID, FirstName, LastName, Department, Salary) VALUES (1, 'John', 'Doe', 'Manufacturing', 50000); INSERT INTO Employees (EmployeeID, FirstName, LastName, Department, Salary) VALUES (2, 'Jane', 'Doe', 'Engineering', 65000); INSERT INTO Employees (EmployeeID, FirstName, LastName, Department, Salary) VALUES (3, 'Mike', 'Smith', 'Engineering', 70000);
What is the average salary of employees in the 'Engineering' department?
SELECT AVG(Salary) as 'Average Salary' FROM Employees WHERE Department = 'Engineering';
gretelai_synthetic_text_to_sql
CREATE TABLE grant_applications (id INT, status VARCHAR(10), department VARCHAR(50), amount DECIMAL(10,2));
Calculate the average grant amount for successful grant applications in the Engineering department.
SELECT AVG(amount) FROM grant_applications WHERE status = 'successful' AND department = 'Engineering';
gretelai_synthetic_text_to_sql
CREATE TABLE cases (case_id INT, region VARCHAR(20)); INSERT INTO cases (case_id, region) VALUES (1, 'Southern'), (2, 'Northern'), (3, 'Southern'), (4, 'Western'), (5, 'Eastern'); CREATE TABLE billing_info (bill_id INT, case_id INT, amount DECIMAL(10,2)); INSERT INTO billing_info (bill_id, case_id, amount) VALUES (1, 1, 500.00), (2, 1, 750.00), (3, 2, 1000.00), (4, 3, 200.00), (5, 4, 800.00);
What is the total billing amount for cases in the southern region?
SELECT SUM(billing_info.amount) FROM billing_info INNER JOIN cases ON billing_info.case_id = cases.case_id WHERE cases.region = 'Southern';
gretelai_synthetic_text_to_sql
CREATE TABLE SpaceMissions (id INT, mission_name VARCHAR(255), country VARCHAR(255), start_date DATE, end_date DATE, crew_size INT); INSERT INTO SpaceMissions (id, mission_name, country, start_date, end_date, crew_size) VALUES (1, 'International Space Station', 'United States', '1998-11-02', '2022-02-28', 6); INSERT INTO SpaceMissions (id, mission_name, country, start_date, end_date, crew_size) VALUES (2, 'Apollo 13', 'United States', '1970-04-11', '1970-04-17', 3); INSERT INTO SpaceMissions (id, mission_name, country, start_date, end_date, crew_size) VALUES (3, 'Soyuz T-15', 'Russia', '1986-03-13', '1986-07-16', 2);
List the space missions with the most crew members as of 2022
SELECT mission_name, crew_size as 'Crew Size' FROM SpaceMissions WHERE end_date IS NULL OR end_date >= '2022-01-01' ORDER BY 'Crew Size' DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Painting (id INT PRIMARY KEY, name VARCHAR(50), artist VARCHAR(50), date DATE); CREATE TABLE Drawing (id INT PRIMARY KEY, name VARCHAR(50), artist VARCHAR(50), date DATE);
What's the difference in the number of pieces between 'Painting' and 'Drawing' tables?
SELECT COUNT(*) FROM Painting EXCEPT SELECT COUNT(*) FROM Drawing;
gretelai_synthetic_text_to_sql
CREATE TABLE Transportation (project_id INT, project_name VARCHAR(255), project_type VARCHAR(255), length FLOAT);
Display the number of bridges and tunnels in the Transportation table
SELECT SUM(CASE WHEN project_type = 'Bridge' THEN 1 ELSE 0 END) AS bridges, SUM(CASE WHEN project_type = 'Tunnel' THEN 1 ELSE 0 END) AS tunnels FROM Transportation;
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, Name VARCHAR(50), Age INT, Game VARCHAR(50), Spending DECIMAL(5,2)); INSERT INTO Players (PlayerID, Name, Age, Game, Spending) VALUES (1, 'John Doe', 25, 'Galactic Conquest', 60.00); INSERT INTO Players (PlayerID, Name, Age, Game, Spending) VALUES (2, 'Jane Smith', 30, 'Galactic Conquest', 55.00); CREATE TABLE Transactions (TransactionID INT, PlayerID INT, Amount DECIMAL(5,2), TransactionDate DATE); INSERT INTO Transactions (TransactionID, PlayerID, Amount, TransactionDate) VALUES (1, 1, 50.00, '2022-01-01'); INSERT INTO Transactions (TransactionID, PlayerID, Amount, TransactionDate) VALUES (2, 1, 10.00, '2022-01-15'); INSERT INTO Transactions (TransactionID, PlayerID, Amount, TransactionDate) VALUES (3, 2, 55.00, '2022-01-05');
What is the average age of players who have played the game "Galactic Conquest" and spent more than $50 in the last month?
SELECT AVG(Players.Age) FROM Players INNER JOIN Transactions ON Players.PlayerID = Transactions.PlayerID WHERE Players.Game = 'Galactic Conquest' AND Transactions.Amount > 50.00 AND Transactions.TransactionDate >= DATEADD(month, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE Customers (CustomerID INT, TransactionDate DATE, TransactionAmount DECIMAL(10,2));
Calculate the total transaction amount for each customer in the "Customers" table, excluding transactions with amounts less than $100.
SELECT CustomerID, SUM(TransactionAmount) as TotalTransactionAmount FROM Customers WHERE TransactionAmount >= 100 GROUP BY CustomerID;
gretelai_synthetic_text_to_sql
CREATE TABLE platformG (artist_name TEXT, genre TEXT, streams BIGINT);
What are the names of the top 2 artists with the highest number of streams on the "platformG" platform, considering only the "rock" genre?
SELECT artist_name FROM platformG WHERE genre = 'rock' GROUP BY artist_name ORDER BY SUM(streams) DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE Permits (PermitID INT, ProjectID INT, PermitType CHAR(1), PermitDate DATE);
Insert a new building permit for a residential project in Texas with permit number 2023001 and a permit date of 2023-01-01.
INSERT INTO Permits (PermitID, ProjectID, PermitType, PermitDate) VALUES (2023001, NULL, 'R', '2023-01-01');
gretelai_synthetic_text_to_sql
CREATE TABLE faculty (faculty_id INT, faculty_name VARCHAR(255), faculty_gender VARCHAR(255), faculty_department VARCHAR(255)); CREATE TABLE publications (publication_id INT, faculty_id INT, publication_title VARCHAR(255), publication_date DATE);
Identify the top 5 most productive departments in terms of publications for female and non-binary faculty in the past 2 years.
SELECT f.faculty_department, COUNT(*) AS cnt FROM faculty f INNER JOIN publications p ON f.faculty_id = p.faculty_id WHERE f.faculty_gender IN ('Female', 'Non-binary') AND p.publication_date >= DATE_SUB(CURRENT_DATE, INTERVAL 2 YEAR) GROUP BY f.faculty_department ORDER BY cnt DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE community_education (id INT, program_name VARCHAR(50), enrollment INT); INSERT INTO community_education (id, program_name, enrollment) VALUES (1, 'Wildlife Conservation', 1500), (2, 'Biodiversity Awareness', 1200), (3, 'Climate Change Education', 1800);
What is the average enrollment for community education programs, rounded to the nearest integer?
SELECT ROUND(AVG(enrollment)) FROM community_education;
gretelai_synthetic_text_to_sql
CREATE TABLE DispensarySales(id INT, dispensary VARCHAR(255), state VARCHAR(255), strain_type VARCHAR(255), sales_amount DECIMAL(10,2));
Find the total sales of Indica and Sativa strains for each dispensary in Nevada.
SELECT dispensary, SUM(CASE WHEN strain_type = 'Indica' THEN sales_amount ELSE 0 END) + SUM(CASE WHEN strain_type = 'Sativa' THEN sales_amount ELSE 0 END) as total_sales FROM DispensarySales WHERE state = 'Nevada' GROUP BY dispensary;
gretelai_synthetic_text_to_sql
CREATE TABLE products(product_id VARCHAR(20), product_name VARCHAR(20), is_fair_trade BOOLEAN, price DECIMAL(5,2)); INSERT INTO products (product_id, product_name, is_fair_trade, price) VALUES ('Product E', 'Handmade Chocolates', true, 5.99), ('Product F', 'Recycled Notebooks', true, 12.99); CREATE TABLE sales(product_id VARCHAR(20), store_location VARCHAR(20), sale_date DATE, quantity INTEGER); INSERT INTO sales (product_id, store_location, sale_date, quantity) VALUES ('Product E', 'London', '2021-09-01', 20), ('Product F', 'London', '2021-10-01', 10);
What is the sum of revenue for fair trade products in London over the last quarter?
SELECT SUM(quantity * price) FROM products JOIN sales ON products.product_id = sales.product_id WHERE products.is_fair_trade = true AND sales.store_location = 'London' AND sale_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH) AND CURRENT_DATE;
gretelai_synthetic_text_to_sql
CREATE TABLE transaction_data (asset_name TEXT, transactions INT, transaction_volume REAL); INSERT INTO transaction_data (asset_name, transactions, transaction_volume) VALUES ('Cardano', 50000, 1000000);
What is the daily transaction volume of digital asset 'Cardano'?
SELECT SUM(transaction_volume) FROM transaction_data WHERE asset_name = 'Cardano' AND transaction_date = CURDATE();
gretelai_synthetic_text_to_sql
CREATE TABLE climate_data (id INT, region VARCHAR, year INT, temperature DECIMAL(5,2));
Find the average temperature per year for the Greenland region.
SELECT region, AVG(temperature) as avg_temperature FROM (SELECT region, year, temperature FROM climate_data WHERE region = 'Greenland' GROUP BY region, year) as subquery GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE Companies (id INT, name TEXT, country TEXT); CREATE TABLE Funding (id INT, company_id INT, investor_type TEXT, amount INT, funding_round TEXT); INSERT INTO Companies (id, name, country) VALUES (1, 'US Co', 'USA'); INSERT INTO Companies (id, name, country) VALUES (2, 'Canada Co', 'Canada'); INSERT INTO Funding (id, company_id, investor_type, amount, funding_round) VALUES (1, 1, 'Seed', 500000, 'Seed'), (2, 1, 'VC', 6000000, 'Series A'), (3, 2, 'Angel', 750000, 'Seed');
List the names of companies founded in the US or Canada that have received seed or series A funding.
SELECT Companies.name FROM Companies INNER JOIN Funding ON Companies.id = Funding.company_id WHERE Companies.country IN ('USA', 'Canada') AND (Funding.funding_round = 'Seed' OR Funding.funding_round = 'Series A')
gretelai_synthetic_text_to_sql
CREATE TABLE AgriculturalProjects (id INT, name VARCHAR(50), location VARCHAR(20), budget FLOAT, completion_date DATE);
Update the names of all agricultural projects in the 'Americas' region with the prefix 'Green'
UPDATE AgriculturalProjects SET name = CONCAT('Green ', name) WHERE location LIKE '%Americas%';
gretelai_synthetic_text_to_sql
CREATE TABLE wells (id INT, location VARCHAR(20), cost FLOAT); INSERT INTO wells (id, location, cost) VALUES (1, 'Gulf of Mexico', 7000000.0), (2, 'North Sea', 6000000.0), (3, 'Gulf of Mexico', 9000000.0);
Identify the top 3 most expensive wells in the Gulf of Mexico
SELECT location, cost FROM wells WHERE cost IN (SELECT * FROM (SELECT DISTINCT cost FROM wells WHERE location = 'Gulf of Mexico' ORDER BY cost DESC LIMIT 3) as subquery) ORDER BY cost DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE manufacturing_sites (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255)); CREATE TABLE safety_incidents (id INT PRIMARY KEY, site_id INT, incident_type VARCHAR(255), date DATE, FOREIGN KEY (site_id) REFERENCES manufacturing_sites(id));
How many safety incidents have occurred at each manufacturing site in the past six months?
SELECT manufacturing_sites.name, COUNT(safety_incidents.id) AS incident_count FROM manufacturing_sites INNER JOIN safety_incidents ON manufacturing_sites.id = safety_incidents.site_id WHERE safety_incidents.date >= DATEADD(month, -6, GETDATE()) GROUP BY manufacturing_sites.id;
gretelai_synthetic_text_to_sql
CREATE TABLE CommunityEvents (EventID INT, Date DATE, Type VARCHAR(50), Location VARCHAR(50));
How many community policing events were held in the last 30 days, broken down by type and location?
SELECT Type, Location, COUNT(*) as EventCount FROM CommunityEvents WHERE Date >= DATEADD(day, -30, GETDATE()) GROUP BY Type, Location;
gretelai_synthetic_text_to_sql
CREATE TABLE tokyo_metro (metro_id INT, ride_date DATE, is_accessible BOOLEAN, is_weekday BOOLEAN); INSERT INTO tokyo_metro (metro_id, ride_date, is_accessible, is_weekday) VALUES (1, '2021-01-01', TRUE, TRUE), (2, '2021-01-02', FALSE, FALSE);
Calculate the percentage of accessible metro rides in Tokyo by day of the week.
SELECT is_weekday, ROUND(100.0 * SUM(is_accessible) / COUNT(*), 2) AS accessibility_percentage FROM tokyo_metro GROUP BY is_weekday;
gretelai_synthetic_text_to_sql
CREATE TABLE barcelona_bikes (id INT, ride_id VARCHAR(20), start_time TIMESTAMP, end_time TIMESTAMP, bike_id INT);
List the 10 oldest bike-sharing trips in Barcelona.
SELECT * FROM barcelona_bikes ORDER BY start_time ASC LIMIT 10;
gretelai_synthetic_text_to_sql
CREATE TABLE Sourcing (id INT, material VARCHAR(20), country VARCHAR(20), quantity INT, year INT); INSERT INTO Sourcing (id, material, country, quantity, year) VALUES (1, 'Organic Cotton', 'India', 5000, 2020), (2, 'Recycled Polyester', 'China', 3000, 2020), (3, 'Organic Cotton', 'India', 5500, 2021), (4, 'Organic Cotton', 'China', 6000, 2021);
What is the total quantity of 'Organic Cotton' sourced from 'India' and 'China' in the year 2021?
SELECT SUM(quantity) FROM Sourcing WHERE material = 'Organic Cotton' AND (country = 'India' OR country = 'China') AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (hotel_id INT, name TEXT, country TEXT, is_eco_friendly BOOLEAN, rating FLOAT); INSERT INTO hotels (hotel_id, name, country, is_eco_friendly, rating) VALUES (1, 'Hotel EcoVista', 'Costa Rica', TRUE, 4.6), (2, 'Hotel Verde Playa', 'Costa Rica', TRUE, 4.3), (3, 'Hotel Playa Mar', 'Costa Rica', FALSE, 4.1);
What is the average hotel rating for eco-friendly accommodations in Costa Rica?
SELECT AVG(rating) FROM hotels WHERE is_eco_friendly = TRUE AND country = 'Costa Rica';
gretelai_synthetic_text_to_sql
CREATE TABLE defense_projects (id INT, project_name VARCHAR(255), start_date DATE, end_date DATE, budget DECIMAL(10,2), region VARCHAR(255)); INSERT INTO defense_projects (id, project_name, start_date, end_date, budget, region) VALUES (1, 'Project A', '2017-01-01', '2021-12-31', 60000000.00, 'Europe'), (2, 'Project B', '2019-01-01', '2023-12-31', 45000000.00, 'Asia-Pacific');
What are the defense project timelines for all projects with a budget greater than $50 million in Europe?
SELECT project_name, start_date, end_date FROM defense_projects WHERE budget > 50000000.00 AND region = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE Museums (MuseumID INT, MuseumName VARCHAR(50), Country VARCHAR(50)); CREATE TABLE ArtPieces (ArtPieceID INT, MuseumID INT, Value INT); INSERT INTO Museums VALUES (1, 'Museum of African Art', 'Morocco'), (2, 'National Museum of African Art', 'USA'), (3, 'South African National Art Gallery', 'South Africa'); INSERT INTO ArtPieces VALUES (1, 1, 5000), (2, 1, 7000), (3, 2, 8000), (4, 2, 9000), (5, 3, 11000), (6, 3, 13000);
What is the total number of art pieces and their average value in African museums?
SELECT COUNT(ArtPieces.ArtPieceID) AS TotalArtPieces, AVG(ArtPieces.Value) AS AvgValue FROM ArtPieces INNER JOIN Museums ON ArtPieces.MuseumID = Museums.MuseumID WHERE Museums.Country = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE Revenue (RevenueId INT, Platform VARCHAR(255), Genre VARCHAR(255), Revenue DECIMAL(10,2), Country VARCHAR(255), Date DATE); INSERT INTO Revenue (RevenueId, Platform, Genre, Revenue, Country, Date) VALUES (1, 'Spotify', 'Pop', 1000, 'USA', '2021-10-01'), (2, 'Apple Music', 'Pop', 1500, 'Canada', '2021-10-01'), (3, 'Deezer', 'Pop', 800, 'Mexico', '2021-10-01'), (4, 'Tidal', 'Pop', 1200, 'Brazil', '2021-10-01'), (5, 'Pandora', 'Pop', 1800, 'Argentina', '2021-10-01'), (6, 'Spotify', 'Pop', 1100, 'USA', '2021-11-01'), (7, 'Apple Music', 'Pop', 1600, 'Canada', '2021-11-01'), (8, 'Deezer', 'Pop', 900, 'Mexico', '2021-11-01'), (9, 'Tidal', 'Pop', 1300, 'Brazil', '2021-11-01'), (10, 'Pandora', 'Pop', 1900, 'Argentina', '2021-11-01'), (11, 'Spotify', 'Pop', 1200, 'USA', '2021-12-01'), (12, 'Apple Music', 'Pop', 1700, 'Canada', '2021-12-01'), (13, 'Deezer', 'Pop', 1000, 'Mexico', '2021-12-01'), (14, 'Tidal', 'Pop', 1400, 'Brazil', '2021-12-01'), (15, 'Pandora', 'Pop', 2000, 'Argentina', '2021-12-01');
Identify the top 3 countries with the highest total revenue for the 'Pop' genre in Q4 2021.
SELECT Country, Genre, SUM(Revenue) AS TotalRevenue FROM Revenue WHERE Genre = 'Pop' AND Date BETWEEN '2021-10-01' AND '2021-12-31' GROUP BY Country, Genre ORDER BY TotalRevenue DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE drilling (drill_id INT, well_id INT, drill_date DATE); INSERT INTO drilling (drill_id, well_id, drill_date) VALUES (6, 6, '2016-01-01'), (7, 7, '2017-01-01'), (8, 8, '2018-01-01'), (9, 9, '2019-01-01'), (10, 10, '2020-01-01');
How many wells were drilled in the Marcellus Shale each year?
SELECT EXTRACT(YEAR FROM drill_date) AS year, COUNT(*) AS num_wells FROM drilling GROUP BY year HAVING year IN (2016, 2017, 2018, 2019, 2020) AND location = 'Marcellus Shale';
gretelai_synthetic_text_to_sql
CREATE TABLE crime_data (id INT, type VARCHAR(255), location VARCHAR(255), reported_date DATE); INSERT INTO crime_data (id, type, location, reported_date) VALUES (1, 'Theft', 'Park', '2021-01-01');
What is the total number of crimes reported before January 15, 2021 in 'crime_data' table?
SELECT COUNT(*) FROM crime_data WHERE reported_date < '2021-01-15';
gretelai_synthetic_text_to_sql
CREATE TABLE athlete_wellbeing (athlete_id INT, name VARCHAR(50), age INT, sport VARCHAR(50)); INSERT INTO athlete_wellbeing (athlete_id, name, age, sport) VALUES (1, 'John Doe', 25, 'Basketball'); INSERT INTO athlete_wellbeing (athlete_id, name, age, sport) VALUES (2, 'Jane Smith', 28, 'Basketball'); INSERT INTO athlete_wellbeing (athlete_id, name, age, sport) VALUES (3, 'Jim Brown', 30, 'Football'); INSERT INTO athlete_wellbeing (athlete_id, name, age, sport) VALUES (4, 'Lucy Davis', 22, 'Football'); INSERT INTO athlete_wellbeing (athlete_id, name, age, sport) VALUES (5, 'Mark Johnson', 20, 'Hockey');
What is the minimum age of athletes in the 'athlete_wellbeing' table that play 'Hockey'?
SELECT MIN(age) FROM athlete_wellbeing WHERE sport = 'Hockey';
gretelai_synthetic_text_to_sql
CREATE TABLE ProjectTimeline (Id INT, ProjectId INT, Activity VARCHAR(50), StartDate DATE, EndDate DATE); INSERT INTO ProjectTimeline (Id, ProjectId, Activity, StartDate, EndDate) VALUES (1, 1, 'Design', '2019-09-01', '2019-12-31'); INSERT INTO ProjectTimeline (Id, ProjectId, Activity, StartDate, EndDate) VALUES (2, 2, 'Planning', '2018-12-01', '2019-03-31');
What are the details of projects that started before 2019-06-01?
SELECT * FROM ProjectTimeline WHERE StartDate < '2019-06-01';
gretelai_synthetic_text_to_sql
CREATE TABLE team_expenses (team_id INT, team_name VARCHAR(50), wellbeing_expenses DECIMAL(10, 2)); CREATE TABLE team_payments (payment_id INT, team_id INT, amount DECIMAL(10, 2));
List the total amount spent on athlete wellbeing programs for each sports team.
SELECT team_name, SUM(team_payments.amount) FROM team_expenses INNER JOIN team_payments ON team_expenses.team_id = team_payments.team_id GROUP BY team_name;
gretelai_synthetic_text_to_sql
CREATE TABLE charging_stations (id INT, city VARCHAR(20), operator VARCHAR(20), num_chargers INT, open_date DATE);
Add a new record to the 'charging_stations' table with id 2001, city 'San Francisco', operator 'Green Charge', num_chargers 10, open_date '2018-05-15'
INSERT INTO charging_stations (id, city, operator, num_chargers, open_date) VALUES (2001, 'San Francisco', 'Green Charge', 10, '2018-05-15');
gretelai_synthetic_text_to_sql
CREATE TABLE Transactions (tx_id INT, contract_name VARCHAR(255), asset_name VARCHAR(255), tx_value DECIMAL(10,2), tx_date DATE); INSERT INTO Transactions (tx_id, contract_name, asset_name, tx_value, tx_date) VALUES (1, 'SmartContract1', 'ETH', 100.50, '2021-09-01'); INSERT INTO Transactions (tx_id, contract_name, asset_name, tx_value, tx_date) VALUES (2, 'SmartContract2', 'BTC', 200.75, '2022-01-01');
What was the total value of transactions for 'SmartContract2' that involved the 'BTC' digital asset, excluding transactions before 2022?
SELECT SUM(tx_value) FROM Transactions WHERE contract_name = 'SmartContract2' AND asset_name = 'BTC' AND tx_date >= '2022-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE player (player_id INT, player_name VARCHAR(50), age INT, country VARCHAR(50), plays_vr BOOLEAN); INSERT INTO player (player_id, player_name, age, country, plays_vr) VALUES (1, 'John Doe', 25, 'USA', FALSE); INSERT INTO player (player_id, player_name, age, country, plays_vr) VALUES (2, 'Jane Smith', 19, 'Canada', TRUE); INSERT INTO player (player_id, player_name, age, country, plays_vr) VALUES (3, 'Bob Johnson', 22, 'USA', TRUE); INSERT INTO player (player_id, player_name, age, country, plays_vr) VALUES (4, 'Alice Davis', 24, 'Mexico', FALSE);
List all countries and the percentage of players who play VR games.
SELECT country, (COUNT(plays_vr)*100.0/ (SELECT COUNT(*) FROM player)) as vr_percentage FROM player WHERE plays_vr = TRUE GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE global_health (donor_id INTEGER, donation_date DATE, organization_name TEXT); INSERT INTO global_health (donor_id, donation_date, organization_name) VALUES (1, '2022-01-01', 'Malaria Consortium'), (2, '2022-02-01', 'Schistosomiasis Control Initiative');
How many unique donors have contributed to the 'global_health' sector in the last 6 months?
SELECT COUNT(DISTINCT donor_id) FROM global_health WHERE donation_date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) AND organization_name LIKE '%global_health%';
gretelai_synthetic_text_to_sql
CREATE TABLE vehicle (vehicle_id INT, model VARCHAR(255), year INT, route_id INT, last_maintenance DATE); INSERT INTO vehicle (vehicle_id, model, year, route_id, last_maintenance) VALUES (3, 'Bus A', 2019, 3, '2022-01-01'); INSERT INTO vehicle (vehicle_id, model, year, route_id, last_maintenance) VALUES (4, 'Train B', 2017, 4, '2021-12-15');
How many vehicles of each model and year are due for maintenance, i.e., have not been maintained in the last 60 days?
SELECT model, year, COUNT(*) as vehicles_due_for_maintenance FROM vehicle WHERE DATEDIFF(CURDATE(), last_maintenance) > 60 GROUP BY model, year;
gretelai_synthetic_text_to_sql
CREATE TABLE ethical_fashion (product_id INT, product_type VARCHAR(50), region VARCHAR(50), material_type VARCHAR(50), price DECIMAL(5,2)); INSERT INTO ethical_fashion (product_id, product_type, region, material_type, price) VALUES (1, 'Ethical Fashion', 'Europe', 'Recycled Polyester', 50.00), (2, 'Ethical Fashion', 'Asia', 'Organic Cotton', 60.00), (3, 'Ethical Fashion', 'North America', 'Tencel', 70.00);
What is the average price of ethical fashion products made from sustainable materials in each region?
SELECT region, AVG(price) FROM ethical_fashion WHERE product_type = 'Ethical Fashion' AND material_type IN ('Recycled Polyester', 'Organic Cotton', 'Tencel') GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE GeneticResearch (id INT, gene_name VARCHAR(255), chromosome INT, research_type VARCHAR(255)); INSERT INTO GeneticResearch (id, gene_name, chromosome, research_type) VALUES (1, 'GeneA', 1, 'Genomic Imprinting'); INSERT INTO GeneticResearch (id, gene_name, chromosome, research_type) VALUES (2, 'GeneB', 2, 'Epigenetics');
Which genetic research has not reached chromosomes 19, 20, 21, X, or Y?
SELECT gene_name, research_type FROM GeneticResearch WHERE chromosome NOT IN (19, 20, 21, 22, X, Y);
gretelai_synthetic_text_to_sql
CREATE TABLE investment_portfolios (portfolio_id INT, client_id INT, portfolio_date DATE, region VARCHAR(50)); INSERT INTO investment_portfolios (portfolio_id, client_id, portfolio_date, region) VALUES (1, 1, '2021-01-10', 'North'); INSERT INTO investment_portfolios (portfolio_id, client_id, portfolio_date, region) VALUES (2, 2, '2021-02-20', 'South'); INSERT INTO investment_portfolios (portfolio_id, client_id, portfolio_date, region) VALUES (3, 3, '2021-03-05', 'East');
How many investment portfolios were opened in Q1 2021, by region?
SELECT region, COUNT(*) as num_portfolios FROM investment_portfolios WHERE portfolio_date >= '2021-01-01' AND portfolio_date < '2021-04-01' GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE old_network_investments (id INT PRIMARY KEY, location TEXT, investment_amount INT, date DATE);
Create a table to archive old network infrastructure investments
CREATE TABLE old_network_investments AS SELECT * FROM network_investments WHERE date < (CURRENT_DATE - INTERVAL '1 year');
gretelai_synthetic_text_to_sql
CREATE TABLE judicial_workload (judge_id INT, year INT, cases_heard INT);
What is the maximum number of cases heard by a judge in a year?
SELECT MAX(cases_heard) FROM judicial_workload;
gretelai_synthetic_text_to_sql
CREATE TABLE agricultural_projects (id INT, province VARCHAR(50), cost FLOAT, project_type VARCHAR(50), start_date DATE, end_date DATE); INSERT INTO agricultural_projects (id, province, cost, project_type, start_date, end_date) VALUES (1, 'Saskatchewan', 60000.00, 'Precision Agriculture', '2020-01-01', '2020-12-31');
What was the total cost of agricultural innovation projects in the province of Saskatchewan in 2020?
SELECT SUM(cost) FROM agricultural_projects WHERE province = 'Saskatchewan' AND start_date <= '2020-12-31' AND end_date >= '2020-01-01' AND project_type = 'Precision Agriculture';
gretelai_synthetic_text_to_sql
CREATE TABLE nyc_inspections (inspection_id INT, borough VARCHAR(20), violation_date DATE, fine_amount INT);
What is the moving average of food safety inspection violation counts for the last 12 months for each borough in New York City?
SELECT borough, AVG(violation_count) as moving_average FROM (SELECT borough, DATEADD(month, DATEDIFF(month, 0, violation_date), 0) as month, COUNT(*) as violation_count FROM nyc_inspections GROUP BY borough, month) AS subquery WHERE month >= DATEADD(month, -12, GETDATE()) GROUP BY borough;
gretelai_synthetic_text_to_sql
CREATE TABLE mines (id INT, name VARCHAR(20)); INSERT INTO mines (id, name) VALUES (1, 'Golden Mine'), (2, 'Silver Mine'); CREATE TABLE calendar (year INT); INSERT INTO calendar (year) VALUES (2020), (2021), (2022); CREATE TABLE mine_production (mine_id INT, year INT, volume INT); INSERT INTO mine_production (mine_id, year, volume) VALUES (1, 2020, 1000), (1, 2021, 1200), (2, 2022, 1500);
Show the total production volume for each mine and year in the "mine_production", "mines", and "calendar" tables
SELECT m.name, c.year, SUM(mp.volume) as total_volume FROM mines m JOIN mine_production mp ON m.id = mp.mine_id JOIN calendar c ON mp.year = c.year GROUP BY m.name, c.year;
gretelai_synthetic_text_to_sql
CREATE TABLE material_waste (region VARCHAR(50), material VARCHAR(50), waste_metric INT); INSERT INTO material_waste (region, material, waste_metric) VALUES ('Asia', 'Plastic', 3000), ('Asia', 'Paper', 2000), ('Asia', 'Metal', 1000);
What percentage of waste is generated from plastic, paper, and metal materials in the 'Asia' region?
SELECT 100.0 * SUM(CASE WHEN material IN ('Plastic', 'Paper', 'Metal') THEN waste_metric ELSE 0 END) / SUM(waste_metric) AS percentage FROM material_waste WHERE region = 'Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE peacekeeping_operations (id INT PRIMARY KEY, operation_name VARCHAR(50), country VARCHAR(50), status VARCHAR(50)); INSERT INTO peacekeeping_operations (id, operation_name, country, status) VALUES (7, 'Operation Harmony', 'Sudan', 'Active'), (8, 'Operation Unity', 'South Sudan', 'Planning');
Update the status of peacekeeping operations for a specific country in the peacekeeping_operations table.
WITH upd_data AS (UPDATE peacekeeping_operations SET status = 'Completed' WHERE country = 'Sudan' RETURNING *) UPDATE peacekeeping_operations SET status = 'Completed' WHERE id IN (SELECT id FROM upd_data);
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT, product_id INT, category VARCHAR(50), quantity INT, price DECIMAL(10,2)); INSERT INTO sales (id, product_id, category, quantity, price) VALUES (1, 1, 'Electronics', 10, 50.00), (2, 2, 'Machinery', 5, 1000.00), (3, 3, 'Electronics', 8, 75.00);
What was the total revenue for each product category in Q1 2021?
SELECT category, SUM(quantity * price) as total_revenue FROM sales WHERE DATE_FORMAT(order_date, '%Y-%m') BETWEEN '2021-01-01' AND '2021-03-31' GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE solar_farms (farm_name VARCHAR(255), country VARCHAR(255), capacity FLOAT); INSERT INTO solar_farms (farm_name, country, capacity) VALUES ('Desert Sunlight', 'US', 550), ('Solar Star', 'US', 579), ('Longyangxia Dam Solar Park', 'CN', 850), ('Tengger Desert Solar Park', 'CN', 1547), ('Topaz Solar Farm', 'US', 550), ('Huanghe Hydropower Hainan Solar Park', 'CN', 2000), ('Ladakh Solar Farm', 'IN', 1500), ('Bhadla Solar Park', 'IN', 2245), ('Pokhran Solar Park', 'IN', 4000), ('Enel Green Power South Africa', 'ZA', 82.5);
List the top 3 countries with the highest solar power capacity (in MW)?
SELECT country, SUM(capacity) as total_capacity FROM solar_farms GROUP BY country ORDER BY total_capacity DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE social_equity_dispensaries (dispensary_id INT, name VARCHAR(255), city VARCHAR(255), state VARCHAR(255), open_date DATE); INSERT INTO social_equity_dispensaries (dispensary_id, name, city, state, open_date) VALUES (1, 'Dispensary 1', 'Los Angeles', 'CA', '2022-04-01');
Which social equity dispensaries were added in Los Angeles in Q2 2022?
SELECT * FROM social_equity_dispensaries WHERE city = 'Los Angeles' AND open_date BETWEEN '2022-04-01' AND '2022-06-30';
gretelai_synthetic_text_to_sql
CREATE TABLE satellites (id INT, name TEXT, launch_date DATE, manufacturer TEXT); INSERT INTO satellites (id, name, launch_date, manufacturer) VALUES (1, 'Dragon', '2012-05-25', 'SpaceX');
What is the name and launch date of the satellites launched by SpaceX?
SELECT name, launch_date FROM satellites WHERE manufacturer = 'SpaceX';
gretelai_synthetic_text_to_sql
CREATE TABLE customer_accounts (customer_id INT, account_id INT, account_type TEXT); INSERT INTO customer_accounts (customer_id, account_id, account_type) VALUES (1, 1, 'High Value'); INSERT INTO customer_accounts (customer_id, account_id, account_type) VALUES (1, 2, 'Premium'); INSERT INTO customer_accounts (customer_id, account_id, account_type) VALUES (2, 3, 'Standard');
Which customers have accounts in both the 'High Value' and 'Premium' categories?
SELECT customer_id FROM customer_accounts WHERE account_type = 'High Value' INTERSECT SELECT customer_id FROM customer_accounts WHERE account_type = 'Premium';
gretelai_synthetic_text_to_sql
CREATE TABLE economic_diversification (country VARCHAR(50), quarter INT, score FLOAT); INSERT INTO economic_diversification (country, quarter, score) VALUES ('Nigeria', 3, 6.2), ('South Africa', 3, 8.5), ('Egypt', 3, 7.1), ('Kenya', 3, 5.9), ('Ghana', 3, 6.8), ('Morocco', 3, 7.6);
What was the average economic diversification score for African countries in Q3 2017?
SELECT AVG(score) as avg_score FROM economic_diversification WHERE country IN ('Nigeria', 'South Africa', 'Egypt', 'Kenya', 'Ghana', 'Morocco') AND quarter = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Landfills (id INT, area VARCHAR(20), capacity INT); INSERT INTO Landfills (id, area, capacity) VALUES (1, 'Rural', 3000);
What is the minimum landfill capacity in the 'Rural' area?
SELECT MIN(capacity) FROM Landfills WHERE area = 'Rural';
gretelai_synthetic_text_to_sql
CREATE TABLE Regions (id INT, name VARCHAR(255)); INSERT INTO Regions (id, name) VALUES (1, 'North'), (2, 'South'), (3, 'East'), (4, 'West'); CREATE TABLE Sales (id INT, region_id INT, quarter INT, year INT, revenue INT); INSERT INTO Sales (id, region_id, quarter, year, revenue) VALUES (1, 1, 2, 2021, 5000), (2, 2, 2, 2021, 6000), (3, 3, 2, 2021, 7000), (4, 4, 2, 2021, 8000);
What was the total revenue for each region in Q2 of 2021?
SELECT r.name, SUM(s.revenue) FROM Sales s JOIN Regions r ON s.region_id = r.id WHERE s.quarter = 2 AND s.year = 2021 GROUP BY r.name;
gretelai_synthetic_text_to_sql
CREATE TABLE Policy_Advocacy (advocacy_id INT, region VARCHAR(20), budget DECIMAL(10, 2), year INT); INSERT INTO Policy_Advocacy (advocacy_id, region, budget, year) VALUES (1, 'Southeast', 5000, 2020), (2, 'Northwest', 6000, 2019);
What was the average budget for policy advocacy in the "Southeast" region in 2020?
SELECT AVG(budget) FROM Policy_Advocacy WHERE region = 'Southeast' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE DonorTransactions (DonorID INT, Amount DECIMAL(10,2), DonorCountry TEXT, TransactionYear INT); INSERT INTO DonorTransactions (DonorID, Amount, DonorCountry, TransactionYear) VALUES (1, 500.00, 'India', 2020), (2, 300.00, 'USA', 2021), (3, 250.00, 'China', 2020);
What is the average amount donated by donors from Asia in the year 2020?
SELECT AVG(Amount) FROM DonorTransactions WHERE DonorCountry LIKE 'Asi%' AND TransactionYear = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE startups(id INT, name TEXT, founding_year INT, founder_refugee BOOLEAN); CREATE TABLE exits(id INT, startup_id INT, exit_type TEXT, exit_value FLOAT); INSERT INTO startups (id, name, founding_year, founder_refugee) VALUES (1, 'Acme Inc', 2010, false); INSERT INTO startups (id, name, founding_year, founder_refugee) VALUES (2, 'Beta Corp', 2015, true); INSERT INTO startups (id, name, founding_year, founder_refugee) VALUES (3, 'Gamma LLC', 2020, false); INSERT INTO exits (id, startup_id, exit_type, exit_value) VALUES (1, 1, 'Acquisition', 10000000); INSERT INTO exits (id, startup_id, exit_type, exit_value) VALUES (2, 3, 'IPO', 50000000); INSERT INTO exits (id, startup_id, exit_type, exit_value) VALUES (3, 2, 'Acquisition', 7500000);
Show the total number of exits made by startups founded by refugees
SELECT COUNT(*) FROM startups s JOIN exits e ON s.id = e.startup_id WHERE s.founder_refugee = true;
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, gender VARCHAR(10), signup_date DATE); INSERT INTO users (id, gender, signup_date) VALUES (1, 'Female', '2020-01-05');
What is the average heart rate of female users during their morning workouts in the month of January?
SELECT AVG(hr) FROM workout_data w JOIN users u ON w.user_id = u.id WHERE u.gender = 'Female' AND HOUR(w.timestamp) BETWEEN 6 AND 12 AND MONTH(w.timestamp) = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE camps (camp_id INT, name VARCHAR(50)); INSERT INTO camps (camp_id, name) VALUES (1, 'Camp A'), (2, 'Camp B'), (3, 'Camp C'); CREATE TABLE supplies (supply_id INT, camp_id INT, type VARCHAR(50), quantity INT); INSERT INTO supplies (supply_id, camp_id, type, quantity) VALUES (1, 1, 'Medical Supplies', 500), (2, 1, 'Food Supplies', 1000), (3, 2, 'Medical Supplies', 800), (4, 3, 'Food Supplies', 1200), (5, 2, 'Food Supplies', 900), (6, 3, 'Medical Supplies', 700)
What is the total number of medical and food supplies delivered to each camp?
SELECT c.name, SUM(CASE WHEN s.type = 'Medical Supplies' THEN s.quantity ELSE 0 END) AS total_medical_supplies, SUM(CASE WHEN s.type = 'Food Supplies' THEN s.quantity ELSE 0 END) AS total_food_supplies FROM supplies s JOIN camps c ON s.camp_id = c.camp_id GROUP BY c.name
gretelai_synthetic_text_to_sql
CREATE TABLE mitigation_initiatives (country VARCHAR(50), start_year INT, end_year INT, initiative_type VARCHAR(50)); INSERT INTO mitigation_initiatives (country, start_year, end_year, initiative_type) VALUES ('Brazil', 2015, 2018, 'Reforestation'), ('Colombia', 2016, 2018, 'Clean Transportation');
How many climate mitigation initiatives were implemented in South America between 2015 and 2018?
SELECT COUNT(*) FROM mitigation_initiatives WHERE country IN (SELECT name FROM countries WHERE region = 'South America') AND start_year <= 2018 AND end_year >= 2015;
gretelai_synthetic_text_to_sql
CREATE TABLE cost (id INT, product VARCHAR(255), cruelty_free BOOLEAN, price FLOAT, region VARCHAR(255)); INSERT INTO cost (id, product, cruelty_free, price, region) VALUES (1, 'Lipstick', false, 12.99, 'France'), (2, 'Mascara', true, 8.99, 'Germany'), (3, 'Eyeliner', false, 9.99, 'France');
What is the average price of cosmetics products that are not cruelty-free and were sold in Europe?
SELECT AVG(price) FROM cost WHERE cruelty_free = false AND region = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE cultural_competency_training (id INT, provider_id INT, program_name VARCHAR(100), program_date DATE); INSERT INTO cultural_competency_training (id, provider_id, program_name, program_date) VALUES (1, 456, 'Cultural Sensitivity 101', '2021-02-01'), (2, 456, 'Working with Diverse Communities', '2021-03-15'); CREATE TABLE healthcare_providers (id INT, name VARCHAR(50), region VARCHAR(50)); INSERT INTO healthcare_providers (id, name, region) VALUES (456, 'Jane Smith', 'New York'), (789, 'Alex Brown', 'New Jersey');
List all unique cultural competency training programs offered by providers in New York and New Jersey.
SELECT DISTINCT program_name FROM cultural_competency_training INNER JOIN healthcare_providers ON cultural_competency_training.provider_id = healthcare_providers.id WHERE healthcare_providers.region IN ('New York', 'New Jersey');
gretelai_synthetic_text_to_sql
CREATE TABLE electricity_consumption (building_type VARCHAR(50), state VARCHAR(50), year INT, month INT, consumption FLOAT); INSERT INTO electricity_consumption (building_type, state, year, month, consumption) VALUES ('Residential', 'Texas', 2020, 1, 1000), ('Residential', 'Texas', 2020, 2, 1200), ('Residential', 'Texas', 2020, 3, 1100), ('Residential', 'Texas', 2020, 4, 1300), ('Residential', 'Texas', 2020, 5, 1400), ('Residential', 'Texas', 2020, 6, 1200), ('Residential', 'Texas', 2020, 7, 1300), ('Residential', 'Texas', 2020, 8, 1500), ('Residential', 'Texas', 2020, 9, 1400), ('Residential', 'Texas', 2020, 10, 1100), ('Residential', 'Texas', 2020, 11, 900), ('Residential', 'Texas', 2020, 12, 800);
What is the average monthly electricity consumption for residential buildings in Texas?
SELECT AVG(consumption) FROM electricity_consumption WHERE building_type = 'Residential' AND state = 'Texas';
gretelai_synthetic_text_to_sql
CREATE TABLE digital_assets (asset_name VARCHAR(255), developer VARCHAR(255), market_cap FLOAT); INSERT INTO digital_assets (asset_name, developer, market_cap) VALUES ('Bitcoin', 'Satoshi Nakamoto', 900.5); INSERT INTO digital_assets (asset_name, developer, market_cap) VALUES ('Stellar', 'Stellar Devs', 350.2);
What are the top 2 digital assets by market capitalization, excluding those developed by Stellar?
SELECT asset_name, developer, market_cap FROM (SELECT asset_name, developer, market_cap, ROW_NUMBER() OVER (ORDER BY market_cap DESC) as row_num FROM digital_assets WHERE developer != 'Stellar Devs') tmp WHERE row_num <= 2;
gretelai_synthetic_text_to_sql
CREATE TABLE articles (title VARCHAR(255), author VARCHAR(255), date DATE, topic VARCHAR(255));
What is the total number of articles published by female authors in the articles table?
SELECT COUNT(*) FROM articles WHERE author IN ('Alice', 'Bella', 'Charlotte');
gretelai_synthetic_text_to_sql
CREATE TABLE community_population (id INT, community VARCHAR(255), population INT); INSERT INTO community_population (id, community, population) VALUES (1, 'Inuit', 700), (2, 'Samí', 300);
How many communities have a population size greater than 500 in the 'community_population' table?
SELECT COUNT(*) FROM community_population WHERE population > 500;
gretelai_synthetic_text_to_sql
CREATE TABLE emergency_calls (id INT, call_time TIMESTAMP, district VARCHAR(20)); INSERT INTO emergency_calls (id, call_time, district) VALUES (1, '2022-01-01 10:30:00', 'Downtown'), (2, '2022-01-02 15:45:00', 'Uptown');
What was the average response time for emergency calls in January 2022 for the 'Downtown' district?
SELECT AVG(EXTRACT(HOUR FROM call_time) * 60 + EXTRACT(MINUTE FROM call_time)) AS avg_response_time FROM emergency_calls WHERE district = 'Downtown' AND call_time >= '2022-01-01' AND call_time < '2022-02-01';
gretelai_synthetic_text_to_sql
CREATE TABLE users (user_id INT, username VARCHAR(20), email VARCHAR(50), follower_count INT); CREATE TABLE posts (post_id INT, user_id INT, content TEXT, post_time TIMESTAMP); CREATE TABLE comments (comment_id INT, post_id INT, user_id INT, comment TEXT, comment_time TIMESTAMP); CREATE TABLE reactions (reaction_id INT, post_id INT, user_id INT, reaction VARCHAR(10), reaction_time TIMESTAMP);
Create a view named user_activity that displays the number of posts, comments, and reactions made by each user.
CREATE VIEW user_activity AS SELECT u.username, COUNT(p.post_id) AS posts, COUNT(c.comment_id) AS comments, COUNT(r.reaction_id) AS reactions FROM users u LEFT JOIN posts p ON u.user_id = p.user_id LEFT JOIN comments c ON u.user_id = c.user_id LEFT JOIN reactions r ON u.user_id = r.user_id GROUP BY u.username;
gretelai_synthetic_text_to_sql
CREATE TABLE european_sites (id INT, site_name VARCHAR(50), artifact_name VARCHAR(50), weight INT);
Minimum weight of artifacts in 'european_sites'
SELECT MIN(weight) FROM european_sites;
gretelai_synthetic_text_to_sql
CREATE TABLE defense_contractors_2 (corp varchar(255), sales int); INSERT INTO defense_contractors_2 (corp, sales) VALUES ('ABC Corp', 1000000), ('DEF Corp', 1200000), ('GHI Corp', 1500000), ('JKL Corp', 1100000), ('MNO Corp', 1300000);
What was the total military equipment sales revenue for the defense industry in 2021?
SELECT SUM(sales) FROM defense_contractors_2;
gretelai_synthetic_text_to_sql
CREATE SCHEMA IF NOT EXISTS intelligence_operations; CREATE TABLE IF NOT EXISTS ops_budget (id INT PRIMARY KEY, region TEXT, budget DECIMAL(10, 2)); INSERT INTO ops_budget (id, region, budget) VALUES (1, 'Asia', 20000000.00), (2, 'Europe', 15000000.00), (3, 'Africa', 10000000.00);
What is the maximum budget allocated for intelligence operations in the 'Asia' region?
SELECT budget FROM intelligence_operations.ops_budget WHERE region = 'Asia' AND budget = (SELECT MAX(budget) FROM intelligence_operations.ops_budget WHERE region = 'Asia');
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (DonationID int, DonationDate date, Country varchar(20)); INSERT INTO Donations (DonationID, DonationDate, Country) VALUES (1, '2021-01-01', 'USA'), (2, '2021-02-01', 'Canada'), (3, '2021-03-01', 'Mexico');
What is the percentage of donations received from each country in the last 6 months?
SELECT Country, COUNT(*) * 100.0 / (SELECT COUNT(*) FROM Donations WHERE DonationDate >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH)) as Percentage FROM Donations WHERE DonationDate >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, HireDate DATE);
Identify the number of employees who were hired in each month, ranked by the number of new hires in descending order.
SELECT MONTH(HireDate) AS Month, COUNT(*) AS NewHires FROM Employees GROUP BY MONTH(HireDate) ORDER BY NewHires DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE samarium_prices (continent VARCHAR(10), price DECIMAL(5,2), year INT); INSERT INTO samarium_prices (continent, price, year) VALUES ('Europe', 180.00, 2020), ('Europe', 185.00, 2019), ('Europe', 175.00, 2018);
What is the average price of samarium produced in Europe?
SELECT AVG(price) FROM samarium_prices WHERE continent = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (hotel_id INT, hotel_name TEXT, country TEXT, num_virtual_tours INT, rating FLOAT); INSERT INTO hotels (hotel_id, hotel_name, country, num_virtual_tours, rating) VALUES (1, 'Hotel X', 'USA', 120, 4.2), (2, 'Hotel Y', 'USA', 50, 3.9), (3, 'Hotel Z', 'USA', 150, 4.6);
What is the average rating of hotels in the United States that have more than 100 virtual tours?
SELECT AVG(rating) FROM hotels WHERE country = 'USA' AND num_virtual_tours > 100;
gretelai_synthetic_text_to_sql
CREATE TABLE aid_agencies (country VARCHAR(50), aid_received INT);
Determine the total aid received by countries in Africa, excluding Egypt, from all aid agencies.
SELECT country, SUM(aid_received) AS total_aid FROM aid_agencies WHERE country != 'Egypt' AND country LIKE '%Africa%' GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE plants (id INT, name TEXT, energy_source TEXT); INSERT INTO plants (id, name, energy_source) VALUES (1, 'manufacturing', 'renewable'), (2, 'assembly', 'non-renewable');
How many 'renewable' energy sources are used in the 'manufacturing' plant?
SELECT COUNT(*) FROM plants WHERE name = 'manufacturing' AND energy_source = 'renewable';
gretelai_synthetic_text_to_sql
CREATE TABLE media_library (id INT, title TEXT, genre TEXT, disinformation_topic TEXT); INSERT INTO media_library (id, title, genre, disinformation_topic) VALUES (1, 'Media1', 'Drama', 'TopicA'), (2, 'Media2', 'Comedy', 'TopicB');
What is the distribution of disinformation topics in the media library?
SELECT disinformation_topic, COUNT(*) as count FROM media_library GROUP BY disinformation_topic;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (species_id INT, species_name VARCHAR(255)); CREATE TABLE ocean_acidification (ocean_id INT, species_id INT, ocean VARCHAR(50)); INSERT INTO marine_species (species_id, species_name) VALUES (1, 'Polar Bear'), (2, 'Narwhal'); INSERT INTO ocean_acidification (ocean_id, species_id, ocean) VALUES (1, 1, 'Arctic'), (2, 2, 'Atlantic');
Which marine species are affected by ocean acidification in the Arctic Ocean?
SELECT marine_species.species_name FROM marine_species INNER JOIN ocean_acidification ON marine_species.species_id = ocean_acidification.species_id WHERE ocean_acidification.ocean = 'Arctic';
gretelai_synthetic_text_to_sql
CREATE TABLE members (member_id INT, name VARCHAR(50), gender VARCHAR(10), dob DATE); INSERT INTO members (member_id, name, gender, dob) VALUES (1, 'Ella Thompson', 'Female', '2004-05-14'); INSERT INTO members (member_id, name, gender, dob) VALUES (2, 'Frederick Johnson', 'Male', '2003-12-20'); CREATE TABLE workout_sessions (session_id INT, member_id INT, session_date DATE, duration INT); INSERT INTO workout_sessions (session_id, member_id, session_date, duration) VALUES (1, 1, '2023-03-02', 45); INSERT INTO workout_sessions (session_id, member_id, session_date, duration) VALUES (2, 1, '2023-03-05', 60); INSERT INTO workout_sessions (session_id, member_id, session_date, duration) VALUES (3, 2, '2023-03-07', 75); INSERT INTO workout_sessions (session_id, member_id, session_date, duration) VALUES (4, 1, '2023-03-13', 30);
What is the total duration of workout sessions for each member in March 2023?
SELECT member_id, SUM(duration) AS total_duration_march_2023 FROM workout_sessions WHERE MONTH(session_date) = 3 AND YEAR(session_date) = 2023 GROUP BY member_id;
gretelai_synthetic_text_to_sql
CREATE TABLE solana_assets (asset_address VARCHAR(44), asset_name VARCHAR(50));
How many unique digital assets are there on the Solana blockchain?
SELECT COUNT(DISTINCT asset_address) FROM solana_assets;
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (id INT PRIMARY KEY, name TEXT, region_id INT, hours_per_week DECIMAL(3,1)); INSERT INTO volunteers (id, name, region_id, hours_per_week) VALUES (1, 'Alice', 1, 15.0); INSERT INTO volunteers (id, name, region_id, hours_per_week) VALUES (2, 'Bob', 1, 8.5); INSERT INTO volunteers (id, name, region_id, hours_per_week) VALUES (3, 'Carol', 2, 22.5);
Which volunteers have contributed more than 10 hours per week on average?
SELECT name FROM volunteers WHERE hours_per_week > (SELECT AVG(hours_per_week) FROM volunteers);
gretelai_synthetic_text_to_sql
CREATE TABLE Farm (id INT, name VARCHAR(50), country VARCHAR(50)); CREATE TABLE Species (id INT, name VARCHAR(50), scientific_name VARCHAR(50), farm_id INT);
Find the number of different species of fish in each aquaculture farm.
SELECT f.name, COUNT(DISTINCT s.id) FROM Farm f JOIN Species s ON f.id = s.farm_id GROUP BY f.name;
gretelai_synthetic_text_to_sql
CREATE TABLE waste_generation (location VARCHAR(50), waste_type VARCHAR(50), generation INT);
Insert new record into waste_generation table for location 'Tokyo' and waste generation 300 tons
INSERT INTO waste_generation (location, waste_type, generation) VALUES ('Tokyo', 'plastic', 300);
gretelai_synthetic_text_to_sql
CREATE TABLE SpaceOdysseyPlayers (PlayerID INT, PlayerName VARCHAR(50), PlaytimeMinutes INT, Rank VARCHAR(10)); INSERT INTO SpaceOdysseyPlayers VALUES (1, 'JimBrown', 600, 'Diamond'), (2, 'KarenGreen', 400, 'Gold'), (3, 'OliverWhite', 900, 'Diamond'), (4, 'SamBlack', 500, 'Platinum');
How many players have achieved a rank of Diamond or higher in the game "Space Odyssey"?
SELECT COUNT(*) FROM SpaceOdysseyPlayers WHERE Rank IN ('Diamond', 'Master');
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, Gender VARCHAR(10), Salary DECIMAL(10,2), Department VARCHAR(50)); INSERT INTO Employees (EmployeeID, Gender, Salary, Department) VALUES (1, 'Female', 85000.00, 'IT'), (2, 'Male', 95000.00, 'Marketing'), (3, 'Non-binary', 70000.00, 'HR'), (4, 'Female', 80000.00, 'IT'), (5, 'Male', 90000.00, 'Marketing'), (6, 'Female', 87000.00, 'IT');
What is the maximum salary for employees who identify as male and work in the marketing department?
SELECT MAX(e.Salary) as MaxSalary FROM Employees e WHERE e.Gender = 'Male' AND e.Department = 'Marketing';
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, HireDate DATE, Department VARCHAR(50)); INSERT INTO Employees (EmployeeID, HireDate, Department) VALUES (1, '2018-01-01', 'HR'), (2, '2020-03-15', 'IT'), (3, '2019-08-25', 'IT'), (4, '2020-11-04', 'HR');
What is the total number of employees hired in the year 2020, grouped by their department?
SELECT Department, COUNT(*) FROM Employees WHERE YEAR(HireDate) = 2020 GROUP BY Department;
gretelai_synthetic_text_to_sql
CREATE TABLE safety_incidents (chemical VARCHAR(20), incident_date DATE); INSERT INTO safety_incidents VALUES ('chemical B', '2021-12-15'); INSERT INTO safety_incidents VALUES ('chemical C', '2022-02-01');
Identify safety incidents involving chemical B in the past year.
SELECT * FROM safety_incidents WHERE chemical = 'chemical B' AND incident_date BETWEEN DATEADD(year, -1, GETDATE()) AND GETDATE();
gretelai_synthetic_text_to_sql
CREATE TABLE research_papers (id INT, title VARCHAR(100), publication_year INT, abstract TEXT); INSERT INTO research_papers (id, title, publication_year, abstract) VALUES (1, 'Deep Learning for Autonomous Driving', 2021, 'In this paper, we propose a deep learning approach for autonomous driving...'), (2, 'Motion Planning for Autonomous Vehicles', 2020, 'In this paper, we propose a motion planning algorithm for autonomous vehicles...'), (3, 'Simulation for Autonomous Driving Testing', 2022, 'In this paper, we propose a simulation-based testing framework for autonomous driving...');
What is the number of autonomous driving research papers published in the research_papers table for each year?
SELECT publication_year, COUNT(*) FROM research_papers GROUP BY publication_year;
gretelai_synthetic_text_to_sql
CREATE TABLE Movies (title VARCHAR(255), release_year INT, budget INT); INSERT INTO Movies (title, release_year, budget) VALUES ('Movie1', 2015, 50000000), ('Movie2', 2016, 75000000), ('Movie3', 2017, 60000000), ('Movie4', 2018, 80000000), ('Movie5', 2019, 90000000);
What is the release year of the first movie with a budget over 70 million?
SELECT release_year FROM Movies WHERE budget > 70000000 ORDER BY release_year ASC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE biosensor_tech(id INT, project_name TEXT, budget DECIMAL(10,2), quarter INT, year INT);
What is the maximum budget for biosensor technology development projects in Q2 2021?
SELECT MAX(budget) FROM biosensor_tech WHERE quarter = 2 AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE JobApplications (ApplicationID INT, ApplicationDate DATE, JobCategory VARCHAR(255)); INSERT INTO JobApplications (ApplicationID, ApplicationDate, JobCategory) VALUES (1, '2022-01-01', 'Software Engineer'), (2, '2022-02-15', 'Data Analyst');
How many job applicants were there in the last 6 months, broken down by job category?
SELECT MONTH(ApplicationDate) AS Month, JobCategory, COUNT(*) FROM JobApplications WHERE ApplicationDate >= DATEADD(MONTH, -6, GETDATE()) GROUP BY JobCategory, MONTH(ApplicationDate);
gretelai_synthetic_text_to_sql
CREATE TABLE union_membership (id INT, member_name VARCHAR(255), join_date DATE, is_new_member BOOLEAN);
Add new union member records for the month of April in the Midwestern region.
INSERT INTO union_membership (id, member_name, join_date, is_new_member) VALUES (6, 'Member F', '2022-04-01', true), (7, 'Member G', '2022-04-15', true);
gretelai_synthetic_text_to_sql
CREATE TABLE Urban_Hotels (hotel_id INT, hotel_name TEXT, rating INT); INSERT INTO Urban_Hotels (hotel_id, hotel_name, rating) VALUES (1, 'Hotel Paris', 4), (2, 'New York Palace', 5);
How many hotels in the 'Urban_Hotels' table have a rating of 4 or higher?
SELECT COUNT(*) FROM Urban_Hotels WHERE rating >= 4;
gretelai_synthetic_text_to_sql
CREATE TABLE Esports_Players (Player_ID INT, Event_Date DATE);
How many players have participated in esports events in the last 6 months from the 'Esports_Players' table?
SELECT COUNT(*) FROM Esports_Players WHERE Event_Date >= DATE(NOW()) - INTERVAL 6 MONTH;
gretelai_synthetic_text_to_sql