context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE intel_budget (id INT, region VARCHAR(255), operation VARCHAR(255), budget DECIMAL(10, 2)); INSERT INTO intel_budget (id, region, operation, budget) VALUES (1, 'Asia-Pacific', 'SIGINT', 5000000), (2, 'Europe', 'HUMINT', 7000000), (3, 'Asia-Pacific', 'GEOINT', 6000000), (4, 'Americas', 'OSINT', 8000000);
What is the average budget for intelligence operations in the Asia-Pacific region?
SELECT AVG(budget) as avg_budget FROM intel_budget WHERE region = 'Asia-Pacific' AND operation = 'SIGINT' OR operation = 'GEOINT';
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (id INT, name TEXT, country TEXT, donation_amount DECIMAL(10, 2), donation_date DATE);
What was the total amount donated by individual donors from the United States in 2021?
SELECT SUM(donation_amount) FROM Donors WHERE country = 'United States' AND EXTRACT(YEAR FROM donation_date) = 2021 AND id NOT IN (SELECT DISTINCT donor_id FROM Organization_Donations);
gretelai_synthetic_text_to_sql
CREATE TABLE clients(id INT, name TEXT, financial_wellbeing_score INT);
How many clients have a financial wellbeing score greater than 70?
SELECT COUNT(*) FROM clients WHERE financial_wellbeing_score > 70;
gretelai_synthetic_text_to_sql
CREATE TABLE release_centers (center_id INT, center_name VARCHAR(50));CREATE TABLE animal_releases (release_id INT, animal_id INT, species_id INT, center_id INT, release_date DATE); INSERT INTO release_centers (center_id, center_name) VALUES (1, 'Release Center A'), (2, 'Release Center B'); INSERT INTO animal_releases (release_id, animal_id, species_id, center_id, release_date) VALUES (1001, 101, 1, 1, '2021-01-01'), (1002, 102, 2, 1, '2021-03-01'), (1003, 103, 3, 2, '2021-05-01');
What is the number of animals released back into the wild for each species?
SELECT s.species_name, COUNT(a.animal_id) AS total_released FROM animal_releases a JOIN release_centers rc ON a.center_id = rc.center_id JOIN animal_species s ON a.species_id = s.species_id GROUP BY s.species_name;
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (hotel_id INT, name VARCHAR(50), facility VARCHAR(50), rating FLOAT); INSERT INTO hotels (hotel_id, name, facility, rating) VALUES (1, 'Hotel X', 'spa,gym', 4.5), (2, 'Hotel Y', 'gym', 4.2), (3, 'Hotel Z', 'spa', 4.7);
Which hotels in the hotels table offer a spa facility and have a rating greater than 4?
SELECT * FROM hotels WHERE facility LIKE '%spa%' AND rating > 4;
gretelai_synthetic_text_to_sql
CREATE TABLE students (student_id INT, district VARCHAR(20), participated_in_llp BOOLEAN, year INT); INSERT INTO students (student_id, district, participated_in_llp, year) VALUES (1, 'Downtown', TRUE, 2021), (2, 'Downtown', FALSE, 2021), (3, 'Uptown', TRUE, 2021);
What is the percentage of students in the "Downtown" school district who participated in lifelong learning programs last year?
SELECT (COUNT(*) FILTER (WHERE participated_in_llp = TRUE)) * 100.0 / COUNT(*) FROM students WHERE district = 'Downtown' AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (species_name TEXT, region TEXT); INSERT INTO marine_species (species_name, region) VALUES ('Pacific Salmon', 'Sea of Okhotsk'), ('Sea Angel', 'Sea of Okhotsk');
What is the total number of marine species in the Sea of Okhotsk?
SELECT COUNT(*) FROM marine_species WHERE region = 'Sea of Okhotsk';
gretelai_synthetic_text_to_sql
CREATE TABLE animals (id INT, name VARCHAR(50), status VARCHAR(20)); INSERT INTO animals (id, name, status) VALUES (1, 'Tiger', 'Endangered'); INSERT INTO animals (id, name, status) VALUES (2, 'Elephant', 'Vulnerable');
Find the total number of animals in the 'endangered' status
SELECT COUNT(*) FROM animals WHERE status = 'Endangered';
gretelai_synthetic_text_to_sql
CREATE TABLE Regions (RegionID INT, RegionName VARCHAR(50), Budget DECIMAL(10,2)); INSERT INTO Regions (RegionID, RegionName, Budget) VALUES (1, 'Northeast', 50000), (2, 'Southeast', 60000), (3, 'Midwest', 45000), (4, 'Southwest', 70000), (5, 'West', 55000);
What is the average budget allocated for disability programs per region?
SELECT AVG(Budget) as AvgBudget, RegionName FROM Regions GROUP BY RegionName;
gretelai_synthetic_text_to_sql
CREATE TABLE developer (developer_id INT, developer_name VARCHAR(255)); CREATE TABLE ai_model (model_id INT, model_name VARCHAR(255)); CREATE TABLE creative_ai_application (app_id INT, app_name VARCHAR(255), developer_id INT, model_id INT); INSERT INTO developer (developer_id, developer_name) VALUES (1, 'Mr. John Smith'); INSERT INTO ai_model (model_id, model_name) VALUES (1, 'GAN Art'); INSERT INTO creative_ai_application (app_id, app_name, developer_id, model_id) VALUES (1, 'AI-Generated Music', 1, NULL);
List all creative AI applications and their developers, along with the corresponding AI model names, if available.
SELECT d.developer_name, caa.app_name, am.model_name FROM developer d LEFT JOIN creative_ai_application caa ON d.developer_id = caa.developer_id LEFT JOIN ai_model am ON caa.model_id = am.model_id;
gretelai_synthetic_text_to_sql
CREATE TABLE EventTypes (id INT, event_type VARCHAR(50)); INSERT INTO EventTypes (id, event_type) VALUES (1, 'Art Exhibition'), (2, 'Music Concert'), (3, 'Theater Play'); CREATE TABLE Events (id INT, event_type INT, attendee INT); INSERT INTO Events (id, event_type, attendee) VALUES (1, 1, 123), (2, 2, 234), (3, 1, 345);
How many times has each type of event been attended by a unique attendee?
SELECT et.event_type, COUNT(DISTINCT e.attendee) as unique_attendees FROM Events e JOIN EventTypes et ON e.event_type = et.id GROUP BY e.event_type;
gretelai_synthetic_text_to_sql
CREATE TABLE Clinics (ProvinceName VARCHAR(50), ClinicName VARCHAR(50), Capacity INT); INSERT INTO Clinics (ProvinceName, ClinicName, Capacity) VALUES ('Ontario', 'ClinicA', 200), ('Ontario', 'ClinicB', 250), ('Quebec', 'ClinicX', 150), ('British Columbia', 'ClinicY', 200), ('British Columbia', 'ClinicZ', 175);
What is the clinic capacity for each province, ranked in descending order?
SELECT ProvinceName, SUM(Capacity) AS TotalCapacity FROM Clinics GROUP BY ProvinceName ORDER BY TotalCapacity DESC
gretelai_synthetic_text_to_sql
CREATE TABLE Carbon_Offset_Initiatives (id INT, initiative_name VARCHAR(50), district VARCHAR(50)); INSERT INTO Carbon_Offset_Initiatives (id, initiative_name, district) VALUES (1, 'Tree Planting', 'Downtown'), (2, 'Recycling Program', 'Uptown'), (3, 'Solar Panels', 'Suburbs');
How many carbon offset initiatives were implemented in each district of a smart city?
SELECT district, COUNT(*) FROM Carbon_Offset_Initiatives GROUP BY district;
gretelai_synthetic_text_to_sql
CREATE TABLE nba_minutes (player_id INT, name VARCHAR(50), team VARCHAR(50), minutes INT); INSERT INTO nba_minutes (player_id, name, team, minutes) VALUES (1, 'LeBron James', 'Los Angeles Lakers', 3000); INSERT INTO nba_minutes (player_id, name, team, minutes) VALUES (2, 'Stephen Curry', 'Golden State Warriors', 2500);
What is the average time spent on the court by each basketball player in the NBA?
SELECT name, minutes / 60 AS avg_minutes FROM nba_minutes;
gretelai_synthetic_text_to_sql
CREATE TABLE EndangeredSpecies (Species VARCHAR(50), AdditionDate DATE); INSERT INTO EndangeredSpecies (Species, AdditionDate) VALUES ('Polar Bear', '2022-02-15');
Delete the 'EndangeredSpecies' table record with the most recent addition date.
DELETE FROM EndangeredSpecies WHERE AdditionDate = (SELECT MAX(AdditionDate) FROM EndangeredSpecies);
gretelai_synthetic_text_to_sql
CREATE TABLE funding (company_id INT, round TEXT, amount INT); INSERT INTO funding (company_id, round, amount) VALUES (1, 'series A', 5000000), (1, 'series B', 8000000), (2, 'series A', 3000000), (3, 'series A', 1000000), (4, 'series B', 12000000), (5, 'series B', 6000000), (6, 'blockchain', 5000000), (6, 'series B', 15000000);
What is the maximum amount of funding for series B rounds for companies in the "blockchain" sector?
SELECT MAX(amount) FROM funding JOIN company ON funding.company_id = company.id WHERE company.industry = 'blockchain' AND round = 'series B';
gretelai_synthetic_text_to_sql
CREATE TABLE Brands (BrandID INT, BrandName VARCHAR(50), Country VARCHAR(50), SustainabilityScore INT); INSERT INTO Brands (BrandID, BrandName, Country, SustainabilityScore) VALUES (1, 'Brand1', 'Country1', 85), (2, 'Brand2', 'Country2', 70), (3, 'Brand3', 'Country1', 90), (4, 'Brand4', 'Country3', 60), (5, 'Brand5', 'Country1', 80);
Show the top 3 countries with the most brands adopting sustainable materials.
SELECT Country, COUNT(BrandID) AS BrandCount FROM Brands WHERE SustainabilityScore > 70 GROUP BY Country ORDER BY BrandCount DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Exhibitions (id INT, name TEXT, visitor_count INT); INSERT INTO Exhibitions (id, name, visitor_count) VALUES (1, 'Dinosaurs', 1000), (2, 'Egypt', 800);
What is the maximum number of visitors for an exhibition?
SELECT MAX(visitor_count) FROM Exhibitions;
gretelai_synthetic_text_to_sql
CREATE TABLE EsportsEvents (EventID INT, EventName VARCHAR(50), GameID INT, EventDate DATE, PrizePool NUMERIC(18,2)); INSERT INTO EsportsEvents (EventID, EventName, GameID, EventDate, PrizePool) VALUES (1, 'Fortnite World Cup', 1, '2019-07-26', 30000000); INSERT INTO EsportsEvents (EventID, EventName, GameID, EventDate, PrizePool) VALUES (2, 'Overwatch League Grand Finals', 2, '2019-09-29', 1500000); INSERT INTO EsportsEvents (EventID, EventName, GameID, EventDate, PrizePool) VALUES (3, 'League of Legends World Championship', 3, '2019-11-10', 24000000); INSERT INTO EsportsEvents (EventID, EventName, GameID, EventDate, PrizePool) VALUES (4, 'Dota 2 International', 4, '2019-08-20', 34500000);
What is the total prize pool for the top 3 games with the highest prize pools in esports events, and their respective ranks?
SELECT GameID, SUM(PrizePool) as TotalPrizePool, NTILE(3) OVER (ORDER BY SUM(PrizePool) DESC) as PrizePoolRank FROM EsportsEvents GROUP BY GameID;
gretelai_synthetic_text_to_sql
CREATE TABLE purchases (id INT, vendor VARCHAR(50), total_cost FLOAT); INSERT INTO purchases (id, vendor, total_cost) VALUES (1, 'vendor1', 5000.00), (2, 'vendor2', 7000.00);
What is the 'total_cost' of 'purchases' from 'vendor1'?
SELECT total_cost FROM purchases WHERE vendor = 'vendor1';
gretelai_synthetic_text_to_sql
CREATE TABLE Sales (SaleID int, ProductID int, ProductName varchar(50), Category varchar(50), SalesNumber int); INSERT INTO Sales (SaleID, ProductID, ProductName, Category, SalesNumber) VALUES (1, 1, 'Eye Shadow A', 'Eye Shadow', 100), (2, 2, 'Eye Shadow B', 'Eye Shadow', 200), (3, 3, 'Lipstick C', 'Lipstick', 300);
Which 'Eye Shadow' products have a sales number greater than 150?
SELECT * FROM Sales WHERE Category = 'Eye Shadow' AND SalesNumber > 150;
gretelai_synthetic_text_to_sql
CREATE TABLE programs (id INT PRIMARY KEY, name VARCHAR(255)); CREATE TABLE volunteers (id INT PRIMARY KEY, name VARCHAR(255), program_id INT, FOREIGN KEY (program_id) REFERENCES programs(id));
What is the total number of volunteers for each program in the 'volunteers' table, grouped by program name?
SELECT program_id, COUNT(*) as total_volunteers FROM volunteers GROUP BY program_id;
gretelai_synthetic_text_to_sql
CREATE TABLE departments (id INT, name VARCHAR(255)); CREATE TABLE volunteers (id INT, department_id INT, joined_date DATE); CREATE TABLE staff (id INT, department_id INT, hired_date DATE);
What is the total number of volunteers and staff members in each department?
SELECT departments.name, COUNT(volunteers.id) + COUNT(staff.id) FROM departments LEFT JOIN volunteers ON departments.id = volunteers.department_id LEFT JOIN staff ON departments.id = staff.department_id GROUP BY departments.id;
gretelai_synthetic_text_to_sql
CREATE TABLE EsportsTeams (TeamID INT, TeamName VARCHAR(100), Country VARCHAR(50)); INSERT INTO EsportsTeams (TeamID, TeamName, Country) VALUES (1, 'Team Europe', 'Germany'), (2, 'Team Canada', 'Canada'); CREATE TABLE EsportsEvents (EventID INT, EventName VARCHAR(100), TeamID INT, Wins INT); INSERT INTO EsportsEvents (EventID, EventName, TeamID, Wins) VALUES (1, 'EventA', 1, 3), (2, 'EventB', 1, 2), (3, 'EventC', 2, 1);
What is the maximum number of esports event wins by a team from Europe?
SELECT MAX(Wins) FROM EsportsEvents WHERE Country = 'Germany';
gretelai_synthetic_text_to_sql
CREATE TABLE company (id INT, name VARCHAR(50), country VARCHAR(50)); CREATE TABLE investment_round (id INT, company_id INT, funding_amount INT); INSERT INTO company (id, name, country) VALUES (1, 'Acme Corp', 'USA'); INSERT INTO investment_round (id, company_id, funding_amount) VALUES (1, 1, 500000); INSERT INTO investment_round (id, company_id, funding_amount) VALUES (2, 1, 750000); INSERT INTO company (id, name, country) VALUES (2, 'Maple Leaf Technologies', 'Canada'); INSERT INTO investment_round (id, company_id, funding_amount) VALUES (3, 2, 250000);
What is the minimum funding amount received by companies founded in the United States?
SELECT MIN(ir.funding_amount) AS min_funding_amount FROM company c JOIN investment_round ir ON c.id = ir.company_id WHERE c.country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE CaseCounts (ID INT, CaseType VARCHAR(20), Year INT, Quarter INT, Count INT); INSERT INTO CaseCounts (ID, CaseType, Year, Quarter, Count) VALUES (1, 'Civil', 2022, 1, 100), (2, 'Criminal', 2022, 1, 150), (3, 'Civil', 2022, 2, 120), (4, 'Criminal', 2022, 2, 160), (5, 'Civil', 2022, 3, 140), (6, 'Criminal', 2022, 3, 170), (7, 'Civil', 2022, 4, 150), (8, 'Criminal', 2022, 4, 180);
What is the difference in the number of cases between the first and last quarter for each case type in the current year?
SELECT CaseType, (MAX(Count) OVER (PARTITION BY CaseType) - MIN(Count) OVER (PARTITION BY CaseType)) AS Difference FROM CaseCounts WHERE Year = EXTRACT(YEAR FROM CURRENT_DATE) GROUP BY CaseType, Quarter, Count;
gretelai_synthetic_text_to_sql
CREATE TABLE sf_units(id INT, address VARCHAR(50), wheelchair_access BOOLEAN); INSERT INTO sf_units VALUES (1, '123 Main St', true), (2, '456 Elm St', false); CREATE TABLE sf_neighborhoods(id INT, name VARCHAR(30), unit_id INT); INSERT INTO sf_neighborhoods VALUES (1, 'Downtown', 1), (2, 'Mission', 2);
List the unique neighborhoods in San Francisco with wheelchair-accessible units.
SELECT DISTINCT sf_neighborhoods.name FROM sf_neighborhoods JOIN sf_units ON sf_neighborhoods.unit_id = sf_units.id WHERE sf_units.wheelchair_access = true;
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (user_id INT, transaction_amount DECIMAL(10, 2), transaction_date DATE, country VARCHAR(255)); INSERT INTO transactions (user_id, transaction_amount, transaction_date, country) VALUES (1, 50.00, '2022-01-01', 'France'), (2, 100.50, '2022-01-02', 'France');
What is the average transaction amount per user in France?
SELECT AVG(transaction_amount) as avg_transaction_amount FROM transactions WHERE country = 'France' GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (id INT, species_name VARCHAR(50), ocean VARCHAR(50));
What are the names of all the marine species in 'marine_species' table that are found in the Pacific Ocean?
SELECT species_name FROM marine_species WHERE ocean = 'Pacific Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE tourism_stats (visitor_country VARCHAR(20), destination VARCHAR(20), expenditure DECIMAL(10,2)); INSERT INTO tourism_stats (visitor_country, destination, expenditure) VALUES ('Italy', 'Rome', 400.00), ('Italy', 'Rome', 350.00), ('Italy', 'Florence', 300.00), ('Italy', 'Venice', 450.00);
Find the total expenditure by tourists from Italy in each destination?
SELECT destination, SUM(expenditure) FROM tourism_stats WHERE visitor_country = 'Italy' GROUP BY destination;
gretelai_synthetic_text_to_sql
CREATE TABLE daily_sales (sale_date DATE, product_id INT, quantity INT); INSERT INTO daily_sales VALUES ('2022-06-01', 1, 50), ('2022-06-01', 2, 30), ('2022-06-02', 1, 75), ('2022-06-02', 2, 40), ('2022-06-03', 1, 80), ('2022-06-03', 2, 35), ('2022-06-04', 1, 90), ('2022-06-04', 2, 45);
What is the change in the quantity of each product sold, compared to the previous day, for the last 7 days?
SELECT sale_date, product_id, quantity, LAG(quantity, 1) OVER (PARTITION BY product_id ORDER BY sale_date) as prev_quantity, quantity - LAG(quantity, 1) OVER (PARTITION BY product_id ORDER BY sale_date) as quantity_change FROM daily_sales WHERE sale_date >= DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY) ORDER BY sale_date, product_id;
gretelai_synthetic_text_to_sql
CREATE TABLE buildings (id INT, name VARCHAR(50), state VARCHAR(50), rating FLOAT, upgrade_year INT);
What is the minimum energy efficiency rating of buildings in California that have received energy efficiency upgrades since 2010?
SELECT MIN(rating) FROM buildings WHERE state = 'California' AND upgrade_year >= 2010;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name TEXT, is_sustainable BOOLEAN); INSERT INTO products VALUES (1, 'Eco Shirt', TRUE); INSERT INTO products VALUES (2, 'Regular Shirt', FALSE); CREATE TABLE inventory (product_id INT, quantity INT); INSERT INTO inventory VALUES (1, 100); INSERT INTO inventory VALUES (2, 200);
What is the total quantity of sustainable products in the products and inventory tables?
SELECT SUM(quantity) FROM products INNER JOIN inventory ON products.product_id = inventory.product_id WHERE is_sustainable = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE startup (id INT, name TEXT, exit_event TEXT); INSERT INTO startup (id, name, exit_event) VALUES (1, 'Acme Inc', 'Acquisition'); INSERT INTO startup (id, name, exit_event) VALUES (2, 'Beta Corp', NULL);
Show the names of startups that have had an acquisition exit event
SELECT name FROM startup WHERE exit_event = 'Acquisition';
gretelai_synthetic_text_to_sql
CREATE TABLE co_ownership (property_id INT, size FLOAT, city VARCHAR(20)); INSERT INTO co_ownership (property_id, size, city) VALUES (1, 1200.0, 'Seattle'), (2, 1500.0, 'NYC');
What is the average size of co-owned properties in NYC?
SELECT AVG(size) FROM co_ownership WHERE city = 'NYC';
gretelai_synthetic_text_to_sql
CREATE TABLE Events (id INT, date DATE, genre VARCHAR(50), city VARCHAR(50), attendance INT); INSERT INTO Events (id, date, genre, city, attendance) VALUES (1, '2021-01-01', 'Classical', 'New York', 100), (2, '2021-01-02', 'Rock', 'Los Angeles', 200);
What is the average attendance at events, in the past month, broken down by day of the week and genre?
SELECT DATE_FORMAT(e.date, '%W') AS day_of_week, e.genre, AVG(e.attendance) AS avg_attendance FROM Events e WHERE e.date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY day_of_week, e.genre;
gretelai_synthetic_text_to_sql
CREATE TABLE TV_Shows_Viewership (id INT, title VARCHAR(100), network VARCHAR(50), avg_viewers DECIMAL(10,2)); INSERT INTO TV_Shows_Viewership (id, title, network, avg_viewers) VALUES (1, 'The Simpsons', 'FOX', 5000000.00), (2, 'Game of Thrones', 'HBO', 12000000.00), (3, 'Friends', 'NBC', 20000000.00);
What is the average viewership for TV shows by network?
SELECT network, AVG(avg_viewers) FROM TV_Shows_Viewership GROUP BY network;
gretelai_synthetic_text_to_sql
CREATE TABLE chemical_plants (id INT, name TEXT, region TEXT, production_volume INT); INSERT INTO chemical_plants (id, name, region, production_volume) VALUES (1, 'Plant A', 'Northeast', 1200), (2, 'Plant B', 'Midwest', 900), (3, 'Plant C', 'West', 1300);
What is the total production volume for all plants?
SELECT SUM(production_volume) FROM chemical_plants;
gretelai_synthetic_text_to_sql
CREATE TABLE research (id INT PRIMARY KEY, research_type VARCHAR(50), description TEXT, date DATE);
Delete all records from the 'research' table where the 'research_type' is 'Bioinformatics'
WITH cte1 AS (DELETE FROM research WHERE research_type = 'Bioinformatics') SELECT * FROM cte1;
gretelai_synthetic_text_to_sql
CREATE TABLE Astronauts (id INT, name VARCHAR(100), flights INT, last_flight DATE, agency VARCHAR(100)); INSERT INTO Astronauts (id, name, flights, last_flight, agency) VALUES (1, 'Astronaut1', 5, '2014-01-01', 'SpaceCorp'); INSERT INTO Astronauts (id, name, flights, last_flight, agency) VALUES (2, 'Astronaut2', 3, '2016-03-03', 'SpaceCorp');
List all astronauts who have not flown after 2015 for SpaceCorp?
SELECT name, flights, last_flight FROM Astronauts WHERE agency = 'SpaceCorp' AND EXTRACT(YEAR FROM last_flight) < 2016;
gretelai_synthetic_text_to_sql
CREATE TABLE music_streaming (song_id INT, song_name TEXT, artist_name TEXT, plays INT);
What is the name of the most popular artist in the 'music_streaming' table?
SELECT artist_name, MAX(plays) FROM music_streaming GROUP BY artist_name;
gretelai_synthetic_text_to_sql
CREATE TABLE low_rated_garments AS SELECT * FROM garments WHERE rating < 3;
Delete garments with a rating below 3.
DELETE FROM garments WHERE id IN (SELECT garment_id FROM low_rated_garments);
gretelai_synthetic_text_to_sql
CREATE TABLE sports (sport_id INT, sport_name VARCHAR(50)); CREATE TABLE fans (fan_id INT, fan_name VARCHAR(50), sport_id INT);
Which sport has the most number of fans?
SELECT s.sport_name, COUNT(*) as fan_count FROM fans f JOIN sports s ON f.sport_id = s.sport_id GROUP BY s.sport_name ORDER BY fan_count DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE EventAccessibility (event_name VARCHAR(50), event_year INT, attendee_disability BOOLEAN); INSERT INTO EventAccessibility (event_name, event_year, attendee_disability) VALUES ('Accessible Arts', 2021, TRUE); INSERT INTO EventAccessibility (event_name, event_year, attendee_disability) VALUES ('Accessible Arts', 2021, FALSE); INSERT INTO EventAccessibility (event_name, event_year, attendee_disability) VALUES ('Accessible Arts', 2020, TRUE);
How many individuals with disabilities attended 'Accessible Arts' events in 2021?
SELECT COUNT(*) FROM EventAccessibility WHERE event_name = 'Accessible Arts' AND event_year = 2021 AND attendee_disability = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE ethics (id INT, journalist VARCHAR(100), country VARCHAR(50), violation_type VARCHAR(50), date DATE); INSERT INTO ethics (id, journalist, country, violation_type, date) VALUES (1, 'Charlie Davis', 'Australia', 'Conflict of Interest', '2022-01-01'); INSERT INTO ethics (id, journalist, country, violation_type, date) VALUES (2, 'David Thompson', 'Australia', 'Plagiarism', '2022-01-02');
Which investigative journalists in Australia have been involved in more than 10 media ethics violations?
SELECT journalist, COUNT(*) FROM ethics WHERE country = 'Australia' GROUP BY journalist HAVING COUNT(*) > 10;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (species_id INT, species_name VARCHAR(100), max_depth FLOAT, conservation_status VARCHAR(50), order_name VARCHAR(50), family VARCHAR(50));
List all marine species that have been recorded at a depth greater than 5000 meters and have a conservation status of 'Least Concern'.
SELECT species_name FROM marine_species WHERE max_depth > 5000 AND conservation_status = 'Least Concern';
gretelai_synthetic_text_to_sql
CREATE TABLE resolved_complaints_year (id INT PRIMARY KEY, complaint TEXT, date DATE);
Create a table to archive resolved complaints for the last year
CREATE TABLE resolved_complaints_year AS SELECT id, complaint, date FROM resolved_complaints WHERE date >= (CURRENT_DATE - INTERVAL '1 year');
gretelai_synthetic_text_to_sql
CREATE TABLE workforce_diversity (id INT, company_name VARCHAR(50), diversity_metric FLOAT); INSERT INTO workforce_diversity (id, company_name, diversity_metric) VALUES (1, 'Company O', 0.5), (2, 'Company P', 0.8);
Which companies have a workforce diversity metric greater than 0.6?
SELECT * FROM workforce_diversity WHERE diversity_metric > 0.6;
gretelai_synthetic_text_to_sql
CREATE TABLE Sales (order_id INT, product_id INT, product_name VARCHAR(50), size INT, price DECIMAL(5,2), sale_date DATE); INSERT INTO Sales (order_id, product_id, product_name, size, price, sale_date) VALUES (1, 1001, 'Dress', 14, 89.99, '2022-01-05'), (2, 1002, 'Dress', 12, 99.99, '2022-02-10'), (3, 1001, 'Dress', 14, 89.99, '2022-03-20');
What is the total quantity of size 14 dresses sold in the last quarter?
SELECT SUM(price) FROM Sales WHERE size = 14 AND sale_date >= '2022-01-01' AND sale_date <= '2022-03-31';
gretelai_synthetic_text_to_sql
CREATE TABLE SatelliteDeployments (Id INT, Operator VARCHAR(50), Name VARCHAR(50), Year INT); INSERT INTO SatelliteDeployments (Id, Operator, Name, Year) VALUES (1, 'SpaceX', 'FalconSat', 2006), (2, 'SpaceX', 'DRAGON', 2010);
List all the satellites deployed by SpaceX before 2015.
SELECT Operator, Name FROM SatelliteDeployments WHERE Operator = 'SpaceX' AND Year < 2015;
gretelai_synthetic_text_to_sql
CREATE TABLE crop (crop_id INT, crop_name TEXT, region TEXT, cost INT); INSERT INTO crop (crop_id, crop_name, region, cost) VALUES (1, 'Corn', 'region1', 200), (2, 'Potatoes', 'region1', 100), (3, 'Beans', 'region2', 150), (4, 'Carrots', 'region2', 120);
What is the average production cost of crops in 'region2' and 'region1'?
SELECT c.region, AVG(c.cost) as avg_production_cost FROM crop c GROUP BY c.region;
gretelai_synthetic_text_to_sql
CREATE TABLE personnel (id INT, country VARCHAR(50), role VARCHAR(50), region VARCHAR(50)); INSERT INTO personnel (id, country, role, region) VALUES (1, 'USA', 'Security Analyst', 'North America'); INSERT INTO personnel (id, country, role, region) VALUES (2, 'Canada', 'Security Engineer', 'North America');
Display the average number of cybersecurity personnel in each country in the North America region.
SELECT region, AVG(CASE WHEN role = 'Security Analyst' OR role = 'Security Engineer' THEN 1 ELSE 0 END) FROM personnel WHERE region = 'North America' GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE Dams (id INT, name VARCHAR(100), height FLOAT, province VARCHAR(50), design_standard VARCHAR(50)); INSERT INTO Dams (id, name, height, province, design_standard) VALUES (1, 'Manicouagan Dam', 162, 'Quebec', 'CSA Z247');
What are the names and design standards of all dams in the province of Quebec with a height greater than 50 meters?
SELECT name, design_standard FROM Dams WHERE province = 'Quebec' AND height > 50;
gretelai_synthetic_text_to_sql
CREATE TABLE PeacekeepingOperations (Operation VARCHAR(50), Year INT, Casualties INT); INSERT INTO PeacekeepingOperations (Operation, Year, Casualties) VALUES ('UNAMID', 2010, 187), ('MONUSCO', 2010, 184), ('MINUSMA', 2013, 164), ('UNMISS', 2013, 158), ('UNSTAMIS', 2014, 129), ('MINUSCA', 2014, 128), ('UNMIK', 2000, 124), ('UNFICYP', 1964, 101), ('ONUC', 1961, 92), ('UNTSO', 1948, 88);
List the peacekeeping operations that have the highest personnel casualties since 2010?
SELECT Operation, MAX(Casualties) AS HighestCasualties FROM PeacekeepingOperations GROUP BY Operation ORDER BY HighestCasualties DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE article (id INT, title VARCHAR(255), publish_date DATE); INSERT INTO article (id, title, publish_date) VALUES (1, 'Article1', '2021-01-01'), (2, 'Article2', '2021-02-15'), (3, 'Article3', '2021-12-20');
How many articles were published on the website per month in 2021?
SELECT MONTH(publish_date), COUNT(*) FROM article WHERE YEAR(publish_date) = 2021 GROUP BY MONTH(publish_date);
gretelai_synthetic_text_to_sql
CREATE TABLE compliance_new (id INT PRIMARY KEY, vessel_id INT, act TEXT, FOREIGN KEY (vessel_id) REFERENCES vessels(id));
Insert a new compliance record for the 'Ocean Pollution Act' with vessel_id 3.
INSERT INTO compliance_new (vessel_id, act) VALUES ((SELECT id FROM vessels WHERE name = 'Test Vessel 3'), 'Ocean Pollution Act');
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, name TEXT, country TEXT); INSERT INTO users (id, name, country) VALUES (1, 'Eve', 'Germany'), (2, 'Frank', 'France'), (3, 'Sophia', 'UK'); CREATE TABLE digital_assets (id INT, user_id INT, value REAL); INSERT INTO digital_assets (id, user_id, value) VALUES (1, 1, 100), (2, 1, 200), (3, 2, 300), (4, 3, 400);
What is the total value of all digital assets owned by users in the European Union?
SELECT SUM(value) FROM digital_assets da INNER JOIN users u ON da.user_id = u.id WHERE u.country IN ('Germany', 'France', 'UK');
gretelai_synthetic_text_to_sql
CREATE TABLE public.vehicles (id INT, type VARCHAR(20), city VARCHAR(20)); INSERT INTO public.vehicles (id, type, city) VALUES (1, 'autonomous_bus', 'San Francisco'), (2, 'conventional_bus', 'San Francisco'), (3, 'autonomous_car', 'Los Angeles');
Find the number of autonomous buses in the city of 'San Francisco'
SELECT COUNT(*) FROM public.vehicles WHERE type = 'autonomous_bus' AND city = 'San Francisco';
gretelai_synthetic_text_to_sql
CREATE TABLE department (id INT, name VARCHAR(255)); CREATE TABLE researcher (id INT, name VARCHAR(255), department_id INT); CREATE TABLE grant (id INT, researcher_id INT, amount DECIMAL(10, 2));
What is the average number of grants awarded to researchers in the Computer Science department?
SELECT department.name, AVG(grant.amount) FROM department INNER JOIN researcher ON department.id = researcher.department_id INNER JOIN grant ON researcher.id = grant.researcher_id WHERE department.name = 'Computer Science' GROUP BY department.name;
gretelai_synthetic_text_to_sql
CREATE TABLE teacher_workshops (teacher_id INT, workshop_id INT, enrollment_date DATE); INSERT INTO teacher_workshops VALUES (1, 1001, '2021-01-01'), (1, 1002, '2021-02-01'); CREATE TABLE workshops (workshop_id INT, workshop_name VARCHAR(50)); INSERT INTO workshops VALUES (1001, 'Tech Tools'), (1002, 'Diverse Classrooms');
What is the progression of professional development workshops attended by a randomly selected teacher?
SELECT teacher_id, workshop_id, LEAD(enrollment_date, 1) OVER (PARTITION BY teacher_id ORDER BY enrollment_date) as next_workshop_date FROM teacher_workshops JOIN workshops ON teacher_workshops.workshop_id = workshops.workshop_id WHERE teacher_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE provinces (id INT, name TEXT, country TEXT); INSERT INTO provinces (id, name, country) VALUES (1, 'Buenos Aires', 'Argentina'), (2, 'Cordoba', 'Argentina');
What is the total crop yield for each crop grown in each province in Argentina?
SELECT crops.name, provinces.name as province_name, SUM(crop_yield.yield) FROM crop_yield JOIN farms ON crop_yield.farm_id = farms.id JOIN crops ON crop_yield.crop_id = crops.id JOIN provinces ON farms.id = provinces.id GROUP BY crops.name, provinces.name;
gretelai_synthetic_text_to_sql
CREATE TABLE oil_production (year INT, state VARCHAR(255), oil_quantity INT); INSERT INTO oil_production (year, state, oil_quantity) VALUES (2015, 'Texas', 1230000), (2016, 'Texas', 1500000), (2017, 'Texas', 1750000), (2018, 'Texas', 1900000), (2019, 'Texas', 2100000);
What was the total oil production in Texas in 2020?
SELECT SUM(oil_quantity) FROM oil_production WHERE year = 2020 AND state = 'Texas';
gretelai_synthetic_text_to_sql
CREATE TABLE SolanaHolders (id INT, address VARCHAR(100), balance DECIMAL(20,2)); INSERT INTO SolanaHolders (id, address, balance) VALUES (1, 'sol1...', 1000000), (2, 'sol2...', 500000), (3, 'sol3...', 300000);
Who are the top 3 holders of the Solana (SOL) cryptocurrency?
SELECT address, balance FROM SolanaHolders ORDER BY balance DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID int, FirstName varchar(50), LastName varchar(50), Department varchar(50), Gender varchar(50), Salary decimal(10,2)); INSERT INTO Employees (EmployeeID, FirstName, LastName, Department, Gender, Salary) VALUES (1, 'John', 'Doe', 'IT', 'Male', 75000); INSERT INTO Employees (EmployeeID, FirstName, LastName, Department, Gender, Salary) VALUES (2, 'Jane', 'Doe', 'HR', 'Female', 80000);
What is the minimum and maximum salary by department?
SELECT Department, MIN(Salary) as MinSalary, MAX(Salary) as MaxSalary FROM Employees GROUP BY Department;
gretelai_synthetic_text_to_sql
CREATE TABLE trial (id INT, company TEXT, year INT); INSERT INTO trial (id, company, year) VALUES (1, 'Germany Pharma', 2018); INSERT INTO trial (id, company, year) VALUES (2, 'Germany Pharma', 2019); INSERT INTO trial (id, company, year) VALUES (3, 'Germany Pharma', 2020); INSERT INTO trial (id, company, year) VALUES (4, 'USA Pharma', 2018); INSERT INTO trial (id, company, year) VALUES (5, 'USA Pharma', 2019);
How many clinical trials were conducted by companies located in Germany in 2018?
SELECT COUNT(*) FROM trial WHERE company LIKE '%Germany%' AND year = 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE games (id INT, home_team VARCHAR(50), away_team VARCHAR(50), season INT); INSERT INTO games (id, home_team, away_team, season) VALUES (1, 'Boston Celtics', 'Brooklyn Nets', 2022); INSERT INTO games (id, home_team, away_team, season) VALUES (2, 'Los Angeles Lakers', 'Golden State Warriors', 2022);
What is the total number of games played in the NBA this season?
SELECT COUNT(*) FROM games WHERE season = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, program_id INT, donation_date DATE); CREATE TABLE programs (id INT, program_name TEXT, is_discontinued BOOLEAN);
Delete all programs that have not had any donations in the last 2 years.
DELETE FROM programs WHERE programs.id NOT IN (SELECT donations.program_id FROM donations WHERE donations.donation_date >= DATE_SUB(CURDATE(), INTERVAL 2 YEAR));
gretelai_synthetic_text_to_sql
CREATE TABLE shipments (id INT, shipped_date DATE, destination VARCHAR(20), delivery_time INT); INSERT INTO shipments (id, shipped_date, destination, delivery_time) VALUES (1, '2022-02-05', 'Europe', 4), (2, '2022-02-07', 'Europe', 6), (3, '2022-02-16', 'Europe', 5);
What is the minimum delivery time for shipments to 'Europe' after the 1st of February?
SELECT MIN(delivery_time) FROM shipments WHERE shipped_date >= '2022-02-01' AND destination = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE rangers (id INT, name VARCHAR(255), region VARCHAR(255)); INSERT INTO rangers (id, name, region) VALUES (1, 'John', 'North America'), (2, 'Sophia', 'South America'), (3, 'Emma', 'Europe'), (4, 'Ethan', 'Africa'), (5, 'Ava', 'Asia'), (6, 'Ben', 'Asia Pacific');
Get the names of all rangers in the 'asia_pacific' region
SELECT name FROM rangers WHERE region = 'Asia Pacific';
gretelai_synthetic_text_to_sql
CREATE TABLE faculty (faculty_id INT, faculty_name VARCHAR(50)); CREATE TABLE publications (pub_id INT, faculty_id INT, pub_type VARCHAR(10)); INSERT INTO faculty (faculty_id, faculty_name) VALUES (1, 'John Doe'), (2, 'Jane Smith'); INSERT INTO publications (pub_id, faculty_id, pub_type) VALUES (100, 1, 'Journal'), (101, 1, 'Conference'), (102, 2, 'Journal'), (103, 2, 'Book');
What are the publication statistics for each faculty member?
SELECT f.faculty_name, COUNT(p.pub_id) AS num_publications, SUM(CASE WHEN p.pub_type = 'Journal' THEN 1 ELSE 0 END) AS num_journal_publications, SUM(CASE WHEN p.pub_type = 'Conference' THEN 1 ELSE 0 END) AS num_conference_publications FROM faculty f LEFT JOIN publications p ON f.faculty_id = p.faculty_id GROUP BY f.faculty_name;
gretelai_synthetic_text_to_sql
CREATE TABLE consumer_preferences (product_id INT, consumer_gender VARCHAR(10), preference_score FLOAT);
What are the most preferred cosmetic products among male consumers?
SELECT product_id, preference_score FROM consumer_preferences WHERE consumer_gender = 'male' ORDER BY preference_score DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE canada_mining_activity (id INT, year INT, activity_level INT);
What is the trend of mining activity in Canada over the past 5 years, and what is the projected trend for the next 5 years?
SELECT year, activity_level FROM canada_mining_activity WHERE year BETWEEN 2016 AND 2021 OR year BETWEEN 2026 AND 2031;
gretelai_synthetic_text_to_sql
CREATE TABLE infrastructure (region VARCHAR(20), project_type VARCHAR(20), count INT); INSERT INTO infrastructure (region, project_type, count) VALUES ('east', 'infrastructure', 150), ('west', 'infrastructure', 200);
Identify the total number of rural infrastructure projects in the 'east' and 'west' regions.
SELECT SUM(count) FROM infrastructure WHERE region IN ('east', 'west') AND project_type = 'infrastructure';
gretelai_synthetic_text_to_sql
CREATE TABLE energy_efficiency (id INT PRIMARY KEY, project_name VARCHAR(100), country VARCHAR(50), kwh_savings INT);
Update the country of the record with id 4001 in the 'energy_efficiency' table to 'Germany'
UPDATE energy_efficiency SET country = 'Germany' WHERE id = 4001;
gretelai_synthetic_text_to_sql
CREATE TABLE student_mental_health (student_id INT, score INT, race_ethnicity VARCHAR(20)); INSERT INTO student_mental_health (student_id, score, race_ethnicity) VALUES (1, 80, 'Asian'), (1, 85, 'Asian'), (2, 70, 'Hispanic'), (2, 75, 'Hispanic'), (3, 90, 'African American'), (3, 95, 'African American');
What is the trend of mental health scores by race/ethnicity?
SELECT race_ethnicity, AVG(score) as avg_score FROM student_mental_health GROUP BY race_ethnicity ORDER BY race_ethnicity;
gretelai_synthetic_text_to_sql
CREATE TABLE smart_cities (city VARCHAR(50), technology VARCHAR(50), energy_consumption FLOAT); INSERT INTO smart_cities (city, technology, energy_consumption) VALUES ('CityA', 'SmartLighting', 1000), ('CityB', 'SmartLighting', 1200), ('CityC', 'SmartTransport', 2000);
What is the average energy consumption (in kWh) per smart city technology in the smart_cities table, grouped by technology type?
SELECT technology, AVG(energy_consumption) as avg_energy_consumption FROM smart_cities GROUP BY technology;
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (id INT, user VARCHAR(255), amount DECIMAL(10, 2)); INSERT INTO Donations (id, user, amount) VALUES (1, 'John', 50.00), (2, 'Jane', 25.00);
Delete all donation records with an amount less than $50.
DELETE FROM Donations WHERE amount < 50;
gretelai_synthetic_text_to_sql
CREATE TABLE soil_moisture (field TEXT, moisture INTEGER, timestamp TIMESTAMP);
Show the change in soil moisture levels for each field over the past month.
SELECT field, DATEDIFF(day, MIN(timestamp), timestamp) as day_diff, AVG(moisture) as avg_moisture FROM soil_moisture GROUP BY field, DAY(timestamp) ORDER BY field, MIN(timestamp);
gretelai_synthetic_text_to_sql
CREATE TABLE movies (id INT, title VARCHAR(255), release_year INT, views INT, country VARCHAR(50), rating FLOAT); INSERT INTO movies (id, title, release_year, views, country, rating) VALUES (1, 'Movie1', 2010, 10000, 'Brazil', 7.5), (2, 'Movie2', 2015, 15000, 'Brazil', 8.2), (3, 'Movie3', 2020, 20000, 'Brazil', 8.8); CREATE TABLE tv_shows (id INT, title VARCHAR(255), release_year INT, views INT, country VARCHAR(50), rating FLOAT); INSERT INTO tv_shows (id, title, release_year, views, country, rating) VALUES (1, 'TVShow1', 2005, 20000, 'Brazil', 8.5), (2, 'TVShow2', 2018, 25000, 'Brazil', 9.0), (3, 'TVShow3', 2021, 30000, 'Brazil', 9.5);
What is the minimum rating for movies and TV shows in Brazil?
SELECT MIN(rating) FROM movies WHERE country = 'Brazil' UNION SELECT MIN(rating) FROM tv_shows WHERE country = 'Brazil';
gretelai_synthetic_text_to_sql
CREATE TABLE employees (id INT, plant TEXT, employee TEXT, hours_worked FLOAT, work_date DATE); INSERT INTO employees (id, plant, employee, hours_worked, work_date) VALUES (1, 'Great Lakes Plant 1', 'Employee C', 45, '2021-07-17'), (2, 'Great Lakes Plant 2', 'Employee D', 50, '2021-08-09');
What is the maximum number of working hours per employee in a week for chemical plants in the Great Lakes region, and the corresponding employee and plant?
SELECT MAX(hours_worked) AS max_hours, plant, employee FROM employees WHERE plant LIKE 'Great Lakes%' GROUP BY plant, employee HAVING max_hours = (SELECT MAX(hours_worked) FROM employees WHERE plant LIKE 'Great Lakes%');
gretelai_synthetic_text_to_sql
CREATE TABLE mental_health_diagnosis (patient_id INT, diagnosis_date DATE, diagnosis VARCHAR(50), prescriber_id INT); INSERT INTO mental_health_diagnosis (patient_id, diagnosis_date, diagnosis, prescriber_id) VALUES (1, '2022-01-01', 'Depression', 101); CREATE TABLE prescriber_details (id INT, prescriber_name VARCHAR(50), language VARCHAR(20), years_of_experience INT); INSERT INTO prescriber_details (id, prescriber_name, language, years_of_experience) VALUES (101, 'Dr. Smith', 'English', 15); CREATE TABLE community_health_workers (id INT, worker_name VARCHAR(50), language VARCHAR(20), years_in_service INT, district VARCHAR(30)); INSERT INTO community_health_workers (id, worker_name, language, years_in_service, district) VALUES (201, 'Ms. Garcia', 'Spanish', 8, 'Downtown'), (202, 'Mr. Nguyen', 'Vietnamese', 12, 'Uptown');
Calculate average mental health diagnosis per community health worker by district.
SELECT C.district, COUNT(DISTINCT M.patient_id) as AvgDiagnosisPerWorker FROM mental_health_diagnosis M JOIN prescriber_details P ON M.prescriber_id = P.id JOIN community_health_workers C ON P.language = C.language GROUP BY C.district;
gretelai_synthetic_text_to_sql
CREATE TABLE cultural_heritage_sites (site_id INT, site_name TEXT, is_virtual_tour BOOLEAN); INSERT INTO cultural_heritage_sites (site_id, site_name, is_virtual_tour) VALUES (1, 'Machu Picchu', false), (2, 'Taj Mahal', true), (3, 'Colosseum', false);
List all cultural heritage sites and their virtual tour availability status.
SELECT site_name, is_virtual_tour FROM cultural_heritage_sites;
gretelai_synthetic_text_to_sql
CREATE TABLE accessible_tech_patents (org_name VARCHAR(50), year INT, accessible_patents INT); INSERT INTO accessible_tech_patents (org_name, year, accessible_patents) VALUES ('ABC Corp', 2021, 120), ('XYZ Inc', 2020, 150), ('DEF Org', 2021, 180), ('GHI Ltd', 2020, 100), ('JKL Co', 2021, 210); CREATE TABLE total_patents (org_name VARCHAR(50), year INT, total_patents INT); INSERT INTO total_patents (org_name, year, total_patents) VALUES ('ABC Corp', 2021, 200), ('XYZ Inc', 2020, 250), ('DEF Org', 2021, 300), ('GHI Ltd', 2020, 200), ('JKL Co', 2021, 350);
Determine the percentage of accessible technology patents for each organization in the last year, ordered by the highest percentage.
SELECT a.org_name, (a.accessible_patents * 100.0 / b.total_patents) as percentage FROM accessible_tech_patents a JOIN total_patents b ON a.org_name = b.org_name WHERE a.year = 2021 GROUP BY a.org_name ORDER BY percentage DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Revenue (restaurant VARCHAR(255), state VARCHAR(255), revenue DECIMAL(10,2)); INSERT INTO Revenue (restaurant, state, revenue) VALUES ('Bistro Veggie', 'California', 35000), ('Pizza House', 'New York', 50000), ('Vegan Delight', 'California', 40000);
Show revenue for restaurants located in 'California' from the 'Revenue' table.
SELECT revenue FROM Revenue WHERE state = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE investments (investment_id INT, investor_id INT, org_id INT, investment_amount INT); INSERT INTO investments (investment_id, investor_id, org_id, investment_amount) VALUES (1, 1, 2, 50000), (2, 2, 3, 75000), (3, 1, 1, 100000), (4, 3, 2, 35000), (5, 2, 1, 80000); CREATE TABLE investors (investor_id INT, investor_name TEXT); INSERT INTO investors (investor_id, investor_name) VALUES (1, 'Investor A'), (2, 'Investor B'), (3, 'Investor C'); CREATE TABLE organizations (org_id INT, org_name TEXT, focus_topic TEXT); INSERT INTO organizations (org_id, org_name, focus_topic) VALUES (1, 'Org 1', 'Social Impact'), (2, 'Org 2', 'Social Impact'), (3, 'Org 3', 'Climate Change');
What is the number of organizations and total invested amount by each investor for organizations focused on social impact?
SELECT investors.investor_name, COUNT(organizations.org_id) AS orgs_invested, SUM(investments.investment_amount) AS total_invested FROM investments JOIN investors ON investments.investor_id = investors.investor_id JOIN organizations ON investments.org_id = organizations.org_id WHERE organizations.focus_topic = 'Social Impact' GROUP BY investors.investor_name;
gretelai_synthetic_text_to_sql
CREATE TABLE FashionBrands (brand TEXT, country TEXT, years_in_business INTEGER); INSERT INTO FashionBrands (brand, country, years_in_business) VALUES ('Brand1', 'Italy', 15), ('Brand2', 'France', 8), ('Brand3', 'Spain', 20), ('Brand4', 'Germany', 12);
Find the top 2 countries with the highest number of fashion brands, and show only those brands that have been in business for more than 10 years.
SELECT country, COUNT(*) as brand_count FROM FashionBrands WHERE years_in_business > 10 GROUP BY country ORDER BY brand_count DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE donors (donor_id INT, donor_name VARCHAR(50), donor_country VARCHAR(50), donation_amount DECIMAL(10,2), donation_date DATE); INSERT INTO donors (donor_id, donor_name, donor_country, donation_amount, donation_date) VALUES (1, 'John Doe', 'USA', 50.00, '2020-01-01');
What is the total amount of donations made by the top 5 donors for the year 2020?
SELECT donor_name, SUM(donation_amount) AS total_donation FROM (SELECT donor_name, donation_amount, ROW_NUMBER() OVER (ORDER BY donation_amount DESC) AS rank FROM donors WHERE YEAR(donation_date) = 2020) donors_ranked WHERE rank <= 5 GROUP BY donor_name;
gretelai_synthetic_text_to_sql
CREATE TABLE tb_cases (id INT, patient_id INT, report_date DATE, province VARCHAR(255), is_active BOOLEAN);
What is the number of TB cases reported in each province of Canada, by year?
SELECT YEAR(report_date) AS year, province, COUNT(*) AS num_tb_cases FROM tb_cases WHERE is_active = TRUE GROUP BY year, province;
gretelai_synthetic_text_to_sql
CREATE TABLE artists (artist_id INT, artist_name VARCHAR(100), gender VARCHAR(10)); INSERT INTO artists (artist_id, artist_name, gender) VALUES (1, 'Taylor Swift', 'Female'), (2, 'Ed Sheeran', 'Male'), (3, 'Kendrick Lamar', 'Male'), (4, 'Ariana Grande', 'Female'); CREATE TABLE songs (song_id INT, song_name VARCHAR(100), release_year INT, gender VARCHAR(10)); INSERT INTO songs (song_id, song_name, release_year, gender) VALUES (1, 'Shape of You', 2017, 'Male'), (2, 'Thinking Out Loud', 2014, 'Male'), (3, 'Bohemian Rhapsody', 1975, 'Male'), (4, 'Problem', 2014, 'Female'), (5, 'The Way', 2013, 'Female'); CREATE TABLE streams (stream_id INT, song_id INT, streams INT); INSERT INTO streams (stream_id, song_id, streams) VALUES (1, 1, 1000000), (2, 1, 750000), (3, 2, 800000), (4, 2, 600000), (5, 3, 50000), (6, 3, 40000), (7, 4, 300000), (8, 4, 250000), (9, 5, 100000), (10, 5, 90000);
How many streams did 'Female Artists' have on their songs released in the last 5 years?
SELECT SUM(s.streams) FROM songs so INNER JOIN artists a ON so.gender = a.gender INNER JOIN streams s ON so.song_id = s.song_id WHERE a.gender = 'Female' AND so.release_year BETWEEN 2016 AND 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE sales_region (id INT, region VARCHAR(20), vehicle_type VARCHAR(20), year INT, quantity INT); INSERT INTO sales_region (id, region, vehicle_type, year, quantity) VALUES (1, 'North', 'ev', 2018, 1500), (2, 'North', 'ev', 2019, 2500), (3, 'South', 'ev', 2018, 1000), (4, 'South', 'ev', 2019, 2000), (5, 'East', 'ev', 2018, 800), (6, 'East', 'ev', 2019, 3000), (7, 'West', 'ev', 2018, 2000), (8, 'West', 'ev', 2019, 4000);
Determine the number of electric vehicles (ev) sold in each region in 2019
SELECT region, year, SUM(quantity) FROM sales_region WHERE vehicle_type = 'ev' GROUP BY region, year;
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (VolunteerID int, State varchar(50), VolunteerDate date); INSERT INTO Volunteers (VolunteerID, State, VolunteerDate) VALUES (1, 'California', '2022-01-01'), (2, 'Texas', '2022-05-15');
How many volunteers signed up in each state in 2022?
SELECT State, COUNT(*) as NumVolunteers FROM Volunteers WHERE VolunteerDate BETWEEN '2022-01-01' AND '2022-12-31' GROUP BY State;
gretelai_synthetic_text_to_sql
CREATE TABLE manufacturing_data (id INT PRIMARY KEY, chemical_name VARCHAR(255), quantity_produced INT, date_manufactured DATE);
Insert a new record into the "manufacturing_data" table
INSERT INTO manufacturing_data (id, chemical_name, quantity_produced, date_manufactured) VALUES (1, 'Ammonia', 100, '2022-01-01');
gretelai_synthetic_text_to_sql
CREATE TABLE CriminalCases (Id INT, State VARCHAR(50), Program VARCHAR(50), ResolutionDate DATE); INSERT INTO CriminalCases (Id, State, Program, ResolutionDate) VALUES (1, 'California', 'Diversion', '2020-03-21'), (2, 'Texas', 'Probation', '2019-12-12'), (3, 'NewYork', 'Diversion', '2020-06-15');
Find the number of criminal cases that were resolved through diversion programs in each state in 2020.
SELECT State, COUNT(*) as NumCases FROM CriminalCases WHERE Program = 'Diversion' AND YEAR(ResolutionDate) = 2020 GROUP BY State;
gretelai_synthetic_text_to_sql
CREATE TABLE VehicleSales (year INT, country VARCHAR(255), vehicle_type VARCHAR(255), sales INT); INSERT INTO VehicleSales (year, country, vehicle_type, sales) VALUES (2015, 'Canada', 'Hybrid', 15000), (2016, 'Canada', 'Hybrid', 20000), (2017, 'Canada', 'Hybrid', 30000), (2018, 'Canada', 'Hybrid', 40000), (2019, 'Canada', 'Hybrid', 50000), (2020, 'Canada', 'Hybrid', 60000);
What is the number of hybrid vehicles sold in Canada each year since 2015?
SELECT year, SUM(sales) AS hybrid_vehicle_sales FROM VehicleSales WHERE country = 'Canada' AND vehicle_type = 'Hybrid' GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE Deliveries (delivery_id INT, delivery_date DATE, item_id INT, quantity INT, country TEXT); CREATE TABLE Items (item_id INT, item_name TEXT);
List all deliveries made to Syria in 2022 that included medical supplies.
SELECT Deliveries.* FROM Deliveries INNER JOIN Items ON Deliveries.item_id = Items.item_id WHERE Deliveries.country = 'Syria' AND Deliveries.delivery_date BETWEEN '2022-01-01' AND '2022-12-31' AND Items.item_name LIKE '%medical%';
gretelai_synthetic_text_to_sql
CREATE TABLE wells (well_id VARCHAR(10), well_location VARCHAR(20)); INSERT INTO wells (well_id, well_location) VALUES ('C03', 'North Sea'); CREATE TABLE production (well_id VARCHAR(10), production_count INT); INSERT INTO production (well_id, production_count) VALUES ('C03', 7000);
Delete the record for well 'C03' in 'North Sea'.
DELETE FROM production WHERE well_id = 'C03';
gretelai_synthetic_text_to_sql
CREATE TABLE Arctic_Research_Station_6 (id INT, community TEXT); CREATE TABLE Arctic_Research_Station_7 (id INT, community TEXT);
How many indigenous communities are in the Arctic Research Station 6 and 7?
SELECT COUNT(DISTINCT community) FROM Arctic_Research_Station_6; SELECT COUNT(DISTINCT community) FROM Arctic_Research_Station_7; SELECT COUNT(DISTINCT community) FROM (SELECT * FROM Arctic_Research_Station_6 UNION ALL SELECT * FROM Arctic_Research_Station_7) AS Arctic_Communities;
gretelai_synthetic_text_to_sql
CREATE TABLE patients (patient_id INT, age INT, gender TEXT, condition TEXT, treatment TEXT); INSERT INTO patients (patient_id, age, gender, condition, treatment) VALUES (1, 35, 'Female', 'Depression', 'CBT'), (2, 40, 'Male', 'Anxiety', 'Medication');
What is the average age of patients for each condition?
SELECT condition, AVG(age) as avg_age FROM patients GROUP BY condition;
gretelai_synthetic_text_to_sql
CREATE TABLE articles (id INT, title VARCHAR(100), topic VARCHAR(50), date DATE); INSERT INTO articles (id, title, topic, date) VALUES (1, 'Article 1', 'Politics', '2021-01-01'); INSERT INTO articles (id, title, topic, date) VALUES (2, 'Article 2', 'Sports', '2021-01-02'); INSERT INTO articles (id, title, topic, date) VALUES (3, 'Article 3', 'Politics', '2021-01-03');
What is the total number of articles by topic?
SELECT topic, COUNT(*) as total_articles FROM articles GROUP BY topic;
gretelai_synthetic_text_to_sql
CREATE TABLE FieldA_Sensors (sensor_id INT, temperature FLOAT, reading_time DATETIME); INSERT INTO FieldA_Sensors (sensor_id, temperature, reading_time) VALUES (1, 23.5, '2022-01-01 10:00:00'), (1, 25.3, '2022-01-02 10:00:00');
What is the average temperature recorded by IoT sensors in the past week in the 'FieldA'?
SELECT AVG(temperature) FROM FieldA_Sensors WHERE reading_time BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK) AND CURRENT_DATE;
gretelai_synthetic_text_to_sql