context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE agreements (id INT, union_id INT, region TEXT, date DATE, agreement_count INT); INSERT INTO agreements (id, union_id, region, date, agreement_count) VALUES (1, 1, 'Europe', '2021-01-01', 5), (2, 2, 'Asia-Pacific', '2021-02-15', 3);
How many collective bargaining agreements were signed in each region in the last 6 months?
SELECT region, COUNT(agreement_count) FROM agreements WHERE date >= DATEADD(month, -6, CURRENT_DATE) GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE broadband_usage (id INT, location VARCHAR(50), data_usage FLOAT); INSERT INTO broadband_usage (id, location, data_usage) VALUES (1, 'New York', 25.6), (2, 'Texas', 30.7), (3, 'California', 28.9);
What is the average monthly data usage for broadband customers in the state of New York?
SELECT AVG(data_usage) FROM broadband_usage WHERE location = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (DonationID INT, DonationDate DATE, CauseCategory VARCHAR(50), DonationAmount NUMERIC(15,2));
What is the average donation amount per day for each cause category?
SELECT CauseCategory, AVG(DonationAmount) as AvgDonationAmount FROM Donations GROUP BY CauseCategory, DATEPART(year, DonationDate), DATEPART(month, DonationDate), DATEPART(day, DonationDate) ORDER BY CauseCategory, DATEPART(year, DonationDate), DATEPART(month, DonationDate), DATEPART(day, DonationDate);
gretelai_synthetic_text_to_sql
CREATE TABLE local_impact (id INT, city VARCHAR(50), value INT); INSERT INTO local_impact (id, city, value) VALUES (1, 'New York', 1000), (2, 'Berlin', 1500), (3, 'Tokyo', 800), (4, 'Seoul', 1200);
What is the average local economic impact in Tokyo and Seoul?
SELECT AVG(value) FROM local_impact WHERE city IN ('Tokyo', 'Seoul');
gretelai_synthetic_text_to_sql
CREATE TABLE factories (factory_id INT, factory_name VARCHAR(20)); INSERT INTO factories VALUES (1, 'Factory A'), (2, 'Factory B'), (3, 'Factory C'); CREATE TABLE roles (role_id INT, role_name VARCHAR(20)); INSERT INTO roles VALUES (1, 'junior'), (2, 'senior'), (3, 'manager'); CREATE TABLE workers (worker_id INT, facto...
What is the average salary of 'junior' workers in each factory?
SELECT f.factory_name, AVG(salary) FROM workers w INNER JOIN roles r ON w.role_id = r.role_id INNER JOIN factories f ON w.factory_id = f.factory_id WHERE r.role_name = 'junior' GROUP BY f.factory_name;
gretelai_synthetic_text_to_sql
CREATE TABLE labor (employee_id INT, age_group VARCHAR(50), material VARCHAR(50), weight FLOAT); INSERT INTO labor (employee_id, age_group, material, weight) VALUES (1, '18-24', 'Iron', 500), (2, '25-34', 'Iron', 450), (3, '35-44', 'Iron', 400), (4, '45-54', 'Iron', 350), (5, '55-64', 'Iron', 300);
What was the total weight of minerals extracted by age group in the given dataset?
SELECT age_group, SUM(weight) as total_weight FROM labor GROUP BY age_group;
gretelai_synthetic_text_to_sql
CREATE TABLE Shipments (id INT, weight INT, origin_country TEXT); INSERT INTO Shipments (id, weight, origin_country) VALUES (1, 8, 'USA'); INSERT INTO Shipments (id, weight, origin_country) VALUES (2, 12, 'USA'); INSERT INTO Shipments (id, weight, origin_country) VALUES (3, 5, 'Canada');
Delete all shipments that have a weight greater than 10 tons and originated from the United States.
DELETE FROM Shipments WHERE weight > 10 AND origin_country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE VolunteerHours (HourID INT, VolunteerID INT, ProgramID INT, Hours DECIMAL(10,2)); CREATE TABLE Donations (DonationID INT, DonorID INT, ProgramID INT, Amount DECIMAL(10,2)); CREATE TABLE Volunteers (VolunteerID INT, Name TEXT); CREATE TABLE Donors (DonorID INT, Name TEXT); INSERT INTO VolunteerHours (HourID...
What is the total number of volunteer hours and total donation amount per program, based on the 'VolunteerHours', 'Volunteers', 'Donations', and 'Donors' tables?
SELECT VolunteerPrograms.ProgramID, SUM(VolunteerHours.Hours) as TotalHours, SUM(Donations.Amount) as TotalDonation FROM VolunteerPrograms INNER JOIN VolunteerHours ON VolunteerPrograms.ProgramID = VolunteerHours.ProgramID INNER JOIN Donations ON VolunteerPrograms.ProgramID = Donations.ProgramID GROUP BY VolunteerProgr...
gretelai_synthetic_text_to_sql
CREATE TABLE department_budgets (department TEXT, budget INT, year INT); INSERT INTO department_budgets (department, budget, year) VALUES ('intelligence', 1000000, 2020), ('reconnaissance', 1200000, 2020), ('intelligence', 1100000, 2019), ('reconnaissance', 1300000, 2019);
What is the difference in budget between the 'intelligence' and 'reconnaissance' departments for the year 2020, ordered by the difference in descending order?
SELECT LAG(budget, 1, 0) OVER (ORDER BY department) as prev_budget, budget, budget - LAG(budget, 1, 0) OVER (ORDER BY department) as budget_diff, department FROM department_budgets WHERE year = 2020 AND (department = 'intelligence' OR department = 'reconnaissance') ORDER BY budget_diff DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (id INT, name TEXT, signup_date DATE, region TEXT); INSERT INTO volunteers (id, name, signup_date, region) VALUES (1, 'Alice', '2022-01-15', 'North'), (2, 'Bob', '2021-12-10', 'South'), (3, 'Charlie', '2022-02-25', 'East'), (4, 'David', '2021-11-05', 'West'), (5, 'Eve', '2022-03-05', 'North');
Show the number of volunteers who signed up in each region for the past 12 months.
SELECT region, COUNT(DISTINCT id) as new_volunteers, DATE_FORMAT(signup_date, '%Y-%m') as month FROM volunteers WHERE signup_date BETWEEN DATE_SUB(NOW(), INTERVAL 12 MONTH) AND NOW() GROUP BY region, month;
gretelai_synthetic_text_to_sql
CREATE TABLE accessibility_data (service_type VARCHAR(50), usage_date DATE); INSERT INTO accessibility_data (service_type, usage_date) VALUES ('Wheelchair Ramp', '2021-01-01'), ('Wheelchair Ramp', '2021-01-05'), ('Service Animal', '2021-01-03');
Count the number of passengers who used accessible services in January 2021
SELECT COUNT(*) FROM accessibility_data WHERE usage_date BETWEEN '2021-01-01' AND '2021-01-31';
gretelai_synthetic_text_to_sql
CREATE TABLE processed_foods (id INT PRIMARY KEY, name VARCHAR(100), category VARCHAR(50), calories INT);
Update the 'calories' column in the 'processed_foods' table for all records with 'name' containing 'chocolate' and set the value to 250
UPDATE processed_foods SET calories = 250 WHERE name LIKE '%chocolate%';
gretelai_synthetic_text_to_sql
CREATE TABLE TerbiumProduction (country VARCHAR(20), year INT, quantity INT); INSERT INTO TerbiumProduction (country, year, quantity) VALUES ('Malaysia', 2018, 70), ('Malaysia', 2019, 75);
What is the total production quantity of terbium in Malaysia for the year 2018?
SELECT SUM(quantity) FROM TerbiumProduction WHERE country = 'Malaysia' AND year = 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE Chemicals (id INT, name VARCHAR(255), max_safe_temp FLOAT); CREATE TABLE Storage (id INT, chemical_id INT, facility_id INT, storage_date DATE);
What is the maximum safe operating temperature for each chemical stored at a specific facility?
SELECT Chemicals.name, Chemicals.max_safe_temp FROM Chemicals INNER JOIN Storage ON Chemicals.id = Storage.chemical_id WHERE Storage.facility_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE attendance_data (id INT, user_id INT, program VARCHAR(50), attend_date DATE); INSERT INTO attendance_data (id, user_id, program, attend_date) VALUES (10, 9, 'Tai Chi', '2021-06-01'), (11, 10, 'Zumba', '2021-07-01'), (12, 11, 'Tai Chi', '2021-08-01'), (13, 12, 'Yoga', '2021-09-01'), (14, 13, 'Pilates', '202...
Which wellness programs were attended by users from Argentina and Colombia, and how many times did they attend?
SELECT program, COUNT(*) as attend_count FROM attendance_data WHERE country IN ('Argentina', 'Colombia') GROUP BY program;
gretelai_synthetic_text_to_sql
CREATE TABLE school_districts (district_id INT, district_name TEXT, average_mental_health_score DECIMAL(5,2)); CREATE TABLE students (student_id INT, district_id INT, mental_health_score INT);
What are the names and number of students for the top 5 school districts with the highest average mental health scores, and what is the overall average mental health score across all school districts?
SELECT d.district_name, COUNT(s.student_id) as num_students, AVG(s.mental_health_score) as avg_mental_health_score FROM students s JOIN school_districts d ON s.district_id = d.district_id GROUP BY d.district_id, d.district_name ORDER BY avg_mental_health_score DESC LIMIT 5; SELECT AVG(s.mental_health_score) as overall_...
gretelai_synthetic_text_to_sql
CREATE TABLE events (id INT, event_date DATE, visitor_count INT, visitor_ethnicity VARCHAR(20)); INSERT INTO events (id, event_date, visitor_count, visitor_ethnicity) VALUES (1, '2021-07-10', 250, 'Latinx'), (2, '2021-07-11', 300, 'Asian'), (3, '2021-07-12', 150, 'African American'), (4, '2021-08-01', 400, 'Caucasian')...
How many visitors identified as Latinx attended events in the past 6 months?
SELECT SUM(visitor_count) FROM events WHERE visitor_ethnicity = 'Latinx' AND event_date BETWEEN '2021-07-01' AND '2021-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE explainable_model (id INT PRIMARY KEY, model_name TEXT, training_date DATE); INSERT INTO explainable_model (id, model_name, training_date) VALUES (1, 'model1', '2021-01-01'), (2, 'model2', '2021-02-01');
What is the earliest 'explainable_model' training date for 'model1'?
SELECT MIN(training_date) FROM explainable_model WHERE model_name = 'model1';
gretelai_synthetic_text_to_sql
CREATE TABLE cultural_tourism(location_id INT, location_name TEXT, country TEXT, tourism_impact INT); INSERT INTO cultural_tourism (location_id, location_name, country, tourism_impact) VALUES (1, 'Tokyo National Museum', 'Japan', 150), (2, 'Asakusa', 'Japan', 200), (3, 'Ueno Park', 'Japan', 120);
What is the local economic impact of cultural tourism in Tokyo, Japan?
SELECT SUM(tourism_impact) FROM cultural_tourism WHERE country = 'Japan' AND location_name IN ('Tokyo National Museum', 'Asakusa');
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, transparency_rating TEXT); INSERT INTO products (product_id, transparency_rating) VALUES (1, 'High'), (2, 'Medium'), (3, 'High'), (4, 'Low'); CREATE TABLE sales (sale_id INT, product_id INT, price DECIMAL(5,2)); INSERT INTO sales (sale_id, product_id, price) VALUES (1, 1, 20.99), ...
What is the total revenue generated from products with a high transparency rating?
SELECT SUM(sales.price) FROM sales INNER JOIN products ON sales.product_id = products.product_id WHERE products.transparency_rating = 'High';
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name TEXT, is_cruelty_free BOOLEAN, sales INT, country TEXT); INSERT INTO products (product_id, product_name, is_cruelty_free, sales, country) VALUES (1, 'Lipstick', true, 500, 'USA'), (2, 'Foundation', false, 700, 'USA'), (3, 'Mascara', true, 600, 'USA');
What are the top 3 cruelty-free cosmetic products by sales in the USA?
SELECT product_name, SUM(sales) as total_sales FROM products WHERE is_cruelty_free = true AND country = 'USA' GROUP BY product_name ORDER BY total_sales DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE vulnerabilities (id INT, department VARCHAR(20), resolved BOOLEAN); INSERT INTO vulnerabilities (id, department, resolved) VALUES (1, 'Marketing', FALSE), (2, 'IT', TRUE), (3, 'Marketing', TRUE), (4, 'Marketing', FALSE);
How many vulnerabilities were resolved in the 'Marketing' department in the last 6 months?
SELECT COUNT(*) FROM vulnerabilities WHERE department = 'Marketing' AND resolved = TRUE AND detection_date >= DATE_SUB(CURDATE(), INTERVAL 6 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (id INT, continent VARCHAR(50), name VARCHAR(50), endemic BOOLEAN); INSERT INTO marine_species (id, continent, name, endemic) VALUES (1, 'Africa', 'Coelacanth', true); INSERT INTO marine_species (id, continent, name, endemic) VALUES (2, 'Asia', 'Dugong', false);
How many marine species are endemic to each continent?
SELECT continent, COUNT(*) FROM marine_species WHERE endemic = true GROUP BY continent;
gretelai_synthetic_text_to_sql
CREATE TABLE factories_asia (factory_id INT, country VARCHAR(50), certification_1 VARCHAR(50), certification_2 VARCHAR(50), certification_3 VARCHAR(50)); INSERT INTO factories_asia (factory_id, country, certification_1, certification_2, certification_3) VALUES (1, 'China', 'Fair Trade', 'SA8000', 'BSCI'), (2, 'India', ...
What is the percentage of factories in Asia with at least one fair labor practice certification?
SELECT COUNT(*) * 100.0 / (SELECT COUNT(*) FROM factories_asia) FROM factories_asia WHERE certification_1 IS NOT NULL OR certification_2 IS NOT NULL OR certification_3 IS NOT NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE workouts (id INT, member_id INT, workout_type VARCHAR(50), duration INT, date DATE, avg_heart_rate DECIMAL(3,1)); INSERT INTO workouts (id, member_id, workout_type, duration, date, avg_heart_rate) VALUES (1, 1, 'Cycling', 60, '2022-03-10', 120.5), (2, 3, 'Yoga', 45, '2022-03-15', 85.0);
Calculate the average heart rate for each member during their workouts in the last month.
SELECT w.member_id, AVG(w.avg_heart_rate) AS avg_heart_rate FROM workouts w WHERE w.date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH) GROUP BY w.member_id;
gretelai_synthetic_text_to_sql
CREATE TABLE subscribers(id INT, plan_type VARCHAR(10), region VARCHAR(10)); INSERT INTO subscribers VALUES (1, 'unlimited', 'Western'); INSERT INTO subscribers VALUES (2, 'limited', 'Northern'); INSERT INTO subscribers VALUES (3, NULL, 'Southern'); CREATE TABLE data_usage(subscriber_id INT, data_used INT); INSERT INTO...
List all the mobile subscribers with their plan type and the amount of data they have used in the Western region, if available. If not, return null values.
SELECT subscribers.id, subscribers.plan_type, data_usage.data_used FROM subscribers LEFT JOIN data_usage ON subscribers.id = data_usage.subscriber_id WHERE subscribers.region = 'Western';
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tours (tour_id INT, hotel_id INT, user_id INT, timestamp TIMESTAMP);
What is the most popular virtual tour for hotels in Brazil?
SELECT hotel_id, COUNT(*) FROM virtual_tours WHERE country = 'Brazil' GROUP BY hotel_id ORDER BY COUNT(*) DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (id INT, name TEXT, city TEXT, is_eco_friendly BOOLEAN, revenue FLOAT); INSERT INTO hotels (id, name, city, is_eco_friendly, revenue) VALUES (1, 'Eco Hotel New York', 'New York', TRUE, 15000.0), (2, 'Green Hotel New York', 'New York', TRUE, 18000.0);
What is the total revenue of eco-friendly hotels in New York?
SELECT SUM(revenue) FROM hotels WHERE city = 'New York' AND is_eco_friendly = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE FareCollection (CollectionID INT, CollectionDate DATE, VehicleType VARCHAR(50)); INSERT INTO FareCollection (CollectionID, CollectionDate, VehicleType) VALUES (1, '2023-01-01', 'Bus'), (2, '2023-01-05', 'Tram'), (3, '2023-02-10', 'Train');
What is the earliest and latest collection date for each vehicle type?
SELECT VehicleType, MIN(CollectionDate) as EarliestCollectionDate, MAX(CollectionDate) as LatestCollectionDate FROM FareCollection GROUP BY VehicleType;
gretelai_synthetic_text_to_sql
CREATE TABLE species (id INT, name VARCHAR(50), habitat_ocean VARCHAR(50)); CREATE TABLE conservation_status (id INT, species_id INT, status VARCHAR(50), score FLOAT);
Show the number of marine species in each ocean and their average conservation status score.
SELECT habitat_ocean, AVG(score), COUNT(*) FROM species INNER JOIN conservation_status ON species.id = conservation_status.species_id GROUP BY habitat_ocean;
gretelai_synthetic_text_to_sql
CREATE TABLE peacekeeping_operations (id INT PRIMARY KEY, operation_name VARCHAR(50), location VARCHAR(50));
Insert a new record into the 'peacekeeping_operations' table with the following values: (3, 'MINUSCA', 'Central African Republic')
INSERT INTO peacekeeping_operations (id, operation_name, location) VALUES (3, 'MINUSCA', 'Central African Republic');
gretelai_synthetic_text_to_sql
CREATE TABLE matches (team1 VARCHAR(255), team2 VARCHAR(255), goals_scored INT);
List all soccer matches with more than 3 goals scored
SELECT * FROM matches WHERE goals_scored > 3;
gretelai_synthetic_text_to_sql
CREATE SCHEMA art; CREATE TABLE art_pieces (artist_id INT, artist_name VARCHAR(255), country VARCHAR(50), art_count INT); INSERT INTO art.art_pieces (artist_id, artist_name, country, art_count) VALUES (1, 'Nana Asante', 'Ghana', 15), (2, 'Aisha Dia', 'Senegal', 20), (3, 'Kwame Opoku', 'Nigeria', 12);
What is the average number of art pieces created per artist in Africa?
SELECT AVG(art_count) FROM art.art_pieces WHERE country = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE VulnerabilityDatabase (id INT, country VARCHAR(50), severity INT, timestamp DATETIME); INSERT INTO VulnerabilityDatabase (id, country, severity, timestamp) VALUES (1, 'Brazil', 7, '2021-01-01 10:00:00'), (2, 'India', 6, '2021-01-01 10:00:00');
What are the top 3 countries with the lowest average vulnerability severity in the last 6 months, according to our Vulnerability Database?
SELECT country, AVG(severity) as avg_severity FROM VulnerabilityDatabase WHERE timestamp >= DATE_SUB(NOW(), INTERVAL 6 MONTH) GROUP BY country ORDER BY avg_severity ASC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE forest_type (forest_type_id INT, forest_type_name TEXT, region_id INT, PRIMARY KEY (forest_type_id)); CREATE TABLE forest (forest_id INT, forest_type_id INT, tree_species_count INT, age INT, carbon_sequestered INT, PRIMARY KEY (forest_id), FOREIGN KEY (forest_type_id) REFERENCES forest_type(forest_type_id)...
Display the total carbon sequestered and the average age of forests, grouped by forest type, for forests located in Asia, sorted by the average age in ascending order.
SELECT ft.forest_type_name, AVG(f.age) AS avg_age, SUM(f.carbon_sequestered) AS total_carbon_sequestered FROM forest_type ft INNER JOIN forest f ON ft.forest_type_id = f.forest_type_id INNER JOIN region r ON ft.region_id = r.region_id WHERE r.region_name = 'Asia' GROUP BY ft.forest_type_name ORDER BY avg_age ASC;
gretelai_synthetic_text_to_sql
CREATE TABLE rd_expenditures (expenditure_id INT, department TEXT, amount INT, expenditure_date DATE); INSERT INTO rd_expenditures (expenditure_id, department, amount, expenditure_date) VALUES (1, 'R&D-A', 150000, '2020-01-01'), (2, 'R&D-B', 200000, '2020-05-15'), (3, 'R&D-C', 0, '2020-12-31');
Calculate the total R&D expenditures for each department for the year 2020, including departments with zero expenditures, from the 'rd_expenditures' table.
SELECT department, COALESCE(SUM(amount), 0) AS total_expenditures FROM rd_expenditures WHERE expenditure_date BETWEEN '2020-01-01' AND '2020-12-31' GROUP BY department;
gretelai_synthetic_text_to_sql
CREATE TABLE rangers (id INT, name VARCHAR(255), region VARCHAR(255)); INSERT INTO rangers (id, name, region) VALUES (1, 'John', 'North America'), (2, 'Sophia', 'South America'), (3, 'Emma', 'Europe'), (4, 'Ethan', 'Africa'), (5, 'Ava', 'Asia');
Count the number of rangers in each region
SELECT region, COUNT(*) AS ranger_count FROM rangers GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE indian_marine_species (species VARCHAR(255), count INT); INSERT INTO indian_marine_species (species, count) VALUES ('Turtle', 150), ('Shark', 200), ('Manta Ray', 100), ('Dolphin', 120);
Find the total number of marine species and their observation counts in the Indian Ocean, excluding sharks and rays.
SELECT COUNT(DISTINCT species) AS species_count, SUM(count) AS total_count FROM indian_marine_species WHERE species NOT IN ('Shark', 'Manta Ray');
gretelai_synthetic_text_to_sql
CREATE TABLE user_posts (user_id INT, country VARCHAR(50)); INSERT INTO user_posts (user_id, country) VALUES (1, 'USA'), (2, 'Canada'), (3, 'Mexico'), (4, 'Brazil'), (5, 'Australia'), (6, 'India'), (7, 'China'), (8, 'Germany'), (9, 'France'), (10, 'UK');
What are the top 3 countries with the most number of users who have posted more than 10 times on "social_media"?
SELECT country, COUNT(DISTINCT user_id) as num_users FROM user_posts WHERE user_id IN (SELECT user_id FROM posts GROUP BY user_id, post_id HAVING COUNT(*) > 10) GROUP BY country ORDER BY num_users DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE textile_waste (id INT, country VARCHAR(50), waste_per_capita INT); INSERT INTO textile_waste (id, country, waste_per_capita) VALUES (1, 'Bangladesh', 20), (2, 'China', 15), (3, 'India', 18), (4, 'USA', 30);
Which country has the highest textile waste per capita?
SELECT country, MAX(waste_per_capita) as max_waste_per_capita FROM textile_waste GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE travel_advisories (country VARCHAR(255), level INT); INSERT INTO travel_advisories (country, level) VALUES ('USA', 1), ('Canada', 1), ('Mexico', 2), ('Kenya', 2);
Update the travel_advisories table to mark Kenya as a level 3 travel advisory country due to recent political unrest.
UPDATE travel_advisories SET level = 3 WHERE country = 'Kenya';
gretelai_synthetic_text_to_sql
CREATE TABLE Safety_Testing (id INT PRIMARY KEY, vehicle_id INT, test_type VARCHAR(50), score INT, date DATE); CREATE TABLE Vehicles (id INT PRIMARY KEY, make VARCHAR(50), model VARCHAR(50), year INT, type VARCHAR(50));
What is the average safety score for electric sedans released after 2019?
SELECT v.make, v.model, AVG(s.score) as avg_safety_score FROM Vehicles v INNER JOIN Safety_Testing s ON v.id = s.vehicle_id WHERE v.type = 'Sedan' AND v.year > 2019 AND s.test_type = 'Crash Test' GROUP BY v.make, v.model;
gretelai_synthetic_text_to_sql
CREATE TABLE movie_studios (studio_id INT, studio_name TEXT, country TEXT); INSERT INTO movie_studios (studio_id, studio_name, country) VALUES (1, 'Studio A', 'USA'), (2, 'Studio B', 'Canada'), (3, 'Studio C', 'UK'); CREATE TABLE movies (movie_id INT, title TEXT, release_date DATE, studio_id INT, revenue INT); INSERT I...
What is the total revenue of movies produced by Studio C in 2020 and 2021?
SELECT SUM(movies.revenue) FROM movies JOIN movie_studios ON movies.studio_id = movie_studios.studio_id WHERE movie_studios.studio_name = 'Studio C' AND YEAR(movies.release_date) BETWEEN 2020 AND 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE landfill_capacity (country VARCHAR(10), capacity INT); INSERT INTO landfill_capacity (country, capacity) VALUES ('CountryA', 20000), ('CountryB', 15000);
What is the difference in landfill capacity between 'CountryA' and 'CountryB' in the 'landfill_capacity' table?
SELECT capacity - (SELECT capacity FROM landfill_capacity WHERE country = 'CountryB') FROM landfill_capacity WHERE country = 'CountryA';
gretelai_synthetic_text_to_sql
CREATE TABLE students (id INT, name VARCHAR(100), department VARCHAR(50), publication_count INT); INSERT INTO students VALUES (1, 'Bob Brown', 'Humanities', 3);
What is the publication rate of graduate students in the Humanities department?
SELECT department, AVG(publication_count) FROM students WHERE department = 'Humanities' GROUP BY department;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, name VARCHAR(50), price DECIMAL(5, 2), sustainable BOOLEAN, material VARCHAR(50));
Insert a new product called "Natural Fiber Scarf" made of bamboo, priced at $24.99 and set it as sustainable.
INSERT INTO products (product_id, name, price, sustainable, material) VALUES (3, 'Natural Fiber Scarf', 24.99, TRUE, 'Bamboo');
gretelai_synthetic_text_to_sql
CREATE TABLE WeatherData (region VARCHAR(255), date DATE, temperature INT); INSERT INTO WeatherData (region, date, temperature) VALUES ('Canada', '2022-12-01', -10), ('Canada', '2022-12-02', -12), ('Russia', '2022-12-01', -15), ('Russia', '2022-12-02', -17), ('Sweden', '2022-12-01', -5), ('Sweden', '2022-12-02', -7);
List the bottom 2 regions with the lowest average temperature in December.
SELECT region, AVG(temperature) as Avg_Temperature FROM WeatherData WHERE date BETWEEN '2022-12-01' AND '2022-12-31' GROUP BY region ORDER BY Avg_Temperature ASC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE field_temperature (field_id INT, date DATE, temperature DECIMAL(5,2)); INSERT INTO field_temperature (field_id, date, temperature) VALUES (33333, '2022-02-01', 20.5), (33333, '2022-02-02', 21.0), (33333, '2022-02-14', 19.5), (33333, '2022-02-15', 20.0);
Delete the temperature data for field ID 33333 that was recorded before 2022-02-15.
DELETE FROM field_temperature WHERE field_id = 33333 AND date < '2022-02-15';
gretelai_synthetic_text_to_sql
CREATE TABLE Residential_Buildings (id INT, building_type VARCHAR(20), location VARCHAR(20), energy_efficiency_rating FLOAT); INSERT INTO Residential_Buildings (id, building_type, location, energy_efficiency_rating) VALUES (1, 'Apartment', 'City of Toronto', 82.5), (2, 'Townhouse', 'City of Toronto', 85.0), (3, 'Single...
What is the average energy efficiency rating for residential buildings in the City of Toronto?
SELECT AVG(energy_efficiency_rating) FROM Residential_Buildings WHERE location = 'City of Toronto';
gretelai_synthetic_text_to_sql
CREATE TABLE marine_conservation_orgs (org_name TEXT, country TEXT, year_founded INTEGER); INSERT INTO marine_conservation_orgs (org_name, country, year_founded) VALUES ('Ocean Conservancy', 'USA', 1972), ('National Marine Sanctuary Foundation', 'USA', 2000);
What is the average year of founding for marine conservation organizations in the USA?
SELECT AVG(year_founded) FROM marine_conservation_orgs WHERE country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE device_cost (country VARCHAR(20), device VARCHAR(20), cost FLOAT); INSERT INTO device_cost (country, device, cost) VALUES ('Brazil', 'Screen Reader', 100.00), ('Argentina', 'Adaptive Keyboard', 80.00), ('Colombia', 'Speech Recognition Software', 120.00);
What is the minimum cost of a device for accessibility in South America?
SELECT MIN(cost) FROM device_cost WHERE country = 'South America';
gretelai_synthetic_text_to_sql
CREATE TABLE wind_turbines (id INT, manufacturer VARCHAR(255), installed_year INT, capacity FLOAT);
Update the 'capacity' of all wind turbines manufactured by 'FutureEnergy' to 2.5 MW
UPDATE wind_turbines SET capacity = 2.5 WHERE manufacturer = 'FutureEnergy';
gretelai_synthetic_text_to_sql
CREATE TABLE cultural_competency_trainings (training_id INT, state VARCHAR(20)); INSERT INTO cultural_competency_trainings (training_id, state) VALUES (1, 'California'), (2, 'Texas'), (3, 'California'), (4, 'New York'), (5, 'Florida'), (6, 'Florida'); CREATE TABLE community_health_workers (worker_id INT, state VARCHAR(...
How many cultural competency trainings are in each state?
SELECT a.state, COUNT(*) FROM cultural_competency_trainings a JOIN community_health_workers b ON a.state = b.state GROUP BY a.state
gretelai_synthetic_text_to_sql
CREATE TABLE brands (brand_id INT, brand_name TEXT); CREATE TABLE cruelty_free_certifications (certification_id INT, brand_id INT, certification_date DATE);
How many cruelty-free certifications were granted to each brand in the past 2 years?
SELECT brand_name, COUNT(*) as certifications_in_past_2_years FROM brands JOIN cruelty_free_certifications ON brands.brand_id = cruelty_free_certifications.brand_id WHERE certification_date > DATEADD(year, -2, CURRENT_DATE) GROUP BY brand_name;
gretelai_synthetic_text_to_sql
CREATE TABLE CreativeAIs (id INT, name VARCHAR(50), safety_score INT, region VARCHAR(50)); INSERT INTO CreativeAIs (id, name, safety_score, region) VALUES (1, 'AI Painter', 85, 'North America'); INSERT INTO CreativeAIs (id, name, safety_score, region) VALUES (2, 'AI Music Composer', 90, 'Europe'); INSERT INTO CreativeA...
List all creative AI applications that have a safety score above 85, ordered by region
SELECT name FROM CreativeAIs WHERE safety_score > 85 ORDER BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE user_action_hist (user_id INT, user_country VARCHAR(50), ad_clicks INT);
What is the total number of users in the United States who have never clicked on any ads?
SELECT COUNT(user_id) FROM user_action_hist WHERE user_country = 'United States' AND ad_clicks = 0;
gretelai_synthetic_text_to_sql
CREATE TABLE monthly_water_usage (month INT, usage INT); INSERT INTO monthly_water_usage (month, usage) VALUES (1, 1000), (2, 1500), (3, 1200), (4, 1800), (5, 2000), (6, 2500), (7, 1500), (8, 1200), (9, 1000), (10, 1400), (11, 1800), (12, 2000);
What is the total water usage in the first half of the year compared to the second half?
SELECT SUM(CASE WHEN month <= 6 THEN usage ELSE 0 END) as first_half, SUM(CASE WHEN month > 6 THEN usage ELSE 0 END) as second_half FROM monthly_water_usage;
gretelai_synthetic_text_to_sql
CREATE TABLE artist_albums (artist_id INT, platform VARCHAR(50), album_count INT); INSERT INTO artist_albums (artist_id, platform, album_count) VALUES (1, 'Pandora', 5), (2, 'Pandora', 6);
_Get the names of the top 3 artists with the highest total number of streams on Pandora, from the Hip Hop genre, who have released at least 5 albums._
SELECT a.name FROM artists a JOIN artist_albums al ON a.id = al.artist_id WHERE a.genre = 'Hip Hop' AND al.platform = 'Pandora' AND a.album_count >= 5 GROUP BY a.name ORDER BY SUM(s.stream_count) DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Programs (ProgramID INT, ProgramName VARCHAR(50)); CREATE TABLE Donations (DonorID INT, ProgramID INT, Amount DECIMAL(10, 2)); INSERT INTO Programs (ProgramID, ProgramName) VALUES (1, 'Youth Mentoring'), (2, 'Food Bank'), (3, 'Climate Action'); INSERT INTO Donations (DonorID, ProgramID, Amount) VALUES (1, ...
Which programs have the highest average donation in the 'Programs' and 'Donations' tables?
SELECT Programs.ProgramName, AVG(Donations.Amount) as AverageDonation FROM Programs INNER JOIN Donations ON Programs.ProgramID = Donations.ProgramID GROUP BY Programs.ProgramID ORDER BY AverageDonation DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE CaseBilling (CaseID int, OpenDate date, BillingAmount decimal(10,2)); INSERT INTO CaseBilling (CaseID, OpenDate, BillingAmount) VALUES (1, '2020-01-01', 1000.00), (2, '2020-02-15', 2000.00), (3, '2020-03-05', 3000.00);
What is the total billing amount per case, ordered by case open date?
SELECT CaseID, OpenDate, BillingAmount, ROW_NUMBER() OVER (ORDER BY OpenDate) AS RowNum, SUM(BillingAmount) OVER (ORDER BY OpenDate) AS RunningTotal FROM CaseBilling;
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name TEXT, founder_gender TEXT, founded_date DATE); INSERT INTO companies (id, name, founder_gender, founded_date) VALUES (1, 'GreenTech', 'Female', '2017-01-01');
Count the number of female and male founders in companies founded in 2016 or later, and list their names and founding dates.
SELECT companies.name, companies.founded_date, COUNT(*) filter (where companies.founder_gender = 'Female') as num_female_founders, COUNT(*) filter (where companies.founder_gender = 'Male') as num_male_founders FROM companies WHERE companies.founded_date >= '2016-01-01' GROUP BY companies.name, companies.founded_date;
gretelai_synthetic_text_to_sql
CREATE TABLE hospitals (hospital_name VARCHAR(50), state VARCHAR(50), num_beds INTEGER, offers_maternity BOOLEAN); INSERT INTO hospitals (hospital_name, state, num_beds, offers_maternity) VALUES ('Hospital A', 'California', 250, TRUE), ('Hospital B', 'California', 150, FALSE), ('Hospital C', 'Texas', 300, TRUE), ('Hosp...
Calculate the minimum and maximum number of hospital beds for hospitals that offer maternity services, in each state.
SELECT state, MIN(num_beds) as min_beds, MAX(num_beds) as max_beds FROM hospitals WHERE offers_maternity = TRUE GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE producers (id INT, name VARCHAR(255), city VARCHAR(255), state VARCHAR(255)); INSERT INTO producers (id, name, city, state) VALUES (1, 'Producer A', 'Portland', 'OR'); CREATE TABLE production (id INT, producer_id INT, quantity INT);
Calculate total cannabis production (in pounds) for each producer in Oregon, grouped by city.
SELECT p.city, SUM(pr.quantity) as total_production FROM producers p INNER JOIN production pr ON p.id = pr.producer_id WHERE p.state = 'OR' GROUP BY p.city;
gretelai_synthetic_text_to_sql
CREATE TABLE Attorneys (attorney_id INT, name TEXT, region TEXT, join_date DATE); INSERT INTO Attorneys (attorney_id, name, region, join_date) VALUES (1, 'John Doe', 'New York', '2015-01-01'), (2, 'Jane Smith', 'California', '2018-05-01'), (3, 'Mike Johnson', 'Texas', '2016-03-15'); CREATE TABLE Cases (case_id INT, att...
What is the average billing amount for cases handled by attorneys from the 'Texas' region who have been with the firm for more than 5 years?
SELECT AVG(Cases.billing_amount) FROM Cases INNER JOIN Attorneys ON Cases.attorney_id = Attorneys.attorney_id WHERE Attorneys.region = 'Texas' AND Attorneys.join_date <= '2016-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE equipment_maintenance (id INT, incident_number VARCHAR(255), equipment_type VARCHAR(255), state VARCHAR(255), cost DECIMAL(10,2));
What is the average cost of military equipment maintenance per incident for each type of equipment in the last year?
SELECT equipment_type, AVG(cost) FROM equipment_maintenance WHERE date >= DATE_SUB(CURRENT_DATE, INTERVAL 12 MONTH) GROUP BY equipment_type;
gretelai_synthetic_text_to_sql
CREATE TABLE investor (investor_id INT, name VARCHAR(255), country VARCHAR(255)); INSERT INTO investor (investor_id, name, country) VALUES (1, 'Acme Corp', 'United States'); CREATE TABLE investment (investment_id INT, investor_id INT, strategy VARCHAR(255), impact_score FLOAT);
Delete all impact investments with an impact score lower than 70.0.
DELETE FROM investment WHERE impact_score < 70.0;
gretelai_synthetic_text_to_sql
CREATE TABLE clients (id INT, name TEXT, region TEXT); INSERT INTO clients (id, name, region) VALUES (1, 'Alice', 'austin'), (2, 'Bob', 'austin'), (3, 'Charlie', 'austin');
What is the count of clients in the 'austin' region?
SELECT COUNT(*) FROM clients WHERE region = 'austin';
gretelai_synthetic_text_to_sql
CREATE TABLE regulations (id INT, proposal TEXT, comments INT); INSERT INTO regulations (id, proposal, comments) VALUES (1, 'Regulation A', 50); INSERT INTO regulations (id, proposal, comments) VALUES (2, 'Regulation B', 100);
What is the total number of proposed regulations for the Transportation sector?
SELECT COUNT(*) FROM regulations WHERE proposal LIKE '%Transportation%';
gretelai_synthetic_text_to_sql
CREATE TABLE middle_east_region_table (id INT, mission_name VARCHAR(100), country VARCHAR(50), num_troops INT); INSERT INTO middle_east_region_table (id, mission_name, country, num_troops) VALUES (1, 'Operation Inherit Resolve', 'Jordan', 3000);
What is the maximum number of troops deployed for a peacekeeping mission in 'middle_east_region_table'?
SELECT MAX(num_troops) FROM middle_east_region_table;
gretelai_synthetic_text_to_sql
CREATE TABLE ports (port_id INT, port_name VARCHAR(50), avg_cargo_time INT); INSERT INTO ports (port_id, port_name, avg_cargo_time) VALUES (1, 'Port of Long Beach', 60), (2, 'Port of Los Angeles', 55), (3, 'Port of Oakland', 50);
What is the average cargo handling time in minutes for each port in the 'ports' table?
SELECT port_name, avg(avg_cargo_time) FROM ports GROUP BY port_name;
gretelai_synthetic_text_to_sql
CREATE TABLE events (id INT PRIMARY KEY, name VARCHAR(255), date DATE, location VARCHAR(255)); INSERT INTO events (id, name, date, location) VALUES (1, 'Community Meeting', '2023-03-22', 'City Hall');
Update the location of the event with id 1
UPDATE events SET location = 'Park' WHERE id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE ProgramCategories (CategoryID INT, Category VARCHAR(20)); INSERT INTO ProgramCategories (CategoryID, Category) VALUES (1, 'Education'), (2, 'Health'), (3, 'Environment'); CREATE TABLE Programs (ProgramID INT, CategoryID INT, ProgramName VARCHAR(50)); INSERT INTO Programs (ProgramID, CategoryID, ProgramName...
What's the average donation amount for each program category?
SELECT pc.Category, AVG(d.DonationAmount) AS AverageDonationAmount FROM ProgramCategories pc JOIN Programs p ON pc.CategoryID = p.CategoryID JOIN Donations d ON p.ProgramID = d.ProgramID GROUP BY pc.Category;
gretelai_synthetic_text_to_sql
CREATE TABLE biotech_funding (id INT PRIMARY KEY, startup_name VARCHAR(100), funding_round VARCHAR(50), funding_amount INT);
Delete the 'biotech_funding' record with 'id' = 7
DELETE FROM biotech_funding WHERE id = 7;
gretelai_synthetic_text_to_sql
CREATE TABLE security_incidents (id INT, department VARCHAR(255), resolution_time INT, timestamp DATETIME);
What is the minimum time to resolve a security incident for each department in the last year?
SELECT department, MIN(resolution_time) as min_resolution_time FROM security_incidents WHERE timestamp >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY department;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists 'disease_data' (id INT, state TEXT, disease TEXT, prevalence INT, PRIMARY KEY(id));
Remove records where prevalence > 1000 from 'disease_data'
DELETE FROM 'disease_data' WHERE prevalence > 1000;
gretelai_synthetic_text_to_sql
CREATE TABLE train_routes (id INT, route_name VARCHAR(255), is_accessible BOOLEAN, fare DECIMAL(5,2)); INSERT INTO train_routes (id, route_name, is_accessible, fare) VALUES (1, 'Red Line', TRUE, 2.50), (2, 'Blue Line', FALSE, 3.00), (3, 'Green Line', TRUE, 1.75);
Find all wheelchair-accessible train routes and their respective fare prices.
SELECT route_name, fare FROM train_routes WHERE is_accessible = TRUE
gretelai_synthetic_text_to_sql
CREATE TABLE customer_complaints (complaint_id INT, complaint_date DATE, plan_id INT, complaint_description VARCHAR(50));
How many customer complaints were there in total for each mobile plan in the past month?
SELECT plan_id, COUNT(complaint_id) as total_complaints FROM customer_complaints WHERE MONTH(complaint_date) = MONTH(current_date) - 1 GROUP BY plan_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Projects (id INT, name TEXT, region TEXT, cost FLOAT); INSERT INTO Projects (id, name, region, cost) VALUES (1, 'ProjectA', 'Caribbean', 1500000.00), (2, 'ProjectB', 'Caribbean', 1200500.75), (3, 'ProjectC', 'Caribbean', 1700000.50);
Which public works project in 'Caribbean' region has the lowest construction cost?
SELECT name, MIN(cost) FROM Projects WHERE region = 'Caribbean';
gretelai_synthetic_text_to_sql
CREATE TABLE hotel_reviews_3 (hotel_id INT, guest_rating INT, review_date DATE, review_text TEXT, city TEXT); INSERT INTO hotel_reviews_3 (hotel_id, guest_rating, review_date, review_text, city) VALUES (5, 8, '2021-09-03', 'Wonderful stay', 'Paris'), (6, 9, '2021-09-05', 'Excellent experience', 'Paris');
What is the average local employment for hotels in Paris?
SELECT AVG(ei.local_employment) FROM economic_impact ei INNER JOIN hotel_reviews_3 hr ON ei.hotel_id = hr.hotel_id WHERE hr.city = 'Paris';
gretelai_synthetic_text_to_sql
CREATE TABLE military_tech_cost (id INT, tech VARCHAR, cost INT); INSERT INTO military_tech_cost (id, tech, cost) VALUES (1, 'Stealth Helicopter', 20000000), (2, 'AI-Powered Drone', 15000000), (3, 'Electric Tank', 10000000);
Display the military technologies and their development costs, and calculate the total development cost.
SELECT tech, cost, SUM(cost) OVER () as total_cost FROM military_tech_cost;
gretelai_synthetic_text_to_sql
CREATE TABLE curators (id INT, name TEXT); CREATE TABLE exhibitions (id INT, title TEXT, cancelled BOOLEAN, curator_id INT); INSERT INTO curators (id, name) VALUES (1, 'John Doe'), (2, 'Jane Smith'); INSERT INTO exhibitions (id, title, cancelled, curator_id) VALUES (1, 'Expressionism', false, 1), (2, 'Cubism', true, 1)...
How many exhibitions have been curated by John Doe, including cancelled ones?
SELECT COUNT(*) FROM exhibitions e INNER JOIN curators c ON e.curator_id = c.id WHERE c.name = 'John Doe';
gretelai_synthetic_text_to_sql
CREATE TABLE oceanographic_research_stations (id INT, station_name VARCHAR(50), region VARCHAR(20), min_depth INT, max_depth INT, year_established INT, year_decommissioned INT);INSERT INTO oceanographic_research_stations (id, station_name, region, min_depth, max_depth, year_established, year_decommissioned) VALUES (1, ...
List all the oceanographic research stations that have been established in the Indian Ocean and are still active.
SELECT station_name FROM oceanographic_research_stations WHERE region = 'Indian' AND year_decommissioned IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE emergency_response (incident_type VARCHAR(255), response_time INT);
Insert a new record into the emergency_response table for the 'Rescue' incident type and a response_time of 8 minutes
INSERT INTO emergency_response (incident_type, response_time) VALUES ('Rescue', 8);
gretelai_synthetic_text_to_sql
CREATE TABLE TraditionalArtsEvents (id INT, city VARCHAR(50), country VARCHAR(50), event_name VARCHAR(100), event_date DATE); INSERT INTO TraditionalArtsEvents (id, city, country, event_name, event_date) VALUES (1, 'Kyoto', 'Japan', 'Kabuki', '2023-04-01'), (2, 'Kyoto', 'Japan', 'Ikebana', '2023-05-15');
What traditional arts events are planned for Kyoto in the next 6 months?
SELECT event_name FROM TraditionalArtsEvents WHERE city = 'Kyoto' AND event_date BETWEEN CURDATE() AND DATE_ADD(CURDATE(), INTERVAL 6 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (id INT, name TEXT, country TEXT, hours_served INT);
List the top 3 countries with the highest number of volunteer hours in Q1 of 2022.
SELECT country, SUM(hours_served) as total_hours FROM volunteers WHERE QUARTER(volunteer_date) = 1 AND YEAR(volunteer_date) = 2022 GROUP BY country ORDER BY total_hours DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (id INT, first_name VARCHAR(50), last_name VARCHAR(50), training_completion_date DATE, accessibility_training_completion_date DATE);
List the employees who have not completed training related to accessibility
SELECT id, first_name, last_name FROM Employees WHERE accessibility_training_completion_date IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE system_status (system_id INT PRIMARY KEY, status_date DATE, is_online BOOLEAN); INSERT INTO system_status (system_id, status_date, is_online) VALUES (1, '2022-04-01', TRUE), (2, '2022-04-10', FALSE), (3, '2022-04-20', FALSE);
Which systems have been offline for more than 10 days?
SELECT system_id, status_date FROM system_status WHERE is_online = FALSE AND status_date < DATE_SUB(CURRENT_DATE, INTERVAL 10 DAY);
gretelai_synthetic_text_to_sql
CREATE TABLE broadband_subscribers (subscriber_id INT, state VARCHAR(20)); INSERT INTO broadband_subscribers (subscriber_id, state) VALUES (1, 'New York'), (2, 'Texas'), (3, 'New York');
How many broadband subscribers are there in the state of New York?
SELECT COUNT(*) FROM broadband_subscribers WHERE state = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE crops_country (id INT, name VARCHAR(50), country VARCHAR(50), year INT, production INT); INSERT INTO crops_country (id, name, country, year, production) VALUES (1, 'Rice', 'India', 2020, 8000), (2, 'Wheat', 'Pakistan', 2020, 6000), (3, 'Corn', 'Mexico', 2020, 4000), (4, 'Potatoes', 'Peru', 2020, 3000), (5,...
What is the production of crops by country in a given year?
SELECT country, name, SUM(production) as total_production FROM crops_country GROUP BY country, name;
gretelai_synthetic_text_to_sql
CREATE TABLE europium_production (country VARCHAR(20), quantity INT); INSERT INTO europium_production (country, quantity) VALUES ('China', 1200), ('USA', 450), ('Australia', 180), ('Russia', 600);
List all the distinct europium production quantities and countries.
SELECT DISTINCT country, quantity FROM europium_production;
gretelai_synthetic_text_to_sql
CREATE TABLE centers (center_id INT, center_name TEXT, community TEXT, population INT, year INT); INSERT INTO centers (center_id, center_name, community, population, year) VALUES (1, 'Health A', 'Riverview', 3000, 2018), (2, 'Health B', 'Riverview', 3500, 2019), (3, 'Health C', 'Seaside', 2500, 2018);
What is the population trend for each community health center?
SELECT community, year, population, LAG(population, 1) OVER (PARTITION BY community ORDER BY year) AS previous_year_population FROM centers ORDER BY community, year;
gretelai_synthetic_text_to_sql
CREATE TABLE ProductionTargets (WellID int, ProductionDate date, TargetBarrelsPerDay decimal(5, 2)); INSERT INTO ProductionTargets (WellID, ProductionDate, TargetBarrelsPerDay) VALUES (501, '2022-01-01', 1000), (502, '2022-01-01', 1200), (501, '2022-01-02', 1100);
Increase the production target for Well ID 501 by 10% in the ProductionTargets table.
UPDATE ProductionTargets SET TargetBarrelsPerDay = 1000 * 1.10 WHERE WellID = 501;
gretelai_synthetic_text_to_sql
CREATE TABLE african_tourists (id INT, country VARCHAR(20), continent VARCHAR(20), year INT, visitors INT); INSERT INTO african_tourists (id, country, continent, year, visitors) VALUES (1, 'Egypt', 'Africa', 2019, 1500000), (2, 'South Africa', 'Africa', 2019, 2000000), (3, 'Morocco', 'Africa', 2019, 1000000);
What is the total number of tourists who visited the African continent in 2019?
SELECT SUM(visitors) as total_visitors FROM african_tourists WHERE continent = 'Africa' AND year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE students (student_id INT, gender_identity VARCHAR(255), hours_spent_on_open_pedagogy_programs INT); INSERT INTO students (student_id, gender_identity, hours_spent_on_open_pedagogy_programs) VALUES (1, 'Transgender', 80), (2, 'Genderqueer', 70), (3, 'Non-binary', 90);
What is the maximum number of hours spent on open pedagogy programs by students who identify as LGBTQ+, broken down by their gender identity?
SELECT gender_identity, MAX(hours_spent_on_open_pedagogy_programs) as max_hours FROM students WHERE gender_identity LIKE '%LGBTQ%' GROUP BY gender_identity;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_adaptation_projects (year INT, region VARCHAR(255), project VARCHAR(255)); INSERT INTO climate_adaptation_projects (year, region, project) VALUES (2018, 'Asia', 'Sea Wall A'), (2019, 'Africa', 'Drought Resistant Crops B'), (2019, 'Asia', 'Flood Early Warning C');
How many climate adaptation projects were completed in 2018 and 2019, grouped by region?
SELECT region, COUNT(*) as project_count FROM climate_adaptation_projects WHERE year IN (2018, 2019) GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE skincare_products (id INT, brand VARCHAR(255), product_category VARCHAR(255), contains_fragrance BOOLEAN, is_natural BOOLEAN);
What is the percentage of skincare products that contain fragrance, grouped by brand and categorized as natural or synthetic?
SELECT brand, 100.0 * AVG(CASE WHEN contains_fragrance THEN 1 ELSE 0 END) as percentage, product_category FROM skincare_products GROUP BY brand, product_category;
gretelai_synthetic_text_to_sql
CREATE TABLE hotel_info_2 (hotel_id INT, city TEXT); INSERT INTO hotel_info_2 (hotel_id, city) VALUES (7, 'Kyoto'), (8, 'Osaka');
What is the total number of virtual tour views for hotels in Kyoto?
SELECT SUM(vt.num_views) FROM virtual_tours vt INNER JOIN hotel_info_2 hi ON vt.hotel_id = hi.hotel_id WHERE hi.city = 'Kyoto';
gretelai_synthetic_text_to_sql
CREATE TABLE Manufacturers (ManufacturerID int, ManufacturerName varchar(50), Region varchar(50)); INSERT INTO Manufacturers (ManufacturerID, ManufacturerName, Region) VALUES (1, 'EcoStitch', 'Southeast'); INSERT INTO Manufacturers (ManufacturerID, ManufacturerName, Region) VALUES (2, 'GreenThreads', 'Northeast'); CREA...
Which manufacturers in the Southeast region produce the most items made from recycled materials, ordered by the total quantity?
SELECT m.ManufacturerName, SUM(pm.Quantity) as TotalQuantity FROM Manufacturers m INNER JOIN ProductManufacturers pm ON m.ManufacturerID = pm.ManufacturerID INNER JOIN Products p ON pm.ProductID = p.ProductID WHERE m.Region = 'Southeast' AND p.RecycledMaterials = true GROUP BY m.ManufacturerName ORDER BY TotalQuantity ...
gretelai_synthetic_text_to_sql
CREATE TABLE Restaurants (restaurant_id INT, city VARCHAR(50), revenue INT); INSERT INTO Restaurants (restaurant_id, city, revenue) VALUES (1, 'New York', 5000), (2, 'Los Angeles', 6000), (3, 'New York', 7000);
What is the total revenue for each city?
SELECT city, SUM(revenue) as total_revenue FROM Restaurants GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE restaurant_data (id INT, restaurant_name VARCHAR(255), revenue INT, number_of_inspections INT); INSERT INTO restaurant_data (id, restaurant_name, revenue, number_of_inspections) VALUES (1, 'Bella Italia', 25000, 4); INSERT INTO restaurant_data (id, restaurant_name, revenue, number_of_inspections) VALUES (2...
Find the average revenue of restaurants with more than 3 inspections
SELECT restaurant_name, AVG(revenue) FROM restaurant_data WHERE number_of_inspections > 3 GROUP BY restaurant_name;
gretelai_synthetic_text_to_sql