context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE CityWaste (CityName VARCHAR(50), WasteQuantity INT, WasteYear INT); INSERT INTO CityWaste (CityName, WasteQuantity, WasteYear) VALUES ('CityA', 12000, 2018), ('CityB', 15000, 2018), ('CityC', NULL, 2018), ('CityD', 18000, 2018);
List all the cities and their total waste generation quantities for 2018, excluding records that have missing data?
SELECT CityName, SUM(WasteQuantity) FROM CityWaste WHERE WasteYear = 2018 AND WasteQuantity IS NOT NULL GROUP BY CityName;
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, name VARCHAR(255), country VARCHAR(255), language VARCHAR(10)); CREATE TABLE posts (id INT, user_id INT, content TEXT, created_at TIMESTAMP);
Get the top 2 languages with the most posts related to AI.
SELECT posts.language, COUNT(posts.id) AS posts_count FROM posts JOIN users ON users.id = posts.user_id WHERE posts.content LIKE '%AI%' GROUP BY posts.language ORDER BY posts_count DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE policyholders (id INT, name TEXT, age INT, gender TEXT, state TEXT); INSERT INTO policyholders (id, name, age, gender, state) VALUES (1, 'John Doe', 35, 'Male', 'Texas'); INSERT INTO policyholders (id, name, age, gender, state) VALUES (2, 'Jane Smith', 42, 'Female', 'Texas'); INSERT INTO policyholders (id, name, age, gender, state) VALUES (3, 'Bob Johnson', 27, 'Male', 'California'); INSERT INTO policyholders (id, name, age, gender, state) VALUES (4, 'Alice Williams', 32, 'Female', 'Texas');
What is the average age of policyholders in 'Texas'?
SELECT AVG(policyholders.age) AS avg_age FROM policyholders WHERE policyholders.state = 'Texas';
gretelai_synthetic_text_to_sql
CREATE TABLE EducationProjects (ProjectID INT, Name VARCHAR(100), Budget DECIMAL(10,2), Year INT, State VARCHAR(50)); INSERT INTO EducationProjects (ProjectID, Name, Budget, Year, State) VALUES (1, 'School Construction', 10000000, 2020, 'New York'), (2, 'Teacher Training', 500000, 2019, 'New York'), (3, 'Education Technology', 800000, 2020, 'California');
What is the total budget allocated to all education projects in the state of New York in the year 2020?
SELECT SUM(Budget) FROM EducationProjects WHERE Year = 2020 AND State = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE cultural_centers (name VARCHAR(255), opening_hours VARCHAR(255), location VARCHAR(255)); INSERT INTO cultural_centers (name, opening_hours, location) VALUES ('Native American Cultural Center', '09:00-17:00', 'New Mexico'), ('Asian Cultural Center', '10:00-18:00', 'New York');
What are the opening hours and locations of all cultural centers in the 'culture' schema?
SELECT name, opening_hours, location FROM culture.cultural_centers;
gretelai_synthetic_text_to_sql
CREATE TABLE warehouse (id INT, location VARCHAR(255), capacity INT); INSERT INTO warehouse (id, location, capacity) VALUES (1, 'warehouse1', 5000), (2, 'warehouse2', 7000); CREATE TABLE freight (id INT, warehouse_id INT, volume INT, destination VARCHAR(255), shipped_date DATE); INSERT INTO freight (id, warehouse_id, volume, destination, shipped_date) VALUES (1, 1, 150, 'Europe', '2021-08-01'), (2, 2, 200, 'Asia', '2021-09-05'), (3, 1, 120, 'Africa', '2021-10-10'), (4, 2, 220, 'Asia', '2021-09-15'), (5, 1, 180, 'Europe', '2021-08-20');
What is the total volume of freight forwarded to Asia from 'warehouse2' in Q3 2021?
SELECT SUM(volume) FROM freight WHERE warehouse_id = 2 AND destination LIKE 'Asia%' AND shipped_date BETWEEN '2021-07-01' AND '2021-12-31' AND EXTRACT(QUARTER FROM shipped_date) = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE regions (id INT, name VARCHAR(255)); INSERT INTO regions (id, name) VALUES (1, 'Region1'); CREATE TABLE schools (id INT, region_id INT, name VARCHAR(255)); CREATE TABLE hospitals (id INT, region_id INT, name VARCHAR(255));
Find the number of schools and hospitals in each region, and their sum
SELECT r.name, COUNT(s.id) AS school_count, COUNT(h.id) AS hospital_count, COUNT(s.id) + COUNT(h.id) AS total FROM regions r
gretelai_synthetic_text_to_sql
CREATE TABLE waste_generation (country VARCHAR(50), year INT, waste_amount FLOAT); INSERT INTO waste_generation (country, year, waste_amount) VALUES ('Canada', 2020, 1200.5), ('Mexico', 2020, 1500.3), ('USA', 2020, 2000.0), ('Brazil', 2020, 1800.2), ('Argentina', 2020, 1300.9);
What is the total waste generation in gram for each country in 2020, sorted by the highest amount?
SELECT country, SUM(waste_amount) FROM waste_generation WHERE year = 2020 GROUP BY country ORDER BY SUM(waste_amount) DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, customer_name VARCHAR(50), state VARCHAR(20), risk_level VARCHAR(10)); INSERT INTO customers (customer_id, customer_name, state, risk_level) VALUES (1, 'John Doe', 'FL', 'medium'), (2, 'Jane Smith', 'NY', 'medium');
What is the average risk level for customers in Florida?
SELECT AVG(CASE WHEN risk_level = 'high' THEN 3 WHEN risk_level = 'medium' THEN 2 WHEN risk_level = 'low' THEN 1 END) FROM customers WHERE state = 'FL';
gretelai_synthetic_text_to_sql
CREATE TABLE Archaeologists (ArchaeologistID INT PRIMARY KEY, Name VARCHAR(255), Age INT, Specialization VARCHAR(255)); INSERT INTO Archaeologists (ArchaeologistID, Name, Age, Specialization) VALUES (6, 'Marie-Louise von Plessen', 72, 'Underwater Archaeology'), (7, 'Francesco Bandelli', 55, 'Historical Archaeology'), (8, 'Sophie de Schaepdrijver', 58, 'Archaeology of War');
Who are the archaeologists specializing in 'Underwater Archaeology'?
SELECT * FROM Archaeologists WHERE Specialization = 'Underwater Archaeology';
gretelai_synthetic_text_to_sql
CREATE TABLE Field17 (sensor_id INT, sensor_name VARCHAR(50), sensor_type VARCHAR(50), data DATETIME); INSERT INTO Field17 (sensor_id, sensor_name, sensor_type, data) VALUES (1, 'TemperatureSensor1', 'Temperature', '2021-06-16 10:00:00'), (2, 'TemperatureSensor2', 'Temperature', '2021-06-14 12:45:00'); CREATE TABLE Field18 (sensor_id INT, sensor_name VARCHAR(50), sensor_type VARCHAR(50), data DATETIME); INSERT INTO Field18 (sensor_id, sensor_name, sensor_type, data) VALUES (3, 'TemperatureSensor3', 'Temperature', '2021-06-30 09:30:00'), (4, 'TemperatureSensor4', 'Temperature', '2021-06-28 11:00:00');
Which temperature sensors in 'Field17' and 'Field18' have recorded data between '2021-06-15' and '2021-06-30'?
SELECT DISTINCT sensor_name FROM Field17 WHERE data BETWEEN '2021-06-15' AND '2021-06-30' UNION SELECT DISTINCT sensor_name FROM Field18 WHERE data BETWEEN '2021-06-15' AND '2021-06-30';
gretelai_synthetic_text_to_sql
CREATE TABLE artists (artist_id INT PRIMARY KEY, name VARCHAR(100), birth_date DATE, death_date DATE, nationality VARCHAR(50)); CREATE TABLE artworks (artwork_id INT PRIMARY KEY, title VARCHAR(100), year INT, artist_id INT, art_medium VARCHAR(50), FOREIGN KEY (artist_id) REFERENCES artists(artist_id));
List all unique art mediums used in the artworks
SELECT DISTINCT art_medium FROM artworks;
gretelai_synthetic_text_to_sql
CREATE TABLE smart_city_features (city VARCHAR(50), feature VARCHAR(50)); INSERT INTO smart_city_features (city, feature) VALUES ('CityA', 'Smart Lighting'), ('CityA', 'Smart Transportation'), ('CityB', 'Smart Waste Management'), ('CityB', 'Smart Grid');
How many smart city features does each city have?
SELECT city, COUNT(feature) FROM smart_city_features GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE businesses (id INT, name TEXT, industry TEXT, ownership TEXT, funding FLOAT); INSERT INTO businesses (id, name, industry, ownership, funding) VALUES (1, 'EnergyCo', 'Energy', 'Majority', 350000.00); INSERT INTO businesses (id, name, industry, ownership, funding) VALUES (2, 'TechCo', 'Technology', 'Minority', 500000.00);
What is the average amount of funding allocated to businesses in the Energy sector?
SELECT AVG(funding) FROM businesses WHERE industry = 'Energy';
gretelai_synthetic_text_to_sql
CREATE TABLE victims (id INT, name TEXT, state TEXT); CREATE TABLE restorative_justice_services (id INT, victim_id INT, service_type TEXT); INSERT INTO victims (id, name, state) VALUES (1, 'Olivia Johnson', 'Colorado'); INSERT INTO victims (id, name, state) VALUES (2, 'Daniel Lee', 'Colorado'); INSERT INTO victims (id, name, state) VALUES (3, 'Maria Garcia', 'Colorado');
Insert a new restorative justice service (type: 'Peacemaking Circle') for a victim (id: 3) in Colorado.
INSERT INTO restorative_justice_services (id, victim_id, service_type) VALUES (1, 3, 'Peacemaking Circle');
gretelai_synthetic_text_to_sql
CREATE TABLE coral_reefs (reef_name TEXT, biomass REAL, region TEXT);
Display the total biomass of coral reefs in the Indo-Pacific region
SELECT SUM(biomass) FROM coral_reefs WHERE region = 'Indo-Pacific';
gretelai_synthetic_text_to_sql
CREATE TABLE green_buildings_timeline (id INT, building_id INT, start_date DATE);
Calculate the total annual energy savings for green buildings constructed in 2020
SELECT SUM(green_buildings.annual_energy_savings_kWh) FROM green_buildings JOIN green_buildings_timeline ON green_buildings.id = green_buildings_timeline.building_id WHERE green_buildings_timeline.start_date >= '2020-01-01' AND green_buildings_timeline.start_date < '2021-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE farm_sizes (id INT, size INT, country VARCHAR(255)); INSERT INTO farm_sizes (id, size, country) VALUES (1, 2, 'India');
What is the minimum area required for a sustainable farm in India?
SELECT MIN(size) FROM farm_sizes WHERE country = 'India';
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists animal_population (id INT, animal VARCHAR(255), country VARCHAR(255), population INT); INSERT INTO animal_population (id, animal, country, population) VALUES (1, 'Tiger', 'India', 2500), (2, 'Tiger', 'Bangladesh', 150), (3, 'Elephant', 'India', 5000), (4, 'Elephant', 'Sri Lanka', 2500);
Calculate the average population of each animal
SELECT animal, AVG(population) FROM animal_population GROUP BY animal;
gretelai_synthetic_text_to_sql
CREATE TABLE teams (team_id INT, team_name VARCHAR(255), league VARCHAR(255));CREATE TABLE players (player_id INT, player_name VARCHAR(255), position VARCHAR(50), team_id INT, birth_date DATE); INSERT INTO teams VALUES (1, 'Liverpool', 'English Premier League'); INSERT INTO players VALUES (1, 'Alisson Becker', 'Goalkeeper', 1, '1992-10-02');
What is the average age of football players in the English Premier League by position?
SELECT position, AVG(YEAR(CURRENT_DATE) - YEAR(birth_date)) AS avg_age FROM players JOIN teams ON players.team_id = teams.team_id WHERE teams.league = 'English Premier League' GROUP BY position;
gretelai_synthetic_text_to_sql
CREATE TABLE SportsTeamPerformance (id INT, team_name VARCHAR(255), win_rate DECIMAL(5,2), avg_fan_age INT); INSERT INTO SportsTeamPerformance (id, team_name, win_rate, avg_fan_age) VALUES (1, 'TeamA', 0.75, 32), (2, 'TeamB', 0.62, 40), (3, 'TeamC', 0.58, 38); CREATE TABLE FanDemographics (id INT, name VARCHAR(255), gender VARCHAR(50), team_name VARCHAR(255), fan_age INT); INSERT INTO FanDemographics (id, name, gender, team_name, fan_age) VALUES (1, 'FanD', 'Male', 'TeamA', 30), (2, 'FanE', 'Female', 'TeamB', 45), (3, 'FanF', 'Male', 'TeamC', 35);
Which sports teams had a win rate greater than 60% and an average fan age above 35?
SELECT team_name FROM SportsTeamPerformance WHERE win_rate > 0.6 AND (SELECT AVG(fan_age) FROM FanDemographics WHERE team_name = SportsTeamPerformance.team_name) > 35;
gretelai_synthetic_text_to_sql
CREATE TABLE company_innovation (company_id INT, founding_year INT, patent_count INT); INSERT INTO company_innovation (company_id, founding_year, patent_count) VALUES (1, 2009, 3), (2, 2011, 1), (3, 2008, 2), (4, 2010, 4);
How many patents were filed by companies founded before 2010?
SELECT founding_year, SUM(patent_count) FROM company_innovation WHERE founding_year < 2010 GROUP BY founding_year;
gretelai_synthetic_text_to_sql
CREATE TABLE Players (Id INT, Name VARCHAR(100), Country VARCHAR(50), Game VARCHAR(50)); INSERT INTO Players VALUES (1, 'Player1', 'USA', 'GameX'), (2, 'Player2', 'Canada', 'GameY'), (3, 'Player3', 'USA', 'GameZ'), (4, 'Player4', 'Mexico', 'GameX'), (5, 'Player5', 'Canada', 'GameY'), (6, 'Player6', 'USA', 'GameW'), (7, 'Player7', 'Brazil', 'GameX'); CREATE TABLE Games (Id INT, Name VARCHAR(100), Genre VARCHAR(50)); INSERT INTO Games VALUES (1, 'GameX', 'Adventure'), (2, 'GameY', 'Simulation'), (3, 'GameZ', 'Adventure'), (4, 'GameW', 'Strategy');
How many players are there in each country playing 'Simulation' games?
SELECT p.Country, COUNT(*) AS Players_Count FROM Players p JOIN Games g ON p.Game = g.Name WHERE g.Genre = 'Simulation' GROUP BY p.Country;
gretelai_synthetic_text_to_sql
CREATE TABLE LegalTechnologyGrants (ID INT, GrantID VARCHAR(20), District VARCHAR(20), Amount INT, Year INT); INSERT INTO LegalTechnologyGrants (ID, GrantID, District, Amount, Year) VALUES (1, 'LTG2016', 'North Valley', 15000, 2016), (2, 'LTG2017', 'East River', 20000, 2017), (3, 'LTG2018', 'North Valley', 10000, 2018);
How many legal technology grants were awarded to organizations in 'North Valley' justice district?
SELECT COUNT(*) FROM LegalTechnologyGrants WHERE District = 'North Valley';
gretelai_synthetic_text_to_sql
CREATE TABLE neighborhoods (name VARCHAR(50), id INT, PRIMARY KEY (id)); INSERT INTO neighborhoods (name, id) VALUES ('Brewerytown', 1), ('Fairmount', 2); CREATE TABLE properties (id INT, neighborhood_id INT, price FLOAT, livable_square_feet INT, PRIMARY KEY (id), FOREIGN KEY (neighborhood_id) REFERENCES neighborhoods(id));
What is the average property price per square foot in each neighborhood?
SELECT neighborhood_id, AVG(price/livable_square_feet) AS avg_price_per_sqft FROM properties GROUP BY neighborhood_id;
gretelai_synthetic_text_to_sql
CREATE TABLE capacity (country VARCHAR(255), technology VARCHAR(255), year INT, capacity FLOAT);
What is the total installed capacity (in MW) for wind and solar power plants by country as of 2020?
SELECT country, SUM(capacity) FROM capacity WHERE year = 2020 AND technology IN ('wind', 'solar') GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE Paintings (PaintingID INT, Title VARCHAR(50), ArtistID INT, YearCreated INT, Movement VARCHAR(50)); INSERT INTO Paintings (PaintingID, Title, ArtistID, YearCreated, Movement) VALUES (1, 'Starry Night', 1, 1889, 'Post-Impressionism'); INSERT INTO Paintings (PaintingID, Title, ArtistID, YearCreated, Movement) VALUES (2, 'The Persistence of Memory', 3, 1931, 'Surrealism'); CREATE TABLE Movements (MovementID INT, Name VARCHAR(50)); INSERT INTO Movements (MovementID, Name) VALUES (1, 'Impressionism'); INSERT INTO Movements (MovementID, Name) VALUES (2, 'Post-Impressionism');
Find all the paintings from the 'Impressionist' movement.
SELECT PaintingID, Title, ArtistID, YearCreated, Movement FROM Paintings WHERE Movement IN ('Impressionism', 'Post-Impressionism');
gretelai_synthetic_text_to_sql
CREATE TABLE population (county_id INT, county_name TEXT, population_count INT); INSERT INTO population (county_id, county_name, population_count) VALUES (1, 'County A', 10000), (2, 'County B', 20000), (3, 'County C', 30000); CREATE TABLE physicians (physician_id INT, physician_name TEXT, county_id INT, specialty TEXT); INSERT INTO physicians (physician_id, physician_name, county_id, specialty) VALUES (1, 'Physician A', 1, 'Primary Care'), (2, 'Physician B', 2, 'Specialty Care'), (3, 'Physician C', 3, 'Primary Care');
What is the number of primary care physicians per capita?
SELECT p.county_name, COUNT(*) FILTER (WHERE p.specialty = 'Primary Care') * 1.0 / p.population_count as ratio FROM physicians p INNER JOIN population pop ON p.county_id = pop.county_id GROUP BY p.county_id;
gretelai_synthetic_text_to_sql
CREATE TABLE user (user_id INT, username VARCHAR(20), posts INT, created_at DATE); INSERT INTO user (user_id, username, posts, created_at) VALUES (1, 'user1', 10, '2022-01-01'), (2, 'user2', 20, '2022-01-02'), (3, 'user3', 30, '2022-01-03'), (4, 'user4', 40, '2022-01-04'), (5, 'user5', 50, '2022-01-05'), (6, 'user6', 6, '2022-01-04'), (7, 'user7', 7, '2022-01-03'), (8, 'user8', 8, '2022-01-02'), (9, 'user9', 9, '2022-01-01'), (10, 'user10', 10, '2022-01-05');
List the top 5 users who have posted the most on Tuesdays in the social_media database.
SELECT user_id, username, SUM(posts) as total_posts FROM user WHERE DATEPART(dw, created_at) = 3 GROUP BY user_id, username ORDER BY total_posts DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE accommodations (id INT, continent VARCHAR(255), eco_certified INT); INSERT INTO accommodations (id, continent, eco_certified) VALUES (1, 'Africa', 1), (2, 'Africa', 1), (3, 'Africa', 1), (4, 'Africa', 0), (5, 'Asia', 1);
Identify the top 3 most eco-certified accommodations in Africa
SELECT continent, SUM(eco_certified) as eco_certified_count FROM accommodations WHERE continent = 'Africa' GROUP BY continent ORDER BY eco_certified_count DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE freshwater_aquaculture (id INT, name TEXT, region TEXT, dissolved_oxygen FLOAT); INSERT INTO freshwater_aquaculture (id, name, region, dissolved_oxygen) VALUES (1, 'Facility G', 'Great Lakes', 8.1), (2, 'Facility H', 'Great Lakes', 7.9), (3, 'Facility I', 'Mississippi River', 7.5);
What is the average dissolved oxygen level in freshwater aquaculture facilities in the Great Lakes region?
SELECT AVG(dissolved_oxygen) FROM freshwater_aquaculture WHERE region = 'Great Lakes';
gretelai_synthetic_text_to_sql
CREATE TABLE eco_accommodations (accom_id INT, accom_name TEXT, location TEXT); INSERT INTO eco_accommodations (accom_id, accom_name, location) VALUES (1, 'Eco Lodge', 'Thailand'), (2, 'Green Villa', 'Indonesia');
What is the total number of eco-friendly accommodations in Thailand and Indonesia?
SELECT COUNT(*) FROM eco_accommodations WHERE location IN ('Thailand', 'Indonesia');
gretelai_synthetic_text_to_sql
CREATE TABLE threat_indicators (id INT, sector TEXT, confidence INT); INSERT INTO threat_indicators (id, sector, confidence) VALUES (1, 'Aviation', 85); INSERT INTO threat_indicators (id, sector, confidence) VALUES (2, 'Aviation', 70); INSERT INTO threat_indicators (id, sector, confidence) VALUES (3, 'Healthcare', 65);
What is the minimum confidence level for threat indicators in the aviation sector globally?
SELECT MIN(confidence) FROM threat_indicators WHERE sector = 'Aviation';
gretelai_synthetic_text_to_sql
CREATE TABLE funding(id INT, project VARCHAR(50), date DATE, amount DECIMAL(10,2)); INSERT INTO funding VALUES (1, 'ProjectA', '2022-04-15', 250000.00), (2, 'ProjectB', '2022-06-30', 350000.00), (3, 'ProjectC', '2022-05-28', 300000.00);
What is the average funding per genetic research project in Q2 2022?
SELECT AVG(amount) FROM funding WHERE date BETWEEN '2022-04-01' AND '2022-06-30';
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name TEXT, country TEXT, industry TEXT, industry_4_0 BOOLEAN); INSERT INTO companies (id, name, country, industry, industry_4_0) VALUES (1, 'ABC Corp', 'Germany', 'Manufacturing', TRUE), (2, 'DEF Corp', 'France', 'Service', FALSE), (3, 'GHI Corp', 'Germany', 'Manufacturing', FALSE);
List the names of all companies in the manufacturing industry that have implemented industry 4.0 technologies.
SELECT name FROM companies WHERE industry = 'Manufacturing' AND industry_4_0 = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE seattle_water_consumption (id INT, date DATE, household_size INT, water_consumption FLOAT); INSERT INTO seattle_water_consumption (id, date, household_size, water_consumption) VALUES (1, '2021-01-01', 4, 1200.0), (2, '2021-01-02', 3, 900.0);
What is the average monthly water consumption per capita in the city of Seattle over the last year?
SELECT AVG(water_consumption / household_size) FROM seattle_water_consumption WHERE date >= DATEADD(year, -1, CURRENT_DATE) AND city = 'Seattle';
gretelai_synthetic_text_to_sql
CREATE TABLE north_american_health_centers (id INT, name VARCHAR(255), patients INT, condition VARCHAR(255)); INSERT INTO north_american_health_centers (id, name, patients, condition) VALUES (1, 'Sunshine Mental Health', 50, 'PTSD'); INSERT INTO north_american_health_centers (id, name, patients, condition) VALUES (2, 'Oceanic Mental Health', 75, 'Depression'); INSERT INTO north_american_health_centers (id, name, patients, condition) VALUES (3, 'Peak Mental Health', 100, 'Anxiety Disorder');
What is the percentage of patients in mental health treatment centers in North America who have been diagnosed with PTSD?
SELECT 100.0 * SUM(CASE WHEN condition = 'PTSD' THEN patients ELSE 0 END) / SUM(patients) FROM north_american_health_centers;
gretelai_synthetic_text_to_sql
CREATE TABLE garment_sales (garment_type VARCHAR(20), country VARCHAR(20), year INT, units_sold INT); INSERT INTO garment_sales (garment_type, country, year, units_sold) VALUES ('hoodie', 'India', 2021, 0), ('jacket', 'India', 2021, 0);
Delete all records related to unsold garments in India in 2021.
DELETE FROM garment_sales WHERE country = 'India' AND year = 2021 AND units_sold = 0;
gretelai_synthetic_text_to_sql
CREATE TABLE Spacecraft (id INT, name VARCHAR(50), manufacturer VARCHAR(50), launch_date DATE); INSERT INTO Spacecraft (id, name, manufacturer, launch_date) VALUES (1, 'Vostok 1', 'Roscosmos', '1961-04-12'), (2, 'Mercury-Redstone 3', 'NASA', '1961-05-05'), (3, 'Sputnik 1', 'Roscosmos', '1957-10-04');
What are the names of all spacecraft that were launched by Roscosmos?
SELECT s.name FROM Spacecraft s WHERE s.manufacturer = 'Roscosmos';
gretelai_synthetic_text_to_sql
CREATE TABLE Workouts (WorkoutID INT, MemberID INT, WorkoutDate DATE, Duration INT); INSERT INTO Workouts (WorkoutID, MemberID, WorkoutDate, Duration) VALUES (1, 3, '2021-01-01', 60), (2, 3, '2021-02-01', 75);
What is the maximum duration of a workout for member 3?
SELECT MAX(Duration) FROM Workouts WHERE MemberID = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Farmers (id INT PRIMARY KEY, name VARCHAR(255), age INT, gender VARCHAR(10), location VARCHAR(255), farmer_id INT); CREATE TABLE Equipment (id INT PRIMARY KEY, type VARCHAR(255), model VARCHAR(255), purchased_date DATE, farmer_id INT, FOREIGN KEY (farmer_id) REFERENCES Farmers(farmer_id));
Which farmers in the US are using outdated tractors?
SELECT Farmers.name, Equipment.type, Equipment.model FROM Farmers INNER JOIN Equipment ON Farmers.farmer_id = Equipment.farmer_id WHERE Farmers.location = 'US' AND Equipment.purchased_date < DATE_SUB(CURRENT_DATE, INTERVAL 10 YEAR) AND Equipment.type = 'tractor';
gretelai_synthetic_text_to_sql
CREATE TABLE farm_info (farm_id INT, farm_name VARCHAR(50), location VARCHAR(50)); CREATE TABLE sensor_data (id INT, sensor_id INT, farm_id INT, install_date DATE); INSERT INTO farm_info (farm_id, farm_name, location) VALUES (1, 'Green Acres', 'USA'); INSERT INTO farm_info (farm_id, farm_name, location) VALUES (2, 'Blue Fields', 'Canada'); INSERT INTO sensor_data (id, sensor_id, farm_id, install_date) VALUES (1, 101, 1, '2020-01-01'); INSERT INTO sensor_data (id, sensor_id, farm_id, install_date) VALUES (2, 102, 1, '2020-03-01'); INSERT INTO sensor_data (id, sensor_id, farm_id, install_date) VALUES (3, 201, 2, '2019-08-01');
List all farms utilizing IoT sensors and the number of sensors used in 2020.
SELECT farm_id, COUNT(DISTINCT sensor_id) as sensor_count FROM sensor_data WHERE YEAR(install_date) = 2020 GROUP BY farm_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Attorneys (id INT, name VARCHAR(50), billing_rate DECIMAL(5,2)); CREATE TABLE Cases (id INT, attorney_id INT, precedent VARCHAR(100)); INSERT INTO Attorneys (id, name, billing_rate) VALUES (1, 'Attorney1', 500.00), (2, 'Attorney2', 600.00), (3, 'Attorney3', 700.00); INSERT INTO Cases (id, attorney_id, precedent) VALUES (1, 1, 'Precedent1'), (2, 1, 'Precedent2'), (3, 2, 'Precedent3'), (4, 3, 'Precedent4');
What are the legal precedents cited in cases handled by the attorney with the highest billing rate?
SELECT Cases.precedent FROM Cases INNER JOIN Attorneys ON Cases.attorney_id = Attorneys.id WHERE Attorneys.billing_rate = (SELECT MAX(billing_rate) FROM Attorneys);
gretelai_synthetic_text_to_sql
CREATE TABLE green_buildings (id INT, name VARCHAR(255), location VARCHAR(255), certification_level VARCHAR(50));
Get the names and certification levels of all the green buildings in the city of Seattle.
SELECT name, certification_level FROM green_buildings WHERE location = 'Seattle';
gretelai_synthetic_text_to_sql
CREATE TABLE labor_cost_canada (cost_id INT, country VARCHAR(50), project_type VARCHAR(50), cost FLOAT); INSERT INTO labor_cost_canada (cost_id, country, project_type, cost) VALUES (1, 'Canada', 'Construction', 20000);
What is the average labor cost for construction projects in Canada?
SELECT AVG(cost) FROM labor_cost_canada WHERE country = 'Canada' AND project_type = 'Construction';
gretelai_synthetic_text_to_sql
CREATE TABLE community_development (id INT, initiative_name VARCHAR(50), number_of_participants INT); INSERT INTO community_development VALUES (1, 'Youth Skills Training', 100), (2, 'Women Empowerment', 120), (3, 'Elderly Care', 80), (4, 'Environmental Conservation', 150), (5, 'Cultural Preservation', 110);
What is the name of the community development initiative with the highest number of participants in the 'community_development' table?;
SELECT initiative_name FROM community_development WHERE number_of_participants = (SELECT MAX(number_of_participants) FROM community_development);
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (id INT PRIMARY KEY, customer_id INT, amount DECIMAL(10,2), transaction_date DATE); INSERT INTO transactions (id, customer_id, amount, transaction_date) VALUES (1, 1, 500.00, '2022-01-01'); INSERT INTO transactions (id, customer_id, amount, transaction_date) VALUES (2, 2, 750.00, '2022-01-02');
List transactions from the last 30 days
SELECT * FROM transactions t WHERE t.transaction_date >= CURDATE() - INTERVAL 30 DAY;
gretelai_synthetic_text_to_sql
CREATE TABLE farmers (id INT, name VARCHAR(255), region VARCHAR(255), training_year INT, training_topic VARCHAR(255));
Insert a new record for a farmer who received training in 'Agroforestry' in the 'Amazon Basin' region in 2022.
INSERT INTO farmers (id, name, region, training_year, training_topic) VALUES (2, 'Marcia Santos', 'Amazon Basin', 2022, 'Agroforestry');
gretelai_synthetic_text_to_sql
CREATE TABLE funding (org_id INT, amount DECIMAL(10,2), funding_date DATE); INSERT INTO funding (org_id, amount, funding_date) VALUES (1, 5000.00, '2020-07-01'), (2, 7000.00, '2020-08-15'), (1, 3000.00, '2020-10-05');
Which organizations received the most funding in Q3 2020?
SELECT org_id, SUM(amount) AS total_funding FROM funding WHERE QUARTER(funding_date) = 3 AND YEAR(funding_date) = 2020 GROUP BY org_id ORDER BY total_funding DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Restaurants (RestaurantID int, RestaurantName varchar(255)); CREATE TABLE MenuItems (MenuID int, MenuName varchar(255), RestaurantID int, IsOrganic bit);
Display the number of organic menu items and the percentage of organic menu items for each restaurant.
SELECT R.RestaurantName, COUNT(MI.MenuID) as OrganicMenuItemCount, (COUNT(MI.MenuID) * 100.0 / (SELECT COUNT(*) FROM MenuItems WHERE RestaurantID = R.RestaurantID)) as OrganicPercentage FROM Restaurants R INNER JOIN MenuItems MI ON R.RestaurantID = MI.RestaurantID WHERE MI.IsOrganic = 1 GROUP BY R.RestaurantID;
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_acidification_arctic (location VARCHAR(255), level FLOAT); INSERT INTO ocean_acidification_arctic (location, level) VALUES ('Arctic Ocean', 8.15);
Determine the average ocean acidification level in the Arctic Ocean.
SELECT AVG(level) FROM ocean_acidification_arctic WHERE location = 'Arctic Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE shipments (shipment_id INT, delivery_time INT, warehouse_id INT, recipient_state VARCHAR(50)); INSERT INTO shipments (shipment_id, delivery_time, warehouse_id, recipient_state) VALUES (1, 3, 2, 'Texas'), (2, 5, 2, 'Texas'), (3, 4, 2, 'California');
What is the average delivery time for shipments to Texas from warehouse 2?
SELECT AVG(delivery_time) FROM shipments WHERE warehouse_id = 2 AND recipient_state = 'Texas';
gretelai_synthetic_text_to_sql
CREATE TABLE Category_Revenue (sale_id INT, sale_date DATE, sale_amount FLOAT, brand_name VARCHAR(50), product_category VARCHAR(50));
What is the percentage of revenue generated from ethical fashion brands in each product category?
SELECT Category_Revenue.product_category, AVG(CASE WHEN Category_Revenue.brand_name IN (SELECT DISTINCT brand_name FROM Ethical_Fashion_Brands) THEN 100 ELSE 0 END) as ethical_brand_percentage FROM Category_Revenue GROUP BY Category_Revenue.product_category;
gretelai_synthetic_text_to_sql
CREATE TABLE Player (PlayerID int, PlayerName varchar(50)); CREATE TABLE Game (GameID int, PlayerID int, RunningDistance decimal(5,2)); INSERT INTO Player (PlayerID, PlayerName) VALUES (1, 'John Doe'), (2, 'Jane Smith'), (3, 'Alex Johnson'); INSERT INTO Game (GameID, PlayerID, RunningDistance) VALUES (1, 1, 5.6), (2, 1, 6.2), (3, 2, 4.8), (4, 2, 5.5), (5, 3, 7.0), (6, 3, 7.3);
What is the average running distance per game for each player?
SELECT p.PlayerName, AVG(g.RunningDistance) AS AvgRunningDistance FROM Player p JOIN Game g ON p.PlayerID = g.PlayerID GROUP BY p.PlayerID, p.PlayerName;
gretelai_synthetic_text_to_sql
CREATE TABLE players (id INT, age INT, game_genre VARCHAR(20), location VARCHAR(20)); INSERT INTO players (id, age, game_genre, location) VALUES (1, 25, 'racing', 'USA'), (2, 30, 'rpg', 'Germany'), (3, 22, 'shooter', 'France'), (4, 35, 'Simulation', 'Nigeria'), (5, 40, 'Simulation', 'Egypt');
What is the average age of players who play games in the 'Simulation' genre in Africa?
SELECT AVG(age) FROM players WHERE game_genre = 'Simulation' AND location LIKE 'Africa%';
gretelai_synthetic_text_to_sql
CREATE TABLE strains (id INT, name VARCHAR(255)); INSERT INTO strains (id, name) VALUES (1, 'Blue Dream'), (2, 'Sour Diesel'); CREATE TABLE prices (id INT, strain_id INT, dispensary_id INT, price DECIMAL(10, 2));
Determine average price difference between Blue Dream and Sour Diesel strains across all dispensaries in Colorado.
SELECT AVG(p1.price - p2.price) as price_difference FROM strains s1 INNER JOIN prices p1 ON s1.id = p1.strain_id INNER JOIN strains s2 ON s2.name = 'Sour Diesel' INNER JOIN prices p2 ON s2.id = p2.strain_id AND p1.dispensary_id = p2.dispensary_id WHERE s1.name = 'Blue Dream';
gretelai_synthetic_text_to_sql
CREATE TABLE MachineProduction (ID INT, MachineID INT, StartTime TIME, EndTime TIME); INSERT INTO MachineProduction (ID, MachineID, StartTime, EndTime) VALUES (1, 501, '06:00:00', '14:00:00'), (2, 502, '08:00:00', '16:00:00'), (3, 501, '10:00:00', '18:00:00'), (4, 503, '07:00:00', '15:00:00');
Calculate the percentage of time each machine was in production during Q3 2020.
SELECT MachineID, SUM(TIMESTAMPDIFF(HOUR, StartTime, EndTime)) / (SELECT SUM(TIMESTAMPDIFF(HOUR, StartTime, EndTime)) FROM MachineProduction WHERE MachineProduction.MachineID = Machines.ID AND MachineProduction.StartTime >= '2020-07-01' AND MachineProduction.StartTime < '2020-10-01') * 100 AS Percentage FROM Machines WHERE MachineID IN (SELECT MachineID FROM MachineProduction WHERE MachineProduction.StartTime >= '2020-07-01' AND MachineProduction.StartTime < '2020-10-01') GROUP BY MachineID;
gretelai_synthetic_text_to_sql
CREATE TABLE patient_outcomes (patient_id INT, condition_id INT, improvement_score INT, follow_up_date DATE); INSERT INTO patient_outcomes (patient_id, condition_id, improvement_score, follow_up_date) VALUES (5, 1, 12, '2022-01-01'); INSERT INTO patient_outcomes (patient_id, condition_id, improvement_score, follow_up_date) VALUES (6, 1, 18, '2022-02-01'); INSERT INTO patient_outcomes (patient_id, condition_id, improvement_score, follow_up_date) VALUES (7, 2, 7, '2022-03-01'); INSERT INTO patient_outcomes (patient_id, condition_id, improvement_score, follow_up_date) VALUES (8, 2, 11, '2022-04-01');
Which is the previous improvement score for each patient at their follow-up date?
SELECT patient_id, condition_id, improvement_score, follow_up_date, LAG(improvement_score) OVER (PARTITION BY patient_id ORDER BY follow_up_date) as previous_score FROM patient_outcomes;
gretelai_synthetic_text_to_sql
CREATE TABLE route (route_id INT, route_name VARCHAR(50)); INSERT INTO route (route_id, route_name) VALUES (1, 'Red Line'), (2, 'Green Line'), (3, 'Blue Line'); CREATE TABLE fare (fare_id INT, route_id INT, fare_amount DECIMAL(5,2), collection_date DATE); INSERT INTO fare (fare_id, route_id, fare_amount, collection_date) VALUES (1, 1, 3.50, '2022-06-01'), (2, 1, 3.25, '2022-06-03'), (3, 2, 3.50, '2022-06-05'), (4, 2, 3.25, '2022-06-07'), (5, 3, 3.50, '2022-06-09'), (6, 3, 3.25, '2022-06-11');
List all routes with fare collections on weekends.
SELECT route_name FROM route JOIN fare ON route.route_id = fare.route_id WHERE DATEPART(dw, collection_date) IN (1, 7);
gretelai_synthetic_text_to_sql
CREATE TABLE policy_info (policy_id INT, premium FLOAT, sum_insured INT); INSERT INTO policy_info (policy_id, premium, sum_insured) VALUES (1, 1200.50, 60000), (2, 2500.00, 70000), (3, 1800.00, 90000);
What is the minimum premium for policies with sum insured less than 60000?
SELECT MIN(premium) FROM policy_info WHERE sum_insured < 60000;
gretelai_synthetic_text_to_sql
CREATE TABLE Events (EventID INT, EventType VARCHAR(50), StartDate DATE, EndDate DATE); INSERT INTO Events (EventID, EventType, StartDate, EndDate) VALUES (1, 'Dance Performance', '2022-04-01', '2022-04-03'), (2, 'Theater Performance', '2022-01-01', '2022-01-31'); CREATE TABLE Tickets (TicketID INT, EventID INT, Quantity INT); INSERT INTO Tickets (TicketID, EventID, Quantity) VALUES (1, 1, 100), (2, 2, 200);
What was the total number of tickets sold for theater performances in Q1 2022?
SELECT SUM(Quantity) FROM Events INNER JOIN Tickets ON Events.EventID = Tickets.EventID WHERE Events.EventType = 'Theater Performance' AND QUARTER(StartDate) = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists autonomous_ridesharing (ride_id INT, driver_id INT, passenger_id INT, start_time TIMESTAMP, end_time TIMESTAMP, vehicle_type VARCHAR(255), is_autonomous BOOLEAN);
What is the total number of rides taken in autonomous ridesharing services?
SELECT COUNT(*) as total_autonomous_rides FROM autonomous_ridesharing WHERE is_autonomous = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE state_services (state VARCHAR(20), service VARCHAR(20), budget INT); INSERT INTO state_services (state, service, budget) VALUES ('Illinois', 'Public Transportation', 8000000);
What is the minimum budget allocated for public transportation in the state of Illinois?
SELECT MIN(budget) FROM state_services WHERE state = 'Illinois' AND service = 'Public Transportation';
gretelai_synthetic_text_to_sql
CREATE TABLE Equipment_Origin (Equipment_Type VARCHAR(255), Country_Of_Origin VARCHAR(255), Equipment_Value INT); INSERT INTO Equipment_Origin (Equipment_Type, Country_Of_Origin, Equipment_Value) VALUES ('Aircraft', 'USA', 5000000), ('Vehicles', 'Canada', 3000000), ('Naval', 'Mexico', 4000000), ('Weaponry', 'Brazil', 6000000), ('Aircraft', 'USA', 7000000), ('Vehicles', 'Canada', 8000000), ('Naval', 'Mexico', 9000000), ('Weaponry', 'Brazil', 10000000);
What is the total value of military equipment by country of origin, ranked by total value in descending order?
SELECT Country_Of_Origin, SUM(Equipment_Value) as Total_Equipment_Value FROM Equipment_Origin GROUP BY Country_Of_Origin ORDER BY Total_Equipment_Value DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE garment_production (id INT, country VARCHAR(50), material VARCHAR(50), quantity INT); INSERT INTO garment_production (id, country, material, quantity) VALUES (1, 'India', 'Cotton', 5000), (2, 'Bangladesh', 'Polyester', 4000), (3, 'China', 'Viscose', 6000);
Show the distribution of garment production by material and country.
SELECT country, material, SUM(quantity) as total_quantity FROM garment_production GROUP BY country, material;
gretelai_synthetic_text_to_sql
CREATE TABLE gulf_of_mexico (id INT, well_name VARCHAR(255), drill_date DATE, daily_production_gas FLOAT);
What is the total number of wells drilled in the Gulf of Mexico between 2017 and 2020, and what is the sum of their daily production rates of gas?
SELECT COUNT(*) as total_wells, SUM(daily_production_gas) as total_daily_production_gas FROM gulf_of_mexico WHERE drill_date BETWEEN '2017-01-01' AND '2020-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers (supplier_id INT, supplier_name VARCHAR(50), country VARCHAR(50), orders INT);
Find the top 3 suppliers in the US by the number of orders in 2021?
SELECT supplier_name, COUNT(orders) FROM suppliers WHERE country = 'USA' AND EXTRACT(YEAR FROM order_date) = 2021 GROUP BY supplier_name ORDER BY COUNT(orders) DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Animals (name VARCHAR(50), species VARCHAR(50), location VARCHAR(50)); INSERT INTO Animals (name, species, location) VALUES ('Polar Bear 1', 'Polar Bear', 'Svalbard Wildlife Reserve'), ('Polar Bear 2', 'Polar Bear', 'Svalbard Wildlife Reserve'), ('Reindeer 1', 'Reindeer', 'Svalbard Wildlife Reserve'); CREATE TABLE Reserves (name VARCHAR(50), location VARCHAR(50)); INSERT INTO Reserves (name, location) VALUES ('Svalbard Wildlife Reserve', 'Svalbard');
List the names and species of all animals in the Svalbard Wildlife Reserve.
SELECT name, species FROM Animals INNER JOIN Reserves ON TRUE WHERE Animals.location = Reserves.location AND Reserves.name = 'Svalbard Wildlife Reserve';
gretelai_synthetic_text_to_sql
CREATE TABLE community_policing (id INT, precinct VARCHAR(20), year INT, events INT);
How many community policing events were held in 'Precinct 5' last year?
SELECT SUM(events) FROM community_policing WHERE precinct = 'Precinct 5' AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (volunteer_id INT, volunteer_name TEXT, volunteer_region TEXT, volunteer_join_date DATE); INSERT INTO volunteers (volunteer_id, volunteer_name, volunteer_region, volunteer_join_date) VALUES (1, 'Alice Doe', 'Africa', '2018-01-01');
Calculate the number of volunteers who joined in H1 2018 from 'Africa' and 'South America'?
SELECT COUNT(*) FROM volunteers WHERE EXTRACT(QUARTER FROM volunteer_join_date) IN (1, 2) AND volunteer_region IN ('Africa', 'South America');
gretelai_synthetic_text_to_sql
CREATE VIEW fan_demographics_v AS SELECT fan_id, age, gender, city, state, country FROM fan_data; CREATE TABLE fan_data (fan_id INT, age INT, gender VARCHAR(10), city VARCHAR(50), state VARCHAR(20), country VARCHAR(50)); INSERT INTO fan_data (fan_id, age, gender, city, state, country) VALUES (1, 22, 'Male', 'New York', 'NY', 'USA'); INSERT INTO fan_data (fan_id, age, gender, city, state, country) VALUES (2, 28, 'Female', 'Los Angeles', 'CA', 'USA');
Show the top 3 cities with the most fans in 'fan_demographics_v'
SELECT city, COUNT(*) AS fan_count FROM fan_demographics_v GROUP BY city ORDER BY fan_count DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE therapy_patients (patient_id INT, gender VARCHAR(6), therapy_type VARCHAR(10), state VARCHAR(20), year INT); INSERT INTO therapy_patients VALUES (1, 'Male', 'CBT', 'New York', 2022), (2, 'Female', 'DBT', 'New York', 2022), (3, 'Male', 'CBT', 'New York', 2022);
What is the number of male and female patients who received therapy in New York in 2022?
SELECT gender, COUNT(*) FROM therapy_patients WHERE therapy_type IN ('CBT', 'DBT') AND state = 'New York' AND year = 2022 GROUP BY gender;
gretelai_synthetic_text_to_sql
CREATE TABLE rural_clinics (clinic_id INT, clinic_name VARCHAR(50), state VARCHAR(2), num_hospital_beds INT); INSERT INTO rural_clinics (clinic_id, clinic_name, state, num_hospital_beds) VALUES (1, 'Rural Clinic A', 'TX', 15), (2, 'Rural Clinic B', 'TX', 20), (3, 'Rural Clinic C', 'CA', 10), (4, 'Rural Clinic D', 'CA', 12);
What is the average number of hospital beds per rural clinic in Texas and California?
SELECT state, AVG(num_hospital_beds) as avg_hospital_beds FROM rural_clinics WHERE state IN ('TX', 'CA') GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE ExcavationSites (SiteID INT PRIMARY KEY, SiteName VARCHAR(255), Country VARCHAR(255), StartDate DATE, EndDate DATE); CREATE TABLE Artifacts (ArtifactID INT PRIMARY KEY, SiteID INT, ArtifactName VARCHAR(255), Description TEXT, Material VARCHAR(255), DateFound DATE); CREATE VIEW ExcavationArtifacts AS SELECT ES.SiteName, A.ArtifactName, A.Material, A.DateFound FROM ExcavationSites ES INNER JOIN Artifacts A ON ES.SiteID = A.SiteID;
Create a view that joins excavation sites and artifacts
CREATE VIEW ExcavationArtifacts AS SELECT ES.SiteName, A.ArtifactName, A.Material, A.DateFound FROM ExcavationSites ES INNER JOIN Artifacts A ON ES.SiteID = A.SiteID;
gretelai_synthetic_text_to_sql
CREATE TABLE wellbeing_scores (customer_id INT, score INT, score_date DATE);
Compute the 12-month rolling average financial wellbeing score.
SELECT customer_id, AVG(score) OVER (PARTITION BY customer_id ORDER BY score_date ROWS BETWEEN 11 PRECEDING AND CURRENT ROW) AS rolling_avg FROM wellbeing_scores;
gretelai_synthetic_text_to_sql
CREATE TABLE posts (post_id INT, user_id INT, post_date DATE, likes INT, hashtags VARCHAR(255), region VARCHAR(255)); INSERT INTO posts (post_id, user_id, post_date, likes, hashtags, region) VALUES (1, 1, '2021-06-01', 100, '#travel', 'North America');
What is the maximum number of likes received by posts with the hashtag '#travel' in the 'North America' region for the month of June 2021?
SELECT MAX(likes) FROM posts WHERE hashtags LIKE '%#travel%' AND region = 'North America' AND post_date >= '2021-06-01' AND post_date < '2021-07-01';
gretelai_synthetic_text_to_sql
CREATE TABLE restaurant_revenue (restaurant_id INT, revenue INT); INSERT INTO restaurant_revenue (restaurant_id, revenue) VALUES (1, 1200), (2, 1500), (3, 800), (4, 2000), (5, 1700);
Find the difference in revenue between restaurants 1 and 2. Display the result as a single value.
SELECT ABS(SUM(r1.revenue) - SUM(r2.revenue)) as revenue_difference FROM restaurant_revenue r1, restaurant_revenue r2 WHERE r1.restaurant_id = 1 AND r2.restaurant_id = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE sites (site_id INT, site_name VARCHAR(100), state VARCHAR(50)); INSERT INTO sites (site_id, site_name, state) VALUES (1, 'Golden Mining Site', 'California'); INSERT INTO sites (site_id, site_name, state) VALUES (2, 'Silver Peak Mine', 'Nevada'); INSERT INTO sites (site_id, site_name, state) VALUES (3, 'Colorado Mine', 'Colorado'); CREATE TABLE employees (employee_id INT, employee_name VARCHAR(100), site_id INT); INSERT INTO employees (employee_id, employee_name, site_id) VALUES (1, 'John Doe', 1); INSERT INTO employees (employee_id, employee_name, site_id) VALUES (2, 'Jane Smith', 1); INSERT INTO employees (employee_id, employee_name, site_id) VALUES (3, 'Robert Johnson', 2); INSERT INTO employees (employee_id, employee_name, site_id) VALUES (4, 'Maria Garcia', 3); INSERT INTO employees (employee_id, employee_name, site_id) VALUES (5, 'Jose Hernandez', 3);
How many employees are working on each mining site in Colorado?
SELECT sites.site_name, COUNT(employees.employee_id) as total_employees FROM sites LEFT JOIN employees ON sites.site_id = employees.site_id WHERE sites.state = 'Colorado' GROUP BY sites.site_name;
gretelai_synthetic_text_to_sql
CREATE TABLE hotel_tech (hotel_id INT, hotel_name VARCHAR(255), city VARCHAR(255), country VARCHAR(255), has_ai_chatbot BOOLEAN); INSERT INTO hotel_tech (hotel_id, hotel_name, city, country, has_ai_chatbot) VALUES (1, 'Hotel Grande', 'Tokyo', 'Japan', true), (2, 'Hotel Matsumoto', 'Tokyo', 'Japan', false);
How many hotels have adopted AI-powered chatbots in Tokyo, Japan?
SELECT COUNT(*) FROM hotel_tech WHERE city = 'Tokyo' AND country = 'Japan' AND has_ai_chatbot = true;
gretelai_synthetic_text_to_sql
CREATE TABLE concerts (concert_id INT, concert_country VARCHAR(50), tickets_sold INT); INSERT INTO concerts (concert_id, concert_country, tickets_sold) VALUES (1, 'France', 500), (2, 'Germany', 800), (3, 'United States', 1500);
What is the percentage of concert ticket sales in Europe out of the total sales worldwide?
SELECT (SUM(CASE WHEN concert_country = 'Europe' THEN tickets_sold ELSE 0 END) / SUM(tickets_sold)) * 100 AS percentage FROM concerts;
gretelai_synthetic_text_to_sql
CREATE TABLE AutonomousResearch (Year INT, Data VARCHAR(255)); INSERT INTO AutonomousResearch (Year, Data) VALUES (2018, 'Data 1'), (2019, 'Data 2'), (2020, 'Data 3'), (2021, 'Data 4');
Find the autonomous driving research data from 2020.
SELECT Data FROM AutonomousResearch WHERE Year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE ai_safety_violations_types (violation_id INT PRIMARY KEY, violation_type VARCHAR(255), region VARCHAR(255));
What is the distribution of AI safety violations by type in South America?
SELECT violation_type, COUNT(*) AS violation_count FROM ai_safety_violations_types WHERE region = 'South America' GROUP BY violation_type;
gretelai_synthetic_text_to_sql
CREATE TABLE tourism_stats (country VARCHAR(255), year INT, tourism_type VARCHAR(255), daily_expenditure DECIMAL(10, 2)); INSERT INTO tourism_stats (country, year, tourism_type, daily_expenditure) VALUES ('New Zealand', 2020, 'Adventure', 150.00), ('New Zealand', 2020, 'Adventure', 160.00), ('New Zealand', 2020, 'Adventure', 170.00);
What was the average expenditure per day for adventure tourists in New Zealand in 2020?
SELECT AVG(daily_expenditure) AS avg_daily_expenditure FROM tourism_stats WHERE country = 'New Zealand' AND year = 2020 AND tourism_type = 'Adventure';
gretelai_synthetic_text_to_sql
CREATE TABLE Supplier (SupplierID INT, SupplierName VARCHAR(50), FarmID INT); INSERT INTO Supplier (SupplierID, SupplierName, FarmID) VALUES (1, 'Farm Fresh', 2), (2, 'Green Fields', 3);
Non-sustainable food items by supplier
SELECT s.SupplierName, f.ItemName FROM Supplier s INNER JOIN FoodItem f ON s.FarmID = f.FarmID WHERE f.IsSustainable = FALSE;
gretelai_synthetic_text_to_sql
CREATE TABLE south_africa_dysprosium (id INT, year INT, amount INT); INSERT INTO south_africa_dysprosium (id, year, amount) VALUES (1, 2014, 2000), (2, 2015, 2500), (3, 2016, 3000), (4, 2017, 3500), (5, 2018, 4000);
What is the total amount of dysprosium produced in South Africa between 2015 and 2017?
SELECT SUM(amount) FROM south_africa_dysprosium WHERE year BETWEEN 2015 AND 2017;
gretelai_synthetic_text_to_sql
CREATE TABLE bridges (id INT, bridge_name VARCHAR(255), built_year INT, state VARCHAR(255)); INSERT INTO bridges (id, bridge_name, built_year, state) VALUES (1, 'Brooklyn Bridge', 1883, 'New York'), (2, 'Golden Gate Bridge', 1937, 'California'), (3, 'Ford Rouge Bridge', 1932, 'Michigan'), (4, 'Boston University Bridge', 1928, 'Massachusetts'), (5, 'Cape Cod Canal Railroad Bridge', 1935, 'Massachusetts'), (6, 'Hell Gate Bridge', 1916, 'New York'), (7, 'Ambassador Bridge', 1929, 'Michigan');
What are the top 3 states with the highest number of bridges built before 1950?
SELECT state, COUNT(*) as bridge_count FROM bridges WHERE built_year < 1950 GROUP BY state ORDER BY bridge_count DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE PRODUCT ( id INT PRIMARY KEY, name TEXT, material TEXT, quantity INT, price INT, country TEXT, certifications TEXT, is_recycled BOOLEAN );
Insert a new product made from recycled polyester with a quantity of 15 and a price of 50.
INSERT INTO PRODUCT (name, material, quantity, price, country, certifications, is_recycled) VALUES ('Recycled Polyester Jacket', 'Recycled Polyester', 15, 50, 'Canada', 'BlueSign', TRUE);
gretelai_synthetic_text_to_sql
CREATE TABLE art_pieces (id INT, title TEXT, artist_name TEXT, medium TEXT, region TEXT); INSERT INTO art_pieces (id, title, artist_name, medium, region) VALUES (1, 'African Mask', 'Unknown', 'sculpture', 'Africa');
How many art pieces were created by artists from Africa in the 'sculpture' medium?
SELECT COUNT(*) FROM art_pieces WHERE medium = 'sculpture' AND region = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name VARCHAR(255), certification VARCHAR(255), price DECIMAL(10,2), quantity INT);INSERT INTO products VALUES (1,'Product A','vegan',10,10),(2,'Product B','organic',15,20),(3,'Product C','organic',20,30),(4,'Product D','vegan',25,40),(5,'Product E','vegan, organic',30,50);
What is the total revenue of products that are 'vegan' and 'organic' certified?
SELECT SUM(price * quantity) FROM products WHERE certification IN ('vegan', 'organic') GROUP BY certification HAVING COUNT(DISTINCT certification) = 2
gretelai_synthetic_text_to_sql
CREATE TABLE real_estate(id INT, city VARCHAR(50), price DECIMAL(10,2), size INT); INSERT INTO real_estate VALUES (1, 'Portland', 350000, 1500);
What is the average co-ownership price per square foot in the city of Portland, OR?
SELECT AVG(price/size) FROM real_estate WHERE city = 'Portland';
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT, song_id INT, price FLOAT, release_year INT); INSERT INTO sales (id, song_id, price, release_year) VALUES (1, 1, 1.2, 2021), (2, 2, 0.9, 2021), (3, 3, 1.5, 2021), (4, 4, 0.8, 2020), (5, 5, 1.3, 2021);
What is the total revenue generated from sales of songs released in 2021?
SELECT SUM(price) FROM sales WHERE release_year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE certifications(certification_id INT, certification_name TEXT); INSERT INTO certifications(certification_id, certification_name) VALUES (1, 'Fair Trade'), (2, 'SA8000'), (3, 'SEDEX'); CREATE TABLE suppliers(supplier_id INT, supplier_name TEXT, country TEXT); INSERT INTO suppliers(supplier_id, supplier_name, country) VALUES (1, 'Ethical Fabrics Germany', 'Germany'); CREATE TABLE supplier_certifications(supplier_id INT, certification_id INT); INSERT INTO supplier_certifications(supplier_id, certification_id) VALUES (1, 2), (1, 3);
Which ethical labor practice certifications are held by suppliers in Germany?
SELECT DISTINCT suppliers.country, certifications.certification_name FROM suppliers JOIN supplier_certifications ON suppliers.supplier_id = supplier_certifications.supplier_id JOIN certifications ON supplier_certifications.certification_id = certifications.certification_id WHERE suppliers.country = 'Germany';
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists asia; USE asia; CREATE TABLE if not exists military_bases (id INT, name VARCHAR(255), type VARCHAR(255), location VARCHAR(255)); INSERT INTO military_bases (id, name, type, location) VALUES (1, 'Yokota Air Base', 'Air Force Base', 'Japan'), (2, 'Camp Humphreys', 'Army Base', 'South Korea'), (3, 'INDRA Base', 'Air Force Base', 'India');
Show me the names and locations of all military bases located in 'asia' schema
SELECT name, location FROM asia.military_bases;
gretelai_synthetic_text_to_sql
CREATE TABLE ArtistTicketSales (artist VARCHAR(255), year INT, sales INT);
What was the total number of concert ticket sales for artist 'X'?
SELECT SUM(sales) FROM ArtistTicketSales WHERE artist = 'X';
gretelai_synthetic_text_to_sql
CREATE TABLE WasteGeneration (Date date, Location text, Material text, Quantity integer);CREATE TABLE LandfillCapacity (Location text, Capacity integer);
What is the total waste quantity generated per location and material, and the total landfill capacity for each location, for the year 2020?
SELECT wg.Location, wg.Material, SUM(wg.Quantity) as TotalWasteQuantity, lc.Capacity as TotalLandfillCapacity FROM WasteGeneration wg JOIN LandfillCapacity lc ON wg.Location = lc.Location WHERE wg.Date >= '2020-01-01' AND wg.Date < '2021-01-01' GROUP BY wg.Location, wg.Material, lc.Capacity;
gretelai_synthetic_text_to_sql
CREATE TABLE accommodations (id INT, name TEXT, continent TEXT, type TEXT, visitors INT); INSERT INTO accommodations (id, name, continent, type, visitors) VALUES (1, 'Eco Lodge', 'South America', 'Eco-friendly', 2500), (2, 'Green Hotel', 'South America', 'Eco-friendly', 3000);
What is the maximum number of visitors to eco-friendly accommodations in South America?
SELECT MAX(visitors) FROM accommodations WHERE continent = 'South America' AND type = 'Eco-friendly';
gretelai_synthetic_text_to_sql
CREATE TABLE public.criminal_justice (id serial PRIMARY KEY, name text, type text, budget integer, year integer); INSERT INTO public.criminal_justice (name, type, budget, year) VALUES ('Prison System', 'Corrections', 85000000, 2020), ('Police Department', 'Law Enforcement', 150000000, 2018);
What was the total budget for criminal justice systems before 2018?
SELECT name, type, budget, year, (SELECT SUM(budget) FROM public.criminal_justice cj2 WHERE cj2.year < cj.year AND cj2.id <> cj.id) as total_budget_before FROM public.criminal_justice cj WHERE year < 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE ships (name VARCHAR(255), year_decommissioned INT, type VARCHAR(255));
Insert a new record into the Ships table for a ship named 'Sea Explorer' that was decommissioned in 2010.
INSERT INTO ships (name, year_decommissioned, type) VALUES ('Sea Explorer', 2010, 'Exploration');
gretelai_synthetic_text_to_sql
CREATE TABLE Workouts (studio VARCHAR(50), workout VARCHAR(50)); INSERT INTO Workouts (studio, workout) VALUES ('Boston', 'Yoga'), ('Boston', 'Pilates'), ('Seattle', 'Cycling'), ('Seattle', 'Yoga');
List the unique types of workouts offered in the 'Boston' and 'Seattle' studios.
SELECT DISTINCT workout FROM Workouts WHERE studio IN ('Boston', 'Seattle');
gretelai_synthetic_text_to_sql
CREATE TABLE players (player_id INT, name VARCHAR(100), game VARCHAR(50));
Update the player's name in the players table
UPDATE players SET name = 'NewPlayerName' WHERE player_id = 1;
gretelai_synthetic_text_to_sql