context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE revenue (id INT, game VARCHAR(30), genre VARCHAR(20), revenue INT, country VARCHAR(20)); INSERT INTO revenue (id, game, genre, revenue, country) VALUES (1, 'Skyrim', 'RPG', 1000000, 'US'), (2, 'CS:GO', 'FPS', 500000, 'US'), (3, 'Half-Life: Alyx', 'VR', 2000000, 'US');
What is the total revenue generated by each game genre in the US?
SELECT genre, SUM(revenue) AS total_revenue FROM revenue WHERE country = 'US' GROUP BY genre;
gretelai_synthetic_text_to_sql
CREATE TABLE Artworks (ArtworkID INT, ExhibitionID INT, VisitorID INT);
What's the average number of artworks viewed per visitor in the 'Europe' region?
SELECT AVG(a.ArtworksViewed) FROM (SELECT v.VisitorID, COUNT(a.ArtworkID) ArtworksViewed FROM Artworks a JOIN Exhibitions e ON a.ExhibitionID = e.ExhibitionID JOIN Visitors v ON a.VisitorID = v.VisitorID JOIN Regions r ON v.Country = r.CountryName WHERE r.Region = 'Europe' GROUP BY v.VisitorID) a;
gretelai_synthetic_text_to_sql
CREATE TABLE artist_streams (stream_id int, user_id int, track_id int, timestamp datetime, artist_id int); INSERT INTO artist_streams (stream_id, user_id, track_id, timestamp, artist_id) VALUES (1, 123, 345, '2022-01-01 10:00:00', 678);
What is the number of streams by hour for a specific artist in Germany?
SELECT DATE_FORMAT(timestamp, '%H') as hour, COUNT(*) as stream_count FROM artist_streams WHERE artist_id = 678 AND timestamp BETWEEN '2022-01-01' AND '2022-12-31' AND DATE_FORMAT(timestamp, '%Y-%m') = '2022-01' AND country = 'Germany' GROUP BY hour;
gretelai_synthetic_text_to_sql
CREATE TABLE species_status (id INT, name VARCHAR(255), status VARCHAR(255)); INSERT INTO species_status (id, name, status) VALUES (1, 'Dolphin', 'Endangered'); INSERT INTO species_status (id, name, status) VALUES (2, 'Shark', 'Vulnerable'); INSERT INTO species_status (id, name, status) VALUES (3, 'Tuna', 'Endang...
Report the total number of marine species that are endangered
SELECT COUNT(*) FROM species_status WHERE status = 'Endangered';
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, DonorName TEXT, DonorGender TEXT, TotalDonation FLOAT);
What is the difference between the average donation amount for male and female donors in 2021?
SELECT AVG(CASE WHEN DonorGender = 'Male' THEN TotalDonation ELSE 0 END) as 'Average Donation Amount for Males', AVG(CASE WHEN DonorGender = 'Female' THEN TotalDonation ELSE 0 END) as 'Average Donation Amount for Females', AVG(CASE WHEN DonorGender IN ('Male', 'Female') THEN TotalDonation ELSE 0 END) as 'Average Donati...
gretelai_synthetic_text_to_sql
CREATE TABLE farmers (id INT, name VARCHAR(50)); CREATE TABLE crops_farmers (farmer_id INT, crop_id INT); CREATE TABLE crops (id INT, name VARCHAR(50)); INSERT INTO farmers (id, name) VALUES (1, 'John'), (2, 'Jane'), (3, 'Mary'); INSERT INTO crops (id, name) VALUES (1, 'Corn'), (2, 'Soybean'), (3, 'Wheat'); INSERT INTO...
What are the names of the farmers who have cultivated more than one type of crop?
SELECT f.name FROM farmers f JOIN crops_farmers cf ON f.id = cf.farmer_id JOIN crops c ON cf.crop_id = c.id GROUP BY f.name HAVING COUNT(DISTINCT c.name) > 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Indigenous_Communities (id INT, name VARCHAR(100), population INT, location VARCHAR(100), language VARCHAR(100)); INSERT INTO Indigenous_Communities (id, name, population, location, language) VALUES (1, 'Inuit', 15000, 'Greenland', 'Greenlandic'); INSERT INTO Indigenous_Communities (id, name, population, l...
What are the names and locations of indigenous communities in Greenland with a population over 10,000 that speak Greenlandic?
SELECT name, location FROM Indigenous_Communities WHERE population > 10000 AND language = 'Greenlandic'
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (ArtistID int, ArtistName varchar(50), BirthYear int); CREATE TABLE Artworks (ArtworkID int, ArtistID int, ArtworkYear int, ArtworkTitle varchar(50));
How many artworks were created by each artist in the 20th century?
SELECT Artists.ArtistName, COUNT(Artworks.ArtworkID) as TotalArtworks FROM Artists INNER JOIN Artworks ON Artists.ArtistID = Artworks.ArtistID WHERE Artworks.ArtworkYear BETWEEN 1900 AND 2000 GROUP BY Artists.ArtistName;
gretelai_synthetic_text_to_sql
game_stats(player_id, game_id, score, date_played)
Find the total number of games played by each player
SELECT player_id, COUNT(DISTINCT game_id) as total_games_played FROM game_stats GROUP BY player_id;
gretelai_synthetic_text_to_sql
CREATE TABLE security_incidents (id INT, threat_actor VARCHAR(255), timestamp DATETIME);
Which threat actors have been involved in the most security incidents in the last month?
SELECT threat_actor, COUNT(*) as total_incidents FROM security_incidents WHERE timestamp >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY threat_actor ORDER BY total_incidents DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE crimes (id INT, district VARCHAR(20), type VARCHAR(20), date DATE); INSERT INTO crimes (id, district, type, date) VALUES (1, 'Downtown', 'Theft', '2022-01-02'); INSERT INTO crimes (id, district, type, date) VALUES (2, 'Uptown', 'Vandalism', '2022-01-03'); INSERT INTO crimes (id, district, type, date) VALUE...
What is the most common type of crime committed in the South district?
SELECT type, COUNT(*) AS count FROM crimes WHERE district = 'South' GROUP BY type ORDER BY count DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE basketball_teams (team_name TEXT, athlete_name TEXT, athlete_age INTEGER);
What is the average age of athletes in the basketball_teams table?
SELECT AVG(athlete_age) FROM basketball_teams;
gretelai_synthetic_text_to_sql
CREATE TABLE china_cerium (id INT, year INT, price DECIMAL); INSERT INTO china_cerium (id, year, price) VALUES (1, 2015, 150), (2, 2016, 160), (3, 2017, 170);
What is the minimum price of cerium produced in China in 2017?
SELECT MIN(price) FROM china_cerium WHERE year = 2017;
gretelai_synthetic_text_to_sql
CREATE TABLE medical_supplies (id INT, delivery_id INT, destination_country VARCHAR(255), delivery_quantity INT, delivery_date DATE); INSERT INTO medical_supplies (id, delivery_id, destination_country, delivery_quantity, delivery_date) VALUES (1, 2001, 'Nigeria', 500, '2020-10-01'); INSERT INTO medical_supplies (id, de...
How many medical supplies were delivered to "Africa" in Q4 2020?
SELECT SUM(delivery_quantity) FROM medical_supplies WHERE destination_country = 'Africa' AND QUARTER(delivery_date) = 4 AND YEAR(delivery_date) = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE vessel (vessel_id INT, vessel_name VARCHAR(20), vessel_type VARCHAR(10)); INSERT INTO vessel VALUES (1, 'V1', 'Bulk Carrier'), (2, 'V2', 'Container Ship'); CREATE TABLE incident (incident_id INT, vessel_id INT, incident_date DATE, incident_type VARCHAR(20)); INSERT INTO incident VALUES (1, 1, '2022-04-15',...
How many regulatory compliance incidents were reported for 'Container Ship' vessels in Q2 2022?
SELECT COUNT(*) FROM incident INNER JOIN vessel ON incident.vessel_id = vessel.vessel_id WHERE vessel.vessel_type = 'Container Ship' AND incident_date BETWEEN '2022-04-01' AND '2022-06-30' AND incident_type = 'Regulatory Compliance';
gretelai_synthetic_text_to_sql
CREATE TABLE socially_responsible_lending (id INT, country VARCHAR(50), loan_amount DECIMAL(10,2));
What is the total loan amount for socially responsible lending in the Caribbean?
SELECT SUM(loan_amount) FROM socially_responsible_lending WHERE country LIKE 'Caribbean%';
gretelai_synthetic_text_to_sql
CREATE TABLE shared_bikes (bike_id INT, availability_date DATE, availability_time TIME, availability_count INT); INSERT INTO shared_bikes (bike_id, availability_date, availability_time, availability_count) VALUES (1, '2022-01-01', '06:00:00', 100), (2, '2022-01-01', '12:00:00', 120), (3, '2022-01-01', '18:00:00', 90);
How many shared bikes were available in Berlin during each day in January 2022?
SELECT availability_date, COUNT(DISTINCT bike_id) AS bikes_available FROM shared_bikes WHERE availability_time BETWEEN '06:00:00' AND '23:59:59' GROUP BY availability_date
gretelai_synthetic_text_to_sql
CREATE TABLE StatePopulation (State VARCHAR(100), Population INT, RuralPopulation INT); INSERT INTO StatePopulation (State, Population, RuralPopulation) VALUES ('Florida', 21674000, 2584000);
What is the total population of the state of Florida, and what is the percentage of the population that lives in rural areas?
SELECT (RuralPopulation / Population) * 100.0 AS RuralPercentage, Population FROM StatePopulation WHERE State = 'Florida';
gretelai_synthetic_text_to_sql
CREATE TABLE vessels_region (vessel_id INT, vessel_name TEXT, region TEXT); INSERT INTO vessels_region VALUES (1, 'Vessel A', 'Americas'), (2, 'Vessel B', 'Asia Pacific'), (3, 'Vessel C', 'Americas'); CREATE TABLE cargo_region (vessel_id INT, cargo_quantity INT); INSERT INTO cargo_region VALUES (1, 1200), (2, 900), (3,...
What are the vessel names and their corresponding total cargo quantities for the Americas region?
SELECT vessels_region.vessel_name, SUM(cargo_region.cargo_quantity) FROM vessels_region INNER JOIN cargo_region ON vessels_region.vessel_id = cargo_region.vessel_id WHERE vessels_region.region = 'Americas' GROUP BY vessels_region.vessel_name;
gretelai_synthetic_text_to_sql
CREATE TABLE company (id INT, name TEXT); CREATE TABLE exit_strategy (id INT, company_id INT, exit_date DATE, exit_type TEXT);
List all companies that have had an acquisition as an exit strategy and their corresponding exit date.
SELECT company.name, exit_strategy.exit_date FROM company JOIN exit_strategy ON company.id = exit_strategy.company_id WHERE exit_strategy.exit_type = 'Acquisition';
gretelai_synthetic_text_to_sql
CREATE TABLE animal_population (animal_id INT, animal_type VARCHAR(10), age INT); INSERT INTO animal_population (animal_id, animal_type, age) VALUES (1, 'cheetah', 8); INSERT INTO animal_population (animal_id, animal_type, age) VALUES (2, 'cheetah', 6);
What is the average age of all cheetahs in the 'animal_population' table?
SELECT AVG(age) FROM animal_population WHERE animal_type = 'cheetah';
gretelai_synthetic_text_to_sql
CREATE TABLE MilitaryPersonnel (region VARCHAR(255), country VARCHAR(255), personnel INT); INSERT INTO MilitaryPersonnel (region, country, personnel) VALUES ('Africa', 'CountryA', 4000), ('Africa', 'CountryB', 6000), ('Africa', 'CountryC', 5000), ('Asia', 'CountryD', 3000), ('Asia', 'CountryE', 2000);
What is the minimum number of military personnel in the Asian region, excluding personnel from countries with more than 10000 personnel?
SELECT MIN(personnel) FROM MilitaryPersonnel WHERE region = 'Asia' HAVING SUM(personnel) < 10000;
gretelai_synthetic_text_to_sql
CREATE TABLE telescopes (id INT, name VARCHAR(255), country VARCHAR(255), type VARCHAR(255), launch_date DATE); INSERT INTO telescopes (id, name, country, type, launch_date) VALUES (1, 'Hubble Space Telescope', 'USA', 'Optical', '1990-04-24'); INSERT INTO telescopes (id, name, country, type, launch_date) VALUES (2, 'Sp...
What are the names and launch dates of telescopes launched by Japan or India?
SELECT name, launch_date FROM telescopes WHERE country = 'Japan' OR country = 'India';
gretelai_synthetic_text_to_sql
CREATE TABLE healthcare_providers (id INT, name VARCHAR(50), area_type VARCHAR(20));
What is the total number of healthcare providers in urban and rural areas?
SELECT COUNT(*) FROM healthcare_providers WHERE area_type IN ('urban', 'rural');
gretelai_synthetic_text_to_sql
CREATE TABLE games (id INT, team_a TEXT, team_b TEXT, location TEXT, score_team_a INT, score_team_b INT); INSERT INTO games (id, team_a, team_b, location, score_team_a, score_team_b) VALUES (1, 'Team A', 'Team H', 'Home', 120, 130), (2, 'Team H', 'Team B', 'Away', 150, 120);
What was the highest scoring game for Team H in the 2017 season?
SELECT MAX(GREATEST(score_team_a, score_team_b)) FROM games WHERE team_a = 'Team H' OR team_b = 'Team H' AND year = 2017;
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_rates (region VARCHAR(50), year INT, recycling_rate FLOAT); INSERT INTO recycling_rates (region, year, recycling_rate) VALUES ('South America', 2019, 0.45);
What is the total recycling rate for South America in the year 2019?
SELECT SUM(recycling_rate) FROM recycling_rates WHERE region = 'South America' AND year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (volunteer_id INT, program_id VARCHAR(20), hours INT); INSERT INTO volunteers (volunteer_id, program_id, hours) VALUES (1, 'Education', 50), (2, 'Health', 75), (3, 'Education', 100);
What is the maximum number of volunteer hours for a single volunteer in each program?
SELECT program_id, MAX(hours) AS max_hours FROM volunteers GROUP BY program_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Exhibitions (ExhibitionID INT, Exhibition VARCHAR(50)); INSERT INTO Exhibitions (ExhibitionID, Exhibition) VALUES (1, 'Photography'), (2, 'Sculpture'); CREATE TABLE Visitors (VisitorID INT, Age INT, ExhibitionID INT); INSERT INTO Visitors (VisitorID, Age, ExhibitionID) VALUES (1, 30, 1), (2, 45, 1), (3, 25...
What is the difference in age between the oldest and youngest visitor, partitioned by exhibition?
SELECT Exhibition, MAX(Age) - MIN(Age) AS AgeDifference FROM Visitors V JOIN Exhibitions E ON V.ExhibitionID = E.ExhibitionID GROUP BY Exhibition;
gretelai_synthetic_text_to_sql
CREATE TABLE patents (id INT, title VARCHAR(50), technology VARCHAR(50), location VARCHAR(50)); INSERT INTO patents (id, title, technology, location) VALUES (1, 'BioSensor 1000', 'Biosensor', 'Germany');
List all biosensor technology patents filed in Germany.
SELECT title FROM patents WHERE technology = 'Biosensor' AND location = 'Germany';
gretelai_synthetic_text_to_sql
CREATE TABLE Cases (CaseID int, ClientID int, OpenDate date); INSERT INTO Cases (CaseID, ClientID, OpenDate) VALUES (1, 1, '2021-01-01'); CREATE TABLE Clients (ClientID int, State text); INSERT INTO Clients (ClientID, State) VALUES (1, 'California');
How many cases were opened in each state in 2021?
SELECT Clients.State, COUNT(*) as NumCases FROM Cases INNER JOIN Clients ON Cases.ClientID = Clients.ClientID WHERE Cases.OpenDate BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY Clients.State;
gretelai_synthetic_text_to_sql
CREATE TABLE community_health_workers (id INT, name VARCHAR(50), age INT, state VARCHAR(2)); INSERT INTO community_health_workers (id, name, age, state) VALUES (1, 'John Doe', 45, 'Texas'), (2, 'Jane Smith', 35, 'California'), (3, 'Alice Johnson', 20, 'California'), (4, 'Bob Brown', 50, 'New York');
What is the minimum age of community health workers in each state?
SELECT state, MIN(age) FROM community_health_workers GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name TEXT, industry TEXT, founding_date DATE, founder_gender TEXT, founder_count INT);CREATE TABLE funds (id INT, company_id INT, amount INT, funding_round TEXT);CREATE TABLE company_funds (company_id INT, fund_id INT);
Determine the average funding amount for companies founded by a team that is at least 50% women in the e-commerce industry.
SELECT AVG(funds.amount) FROM funds INNER JOIN company_funds ON funds.id = company_funds.fund_id INNER JOIN companies ON company_funds.company_id = companies.id WHERE companies.industry = 'e-commerce' GROUP BY companies.id HAVING SUM(CASE WHEN companies.founder_gender = 'woman' THEN companies.founder_count ELSE 0 END) ...
gretelai_synthetic_text_to_sql
CREATE TABLE employee_demographics(emp_id INT, dept_id INT, race VARCHAR(50)); INSERT INTO employee_demographics VALUES (1, 1, 'White'), (2, 1, 'Black'), (3, 2, 'Asian'), (4, 2, 'White'), (5, 3, 'Hispanic');
Calculate the percentage of employees who are people of color, by department
SELECT d.dept_name, (COUNT(CASE WHEN e.race IN ('Black', 'Asian', 'Hispanic') THEN 1 END) / COUNT(e.emp_id)) * 100 as pct_employees_of_color FROM departments d JOIN employee_demographics e ON d.dept_id = e.dept_id GROUP BY d.dept_name;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists biotech; CREATE TABLE if not exists biotech.patents (id INT, name VARCHAR(50), location VARCHAR(50), filed_date DATE, industry VARCHAR(50)); INSERT INTO biotech.patents (id, name, location, filed_date, industry) VALUES (1, 'PatentA', 'India', '2021-05-15', 'Bioprocess Engineering'), (2, 'Pat...
What is the average bioprocess engineering patent filing date, per country, in the past 5 years?
SELECT location, AVG(filed_date) as avg_filing_date FROM biotech.patents WHERE industry = 'Bioprocess Engineering' AND filed_date >= DATE_SUB(CURRENT_DATE, INTERVAL 5 YEAR) GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE Weather (field VARCHAR(50), date DATE, temperature FLOAT); INSERT INTO Weather (field, date, temperature) VALUES ('Field A', '2021-03-01', 15.2), ('Field A', '2021-03-02', 16.7), ('Field A', '2021-03-03', 14.5);
What is the average temperature in field A during March?
SELECT AVG(temperature) FROM Weather WHERE field = 'Field A' AND date BETWEEN '2021-03-01' AND '2021-03-31';
gretelai_synthetic_text_to_sql
CREATE TABLE anti_discrimination_training (id INT, worker_id INT, training_date DATE); INSERT INTO anti_discrimination_training (id, worker_id, training_date) VALUES (1, 789, '2021-04-01'), (2, 789, '2021-06-15'); CREATE TABLE community_health_workers (id INT, name VARCHAR(50), region VARCHAR(50)); INSERT INTO communit...
What is the percentage of community health workers in California who have received anti-discrimination training?
SELECT 100.0 * COUNT(DISTINCT anti_discrimination_training.worker_id) / COUNT(DISTINCT community_health_workers.id) FROM anti_discrimination_training RIGHT JOIN community_health_workers ON anti_discrimination_training.worker_id = community_health_workers.id WHERE community_health_workers.region = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE programs (id INT, name VARCHAR); CREATE TABLE financial_donations (id INT, program_id INT, amount INT)
Show programs with donation amounts over $10,000, ordered by total donation
SELECT p.name, SUM(fd.amount) AS total_donation FROM programs p JOIN financial_donations fd ON p.id = fd.program_id GROUP BY p.id, p.name HAVING total_donation > 10000 ORDER BY total_donation DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE diversity_quota (id INT PRIMARY KEY, region VARCHAR(255), gender VARCHAR(255), ethnicity VARCHAR(255), total_employees INT);
Create a table named 'diversity_quota' to store diversity metrics
CREATE TABLE diversity_quota (id INT PRIMARY KEY, region VARCHAR(255), gender VARCHAR(255), ethnicity VARCHAR(255), total_employees INT);
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (ArtistID INT PRIMARY KEY, ArtistName VARCHAR(100), Gender VARCHAR(50)); INSERT INTO Artists (ArtistID, ArtistName, Gender) VALUES (1, 'Alice Neel', 'Female'), (2, 'Francisco Goya', 'Male'), (3, 'Yayoi Kusama', 'Female'); CREATE TABLE Artworks (ArtworkID INT PRIMARY KEY, ArtworkName VARCHAR(100), Y...
What is the total number of artworks created by female artists?
SELECT COUNT(*) FROM Artworks INNER JOIN Artists ON Artworks.ArtistID = Artists.ArtistID WHERE Artists.Gender = 'Female';
gretelai_synthetic_text_to_sql
CREATE TABLE SpaceMissions (id INT, name VARCHAR(255), launch_date DATE); INSERT INTO SpaceMissions (id, name, launch_date) VALUES (1, 'Mars Rover', '2020-07-30'), (2, 'Mars Habitat', '2022-03-01');
What is the earliest launch date for a mission to Mars?
SELECT MIN(launch_date) FROM SpaceMissions WHERE name LIKE '%Mars%';
gretelai_synthetic_text_to_sql
CREATE TABLE users (user_id INT, country VARCHAR(50), joined_date DATE);CREATE TABLE data_privacy_laws (country VARCHAR(50), privacy_level INT); INSERT INTO users (user_id, country, joined_date) VALUES (1, 'USA', '2023-02-15'), (2, 'Germany', '2023-02-27'); INSERT INTO data_privacy_laws (country, privacy_level) VALUES ...
How many new users joined from countries with stricter data privacy laws than the United States in the past month?
SELECT COUNT(user_id) FROM users JOIN data_privacy_laws ON users.country = data_privacy_laws.country WHERE data_privacy_laws.privacy_level > (SELECT privacy_level FROM data_privacy_laws WHERE country = 'USA') AND joined_date >= DATEADD(month, -1, CURRENT_DATE);
gretelai_synthetic_text_to_sql
CREATE TABLE TrafficViolations (ID INT, District VARCHAR(20), Fine FLOAT); INSERT INTO TrafficViolations (ID, District, Fine) VALUES (1, 'District1', 100.0), (2, 'District2', 150.0), (3, 'District1', 120.0), (4, 'District3', 75.0);
What is the average fine for traffic violations in each district?
SELECT District, AVG(Fine) OVER (PARTITION BY District) AS AvgFine FROM TrafficViolations;
gretelai_synthetic_text_to_sql
CREATE TABLE clinical_trials (country TEXT, trial_status TEXT); INSERT INTO clinical_trials (country, trial_status) VALUES ('Canada', 'Completed'), ('Canada', 'Terminated');
List all clinical trials that were conducted in Canada and have a status of 'Completed' or 'Terminated'.
SELECT * FROM clinical_trials WHERE country = 'Canada' AND trial_status IN ('Completed', 'Terminated');
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists 'disease_data' (id INT, state TEXT, disease TEXT, prevalence INT, PRIMARY KEY(id));
Get disease prevalence per state
SELECT state, AVG(prevalence) FROM 'disease_data' GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE departments (id INT, name VARCHAR(50), budget FLOAT); INSERT INTO departments (id, name, budget) VALUES (1, 'HR', 300000.00), (2, 'IT', 500000.00); CREATE TABLE employees (id INT, name VARCHAR(50), department VARCHAR(50), salary FLOAT); INSERT INTO employees (id, name, department, salary) VALUES (1, 'John ...
What is the total salary expense for the HR department?
SELECT SUM(e.salary) FROM employees e INNER JOIN departments d ON e.department = d.name WHERE d.name = 'HR';
gretelai_synthetic_text_to_sql
CREATE TABLE Departments (DepartmentID INT, Name TEXT, Budget DECIMAL(10,2)); INSERT INTO Departments VALUES (1, 'Marketing', 50000.00), (2, 'Operations', 70000.00);
What is the average budget for each department in Q3 of 2021?
SELECT Name, AVG(Budget) FROM Departments WHERE QUARTER(Date) = 3 AND YEAR(Date) = 2021 GROUP BY Name;
gretelai_synthetic_text_to_sql
CREATE TABLE Programs (id INT, name TEXT, category TEXT, budget INT); INSERT INTO Programs (id, name, category, budget) VALUES (1, 'Dance Performance', 'Theater', 50000), (2, 'Film Festival', 'Music', 75000), (3, 'Photography Exhibition', 'Visual Arts', 100000);
Show the total amount of funding for programs in 'Theater' category, excluding programs with a budget over $50,000.
SELECT SUM(budget) FROM Programs WHERE category = 'Theater' AND budget <= 50000;
gretelai_synthetic_text_to_sql
CREATE TABLE Clients (ClientID INT, Name TEXT); INSERT INTO Clients VALUES (1, 'Thomas'), (2, 'Ramirez'), (3, 'Gonzalez'), (4, 'Clark'); CREATE TABLE Cases (CaseID INT, ClientID INT, Quarter TEXT); INSERT INTO Cases VALUES (1, 1, 'Q1'), (2, 2, 'Q2'), (3, 3, 'Q3'), (4, 1, 'Q4'), (5, 4, 'Q4');
What are the names of clients who have had cases in both the first quarter and the fourth quarter?
SELECT c.Name FROM Clients c INNER JOIN Cases n ON c.ClientID = n.ClientID WHERE n.Quarter = 'Q1' INTERSECT SELECT c.Name FROM Clients c INNER JOIN Cases t ON c.ClientID = t.ClientID WHERE t.Quarter = 'Q4';
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, nonprofit_id INT, donation_date DATE, amount DECIMAL(10, 2));
Delete all donations made in January 2022
DELETE FROM donations WHERE donation_date BETWEEN '2022-01-01' AND '2022-01-31';
gretelai_synthetic_text_to_sql
CREATE TABLE peacekeeping (id INT, country VARCHAR(50), num_operations INT);
What is the number of peacekeeping operations participated in by each country in the 'peacekeeping' table, excluding those with less than 3 operations, ordered by the number of operations in ascending order?
SELECT country, COUNT(*) as num_operations FROM peacekeeping GROUP BY country HAVING COUNT(*) >= 3 ORDER BY num_operations ASC;
gretelai_synthetic_text_to_sql
CREATE TABLE regulatory_frameworks (framework_id INT, framework_name VARCHAR(50), framework_jurisdiction VARCHAR(50), enforcement_agency VARCHAR(50), implementation_year INT);
How many regulatory frameworks have been implemented in Africa per year?
CREATE VIEW africa_frameworks_per_year AS SELECT TO_CHAR(implementation_year, 'YYYY') AS implementation_year, COUNT(framework_id) AS frameworks_implemented FROM regulatory_frameworks WHERE framework_jurisdiction = 'Africa' GROUP BY implementation_year ORDER BY implementation_year;
gretelai_synthetic_text_to_sql
CREATE TABLE players (player_id INT, name TEXT); INSERT INTO players (player_id, name) VALUES (1, 'Messi'), (2, 'Ronaldo'); CREATE TABLE penalties (penalty_id INT, player_id INT); INSERT INTO penalties (penalty_id, player_id) VALUES (1, 1), (2, 1), (3, 2);
Count the number of penalties taken by 'Messi' in all competitions.
SELECT COUNT(*) FROM penalties JOIN players ON penalties.player_id = players.player_id WHERE players.name = 'Messi';
gretelai_synthetic_text_to_sql
CREATE TABLE food_safety(inspection_id INT, inspector VARCHAR(255), restaurant VARCHAR(255), inspection_date DATE, result ENUM('Pass', 'Fail'));
Update the food safety records for the 'Sushi Bar' restaurant to 'Fail' for the 'Health Inspector' with ID 890.
UPDATE food_safety SET result = 'Fail' WHERE restaurant = 'Sushi Bar' AND inspector = '890';
gretelai_synthetic_text_to_sql
CREATE TABLE Projects (id INT, name VARCHAR(30), region VARCHAR(20), negotiation_start_date DATE, negotiation_end_date DATE);
What is the average negotiation duration for defense projects in the Middle East?
SELECT AVG(DATEDIFF(negotiation_end_date, negotiation_start_date)) as avg_negotiation_duration FROM Projects WHERE region = 'Middle East';
gretelai_synthetic_text_to_sql
CREATE TABLE GameSales (GameID INT, GameType VARCHAR(10), SaleDate DATE); INSERT INTO GameSales (GameID, GameType, SaleDate) VALUES (1, 'Mobile', '2022-01-01'), (2, 'PC', '2022-01-02');
What is the total number of games sold in the last month?
SELECT COUNT(*) FROM GameSales WHERE SaleDate >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH)
gretelai_synthetic_text_to_sql
CREATE TABLE ai_research (research_id INT, area VARCHAR(50), region VARCHAR(20)); INSERT INTO ai_research (research_id, area, region) VALUES (1, 'computer vision', 'South America'), (2, 'natural language processing', 'South America'), (3, 'machine learning', 'North America'), (4, 'reinforcement learning', 'Europe');
What is the distribution of AI research areas in South America?
SELECT area, COUNT(*) as frequency FROM ai_research WHERE region = 'South America' GROUP BY area;
gretelai_synthetic_text_to_sql
CREATE TABLE crop_moisture (crop_type TEXT, measurement_date DATE, soil_moisture INT); INSERT INTO crop_moisture (crop_type, measurement_date, soil_moisture) VALUES ('Corn', '2022-06-01', 650), ('Soybeans', '2022-06-01', 700), ('Wheat', '2022-06-01', 550);
What are the average soil moisture levels for each crop type in the month of June?
SELECT crop_type, AVG(soil_moisture) FROM crop_moisture WHERE measurement_date BETWEEN '2022-06-01' AND '2022-06-30' GROUP BY crop_type;
gretelai_synthetic_text_to_sql
CREATE TABLE games_v2 (game_id INT, game_name VARCHAR(50), playtime INT); INSERT INTO games_v2 (game_id, game_name, playtime) VALUES (4, 'GameD', 4000), (5, 'GameE', 5000);
What is the total playtime for each game in the 'games_v2' table?
SELECT game_name, SUM(playtime) FROM games_v2 GROUP BY game_name;
gretelai_synthetic_text_to_sql
CREATE TABLE Faculty_Members (Faculty_ID INT, First_Name VARCHAR(50), Last_Name VARCHAR(50), Title VARCHAR(20), Department VARCHAR(50), Hire_Date DATE, Salary DECIMAL(10, 2));
Delete records in the 'Faculty_Members' table where the 'Title' is 'Visiting Scholar' and 'Hire_Date' is before '2018-01-01
DELETE FROM Faculty_Members WHERE Title = 'Visiting Scholar' AND Hire_Date < '2018-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tour (tour_id INT, name TEXT, city TEXT, length INT); INSERT INTO virtual_tour (tour_id, name, city, length) VALUES (3, 'NYC Skyline', 'New York City', 45);
Delete virtual tours in New York City with a length less than 30 minutes.
DELETE FROM virtual_tour WHERE city = 'New York City' AND length < 30;
gretelai_synthetic_text_to_sql
CREATE TABLE FishProduction (Species TEXT, Quantity INT); INSERT INTO FishProduction (Species, Quantity) VALUES ('Tilapia', 6000000), ('Salmon', 3500000), ('Shrimp', 5000000), ('Cod', 2000000), ('Pangasius', 1200000);
what are the top 3 fish species in terms of global production?
SELECT Species, Quantity FROM FishProduction ORDER BY Quantity DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Attorneys (AttorneyID INT, BarExamAttempts INT);
How many cases were handled by attorneys who passed the bar exam on the first attempt?
SELECT COUNT(*) FROM Attorneys WHERE BarExamAttempts = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE biosensors(id INT, project VARCHAR(50), city VARCHAR(50), budget DECIMAL(10,2)); INSERT INTO biosensors VALUES (1, 'ProjectA', 'LA', 3000000.00), (2, 'ProjectB', 'NYC', 5000000.00), (3, 'ProjectC', 'LA', 4000000.00);
What is the maximum budget for a biosensor technology project in each city?
SELECT city, MAX(budget) FROM biosensors GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE arctic_research (id INTEGER, type TEXT);
How many times was each type of research conducted in the 'arctic_research' table, excluding 'climate change' research?
SELECT type, COUNT(*) FROM arctic_research WHERE type != 'climate change' GROUP BY type;
gretelai_synthetic_text_to_sql
CREATE TABLE country_donations (country_id INT, country_name VARCHAR(50), total_donations DECIMAL(10,2), donation_year INT, avg_donation DECIMAL(10,2)); INSERT INTO country_donations (country_id, country_name, total_donations, donation_year, avg_donation) VALUES (1, 'USA', 50000.00, 2021, 100.00), (2, 'Canada', 40000.0...
Find the top 2 countries with the highest total donation amounts in 2021 and their respective average donation amounts?
SELECT donation_year, country_name, total_donations, AVG(avg_donation) avg_donation, RANK() OVER (ORDER BY total_donations DESC) country_rank FROM country_donations WHERE donation_year = 2021 AND country_rank <= 2 GROUP BY donation_year, country_name, total_donations;
gretelai_synthetic_text_to_sql
CREATE TABLE Sites (SiteID int, Name text, Country text); INSERT INTO Sites (SiteID, Name, Country) VALUES (1, 'SiteA', 'USA'); CREATE TABLE Artifacts (ArtifactID int, Name text, SiteID int, ExcavationYear int); INSERT INTO Artifacts (ArtifactID, Name, SiteID, ExcavationYear) VALUES (1, 'Artifact1', 2, 2005);
Which sites in 'North America' have no excavated artifacts?
SELECT Name FROM Sites LEFT JOIN Artifacts ON Sites.SiteID = Artifacts.SiteID WHERE Artifacts.SiteID IS NULL AND Country = 'North America';
gretelai_synthetic_text_to_sql
CREATE TABLE Games (GameID INT, Genre VARCHAR(20), Revenue INT, ReleaseYear INT); INSERT INTO Games (GameID, Genre, Revenue, ReleaseYear) VALUES (1, 'Sports', 5000000, 2019), (2, 'RPG', 7000000, 2020), (3, 'Strategy', 6000000, 2019), (4, 'Sports', 8000000, 2020), (5, 'RPG', 9000000, 2019);
What is the total revenue for each game genre in 2019 and 2020?
SELECT Genre, ReleaseYear, SUM(Revenue) as TotalRevenue FROM Games GROUP BY Genre, ReleaseYear
gretelai_synthetic_text_to_sql
CREATE TABLE judges (judge_id INT, name VARCHAR(50)); INSERT INTO judges (judge_id, name) VALUES (1, 'John Doe'), (2, 'Jane Smith'), (3, 'Robert Johnson'); CREATE TABLE cases (case_id INT, judge_id INT, case_status VARCHAR(10)); INSERT INTO cases (case_id, judge_id, case_status) VALUES (101, 1, 'open'), (102, 1, 'dismi...
Display the total number of cases and the number of dismissed cases for each judge, ordered by the total number of cases?
SELECT judge_id, COUNT(*) as total_cases, SUM(CASE WHEN case_status = 'dismissed' THEN 1 ELSE 0 END) as dismissed_cases FROM cases GROUP BY judge_id ORDER BY total_cases DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE mines (id INT, name TEXT, location TEXT, annual_production INT); INSERT INTO mines (id, name, location, annual_production) VALUES (1, 'Mine A', 'Country X', 1500), (2, 'Mine B', 'Country Y', 2000), (3, 'Mine C', 'Country Z', 1750);
Which mine produced the most REE in 2021?
SELECT name, MAX(annual_production) as max_production FROM mines WHERE YEAR(timestamp) = 2021 GROUP BY name;
gretelai_synthetic_text_to_sql
CREATE TABLE REVENUE(city VARCHAR(20), revenue DECIMAL(5,2)); INSERT INTO REVENUE(city, revenue) VALUES('Tokyo', 2000.00), ('Tokyo', 1800.00), ('Sydney', 2500.00), ('Sydney', 2200.00);
What is the revenue of sustainable fashion sales in Tokyo and Sydney?
SELECT SUM(revenue) FROM REVENUE WHERE city IN ('Tokyo', 'Sydney') AND revenue > 1500.00;
gretelai_synthetic_text_to_sql
CREATE TABLE bus_waiting_times (bus_id INT, waiting_time INT); INSERT INTO bus_waiting_times (bus_id, waiting_time) VALUES (1, 10), (2, 5), (3, 15), (4, 8), (5, 12);
What is the average waiting time for buses in the Rome public transportation network?
SELECT AVG(waiting_time) FROM bus_waiting_times;
gretelai_synthetic_text_to_sql
CREATE TABLE Indigenous_Communities (id INT, name VARCHAR(100), population INT, location VARCHAR(100), language VARCHAR(100)); INSERT INTO Indigenous_Communities (id, name, population, location, language) VALUES (1, 'Inuit', 80000, 'Canada', 'Inuktitut'); INSERT INTO Indigenous_Communities (id, name, population, locati...
What are the names and populations of indigenous communities in Canada that speak Inuktitut or Yupik?
SELECT name, population FROM Indigenous_Communities WHERE (language = 'Inuktitut' OR language = 'Yupik') AND location = 'Canada'
gretelai_synthetic_text_to_sql
CREATE TABLE military_innovation (id INT, region VARCHAR, project_count INT);
What is the total number of military innovation projects for each region?
SELECT region, SUM(project_count) FROM military_innovation GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE expeditions (id INT PRIMARY KEY, name VARCHAR(255), objective VARCHAR(255), start_date DATE, end_date DATE, budget FLOAT);
Which expeditions have a budget greater than $500,000 and were completed in the last 3 years?
SELECT name, budget FROM expeditions WHERE budget > 500000 AND end_date >= DATE_SUB(CURDATE(), INTERVAL 3 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE CrueltyFreeMakeupSales (sale_id INT, product_name TEXT, is_cruelty_free BOOLEAN, sale_amount FLOAT, sale_date DATE, country TEXT); INSERT INTO CrueltyFreeMakeupSales (sale_id, product_name, is_cruelty_free, sale_amount, sale_date, country) VALUES (1, 'Cruelty-Free Lipstick', TRUE, 25.00, '2021-01-10', 'USA...
determine the average sale price of cruelty-free makeup products in the USA
SELECT AVG(sale_amount) FROM CrueltyFreeMakeupSales WHERE is_cruelty_free = TRUE AND country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_acidity (ocean VARCHAR(255), region VARCHAR(255), acidity FLOAT); INSERT INTO ocean_acidity (ocean, region, acidity) VALUES ('Indian', 'Indonesia', 8.2); INSERT INTO ocean_acidity (ocean, region, acidity) VALUES ('Indian', 'Sri Lanka', 8.1);
What is the maximum ocean acidity level in the Indian Ocean near Indonesia?
SELECT MAX(acidity) FROM ocean_acidity WHERE ocean = 'Indian' AND region = 'Indonesia';
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_subscribers (subscriber_id INT, name VARCHAR(255), country VARCHAR(255)); INSERT INTO mobile_subscribers (subscriber_id, name, country) VALUES (1, 'Jane Doe', 'USA'), (2, 'Maria Garcia', 'Mexico');
What is the total number of mobile subscribers in each country?
SELECT country, COUNT(*) FROM mobile_subscribers GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE PolicyAdvocacy (AdvocacyID INT, AdvocacyType VARCHAR(50), InitiativeID INT, StartDate DATE, EndDate DATE); INSERT INTO PolicyAdvocacy (AdvocacyID, AdvocacyType, InitiativeID, StartDate, EndDate) VALUES (1, 'Legislation', 1, '2020-01-01', '2020-04-15'); INSERT INTO PolicyAdvocacy (AdvocacyID, AdvocacyType, ...
What is the average time taken for disability policy advocacy initiatives to be implemented, categorized by initiative type?
SELECT AdvocacyType, AVG(DATEDIFF(DAY, StartDate, EndDate)) AS AvgTime FROM PolicyAdvocacy GROUP BY AdvocacyType;
gretelai_synthetic_text_to_sql
CREATE TABLE events (event_id INT, event_name VARCHAR(50), city VARCHAR(30), attendance INT); INSERT INTO events (event_id, event_name, city, attendance) VALUES (1, 'Theater Play', 'New York', 200), (2, 'Art Exhibit', 'Los Angeles', 300), (3, 'Music Festival', 'New York', 400);
Display the event name and its corresponding city for all events with attendance greater than 250
SELECT event_name, city FROM events WHERE attendance > 250;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_life (id INT, species VARCHAR(255), population INT, region VARCHAR(255)); INSERT INTO marine_life (id, species, population, region) VALUES (1, 'Salmon', 15000, 'pacific_ocean'); INSERT INTO marine_life (id, species, population, region) VALUES (2, 'Lionfish', 1200, 'atlantic_ocean'); INSERT INTO mari...
List all species in the marine_life table with their population counts for the arctic_ocean region, ordered by population in descending order.
SELECT species, population, region FROM marine_life WHERE region = 'arctic_ocean' ORDER BY population DESC;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists genetics;CREATE TABLE if not exists genetics.research_data_1 (id INT PRIMARY KEY, sample_id VARCHAR(50), sample_date DATE);CREATE TABLE if not exists genetics.research_data_2 (id INT PRIMARY KEY, sample_id VARCHAR(50), sample_result INT);CREATE TABLE if not exists genetics.research_data_3 (i...
List all genetic research data tables that have a 'sample_date' column.
SELECT table_name FROM information_schema.columns WHERE table_schema = 'genetics' AND column_name = 'sample_date';
gretelai_synthetic_text_to_sql
CREATE TABLE farm (id INT PRIMARY KEY, name VARCHAR(50), region_id INT, avg_temp DECIMAL(5,2)); CREATE TABLE region (id INT PRIMARY KEY, name VARCHAR(50)); INSERT INTO region (id, name) VALUES (1, 'Midwest'), (2, 'South'); INSERT INTO farm (id, name, region_id, avg_temp) VALUES (1, 'Smith Farm', 1, 15.5), (2, 'Jones Fa...
What is the average temperature for all regions growing 'Corn'?
SELECT AVG(f.avg_temp) FROM farm f INNER JOIN region r ON f.region_id = r.id WHERE r.name IN (SELECT name FROM region WHERE id IN (SELECT region_id FROM farm WHERE name = 'Corn'));
gretelai_synthetic_text_to_sql
CREATE TABLE flu_cases (id INT, age INT, location TEXT, year INT); INSERT INTO flu_cases (id, age, location, year) VALUES (1, 5, 'Florida', 2019); INSERT INTO flu_cases (id, age, location, year) VALUES (2, 25, 'Florida', 2018); INSERT INTO flu_cases (id, age, location, year) VALUES (3, 65, 'Florida', 2019);
Find the number of flu cases for each age group in Florida in 2019?
SELECT flu_cases.age, COUNT(flu_cases.id) FROM flu_cases WHERE flu_cases.location = 'Florida' AND flu_cases.year = 2019 GROUP BY flu_cases.age;
gretelai_synthetic_text_to_sql
CREATE TABLE urban_schools (student_id INT, survey_score INT); INSERT INTO urban_schools VALUES (1001, 80), (1002, 85), (1003, 90); CREATE TABLE open_pedagogy_programs (student_id INT, program_type VARCHAR(50)); INSERT INTO open_pedagogy_programs VALUES (1001, 'Online'), (1002, 'Blended'), (1003, 'In-person');
What is the average mental health survey score for students in urban schools who have participated in open pedagogy programs?
SELECT AVG(survey_score) FROM urban_schools JOIN open_pedagogy_programs ON urban_schools.student_id = open_pedagogy_programs.student_id WHERE program_type = 'Online' OR program_type = 'Blended';
gretelai_synthetic_text_to_sql
CREATE TABLE CreativeAI (app_id INT, app_name VARCHAR(255), region VARCHAR(255), safety_score DECIMAL(5,2)); INSERT INTO CreativeAI (app_id, app_name, region, safety_score) VALUES (1, 'DreamApp', 'US', 85.2), (2, 'Invento', 'India', 88.7), (3, 'AIArtist', 'Canada', 91.5), (4, 'ScriptBot', 'UK', 96.8);
What is the average safety score of creative AI applications by region, ordered by the highest average score?
SELECT region, AVG(safety_score) as avg_safety_score FROM CreativeAI GROUP BY region ORDER BY avg_safety_score DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE wildlife_habitats (id INT, name VARCHAR(255), population INT, density FLOAT);
List all wildlife habitats with a population density over 5
SELECT * FROM wildlife_habitats WHERE density > 5;
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, Name VARCHAR(100), Country VARCHAR(50), TotalHoursPlayed INT, Platform VARCHAR(50)); INSERT INTO Players VALUES (1, 'Michael Brown', 'USA', 50, 'PC'); INSERT INTO Players VALUES (2, 'Emily White', 'Canada', 35, 'Console'); CREATE TABLE GameDesign (GameID INT, GameName VARCHAR(100), G...
Count the number of unique players who have played sports games and have spent more than 30 hours on them, regardless of platform.
SELECT COUNT(DISTINCT P.PlayerID) as UniquePlayers FROM Players P JOIN GameDesign GD ON P.PlayerID = GD.GameID WHERE GD.Genre = 'Sports' AND P.TotalHoursPlayed > 30;
gretelai_synthetic_text_to_sql
CREATE TABLE Inspections (restaurant_id INT, inspection_date DATE, violation_count INT); INSERT INTO Inspections (restaurant_id, inspection_date, violation_count) VALUES (2, '2020-04-01', 3), (2, '2020-07-15', 2);
List all food safety violations for 'Budget Burger' in Q2 2020.
SELECT * FROM Inspections WHERE restaurant_id = 2 AND EXTRACT(QUARTER FROM inspection_date) = 2 AND EXTRACT(YEAR FROM inspection_date) = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE programs (name VARCHAR(255), location VARCHAR(255), arts VARCHAR(255)); INSERT INTO programs (name, location, arts) VALUES ('Program1', 'North America', 'Art1, Art2'), ('Program2', 'North America', 'Art2, Art3'), ('Program3', 'Europe', 'Art1');
Identify the community engagement programs in North America that have the most diverse range of traditional art forms.
SELECT location, COUNT(DISTINCT arts) AS diversity FROM programs WHERE location = 'North America' GROUP BY location ORDER BY diversity DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE user_posts (post_id INT, user_id INT, hashtags VARCHAR(255)); INSERT INTO user_posts (post_id, user_id) VALUES (1, 1), (2, 2), (3, 3); CREATE TABLE post_hashtags (post_id INT, hashtags VARCHAR(255)); INSERT INTO post_hashtags (post_id, hashtags) VALUES (1, '#music'), (1, '#food'), (2, '#nature'), (3, '#mus...
What is the total number of posts with the hashtag "#music" for users from the UK in the "user_posts" and "post_hashtags" tables?
SELECT COUNT(DISTINCT up.post_id) FROM user_posts up JOIN post_hashtags ph ON up.post_id = ph.post_id JOIN user_profiles upr ON up.user_id = upr.id WHERE ph.hashtags LIKE '%#music%' AND upr.country = 'UK';
gretelai_synthetic_text_to_sql
CREATE TABLE nurses (id INT, name VARCHAR(50), salary DECIMAL(10, 2), is_union_member BOOLEAN, department VARCHAR(50)); INSERT INTO nurses (id, name, salary, is_union_member, department) VALUES (1, 'Peter', 60000.00, false, 'nursing'), (2, 'Penny', 65000.00, true, 'nursing'), (3, 'Patrick', 55000.00, false, 'nursing');
What is the minimum salary for workers in the 'healthcare_database' database who are not members of a union and work in the 'nursing' department?
SELECT MIN(salary) FROM nurses WHERE is_union_member = false AND department = 'nursing';
gretelai_synthetic_text_to_sql
CREATE TABLE materials (id INT, name TEXT, ethical_source BOOLEAN); CREATE TABLE inventory (id INT, material_id INT, quantity INT); INSERT INTO materials (id, name, ethical_source) VALUES (1, 'Material A', true), (2, 'Material B', false), (3, 'Material C', true); INSERT INTO inventory (id, material_id, quantity) VALUES...
What is the total quantity of ethically sourced materials in stock?
SELECT SUM(inventory.quantity) FROM inventory INNER JOIN materials ON inventory.material_id = materials.id WHERE materials.ethical_source = true;
gretelai_synthetic_text_to_sql
CREATE TABLE environmental_impact (id INT, date DATE, co2_emissions FLOAT);
Identify the monthly trend of CO2 emissions in the past year.
SELECT EXTRACT(MONTH FROM date) as month, AVG(co2_emissions) as avg_co2_emissions FROM environmental_impact WHERE date >= DATEADD(year, -1, CURRENT_DATE) GROUP BY EXTRACT(MONTH FROM date) ORDER BY EXTRACT(MONTH FROM date);
gretelai_synthetic_text_to_sql
CREATE TABLE criminal_justice_reform_groups (group_id INT, country VARCHAR(50));
What is the number of criminal justice reform advocacy groups in each country?
SELECT country, COUNT(*) FROM criminal_justice_reform_groups GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE fleet (id INT PRIMARY KEY, name VARCHAR(255), type VARCHAR(255)); INSERT INTO fleet (id, name, type) VALUES (1, 'City Bus', 'Conventional'), (2, 'Trolley', 'Electric'), (3, 'Autonomous Shuttle', NULL);
Add a new autonomous shuttle to the fleet table.
UPDATE fleet SET type = 'Autonomous' WHERE id = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE eco_hotels (hotel_id INT, hotel_name TEXT, country TEXT, certification_level INT, occupancy_rate DECIMAL); INSERT INTO eco_hotels (hotel_id, hotel_name, country, certification_level, occupancy_rate) VALUES (401, 'Asia Eco Lodge', 'India', 4, 0.85), (402, 'Bali Green Resort', 'Indonesia', 5, 0.90), (403, 'J...
What is the average occupancy rate of eco-friendly hotels in Europe with certification level 5?
SELECT AVG(occupancy_rate) as avg_occupancy_rate FROM eco_hotels WHERE country IN ('France') AND certification_level = 5;
gretelai_synthetic_text_to_sql
CREATE TABLE users (user_id INT, first_name VARCHAR(50), last_name VARCHAR(50), age INT, gender VARCHAR(10), country VARCHAR(50), accepted_privacy_policy BOOLEAN);
What is the percentage of users who have accepted our data privacy policy in each country, in the past 6 months?
SELECT country, ROUND(100.0 * SUM(CASE WHEN accepted_privacy_policy THEN 1 ELSE 0 END) / COUNT(user_id) OVER (PARTITION BY country), 2) AS acceptance_percentage FROM users WHERE accepted_privacy_policy IS NOT NULL AND post_date >= (CURRENT_DATE - INTERVAL '6 months') GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE Patients (PatientID int, PatientName varchar(50), ClinicID int); CREATE TABLE Addresses (AddressID int, Address varchar(50), ClinicID int, Longitude decimal(10,8), Latitude decimal(10,8)); INSERT INTO Patients (PatientID, PatientName, ClinicID) VALUES (1, 'Patient A', 1); INSERT INTO Addresses (AddressID, ...
What is the average distance from rural healthcare professionals to their patients?
SELECT AVG(ST_Distance(Patients.Address, Addresses)) AS AvgDistance FROM Patients JOIN Addresses ON Patients.ClinicID = Addresses.ClinicID;
gretelai_synthetic_text_to_sql
CREATE TABLE Smart_Contracts (Contract_ID INT, Gas_Fees DECIMAL(10,2), Developer_Location VARCHAR(50)); INSERT INTO Smart_Contracts (Contract_ID, Gas_Fees, Developer_Location) VALUES (1, 50.50, 'Germany'), (2, 75.25, 'China'), (3, 30.00, 'France');
What are the average gas fees for Ethereum smart contracts executed by developers in the EU and Asia?
SELECT AVG(Gas_Fees) FROM Smart_Contracts WHERE Developer_Location IN ('EU', 'Asia');
gretelai_synthetic_text_to_sql
CREATE TABLE canada_traffic_accidents (id INT, year INT, province VARCHAR(255), num_accidents INT); INSERT INTO canada_traffic_accidents (id, year, province, num_accidents) VALUES (1, 2012, 'Ontario', 187000);
What is the total number of traffic accidents in Canada, by province, for the last 10 years?
SELECT province, SUM(num_accidents) AS total_accidents FROM canada_traffic_accidents WHERE year BETWEEN 2012 AND 2021 GROUP BY province;
gretelai_synthetic_text_to_sql