context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE DroughtImpact (Id INT PRIMARY KEY, City VARCHAR(255), Impact FLOAT, Date DATE); INSERT INTO DroughtImpact (Id, City, Impact, Date) VALUES (1, 'San Francisco', 0.15, '2022-01-30'); INSERT INTO DroughtImpact (Id, City, Impact, Date) VALUES (2, 'Los Angeles', 0.20, '2022-01-30'); INSERT INTO DroughtImpact (Id...
What is the average drought impact for cities in California on January 30, 2022?
SELECT City, AVG(Impact) FROM DroughtImpact WHERE Date = '2022-01-30' AND City IN ('San Francisco', 'Los Angeles', 'San Diego') GROUP BY City HAVING COUNT(*) > 1;
gretelai_synthetic_text_to_sql
CREATE SCHEMA news;CREATE TABLE NewsSource (name varchar(255), type varchar(10));CREATE TABLE Region (name varchar(255), location varchar(10));INSERT INTO NewsSource (name, type) VALUES ('NewsSourceA', 'news'), ('NewsSourceB', 'news'), ('NewsSourceC', 'opinion'), ('NewsSourceD', 'news'), ('NewsSourceE', 'opinion');INSE...
What is the total number of articles and opinion pieces published by news sources in the eastern region, excluding articles published by NewsSourceD?
SELECT COUNT(*) FROM ( (SELECT * FROM news.NewsSource WHERE type = 'news' AND location = 'eastern') EXCEPT (SELECT * FROM news.NewsSource WHERE name = 'NewsSourceD') ) AS eastern_news
gretelai_synthetic_text_to_sql
CREATE TABLE Inventory (ItemID INT, Name VARCHAR(50), Quantity INT, VendorID INT, Sustainable BOOLEAN); INSERT INTO Inventory (ItemID, Name, Quantity, VendorID, Sustainable) VALUES (1, 'Box', 10, 1, true), (2, 'Bag', 20, 1, true), (3, 'Container', 30, 2, false);
What is the total weight of sustainable packaging materials used by each vendor?
SELECT VendorID, SUM(Quantity) FROM Inventory WHERE Sustainable = true GROUP BY VendorID;
gretelai_synthetic_text_to_sql
CREATE TABLE safety_incidents (country VARCHAR(20), incident_type VARCHAR(20), incident_count INT); INSERT INTO safety_incidents (country, incident_type, incident_count) VALUES ('USA', 'autonomous_vehicle', 3), ('Canada', 'autonomous_vehicle', 1), ('USA', 'AI_assistant', 2);
What is the number of AI safety incidents recorded for each country in the 'safety_incidents' table?
SELECT country, incident_type, SUM(incident_count) as total_incidents FROM safety_incidents GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE power_plants (id INT, name VARCHAR(255), type VARCHAR(255), capacity INT, location VARCHAR(255)); INSERT INTO power_plants (id, name, type, capacity, location) VALUES (1, 'La Grande-1', 'Hydro', 2730, 'Canada'); INSERT INTO power_plants (id, name, type, capacity, location) VALUES (2, 'Three Gorges', 'Hydro...
What is the total hydroelectric power plant capacity in 'Brazil' from the 'power_plants' table?
SELECT SUM(capacity) FROM power_plants WHERE type = 'Hydro' AND location = 'Brazil';
gretelai_synthetic_text_to_sql
CREATE TABLE PRODUCT ( id INT PRIMARY KEY, name TEXT, material TEXT, quantity INT, price INT, country TEXT, certifications TEXT, is_recycled BOOLEAN ); INSERT INTO PRODUCT (id, name, material, quantity, price, country, certifications, is_recycled) VALUES (1, 'Organic Cotton Shirt', 'Organic Cotton', 30, 50, 'USA', 'GOT...
Delete all products that are made from materials other than recycled polyester, recycled cotton, or bamboo.
DELETE FROM PRODUCT WHERE material NOT IN ('Recycled Polyester', 'Recycled Cotton', 'Bamboo');
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers( supplier_id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), sustainability_score INT); INSERT INTO suppliers (supplier_id, name, location, sustainability_score) VALUES (1, 'Supplier A', 'City A', 80);
Insert data into 'suppliers' table
INSERT INTO suppliers (supplier_id, name, location, sustainability_score) VALUES (2, 'Supplier B', 'City B', 85);
gretelai_synthetic_text_to_sql
CREATE TABLE teacher_pd (teacher_id INT, course_id INT, course_type VARCHAR(255));
Insert a new professional development course 'Diversity Training' of type 'Webinar' for teacher with ID 678.
INSERT INTO teacher_pd (teacher_id, course_id, course_type) VALUES (678, 'Diversity Training', 'Webinar');
gretelai_synthetic_text_to_sql
CREATE TABLE education (id INT, name VARCHAR(50), community VARCHAR(20));
List all the education records for underrepresented communities.
SELECT * FROM education WHERE community IN ('Latinx', 'Black', 'Indigenous');
gretelai_synthetic_text_to_sql
CREATE TABLE cricket_teams (team_id INT, team_name VARCHAR(50)); INSERT INTO cricket_teams (team_id, team_name) VALUES (1, 'Mumbai Indians'), (2, 'Chennai Super Kings'), (3, 'Kolkata Knight Riders'); CREATE TABLE cricket_matches (match_id INT, team_id INT, match_date DATE, result VARCHAR(10)); CREATE TABLE fan_demograp...
Identify cricket teams with the highest number of wins in the last 3 months and their corresponding fan demographics.
SELECT ct.team_name, COUNT(cm.match_id) as wins_in_last_3_months, AVG(fd.age) as avg_age, fd.gender FROM cricket_teams ct JOIN cricket_matches cm ON ct.team_id = cm.team_id JOIN fan_demographics_cricket fd ON ct.team_id = fd.team_id WHERE cm.match_date >= DATEADD(month, -3, GETDATE()) AND cm.result = 'Win' GROUP BY ct....
gretelai_synthetic_text_to_sql
CREATE TABLE players (id INT PRIMARY KEY, name TEXT, team TEXT, position TEXT, three_pointers_scored INT, games_played INT); INSERT INTO players (id, name, team, position, three_pointers_scored, games_played) VALUES (1, 'Stephen Curry', 'Golden State Warriors', 'Point Guard', 138, 33), (2, 'Buddy Hield', 'Sacramento Ki...
Find the total number of three-pointers scored by each player in the NBA
SELECT name, three_pointers_scored FROM players;
gretelai_synthetic_text_to_sql
CREATE TABLE GlobalContributions (id INT, contributor VARCHAR(50), project VARCHAR(50), continent VARCHAR(50), amount FLOAT); INSERT INTO GlobalContributions (id, contributor, project, continent, amount) VALUES (1, 'John Smith', 'Pyramids Restoration', 'Africa', 1000000), (2, 'Anna Lee', 'Great Wall Restoration', 'Asia...
Who are the top 2 contributors to heritage site preservation globally and their total contributions?
SELECT contributor, SUM(amount) AS total_contributions FROM GlobalContributions GROUP BY contributor ORDER BY total_contributions DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE Programs (ProgramID INT, Name TEXT, Budget DECIMAL); INSERT INTO Programs (ProgramID, Name, Budget) VALUES (1, 'Education Support', 5000); INSERT INTO Programs (ProgramID, Name, Budget) VALUES (2, 'Senior Care', 7000);
Update the program name for program ID 2 to 'Youth Mentoring'.
UPDATE Programs SET Name = 'Youth Mentoring' WHERE ProgramID = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_name VARCHAR(50), is_cruelty_free BOOLEAN); INSERT INTO products (product_name, is_cruelty_free) VALUES ('Clean Slate', true), ('Eye Have You', false); CREATE TABLE ingredient_sources (product_name VARCHAR(50), ingredient_source VARCHAR(50)); INSERT INTO ingredient_sources (product_name, ...
What are the names of all cruelty-free certified products and their corresponding ingredient sources?
SELECT products.product_name, ingredient_sources.ingredient_source FROM products JOIN ingredient_sources ON products.product_name = ingredient_sources.product_name WHERE products.is_cruelty_free = true;
gretelai_synthetic_text_to_sql
CREATE TABLE zip_codes (zip_code VARCHAR(10), city VARCHAR(50)); INSERT INTO zip_codes (zip_code, city) VALUES ('12345', 'Anytown'), ('23456', 'Othertown'), ('34567', 'Sometown'); CREATE TABLE providers (provider_id INT, name VARCHAR(50), zip_code VARCHAR(10)); INSERT INTO providers (provider_id, name, zip_code) VALUES...
Delete records in the "providers" table where the "zip_code" is not present in the "zip_codes" table
DELETE FROM providers WHERE zip_code NOT IN (SELECT zip_code FROM zip_codes);
gretelai_synthetic_text_to_sql
CREATE TABLE landfill_capacities (city TEXT, capacity_cubic_meters INT, date DATE); INSERT INTO landfill_capacities (city, capacity_cubic_meters, date) VALUES ('Accra', 100000, '2023-02-16');
What is the current landfill capacity in cubic meters for the city of Accra?
SELECT capacity_cubic_meters FROM landfill_capacities WHERE city = 'Accra' AND date = (SELECT MAX(date) FROM landfill_capacities WHERE city = 'Accra');
gretelai_synthetic_text_to_sql
CREATE TABLE employees (id INT, name VARCHAR(50), department VARCHAR(50), hire_date DATE); INSERT INTO employees (id, name, department, hire_date) VALUES (1, 'John Doe', 'IT', '2021-03-01'), (2, 'Jane Smith', 'Marketing', '2021-07-15'), (3, 'Mike Johnson', 'IT', '2021-02-12'), (4, 'Sara Connor', 'Marketing', '2021-10-0...
Show the number of employees hired in each quarter of the year, broken down by department.
SELECT department, DATE_TRUNC('quarter', hire_date) AS hire_quarter, COUNT(*) AS num_hires FROM employees GROUP BY department, hire_quarter;
gretelai_synthetic_text_to_sql
CREATE TABLE Countries (Country VARCHAR(255), AvgScore FLOAT); INSERT INTO Countries (Country, AvgScore) VALUES ('United States', 80.1), ('Japan', 72.3), ('Brazil', 78.9), ('Canada', 76.2), ('Germany', 73.5);
Which countries have an average player score in the game "Starship Siege" above 75?
SELECT Country FROM Countries WHERE AvgScore > 75;
gretelai_synthetic_text_to_sql
CREATE TABLE charging_stations (id INT PRIMARY KEY, station_name VARCHAR(255), location VARCHAR(255), num_charging_ports INT);
Create a table for electric vehicle charging stations
CREATE TABLE electric_charging_stations (id INT PRIMARY KEY, station_name VARCHAR(255), location VARCHAR(255), num_charging_ports INT);
gretelai_synthetic_text_to_sql
CREATE TABLE movies (id INT, title VARCHAR(255), release_year INT, views INT, country VARCHAR(50)); INSERT INTO movies (id, title, release_year, views, country) VALUES (1, 'Movie1', 2010, 10000, 'USA'), (2, 'Movie2', 2015, 15000, 'USA'); CREATE TABLE tv_shows (id INT, title VARCHAR(255), release_year INT, views INT, co...
What is the total view count for all movies and TV shows produced in the US?
SELECT SUM(views) FROM movies WHERE country = 'USA' UNION SELECT SUM(views) FROM tv_shows WHERE country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE programs (program_id INT, lender_id INT, sector VARCHAR(20), is_financial_wellbeing BOOLEAN); INSERT INTO programs (program_id, lender_id, sector, is_financial_wellbeing) VALUES (1, 1, 'financial', true), (2, 1, 'technology', false), (3, 2, 'financial', false), (4, 2, 'technology', true);
List all the financial wellbeing programs offered by lenders in the technology sector.
SELECT program_id FROM programs WHERE sector = 'technology' AND is_financial_wellbeing = true;
gretelai_synthetic_text_to_sql
CREATE TABLE student (id INT, program TEXT, gpa REAL); INSERT INTO student (id, program, gpa) VALUES (1, 'cs', 3.8), (2, 'cs', 3.9), (3, 'cs', 4.0);
What is the maximum GPA of graduate students in the 'cs' program?
SELECT MAX(gpa) FROM student WHERE program = 'cs';
gretelai_synthetic_text_to_sql
CREATE TABLE Concerts (concert_id INT, concert_name VARCHAR(255), location VARCHAR(255), year INT, marketing_budget INT); INSERT INTO Concerts (concert_id, concert_name, location, year, marketing_budget) VALUES (1, 'Concert A', 'New York', 2019, 500000), (2, 'Concert B', 'Toronto', 2020, 600000), (3, 'Concert C', 'Sao ...
What is the average marketing budget for Latin American concerts since 2019?
SELECT AVG(marketing_budget) FROM Concerts WHERE year >= 2019 AND location LIKE 'Latin%';
gretelai_synthetic_text_to_sql
CREATE TABLE AIModels (model_name TEXT, confidence FLOAT, country TEXT); INSERT INTO AIModels (model_name, confidence, country) VALUES ('ModelA', 0.85, 'UAE'), ('ModelB', 0.92, 'Saudi Arabia'), ('ModelC', 0.78, 'Israel');
What is the average confidence score for AI models in the Middle East, grouped by country?
SELECT country, AVG(confidence) FROM AIModels WHERE country IN ('UAE', 'Saudi Arabia', 'Israel') GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE CommunityOutreach (id INT, program VARCHAR(50), year INT, visits INT); INSERT INTO CommunityOutreach (id, program, year, visits) VALUES (1, 'Summer Camp', 2022, 250), (2, 'Senior Tour', 2022, 300), (3, 'Education Day', 2021, 400), (4, 'Youth Tour', 2021, 500);
Find the total number of visits for each community outreach program in 2021.
SELECT program, SUM(visits) FROM CommunityOutreach WHERE year = 2021 GROUP BY program
gretelai_synthetic_text_to_sql
CREATE TABLE SatelliteLaunches (LaunchID INT, Country VARCHAR(50), Success BOOLEAN); INSERT INTO SatelliteLaunches (LaunchID, Country, Success) VALUES (1, 'USA', true); INSERT INTO SatelliteLaunches (LaunchID, Country, Success) VALUES (2, 'China', true); INSERT INTO SatelliteLaunches (LaunchID, Country, Success) VALUES...
Calculate the percentage of successful satellite launches for each country, sorted by the most successful.
SELECT Country, COUNT(*) * 100.0 / SUM(COUNT(*)) OVER () AS Success_Percentage, RANK() OVER (ORDER BY COUNT(*) * 100.0 / SUM(COUNT(*)) OVER () DESC) AS Launch_Success_Rank FROM SatelliteLaunches GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE CaseTypes (CaseID INT, CaseType VARCHAR(50), BillingAmount DECIMAL(10,2)); INSERT INTO CaseTypes (CaseID, CaseType, BillingAmount) VALUES (1, 'Civil', 1000.00), (2, 'Criminal', 2000.00), (3, 'Civil', 3000.00);
What is the total billing amount for each case type?
SELECT CaseType, SUM(BillingAmount) AS TotalBilling FROM CaseTypes GROUP BY CaseType;
gretelai_synthetic_text_to_sql
CREATE TABLE exhibitions (id INT, name VARCHAR(255), price DECIMAL(5,2)); INSERT INTO exhibitions (id, name, price) VALUES (1, 'Art Deco', 15.99);
Increase the ticket price by 10% for the 'Art Deco' exhibition
WITH updated AS (UPDATE exhibitions SET price = price * 1.10 WHERE name = 'Art Deco') SELECT * FROM updated;
gretelai_synthetic_text_to_sql
CREATE TABLE organic_produce_shipments (shipment_id INT, shipment_date DATE, weight INT, product VARCHAR(255), country VARCHAR(255), is_organic BOOLEAN);
Calculate the average weight of all shipments of organic produce from Mexico in the organic_produce_shipments table.
SELECT AVG(weight) FROM organic_produce_shipments WHERE is_organic = true AND country = 'Mexico';
gretelai_synthetic_text_to_sql
CREATE TABLE union_members (id INT, name VARCHAR(50), state VARCHAR(2), city VARCHAR(20), occupation VARCHAR(20)); INSERT INTO union_members (id, name, state, city, occupation) VALUES (1, 'John Doe', 'NY', 'New York', 'Engineer'); INSERT INTO union_members (id, name, state, city, occupation) VALUES (2, 'Jane Smith', 'C...
Update "union_members" table where the "id" is 2
UPDATE union_members SET state = 'WA', city = 'Seattle' WHERE id = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (id INT, name TEXT, country TEXT); CREATE TABLE volunteer_hours (id INT, volunteer_id INT, hours INT);
Show the number of volunteers and total hours per country in 'volunteers' and 'volunteer_hours' tables.
SELECT v.country, COUNT(v.id) AS num_volunteers, SUM(vh.hours) AS total_hours FROM volunteers v INNER JOIN volunteer_hours vh ON v.id = vh.volunteer_id GROUP BY v.country;
gretelai_synthetic_text_to_sql
CREATE TABLE donors (donor_id INT, donor_name TEXT, donation_amount DECIMAL(10,2), country TEXT); INSERT INTO donors (donor_id, donor_name, donation_amount, country) VALUES (1, 'John Doe', 500.00, 'United States'); INSERT INTO donors (donor_id, donor_name, donation_amount, country) VALUES (2, 'Jane Smith', 300.00, 'Can...
What is the minimum donation amount from donors living in 'South Africa'?
SELECT MIN(donation_amount) FROM donors WHERE country = 'South Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE vehicles (vehicle_id INT, vehicle_type VARCHAR(255), last_maintenance_date DATE); INSERT INTO vehicles (vehicle_id, vehicle_type, last_maintenance_date) VALUES (1001, 'Bus', '2022-05-15'), (1002, 'Train', '2022-04-01'), (1003, 'Wheelchair Accessible Bus', '2022-05-28');
How many wheelchair accessible vehicles were serviced in the month of May?
SELECT COUNT(*) FROM vehicles WHERE vehicle_type LIKE '%Wheelchair%' AND last_maintenance_date BETWEEN '2022-05-01' AND '2022-05-31';
gretelai_synthetic_text_to_sql
CREATE TABLE students (student_id INT, student_name VARCHAR(50), grade_level INT, prefers_open_pedagogy BOOLEAN); INSERT INTO students (student_id, student_name, grade_level, prefers_open_pedagogy) VALUES (1, 'John Doe', 9, true), (2, 'Jane Smith', 10, false);
What is the percentage of students who prefer open pedagogy in each grade level?
SELECT grade_level, AVG(CAST(prefers_open_pedagogy AS FLOAT)) * 100 AS percentage FROM students GROUP BY grade_level;
gretelai_synthetic_text_to_sql
CREATE TABLE austin_properties(id INT, address TEXT, affordability_rating INT); INSERT INTO austin_properties(id, address, affordability_rating) VALUES (1, '123 Main St', 5);
Update affordability ratings for Austin properties.
UPDATE austin_properties SET affordability_rating = 6 WHERE address = '123 Main St';
gretelai_synthetic_text_to_sql
CREATE TABLE PlayerGames (PlayerID INT, GameID INT, GameWon BOOLEAN); CREATE TABLE Games (GameID INT, GameName VARCHAR(255)); INSERT INTO Games (GameID, GameName) VALUES (1, 'GameX'), (2, 'GameY'), (3, 'GameZ');
Find the number of players who have played game Y and game Z in the 'PlayerGames' and 'Games' tables
SELECT COUNT(DISTINCT PlayerID) as PlayersPlayedBoth FROM PlayerGames JOIN Games ON PlayerGames.GameID = Games.GameID WHERE Games.GameName IN ('GameY', 'GameZ') GROUP BY Games.GameName HAVING COUNT(DISTINCT Games.GameName) = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE dapps (dapp_id INT, name VARCHAR(255), network VARCHAR(255), creation_date DATE); INSERT INTO dapps (dapp_id, name, network, creation_date) VALUES (1, 'App1', 'binance', '2022-01-01'), (2, 'App2', 'polygon', '2021-12-31');
What are the names of the decentralized applications in the 'binance' network that were not created before 2021?
SELECT name FROM dapps WHERE network = 'binance' AND creation_date > '2021-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE lifelong_learners (learner_id INT, last_course_date DATE); INSERT INTO lifelong_learners (learner_id, last_course_date) VALUES (1, '2022-03-01'), (2, '2022-01-15'), (3, '2021-12-31'), (4, '2022-04-10'); CREATE TABLE courses (course_date DATE); INSERT INTO courses (course_date) VALUES ('2022-01-01'), ('2022...
What is the percentage of lifelong learners who have completed at least one course in the past year?
SELECT COUNT(DISTINCT lifelong_learners.learner_id) as total_learners, COUNT(DISTINCT CASE WHEN lifelong_learners.last_course_date >= DATEADD(year, -1, GETDATE()) THEN lifelong_learners.learner_id END) as eligible_learners, CAST(COUNT(DISTINCT CASE WHEN lifelong_learners.last_course_date >= DATEADD(year, -1, GETDATE())...
gretelai_synthetic_text_to_sql
CREATE TABLE Events (ID INT PRIMARY KEY, Title TEXT, Date DATE, Location TEXT, Attendees INT);
Display the title and date of events with more than 1000 attendees
SELECT Title, Date FROM Events WHERE Attendees > 1000;
gretelai_synthetic_text_to_sql
CREATE TABLE EcoFriendlyDyeProducts (product_id INT, is_eco_friendly_dye BOOLEAN); INSERT INTO EcoFriendlyDyeProducts (product_id, is_eco_friendly_dye) VALUES (1, true), (2, false), (3, true); CREATE TABLE Products (product_id INT, region VARCHAR(50)); INSERT INTO Products (product_id, region) VALUES (1, 'Asia'), (2, '...
How many products are made with eco-friendly dyes in Asia?
SELECT COUNT(EcoFriendlyDyeProducts.product_id) FROM EcoFriendlyDyeProducts INNER JOIN Products ON EcoFriendlyDyeProducts.product_id = Products.product_id WHERE Products.region = 'Asia' AND EcoFriendlyDyeProducts.is_eco_friendly_dye = true;
gretelai_synthetic_text_to_sql
CREATE TABLE clients (id INT, name VARCHAR(50), location VARCHAR(50), financial_capability_score FLOAT);
Determine the average financial capability score for clients living in urban areas.
SELECT AVG(financial_capability_score) FROM clients WHERE location LIKE '%urban%';
gretelai_synthetic_text_to_sql
CREATE TABLE TotalBudget (Program VARCHAR(50), Budget DECIMAL(10,2), BudgetDate DATE); INSERT INTO TotalBudget (Program, Budget, BudgetDate) VALUES ('Feeding the Homeless', 4000, '2022-01-01'), ('Tree Planting', 2000, '2022-01-01');
What was the total budget allocated for all programs in H1 2022?
SELECT SUM(Budget) as TotalBudget FROM TotalBudget WHERE BudgetDate BETWEEN '2022-01-01' AND '2022-06-30';
gretelai_synthetic_text_to_sql
CREATE TABLE Products (productID INT, productName VARCHAR(50), price DECIMAL(10,2), fairTrade BOOLEAN, country VARCHAR(50));
What is the average cost of fair trade coffee beans in Colombia?
SELECT AVG(price) FROM Products WHERE productName = 'coffee beans' AND fairTrade = TRUE AND country = 'Colombia';
gretelai_synthetic_text_to_sql
CREATE TABLE languages (id INT, name VARCHAR(50), location VARCHAR(50), speakers INT, status VARCHAR(50), PRIMARY KEY(id)); INSERT INTO languages (id, name, location, speakers, status) VALUES (1, 'Yoruba', 'Nigeria, Africa', 40000000, 'Vigorous'), (2, 'Hausa', 'Nigeria, Africa', 33000000, 'Vigorous'), (3, 'Swahili', 'T...
What is the average number of speakers per language in Africa?
SELECT AVG(l.speakers) FROM languages l WHERE l.location LIKE '%Africa%';
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (donation_id INT, donor_id INT, donation_amount DECIMAL(10,2), donation_date DATE); INSERT INTO Donations (donation_id, donor_id, donation_amount, donation_date) VALUES (1, 1, 500.00, '2020-01-01'), (2, 2, 300.00, '2019-05-15');
Find the top 3 cities with the highest average donation amount in 'CA'?
SELECT city, AVG(donation_amount) FROM Donors d JOIN Donations don ON d.donor_id = don.donor_id WHERE state = 'CA' GROUP BY city ORDER BY AVG(donation_amount) DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE tokyo_ev_sales (vehicle_id INT, type VARCHAR(20), sales INT); INSERT INTO tokyo_ev_sales (vehicle_id, type, sales) VALUES (1, 'Tesla Model 3', 500), (2, 'Nissan Leaf', 450), (3, 'Mitsubishi Outlander PHEV', 400), (4, 'Toyota Prius Prime', 350), (5, 'BMW i3', 300);
What are the top 3 electric vehicle types in Tokyo with the highest adoption rates?
SELECT DISTINCT type FROM (SELECT type, ROW_NUMBER() OVER(ORDER BY sales DESC) as rank FROM tokyo_ev_sales) as ev_ranks WHERE rank <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE brands (id INT, name VARCHAR(255), country VARCHAR(255), size_diversity_policy BOOLEAN); INSERT INTO brands (id, name, country, size_diversity_policy) VALUES (1, 'BrandA', 'USA', true), (2, 'BrandB', 'Canada', false), (3, 'BrandC', 'France', true), (4, 'BrandD', 'UK', true), (5, 'BrandE', 'Germany', false)...
Which country has the highest number of fashion brands with a size diversity policy?
SELECT country, COUNT(*) as brand_count FROM brands WHERE size_diversity_policy = true GROUP BY country ORDER BY brand_count DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Vehicles (VehicleID int, DepotID int, VehicleType varchar(20), Accessible bit); INSERT INTO Vehicles VALUES (1, 1, 'Bus', 1), (2, 1, 'Bus', 0), (3, 2, 'Tram', 1);
What is the total number of vehicles in the fleet?
SELECT COUNT(VehicleID) FROM Vehicles;
gretelai_synthetic_text_to_sql
CREATE TABLE historical_sites (id INT, site_name VARCHAR(255), site_date DATE, visitor_age_group VARCHAR(255), visitor_count INT);
Which historical sites have the highest and lowest attendance by age group?
SELECT site_name, visitor_age_group, SUM(visitor_count) as total_visitors FROM historical_sites GROUP BY site_name, visitor_age_group ORDER BY total_visitors DESC, site_name;
gretelai_synthetic_text_to_sql
CREATE TABLE tourism_stats (visitor_country VARCHAR(255), trip_duration INT); INSERT INTO tourism_stats (visitor_country, trip_duration) VALUES ('Japan', 12);
What is the average trip duration for tourists visiting Japan?
SELECT AVG(trip_duration) FROM tourism_stats WHERE visitor_country = 'Japan';
gretelai_synthetic_text_to_sql
CREATE TABLE philanthropy.donors (donor_id INT, donor_name TEXT);
What is the average donation amount for causes in the 'philanthropy.causes' table?
SELECT AVG(amount) FROM philanthropy.donations d JOIN philanthropy.causes c ON d.cause_id = c.cause_id;
gretelai_synthetic_text_to_sql
CREATE TABLE AussieTournaments (TournamentID INT, TournamentName VARCHAR(50), Sport VARCHAR(20), City VARCHAR(50), StartDate DATE, EndDate DATE); INSERT INTO AussieTournaments (TournamentID, TournamentName, Sport, City, StartDate, EndDate) VALUES (1, 'Australian Open', 'Tennis', 'Melbourne', '2023-01-16', '2023-01-29')...
What is the duration and next start date of tournaments in Australia?
SELECT TournamentID, TournamentName, Sport, DATEDIFF(day, StartDate, EndDate) AS DaysDuration, LEAD(StartDate) OVER (ORDER BY StartDate) AS NextTournamentStartDate FROM AussieTournaments;
gretelai_synthetic_text_to_sql
CREATE TABLE Hotels (Hotel_Name VARCHAR(50), City VARCHAR(30)); INSERT INTO Hotels (Hotel_Name, City) VALUES ('H1', 'CityA'), ('H2', 'CityB'), ('H3', 'CityA'); CREATE TABLE Ratings (Hotel_Name VARCHAR(50), Rating INT); INSERT INTO Ratings (Hotel_Name, Rating) VALUES ('H1', 4), ('H2', 5), ('H3', 3);
What is the average hotel rating in each city?
SELECT H.City, AVG(R.Rating) AS Average_Rating FROM Ratings R JOIN Hotels H ON R.Hotel_Name = H.Hotel_Name GROUP BY H.City;
gretelai_synthetic_text_to_sql
CREATE TABLE organic_cotton_production (production_id INT, organic_cotton_quantity INT); INSERT INTO organic_cotton_production (production_id, organic_cotton_quantity) VALUES (1, 500), (2, 1000);
Find the total quantity of organic cotton used in production.
SELECT SUM(organic_cotton_quantity) FROM organic_cotton_production;
gretelai_synthetic_text_to_sql
CREATE TABLE cases (id INT, city VARCHAR(255), office VARCHAR(255), result VARCHAR(255)); INSERT INTO cases (id, city, office, result) VALUES (1, 'Chicago', 'Public Defender', 'Won'), (2, 'Chicago', 'Public Defender', 'Lost'), (3, 'Chicago', 'Prosecutor', 'Won');
What is the success rate of the public defender's office in the city of Chicago?
SELECT (SUM(CASE WHEN result = 'Won' THEN 1 ELSE 0 END) / COUNT(*)) * 100 AS success_rate FROM cases WHERE city = 'Chicago' AND office = 'Public Defender';
gretelai_synthetic_text_to_sql
CREATE TABLE locations (location_id INT, location VARCHAR(20), initiative_id INT, initiative_type VARCHAR(20)); INSERT INTO locations (location_id, location, initiative_id, initiative_type) VALUES (1, 'Online', 1, 'Open Pedagogy'), (2, 'In-person', 2, 'Open Pedagogy'), (3, 'Online', 3, 'Open Pedagogy'), (4, 'In-person'...
What is the distribution of open pedagogy initiatives by location?
SELECT location, COUNT(*) as num_initiatives FROM locations WHERE initiative_type = 'Open Pedagogy' GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE graduate_students (student_id INT, dept_name VARCHAR(50), gre_score INT); CREATE TABLE research_grants (grant_id INT, student_id INT, grant_date DATE);
What is the average GRE score of graduate students who received a research grant in the past year, and group the results by department?
SELECT g.dept_name, AVG(gs.gre_score) as avg_gre FROM graduate_students gs INNER JOIN research_grants rg ON gs.student_id = rg.student_id WHERE rg.grant_date >= DATE_SUB(CURRENT_DATE(), INTERVAL 1 YEAR) GROUP BY g.dept_name;
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name VARCHAR(100), industry VARCHAR(50), num_employees INT); CREATE TABLE machines (id INT, company_id INT, sector VARCHAR(50), num_machines INT); INSERT INTO companies (id, name, industry, num_employees) VALUES (1, 'ABC Motors', 'automotive', 500), (2, 'XYZ Retail', 'retail', 300); INSE...
What is the total number of employees and machines in the 'automotive' sector?
SELECT SUM(companies.num_employees) AS total_employees, SUM(machines.num_machines) AS total_machines FROM companies JOIN machines ON companies.id = machines.company_id WHERE companies.industry = 'automotive';
gretelai_synthetic_text_to_sql
CREATE TABLE neighborhoods (name VARCHAR(255), id INT, city VARCHAR(255)); INSERT INTO neighborhoods (name, id, city) VALUES ('East Austin', 1, 'Austin'), ('Downtown Austin', 2, 'Austin'), ('South Austin', 3, 'Austin'); CREATE TABLE properties (id INT, neighborhood_id INT, price FLOAT); INSERT INTO properties (id, neig...
What is the average property price for each neighborhood in the city of Austin?
SELECT n.name, AVG(p.price) FROM properties p JOIN neighborhoods n ON p.neighborhood_id = n.id WHERE n.city = 'Austin' GROUP BY n.name;
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (hotel_id INT, hotel_name TEXT, country TEXT, rating FLOAT, virtual_tour BOOLEAN); INSERT INTO hotels (hotel_id, hotel_name, country, rating, virtual_tour) VALUES (1, 'Hotel X', 'USA', 4.2, true), (2, 'Hotel Y', 'Canada', 4.5, false);
What is the average rating of hotels in the US that offer virtual tours?
SELECT AVG(rating) FROM hotels WHERE country = 'USA' AND virtual_tour = true;
gretelai_synthetic_text_to_sql
CREATE TABLE donors (donor_id INT, donor_type TEXT, donation_amount DECIMAL(10,2), donation_date DATE); INSERT INTO donors VALUES (1, 'Individual', 50.00, '2020-01-01'); INSERT INTO donors VALUES (2, 'Corporation', 5000.00, '2020-02-01');
What was the total donation amount by each donor type in 2020?
SELECT donor_type, SUM(donation_amount) as total_donation FROM donors WHERE YEAR(donation_date) = 2020 GROUP BY donor_type;
gretelai_synthetic_text_to_sql
CREATE TABLE resilience_standards (id INT, name VARCHAR(50), location VARCHAR(50), start_date DATE, completion_date DATE);
List the projects in the 'resilience_standards' table that have a completion date within the last 6 months, ordered by their start date.
SELECT * FROM resilience_standards WHERE completion_date >= DATEADD(month, -6, GETDATE()) ORDER BY start_date;
gretelai_synthetic_text_to_sql
CREATE TABLE Ratings (rating_id INT PRIMARY KEY, menu_item VARCHAR(50), rating DECIMAL(2,1)); CREATE TABLE Menu (menu_item VARCHAR(50) PRIMARY KEY, menu_item_category VARCHAR(50));
What is the average rating for menu items in the "vegan" category?
SELECT AVG(r.rating) FROM Ratings r JOIN Menu m ON r.menu_item = m.menu_item WHERE m.menu_item_category = 'vegan';
gretelai_synthetic_text_to_sql
CREATE TABLE investment ( id INT PRIMARY KEY, sector VARCHAR(20), return FLOAT ); INSERT INTO investment (id, sector, return) VALUES (1, 'renewables', 10.5), (2, 'storage', 15.6), (3, 'grid', 12.3);
Update the 'investment' table, setting the 'return' to 12 for any record where sector is 'renewables'
WITH cte AS (UPDATE investment SET return = 12 WHERE sector = 'renewables') SELECT * FROM cte;
gretelai_synthetic_text_to_sql
CREATE TABLE dispensaries (id INT, name TEXT, state TEXT, county TEXT); INSERT INTO dispensaries (id, name, state, county) VALUES (1, 'The Healing Center', 'California', 'Los Angeles'), (2, 'Remedy', 'Texas', 'Travis'); CREATE TABLE sales (id INT, dispensary_id INT, product TEXT, quantity INT);
What is the total quantity of cannabis flower sold by dispensaries located in Los Angeles County?
SELECT SUM(s.quantity) FROM sales s JOIN dispensaries d ON s.dispensary_id = d.id WHERE d.county = 'Los Angeles';
gretelai_synthetic_text_to_sql
CREATE TABLE rd_expenditure (country VARCHAR(50), drug_type VARCHAR(50), amount NUMERIC(10, 2)); INSERT INTO rd_expenditure (country, drug_type, amount) VALUES ('South Korea', 'Rheumatology', 12000000), ('South Korea', 'Rheumatology', 14000000), ('South Korea', 'Rheumatology', 13000000);
What is the minimum R&D expenditure for rheumatology drugs in South Korea?
SELECT MIN(amount) FROM rd_expenditure WHERE drug_type = 'Rheumatology' AND country = 'South Korea';
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_acidity (id INT, location TEXT, pH FLOAT, year INT); INSERT INTO ocean_acidity (id, location, pH, year) VALUES (1, 'Atlantic Ocean', 7.8, 2019), (2, 'Atlantic Ocean', 7.6, 2018), (3, 'Atlantic Ocean', 7.9, 2017);
What is the maximum ocean acidity level (pH value) recorded in the Atlantic Ocean in 2019?
SELECT MAX(pH) FROM ocean_acidity WHERE location = 'Atlantic Ocean' AND year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE CoOwnedProperties (PropertyID INT, OwnerName TEXT, City TEXT, State TEXT, PropertyTaxRate DECIMAL(5,2)); INSERT INTO CoOwnedProperties (PropertyID, OwnerName, City, State, PropertyTaxRate) VALUES (1, 'John Doe', 'Seattle', 'WA', 1.25), (2, 'Jane Smith', 'Seattle', 'WA', 1.30);
What is the average property tax rate for co-owned properties in the city of Seattle?
SELECT AVG(PropertyTaxRate) FROM CoOwnedProperties WHERE City = 'Seattle' AND State = 'WA';
gretelai_synthetic_text_to_sql
CREATE TABLE policy_2 (policy_id INT, policy_type VARCHAR(20), premium FLOAT); INSERT INTO policy_2 (policy_id, policy_type, premium) VALUES (1, 'Home', 1500.00), (2, 'Auto', 750.00), (3, 'Life', 1200.00), (4, 'Home', 1800.00);
Find the policy type with the highest average premium.
SELECT policy_type, AVG(premium) AS avg_premium, RANK() OVER (ORDER BY AVG(premium) DESC) AS policy_rank FROM policy_2 GROUP BY policy_type HAVING policy_rank = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE safety_incidents (incident_id INT, incident_date DATE, incident_type VARCHAR(50)); INSERT INTO safety_incidents (incident_id, incident_date, incident_type) VALUES (1, '2022-01-01', 'Chemical Spill'); INSERT INTO safety_incidents (incident_id, incident_date, incident_type) VALUES (2, '2022-02-01', 'Equipmen...
How many safety incidents were reported per month in 2022?
SELECT EXTRACT(MONTH FROM incident_date) as month, COUNT(incident_id) as incidents_per_month FROM safety_incidents WHERE EXTRACT(YEAR FROM incident_date) = 2022 GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE players (id INT, name TEXT, age INT, league TEXT); INSERT INTO players (id, name, age, league) VALUES (1, 'John Doe', 25, 'NBA'), (2, 'Jane Smith', 30, 'EuroLeague');
What is the average age of players who have played in both the NBA and EuroLeague?
SELECT AVG(age) FROM players p1 INNER JOIN players p2 ON p1.name = p2.name WHERE p1.league = 'NBA' AND p2.league = 'EuroLeague';
gretelai_synthetic_text_to_sql
CREATE TABLE rural_infrastructure (id INT, project_name TEXT, budget INT, category TEXT, completion_date DATE); INSERT INTO rural_infrastructure (id, project_name, budget, category, completion_date) VALUES (1, 'Road Construction', 50000, 'Roads', '2018-05-01'), (2, 'Clean Water Supply', 75000, 'Water', '2019-08-15'), (...
What is the average budget for rural infrastructure projects, categorized by type, for each year?
SELECT category, YEAR(completion_date) AS completion_year, AVG(budget) FROM rural_infrastructure GROUP BY category, YEAR(completion_date);
gretelai_synthetic_text_to_sql
CREATE TABLE targets (country TEXT, year INT, emissions_target FLOAT); INSERT INTO targets (country, year, emissions_target) VALUES ('Canada', 2020, 500000);
Which countries have exceeded their historical emissions targets as of 2020?
SELECT country FROM targets WHERE year = 2020 AND emissions_target < (SELECT emissions FROM emissions WHERE country = targets.country AND year = 2020);
gretelai_synthetic_text_to_sql
CREATE TABLE Patients (PatientID INT, Age INT, Gender VARCHAR(10)); CREATE TABLE MentalHealthConditions (ConditionID INT, PatientID INT, Condition VARCHAR(50));
What are the most common mental health conditions in a specific age group?
SELECT Patients.Age, MentalHealthConditions.Condition, COUNT(MentalHealthConditions.ConditionID) FROM Patients INNER JOIN MentalHealthConditions ON Patients.PatientID = MentalHealthConditions.PatientID WHERE Patients.Age BETWEEN 20 AND 30 GROUP BY Patients.Age, MentalHealthConditions.Condition ORDER BY Patients.Age, CO...
gretelai_synthetic_text_to_sql
CREATE TABLE transportation.country_electric_vehicle_sales (country VARCHAR(50), year INT, electric_vehicle_sales INT);
Which countries have the highest and lowest adoption rate of electric vehicles in the 'country_electric_vehicle_sales' table?
SELECT country, ROUND((electric_vehicle_sales * 100.0 / SUM(electric_vehicle_sales) OVER ())::numeric, 2) AS adoption_rate FROM transportation.country_electric_vehicle_sales GROUP BY country, electric_vehicle_sales, year ORDER BY adoption_rate DESC, country;
gretelai_synthetic_text_to_sql
CREATE TABLE courts (id INT, name VARCHAR(50), location VARCHAR(50));
Add a new court named 'High Court of New Zealand' located in 'Wellington'
INSERT INTO courts (id, name, location) VALUES (3, 'High Court of New Zealand', 'Wellington');
gretelai_synthetic_text_to_sql
CREATE TABLE satellites (id INT, name VARCHAR(255), manufacturer VARCHAR(255), launch_date DATE); INSERT INTO satellites (id, name, manufacturer, launch_date) VALUES (1, 'FalconSat', 'SpaceX', '2020-01-01'), (2, 'Cubesat', 'Blue Origin', '2019-01-01');
What is the name and manufacturer of the most recently deployed satellite?
SELECT name, manufacturer FROM satellites ORDER BY launch_date DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE peacekeeping_operations (operation_id INT, country_name VARCHAR(50), operation_start_date DATE, operation_end_date DATE);
Add new peacekeeping operations records for 'Brazil', 'South Africa', and 'Argentina'
INSERT INTO peacekeeping_operations (country_name, operation_start_date, operation_end_date) VALUES ('Brazil', '2021-11-15', '2022-05-30'), ('South Africa', '2020-06-01', '2021-12-31'), ('Argentina', '2019-08-08', '2020-12-25');
gretelai_synthetic_text_to_sql
CREATE TABLE Green_Buildings (id INT, region VARCHAR(20), number_of_buildings INT); INSERT INTO Green_Buildings (id, region, number_of_buildings) VALUES (1, 'Europe', 5000), (2, 'Asia', 7000), (3, 'Africa', 3000);
What is the total number of green buildings in Europe?
SELECT SUM(number_of_buildings) FROM Green_Buildings WHERE region = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE rural_infrastructure (project_id INT, project_name TEXT, start_date DATE, end_date DATE, budget INT); INSERT INTO rural_infrastructure (project_id, project_name, start_date, end_date, budget) VALUES (1, 'Water Supply', '2021-01-01', '2021-12-31', 100000), (2, 'Road Construction', '2020-04-01', '2020-12-31'...
List all the infrastructure projects in the 'rural_infrastructure' table, ordered by start date.
SELECT * FROM rural_infrastructure ORDER BY start_date;
gretelai_synthetic_text_to_sql
CREATE TABLE Pipelines(id INT, name TEXT, location TEXT, built DATE); INSERT INTO Pipelines(id, name, location, built) VALUES (1, 'Seaway Pipeline', 'Texas', '1970-01-01');
Show the pipelines in Texas that were constructed in the 1970s.
SELECT name FROM Pipelines WHERE location = 'Texas' AND built BETWEEN '1970-01-01' AND '1979-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE ticket_sales (ticket_id INT, city VARCHAR(50), sport VARCHAR(20), ticket_count INT);
Find the top 3 cities with the most ticket sales for football games.
SELECT city, SUM(ticket_count) AS total_sales FROM ticket_sales WHERE sport = 'football' GROUP BY city ORDER BY total_sales DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE intel_methods (agency VARCHAR(50), year INT, method VARCHAR(50), frequency INT); INSERT INTO intel_methods (agency, year, method, frequency) VALUES ('CIA', 2017, 'HUMINT', 300), ('CIA', 2017, 'SIGINT', 200), ('CIA', 2017, 'GEOINT', 100), ('MI6', 2017, 'HUMINT', 400), ('MI6', 2017, 'SIGINT', 350), ('MI6', 2...
What were the most common intelligence gathering methods used by the CIA and MI6 in 2017?
SELECT agency, method, frequency FROM intel_methods WHERE agency IN ('CIA', 'MI6') AND year = 2017;
gretelai_synthetic_text_to_sql
CREATE TABLE Branches (branch_id INT, branch_name VARCHAR(255));CREATE TABLE Menu (dish_name VARCHAR(255), branch_id INT, price DECIMAL(5,2));CREATE TABLE Sales (sale_date DATE, dish_name VARCHAR(255), quantity INT);
What is the total revenue of each dish sold in branch 8, 9, and 10?
SELECT dish_name, SUM(quantity * price) as total_revenue FROM Sales JOIN Menu ON Sales.dish_name = Menu.dish_name WHERE branch_id IN (8, 9, 10) GROUP BY dish_name;
gretelai_synthetic_text_to_sql
CREATE TABLE policies (id INT, name VARCHAR(50), country VARCHAR(50), type VARCHAR(50), enactment_date DATE); INSERT INTO policies (id, name, country, type, enactment_date) VALUES (1, 'Coastal Protection Policy', 'Fiji', 'Adaptation', '2018-01-01'); INSERT INTO policies (id, name, country, type, enactment_date) VALUES ...
List all climate adaptation policies enacted by Pacific Island nations and their corresponding impact scores.
SELECT p.name, p.country, p.type, p.enactment_date, coalesce(avg(i.impact_score), 0) as avg_impact_score FROM policies p LEFT JOIN impact_assessments i ON p.id = i.policy_id WHERE p.type = 'Adaptation' AND p.country LIKE 'Pacific%' GROUP BY p.name, p.country, p.type, p.enactment_date;
gretelai_synthetic_text_to_sql
CREATE TABLE nfl_2021 (team TEXT, wins INT);
Find the team with the most wins in the NFL in the 2021 season.
SELECT team, MAX(wins) FROM nfl_2021 GROUP BY team ORDER BY wins DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists Projects (id INT, name VARCHAR(50), type VARCHAR(50), budget DECIMAL(10,2), start_date DATE); INSERT INTO Projects (id, name, type, budget, start_date) VALUES (1, 'Seawall', 'Resilience', 5000000.00, '2022-01-01'), (2, 'Floodgate', 'Resilience', 3000000.00, '2022-02-01'), (3, 'Bridge', 'Trans...
List all transportation projects in the state of California, along with their budgets and start dates.
SELECT name, budget, start_date FROM Projects INNER JOIN States ON Projects.id = 4 AND States.name = 'California' WHERE type = 'Transportation';
gretelai_synthetic_text_to_sql
CREATE TABLE articles (id INT PRIMARY KEY, title VARCHAR(255), section VARCHAR(255), source VARCHAR(255)); INSERT INTO articles (id, title, section, source) VALUES (1, 'The Future of Politics', 'politics', 'New York Times'), (2, 'The Impact of Climate Change on Agriculture', 'environment', 'National Geographic'), (3, '...
Get the number of unique sources cited in all articles in the 'politics' section
SELECT COUNT(DISTINCT source) FROM articles WHERE section = 'politics';
gretelai_synthetic_text_to_sql
CREATE TABLE wastewater_treatment_m3 (country VARCHAR(20), region VARCHAR(20), value FLOAT); INSERT INTO wastewater_treatment_m3 (country, region, value) VALUES ('South Africa', NULL, 3000000);
What is the minimum wastewater treatment capacity in South Africa in cubic meters?
SELECT MIN(value) FROM wastewater_treatment_m3 WHERE country = 'South Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE equipment_sales (eq_id INT, eq_type VARCHAR(50), sale_amount INT, region VARCHAR(50)); INSERT INTO equipment_sales (eq_id, eq_type, sale_amount, region) VALUES (1, 'M1 Abrams', 5000000, 'Middle East'), (2, 'F-35', 8000000, 'Middle East');
Get unique equipment types and sales data for 'Middle East'
SELECT DISTINCT eq_type, SUM(sale_amount) AS total_sales_amount FROM equipment_sales WHERE region = 'Middle East' GROUP BY eq_type;
gretelai_synthetic_text_to_sql
CREATE TABLE regional_newspapers (article_id INT, publication_date DATE, region VARCHAR(50));CREATE TABLE international_newswire (article_id INT, publication_date DATE, country VARCHAR(50));
What is the distribution of publication dates in 'regional_newspapers' table and 'international_newswire' table?
SELECT DATE_FORMAT(publication_date, '%Y-%m-%d') AS publication_date, COUNT(*) FROM regional_newspapers GROUP BY publication_date;SELECT DATE_FORMAT(publication_date, '%Y-%m-%d') AS publication_date, COUNT(*) FROM international_newswire GROUP BY publication_date;
gretelai_synthetic_text_to_sql
CREATE TABLE movies (id INT, title VARCHAR(100), production_budget INT, revenue INT, production_country VARCHAR(50)); INSERT INTO movies (id, title, production_budget, revenue, production_country) VALUES (1, 'MovieA', 15000000, 40000000, 'India'); INSERT INTO movies (id, title, production_budget, revenue, production_co...
What is the total revenue for movies produced in India and China?
SELECT SUM(revenue) FROM movies WHERE production_country IN ('India', 'China');
gretelai_synthetic_text_to_sql
CREATE SCHEMA Maritime; CREATE TABLE Law (vessel_id INT, compliance_status VARCHAR(10)); INSERT INTO Law (vessel_id, compliance_status) VALUES (1, 'Compliant'), (2, 'Non-Compliant'), (3, 'Compliant'), (4, 'Compliant'), (5, 'Compliant');
How many vessels are compliant with maritime law in the 'Maritime' schema?
SELECT COUNT(*) FROM Maritime.Law WHERE compliance_status = 'Compliant';
gretelai_synthetic_text_to_sql
CREATE TABLE athletes (id INT, age INT, program_id INT); INSERT INTO athletes (id, age, program_id) VALUES (1, 25, 1); INSERT INTO athletes (id, age, program_id) VALUES (2, 28, 2);
What is the average age of athletes in each wellbeing program?
SELECT p.program_type, AVG(a.age) AS avg_age FROM athletes a JOIN wellbeing w ON a.program_id = w.id GROUP BY p.program_type;
gretelai_synthetic_text_to_sql
CREATE TABLE Hotels (hotel_id INT, hotel_name VARCHAR(50), city VARCHAR(50)); CREATE TABLE VirtualTours (tour_id INT, hotel_id INT, tour_name VARCHAR(50)); CREATE TABLE UserInteractions (user_id INT, tour_id INT, interaction_date DATE, completed BOOLEAN); INSERT INTO Hotels (hotel_id, hotel_name, city) VALUES (1, 'Hote...
How many users started but did not complete a virtual tour for hotels in 'CityG' in the last 30 days?
SELECT COUNT(DISTINCT ui.user_id) FROM Hotels h JOIN VirtualTours vt ON h.hotel_id = vt.hotel_id JOIN UserInteractions ui ON vt.tour_id = ui.tour_id WHERE h.city = 'CityG' AND ui.interaction_date >= DATE_SUB(CURDATE(), INTERVAL 30 DAY) AND ui.completed = FALSE;
gretelai_synthetic_text_to_sql
CREATE TABLE daily_production (production_date DATE, chemical VARCHAR(20), quantity INT); INSERT INTO daily_production (production_date, chemical, quantity) VALUES ('2020-01-01', 'chemical C', 300); INSERT INTO daily_production (production_date, chemical, quantity) VALUES ('2020-01-02', 'chemical C', 400);
What is the maximum quantity of chemical C produced in a single day?
SELECT production_date, max(quantity) as max_quantity FROM daily_production WHERE chemical = 'chemical C' GROUP BY production_date ORDER BY max_quantity DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (id INT, city VARCHAR(50), joined_date DATE, hours INT); INSERT INTO volunteers (id, city, joined_date, hours) VALUES (1, 'New York', '2020-01-01', 300), (2, 'Los Angeles', '2021-01-15', 450), (3, 'Chicago', '2019-12-31', 250), (4, 'New York', '2021-03-15', 500), (5, 'Los Angeles', '2021-02-10',...
What's the number of volunteers who joined after 2019 and volunteered more than 200 hours?
SELECT COUNT(*) FROM volunteers WHERE joined_date > '2019-12-31' AND hours > 200;
gretelai_synthetic_text_to_sql
CREATE TABLE investments (fund_name VARCHAR(20), company_id INT, investment_amount FLOAT); CREATE TABLE companies (id INT, company_name VARCHAR(20), sector VARCHAR(20)); INSERT INTO investments (fund_name, company_id, investment_amount) VALUES ('Impact Fund 1', 1, 50000), ('Impact Fund 2', 2, 75000), ('Impact Fund 1', ...
What's the total investment amount made by 'Impact Fund 1' in the 'technology' sector?
SELECT SUM(investments.investment_amount) FROM investments INNER JOIN companies ON investments.company_id = companies.id WHERE investments.fund_name = 'Impact Fund 1' AND companies.sector = 'technology';
gretelai_synthetic_text_to_sql
CREATE TABLE districts (id INT, district_name VARCHAR(255), state VARCHAR(255));CREATE TABLE schools (id INT, school_name VARCHAR(255), district_id INT);
What is the total number of schools and their respective districts in the state of New York?
SELECT COUNT(DISTINCT s.district_id) as num_districts, COUNT(*) as num_schools FROM schools s INNER JOIN districts d ON s.district_id = d.id WHERE d.state = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT PRIMARY KEY, FirstName VARCHAR(50), LastName VARCHAR(50), Email VARCHAR(100));
Update the email address of a donor in the 'Donors' table
UPDATE Donors SET Email = 'new.email@example.com' WHERE DonorID = 101;
gretelai_synthetic_text_to_sql