context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE Warehouses(id INT, location VARCHAR(50), capacity INT); INSERT INTO Warehouses(id, location, capacity) VALUES (1, 'Canada', 1000); CREATE TABLE Inventory(id INT, warehouse_id INT, quantity INT); INSERT INTO Inventory(id, warehouse_id, quantity) VALUES (1, 1, 500);
List all warehouses in Canada and the total quantity of items stored in each.
SELECT Warehouses.location, SUM(Inventory.quantity) FROM Warehouses INNER JOIN Inventory ON Warehouses.id = Inventory.warehouse_id WHERE Warehouses.location = 'Canada' GROUP BY Warehouses.id;
gretelai_synthetic_text_to_sql
CREATE TABLE geopolitical_risks(id INT, region VARCHAR(50), quarter INT, year INT, score FLOAT); INSERT INTO geopolitical_risks(id, region, quarter, year, score) VALUES (1, 'Asia-Pacific', 1, 2022, 4.5); INSERT INTO geopolitical_risks(id, region, quarter, year, score) VALUES (2, 'Asia-Pacific', 2, 2022, 5.0);
Calculate the average geopolitical risk score for the Asia-Pacific region in Q2 2022.
SELECT AVG(score) FROM geopolitical_risks WHERE region = 'Asia-Pacific' AND quarter = 2 AND year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE diplomacy_staff (staff_id INT, name VARCHAR(255), position VARCHAR(255), salary INT); INSERT INTO diplomacy_staff (staff_id, name, position, salary) VALUES (1, 'John Doe', 'Ambassador', 75000), (2, 'Jane Smith', 'Consul', 50000), (3, 'Michael Johnson', 'Diplomatic Attaché', 60000);
Update diplomacy staff salaries to be 5% higher than their current amount.
UPDATE diplomacy_staff SET salary = salary * 1.05;
gretelai_synthetic_text_to_sql
CREATE TABLE wells (well_id INT, well_name VARCHAR(255), well_depth FLOAT, region VARCHAR(255)); INSERT INTO wells (well_id, well_name, well_depth, region) VALUES (1, 'A1', 3000, 'North Sea'), (2, 'B2', 2500, 'North Sea'), (3, 'C3', 4000, 'Gulf of Mexico');
What is the average well depth for wells in the 'North Sea' region?
SELECT AVG(well_depth) FROM wells WHERE region = 'North Sea';
gretelai_synthetic_text_to_sql
CREATE TABLE unions (id INT, name TEXT, location TEXT, type TEXT, safety_score INT); INSERT INTO unions (id, name, location, type, safety_score) VALUES (1, 'Union A', 'Germany', 'Manufacturing', 85), (2, 'Union B', 'France', 'Manufacturing', 80);
What is the average workplace safety score for manufacturing unions in Germany?
SELECT AVG(safety_score) FROM unions WHERE location = 'Germany' AND type = 'Manufacturing';
gretelai_synthetic_text_to_sql
CREATE TABLE school_districts (district_id INT, district_name TEXT, num_students INT);
What is the total number of students in each school district?
SELECT district_name, SUM(num_students) as total_students FROM school_districts GROUP BY district_name;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_mitigation (id INT, initiative_name VARCHAR(50), location VARCHAR(50), allocated_funding FLOAT, funding_year INT); INSERT INTO climate_mitigation (id, initiative_name, location, allocated_funding, funding_year) VALUES (1, 'Green Media Campaign', 'Europe', 500000, 2022);
What is the total funding allocated for climate communication initiatives in Europe in 2022?
SELECT SUM(allocated_funding) FROM climate_mitigation WHERE location = 'Europe' AND funding_year = 2022 AND initiative_name LIKE '%climate communication%';
gretelai_synthetic_text_to_sql
CREATE TABLE AlbumStreams (AlbumID int, SongID int, StreamCount int, ArtistID int); INSERT INTO AlbumStreams (AlbumID, SongID, StreamCount, ArtistID) VALUES (1, 1, 1000, 1), (2, 2, 2000, 2), (3, 3, 1500, 3), (4, 4, 2500, 4), (5, 5, 1800, 5);
What is the percentage of total streams for each artist?
SELECT Artists.ArtistName, (SUM(AlbumStreams.StreamCount) / (SELECT SUM(StreamCount) FROM AlbumStreams) * 100) as Percentage FROM Artists INNER JOIN AlbumStreams ON Artists.ArtistID = AlbumStreams.ArtistID GROUP BY Artists.ArtistName;
gretelai_synthetic_text_to_sql
CREATE TABLE regions (id INT, name TEXT); INSERT INTO regions (id, name) VALUES (1, 'North America'), (2, 'South America'), (3, 'Europe'), (4, 'Asia'), (5, 'Africa'); CREATE TABLE products (id INT, name TEXT, is_fair_trade BOOLEAN); INSERT INTO products (id, name, is_fair_trade) VALUES (1, 'Product X', true), (2, 'Product Y', false), (3, 'Product Z', true), (4, 'Product W', false); CREATE TABLE sales (id INT, product TEXT, quantity INT, region TEXT); INSERT INTO sales (id, product, quantity, region) VALUES (1, 'Product X', 100, 'South America'), (2, 'Product Y', 150, 'North America'), (3, 'Product Z', 80, 'Europe'), (4, 'Product W', 120, 'Asia');
What is the total quantity of fair trade products sold in South America?
SELECT SUM(sales.quantity) FROM sales INNER JOIN regions ON sales.region = regions.name INNER JOIN products ON sales.product = products.name WHERE products.is_fair_trade = true AND regions.name = 'South America';
gretelai_synthetic_text_to_sql
CREATE TABLE Maintenance_Requests (Equipment VARCHAR(50), Request_Month DATE, Quantity INT); INSERT INTO Maintenance_Requests (Equipment, Request_Month, Quantity) VALUES ('F-16', '2022-01-01', 3), ('F-35', '2022-01-01', 5), ('A-10', '2022-01-01', 2), ('F-16', '2022-02-01', 4), ('F-35', '2022-02-01', 6), ('A-10', '2022-02-01', 1);
Rank military equipment maintenance requests by the number of requests per month in descending order.
SELECT Equipment, ROW_NUMBER() OVER (ORDER BY SUM(Quantity) DESC) as Rank FROM Maintenance_Requests GROUP BY Equipment;
gretelai_synthetic_text_to_sql
CREATE TABLE Neighborhoods (NeighborhoodID INT, NeighborhoodName VARCHAR(255)); CREATE TABLE PropertyTaxRates (PropertyTaxRateID INT, NeighborhoodID INT, Rate DECIMAL(5,2));
What is the maximum property tax rate for properties in each neighborhood?
SELECT N.NeighborhoodName, MAX(PTR.Rate) as MaxRate FROM Neighborhoods N JOIN PropertyTaxRates PTR ON N.NeighborhoodID = PTR.NeighborhoodID GROUP BY N.NeighborhoodName;
gretelai_synthetic_text_to_sql
CREATE SCHEMA fitness; CREATE TABLE memberships (id INT, member_name VARCHAR(50), region VARCHAR(50), membership_type VARCHAR(50), price DECIMAL(5,2), start_date DATE, end_date DATE); INSERT INTO memberships (id, member_name, region, membership_type, price, start_date, end_date) VALUES (1, 'John Doe', 'Midwest', 'Premium', 79.99, '2022-01-01', '2022-12-31');
What is the total revenue generated from 'Premium' memberships in the 'Midwest' region for the year 2022?
SELECT SUM(price) FROM fitness.memberships WHERE region = 'Midwest' AND membership_type = 'Premium' AND YEAR(start_date) = 2022 AND YEAR(end_date) = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE comments (id INT, post_id INT, user_id INT, text TEXT, created_date DATE); INSERT INTO comments (id, post_id, user_id, text, created_date) VALUES (1, 1, 6, 'Great article!', '2022-07-01'), (2, 2, 6, 'Thank you for sharing.', '2022-08-15');
Delete all comments made by a user from France before 2022-08-01.
DELETE FROM comments WHERE user_id IN (SELECT user_id FROM comments WHERE country = 'France') AND created_date < '2022-08-01'
gretelai_synthetic_text_to_sql
CREATE TABLE Property (id INT PRIMARY KEY, address VARCHAR(255), city VARCHAR(255), state VARCHAR(255), zip INT, co_owners INT, sustainable_features VARCHAR(255), price INT); CREATE TABLE InclusiveHousing (id INT PRIMARY KEY, property_id INT, policy_type VARCHAR(255), start_date DATE, end_date DATE);
Delete properties with inclusive housing policies that have expired over a year ago.
DELETE FROM Property WHERE id IN (SELECT Property.id FROM Property INNER JOIN InclusiveHousing ON Property.id = InclusiveHousing.property_id WHERE end_date < DATE_SUB(CURDATE(), INTERVAL 1 YEAR));
gretelai_synthetic_text_to_sql
CREATE TABLE production (country VARCHAR(255), element VARCHAR(255), quantity INT, year INT); INSERT INTO production (country, element, quantity, year) VALUES ('China', 'Lutetium', 2000, 2019), ('China', 'Lutetium', 2500, 2019), ('India', 'Lutetium', 1000, 2019), ('India', 'Lutetium', 1200, 2019);
What is the average production of Lutetium per country in 2019?
SELECT country, AVG(quantity) as avg_production FROM production WHERE element = 'Lutetium' AND year = 2019 GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE patients_treatments (patient_id INT, treatment VARCHAR(20)); INSERT INTO patients_treatments (patient_id, treatment) VALUES (1, 'therapy');
Find the percentage of patients who received therapy
SELECT (COUNT(CASE WHEN treatment = 'therapy' THEN 1 END) * 100.0 / COUNT(*)) AS therapy_percentage FROM patients_treatments;
gretelai_synthetic_text_to_sql
CREATE TABLE CommunityEvents (event_id INT, event_name VARCHAR(20), event_type VARCHAR(10), event_status VARCHAR(10)); CREATE TABLE EventDates (event_id INT, event_date DATE);
Delete records of community engagement events that have been cancelled or do not have a specified event type.
DELETE FROM CommunityEvents WHERE event_status = 'Cancelled' OR event_type IS NULL; DELETE FROM EventDates WHERE event_id NOT IN (SELECT event_id FROM CommunityEvents);
gretelai_synthetic_text_to_sql
CREATE TABLE advisories (country VARCHAR(255), issue_date DATE); INSERT INTO advisories (country, issue_date) VALUES ('Brazil', '2022-05-12'), ('Brazil', '2022-03-28');
Number of travel advisories issued for Brazil in the past 6 months
SELECT COUNT(*) FROM advisories WHERE country = 'Brazil' AND issue_date >= DATEADD(month, -6, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE bookings (id INT, hotel_id INT, tourist_id INT, cost FLOAT, date DATE); CREATE TABLE hotels (id INT, name TEXT, location TEXT, country TEXT, sustainable BOOLEAN); INSERT INTO bookings (id, hotel_id, tourist_id, cost, date) VALUES (1, 1, 101, 100.00, '2022-02-01'), (2, 2, 102, 120.00, '2022-02-10'); INSERT INTO hotels (id, name, location, country, sustainable) VALUES (1, 'Eco Hotel Lisbon', 'Lisbon', 'Portugal', true), (2, 'Green Hotel Porto', 'Porto', 'Portugal', true);
What is the revenue generated by each sustainable hotel in Portugal last month?
SELECT hotel_id, SUM(cost) FROM bookings INNER JOIN hotels ON bookings.hotel_id = hotels.id WHERE country = 'Portugal' AND sustainable = true AND date >= DATEADD(day, -30, GETDATE()) GROUP BY hotel_id;
gretelai_synthetic_text_to_sql
CREATE TABLE space_events (id INT PRIMARY KEY, name VARCHAR(50), year INT); INSERT INTO space_events (id, name, year) VALUES (1, 'First Satellite Launched', 1957), (2, 'First Human in Space', 1961), (3, 'First Spacewalk', 1965), (4, 'First Space Station', 1971), (5, 'First Image of a Black Hole', 2019);
Delete all records from the 'space_events' table that occurred before the year 2000
DELETE FROM space_events WHERE year < 2000;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (day VARCHAR(255), sales DECIMAL(10,2)); INSERT INTO sales (day, sales) VALUES ('Monday', 1500), ('Tuesday', 1700), ('Wednesday', 1200), ('Thursday', 2000), ('Friday', 2500), ('Saturday', 3000), ('Sunday', 1800);
Calculate the total sales for each day of the week
SELECT day, SUM(sales) as total_sales FROM sales GROUP BY day;
gretelai_synthetic_text_to_sql
CREATE TABLE military_spending (country TEXT, year INT, amount INT); INSERT INTO military_spending (country, year, amount) VALUES ('Germany', 2018, 45000000);
What is the average annual military spending by 'Germany' in the last 5 years?
SELECT AVG(amount) AS avg_annual_spending FROM military_spending WHERE country = 'Germany' AND year BETWEEN YEAR(DATE_SUB(CURDATE(), INTERVAL 5 YEAR)) AND YEAR(CURDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE MilitaryInnovation(Country NVARCHAR(50), EventType VARCHAR(50), Year INT);INSERT INTO MilitaryInnovation(Country, EventType, Year) VALUES ('United States', 'Drone Technology', 2015), ('China', 'Artificial Intelligence', 2016), ('United States', 'Cybersecurity', 2017), ('China', 'Hypersonic Weapons', 2018), ('United States', 'Quantum Computing', 2019), ('China', 'Robotics', 2020);
What is the rank of military innovation events by country based on frequency?
SELECT Country, RANK() OVER(ORDER BY COUNT(*) DESC) AS Event_Rank FROM MilitaryInnovation GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE accommodations (id INT, student_id INT, accommodation_type VARCHAR(255), cost FLOAT); INSERT INTO accommodations (id, student_id, accommodation_type, cost) VALUES (1, 123, 'visual_aids', 250.0), (2, 456, 'audio_aids', 100.0), (3, 789, 'large_print_materials', 120.0), (4, 890, 'mobility_aids', 300.0);
Delete all records with accommodation type "mobility_aids" from the "accommodations" table
DELETE FROM accommodations WHERE accommodation_type = 'mobility_aids';
gretelai_synthetic_text_to_sql
CREATE TABLE construction_labor (id INT, worker_name VARCHAR(50), hours_worked INT, project_type VARCHAR(20), state VARCHAR(20)); INSERT INTO construction_labor (id, worker_name, hours_worked, project_type, state) VALUES (1, 'John Doe', 100, 'Sustainable', 'California');
What is the total number of labor hours spent on sustainable building projects in the state of California?
SELECT SUM(hours_worked) FROM construction_labor WHERE project_type = 'Sustainable' AND state = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE posts (id INT, user_id INT, post_date DATE); INSERT INTO posts (id, user_id, post_date) VALUES (1, 1, '2022-01-01'), (2, 2, '2022-01-02'), (3, 3, '2022-04-01'), (4, 4, '2022-03-01'), (5, 5, '2022-04-15'), (6, 6, '2022-04-30');
How many unique users posted content in April?
SELECT COUNT(DISTINCT user_id) FROM posts WHERE MONTH(post_date) = 4;
gretelai_synthetic_text_to_sql
CREATE TABLE event_attendance (id INT, event TEXT, category TEXT, attendees INT); INSERT INTO event_attendance (id, event, category, attendees) VALUES (1, 'Concert', 'music', 1000), (2, 'Jazz Festival', 'music', 2000), (3, 'Theatre Play', 'theatre', 1500);
What is the average attendance for cultural events in the 'music' category, and how many events are there in total for this category?
SELECT category, AVG(attendees) as avg_attendance, COUNT(DISTINCT event) as num_events FROM event_attendance WHERE category = 'music' GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE HealthcareBudget (Region VARCHAR(50), Year INT, Budget FLOAT); INSERT INTO HealthcareBudget VALUES ('North', 2018, 12000000), ('South', 2019, 13000000), ('East', 2020, 14000000), ('West', 2021, 15000000);
What is the maximum budget allocated for healthcare services in each region?
SELECT Region, MAX(Budget) OVER (PARTITION BY Year) AS MaxBudget FROM HealthcareBudget;
gretelai_synthetic_text_to_sql
CREATE TABLE policy_advocacy (initiative_id INT, initiative_name VARCHAR(50), implementation_year INT, region VARCHAR(50)); INSERT INTO policy_advocacy (initiative_id, initiative_name, implementation_year, region) VALUES (1, 'Accessible Curriculum', 2018, 'Northeast');
What is the number of policy advocacy initiatives implemented in each year by region?
SELECT region, implementation_year, COUNT(*) as initiatives_per_year FROM policy_advocacy GROUP BY region, implementation_year;
gretelai_synthetic_text_to_sql
CREATE TABLE training_operations (id INT, name VARCHAR(50), department VARCHAR(50), program VARCHAR(50));
Insert a new record for an employee from the 'Operations' department who joined the 'Team Building' training program.
INSERT INTO training_operations (id, name, department, program) VALUES (2, 'Clara Garcia', 'Operations', 'Team Building');
gretelai_synthetic_text_to_sql
CREATE TABLE athlete_wellbeing (athlete_id INT, wellbeing_program VARCHAR(20)); INSERT INTO athlete_wellbeing (athlete_id, wellbeing_program) VALUES (1, 'Yoga'), (2, 'Meditation'), (3, 'Stretching');
Delete all records from the 'athlete_wellbeing' table where the 'wellbeing_program' is 'Yoga'
DELETE FROM athlete_wellbeing WHERE wellbeing_program = 'Yoga';
gretelai_synthetic_text_to_sql
CREATE TABLE Claims (ClaimID INT, PolicyID INT, ClaimAmount DECIMAL(10,2)); CREATE TABLE Policy (PolicyID INT, PolicyType VARCHAR(20)); INSERT INTO Claims (ClaimID, PolicyID, ClaimAmount) VALUES (1, 1, 1500.00), (2, 2, 250.00), (3, 3, 500.00), (4, 1, 1000.00); INSERT INTO Policy (PolicyID, PolicyType) VALUES (1, 'Homeowners'), (2, 'Auto'), (3, 'Renters'), (4, 'Homeowners'), (5, 'Homeowners');
What is the average claim amount for each policy type, excluding policy types with fewer than 3 policies?
SELECT Policy.PolicyType, AVG(Claims.ClaimAmount) AS AvgClaimAmount FROM Policy INNER JOIN Claims ON Policy.PolicyID = Claims.PolicyID GROUP BY Policy.PolicyType HAVING COUNT(DISTINCT Policy.PolicyID) >= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE faculty (id INT, name VARCHAR(30), department VARCHAR(20), research_interest TEXT); INSERT INTO faculty (id, name, department, research_interest) VALUES (1, 'John Doe', 'Social Sciences', 'Inequality and Education'), (2, 'Jane Smith', 'Natural Sciences', 'Climate Change');
List the names and research interests of all faculty members in the 'Social Sciences' department
SELECT name, research_interest FROM faculty WHERE department = 'Social Sciences';
gretelai_synthetic_text_to_sql
CREATE TABLE LegalAidServices (ServiceID INT, ClientName VARCHAR(50), State VARCHAR(20)); INSERT INTO LegalAidServices VALUES (1, 'Client A', 'Texas'); INSERT INTO LegalAidServices VALUES (2, 'Client B', 'Texas'); INSERT INTO LegalAidServices VALUES (3, 'Client C', 'New York');
How many individuals have accessed legal aid services in Texas and New York?
SELECT COUNT(*) FROM LegalAidServices WHERE State IN ('Texas', 'New York');
gretelai_synthetic_text_to_sql
CREATE TABLE brands (brand_id INT, brand_name VARCHAR(50)); INSERT INTO brands VALUES (1, 'Lush'), (2, 'The Body Shop'), (3, 'Sephora'), (4, 'Ulta'); CREATE TABLE products (product_id INT, product_name VARCHAR(50), price DECIMAL(5,2), brand_id INT); INSERT INTO products VALUES (1, 'Face Wash', 15.99, 1), (2, 'Moisturizer', 25.49, 1), (3, 'Scrub', 12.50, 2), (4, 'Lip Balm', 4.99, 2), (5, 'Eye Shadow Palette', 35.00, 3), (6, 'Mascara', 14.99, 3), (7, 'Foundation', 29.99, 4), (8, 'Blush', 12.99, 4);
What is the average price of products for each brand, ranked by the average price?
SELECT brand_name, AVG(price) as avg_price FROM products JOIN brands ON products.brand_id = brands.brand_id GROUP BY brand_name ORDER BY avg_price DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Military_Innovation_Projects (id INT, country VARCHAR(50), year INT, project VARCHAR(50), budget INT);
What is the number of military innovation projects and their total budget for each country in the Asia-Pacific region in the last 7 years?
SELECT country, COUNT(project) as projects, SUM(budget) as total_budget FROM Military_Innovation_Projects WHERE region = 'Asia-Pacific' AND year BETWEEN (YEAR(CURRENT_DATE) - 7) AND YEAR(CURRENT_DATE) GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE dam_reservoirs (dam_id INT, dam_name VARCHAR(50), reservoir_name VARCHAR(50), reservoir_capacity INT);
What is the minimum reservoir capacity of a dam in the 'dam_reservoirs' table?
SELECT MIN(reservoir_capacity) FROM dam_reservoirs;
gretelai_synthetic_text_to_sql
CREATE TABLE support_programs (program_id INT PRIMARY KEY, name VARCHAR(255), description TEXT, category VARCHAR(255));
Create a table for storing information about disability support programs
CREATE TABLE if not exists support_programs_new AS SELECT * FROM support_programs WHERE 1=0;
gretelai_synthetic_text_to_sql
CREATE TABLE vessel_safety ( last_inspection_date DATE, last_inspection_grade CHAR(1), vessel_name VARCHAR(255));
Insert records in the vessel_safety table for vessel "Island Breeze" with the following data: (2022-02-01, 'A')
INSERT INTO vessel_safety (last_inspection_date, last_inspection_grade, vessel_name) VALUES ('2022-02-01', 'A', 'Island Breeze');
gretelai_synthetic_text_to_sql
CREATE TABLE Produce (id INT PRIMARY KEY, name VARCHAR(255), type VARCHAR(255), price DECIMAL(5,2)); INSERT INTO Produce (id, name, type, price) VALUES (1, 'Apples', 'Organic', 1.99), (2, 'Bananas', 'Organic', 1.49);
Find the average price of organic fruits in the 'Produce' table
SELECT AVG(price) FROM Produce WHERE type = 'Organic' AND name LIKE 'Fruits%';
gretelai_synthetic_text_to_sql
CREATE TABLE aircraft (aircraft_id INT, model VARCHAR(100), manufacturer VARCHAR(100), launch_date DATE); INSERT INTO aircraft (aircraft_id, model, manufacturer, launch_date) VALUES (1, 'Aircraft Model 1', 'Aviation Inc.', '2015-01-01'); INSERT INTO aircraft (aircraft_id, model, manufacturer, launch_date) VALUES (2, 'Aircraft Model 2', 'Flight Corp.', '2020-05-15');
Show all aircraft models and their associated manufacturers and launch dates.
SELECT model, manufacturer, launch_date FROM aircraft;
gretelai_synthetic_text_to_sql
CREATE TABLE libraries (library_id INT, library_name TEXT, city TEXT, rating INT); INSERT INTO libraries (library_id, library_name, city, rating) VALUES (1, 'Los Angeles Central Library', 'Los Angeles', 8), (2, 'Los Angeles Public Library', 'Los Angeles', 7), (3, 'Baldwin Hills Library', 'Los Angeles', 9);
What is the average rating of public libraries in the city of "Los Angeles"?
SELECT AVG(rating) FROM libraries WHERE city = 'Los Angeles' AND type = 'Public';
gretelai_synthetic_text_to_sql
CREATE TABLE conservation_initiatives (date DATE, water_conserved FLOAT); INSERT INTO conservation_initiatives (date, water_conserved) VALUES ('2020-01-01', 100000), ('2020-02-01', 150000), ('2020-03-01', 120000), ('2020-04-01', 180000);
What is the change in water conservation efforts by month in 2020?
SELECT EXTRACT(MONTH FROM date) AS month, AVG(water_conserved) AS avg_conserved FROM conservation_initiatives WHERE date BETWEEN '2020-01-01' AND '2020-12-31' GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE satellites (satellite_id INT, satellite_name VARCHAR(100), country VARCHAR(50), launch_date DATE, in_orbit BOOLEAN); INSERT INTO satellites (satellite_id, satellite_name, country, launch_date, in_orbit) VALUES (1, 'Sputnik 1', 'Russia', '1957-10-04', TRUE); INSERT INTO satellites (satellite_id, satellite_name, country, launch_date, in_orbit) VALUES (2, 'Explorer 1', 'United States', '1958-01-31', TRUE);
What is the earliest launch date of any satellite that is still in orbit?
SELECT MIN(launch_date) FROM satellites WHERE in_orbit = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_subscribers (subscriber_id INT, city VARCHAR(255), data_usage_gb DECIMAL(5,2)); INSERT INTO mobile_subscribers (subscriber_id, city, data_usage_gb) VALUES (1, 'New York', 18.3), (2, 'New York', 12.5), (3, 'Los Angeles', 16.7);
Which mobile subscribers in the city of New York have a data usage greater than 15 GB?
SELECT subscriber_id FROM mobile_subscribers WHERE city = 'New York' AND data_usage_gb > 15;
gretelai_synthetic_text_to_sql
CREATE TABLE recruitment_database (id INT, applicant_race TEXT, applicant_ethnicity TEXT, application_date DATE); INSERT INTO recruitment_database (id, applicant_race, applicant_ethnicity, application_date) VALUES (1, 'Asian', 'Not Hispanic or Latino', '2022-03-01'), (2, 'White', 'Not Hispanic or Latino', '2022-03-02'), (3, 'Black or African American', 'Hispanic or Latino', '2022-03-03');
How many job applicants in the recruitment database are from underrepresented racial or ethnic groups?
SELECT COUNT(*) as count FROM recruitment_database WHERE (applicant_race = 'Black or African American' OR applicant_race = 'Hispanic or Latino' OR applicant_race = 'American Indian or Alaska Native' OR applicant_race = 'Native Hawaiian or Other Pacific Islander') OR (applicant_ethnicity = 'Hispanic or Latino');
gretelai_synthetic_text_to_sql
CREATE TABLE daaps (id INT, name VARCHAR(255), regulatory_framework VARCHAR(255)); INSERT INTO daaps (id, name, regulatory_framework) VALUES (1, 'Uniswap', 'MiCA'), (2, 'Aave', 'AMLD'), (3, 'Compound', 'eIDAS'); CREATE TABLE regions (id INT, name VARCHAR(255)); INSERT INTO regions (id, name) VALUES (1, 'EU'), (2, 'US'), (3, 'APAC');
List all regulatory frameworks for decentralized applications in the EU.
SELECT name FROM daaps INNER JOIN regions ON daaps.regulatory_framework = regions.name WHERE regions.name = 'EU';
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (DonationID INT, DonorID INT, DonationDate DATE, DonationAmount FLOAT);
Who is the top donor in April 2022?
SELECT DonorID, MAX(DonationAmount) as 'Highest Donation' FROM Donations WHERE DonationDate BETWEEN '2022-04-01' AND '2022-04-30' GROUP BY DonorID ORDER BY 'Highest Donation' DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE city_attendees (city VARCHAR(20), attendee_id INT); INSERT INTO city_attendees (city, attendee_id) VALUES ('NYC', 1), ('LA', 2), ('NYC', 3), ('Chicago', 4);
Identify the top 5 cities with the most attendees
SELECT city, COUNT(attendee_id) AS num_attendees FROM city_attendees GROUP BY city ORDER BY num_attendees DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE memberships (id INT, member_type VARCHAR(50), region VARCHAR(50)); CREATE TABLE workout_data (member_id INT, workout_type VARCHAR(50), duration INT, heart_rate_avg INT, calories_burned INT, workout_date DATE);
What is the average heart rate for each member during 'Yoga' workouts in January 2022?
SELECT m.id, AVG(w.heart_rate_avg) as avg_heart_rate FROM memberships m JOIN workout_data w ON m.id = w.member_id WHERE w.workout_type = 'Yoga' AND w.workout_date >= DATE '2022-01-01' AND w.workout_date < DATE '2022-02-01' GROUP BY m.id;
gretelai_synthetic_text_to_sql
CREATE TABLE employee (id INT, job_id INT); CREATE TABLE job (id INT, title TEXT);
List all job titles that have less than 3 employees and the number of employees in the "employee" and "job" tables
SELECT j.title, COUNT(e.id) AS num_employees FROM job j LEFT JOIN employee e ON j.id = e.job_id GROUP BY j.title HAVING COUNT(e.id) < 3;
gretelai_synthetic_text_to_sql
CREATE TABLE broadband_customers (customer_id INT, name VARCHAR(50), plan_speed FLOAT, state VARCHAR(20)); INSERT INTO broadband_customers (customer_id, name, plan_speed, state) VALUES (1, 'Jane Smith', 150, 'California');
List all broadband customers in California who have a plan with speeds greater than 100 Mbps.
SELECT * FROM broadband_customers WHERE state = 'California' AND plan_speed > 100;
gretelai_synthetic_text_to_sql
CREATE TABLE Lines(id INT, name TEXT); CREATE TABLE Delays(line_id INT, delay TIME);
Which metro lines have the most delays?
SELECT Lines.name, COUNT(*) FROM Lines JOIN Delays ON Lines.id = Delays.line_id GROUP BY Lines.name ORDER BY COUNT(*) DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE habitats (id INT, name VARCHAR(255)); INSERT INTO habitats (id, name) VALUES (1, 'Forest'), (2, 'Savannah'), (3, 'Wetlands'); CREATE TABLE animals (id INT, name VARCHAR(255), habitat_id INT); INSERT INTO animals (id, name, habitat_id) VALUES (1, 'Lion', 2), (2, 'Elephant', 1), (3, 'Hippo', 3), (4, 'Giraffe', 2), (5, 'Duck', 3);
Count the number of animals in each habitat
SELECT habitats.name, COUNT(animals.id) AS animal_count FROM habitats JOIN animals ON habitats.id = animals.habitat_id GROUP BY habitats.name;
gretelai_synthetic_text_to_sql
CREATE TABLE water_temps (id INT, region TEXT, date DATE, temp FLOAT); INSERT INTO water_temps (id, region, date, temp) VALUES (1, 'North', '2022-01-01', 12.3), (2, 'South', '2022-01-01', 14.2), (3, 'North', '2022-01-02', 12.4), (4, 'South', '2022-01-02', 14.1);
What is the average water temperature in each region for the past week?
SELECT region, AVG(temp) FROM water_temps WHERE date >= DATE_SUB(CURDATE(), INTERVAL 7 DAY) GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE financial_wellbeing_2 (id INT, country VARCHAR(20), score INT); INSERT INTO financial_wellbeing_2 (id, country, score) VALUES (1, 'United States', 75);
Total financial wellbeing score for the United States.
SELECT SUM(score) FROM financial_wellbeing_2 WHERE country = 'United States';
gretelai_synthetic_text_to_sql
CREATE TABLE Users (UserID INT, Country VARCHAR(255)); INSERT INTO Users (UserID, Country) VALUES (1, 'USA'), (2, 'Canada'), (3, 'USA');
What is the total number of users in each country?
SELECT Country, COUNT(*) FROM Users GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE districts (id INT, name TEXT, budget INT);
Which districts have the highest total budget for public services?
SELECT d.name, SUM(s.budget) as total_budget FROM districts d JOIN schools s ON d.id = s.district_id GROUP BY d.name ORDER BY total_budget DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE trips (id INT, date DATE, mode VARCHAR(20)); INSERT INTO trips VALUES (1, '2022-01-01', 'Bus'), (2, '2022-01-02', 'Train'), (3, '2022-01-03', 'Subway'), (4, '2022-01-04', 'Bus'), (5, '2022-01-05', 'Train');
What is the maximum number of public transportation trips taken in a day in CityD?
SELECT MAX(count) FROM (SELECT date, COUNT(*) AS count FROM trips GROUP BY date) AS temp WHERE date = (SELECT MAX(date) FROM trips);
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, industry VARCHAR(255), funding_amount DECIMAL(10,2)); INSERT INTO companies (id, industry, funding_amount) VALUES (1, 'Tech', 50000.00), (2, 'Biotech', 20000.00), (3, 'Tech', 75000.00);
Find the average funding amount per industry
SELECT industry, AVG(funding_amount) FROM companies GROUP BY industry;
gretelai_synthetic_text_to_sql
CREATE TABLE deep_sea_expeditions (expedition_name TEXT, year INTEGER, discovered_new_species BOOLEAN); INSERT INTO deep_sea_expeditions (expedition_name, year, discovered_new_species) VALUES ('Challenger Expedition', 1872, TRUE), ('Galathea Expedition', 1950, FALSE);
Which deep-sea expeditions have discovered new marine life forms?
SELECT expedition_name FROM deep_sea_expeditions WHERE discovered_new_species = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE articles (id INT, title TEXT, category TEXT, publish_date DATE); INSERT INTO articles (id, title, category, publish_date) VALUES (1, 'Article Title 1', 'technology', '2020-02-01'), (2, 'Article Title 2', 'technology', '2022-06-05');
How many articles were published per month in the 'technology' category over the last 2 years?
SELECT DATE_FORMAT(publish_date, '%Y-%m') AS pub_month, COUNT(*) AS num_articles FROM articles WHERE category = 'technology' AND publish_date >= NOW() - INTERVAL 2 YEAR GROUP BY pub_month ORDER BY pub_month;
gretelai_synthetic_text_to_sql
CREATE TABLE ai_hotels (hotel_id INT, hotel_name TEXT, country TEXT, ai_adoption BOOLEAN, virtual_tour BOOLEAN); INSERT INTO ai_hotels (hotel_id, hotel_name, country, ai_adoption, virtual_tour) VALUES (1, 'Hotel X', 'Africa', true, true), (2, 'Hotel Y', 'Europe', true, false), (3, 'Hotel Z', 'Africa', false, true);
What is the number of hotels in Africa that have adopted AI technology and offer virtual tours?
SELECT COUNT(*) FROM ai_hotels WHERE country = 'Africa' AND ai_adoption = true AND virtual_tour = true;
gretelai_synthetic_text_to_sql
CREATE TABLE MuseumStores (id INT, location VARCHAR(50), date DATE, revenue DECIMAL(5,2)); INSERT INTO MuseumStores (id, location, date, revenue) VALUES (1, 'New York', '2022-01-01', 100.00), (2, 'Los Angeles', '2022-01-02', 200.00), (3, 'New York', '2022-01-03', 300.00);
What is the total revenue generated by museum stores in the last month?
SELECT SUM(revenue) FROM MuseumStores WHERE date >= DATEADD(month, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tour_stats (hotel_id INT, view_date DATE, view_duration INT);
Create a view named 'virtual_tour_stats_summary' that shows the number of virtual tours and the average view duration for each hotel_id in the 'virtual_tour_stats' table
CREATE VIEW virtual_tour_stats_summary AS SELECT hotel_id, COUNT(*), AVG(view_duration) FROM virtual_tour_stats GROUP BY hotel_id;
gretelai_synthetic_text_to_sql
CREATE TABLE GreenBuildings ( id INT, name VARCHAR(50), squareFootage INT, certification VARCHAR(10) ); INSERT INTO GreenBuildings (id, name, squareFootage, certification) VALUES (1, 'EcoTower', 50000, 'LEED Platinum'), (2, 'SolarHills', 75000, 'LEED Gold'), (3, 'GreenHaven', 35000, 'LEED Silver');
How many LEED certified buildings are there in the 'GreenBuildings' table that have a square footage greater than 40,000?
SELECT COUNT(*) FROM GreenBuildings WHERE squareFootage > 40000 AND certification = 'LEED';
gretelai_synthetic_text_to_sql
CREATE TABLE businesses_india (business_id INT, state TEXT, owner_gender TEXT, sustainable_practices BOOLEAN); INSERT INTO businesses_india (business_id, state, owner_gender, sustainable_practices) VALUES (1, 'Karnataka', 'Female', TRUE), (2, 'Karnataka', 'Male', FALSE), (3, 'Karnataka', 'Female', TRUE);
What is the number of rural women-led businesses in the state of Karnataka, India, that have adopted sustainable agricultural practices?
SELECT COUNT(*) as num_women_led_sustainable FROM businesses_india WHERE state = 'Karnataka' AND owner_gender = 'Female' AND sustainable_practices = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE Designers (DesignerID INT, DesignerName VARCHAR(50), Age INT); CREATE TABLE VR_Games (GameID INT, GameName VARCHAR(50), Genre VARCHAR(20), DesignerID INT); CREATE TABLE GamePlayer (PlayerID INT, GameID INT); CREATE TABLE Players (PlayerID INT, Age INT, Gender VARCHAR(10));
List all the designers who have created VR games, along with the average age of players who have played their games.
SELECT Designers.DesignerName, AVG(Players.Age) FROM Designers INNER JOIN VR_Games ON Designers.DesignerID = VR_Games.DesignerID INNER JOIN GamePlayer ON VR_Games.GameID = GamePlayer.GameID INNER JOIN Players ON GamePlayer.PlayerID = Players.PlayerID GROUP BY Designers.DesignerName;
gretelai_synthetic_text_to_sql
CREATE TABLE LocalBusinesses (BusinessID INTEGER, BusinessName TEXT, Location TEXT, TourismImpact INTEGER); INSERT INTO LocalBusinesses (BusinessID, BusinessName, Location, TourismImpact) VALUES (1, 'Family-Owned Restaurant', 'Italy', 1500), (2, 'Artisanal Bakery', 'France', 800), (3, 'Handmade Jewelry Shop', 'Spain', 1200), (4, 'Local Winery', 'Germany', 3000), (5, 'Traditional Brewery', 'Ireland', 2500);
What are the names and locations of the local businesses in 'Europe' with a tourism impact lower than 2000?
SELECT BusinessName, Location FROM LocalBusinesses WHERE Location = 'Europe' AND TourismImpact < 2000;
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_subscribers (subscriber_id INT, subscription_type VARCHAR(10), country VARCHAR(20)); INSERT INTO mobile_subscribers (subscriber_id, subscription_type, country) VALUES (1, 'postpaid', 'Australia'), (2, 'prepaid', 'Australia'), (3, 'postpaid', 'Australia');
How many mobile customers have a postpaid subscription in the country of Australia?
SELECT COUNT(*) FROM mobile_subscribers WHERE subscription_type = 'postpaid' AND country = 'Australia';
gretelai_synthetic_text_to_sql
CREATE TABLE platforms (platform_name TEXT, location TEXT); INSERT INTO platforms (platform_name, location) VALUES ('Platform A', 'Gulf of Mexico'), ('Platform B', 'North Sea'), ('Platform C', 'Gulf of Mexico');
List all the platforms located in the 'Gulf of Mexico'
SELECT platform_name FROM platforms WHERE location = 'Gulf of Mexico';
gretelai_synthetic_text_to_sql
CREATE TABLE startups (id INT, name VARCHAR(50), sector VARCHAR(50), funding FLOAT); INSERT INTO startups (id, name, sector, funding) VALUES (1, 'Genetech', 'genetic research', 2000000), (2, 'BioVentures', 'bioprocess engineering', 1500000), (3, 'NanoBio', 'biosensor technology', 1000000);
What is the minimum funding received by a startup in the 'genetic research' sector?
SELECT MIN(funding) FROM startups WHERE sector = 'genetic research';
gretelai_synthetic_text_to_sql
CREATE TABLE union_membership (id INT, union VARCHAR(20), member_count INT); INSERT INTO union_membership (id, union, member_count) VALUES (1, 'construction', 3500), (2, 'education', 8000), (3, 'manufacturing', 5000);
What is the average number of members in all unions?
SELECT AVG(member_count) FROM union_membership;
gretelai_synthetic_text_to_sql
CREATE TABLE vulnerabilities (id INT, timestamp TIMESTAMP, category VARCHAR(255), vulnerability VARCHAR(255), severity VARCHAR(255)); INSERT INTO vulnerabilities (id, timestamp, category, vulnerability, severity) VALUES (1, '2022-01-01 10:00:00', 'Web Applications', 'SQL Injection', 'High'), (2, '2022-01-01 10:00:00', 'Web Applications', 'Cross-site Scripting', 'Medium');
What are the top 3 most common vulnerabilities in the 'Web Applications' category in the last 6 months?
SELECT category, vulnerability, COUNT(*) as vulnerability_count FROM vulnerabilities WHERE timestamp >= DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 6 MONTH) AND category = 'Web Applications' GROUP BY category, vulnerability ORDER BY vulnerability_count DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE SCHEMA CityData; CREATE TABLE CityEducation (Name varchar(255), Type varchar(255)); INSERT INTO CityEducation (Name, Type) VALUES ('SchoolA', 'Public'), ('SchoolB', 'Public'), ('SchoolC', 'Private'); CREATE TABLE CityLibrary (Name varchar(255), Type varchar(255)); INSERT INTO CityLibrary (Name, Type) VALUES ('LibraryA', 'Public'), ('LibraryB', 'Public'), ('LibraryC', 'Private');
How many public schools and public libraries exist in total, in the 'CityData' schema's 'CityEducation' and 'CityLibrary' tables,
SELECT COUNT(*) FROM CityData.CityEducation WHERE Type = 'Public' INTERSECT SELECT COUNT(*) FROM CityData.CityLibrary WHERE Type = 'Public';
gretelai_synthetic_text_to_sql
CREATE TABLE Tourist_Arrivals ( id INT, country_id INT, year INT, visitors INT, FOREIGN KEY (country_id) REFERENCES Countries(id) ); INSERT INTO Tourist_Arrivals (id, country_id, year, visitors) VALUES (1, 3, 2019, 9000000); INSERT INTO Tourist_Arrivals (id, country_id, year, visitors) VALUES (2, 4, 2019, 6000000); INSERT INTO Tourist_Arrivals (id, country_id, year, visitors) VALUES (3, 3, 2020, 10000000); INSERT INTO Tourist_Arrivals (id, country_id, year, visitors) VALUES (4, 4, 2020, 7000000);
What is the total number of tourists who visited Asian countries in 2019 and 2020?
SELECT SUM(t.visitors) as total_visitors FROM Tourist_Arrivals t WHERE t.year IN (2019, 2020) AND t.country_id IN (SELECT id FROM Countries WHERE continent = 'Asia');
gretelai_synthetic_text_to_sql
CREATE TABLE SpaceMissions (MissionID INT, DestinationPlanet VARCHAR, AverageDistance FLOAT);
What are the average distances from Earth for all space missions to each planet in our solar system?
SELECT DestinationPlanet, AVG(AverageDistance) FROM SpaceMissions GROUP BY DestinationPlanet;
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_offsets (id INT, initiative_name VARCHAR(100), co2_offset FLOAT); INSERT INTO carbon_offsets (id, initiative_name, co2_offset) VALUES (1, 'Green Transport UK', 1234.5), (2, 'Renewable Energy UK', 678.9), (3, 'Energy Efficiency UK', 345.6);
What is the average CO2 offset of carbon offset initiatives in the United Kingdom?
SELECT AVG(co2_offset) FROM carbon_offsets WHERE country = 'United Kingdom';
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (id INT, donor_name VARCHAR(50), donation_amount DECIMAL(10,2), donation_date DATE, donor_location VARCHAR(50));
List all unique countries from which donations were received in 2022.
SELECT DISTINCT donor_location FROM Donations WHERE donation_date BETWEEN '2022-01-01' AND '2022-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE students (student_id INT, name TEXT); INSERT INTO students (student_id, name) VALUES (1, 'Alice Johnson'), (2, 'Bob Brown'); CREATE TABLE grants (grant_id INT, student_id INT, year INT, amount INT); INSERT INTO grants (grant_id, student_id, year, amount) VALUES (1, 1, 2021, 10000), (2, 2, 2022, 20000);
What is the name of the graduate student who received the largest research grant in the past year?
SELECT s.name FROM students s INNER JOIN (SELECT student_id, MAX(amount) as max_amount FROM grants WHERE year = 2022 GROUP BY student_id) g ON s.student_id = g.student_id WHERE g.max_amount = (SELECT MAX(amount) FROM grants WHERE year = 2022);
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tours (tour_id INT, title TEXT, city TEXT, link TEXT); INSERT INTO virtual_tours (tour_id, title, city, link) VALUES (1, 'Paris Virtual Tour', 'Paris', 'old_link');
Update the record of the virtual tour in Paris with a new link.
UPDATE virtual_tours SET link = 'new_link' WHERE tour_id = 1 AND city = 'Paris';
gretelai_synthetic_text_to_sql
CREATE TABLE farm (id INT PRIMARY KEY, name VARCHAR(50), region_id INT, avg_rainfall DECIMAL(5,2)); CREATE TABLE region (id INT PRIMARY KEY, name VARCHAR(50)); INSERT INTO region (id, name) VALUES (1, 'Andes'), (2, 'Altiplano'); INSERT INTO farm (id, name, region_id, avg_rainfall) VALUES (1, 'Quinoa Farm 1', 1, 450.1), (2, 'Quinoa Farm 2', 1, 460.2), (3, 'Quinoa Farm 3', 2, 500.0);
What is the average rainfall for all regions growing 'Quinoa'?
SELECT AVG(f.avg_rainfall) FROM farm f INNER JOIN region r ON f.region_id = r.id WHERE r.name IN (SELECT name FROM region WHERE id IN (SELECT region_id FROM farm WHERE name = 'Quinoa'));
gretelai_synthetic_text_to_sql
CREATE TABLE healthcare_access (id INT, community TEXT, metric TEXT); INSERT INTO healthcare_access (id, community, metric) VALUES (1, 'Indigenous A', 'Accessibility'), (2, 'Indigenous B', 'Availability'), (3, 'Indigenous A', 'Quality');
What is the total number of healthcare access metrics for indigenous communities?
SELECT COUNT(DISTINCT community) FROM healthcare_access WHERE community LIKE '%Indigenous%';
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas (name VARCHAR(255), area_id INT, depth FLOAT, size INT, country VARCHAR(255)); INSERT INTO marine_protected_areas (name, area_id, depth, size, country) VALUES ('Palau National Marine Sanctuary', 5, 3000, 500000, 'Palau'), ('Phoenix Islands Protected Area', 6, 5000, 408000, 'Kiribati');
What is the maximum depth of marine protected areas in the Pacific Ocean?
SELECT MAX(depth) FROM marine_protected_areas WHERE country = 'Pacific Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE production_output (output_id INT, machine_id INT, production_date DATE, output_quantity INT); INSERT INTO production_output (output_id, machine_id, production_date, output_quantity) VALUES (5, 3, '2022-07-01', 200), (6, 3, '2022-07-02', 220), (7, 4, '2022-07-01', 250), (8, 4, '2022-07-02', 260); CREATE TABLE facilities (facility_id INT, facility_name VARCHAR(255), country VARCHAR(255)); INSERT INTO facilities (facility_id, facility_name, country) VALUES (3, 'Mumbai Plant', 'India'), (4, 'New Delhi Plant', 'India'), (5, 'Bangalore Plant', 'India');
What is the average production output for each machine in the company's facility in India?
SELECT machine_id, AVG(output_quantity) as avg_output FROM production_output po JOIN facilities f ON f.facility_name = 'Mumbai Plant' WHERE po.production_date BETWEEN '2022-07-01' AND '2022-12-31' GROUP BY machine_id;
gretelai_synthetic_text_to_sql
CREATE TABLE courts (court_id INT, name VARCHAR(50)); INSERT INTO courts (court_id, name) VALUES (1001, 'Court A'), (1002, 'Court B'), (1003, 'Court C'); CREATE TABLE cases (case_id INT, court_id INT, duration INT); INSERT INTO cases (case_id, court_id, duration) VALUES (1, 1001, 30), (2, 1001, 45), (3, 1002, 60), (4, 1002, 75), (5, 1003, 90), (6, 1003, 105);
List all courts with their average case duration, in descending order of average duration?
SELECT court_id, AVG(duration) as avg_duration FROM cases GROUP BY court_id ORDER BY avg_duration DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Disease (name VARCHAR(50), vaccination_rate FLOAT); INSERT INTO Disease (name, vaccination_rate) VALUES ('Nigeria', 77.2), ('South Africa', 88.6);
What is the vaccination rate for measles in Africa?
SELECT AVG(vaccination_rate) FROM Disease WHERE name IN ('Nigeria', 'South Africa');
gretelai_synthetic_text_to_sql
CREATE TABLE member_workouts (member_id INT, max_heart_rate INT); INSERT INTO member_workouts (member_id, max_heart_rate) VALUES (1, 190), (2, 170), (3, 185), (4, 160), (5, 200);
What is the maximum heart rate recorded for any member?
SELECT MAX(max_heart_rate) FROM member_workouts;
gretelai_synthetic_text_to_sql
CREATE TABLE flower_sales (dispensary_id INT, thc_content DECIMAL(3,2), sale_date DATE); INSERT INTO flower_sales (dispensary_id, thc_content, sale_date) VALUES (1, 25.3, '2022-01-01'), (2, 23.5, '2022-02-01'), (3, 24.6, '2022-01-15'); CREATE TABLE dispensaries (dispensary_id INT, state CHAR(2)); INSERT INTO dispensaries (dispensary_id, state) VALUES (1, 'MO'), (2, 'CA'), (3, 'OR');
What is the average THC content of cannabis flower sold in Missouri dispensaries?
SELECT AVG(thc_content) FROM flower_sales fs JOIN dispensaries d ON fs.dispensary_id = d.dispensary_id WHERE d.state = 'MO';
gretelai_synthetic_text_to_sql
CREATE TABLE menu (menu_id INT, menu_name TEXT, menu_type TEXT, price DECIMAL, daily_sales INT, region TEXT);
What is the total number of menu items sold in the Hawaii region?
SELECT SUM(daily_sales) FROM menu WHERE region = 'Hawaii';
gretelai_synthetic_text_to_sql
CREATE TABLE military_innovation_operations (id INT, operation VARCHAR(50), date DATE, budget INT, country VARCHAR(50), gdp DECIMAL(10,2), defense_expenditure DECIMAL(10,2)); INSERT INTO military_innovation_operations (id, operation, date, budget, country, gdp, defense_expenditure) VALUES (1, 'Operation Lightning Bolt', '2021-06-15', 75000000, 'United States', 21433000, 0.73), (2, 'Operation Thunder Strike', '2022-02-03', 60000000, 'China', 16177000, 1.9), (3, 'Operation Iron Fist', '2021-10-10', 80000000, 'Russia', 16177000, 4.3), (4, 'Operation Northern Wind', '2022-07-25', 45000000, 'Germany', 3984300, 1.5), (5, 'Operation Red Storm', '2021-03-09', 50000000, 'France', 2813600, 2.3), (6, 'Operation Sky Shield', '2022-09-18', 90000000, 'United Kingdom', 2435000, 2.2), (7, 'Operation Pacific Vanguard', '2022-12-12', 40000000, 'Japan', 5364000, 1);
List all military innovation operations with a budget greater than $50 million, excluding those from countries with a defense expenditure lower than 3% of their GDP.
SELECT * FROM military_innovation_operations WHERE budget > 50000000 AND defense_expenditure/gdp > 0.03;
gretelai_synthetic_text_to_sql
CREATE TABLE decentralized_applications (app_id INT PRIMARY KEY, name VARCHAR(255), category VARCHAR(50), launch_date DATETIME);
Identify and display any records in the decentralized_applications table that have launch_date in the next 30 days.
SELECT * FROM decentralized_applications WHERE launch_date BETWEEN CURRENT_DATE AND DATE_ADD(CURRENT_DATE, INTERVAL 30 DAY);
gretelai_synthetic_text_to_sql
CREATE TABLE EsportsEvents (EventName VARCHAR(50), EventLocation VARCHAR(50)); INSERT INTO EsportsEvents (EventName, EventLocation) VALUES ('Asia-Pacific Games', 'Tokyo'); INSERT INTO EsportsEvents (EventName, EventLocation) VALUES ('North American Championships', 'New York');
Show the number of esports events hosted in the Asia-Pacific region
SELECT COUNT(*) FROM EsportsEvents WHERE EventLocation LIKE '%Asia-Pacific%';
gretelai_synthetic_text_to_sql
CREATE TABLE GameSessions (SessionID INT, UserID INT, Playtime INT, SessionDate DATE); INSERT INTO GameSessions (SessionID, UserID, Playtime, SessionDate) VALUES (1, 9, 300, '2022-03-06'), (2, 10, 250, '2022-03-07'), (3, 11, 400, '2022-03-08');
What is the maximum playtime per user for players from Argentina, calculated for each day of the week?
SELECT EXTRACT(DOW FROM SessionDate) AS Day, MAX(Playtime) FROM GameSessions WHERE Country = 'Argentina' GROUP BY Day;
gretelai_synthetic_text_to_sql
CREATE TABLE games (id INT PRIMARY KEY, player_id INT, game_name VARCHAR(100), last_played TIMESTAMP); INSERT INTO games VALUES (1, 1001, 'GameA', '2021-01-01 12:00:00'), (2, 1002, 'GameB', '2021-02-15 14:30:00'), (3, 1003, 'GameA', '2021-06-20 09:15:00'); CREATE TABLE players (id INT PRIMARY KEY, name VARCHAR(50));
Delete records of players who have not played any game in the last 6 months
DELETE FROM players WHERE id NOT IN (SELECT player_id FROM games WHERE last_played > DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 6 MONTH));
gretelai_synthetic_text_to_sql
CREATE TABLE products (id INT, name VARCHAR(50), category VARCHAR(50)); INSERT INTO products (id, name, category) VALUES (1, 'Reusable Water Bottle', 'Eco-friendly'); CREATE TABLE reviews (id INT, product_id INT, review TEXT, review_date DATE); INSERT INTO reviews (id, product_id, review, review_date) VALUES (1, 1, 'Great quality and sustainable!', '2022-03-20');
What is the average word count of reviews for products in the 'Eco-friendly' category in the last month?
SELECT AVG(LENGTH(r.review) - LENGTH(REPLACE(r.review, ' ', '')) + 1) as avg_word_count FROM reviews r JOIN products p ON r.product_id = p.id WHERE p.category = 'Eco-friendly' AND r.review_date BETWEEN DATE_SUB(CURDATE(), INTERVAL 1 MONTH) AND CURDATE();
gretelai_synthetic_text_to_sql
CREATE TABLE fish_farms (id INT, name TEXT, region TEXT); INSERT INTO fish_farms (id, name, region) VALUES (1, 'Farm A', 'Arctic Ocean'), (2, 'Farm B', 'Antarctic Ocean'); CREATE TABLE water_quality (id INT, farm_id INT, region TEXT, salinity FLOAT); INSERT INTO water_quality (id, farm_id, region, salinity) VALUES (1, 1, 'Arctic Ocean', 33.2), (2, 1, 'Arctic Ocean', 33.3), (3, 2, 'Antarctic Ocean', 34.1);
What is the average water salinity for fish farms in the 'Arctic Ocean' region?
SELECT AVG(water_quality.salinity) FROM water_quality INNER JOIN fish_farms ON water_quality.farm_id = fish_farms.id WHERE fish_farms.region = 'Arctic Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE defense_projects (id INT, project_name VARCHAR(255), region VARCHAR(255), start_date DATE, end_date DATE, budget DECIMAL(10,2)); INSERT INTO defense_projects (id, project_name, region, start_date, end_date, budget) VALUES (1, 'Project C', 'Southeast Asia', '2017-01-01', '2021-12-31', 1000000); INSERT INTO defense_projects (id, project_name, region, start_date, end_date, budget) VALUES (2, 'Project D', 'Southeast Asia', '2018-01-01', NULL, 1500000);
Calculate the total value of defense projects in the Southeast Asia region that have not been completed yet, ordered by the sum in descending order.
SELECT region, SUM(budget) FROM defense_projects WHERE end_date IS NULL GROUP BY region ORDER BY SUM(budget) DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Purple_Partners (id INT, esg_factor VARCHAR(30)); INSERT INTO Purple_Partners (id, esg_factor) VALUES (1, 'Climate Change'), (2, 'Gender Equality'), (3, 'Labor Practices');
Which ESG factors are most relevant to Purple Partners' investment strategy?
SELECT esg_factor FROM Purple_Partners WHERE TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, name VARCHAR(50), last_transaction_date DATE); INSERT INTO customers (customer_id, name, last_transaction_date) VALUES (1, 'John Doe', '2022-02-05'), (2, 'Jane Smith', NULL), (3, 'Bob Johnson', '2022-02-02');
What is the total number of customers who have made at least one transaction in the last week?
SELECT COUNT(DISTINCT customer_id) FROM customers WHERE last_transaction_date >= DATE_SUB(CURDATE(), INTERVAL 1 WEEK);
gretelai_synthetic_text_to_sql