context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE production_volume (chemical_category VARCHAR(255), chemical_subcategory VARCHAR(255), production_volume INT); INSERT INTO production_volume (chemical_category, chemical_subcategory, production_volume) VALUES ('Polymers', 'Plastics', 800), ('Polymers', 'Resins', 400), ('Dyes', 'Natural Dyes', 400);
What is the total production volume for each chemical category and subcategory?
SELECT chemical_category, chemical_subcategory, SUM(production_volume) OVER (PARTITION BY chemical_category, chemical_subcategory) AS total_volume FROM production_volume;
gretelai_synthetic_text_to_sql
CREATE TABLE players (player_id INT, name VARCHAR(100), position VARCHAR(50), team_id INT); INSERT INTO players (player_id, name, position, team_id) VALUES (1, 'John Doe', 'Forward', 1), (2, 'Jane Smith', 'Goalie', 2); CREATE TABLE teams (team_id INT, name VARCHAR(100), city VARCHAR(100)); INSERT INTO teams (team_id, name, city) VALUES (1, 'Boston Bruins', 'Boston'), (2, 'New York Rangers', 'New York');
Update the city of team 1 to 'Philadelphia'
UPDATE teams SET city = 'Philadelphia' WHERE team_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE sales_data (id INT PRIMARY KEY, manufacturer VARCHAR(50), model VARCHAR(50), year INT, is_autonomous BOOLEAN, quantity INT);
How many autonomous vehicles were sold in the 'sales_data' table by manufacturer?
SELECT manufacturer, COUNT(*) as total_sales FROM sales_data WHERE is_autonomous = TRUE GROUP BY manufacturer;
gretelai_synthetic_text_to_sql
CREATE TABLE restaurants (restaurant_id INT, restaurant_name VARCHAR(50), city VARCHAR(50), state VARCHAR(50), revenue FLOAT); INSERT INTO restaurants (restaurant_id, restaurant_name, city, state, revenue) VALUES (1, 'Restaurant A', 'City A', 'State A', 123456.78);
What is the average revenue of restaurants in each state?
SELECT state, AVG(revenue) FROM restaurants GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE VesselMovements (vessel_id INT, movement_year INT, speed INT);
Find the vessel with the lowest average speed for a specific year
SELECT vessel_id, AVG(speed) AS avg_speed FROM VesselMovements WHERE movement_year = 2022 GROUP BY vessel_id ORDER BY avg_speed ASC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE cultural_heritage_sites (site_id INT, site_name TEXT, country TEXT, annual_visitors INT); INSERT INTO cultural_heritage_sites (site_id, site_name, country, annual_visitors) VALUES (1, 'Tsukiji Fish Market', 'Japan', 120000), (2, 'Nijo Castle', 'Japan', 80000);
How many cultural heritage sites are in Japan with over 100,000 annual visitors?
SELECT COUNT(*) FROM cultural_heritage_sites WHERE country = 'Japan' AND annual_visitors > 100000;
gretelai_synthetic_text_to_sql
CREATE TABLE Users (id INT, join_date DATE); INSERT INTO Users (id, join_date) VALUES (1, '2021-02-01'), (2, '2021-02-15'), (3, '2021-03-20'), (4, '2021-04-01');
Find the number of users who joined in each month in 2021.
SELECT EXTRACT(MONTH FROM u.join_date) as month, COUNT(*) as users_joined FROM Users u WHERE EXTRACT(YEAR FROM u.join_date) = 2021 GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE water_consumption (id INT, operation_id INT, date DATE, consumption INT); INSERT INTO water_consumption (id, operation_id, date, consumption) VALUES (1, 1, '2021-01-01', 1000), (2, 1, '2021-02-01', 1200), (3, 2, '2021-01-01', 1500), (4, 2, '2021-02-01', 1800), (5, 3, '2021-01-01', 800), (6, 3, '2021-02-01', 900);
What is the average monthly water consumption for each mining operation?
SELECT o.operation_name, DATE_FORMAT(w.date, '%Y-%m') as month, AVG(w.consumption) as avg_consumption FROM mining_operations o INNER JOIN water_consumption w ON o.id = w.operation_id GROUP BY o.id, month;
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (VolunteerID INT, VolunteerName TEXT, DateOfBirth DATE); INSERT INTO Volunteers (VolunteerID, VolunteerName, DateOfBirth) VALUES (1, 'James', '1990-05-12'), (2, 'Kim', '2001-08-21'), (3, 'Liam', '1985-11-03'); CREATE TABLE VolunteerPrograms (ProgramID INT, ProgramName TEXT); INSERT INTO VolunteerPrograms (ProgramID, ProgramName) VALUES (1, 'Arts'), (2, 'Sports'), (3, 'Science'); CREATE TABLE VolunteerEvents (EventID INT, ProgramID INT, VolunteerID INT, EventDate DATE); INSERT INTO VolunteerEvents (EventID, ProgramID, VolunteerID, EventDate) VALUES (1, 1, 1, '2021-01-01'), (2, 2, 2, '2021-02-01'), (3, 1, 3, '2021-05-01');
What is the average age of volunteers in the 'Arts' program?
SELECT AVG(DATEDIFF(CURDATE(), Volunteers.DateOfBirth) / 365.25) AS AverageAge FROM Volunteers INNER JOIN VolunteerEvents ON Volunteers.VolunteerID = VolunteerEvents.VolunteerID INNER JOIN VolunteerPrograms ON VolunteerEvents.ProgramID = VolunteerPrograms.ProgramID WHERE VolunteerPrograms.ProgramName = 'Arts';
gretelai_synthetic_text_to_sql
CREATE TABLE cases (case_id INT, billing_amount DECIMAL(10, 2), outcome VARCHAR(50)); INSERT INTO cases (case_id, billing_amount, outcome) VALUES (1, 5000.00, 'Settled'), (2, 7000.00, 'Dismissed'), (3, 8000.00, 'Won');
What is the total billing amount for cases that resulted in a 'Settled' outcome?
SELECT SUM(billing_amount) FROM cases WHERE outcome = 'Settled';
gretelai_synthetic_text_to_sql
CREATE TABLE matches (match_id INT, sport VARCHAR(50), location VARCHAR(50), tickets_sold INT);
Insert a new record for a tennis match in France with 1500 tickets sold.
INSERT INTO matches (match_id, sport, location, tickets_sold) VALUES (3, 'Tennis', 'France', 1500);
gretelai_synthetic_text_to_sql
CREATE TABLE cases (id INT, judge_gender VARCHAR(6), defendant_gender VARCHAR(6)); INSERT INTO cases (id, judge_gender, defendant_gender) VALUES (1, 'Female', 'Male'), (2, 'Male', 'Female'), (3, 'Female', 'Male');
What is the number of cases with a female judge and male defendant?
SELECT COUNT(*) FROM cases WHERE judge_gender = 'Female' AND defendant_gender = 'Male';
gretelai_synthetic_text_to_sql
CREATE TABLE crops (id INT, name VARCHAR(255), type VARCHAR(255)); INSERT INTO crops (id, name, type) VALUES (1, 'Rice', 'Cereal'), (2, 'Soybean', 'Pulse');
What is the average yield (in kg) of indigenous crops in Asia in 2020?
SELECT AVG(yield_kg) FROM indigenous_crops JOIN crops ON indigenous_crops.crop_id = crops.id WHERE region = 'Asia' AND YEAR(date) = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE Programs (ProgramID INT, ProgramName TEXT, VolunteerCount INT); INSERT INTO Programs (ProgramID, ProgramName, VolunteerCount) VALUES (1, 'Feeding America', 75); INSERT INTO Programs (ProgramID, ProgramName, VolunteerCount) VALUES (2, 'Red Cross', 30); INSERT INTO Programs (ProgramID, ProgramName, VolunteerCount) VALUES (3, 'Habitat for Humanity', 60);
How many unique programs have more than 50 volunteers?
SELECT COUNT(DISTINCT ProgramID) FROM Programs WHERE VolunteerCount > 50;
gretelai_synthetic_text_to_sql
CREATE TABLE mining_sites (id INT, site_name TEXT, environmental_impact_score INT);CREATE VIEW site_averages AS SELECT id, AVG(environmental_impact_score) as avg_score FROM mining_sites;
What is the average environmental impact score for each mining site, and which sites have a score above the average?
SELECT s.site_name, s.environmental_impact_score, avg.avg_score FROM mining_sites s JOIN site_averages avg ON s.id = avg.id WHERE s.environmental_impact_score > avg.avg_score;
gretelai_synthetic_text_to_sql
CREATE TABLE LaborHours (State VARCHAR(2), Job VARCHAR(50), HoursWorked DATE);
What is the average construction labor hours worked per day, in each state, for electricians, in the past month, ordered from highest to lowest?
SELECT State, Job, AVG(HoursWorked / DATEDIFF(day, '2022-01-01', HoursWorked)) as AvgHoursPerDay FROM LaborHours WHERE Job = 'Electricians' AND HoursWorked >= DATEADD(MONTH, -1, GETDATE()) GROUP BY State, Job ORDER BY AvgHoursPerDay DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE HealthCenters (HealthCenterID INT, Name VARCHAR(50), State VARCHAR(20), PatientCount INT); INSERT INTO HealthCenters (HealthCenterID, Name, State, PatientCount) VALUES (1, 'Rural Health Center A', 'California', 3000); INSERT INTO HealthCenters (HealthCenterID, Name, State, PatientCount) VALUES (2, 'Rural Health Center B', 'California', 4000);
What is the name of the rural health center with the highest number of patients in "California"?
SELECT Name FROM HealthCenters WHERE State = 'California' AND PatientCount = (SELECT MAX(PatientCount) FROM HealthCenters WHERE State = 'California');
gretelai_synthetic_text_to_sql
CREATE TABLE Museums (MuseumID int, MuseumName varchar(50), CountryID int); CREATE TABLE Art (ArtID int, ArtName varchar(50), MuseumID int, ArtType varchar(50));
Which museums in Asia have the most extensive collections of Impressionist art?
SELECT Museums.MuseumName, COUNT(Art.ArtID) as TotalImpressionistArt FROM Museums INNER JOIN Art ON Museums.MuseumID = Art.MuseumID WHERE Art.ArtType = 'Impressionist' GROUP BY Museums.MuseumName HAVING Museums.CountryID = (SELECT CountryID FROM Countries WHERE Continent = 'Asia') ORDER BY TotalImpressionistArt DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE factories (factory_id INT, name TEXT, location TEXT, region TEXT, num_workers INT, industry_4_0 TEXT, num_technologies INT);
Show the number of workers in each factory, and the number of Industry 4.0 technologies they have implemented, grouped by region.
SELECT region, SUM(num_workers) as total_workers, COUNT(industry_4_0) as num_technologies FROM factories GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE acidity_measurements_southern (location TEXT, acidity_level REAL); INSERT INTO acidity_measurements_southern (location, acidity_level) VALUES ('Antarctica', 7.8), ('South Georgia', 8.0), ('Falkland Islands', 8.1);
What is the maximum ocean acidity level measured in the Southern Ocean?
SELECT MAX(acidity_level) FROM acidity_measurements_southern;
gretelai_synthetic_text_to_sql
CREATE TABLE inclusive_housing (property_id INT, size FLOAT, location VARCHAR(255)); INSERT INTO inclusive_housing (property_id, size, location) VALUES (1, 1000, 'Diverse District'), (2, 1100, 'Diverse District'), (3, 1300, 'Inclusive Isle');
How many properties are there in the inclusive_housing table for each location?
SELECT location, COUNT(property_id) FROM inclusive_housing GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE students (student_id INT, student_name TEXT); INSERT INTO students (student_id, student_name) VALUES (1, 'Alice Johnson'), (2, 'Bob Smith'), (3, 'Charlie Brown'), (4, 'Diana Ross'); CREATE TABLE open_pedagogy_projects (project_id INT, student_id INT, hours_spent_on_project INT); INSERT INTO open_pedagogy_projects (project_id, student_id, hours_spent_on_project) VALUES (1, 1, 20), (2, 1, 15), (3, 2, 30), (4, 2, 25), (5, 3, 10), (6, 3, 12), (7, 4, 35), (8, 4, 40);
What is the total number of hours spent on open pedagogy projects per student?
SELECT s.student_name, SUM(opp.hours_spent_on_project) as total_hours_spent_on_projects FROM open_pedagogy_projects opp JOIN students s ON opp.student_id = s.student_id GROUP BY opp.student_id;
gretelai_synthetic_text_to_sql
CREATE TABLE flights (flight_id INT, departure_date DATE, departure_country TEXT, arrival_country TEXT, co2_emission DECIMAL); INSERT INTO flights (flight_id, departure_date, departure_country, arrival_country, co2_emission) VALUES (1, '2020-01-01', 'USA', 'India', 100.00), (2, '2020-12-31', 'USA', 'India', 120.00);
What is the total CO2 emission of flights from USA to India in 2020?
SELECT SUM(co2_emission) FROM flights WHERE departure_country = 'USA' AND arrival_country = 'India' AND YEAR(departure_date) = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE deep_sea_expeditions (expedition_id INT, country VARCHAR(50), year INT);
How many deep-sea expeditions were conducted by country?'
SELECT country, COUNT(expedition_id) AS num_expeditions FROM deep_sea_expeditions GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_communication (campaign_name TEXT, start_date DATE); INSERT INTO climate_communication (campaign_name, start_date) VALUES ('Climate Action', '2021-01-01'), ('Green Tomorrow', '2022-01-01'), ('Green Horizons', '2023-01-01');
What is the name of the communication campaign that started last in the 'climate_communication' table?
SELECT campaign_name FROM climate_communication ORDER BY start_date DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE rugby_matches (id INT, home_team VARCHAR(50), away_team VARCHAR(50), location VARCHAR(50), date DATE, penalties_home INT, penalties_away INT); INSERT INTO rugby_matches (id, home_team, away_team, location, date, penalties_home, penalties_away) VALUES (1, 'New Zealand All Blacks', 'Australia Wallabies', 'Sydney', '2022-08-01', 6, 4); INSERT INTO rugby_matches (id, home_team, away_team, location, date, penalties_home, penalties_away) VALUES (2, 'South Africa Springboks', 'England Roses', 'London', '2022-09-05', 3, 1);
What is the total number of penalties given to a single team in the 'rugby_matches' table?
SELECT (SUM(penalties_home) + SUM(penalties_away)) FROM rugby_matches;
gretelai_synthetic_text_to_sql
CREATE TABLE ModelFairnessScores (ModelID INT, TeamID INT, FairnessScore INT); CREATE TABLE TeamLocations (TeamID INT, Country VARCHAR(20));
What is the distribution of fairness scores for models developed by teams in the US and Canada?
SELECT ModelFairnessScores.FairnessScore, TeamLocations.Country, COUNT(ModelFairnessScores.ModelID) AS ModelCount FROM ModelFairnessScores INNER JOIN TeamLocations ON ModelFairnessScores.TeamID = TeamLocations.TeamID WHERE TeamLocations.Country IN ('USA', 'Canada') GROUP BY ModelFairnessScores.FairnessScore, TeamLocations.Country;
gretelai_synthetic_text_to_sql
CREATE TABLE dance_attendance (id INT, attendee_age INT, program_type VARCHAR(255), visit_year INT);
What is the average age of visitors to dance programs in 2022?
SELECT program_type, AVG(attendee_age) OVER (PARTITION BY program_type) AS avg_age_by_program_type FROM dance_attendance WHERE visit_year = 2022 AND program_type LIKE '%dance%' ORDER BY program_type;
gretelai_synthetic_text_to_sql
CREATE TABLE funding(id INT, organization VARCHAR(255), amount FLOAT);
Insert new records into the funding table
INSERT INTO funding (id, organization, amount) VALUES (1, 'National Science Foundation', 500000); INSERT INTO funding (id, organization, amount) VALUES (2, 'Norwegian Research Council', 700000);
gretelai_synthetic_text_to_sql
CREATE TABLE art_styles (id INT, style VARCHAR(255), movement VARCHAR(255)); CREATE TABLE artworks (id INT, title VARCHAR(255), year INT, style_id INT);
Delete all artworks associated with the style 'Cubism' created before 1915.
DELETE FROM artworks WHERE style_id = (SELECT s.id FROM art_styles s WHERE s.style = 'Cubism') AND year < 1915;
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_sequestration (sequestration_id INT, species VARCHAR(50), co2_sequestration FLOAT);
List all the species in the carbon_sequestration table with a CO2 sequestration value above the average CO2 sequestration?
SELECT species FROM carbon_sequestration WHERE co2_sequestration > (SELECT AVG(co2_sequestration) FROM carbon_sequestration);
gretelai_synthetic_text_to_sql
CREATE TABLE mining_operations (id INT, country VARCHAR(20), operation_name VARCHAR(30), co2_emission INT); INSERT INTO mining_operations (id, country, operation_name, co2_emission) VALUES (1, 'Australia', 'Operation G', 18000); INSERT INTO mining_operations (id, country, operation_name, co2_emission) VALUES (2, 'Australia', 'Operation H', 22000); INSERT INTO mining_operations (id, country, operation_name, co2_emission) VALUES (3, 'Indonesia', 'Operation I', 15000);
What is the total CO2 emission of mining operations in Australia and Indonesia, and which operations emit more than 20,000 tons of CO2 per year?
SELECT operation_name, SUM(co2_emission) AS total_co2 FROM mining_operations WHERE country IN ('Australia', 'Indonesia') GROUP BY operation_name HAVING SUM(co2_emission) > 20000;
gretelai_synthetic_text_to_sql
CREATE TABLE tours (id INT, country VARCHAR(50), type VARCHAR(50), revenue FLOAT); INSERT INTO tours (id, country, type, revenue) VALUES (1, 'Costa Rica', 'Eco-friendly', 5000), (2, 'Brazil', 'Regular', 7000), (3, 'Costa Rica', 'Regular', 3000);
What is the total revenue generated from eco-friendly tours in Costa Rica?
SELECT SUM(revenue) FROM tours WHERE country = 'Costa Rica' AND type = 'Eco-friendly';
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (ArtistID INT, Name VARCHAR(100), Age INT, Genre VARCHAR(50)); INSERT INTO Artists (ArtistID, Name, Age, Genre) VALUES (1, 'John Doe', 35, 'Rock'); INSERT INTO Artists (ArtistID, Name, Age, Genre) VALUES (2, 'Jane Smith', 58, 'Rock');
Who is the oldest rock artist in the database?
SELECT Name, MAX(Age) FROM Artists WHERE Genre = 'Rock';
gretelai_synthetic_text_to_sql
CREATE TABLE MilitaryEquipmentSales (id INT, product VARCHAR(50), region VARCHAR(50), year INT, sales FLOAT); INSERT INTO MilitaryEquipmentSales (id, product, region, year, sales) VALUES (1, 'Tank', 'Asia-Pacific', 2020, 5000000); INSERT INTO MilitaryEquipmentSales (id, product, region, year, sales) VALUES (2, 'Fighter Jet', 'Asia-Pacific', 2020, 12000000);
Find the total number of military equipment sales in the Asia-Pacific region in 2020.
SELECT SUM(sales) FROM MilitaryEquipmentSales WHERE region = 'Asia-Pacific' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE FishPopulations (id INT, species VARCHAR(50), location VARCHAR(50), population INT, last_surveyed DATE); INSERT INTO FishPopulations (id, species, location, population, last_surveyed) VALUES (5, 'Clownfish', 'Indian Ocean', 350, '2020-07-01'); INSERT INTO FishPopulations (id, species, location, population, last_surveyed) VALUES (6, 'Parrotfish', 'Indian Ocean', 250, '2020-08-01');
What is the total population and earliest survey date for each fish species in the Indian Ocean?
SELECT species, SUM(population) as total_population, MIN(last_surveyed) as first_survey FROM FishPopulations WHERE location = 'Indian Ocean' GROUP BY species;
gretelai_synthetic_text_to_sql
CREATE TABLE MusicalEquipment (Id INT, EquipmentName VARCHAR(50), Category VARCHAR(50));CREATE TABLE Checkouts (Id INT, EquipmentId INT, ArtistId INT, CheckoutDate DATE);CREATE TABLE Artists (Id INT, Name VARCHAR(50));
How many times has each unique piece of musical equipment been checked out, and by which artists?
SELECT C.ArtistId, M.EquipmentName, COUNT(*) as CheckoutCount FROM Checkouts C INNER JOIN MusicalEquipment M ON C.EquipmentId = M.Id INNER JOIN Artists A ON C.ArtistId = A.Id GROUP BY C.ArtistId, M.EquipmentName;
gretelai_synthetic_text_to_sql
CREATE TABLE AI_Safety_Incidents (id INT, incident_type VARCHAR(50), region VARCHAR(50)); INSERT INTO AI_Safety_Incidents (id, incident_type, region) VALUES (1, 'Data Leakage', 'North America'); INSERT INTO AI_Safety_Incidents (id, incident_type, region) VALUES (2, 'Bias', 'Europe'); INSERT INTO AI_Safety_Incidents (id, incident_type, region) VALUES (3, 'Inaccuracy', 'Asia');
How many AI safety incidents have been recorded for each region, in descending order?
SELECT region, COUNT(*) as incident_count FROM AI_Safety_Incidents GROUP BY region ORDER BY incident_count DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels (ID VARCHAR(20), Name VARCHAR(20), Type VARCHAR(20), MinSpeed FLOAT); INSERT INTO Vessels VALUES ('V021', 'Vessel U', 'Passenger', 25.0), ('V022', 'Vessel V', 'Passenger', 22.5), ('V023', 'Vessel W', 'Cargo', 15.5);
What is the minimum speed of a passenger vessel?
SELECT MinSpeed FROM Vessels WHERE ID = (SELECT MIN(ID) FROM Vessels WHERE Type = 'Passenger');
gretelai_synthetic_text_to_sql
CREATE TABLE countries (id INT, name TEXT); CREATE TABLE satellites (id INT, country_id INT, name TEXT, launch_date DATE, manufacturer TEXT); INSERT INTO countries (id, name) VALUES (1, 'USA'), (2, 'Russia'), (3, 'China'), (4, 'India'); INSERT INTO satellites (id, country_id, name, launch_date, manufacturer) VALUES (1, 1, 'Dragon', '2012-05-25', 'SpaceX'), (2, 1, 'Falcon', '2015-12-21', 'SpaceX'), (3, 2, 'Sputnik', '1957-10-04', 'Russia'), (4, 3, 'ChinaSat 1E', '2000-12-05', 'CAST'), (5, 4, 'EDUSAT', '2004-09-20', 'ISRO'), (6, 2, 'Sputnik 2', '1957-11-03', 'Russia'), (7, 3, 'Dong Fang Hong 1', '1970-04-24', 'CAST'), (8, 4, 'Rohini', '1980-07-18', 'ISRO');
What is the name and launch date of the first satellite launched by each country?
SELECT c.name, s.name, s.launch_date FROM satellites s JOIN countries c ON s.country_id = c.id WHERE s.launch_date = (SELECT MIN(launch_date) FROM satellites WHERE country_id = c.id) GROUP BY c.name;
gretelai_synthetic_text_to_sql
CREATE TABLE Dam (id INT, name VARCHAR(255), build_date DATE); INSERT INTO Dam (id, name, build_date) VALUES (1, 'Dam A', '1991-01-01'), (2, 'Dam B', '1985-05-15'), (3, 'Dam C', '1999-03-25');
List all dams that were built in the 1990s
SELECT * FROM Dam WHERE build_date BETWEEN '1990-01-01' AND '1999-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE Arts_Centers (Center_Name VARCHAR(50), Country VARCHAR(50), Type VARCHAR(50)); INSERT INTO Arts_Centers (Center_Name, Country, Type) VALUES ('Sydney Opera House', 'Australia', 'Opera'), ('Teatro Colon', 'Argentina', 'Ballet');
What is the total number of traditional arts centers and the number of centers dedicated to dance in each continent, excluding Antarctica?
SELECT Continent, COUNT(*) AS Total_Arts_Centers, SUM(CASE WHEN Type = 'Dance' THEN 1 ELSE 0 END) AS Dance_Centers FROM Arts_Centers JOIN (SELECT 'Australia' AS Country, 'Oceania' AS Continent UNION ALL SELECT 'Argentina' AS Country, 'South America' AS Continent) AS Continents ON Arts_Centers.Country = Continents.Country GROUP BY Continent;
gretelai_synthetic_text_to_sql
CREATE TABLE Space_Satellites (Satellite_ID INT, Satellite_Name VARCHAR(100), Launch_Date DATE, Country_Name VARCHAR(50), Agency_Name VARCHAR(50)); INSERT INTO Space_Satellites (Satellite_ID, Satellite_Name, Launch_Date, Country_Name, Agency_Name) VALUES (1, 'Sat1', '2000-01-01', 'USA', 'NASA'), (2, 'Sat2', '2001-01-01', 'Russia', 'Roscosmos'), (3, 'Sat3', '2002-01-01', 'China', 'CNSA'), (4, 'Sat4', '2003-01-01', 'USA', 'NASA'), (5, 'Sat5', '2004-01-01', 'India', 'ISRO');
What is the earliest launch date for a satellite by country?
SELECT Country_Name, MIN(Launch_Date) as Earliest_Launch_Date FROM Space_Satellites GROUP BY Country_Name;
gretelai_synthetic_text_to_sql
CREATE TABLE crimes (id INT PRIMARY KEY, incident_date DATE, location VARCHAR(50), crime_type VARCHAR(50), description TEXT, FOREIGN KEY (incident_date) REFERENCES dates(date));
Delete all crime records for the location 'Park Avenue'
DELETE FROM crimes WHERE location = 'Park Avenue';
gretelai_synthetic_text_to_sql
CREATE TABLE space_missions (id INT, mission_name VARCHAR(255), launch_date DATE, average_temperature FLOAT); INSERT INTO space_missions (id, mission_name, launch_date, average_temperature) VALUES (1, 'Apollo 11', '1969-07-16', 300.5), (2, 'Mars Rover', '2004-01-04', 220.3);
What is the average temperature (in Kelvin) for each space mission?
SELECT mission_name, AVG(average_temperature) OVER (PARTITION BY mission_name) as avg_temp FROM space_missions;
gretelai_synthetic_text_to_sql
CREATE TABLE districts (did INT, district_name VARCHAR(255)); INSERT INTO districts (did, district_name) VALUES (1, 'Downtown'), (2, 'Uptown'), (3, 'Harbor'); CREATE TABLE emergency_calls (call_id INT, did INT, response_time INT, call_date DATE); INSERT INTO emergency_calls (call_id, did, response_time, call_date) VALUES (1, 1, 45, '2022-01-01'), (2, 2, 62, '2022-01-02'), (3, 3, 55, '2022-01-03');
Get the average response time for emergency calls by district for a specific date range
SELECT d.district_name, AVG(ec.response_time) as avg_response_time FROM districts d INNER JOIN emergency_calls ec ON d.did = ec.did WHERE ec.call_date BETWEEN '2022-01-01' AND '2022-01-03' GROUP BY d.district_name;
gretelai_synthetic_text_to_sql
CREATE TABLE CompanyEmployees (CompanyID INT, Company VARCHAR(20), Employees INT); INSERT INTO CompanyEmployees (CompanyID, Company, Employees) VALUES (1, 'Canada Gold', 100), (2, 'USA Silver', 200), (3, 'Mexico Coal', 150);
How many employees work at each mining company?
SELECT Company, COUNT(*) FROM CompanyEmployees GROUP BY Company;
gretelai_synthetic_text_to_sql
CREATE TABLE countries (id INT, name VARCHAR(50)); CREATE TABLE agroecology_practices (id INT, country_id INT, practice_name VARCHAR(50)); INSERT INTO countries (id, name) VALUES (1, 'Bolivia'), (2, 'Cuba'), (3, 'India'), (4, 'Kenya'); INSERT INTO agroecology_practices (id, country_id, practice_name) VALUES (1, 1, 'Agroforestry'), (2, 1, 'Crop rotation'), (3, 2, 'Organic farming'), (4, 3, 'System of Rice Intensification'), (5, 4, 'Permaculture'), (6, 1, 'Intercropping');
Display the names of all countries that have implemented agroecology practices and the total number of practices in each.
SELECT c.name, COUNT(ap.practice_name) AS total_practices FROM countries c JOIN agroecology_practices ap ON c.id = ap.country_id GROUP BY c.name;
gretelai_synthetic_text_to_sql
CREATE TABLE Restaurants (restaurant_id INT, name TEXT, city TEXT, revenue FLOAT); INSERT INTO Restaurants (restaurant_id, name, city, revenue) VALUES (1, 'Asian Fusion', 'New York', 50000.00), (2, 'Bella Italia', 'Los Angeles', 60000.00), (3, 'Sushi House', 'New York', 70000.00), (4, 'Pizzeria La Rosa', 'Chicago', 80000.00);
Find the top 5 cities with the highest average revenue.
SELECT city, AVG(revenue) as avg_revenue FROM Restaurants GROUP BY city ORDER BY avg_revenue DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE semiannual_rd_expenditures (half_year TEXT, drug_name TEXT, amount INT); CREATE TABLE drug_types (drug_name TEXT, drug_type TEXT); INSERT INTO semiannual_rd_expenditures (half_year, drug_name, amount) VALUES ('H1', 'DrugX', 250000), ('H2', 'DrugX', 300000), ('H1', 'DrugY', 350000), ('H2', 'DrugY', 400000), ('H1', 'DrugZ', 450000), ('H2', 'DrugZ', 500000); INSERT INTO drug_types (drug_name, drug_type) VALUES ('DrugX', 'Biologic'), ('DrugY', 'Generic'), ('DrugZ', 'Brand');
What are the total R&D expenditures per half year for each drug type in the 'semiannual_rd_expenditures' and 'drug_types' tables?
SELECT dt.drug_type, sre.half_year, SUM(sre.amount) as total_expenditure FROM semiannual_rd_expenditures sre JOIN drug_types dt ON sre.drug_name = dt.drug_name GROUP BY dt.drug_type, sre.half_year;
gretelai_synthetic_text_to_sql
CREATE TABLE offense (offense_id INT, offense_type VARCHAR(50), fine_amount INT); INSERT INTO offense (offense_id, offense_type, fine_amount) VALUES (1, 'Speeding', 100), (2, 'Theft', 500), (3, 'DUI', 1500);
What is the average fine amount per offense type?
SELECT offense_type, AVG(fine_amount) as avg_fine FROM offense GROUP BY offense_type;
gretelai_synthetic_text_to_sql
CREATE TABLE entrepreneurs (id INT, entrepreneur_id INT, country VARCHAR(50), gender VARCHAR(50), support_program BOOLEAN, support_year INT); INSERT INTO entrepreneurs (id, entrepreneur_id, country, gender, support_program, support_year) VALUES (1, 6001, 'Mexico', 'female', true, 2020), (2, 6002, 'Mexico', 'male', false, 2019);
How many female entrepreneurs received support in Mexico through economic diversification programs in 2020?
SELECT COUNT(*) FROM entrepreneurs WHERE country = 'Mexico' AND gender = 'female' AND support_program = true AND support_year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE shipping_lines(line_id INT, line_name TEXT);CREATE TABLE cargo(cargo_id INT, line_id INT, container_type TEXT, revenue INT);INSERT INTO shipping_lines VALUES (1,'Line A'),(2,'Line B'),(3,'Line C');INSERT INTO cargo VALUES (1,1,'Dry Van',1000),(2,1,'Reefer',1500),(3,2,'Dry Van',2000),(4,2,'Flat Rack',2500),(5,3,'Open Top',3000),(6,3,'Dry Van',3500);
Identify the top 3 container types that contribute to the highest revenue for each shipping line, considering the revenue generated from all cargo transported using those container types.
SELECT l.line_name, c.container_type, SUM(c.revenue) as total_revenue FROM cargo c JOIN shipping_lines l ON c.line_id = l.line_id GROUP BY l.line_id, c.container_type ORDER BY total_revenue DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Concerts (genre VARCHAR(255), city VARCHAR(255), ticket_price DECIMAL(5,2));
What is the highest ticket price for a jazz concert in Chicago?
SELECT MAX(ticket_price) FROM Concerts WHERE genre = 'jazz' AND city = 'Chicago';
gretelai_synthetic_text_to_sql
CREATE TABLE dispensaries (dispensary_id INT, name VARCHAR(255), address VARCHAR(255));
Insert a new record into the 'dispensaries' table with dispensary_id 501, name 'Buds & Beyond', and address '123 Main St'
INSERT INTO dispensaries (dispensary_id, name, address) VALUES (501, 'Buds & Beyond', '123 Main St');
gretelai_synthetic_text_to_sql
CREATE TABLE emissions (emission_id INT, product_id INT, category VARCHAR(50), co2_emissions INT);
What is the average CO2 emissions per beauty product category in 2021?
SELECT category, AVG(co2_emissions) as avg_emissions FROM emissions WHERE sale_date >= '2021-01-01' AND sale_date < '2022-01-01' GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_offsets_texas (project_name TEXT, state TEXT, carbon_offset INTEGER); INSERT INTO carbon_offsets_texas (project_name, state, carbon_offset) VALUES ('Carbon Capture Project', 'Texas', 2000);
What is the minimum carbon offset per project for carbon offset initiatives in the state of Texas?
SELECT MIN(carbon_offset) FROM carbon_offsets_texas WHERE state = 'Texas';
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, donor_id INT, amount DECIMAL(10,2), donation_date DATE);
What is the total amount donated per month, based on the 'donations' table?
SELECT EXTRACT(MONTH FROM donations.donation_date) AS month, SUM(donations.amount) FROM donations GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species_population (species_id INTEGER, species_name VARCHAR(255), population_trend VARCHAR(50));
List all marine species with a population trend of 'Decreasing'.
SELECT species_name FROM marine_species_population WHERE population_trend = 'Decreasing';
gretelai_synthetic_text_to_sql
CREATE TABLE FireDepartments (DepartmentID INT PRIMARY KEY, DepartmentName VARCHAR(50), EstablishedYear INT);
Delete all records in the 'FireDepartments' table where the 'DepartmentName' is 'Westside Fire Department'
DELETE FROM FireDepartments WHERE DepartmentName = 'Westside Fire Department';
gretelai_synthetic_text_to_sql
CREATE TABLE mining_sites (id INT, name VARCHAR(255), country VARCHAR(255), carbon_emissions_score INT); INSERT INTO mining_sites (id, name, country, carbon_emissions_score) VALUES (1, 'Site A', 'Canada', 75), (2, 'Site B', 'Mexico', 85), (3, 'Site C', 'Brazil', 95);
Which mining sites have a higher than average carbon emissions score, for a specific country?
SELECT name, carbon_emissions_score FROM mining_sites WHERE country = 'Canada' AND carbon_emissions_score > (SELECT AVG(carbon_emissions_score) FROM mining_sites WHERE country = 'Canada');
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name TEXT, founded_date DATE, founder_race TEXT); INSERT INTO companies (id, name, founded_date, founder_race) VALUES (1, 'Acme Inc', '2010-01-01', 'white'); INSERT INTO companies (id, name, founded_date, founder_race) VALUES (2, 'Beta Corp', '2015-05-15', 'asian'); INSERT INTO companies (id, name, founded_date, founder_race) VALUES (3, 'Gamma Startup', '2018-09-09', 'black');
How many companies were founded by individuals from underrepresented racial backgrounds?
SELECT COUNT(*) FROM companies WHERE founder_race IN ('black', 'latin', 'indigenous', 'pacific_islander');
gretelai_synthetic_text_to_sql
CREATE TABLE programs_2022 (id INT, program_name VARCHAR(50), participants INT, success INT); INSERT INTO programs_2022 (id, program_name, participants, success) VALUES (1, 'Program R', 20, 10), (2, 'Program S', 25, 15), (3, 'Program T', 30, 20), (4, 'Program U', 35, 25), (5, 'Program V', 40, 30), (6, 'Program W', 45, 35);
List the programs with a success rate of less than 50% in 2022?
SELECT program_name FROM programs_2022 WHERE success * 2 < participants GROUP BY program_name;
gretelai_synthetic_text_to_sql
CREATE TABLE MenuItems (menu_item_id INT, menu_item_name VARCHAR(255), price DECIMAL(10,2)); INSERT INTO MenuItems (menu_item_id, menu_item_name, price) VALUES (1, 'Burger', 5.99), (2, 'Pizza', 9.99), (3, 'Salad', 7.49); CREATE TABLE RestaurantSales (sale_id INT, restaurant_id INT, menu_item_id INT, quantity INT); INSERT INTO RestaurantSales (sale_id, restaurant_id, menu_item_id, quantity) VALUES (1, 1, 1, 2), (2, 1, 2, 1), (3, 2, 1, 1), (4, 2, 3, 3), (5, 3, 2, 2);
Calculate the revenue for each menu item
SELECT m.menu_item_name, SUM(rs.quantity * m.price) as revenue FROM MenuItems m INNER JOIN RestaurantSales rs ON m.menu_item_id = rs.menu_item_id GROUP BY m.menu_item_name;
gretelai_synthetic_text_to_sql
CREATE TABLE schools (school_id INT, district TEXT, budget INT); INSERT INTO schools (school_id, district, budget) VALUES (1, 'Downtown', 800000), (2, 'Uptown', 1200000), (3, 'Harbor', 1500000);
How many schools in each district have a budget over $1M?
SELECT district, COUNT(*) FROM schools WHERE budget > 1000000 GROUP BY district;
gretelai_synthetic_text_to_sql
CREATE TABLE conservation (id INT PRIMARY KEY, artifact_id INT, date DATE, notes TEXT);
Delete all conservation records for artifacts from the 'Tutankhamun's Tomb'
DELETE FROM conservation WHERE artifact_id IN (SELECT id FROM artifacts WHERE site_id = (SELECT id FROM sites WHERE name = 'Tutankhamun''s Tomb'));
gretelai_synthetic_text_to_sql
CREATE TABLE employees (employee_id INT, site_id INT, name VARCHAR(255), position VARCHAR(255)); INSERT INTO employees (employee_id, site_id, name, position) VALUES (1, 1, 'John Doe', 'Engineer'), (2, 1, 'Jane Smith', 'Supervisor'), (3, 2, 'Mike Johnson', 'Engineer');
Update the position of an employee in the employees table to 'Manager'
UPDATE employees SET position = 'Manager' WHERE employee_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Assistance (id INT, region VARCHAR(255), type VARCHAR(255), year INT);
What is the total number of humanitarian assistance incidents in the 'Assistance' table, for the 'Asia' region, that occurred in the year 2020?
SELECT COUNT(*) FROM Assistance WHERE region = 'Asia' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE pollution_control (id INT, initiative TEXT, ocean TEXT); INSERT INTO pollution_control (id, initiative, ocean) VALUES (1, 'Project Blue', 'Indian'), (2, 'Ocean Guard', 'Atlantic'), (3, 'Sea Cleaners', 'Pacific');
List all pollution control initiatives in the Indian and Atlantic oceans, ordered by initiative ID.
SELECT initiative FROM pollution_control WHERE ocean IN ('Indian', 'Atlantic') ORDER BY id;
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_energy_capacity_sa (energy_source VARCHAR(50), capacity INT); INSERT INTO renewable_energy_capacity_sa (energy_source, capacity) VALUES ('wind', 1500), ('solar', 2000), ('hydro', 1000);
What is the percentage of renewable energy generation capacity in South Africa that is attributed to solar energy?
SELECT 100.0 * SUM(CASE WHEN energy_source = 'solar' THEN capacity ELSE 0 END) / SUM(capacity) as solar_percentage FROM renewable_energy_capacity_sa;
gretelai_synthetic_text_to_sql
CREATE TABLE communities (community_id INT, community_name VARCHAR(50)); CREATE TABLE crimes (crime_id INT, community_id INT, crime_type VARCHAR(50), reported_date DATE); INSERT INTO communities (community_id, community_name) VALUES (1, 'Community A'), (2, 'Community B'), (3, 'Community C'); INSERT INTO crimes (crime_id, community_id, crime_type, reported_date) VALUES (1, 1, 'Theft', '2021-01-01'), (2, 2, 'Vandalism', '2021-02-01'), (3, 3, 'Burglary', '2021-03-01'), (4, 1, 'Theft', '2021-04-01');
What is the number of crimes committed by month in each community?
SELECT community_name, EXTRACT(MONTH FROM reported_date) AS month, COUNT(crime_id) crime_count FROM crimes JOIN communities ON crimes.community_id = communities.community_id GROUP BY community_name, month;
gretelai_synthetic_text_to_sql
CREATE TABLE threat_intelligence (threat_id INT, threat_type VARCHAR(20), threat_details TEXT);
Add a new view 'threat_summary' that displays the 'threat_type' and number of threats for each type from the 'threat_intelligence' table
CREATE VIEW threat_summary AS SELECT threat_type, COUNT(*) FROM threat_intelligence GROUP BY threat_type;
gretelai_synthetic_text_to_sql
CREATE TABLE Programs (ProgramID INT, ProgramName TEXT, ProgramCategory TEXT, Budget DECIMAL); INSERT INTO Programs (ProgramID, ProgramName, ProgramCategory, Budget) VALUES (1, 'Education', 'Social', 15000.00), (2, 'Healthcare', 'Health', 20000.00), (3, 'Environment', 'Environment', 10000.00);
What is the total budget for each program category?
SELECT ProgramCategory, SUM(Budget) as TotalBudget FROM Programs GROUP BY ProgramCategory;
gretelai_synthetic_text_to_sql
CREATE TABLE MarineSpeciesByRegion (RegionID INT, RegionName TEXT, SpeciesCount INT);
How many marine species are there in each region in the 'MarineSpeciesByRegion' table?
SELECT RegionName, SpeciesCount FROM MarineSpeciesByRegion;
gretelai_synthetic_text_to_sql
CREATE TABLE near_validators (validator_address VARCHAR(42), is_active BOOLEAN);
What is the total number of validators on the Near blockchain?
SELECT COUNT(validator_address) FROM near_validators WHERE is_active = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE temperature (year INT, avg_temp FLOAT);
Get the maximum and minimum ocean temperatures recorded in the last 5 years.
SELECT MAX(avg_temp), MIN(avg_temp) FROM temperature WHERE year >= EXTRACT(YEAR FROM NOW()) - 5;
gretelai_synthetic_text_to_sql
CREATE TABLE sales_data (drug_name TEXT, region TEXT, year INTEGER, sales INTEGER);
Identify the year-over-year change in sales for a specific drug in a specific sales region.
SELECT drug_name, region, year, sales, (LAG(sales) OVER (PARTITION BY drug_name, region ORDER BY year) - sales) / ABS(LAG(sales) OVER (PARTITION BY drug_name, region ORDER BY year)) AS yoy_change FROM sales_data WHERE drug_name = 'DrugZ' AND region = 'RegionB' ORDER BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE energy_efficiency_ratings (id INT, country VARCHAR(50), rating VARCHAR(10)); INSERT INTO energy_efficiency_ratings (id, country, rating) VALUES (1, 'Canada', 'B'), (2, 'US', 'C'), (3, 'Canada', 'B');
Update the energy efficiency rating to 'A' for all records in the 'energy_efficiency_ratings' table where the country is 'Canada'.
UPDATE energy_efficiency_ratings SET rating = 'A' WHERE country = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (hotel_id INT, hotel_name TEXT, city TEXT, eco_friendly BOOLEAN, occupancy_rate DECIMAL(5,2)); INSERT INTO hotels (hotel_id, hotel_name, city, eco_friendly, occupancy_rate) VALUES (1, 'EcoHotel Amsterdam', 'Amsterdam', TRUE, 0.82), (2, 'GreenSuites Amsterdam', 'Amsterdam', TRUE, 0.78), (3, 'Hotel Amsterdam', 'Amsterdam', FALSE, 0.90);
What is the average occupancy rate for eco-friendly hotels in Amsterdam?
SELECT AVG(occupancy_rate) FROM hotels WHERE city = 'Amsterdam' AND eco_friendly = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE Dispensaries (id INT, dispensary_name VARCHAR(255), state VARCHAR(255), income DECIMAL(10, 2), social_equity BOOLEAN); INSERT INTO Dispensaries (id, dispensary_name, state, income, social_equity) VALUES (1, 'Rainbow Dispensary', 'Washington', 200000.00, true);
What is the total revenue generated by social equity dispensaries in Washington?
SELECT SUM(income) FROM Dispensaries WHERE state = 'Washington' AND social_equity = true;
gretelai_synthetic_text_to_sql
CREATE TABLE teacher_info (teacher_id INT, name TEXT, last_pd_date DATE); INSERT INTO teacher_info (teacher_id, name, last_pd_date) VALUES (1, 'John Doe', '2022-01-01'), (2, 'Jane Smith', '2021-12-01'), (3, 'Mike Johnson', NULL); CREATE VIEW no_pd_teachers AS SELECT teacher_id, name FROM teacher_info WHERE last_pd_date IS NULL OR last_pd_date < DATEADD(year, -1, GETDATE());
Which teachers have not completed any professional development in the last year?
SELECT teacher_id, name FROM no_pd_teachers;
gretelai_synthetic_text_to_sql
CREATE TABLE grants (id INT, faculty_id INT, year INT, amount DECIMAL(10,2)); INSERT INTO grants (id, faculty_id, year, amount) VALUES (1, 1, 2020, 25000); INSERT INTO grants (id, faculty_id, year, amount) VALUES (2, 2, 2019, 30000); CREATE TABLE faculty (id INT, name VARCHAR(50), department VARCHAR(50)); INSERT INTO faculty (id, name, department) VALUES (1, 'Eva', 'Biology'); INSERT INTO faculty (id, name, department) VALUES (2, 'Frank', 'Chemistry');
What is the minimum amount of grant funding received by a single faculty member in the Biology department in a single year?
SELECT MIN(g.amount) FROM grants g JOIN faculty f ON g.faculty_id = f.id WHERE f.department = 'Biology';
gretelai_synthetic_text_to_sql
CREATE TABLE student_info (student_id INT, name VARCHAR(255)); INSERT INTO student_info (student_id, name) VALUES (1, 'John Doe'); INSERT INTO student_info (student_id, name) VALUES (2, 'Jane Smith'); CREATE TABLE student_disability_accommodations (student_id INT, accommodation_type VARCHAR(255), department VARCHAR(255)); INSERT INTO student_disability_accommodations (student_id, accommodation_type, department) VALUES (1, 'Extended Testing Time', 'Computer Science'); INSERT INTO student_disability_accommodations (student_id, accommodation_type, department) VALUES (1, 'Note Taker', 'Physics');
List the names and IDs of students who have received accommodations in more than one department.
SELECT s.student_id, s.name FROM student_info s JOIN student_disability_accommodations sa1 ON s.student_id = sa1.student_id JOIN student_disability_accommodations sa2 ON s.student_id = sa2.student_id WHERE sa1.department <> sa2.department;
gretelai_synthetic_text_to_sql
CREATE TABLE Events (event_id INT, event_name VARCHAR(255)); INSERT INTO Events (event_id, event_name) VALUES (1, 'Art in the Park'), (2, 'Music Festival'); CREATE TABLE Audience (audience_id INT, event_id INT, age_group VARCHAR(50)); INSERT INTO Audience (audience_id, event_id, age_group) VALUES (1, 1, '18-24'), (2, 1, '25-34'), (3, 2, '35-44');
What is the distribution of attendees by age group for the 'Art in the Park' event?
SELECT e.event_name, a.age_group, COUNT(a.audience_id) AS attendee_count FROM Events e JOIN Audience a ON e.event_id = a.event_id GROUP BY e.event_name, a.age_group;
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers (id INT, name VARCHAR(50), country VARCHAR(50), sustainability_score INT); INSERT INTO suppliers (id, name, country, sustainability_score) VALUES (1, 'GreenTech', 'USA', 85); INSERT INTO suppliers (id, name, country, sustainability_score) VALUES (2, 'EcoInnovations', 'Canada', 90);
Rank suppliers by their sustainability scores.
SELECT *, ROW_NUMBER() OVER (ORDER BY sustainability_score DESC) as rank FROM suppliers;
gretelai_synthetic_text_to_sql
CREATE TABLE game_ticket_sales_by_team (id INT, game_id INT, team VARCHAR(50), revenue INT); INSERT INTO game_ticket_sales_by_team (id, game_id, team, revenue) VALUES (1, 1, 'TeamA', 3000), (2, 1, 'TeamA', 2000), (3, 2, 'TeamB', 4000), (4, 2, 'TeamB', 3000);
What is the total revenue from tickets sold for each game?
SELECT game_id, team, SUM(revenue) as total_revenue FROM game_ticket_sales_by_team GROUP BY game_id, team;
gretelai_synthetic_text_to_sql
CREATE TABLE plate (plate_id INT, name VARCHAR(255), PRIMARY KEY(plate_id)); INSERT INTO plate (plate_id, name) VALUES (1, 'Pacific'); CREATE TABLE trench (trench_id INT, name VARCHAR(255), plate_id INT, avg_depth DECIMAL(5,2), PRIMARY KEY(trench_id), FOREIGN KEY (plate_id) REFERENCES plate(plate_id)); INSERT INTO trench (trench_id, name, plate_id, avg_depth) VALUES (1, 'Mariana Trench', 1, 10994);
What is the average depth of oceanic trenches in the Pacific plate?'
SELECT AVG(avg_depth) FROM trench WHERE plate_id = (SELECT plate_id FROM plate WHERE name = 'Pacific');
gretelai_synthetic_text_to_sql
CREATE TABLE freight_forwarder (id INT, name VARCHAR(255), revenue FLOAT); INSERT INTO freight_forwarder (id, name, revenue) VALUES (1, 'ABC Logistics', 500000), (2, 'XYZ Freight', 600000); CREATE TABLE revenue_by_quarter (ff_id INT, quarter VARCHAR(10), revenue FLOAT); INSERT INTO revenue_by_quarter (ff_id, quarter, revenue) VALUES (1, 'Q2 2022', 150000), (2, 'Q2 2022', 200000);
Identify the freight forwarder with the highest revenue in 'Q2 2022'.
SELECT ff_id, MAX(revenue) FROM revenue_by_quarter WHERE quarter = 'Q2 2022' GROUP BY ff_id;
gretelai_synthetic_text_to_sql
CREATE TABLE financial_capability (gender VARCHAR(255), score INT); INSERT INTO financial_capability (gender, score) VALUES ('Male', 1200), ('Female', 1300);
What is the total financial capability score for each gender?
SELECT gender, SUM(score) FROM financial_capability GROUP BY gender;
gretelai_synthetic_text_to_sql
CREATE TABLE financial_capability_programs (program_id INT, launch_date DATE, region TEXT); CREATE TABLE financial_capability_launches (launch_id INT, program_id INT);
How many financial capability programs have been launched in each region in the past year?
SELECT fcp.region, COUNT(fcp.program_id) FROM financial_capability_programs fcp JOIN financial_capability_launches fcl ON fcp.program_id = fcl.program_id WHERE fcp.launch_date >= DATEADD(year, -1, CURRENT_DATE()) GROUP BY fcp.region;
gretelai_synthetic_text_to_sql
CREATE TABLE Revenue (Date DATE, Genre VARCHAR(10), Revenue DECIMAL(10, 2)); INSERT INTO Revenue VALUES ('2021-01-01', 'Rock', 1500), ('2021-02-01', 'Pop', 2000), ('2022-01-01', 'Rock', 1800), ('2022-02-01', 'Pop', 2200);
Show me the total revenue generated by rock and pop genres in 2021 and 2022.
(SELECT Genre, SUM(Revenue) FROM Revenue WHERE Date >= '2021-01-01' AND Date <= '2022-12-31' AND Genre = 'Rock' GROUP BY Genre) UNION (SELECT Genre, SUM(Revenue) FROM Revenue WHERE Date >= '2021-01-01' AND Date <= '2022-12-31' AND Genre = 'Pop' GROUP BY Genre);
gretelai_synthetic_text_to_sql
CREATE TABLE theater_performances (performance_id INT, genre VARCHAR(255), num_attendees INT); INSERT INTO theater_performances (performance_id, genre, num_attendees) VALUES (1, 'Drama', 100), (2, 'Comedy', 120), (3, 'Musical', 150);
Count the number of attendees at the "theater_performances" table grouped by genre.
SELECT genre, COUNT(*) FROM theater_performances GROUP BY genre;
gretelai_synthetic_text_to_sql
CREATE TABLE Digital_Assets (Asset_ID INT, Asset_Name VARCHAR(100), Gas_Fees DECIMAL(10,2), Issuer_Country VARCHAR(50)); INSERT INTO Digital_Assets (Asset_ID, Asset_Name, Gas_Fees, Issuer_Country) VALUES (1, 'AssetA', 0.15, 'Nigeria'), (2, 'AssetB', 0.05, 'South Africa');
What is the average gas fee for Cardano and Stellar digital assets issued by companies based in Africa?
SELECT Issuer_Country, AVG(Gas_Fees) FROM Digital_Assets WHERE Issuer_Country = 'Africa' AND Asset_Name IN ('Cardano', 'Stellar') GROUP BY Issuer_Country;
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (id INT, name TEXT, community_type TEXT, hours_contributed INT); INSERT INTO volunteers (id, name, community_type, hours_contributed) VALUES (1, 'John Doe', 'Underrepresented', 25); INSERT INTO volunteers (id, name, community_type, hours_contributed) VALUES (2, 'Jane Smith', 'Represented', 30);
What is the total number of volunteer hours contributed by volunteers from underrepresented communities in the past year?
SELECT SUM(hours_contributed) FROM volunteers WHERE community_type = 'Underrepresented' AND DATE(event_date) >= DATE_SUB(CURRENT_DATE(), INTERVAL 1 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE polar_bears (polar_bear_id INT, polar_bear_name VARCHAR(50), age INT, weight FLOAT, sanctuary VARCHAR(50)); INSERT INTO polar_bears (polar_bear_id, polar_bear_name, age, weight, sanctuary) VALUES (1, 'Polar_Bear_1', 12, 500, 'Arctic Tundra'); INSERT INTO polar_bears (polar_bear_id, polar_bear_name, age, weight, sanctuary) VALUES (2, 'Polar_Bear_2', 8, 600, 'Arctic Tundra');
What is the maximum weight of adult polar bears in the 'Arctic Tundra' sanctuary?
SELECT MAX(weight) FROM polar_bears WHERE sanctuary = 'Arctic Tundra' AND age >= 18;
gretelai_synthetic_text_to_sql
CREATE TABLE games (game_id INT, home_team INT, away_team INT, home_points INT, away_points INT);
What is the highest scoring game in the history of the NBA?
SELECT home_team, away_team, home_points, away_points FROM games WHERE (home_points + away_points) = (SELECT MAX(home_points + away_points) FROM games);
gretelai_synthetic_text_to_sql
CREATE TABLE brands (brand_id INT, brand_name TEXT); CREATE TABLE products (product_id INT, product_name TEXT, brand_id INT, is_cruelty_free BOOLEAN); INSERT INTO products (product_id, product_name, brand_id, is_cruelty_free) VALUES (1, 'Product X', 1, FALSE), (2, 'Product Y', 1, FALSE), (3, 'Product Z', 2, TRUE);
Which brands have the lowest percentage of cruelty-free products in Germany?
SELECT brand_name, AVG(is_cruelty_free) as percentage_cruelty_free FROM brands JOIN products ON brands.brand_id = products.brand_id GROUP BY brand_name ORDER BY percentage_cruelty_free ASC;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_life_research_stations (id INT, name VARCHAR(255), region VARCHAR(255), depth FLOAT);
What is the average depth of marine life research stations in each region?
SELECT region, AVG(depth) FROM marine_life_research_stations GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE mines (id INT, name VARCHAR(50), location VARCHAR(50), size INT, operational_status VARCHAR(20), state VARCHAR(20)); INSERT INTO mines VALUES (1, 'Mine 1', 'USA', 500, 'operational', 'California'); INSERT INTO mines VALUES (2, 'Mine 2', 'USA', 400, 'operational', 'Texas'); INSERT INTO mines VALUES (3, 'Mine 3', 'Australia', 600, 'operational', 'Queensland');
List the number of operational mines in each state, grouped by state.
SELECT state, COUNT(*) as operational_mine_count FROM mines WHERE operational_status = 'operational' GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE oklahoma_rural_clinics (clinic_id INT, rural_area VARCHAR(255), address VARCHAR(255), distance FLOAT); INSERT INTO oklahoma_rural_clinics VALUES (1, 'Rural Area 1', '123 Main St', 5.5), (2, 'Rural Area 2', '456 Elm St', 8.3);
What is the minimum distance to the nearest clinic for residents in rural areas of Oklahoma?
SELECT MIN(distance) FROM oklahoma_rural_clinics WHERE rural_area IS NOT NULL;
gretelai_synthetic_text_to_sql