context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE Volunteers (VolunteerID int, EventID int, Hours decimal(5,2)); INSERT INTO Volunteers (VolunteerID, EventID, Hours) VALUES (1, 100, 5.5), (2, 101, 7.2), (3, 100, 3.8), (4, 102, 6.5), (5, 101, 8.0);
What is the total number of volunteers who participated in events in 2021, and the average number of hours they contributed?
SELECT COUNT(DISTINCT VolunteerID), AVG(Hours) FROM Volunteers INNER JOIN (SELECT EventID FROM Events WHERE EXTRACT(YEAR FROM EventDate) = 2021) AS EventLocations ON Volunteers.EventID = EventLocations.EventID;
gretelai_synthetic_text_to_sql
CREATE TABLE subscriber_data (subscriber_id INT, subscriber_type VARCHAR(10), country VARCHAR(20)); INSERT INTO subscriber_data (subscriber_id, subscriber_type, country) VALUES (1, 'Mobile', 'USA'), (2, 'Broadband', 'Canada'), (3, 'Mobile', 'Mexico');
Display the difference between the total number of mobile and broadband subscribers in each country, excluding 'Canada' and 'Mexico'
SELECT country, (SUM(CASE WHEN subscriber_type = 'Mobile' THEN 1 ELSE 0 END) - SUM(CASE WHEN subscriber_type = 'Broadband' THEN 1 ELSE 0 END)) as subscriber_difference FROM subscriber_data WHERE country NOT IN ('Canada', 'Mexico') GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE SCHEMA EcoPower; CREATE TABLE RenewableProjects (project_id INT, name VARCHAR(100), type VARCHAR(50), installed_capacity INT); INSERT INTO RenewableProjects (project_id, name, type, installed_capacity) VALUES (1, 'SolarFarm 1', 'Solar', 100000), (2, 'WindFarm 2', 'Wind', 80000), (3, 'HydroProject 1', 'Hydro', 12...
Which renewable energy projects have the highest installed capacity in the 'EcoPower' schema?
SELECT name, installed_capacity FROM EcoPower.RenewableProjects ORDER BY installed_capacity DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE teachers (id INT, subject_area TEXT);CREATE TABLE courses (id INT, teacher_id INT, subject_area TEXT);CREATE TABLE course_completions (course_id INT, completion_date DATE);
What is the number of teachers who have completed professional development courses in each subject area?
SELECT teachers.subject_area, COUNT(DISTINCT courses.id) as courses_completed FROM teachers INNER JOIN courses ON teachers.id = courses.teacher_id INNER JOIN course_completions ON courses.id = course_completions.course_id GROUP BY teachers.subject_area;
gretelai_synthetic_text_to_sql
CREATE TABLE Manufacturers (ManufacturerID INT, ManufacturerName VARCHAR(50), Region VARCHAR(50)); INSERT INTO Manufacturers (ManufacturerID, ManufacturerName, Region) VALUES (1, 'EcoFriendlyFabrics', 'Europe'), (2, 'GreenYarns', 'Asia'); CREATE TABLE Materials (MaterialID INT, MaterialName VARCHAR(50), QuantityUsed IN...
What is the average quantity of sustainable materials used per manufacturer in the 'Asia' region?
SELECT AVG(QuantityUsed) FROM Materials INNER JOIN Manufacturers ON Materials.ManufacturerID = Manufacturers.ManufacturerID WHERE Region = 'Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE videos (id text, category text, region text, watch_time integer); INSERT INTO videos (id, category, region, watch_time) VALUES ('VideoA', 'investigative journalism', 'North America', 3600); INSERT INTO videos (id, category, region, watch_time) VALUES ('VideoB', 'investigative journalism', 'Europe', 4200);
What is the total watch time for videos in the 'investigative journalism' category, grouped by region?
SELECT region, SUM(watch_time) as total_watch_time FROM videos WHERE category = 'investigative journalism' GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (id INT, name TEXT, ocean TEXT); INSERT INTO marine_species (id, name, ocean) VALUES (1, 'Polar Bear', 'Arctic'); INSERT INTO marine_species (id, name, ocean) VALUES (2, 'Krill', 'Southern'); INSERT INTO marine_species (id, name, ocean) VALUES (3, 'Beluga Whale', 'Arctic'); INSERT INTO marin...
How many marine species are there in the Arctic Ocean compared to the Southern Ocean?
SELECT ocean, COUNT(*) FROM marine_species GROUP BY ocean;
gretelai_synthetic_text_to_sql
CREATE TABLE na_nurses (country VARCHAR(50), nurses_per_1000 DECIMAL(3,1)); INSERT INTO na_nurses (country, nurses_per_1000) VALUES ('Canada', 10.8), ('USA', 11.9);
What is the number of practicing nurses per 1000 people in North America by country?
SELECT country, AVG(nurses_per_1000 * 1000) as nurses_per_1000_people FROM na_nurses GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE Social_Good_Accessibility (country VARCHAR(255), budget INT, score INT); INSERT INTO Social_Good_Accessibility (country, budget, score) VALUES ('Sweden', 4000000, 90), ('Norway', 3000000, 85), ('Finland', 2000000, 80);
What is the correlation between the budget allocated for social good initiatives and the technology accessibility score by country?
SELECT country, CORR(budget, score) as correlation FROM Social_Good_Accessibility;
gretelai_synthetic_text_to_sql
CREATE TABLE states (id INT, name VARCHAR(255)); INSERT INTO states (id, name) VALUES (1, 'Texas'); CREATE TABLE veteran_stats (id INT, state_id INT, employed INT, unemployed INT); INSERT INTO veteran_stats (id, state_id, employed, unemployed) VALUES (1, 1, 5000, 1000);
List all veteran employment stats for Texas state.
SELECT state_id, employed, unemployed FROM veteran_stats WHERE state_id = (SELECT id FROM states WHERE name = 'Texas');
gretelai_synthetic_text_to_sql
CREATE TABLE media_outlets_na (id INT, name TEXT, country TEXT, media_literacy_score INT); INSERT INTO media_outlets_na (id, name, country, media_literacy_score) VALUES (1, 'Media Outlet 1', 'USA', 5); INSERT INTO media_outlets_na (id, name, country, media_literacy_score) VALUES (2, 'Media Outlet 2', 'Canada', 6);
What is the total number of media outlets in North America with a media literacy score below 6?
SELECT COUNT(*) FROM media_outlets_na WHERE country = 'North America' AND media_literacy_score < 6;
gretelai_synthetic_text_to_sql
CREATE TABLE waste_generation ( id INT PRIMARY KEY, region VARCHAR(50), year INT, metric DECIMAL(5,2)); INSERT INTO waste_generation (id, region, year, metric) VALUES (1, 'Mumbai', 2018, 5678.90), (2, 'Mumbai', 2019, 6001.12), (3, 'Tokyo', 2018, 3456.78), (4, 'Tokyo', 2019, 3501.09);
What is the average waste generation metric for all regions in 2019?
SELECT AVG(metric) FROM waste_generation WHERE year = 2019 GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE IntelligenceOperations (Operation VARCHAR(50), Type VARCHAR(50)); INSERT INTO IntelligenceOperations (Operation, Type) VALUES ('Operation Red Sparrow', 'Military'), ('Operation Moonlight', 'Cybersecurity'), ('Operation Glowing Symphony', 'Cybersecurity'), ('Operation Olympic Games', 'Cybersecurity');
What are the names of all intelligence operations that are not related to military operations?
SELECT Operation FROM IntelligenceOperations WHERE Type != 'Military';
gretelai_synthetic_text_to_sql
CREATE TABLE movies (title VARCHAR(255), rating INT, director VARCHAR(50)); INSERT INTO movies (title, rating, director) VALUES ('Movie1', 8, 'DirectorA'), ('Movie2', 7, 'DirectorB'), ('Movie3', 9, 'DirectorA'), ('Movie4', 6, 'DirectorB');
Which director has the highest average movie rating?
SELECT director, AVG(rating) as avg_rating FROM movies GROUP BY director ORDER BY avg_rating DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE reporters (id INT PRIMARY KEY, name TEXT, gender TEXT, age INT, country TEXT);
What is the average age of all female news reporters in the "reporters" table?
SELECT AVG(age) FROM reporters WHERE gender = 'female';
gretelai_synthetic_text_to_sql
CREATE TABLE news_reports (id INT, title VARCHAR(255), author VARCHAR(255), publication_date DATE, word_count INT, country VARCHAR(255));
Which countries have the highest and lowest average word count per article in the 'news_reports' table, excluding articles with a word count less than 500?
SELECT country, AVG(word_count) as avg_word_count FROM news_reports WHERE word_count >= 500 GROUP BY country ORDER BY avg_word_count DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE fairness_issues (id INT, model_id INT, severity INT, issue_description TEXT); INSERT INTO fairness_issues (id, model_id, severity, issue_description) VALUES (1, 1, 5, 'IssueA'), (2, 2, 8, 'IssueB');
Delete fairness issues with a severity level greater than 7 for models in the EU.
DELETE FROM fairness_issues WHERE severity > 7 AND model_id IN (SELECT id FROM models WHERE country = 'EU');
gretelai_synthetic_text_to_sql
CREATE TABLE VehicleCounts (id INT, type VARCHAR(50), state VARCHAR(50), count INT); INSERT INTO VehicleCounts (id, type, state, count) VALUES (1, 'Electric', 'Texas', 5000); INSERT INTO VehicleCounts (id, type, state, count) VALUES (2, 'Hybrid', 'Texas', 3000); INSERT INTO VehicleCounts (id, type, state, count) VALUES...
What is the total number of vehicles (electric, hybrid, and autonomous) in the state of Texas?
SELECT SUM(count) FROM VehicleCounts WHERE state = 'Texas';
gretelai_synthetic_text_to_sql
CREATE TABLE professors (id INT, name VARCHAR(50), department VARCHAR(50), research_interest VARCHAR(50), num_papers INT); INSERT INTO professors (id, name, department, research_interest, num_papers) VALUES (1, 'John Doe', 'Computer Science', 'Machine Learning', 6), (2, 'Jane Smith', 'Computer Science', 'Data Science',...
Show the names and research interests of all professors who have published at least as many papers as the professor with the most papers.
SELECT name, research_interest FROM professors WHERE num_papers >= (SELECT MAX(num_papers) FROM professors);
gretelai_synthetic_text_to_sql
CREATE TABLE sales (sale_id INT, product_id INT, sale_quantity INT, country VARCHAR(255)); CREATE TABLE product_categories (product_id INT, category VARCHAR(255));
What is the total quantity of moisturizers sold in Japan and South Korea?
SELECT SUM(sale_quantity) FROM sales JOIN product_categories ON sales.product_id = product_categories.product_id WHERE category = 'moisturizer' AND country IN ('Japan', 'South Korea');
gretelai_synthetic_text_to_sql
CREATE TABLE Astronauts (AstronautID INT, Age INT, Gender VARCHAR(10), HasFlownToMars BOOLEAN); CREATE TABLE MedicalConditions (ConditionID INT, Condition VARCHAR(50), AstronautID INT);
How many unique medical conditions are there among astronauts who have flown to Mars?
SELECT COUNT(DISTINCT Condition) FROM MedicalConditions INNER JOIN Astronauts ON MedicalConditions.AstronautID = Astronauts.AstronautID WHERE Astronauts.HasFlownToMars = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE TrainingSessions (SessionID INT, SessionName VARCHAR(50), SessionDate DATE, NumberOfAttendees INT);
What is the total number of diversity and inclusion training sessions conducted in the last quarter?
SELECT COUNT(*) as TotalSessions FROM TrainingSessions WHERE SessionName = 'Diversity and Inclusion' AND SessionDate >= DATE_SUB(CURDATE(), INTERVAL 3 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE mining_operations (id INT, name VARCHAR(50), department VARCHAR(50), age INT);
What is the total number of employees working in the "underground" department?
SELECT COUNT(*) FROM mining_operations WHERE department = 'underground';
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id int, product_category varchar(50), co2_emissions decimal(5,2));
What is the average CO2 emissions of products in each category?
SELECT product_category, AVG(co2_emissions) as avg_co2_emissions FROM products GROUP BY product_category;
gretelai_synthetic_text_to_sql
CREATE TABLE security_incidents (id INT, incident_type TEXT, date_reported DATE, severity TEXT); INSERT INTO security_incidents (id, incident_type, date_reported, severity) VALUES (1, 'Phishing', '2022-01-01', 'High'), (2, 'Malware', '2022-06-15', 'Medium');
What is the number of security incidents for each incident type in H1 2022?
SELECT incident_type, COUNT(*) as count FROM security_incidents WHERE date_reported >= '2022-01-01' AND date_reported < '2022-07-01' GROUP BY incident_type;
gretelai_synthetic_text_to_sql
CREATE TABLE cybersecurity_incidents (id INT, incident_date DATE, category VARCHAR(255), region VARCHAR(255)); INSERT INTO cybersecurity_incidents (id, incident_date, category, region) VALUES (1, '2017-01-01', 'Malware', 'Europe'), (2, '2018-05-15', 'Phishing', 'Europe');
Identify the number of cybersecurity incidents and their categories in Europe over the last 5 years.
SELECT COUNT(*), category FROM cybersecurity_incidents WHERE region = 'Europe' AND incident_date >= DATE_SUB(CURDATE(), INTERVAL 5 YEAR) GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE Astronauts (AstronautName VARCHAR(255), Birthdate DATE); INSERT INTO Astronauts (AstronautName, Birthdate) VALUES ('Neil Armstrong', '1930-08-05'), ('Buzz Aldrin', '1930-01-20');
Insert a new astronaut record for 'Chiaki Mukai' with a birthdate of '1952-05-06' into the Astronauts table.
INSERT INTO Astronauts (AstronautName, Birthdate) VALUES ('Chiaki Mukai', '1952-05-06');
gretelai_synthetic_text_to_sql
CREATE TABLE ny_buses (bus_id INT, speed FLOAT, location VARCHAR(20));CREATE TABLE ca_buses (bus_id INT, speed FLOAT, location VARCHAR(20));
What is the average speed of public buses in New York and California?
SELECT AVG(ny_buses.speed) AS ny_avg_speed, AVG(ca_buses.speed) AS ca_avg_speed FROM ny_buses INNER JOIN ca_buses ON 1=1;
gretelai_synthetic_text_to_sql
CREATE TABLE property (id INT, name VARCHAR(255), program VARCHAR(255)); INSERT INTO property (id, name, program) VALUES (1, 'EcoTower', 'Sustainable Urbanism'); CREATE TABLE sustainable_materials (id INT, property_id INT, material VARCHAR(255), percentage DECIMAL(5,2)); INSERT INTO sustainable_materials (id, property_...
What is the average sustainable material percentage for properties in the 'Sustainable Urbanism' program?
SELECT property_id, AVG(percentage) FROM sustainable_materials WHERE property_id IN (SELECT id FROM property WHERE program = 'Sustainable Urbanism') GROUP BY property_id;
gretelai_synthetic_text_to_sql
CREATE TABLE CollectiveBargaining (AgreementID INT, Sector VARCHAR(20), SignDate DATE); INSERT INTO CollectiveBargaining (AgreementID, Sector, SignDate) VALUES (1, 'Education', '2016-05-01'), (2, 'Healthcare', '2018-09-15'), (3, 'Education', '2017-03-25'), (4, 'Education', '2018-12-31');
How many collective bargaining agreements were signed in the 'Education' sector in 2018?
SELECT COUNT(*) FROM CollectiveBargaining WHERE Sector = 'Education' AND YEAR(SignDate) = 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE Tech_Accessibility_Asia (country VARCHAR(50), initiative_type VARCHAR(50), initiatives INT); INSERT INTO Tech_Accessibility_Asia (country, initiative_type, initiatives) VALUES ('China', 'hardware', 1000), ('China', 'software', 1500), ('China', 'training', 1200), ('India', 'hardware', 800), ('India', 'softw...
List the number of technology accessibility initiatives by type, for the top 2 countries with the highest number of technology accessibility initiatives in Asia?
SELECT Tech_Accessibility_Asia.initiative_type, SUM(Tech_Accessibility_Asia.initiatives) FROM Tech_Accessibility_Asia WHERE Tech_Accessibility_Asia.country IN (SELECT Tech_Accessibility_Asia.country FROM Tech_Accessibility_Asia WHERE Tech_Accessibility_Asia.country = 'Asia' GROUP BY Tech_Accessibility_Asia.country ORDE...
gretelai_synthetic_text_to_sql
CREATE TABLE Districts (DistrictID INT, Name VARCHAR(50)); CREATE TABLE Crimes (CrimeID INT, DistrictID INT, Date DATE);
How many reported crimes occurred in each district in the last month?
SELECT D.Name, COUNT(C.CrimeID) as NumCrimes FROM Districts D INNER JOIN Crimes C ON D.DistrictID = C.DistrictID WHERE C.Date >= DATEADD(MONTH, -1, GETDATE()) GROUP BY D.Name;
gretelai_synthetic_text_to_sql
CREATE TABLE menus (menu_id INT, item VARCHAR(255), category VARCHAR(255), price DECIMAL(10, 2), is_vegan BOOLEAN); INSERT INTO menus VALUES (1, 'Chicken Wings', 'Appetizers', 12.99, false); INSERT INTO menus VALUES (2, 'Beef Burger', 'Entrees', 15.99, false); INSERT INTO menus VALUES (3, 'Veggie Burger', 'Entrees', 10...
What is the average price of vegan menu items in a specific region?
SELECT AVG(price) FROM menus WHERE is_vegan = true AND region = 'North';
gretelai_synthetic_text_to_sql
CREATE TABLE hotel_reservations (reservation_id INT, hotel_id INT, guest_name TEXT, arrival_date DATE, departure_date DATE, num_guests INT, payment_amount FLOAT, is_cancelled BOOLEAN);
Create a view that displays the number of reservations for each hotel_id
CREATE VIEW reservations_per_hotel AS SELECT hotel_id, COUNT(*) FROM hotel_reservations GROUP BY hotel_id;
gretelai_synthetic_text_to_sql
CREATE TABLE DisabilityTypes (TypeID INT, TypeName VARCHAR(100)); INSERT INTO DisabilityTypes(TypeID, TypeName) VALUES (1, 'Autism'), (2, 'Blindness'), (3, 'Deafness'); CREATE TABLE AccommodationCosts (CostID INT, TypeID INT, CountryID INT, Cost DECIMAL(10, 2)); INSERT INTO AccommodationCosts(CostID, TypeID, CountryID,...
What is the average accommodation cost for each type of disability in the USA?
SELECT DT.TypeName, AVG(AC.Cost) as AvgCost FROM DisabilityTypes DT INNER JOIN AccommodationCosts AC ON DT.TypeID = AC.TypeID WHERE AC.CountryID = 1 GROUP BY DT.TypeName;
gretelai_synthetic_text_to_sql
CREATE TABLE genetic_data (id INT, type VARCHAR(50), value FLOAT); INSERT INTO genetic_data (id, type, value) VALUES (1, 'DNA Sequencing', 1200); INSERT INTO genetic_data (id, type, value) VALUES (2, 'RNA Sequencing', 1500); INSERT INTO genetic_data (id, type, value) VALUES (3, 'Protein Analysis', 800);
List the genetic research data by type and the average value.
SELECT type, AVG(value) FROM genetic_data GROUP BY type;
gretelai_synthetic_text_to_sql
CREATE TABLE Sustainability (product_id INT, sustainable BOOLEAN, PRIMARY KEY (product_id)); INSERT INTO Sustainability (product_id) VALUES (101), (102);
What was the average price of sustainable garments in the US?
SELECT AVG(price) as avg_price FROM Products JOIN Sustainability ON Products.product_id = Sustainability.product_id WHERE Products.category = 'Sustainable' AND Sustainability.sustainable = TRUE AND Products.country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteer_Hours (VolunteerID INT, Region VARCHAR(50), Hours DECIMAL(10, 2));
List the number of volunteers and total hours spent per region, from the 'Volunteer_Hours' table, grouped by Region.
SELECT Region, COUNT(*) AS Number_Of_Volunteers, SUM(Hours) AS Total_Hours_Spent FROM Volunteer_Hours GROUP BY Region;
gretelai_synthetic_text_to_sql
CREATE TABLE WasteGeneration (area_type VARCHAR(255), year INT, waste_generation FLOAT); INSERT INTO WasteGeneration (area_type, year, waste_generation) VALUES ('Urban', 2021, 6000), ('Rural', 2021, 2000);
What is the total waste generation in grams for urban and rural areas in 2021?
SELECT area_type, SUM(waste_generation) FROM WasteGeneration WHERE year = 2021 GROUP BY area_type;
gretelai_synthetic_text_to_sql
CREATE TABLE crops (id INT, name VARCHAR(50), location VARCHAR(50), year INT, production INT); INSERT INTO crops (id, name, location, year, production) VALUES (1, 'Corn', 'US', 2020, 5000), (2, 'Wheat', 'US', 2020, 7000), (3, 'Soybean', 'Canada', 2020, 3000), (4, 'Barley', 'Canada', 2020, 4000), (5, 'Corn', 'US', 2019,...
What is the production of crops in a given year?
SELECT year, SUM(production) as total_production FROM crops GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE mining_companies_3 (company_name TEXT, location TEXT); INSERT INTO mining_companies_3 (company_name, location) VALUES ('LMN Mining', 'China'), ('XYZ Mining', 'India'), ('PQR Mining', 'Japan'); CREATE TABLE neodymium_production (year INT, company_name TEXT, quantity INT); INSERT INTO neodymium_production (y...
What is the average production quantity (in metric tons) of Neodymium in 2021, grouped by mining company locations in Asia?
SELECT location, AVG(quantity) as avg_quantity FROM neodymium_production JOIN mining_companies_3 ON neodymium_production.company_name = mining_companies_3.company_name WHERE year = 2021 AND location LIKE 'Asia%' GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE socially_responsible_investments (id INT, investment_type VARCHAR(255), value DECIMAL(10,2), country VARCHAR(255));
What is the minimum transaction value for socially responsible investments in France?
SELECT MIN(value) FROM socially_responsible_investments WHERE country = 'France';
gretelai_synthetic_text_to_sql
CREATE TABLE CounselingSessions (StudentID INT, State VARCHAR(10), Sessions INT); INSERT INTO CounselingSessions (StudentID, State, Sessions) VALUES (1, 'MI', 7), (2, 'MI', 3);
Find the number of students who have attended more than 5 mental health counseling sessions in 'Michigan'
SELECT COUNT(*) FROM CounselingSessions WHERE State = 'Michigan' AND Sessions > 5;
gretelai_synthetic_text_to_sql
CREATE TABLE Digital_Divide_Initiatives (Half INT, Initiatives INT); INSERT INTO Digital_Divide_Initiatives (Half, Initiatives) VALUES (1, 25), (2, 50), (3, 75), (4, 100);
Identify the total number of digital divide initiatives launched in the first half of the year 2021 and the second half of the year 2022.
SELECT SUM(Initiatives) FROM Digital_Divide_Initiatives WHERE Half IN (2, 4);
gretelai_synthetic_text_to_sql
CREATE TABLE Exhibitions (exhibition_name TEXT, exhibition_duration INT, category TEXT);
Find the average duration of exhibitions in 'museums' category.
SELECT AVG(exhibition_duration) FROM Exhibitions WHERE category = 'museums';
gretelai_synthetic_text_to_sql
CREATE TABLE memberships (id INT, member_type VARCHAR(50), region VARCHAR(50)); CREATE TABLE workout_data (member_id INT, workout_type VARCHAR(50), duration INT, heart_rate_avg INT, calories_burned INT, workout_date DATE);
Which members in the East region have not completed any workouts in the last 90 days?
SELECT m.id FROM memberships m LEFT JOIN workout_data w ON m.id = w.member_id WHERE w.workout_date IS NULL OR w.workout_date < CURRENT_DATE - INTERVAL '90' DAY AND m.region = 'East' GROUP BY m.id HAVING COUNT(w.id) = 0;
gretelai_synthetic_text_to_sql
CREATE TABLE MedicalProfiles(astronaut_id INT, height INT, weight INT);
Find the minimum height of an astronaut.
SELECT MIN(height) FROM MedicalProfiles;
gretelai_synthetic_text_to_sql
CREATE TABLE Products (Product VARCHAR(50), Type VARCHAR(50), Revenue DECIMAL(10,2)); INSERT INTO Products (Product, Type, Revenue) VALUES ('Cleanser', 'Organic', 15000), ('Moisturizer', 'Organic', 20000), ('Toner', 'Organic', 10000);
What is the total revenue for organic skincare products?
SELECT SUM(Revenue) FROM Products WHERE Type = 'Organic';
gretelai_synthetic_text_to_sql
CREATE TABLE project_budget (project_id INT, budget DECIMAL); INSERT INTO project_budget (project_id, budget) VALUES (1, 5000000.00);
What is the average budget for climate adaptation projects in South America?
SELECT AVG(budget) FROM project_budget JOIN climate_project ON project_budget.project_id = climate_project.project_id WHERE climate_project.project_type = 'Adaptation' AND climate_project.project_region = 'South America';
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (volunteer_id INT, location VARCHAR(25)); INSERT INTO volunteers (volunteer_id, location) VALUES (1, 'New York'), (2, 'Los Angeles'), (3, 'New York');
What is the total number of volunteers in the volunteers table, grouped by their location?
SELECT COUNT(*), location FROM volunteers GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE field_temperature (field_id INT, date DATE, temperature FLOAT); INSERT INTO field_temperature (field_id, date, temperature) VALUES (9, '2021-07-01', 25.5), (9, '2021-07-02', 24.3), (9, '2021-07-03', 26.1);
What is the minimum temperature in field 9 over the last 14 days?
SELECT MIN(temperature) FROM field_temperature WHERE field_id = 9 AND date >= DATE_SUB(CURRENT_DATE, INTERVAL 14 DAY);
gretelai_synthetic_text_to_sql
CREATE TABLE games (game_id INT, game_name VARCHAR(50), playtime INT); INSERT INTO games (game_id, game_name, playtime) VALUES (1, 'GameA', 1000), (2, 'GameB', 2000), (3, 'GameC', 3000);
What is the total playtime for each game in the 'games' table?
SELECT game_name, SUM(playtime) FROM games GROUP BY game_name;
gretelai_synthetic_text_to_sql
CREATE TABLE bears (id INT, species VARCHAR(255), body_weight FLOAT); INSERT INTO bears (id, species, body_weight) VALUES (1, 'Giant Panda', 150.0), (2, 'Polar Bear', 500.0);
What is the maximum body weight of all bears in the conservation program?
SELECT MAX(body_weight) FROM bears WHERE species IN ('Giant Panda', 'Polar Bear', 'American Black Bear', 'Asiatic Black Bear') GROUP BY species;
gretelai_synthetic_text_to_sql
CREATE TABLE Workouts (WorkoutID INT, MemberID INT, WorkoutType VARCHAR(20), Duration INT, Date DATE); INSERT INTO Workouts (WorkoutID, MemberID, WorkoutType, Duration, Date) VALUES (5, 1005, 'Swimming', 60, '2023-02-15'); INSERT INTO Workouts (WorkoutID, MemberID, WorkoutType, Duration, Date) VALUES (6, 1006, 'Weightl...
SELECT MemberID, COUNT(*) as WorkoutCountThisMonth FROM Workouts WHERE DATE_TRUNC('month', Date) = DATE_TRUNC('month', CURRENT_DATE) GROUP BY MemberID ORDER BY WorkoutCountThisMonth DESC;
SELECT MemberID, SUM(Duration) as TotalWorkoutDurationLastWeek FROM Workouts WHERE Date >= DATE_TRUNC('week', CURRENT_DATE - INTERVAL '7 days') AND Date < DATE_TRUNC('week', CURRENT_DATE) GROUP BY MemberID ORDER BY TotalWorkoutDurationLastWeek DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE space_missions (mission_name VARCHAR(100) PRIMARY KEY, start_date DATE, end_date DATE, mission_type VARCHAR(50));
Add a row to the space_missions table
INSERT INTO space_missions (mission_name, start_date, end_date, mission_type) VALUES ('Artemis I', '2022-08-29', '2022-12-11', 'Human Exploration');
gretelai_synthetic_text_to_sql
CREATE TABLE Space_Probes (probe_name TEXT, max_altitude FLOAT); INSERT INTO Space_Probes (probe_name, max_altitude) VALUES ('Voyager 1', 21384000000), ('New Horizons', 12670000000), ('Pioneer 10', 12670000000), ('Voyager 2', 11620000000), ('Pioneer 11', 10500000000);
What is the maximum altitude reached by space probes?
SELECT max_altitude as max_altitude_reached FROM Space_Probes ORDER BY max_altitude DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE children_vaccinations (id INT, child_id INT, vaccine_type VARCHAR(20), vaccination_date DATE, country VARCHAR(30)); CREATE VIEW children_under_5 AS SELECT * FROM children_vaccinations WHERE YEAR(vaccination_date) >= 2014 AND child_id IN (SELECT child_id FROM children_vaccinations GROUP BY child_id HAVING C...
What is the percentage of children under 5 who received all recommended vaccinations in 2018 in Canada?
SELECT COUNT(*) * 100.0 / (SELECT COUNT(*) FROM children_under_5 WHERE country = 'Canada') FROM children_under_5 WHERE country = 'Canada' AND YEAR(vaccination_date) = 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE community_development (id INT, initiative_name TEXT, location TEXT, start_date DATE); INSERT INTO community_development (id, initiative_name, location, start_date) VALUES (1, 'Youth Center', 'North', '2021-05-01'), (2, 'Community Garden', 'South', '2020-01-15'), (3, 'Senior Center', 'West', '2022-06-15'), ...
What is the earliest start date for community development initiatives in the 'community_development' table, by location?
SELECT location, MIN(start_date) FROM community_development GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_rates (state VARCHAR(255), year INT, rate DECIMAL(5,2)); INSERT INTO recycling_rates (state, year, rate) VALUES ('New York', 2019, 0.35);
What is the recycling rate in the state of New York in 2019?
SELECT rate FROM recycling_rates WHERE state = 'New York' AND year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE CargoHandling (PortID INT, PortName VARCHAR(100), TotalCargoHandled INT, LastYearCargo INT, PortRegion VARCHAR(50)); INSERT INTO CargoHandling (PortID, PortName, TotalCargoHandled, LastYearCargo, PortRegion) VALUES (1, 'Port A', 1000000, 120000, 'Americas'), (2, 'Port B', 1500000, 135000, 'Europe'), (3, 'P...
Show the top 3 ports in terms of cargo handling in the last year
SELECT PortName, TotalCargoHandled FROM CargoHandling WHERE PortRegion IN ('Americas', 'Europe', 'Asia') ORDER BY TotalCargoHandled DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Warehouse (id INT, name VARCHAR(50), location VARCHAR(50)); INSERT INTO Warehouse (id, name, location) VALUES (1, 'Dallas', 'USA'); CREATE TABLE Shipment (id INT, warehouse_id INT, region VARCHAR(50), shipment_date DATE, volume INT); INSERT INTO Shipment (id, warehouse_id, region, shipment_date, volume) VA...
What is the maximum number of packages shipped in a single day from our Dallas warehouse to the Middle East?
SELECT MAX(volume) FROM Shipment WHERE warehouse_id = (SELECT id FROM Warehouse WHERE location = 'Dallas') AND region = 'Middle East' GROUP BY shipment_date;
gretelai_synthetic_text_to_sql
CREATE TABLE peacekeeping_ops (id INT, country VARCHAR(50), region VARCHAR(50)); INSERT INTO peacekeeping_ops (id, country, region) VALUES (1, 'Nigeria', 'Africa'), (2, 'Egypt', 'Africa'), (3, 'Iraq', 'Middle East'), (4, 'Nigeria', 'Africa');
Remove any duplicate records from the "peacekeeping_ops" table
DELETE FROM peacekeeping_ops WHERE id IN (SELECT MAX(id) FROM peacekeeping_ops GROUP BY country, region HAVING COUNT(*) > 1);
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID int, Country varchar(50)); INSERT INTO Donors (DonorID, Country) VALUES (1, 'USA'), (2, 'Canada'), (3, 'Mexico'), (4, 'USA'), (5, 'Canada'); CREATE TABLE Donations (DonationID int, DonorID int, Cause varchar(50), Amount decimal(10,2)); INSERT INTO Donations (DonationID, DonorID, Cause, Amou...
How many donors have given to each cause?
SELECT Cause, COUNT(DISTINCT DonorID) as DonorCount FROM Donations GROUP BY Cause;
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers (id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255), sustainable_practices BOOLEAN);
Create a new table for storing information about restaurant suppliers
CREATE TABLE suppliers (id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255), sustainable_practices BOOLEAN);
gretelai_synthetic_text_to_sql
CREATE TABLE teacher_workshops (id INT, teacher_id INT, workshop VARCHAR(50), hours INT); INSERT INTO teacher_workshops (id, teacher_id, workshop, hours) VALUES (1, 1, 'Python', 10); INSERT INTO teacher_workshops (id, teacher_id, workshop, hours) VALUES (2, 2, 'Data Science', 5);
Delete records of workshops with less than 5 hours
DELETE FROM teacher_workshops WHERE hours < 5;
gretelai_synthetic_text_to_sql
CREATE TABLE bookings (booking_id INT, hotel_id INT, booking_date DATE, booking_channel TEXT); INSERT INTO bookings (booking_id, hotel_id, booking_date, booking_channel) VALUES (1, 1, '2022-04-01', 'OTA'), (2, 2, '2022-05-15', 'Direct'), (3, 1, '2022-06-30', 'OTA'), (4, 3, '2022-07-01', 'OTA'), (5, 3, '2022-07-01', 'OT...
What is the maximum number of bookings made through OTA channels in a single day for hotels in the Asia region?
SELECT region, MAX(count) FROM (SELECT region, booking_date, COUNT(*) as count FROM bookings b JOIN hotels h ON b.hotel_id = h.hotel_id WHERE booking_channel = 'OTA' GROUP BY region, booking_date) subquery GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists investments (investment_id INT, region VARCHAR(50), sector VARCHAR(50), amount DECIMAL(10,2), investment_year INT); INSERT INTO investments (investment_id, region, sector, amount, investment_year) VALUES (4, 'South America', 'Social Enterprises', 900000, 2017), (5, 'South America', 'Social En...
What is the total investment in social enterprises in South America in 2017?
SELECT SUM(amount) FROM investments WHERE region = 'South America' AND sector = 'Social Enterprises' AND investment_year = 2017;
gretelai_synthetic_text_to_sql
CREATE TABLE team_info (team VARCHAR(255), conference VARCHAR(255)); INSERT INTO team_info (team, conference) VALUES ('TeamA', 'Western Conference'), ('TeamB', 'Eastern Conference');
List all athletes who have played more than 50 games in the 'Western Conference'
SELECT a.name, a.games_played FROM athlete_stats a INNER JOIN team_info t ON a.team = t.team WHERE t.conference = 'Western Conference' AND a.games_played > 50;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (id INT, name VARCHAR(255), country VARCHAR(255), balance DECIMAL(10, 2));
Insert a new customer 'Alice Johnson' from the United Kingdom with a balance of 8000.00.
INSERT INTO customers (name, country, balance) VALUES ('Alice Johnson', 'United Kingdom', 8000.00);
gretelai_synthetic_text_to_sql
CREATE TABLE properties (id INT, price FLOAT, city VARCHAR(20), walkability_score INT); INSERT INTO properties (id, price, city, walkability_score) VALUES (1, 950000, 'Chicago', 70), (2, 800000, 'Chicago', 65), (3, 700000, 'Chicago', 67), (4, 1000000, 'Chicago', 80), (5, 600000, 'Chicago', 62);
What is the median property price for properties in the city of Chicago with a walkability score above 60?
SELECT AVG(price) FROM (SELECT price FROM properties WHERE city = 'Chicago' AND walkability_score > 60 ORDER BY price LIMIT 2 OFFSET 1) AS subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE scheme_prices (scheme_id INT, property_type VARCHAR(50), property_price FLOAT); INSERT INTO scheme_prices (scheme_id, property_type, property_price) VALUES (1, 'Apartment', 500000.00), (1, 'House', 700000.00), (2, 'Townhouse', 600000.00), (3, 'Condominium', 800000.00);
What is the maximum property price in each type of inclusive housing scheme?
SELECT property_type, MAX(property_price) FROM scheme_prices GROUP BY property_type;
gretelai_synthetic_text_to_sql
CREATE TABLE transportation_systems (id INT, city VARCHAR(20), system_type VARCHAR(20)); INSERT INTO transportation_systems (id, city, system_type) VALUES (1, 'Berlin', 'Multimodal'), (2, 'Munich', 'Tram'), (3, 'Frankfurt', 'Multimodal');
List all cities with multimodal transportation systems in Germany.
SELECT DISTINCT city FROM transportation_systems WHERE system_type = 'Multimodal';
gretelai_synthetic_text_to_sql
CREATE TABLE TheaterProgram (id INT, year INT, funding FLOAT); INSERT INTO TheaterProgram (id, year, funding) VALUES (1, 2016, 15000), (2, 2017, 18000), (3, 2018, 22000), (4, 2019, 25000);
What was the total funding received by the theater program in the year 2018?
SELECT SUM(funding) FROM TheaterProgram WHERE year = 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE GameEvents (PlayerID INT, EventTimestamp DATETIME, EventType VARCHAR(255)); INSERT INTO GameEvents (PlayerID, EventTimestamp, EventType) VALUES (1, '2022-01-01 12:00:00', 'GameStart'), (2, '2022-01-01 13:00:00', 'GameEnd'), (3, '2022-01-01 14:00:00', 'GameStart');
Find the total number of players who played more than 50% of the game time in the last 4 months.
SELECT COUNT(DISTINCT PlayerID) as TotalPlayers FROM GameEvents WHERE EventType = 'GameStart' AND EventTimestamp BETWEEN DATEADD(month, -4, CURRENT_DATE) AND CURRENT_DATE AND (SELECT COUNT(*) FROM GameEvents as GE2 WHERE GE2.PlayerID = GameEvents.PlayerID AND GE2.EventType IN ('GameStart', 'GameEnd') AND GE2.EventTimes...
gretelai_synthetic_text_to_sql
CREATE TABLE agroecology (id INT, practice TEXT, region TEXT); INSERT INTO agroecology (id, practice, region) VALUES (1, 'Practice 1', 'Central America'), (2, 'Practice 2', 'South America');
Find all agroecological practices in 'Central America' and 'South America'.
SELECT practice FROM agroecology WHERE region IN ('Central America', 'South America');
gretelai_synthetic_text_to_sql
CREATE TABLE Feedback (Service VARCHAR(25), Score INT); INSERT INTO Feedback (Service, Score) VALUES ('Library', 8), ('Park', 7), ('Recreation Center', 9);
What is the maximum citizen feedback score for recreation centers?
SELECT MAX(Score) FROM Feedback WHERE Service = 'Recreation Center';
gretelai_synthetic_text_to_sql
CREATE TABLE mental_health.treatments (treatment_id INT, patient_id INT, therapist_id INT, treatment_type VARCHAR(50), country VARCHAR(50)); INSERT INTO mental_health.patients (patient_id, first_name, last_name, age, gender, country) VALUES (14, 'Marie', 'Dupont', 40, 'Female', 'France');
Insert a new treatment record for a patient in France who received family therapy
INSERT INTO mental_health.treatments (treatment_id, patient_id, therapist_id, treatment_type, country) VALUES (16, (SELECT patient_id FROM mental_health.patients WHERE first_name = 'Marie' AND last_name = 'Dupont' AND country = 'France'), 202, 'Family Therapy', 'France');
gretelai_synthetic_text_to_sql
CREATE TABLE diversity_metrics (id INT, company_id INT, female_founders INT, minority_founders INT, underrepresented_founders INT); INSERT INTO diversity_metrics (id, company_id, female_founders, minority_founders, underrepresented_founders) VALUES (1, 1, 1, 0, 0), (2, 2, 0, 1, 0), (3, 3, 0, 0, 1);
What is the minimum funding round amount for a company in the e-commerce sector with at least one female founder?
SELECT MIN(funding_rounds.amount) FROM funding_rounds JOIN companies ON funding_rounds.company_id = companies.id JOIN diversity_metrics ON companies.id = diversity_metrics.company_id WHERE companies.industry = 'E-commerce' AND diversity_metrics.female_founders > 0;
gretelai_synthetic_text_to_sql
CREATE TABLE community_diversification (country TEXT, initiative_type TEXT, year INT, participants INT); INSERT INTO community_diversification (country, initiative_type, year, participants) VALUES ('Peru', 'Community Development', 2017, 300), ('Peru', 'Economic Diversification', 2017, 500), ('Peru', 'Community Developm...
What was the total number of community development initiatives and economic diversification efforts in Peru, in descending order of total participants?
SELECT initiative_type, SUM(participants) OVER (PARTITION BY initiative_type ORDER BY SUM(participants) DESC) AS total_participants FROM community_diversification WHERE country = 'Peru' GROUP BY initiative_type, year ORDER BY total_participants DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE CommunityHealthWorker (WorkerID INT, FirstName VARCHAR(50), LastName VARCHAR(50), Zipcode VARCHAR(10), Specialty VARCHAR(50)); INSERT INTO CommunityHealthWorker (WorkerID, FirstName, LastName, Zipcode, Specialty) VALUES (1, 'John', 'Doe', '12345', 'Mental Health');
What are the unique Zipcodes and corresponding Community Health Worker counts for CommunityHealthWorker table?
SELECT DISTINCT Zipcode, COUNT(*) as CHW_Count FROM CommunityHealthWorker GROUP BY Zipcode;
gretelai_synthetic_text_to_sql
CREATE TABLE military_operations (operation_id INT, name TEXT, country1 TEXT, country2 TEXT); INSERT INTO military_operations (operation_id, name, country1, country2) VALUES (1, 'Operation Artemis', 'United States', 'Colombia');
What are the names of all military operations involving the United States and Colombia?
SELECT name FROM military_operations WHERE country1 = 'United States' AND country2 = 'Colombia'
gretelai_synthetic_text_to_sql
CREATE TABLE Strategy_Games (player_id INT, name VARCHAR(50), age INT, gender VARCHAR(10)); INSERT INTO Strategy_Games (player_id, name, age, gender) VALUES (1, 'Emily Wilson', 35, 'Female'), (2, 'William Thompson', 40, 'Male'), (3, 'Grace Lee', 33, 'Female'); CREATE TABLE Fighting_Games (player_id INT, name VARCHAR(50...
List players who have played games exclusively in the 'Strategy' genre and have not played any games in the 'Fighting' genre, with age over 30.
SELECT age, gender FROM Strategy_Games WHERE player_id NOT IN (SELECT player_id FROM Fighting_Games) AND age > 30;
gretelai_synthetic_text_to_sql
CREATE SCHEMA RuralHealth; USE RuralHealth; CREATE TABLE States (StateName VARCHAR(50), StateAbbreviation VARCHAR(10)); CREATE TABLE Hospitals (HospitalID INT, HospitalName VARCHAR(50), StateAbbreviation VARCHAR(10)); INSERT INTO States (StateName, StateAbbreviation) VALUES ('Alabama', 'AL'), ('Alaska', 'AK'); INSERT I...
What is the number of hospitals in each state, ordered by the number of hospitals in descending order?
SELECT StateAbbreviation, COUNT(*) as NumberOfHospitals FROM Hospitals GROUP BY StateAbbreviation ORDER BY NumberOfHospitals DESC;
gretelai_synthetic_text_to_sql
CREATE SCHEMA CarbonOffsets; USE CarbonOffsets; CREATE TABLE CarbonOffsetInitiatives (id INT, initiative_name VARCHAR(100), cost DECIMAL(10,2)); INSERT INTO CarbonOffsetInitiatives (id, initiative_name, cost) VALUES (1, 'Tree Planting', 10000.00), (2, 'Carbon Capture Technology', 50000.00);
Show the carbon offset initiatives and their costs in the CarbonOffsets schema
SELECT initiative_name, cost FROM CarbonOffsets.CarbonOffsetInitiatives;
gretelai_synthetic_text_to_sql
CREATE TABLE smart_city_projects (id INT, project_name VARCHAR(50), city VARCHAR(50), country VARCHAR(50), project_type VARCHAR(50)); INSERT INTO smart_city_projects (id, project_name, city, country, project_type) VALUES (1, 'London Smart Grid', 'London', 'United Kingdom', 'Transportation');
How many smart city projects are there in London, United Kingdom?
SELECT COUNT(*) FROM smart_city_projects WHERE city = 'London' AND country = 'United Kingdom';
gretelai_synthetic_text_to_sql
CREATE TABLE healthcare_providers (provider_id INT, name VARCHAR(255), specialty VARCHAR(255), district VARCHAR(255)); INSERT INTO healthcare_providers (provider_id, name, specialty, district) VALUES (1, 'Dr. Smith', 'Cardiology', 'Rural'), (2, 'Dr. Johnson', 'Pediatrics', 'Rural'), (3, 'Dr. Brown', 'Cardiology', 'Rura...
What is the number of healthcare providers in rural communities by specialty?
SELECT specialty, COUNT(*) FROM healthcare_providers WHERE district = 'Rural' GROUP BY specialty;
gretelai_synthetic_text_to_sql
CREATE TABLE Regions (RegionID INT, Region VARCHAR(20)); INSERT INTO Regions (RegionID, Region) VALUES (1, 'Northeast'), (2, 'Southeast'), (3, 'Midwest'), (4, 'Southwest'), (5, 'West'); CREATE TABLE Cases (CaseID INT, RegionID INT, BillingAmount DECIMAL(10,2)); INSERT INTO Cases (CaseID, RegionID, BillingAmount) VALUES...
What is the minimum billing amount for cases in each region?
SELECT Region, MIN(BillingAmount) FROM Cases INNER JOIN Regions ON Cases.RegionID = Regions.RegionID GROUP BY Region;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (id INT, name VARCHAR(100), region VARCHAR(50), assets_value FLOAT); INSERT INTO customers (id, name, region, assets_value) VALUES (1, 'Pedro Alvarez', 'Latin America', 400000.00);
What is the average assets value for all customers from 'Latin America' region?
SELECT AVG(assets_value) FROM customers WHERE region = 'Latin America';
gretelai_synthetic_text_to_sql
CREATE TABLE events (event_type VARCHAR(50), fan_count INT); INSERT INTO events (event_type, fan_count) VALUES ('Football', 2000), ('Basketball', 1500), ('Hockey', 1200);
How many fans attended each sport event by type?
SELECT event_type, SUM(fan_count) FROM events GROUP BY event_type;
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (hotel_id INT, hotel_name TEXT, country TEXT);CREATE TABLE virtual_tours (tour_id INT, hotel_id INT, engagement_time FLOAT); INSERT INTO hotels (hotel_id, hotel_name, country) VALUES (1, 'Hotel X', 'USA'), (2, 'Hotel Y', 'USA'); INSERT INTO virtual_tours (tour_id, hotel_id, engagement_time) VALUES (...
Which hotels have had the most virtual tour engagement in the US, and what is the average engagement time?
SELECT h.hotel_name, SUM(vt.engagement_time) as total_engagement, AVG(vt.engagement_time) as avg_engagement FROM hotels h INNER JOIN virtual_tours vt ON h.hotel_id = vt.hotel_id WHERE h.country = 'USA' GROUP BY h.hotel_name;
gretelai_synthetic_text_to_sql
CREATE TABLE properties (id INT, city VARCHAR(20), price INT, green_certified BOOLEAN); INSERT INTO properties (id, city, price, green_certified) VALUES (1, 'Vancouver', 500000, true);
What is the average property price for green-certified buildings in Vancouver?
SELECT AVG(price) FROM properties WHERE city = 'Vancouver' AND green_certified = true;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists arts_culture;CREATE TABLE if not exists arts_culture.audiences (audience_id INT PRIMARY KEY, name VARCHAR(255));CREATE TABLE if not exists arts_culture.events (event_id INT PRIMARY KEY, name VARCHAR(255), audience_id INT, FOREIGN KEY (audience_id) REFERENCES arts_culture.audiences(audience_i...
How many events have been attended by each audience member?
SELECT a.name as audience_name, COUNT(e.event_id) as attended_events FROM arts_culture.audiences a JOIN arts_culture.events e ON a.audience_id = e.audience_id GROUP BY a.name;
gretelai_synthetic_text_to_sql
CREATE TABLE Restaurants (id INT, name VARCHAR(50), city VARCHAR(20)); CREATE TABLE Menu (id INT, restaurant_id INT, dish VARCHAR(50), category VARCHAR(20), price DECIMAL(5,2)); INSERT INTO Restaurants (id, name, city) VALUES (1, 'VeggieHeaven', 'London'); INSERT INTO Menu (id, restaurant_id, dish, category, price) VAL...
What is the minimum price of vegetarian dishes in London?
SELECT MIN(price) FROM Menu JOIN Restaurants ON Menu.restaurant_id = Restaurants.id WHERE Restaurants.city = 'London' AND category = 'Vegetarian';
gretelai_synthetic_text_to_sql
CREATE TABLE Safety_Incidents (Incident_Type VARCHAR(255), Incident_Date DATE); INSERT INTO Safety_Incidents (Incident_Type, Incident_Date) VALUES ('Incident1', '2022-01-01'), ('Incident2', '2022-01-02'), ('Incident1', '2022-02-01'), ('Incident3', '2022-02-02');
Determine the number of safety incidents reported for each type of incident, in the past year, and rank them in ascending order.
SELECT Incident_Type, COUNT(*) AS Incident_Count, RANK() OVER (ORDER BY COUNT(*) ASC) AS Rank FROM Safety_Incidents WHERE Incident_Date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY Incident_Type;
gretelai_synthetic_text_to_sql
CREATE TABLE ArtSales (id INT, painting_name VARCHAR(50), price FLOAT, sale_date DATE, painting_style VARCHAR(20), sale_location VARCHAR(30)); INSERT INTO ArtSales (id, painting_name, price, sale_date, painting_style, sale_location) VALUES (1, 'Painting1', 8000, '2017-05-01', 'Pop Art', 'New York');
What is the total revenue of Pop Art paintings sold in New York since 2017?
SELECT SUM(price) FROM ArtSales WHERE painting_style = 'Pop Art' AND sale_location = 'New York' AND sale_date >= '2017-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE offshore_rigs (id INT, location VARCHAR(50), status VARCHAR(50)); INSERT INTO offshore_rigs (id, location, status) VALUES (1, 'North Sea', 'Operational');
What is the total number of offshore rigs in the North Sea?
SELECT COUNT(*) FROM offshore_rigs WHERE location = 'North Sea' AND status = 'Operational';
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, Age INT, Level INT, PerformanceScore INT);
What is the correlation between player level and game performance in RPG games?
SELECT CORR(p.Level, p.PerformanceScore) as Correlation FROM Players p WHERE p.GameType = 'RPG';
gretelai_synthetic_text_to_sql
CREATE TABLE customers (id INT, name TEXT, age INT, country TEXT, assets FLOAT); INSERT INTO customers (id, name, age, country, assets) VALUES (1, 'John Doe', 45, 'USA', 250000.00); INSERT INTO customers (id, name, age, country, assets) VALUES (2, 'Jane Smith', 34, 'Canada', 320000.00);
What is the total assets value for customers from the USA?
SELECT SUM(assets) FROM customers WHERE country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, donor VARCHAR(50), country VARCHAR(50), amount INT); INSERT INTO donations (id, donor, country, amount) VALUES (1, 'USAID', 'Haiti', 100000); INSERT INTO donations (id, donor, country, amount) VALUES (2, 'World Food Programme', 'Syria', 200000); INSERT INTO donations (id, donor, country,...
Identify the top 3 donors who have donated to the most number of countries?
SELECT donor, COUNT(DISTINCT country) as country_count FROM donations GROUP BY donor ORDER BY country_count DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE genres (genre_id INT, genre VARCHAR(50)); CREATE TABLE sales (sale_id INT, genre_id INT, sale_date DATE, revenue DECIMAL(5,2));
What is the total revenue by genre for the first quarter of the year?
SELECT g.genre, SUM(s.revenue) AS total_revenue FROM genres g JOIN sales s ON g.genre_id = s.genre_id WHERE s.sale_date >= DATEADD(quarter, DATEDIFF(quarter, 0, GETDATE()), 0) GROUP BY g.genre;
gretelai_synthetic_text_to_sql