context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE army_table (id INT, name VARCHAR(100), country VARCHAR(50), num_soldiers INT); INSERT INTO army_table (id, name, country, num_soldiers) VALUES (1, 'US Army', 'USA', 475000);
Select the total number of soldiers in the 'army_table'
SELECT SUM(num_soldiers) FROM army_table WHERE name = 'US Army';
gretelai_synthetic_text_to_sql
CREATE TABLE countries (id INT PRIMARY KEY, name VARCHAR(50), continent VARCHAR(50), certified_sustainable BOOLEAN); INSERT INTO countries (id, name, continent, certified_sustainable) VALUES (1, 'India', 'Asia', TRUE); CREATE TABLE tourism (id INT PRIMARY KEY, country VARCHAR(50), destination VARCHAR(50), certified_sustainable BOOLEAN); INSERT INTO tourism (id, country, destination, certified_sustainable) VALUES (1, 'India', 'Japan', TRUE);
What is the total number of tourists visiting Japan from India with sustainable tourism certifications?
SELECT COUNT(*) FROM tourism WHERE country = 'India' AND destination = 'Japan' AND certified_sustainable = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE projects (project_id INT, project_name TEXT, project_type TEXT, start_date DATE, end_date DATE, region TEXT); INSERT INTO projects (project_id, project_name, project_type, start_date, end_date, region) VALUES (1, 'Building Schools', 'community development', '2020-01-01', '2020-12-31', 'North America');
How many community development projects were completed in North America in 2020?
SELECT COUNT(*) as total_projects FROM projects WHERE project_type = 'community development' AND region = 'North America' AND start_date <= '2020-12-31' AND end_date >= '2020-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE Atlantic_Marine_Species (species_name TEXT, population INT, is_affected_by_pollution BOOLEAN); INSERT INTO Atlantic_Marine_Species (species_name, population, is_affected_by_pollution) VALUES ('Blue Whale', 12000, true), ('Dolphin', 54000, false), ('Shark', 36000, true);
Calculate the total population of marine species affected by pollution in the Atlantic Ocean.
SELECT SUM(population) FROM Atlantic_Marine_Species WHERE is_affected_by_pollution = true;
gretelai_synthetic_text_to_sql
CREATE TABLE districts (id INT PRIMARY KEY, name VARCHAR(255));CREATE TABLE traffic_violations (id INT PRIMARY KEY, district_id INT, FOREIGN KEY (district_id) REFERENCES districts(id)); INSERT INTO districts (id, name) VALUES (1, 'Downtown'); INSERT INTO districts (id, name) VALUES (2, 'Midtown');
Show the number of traffic violations issued in each police district from the 'traffic_violations' database.
SELECT districts.name, COUNT(traffic_violations.id) as violation_count FROM districts INNER JOIN traffic_violations ON districts.id = traffic_violations.district_id GROUP BY districts.name;
gretelai_synthetic_text_to_sql
CREATE TABLE hospitals (id INT, name TEXT, location TEXT, beds INT, rural BOOLEAN, built DATE); INSERT INTO hospitals (id, name, location, beds, rural, built) VALUES (1, 'Hospital A', 'Florida', 120, true, '2006-01-01'), (2, 'Hospital B', 'Florida', 150, true, '2007-01-01');
What is the minimum number of hospital beds in rural hospitals of Florida that were built after 2005?
SELECT MIN(beds) FROM hospitals WHERE location = 'Florida' AND rural = true AND built > '2005-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_trenches (name TEXT, average_depth REAL); INSERT INTO ocean_trenches (name, average_depth) VALUES ('Mariana Trench', 10994), ('Tonga Trench', 10820), ('Kuril-Kamchatka Trench', 10542), ('Philippine Trench', 10540), ('Kermadec Trench', 10047);
List the top 3 deepest oceanic trenches.
SELECT * FROM ocean_trenches ORDER BY average_depth DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE cosmetics (product_id INT, product_name VARCHAR(100), product_type VARCHAR(50), is_cruelty_free BOOLEAN, consumer_preference_score INT); INSERT INTO cosmetics (product_id, product_name, product_type, is_cruelty_free, consumer_preference_score) VALUES (1, 'Lipstick A', 'Lipstick', TRUE, 80), (2, 'Foundation B', 'Foundation', FALSE, 90), (3, 'Mascara C', 'Mascara', TRUE, 85), (4, 'Eyeshadow D', 'Eyeshadow', TRUE, 70), (5, 'Blush E', 'Blush', FALSE, 95); CREATE TABLE ingredient_sourcing (ingredient_id INT, ingredient_name VARCHAR(100), sourcing_country VARCHAR(50), is_organic BOOLEAN); INSERT INTO ingredient_sourcing (ingredient_id, ingredient_name, sourcing_country, is_organic) VALUES (1, 'Rosehip Oil', 'Brazil', TRUE), (2, 'Shea Butter', 'Ghana', TRUE), (3, 'Jojoba Oil', 'Argentina', TRUE), (4, 'Coconut Oil', 'Philippines', FALSE), (5, 'Aloe Vera', 'Mexico', TRUE);
Count the number of cosmetics that have a sourcing country of 'Brazil'.
SELECT COUNT(*) FROM cosmetics INNER JOIN ingredient_sourcing ON cosmetics.product_id = ingredient_sourcing.ingredient_id WHERE sourcing_country = 'Brazil';
gretelai_synthetic_text_to_sql
CREATE TABLE students (id INT, name VARCHAR(100), field_of_study VARCHAR(50), country VARCHAR(50)); INSERT INTO students VALUES (1, 'Alice Johnson', 'Computer Science', 'USA');
How many graduate students are enrolled in STEM fields per country?
SELECT country, COUNT(*) FROM students WHERE field_of_study IN ('Computer Science', 'Mathematics', 'Engineering', 'Physics') GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE ports (port_id INT, port_name VARCHAR(255), country VARCHAR(255)); INSERT INTO ports VALUES (1, 'Port of Shanghai', 'China'), (2, 'Port of Oakland', 'USA'); CREATE TABLE cargo (cargo_id INT, port_id INT, weight FLOAT, handling_date DATE); INSERT INTO cargo VALUES (1, 1, 5000, '2021-01-01'), (2, 2, 4000, '2021-12-31'), (3, 1, 7000, '2020-12-31');
Delete cargo records with handling date before '2022-01-01'
DELETE FROM cargo WHERE handling_date < '2022-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE reo_production (id INT PRIMARY KEY, reo_type VARCHAR(50), production_year INT, impurity_level FLOAT);
Delete all refined Rare Earth Oxides (REO) records where impurity level is greater than 200 ppm from the reo_production table
DELETE FROM reo_production WHERE impurity_level > 200;
gretelai_synthetic_text_to_sql
CREATE TABLE Resource_Management (id INT, project VARCHAR(100), location VARCHAR(100), budget FLOAT, start_date DATE); INSERT INTO Resource_Management (id, project, location, budget, start_date) VALUES (1, 'Arctic Mining', 'Canada', 700000, '2019-01-01'); INSERT INTO Resource_Management (id, project, location, budget, start_date) VALUES (2, 'Forest Conservation', 'Finland', 600000, '2020-06-01'); INSERT INTO Resource_Management (id, project, location, budget, start_date) VALUES (3, 'Oceanic Preservation', 'Finland', 550000, '2019-01-01');
What are the projects and budgets of resource management initiatives in Canada or Finland, with a budget greater than 500,000, that started after 2018?
SELECT project, budget FROM Resource_Management WHERE (location = 'Canada' OR location = 'Finland') AND budget > 500000 AND start_date > '2018-12-31'
gretelai_synthetic_text_to_sql
CREATE TABLE fishing_vessels (id INT, name VARCHAR(255), type VARCHAR(255), location VARCHAR(255)); INSERT INTO fishing_vessels (id, name, type, location) VALUES (1, 'F/V Nautilus', 'Trawler', 'Indian Ocean'), (2, 'F/V Neptune', 'Longliner', 'Pacific Ocean');
Get the total number of fishing vessels in the Pacific.
SELECT COUNT(*) FROM fishing_vessels WHERE location = 'Pacific Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE regulatory_frameworks (framework_id INT, country VARCHAR(100), framework VARCHAR(100)); INSERT INTO regulatory_frameworks (framework_id, country, framework) VALUES (1, 'United States', 'Framework1'), (2, 'Japan', 'Framework2'), (3, 'France', 'Framework3');
Show all regulatory frameworks for digital assets in the United States and Japan?
SELECT framework_id, country, framework FROM regulatory_frameworks WHERE country IN ('United States', 'Japan');
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, program TEXT, country TEXT, donation_amount DECIMAL(10, 2)); INSERT INTO donations VALUES (1, 'Education', 'USA', 200.00), (2, 'Healthcare', 'USA', 300.00), (3, 'Environment', 'Canada', 400.00);
What is the total donation amount per program in the United States?
SELECT program, SUM(donation_amount) FROM donations WHERE country = 'USA' GROUP BY program;
gretelai_synthetic_text_to_sql
CREATE TABLE StreamingData (stream_id INT, stream_date DATE, song_id INT, artist_name VARCHAR(255), streams INT); INSERT INTO StreamingData (stream_id, stream_date, song_id, artist_name, streams) VALUES (1, '2022-08-01', 1, 'Rihanna', 100000), (2, '2022-08-02', 2, 'The Weeknd', 120000), (3, '2022-08-03', 3, 'Beyoncé', 90000), (4, '2022-08-04', 4, 'Ariana Grande', 80000), (5, '2022-08-05', 5, 'Selena Gomez', 70000);
Who are the top 3 artists with the most streams in the month of August?
SELECT artist_name, SUM(streams) as total_streams FROM StreamingData WHERE MONTH(stream_date) = 8 GROUP BY artist_name ORDER BY total_streams DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Suppliers (SupplierID INT, SupplierName VARCHAR(50), Location VARCHAR(50)); INSERT INTO Suppliers (SupplierID, SupplierName, Location) VALUES (1, 'Supplier A', 'Northeast'), (2, 'Supplier B', 'Southeast'); CREATE TABLE Products (ProductID INT, ProductName VARCHAR(50), SupplierID INT, Category VARCHAR(50)); INSERT INTO Products (ProductID, ProductName, SupplierID, Category) VALUES (1, 'Beef', 1, 'Meat'), (2, 'Chicken', 1, 'Meat'), (3, 'Tofu', 2, 'Vegetables'), (4, 'Pork', 2, 'Meat'); CREATE TABLE Sales (SaleID INT, ProductID INT, Quantity INT); INSERT INTO Sales (SaleID, ProductID, Quantity) VALUES (1, 1, 10), (2, 2, 15), (3, 3, 20);
What is the total quantity of vegetables sold in the Northeast region?
SELECT SUM(Quantity) FROM Sales JOIN Products ON Sales.ProductID = Products.ProductID JOIN Suppliers ON Products.SupplierID = Suppliers.SupplierID WHERE Category = 'Vegetables' AND Suppliers.Location = 'Northeast';
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (hotel_id INT, name TEXT, country TEXT, has_ecofriendly BOOLEAN, price INT); INSERT INTO hotels (hotel_id, name, country, has_ecofriendly, price) VALUES (1, 'Eco Lodge', 'Brazil', true, 120), (2, 'Green Hotel', 'USA', true, 180);
What is the average hotel price for eco-friendly hotels in Brazil?
SELECT AVG(price) FROM hotels WHERE has_ecofriendly = true AND country = 'Brazil';
gretelai_synthetic_text_to_sql
CREATE TABLE Cities (CityID int, CityName varchar(255), State varchar(255), NoOfHospitals int); INSERT INTO Cities (CityID, CityName, State, NoOfHospitals) VALUES (1, 'Los Angeles', 'California', 5), (2, 'San Francisco', 'California', 3);
What is the average number of hospitals per city in the state of California?
SELECT AVG(NoOfHospitals) FROM Cities WHERE State = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE incl_hsg_policy (policy_id INT, area VARCHAR(20), units INT); INSERT INTO incl_hsg_policy (policy_id, area, units) VALUES (1, 'urban', 50);
What is the total number of units with inclusive housing policies in the 'urban' area?
SELECT SUM(units) FROM incl_hsg_policy WHERE area = 'urban';
gretelai_synthetic_text_to_sql
CREATE TABLE Disability_Support_Programs (id INT, country VARCHAR(50), budget DECIMAL(10,2), adjustment_date DATE); CREATE TABLE Adjustments (id INT, program_id INT, adjustment_amount DECIMAL(10,2), adjustment_date DATE); CREATE TABLE Support_Programs (id INT, program_name VARCHAR(100), country VARCHAR(50));
What is the total budget allocated for disability support programs in each country, including any adjustments made in the last quarter, and the number of support programs offered in each country?
SELECT s.country, SUM(dsp.budget + COALESCE(adj.adjustment_amount, 0)) as total_budget, COUNT(sp.id) as support_program_count FROM Disability_Support_Programs dsp INNER JOIN Adjustments adj ON dsp.id = adj.program_id AND adj.adjustment_date >= DATEADD(quarter, -1, GETDATE()) INNER JOIN Support_Programs sp ON dsp.id = sp.program_id GROUP BY s.country;
gretelai_synthetic_text_to_sql
CREATE TABLE regions (id INT, name VARCHAR(255)); CREATE TABLE public_works (id INT, name VARCHAR(255), location VARCHAR(255), budget FLOAT, region_id INT); INSERT INTO regions (id, name) VALUES (1, 'West'), (2, 'Central'), (3, 'East'); INSERT INTO public_works (id, name, location, budget, region_id) VALUES (1, 'Park', 'California', 1200000, 1);
Which regions have the most public works projects?
SELECT r.name as region, COUNT(pw.id) as num_projects FROM regions r JOIN public_works pw ON r.id = pw.region_id GROUP BY r.name ORDER BY num_projects DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE space_missions (id INT, name VARCHAR(255), mission_type VARCHAR(255), country VARCHAR(255), start_date DATE, end_date DATE); INSERT INTO space_missions (id, name, mission_type, country, start_date, end_date) VALUES (1, 'Apollo 11', 'Human', 'USA', '1969-07-16', '1969-07-24'); INSERT INTO space_missions (id, name, mission_type, country, start_date, end_date) VALUES (2, 'Mars Science Laboratory', 'Robotic', 'USA', '2011-11-26', '2012-08-06'); INSERT INTO space_missions (id, name, mission_type, country, start_date, end_date) VALUES (3, 'Mars Orbiter Mission', 'Robotic', 'India', '2013-11-05', NULL);
What are the names and countries of the Mars missions that have not yet ended?
SELECT name, country FROM space_missions WHERE end_date IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE train_models (model_id INT, model_name VARCHAR(255));CREATE TABLE failures (failure_id INT, model_id INT, failure_time DATETIME);
What is the average time between failures for each train model in the Berlin S-Bahn system?
SELECT model_id, model_name, AVG(failure_time - LAG(failure_time) OVER (PARTITION BY model_id ORDER BY failure_time)) as average_time_between_failures FROM train_models tm JOIN failures f ON tm.model_id = f.model_id;
gretelai_synthetic_text_to_sql
CREATE TABLE UnionMembers (id INT, union_name VARCHAR(50), country VARCHAR(50), member_count INT); INSERT INTO UnionMembers (id, union_name, country, member_count) VALUES (1, 'United Steelworkers', 'USA', 200000), (2, 'UNITE HERE', 'USA', 300000), (3, 'TUC', 'UK', 6000000), (4, 'CUPE', 'Canada', 650000), (5, 'USW', 'Canada', 120000), (6, 'CGT', 'France', 670000), (7, 'CFDT', 'France', 630000), (8, 'IG Metall', 'Germany', 2300000), (9, 'ver.di', 'Germany', 1800000), (10, 'CC.OO.', 'Spain', 1200000);
What is the total number of members in unions in France, Germany, and Spain?
SELECT SUM(member_count) as total_members FROM UnionMembers WHERE country IN ('France', 'Germany', 'Spain');
gretelai_synthetic_text_to_sql
CREATE TABLE autonomous_vehicles (id INT, vehicle_type VARCHAR(255), manufacturer VARCHAR(255), avg_speed DECIMAL(5,2));
What is the average speed of electric vehicles in the 'autonomous_vehicles' table, grouped by their 'vehicle_type'?
SELECT vehicle_type, AVG(avg_speed) FROM autonomous_vehicles WHERE manufacturer = 'Tesla' GROUP BY vehicle_type;
gretelai_synthetic_text_to_sql
CREATE SCHEMA ratings; CREATE TABLE ratings (rating_id INT, program_id INT, user_id INT, gender VARCHAR(255), rating DECIMAL(2,1)); INSERT INTO ratings (rating_id, program_id, user_id, gender, rating) VALUES (1, 1, 1, 'Female', 4.5), (2, 1, 2, 'Male', 3.5), (3, 2, 3, 'Non-binary', 4.0);
What is the average rating by gender for a specific program?
SELECT gender, AVG(rating) as average_rating FROM ratings WHERE program_id = 1 GROUP BY gender;
gretelai_synthetic_text_to_sql
CREATE TABLE HealthEquity (HEID int, CHWID int, Score int);CREATE TABLE CulturalCompetency (CCID int, CHWID int, Score int);
What is the health equity metric score and the cultural competency score of each community health worker?
SELECT CHWID, AVG(HealthEquity.Score) as AvgHealthEquityScore, AVG(CulturalCompetency.Score) as AvgCulturalCompetencyScore FROM HealthEquity JOIN CulturalCompetency ON HealthEquity.CHWID = CulturalCompetency.CHWID GROUP BY CHWID;
gretelai_synthetic_text_to_sql
CREATE TABLE resources (id INT PRIMARY KEY, name TEXT, quantity INT, city TEXT, state TEXT); INSERT INTO resources (id, name, quantity, city, state) VALUES (2, 'Medicine X', 200, 'Rural Clinic', 'TX');
What is the current quantity of 'Medicine X' at the 'Rural Clinic'?
SELECT quantity FROM resources WHERE name = 'Medicine X' AND city = 'Rural Clinic';
gretelai_synthetic_text_to_sql
CREATE TABLE events (id INT, name TEXT, category TEXT, capacity INT); INSERT INTO events (id, name, category, capacity) VALUES (1, 'Play', 'theater', 600), (2, 'Concert', 'music', 200), (3, 'Musical', 'theater', 800); CREATE TABLE event_attendance (event_id INT, attendees INT); INSERT INTO event_attendance (event_id, attendees) VALUES (1, 550), (2, 180), (3, 750);
What is the average attendance for events in the 'theater' category with a capacity greater than 500?
SELECT AVG(event_attendance.attendees) FROM event_attendance JOIN events ON event_attendance.event_id = events.id WHERE events.category = 'theater' AND capacity > 500;
gretelai_synthetic_text_to_sql
CREATE TABLE movies (id INT, title VARCHAR(255), rating FLOAT, country VARCHAR(255)); INSERT INTO movies (id, title, rating, country) VALUES (1, 'Movie1', 4.5, 'USA'), (2, 'Movie2', 3.2, 'Canada');
What is the average rating of movies produced in the United States?
SELECT AVG(rating) FROM movies WHERE country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE paper (id INT, student_id INT); INSERT INTO paper (id, student_id) VALUES (1, 1), (2, 2), (3, 3); CREATE TABLE student (id INT, name TEXT); INSERT INTO student (id, name) VALUES (1, 'Alice'), (2, 'Bob'), (3, 'Charlie'), (4, 'Diana');
List the names of all graduate students who have not published an academic paper.
SELECT name FROM student WHERE id NOT IN (SELECT student_id FROM paper);
gretelai_synthetic_text_to_sql
CREATE TABLE Attorneys (ID INT, Name VARCHAR(255), Wins INT, Losses INT); INSERT INTO Attorneys (ID, Name, Wins, Losses) VALUES (1, 'John Smith', 20, 10), (2, 'Jane Doe', 25, 15), (3, 'Bob Johnson', 30, 20);
Who are the top 3 attorneys with the most cases won in the last year?
SELECT Name, ROW_NUMBER() OVER (ORDER BY Wins DESC) as Rank FROM Attorneys WHERE YEAR(LastCaseDate) = YEAR(CURRENT_DATE) - 1 HAVING Rank <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Environmental_Impact (Mine_ID INT, Pollutant VARCHAR(10), Amount FLOAT, Date DATE); INSERT INTO Environmental_Impact (Mine_ID, Pollutant, Amount, Date) VALUES (1, 'CO2', 1200, '2020-01-01'), (2, 'SO2', 800, '2020-01-02'), (1, 'SO2', 900, '2020-01-01');
Sum the amount of CO2 and SO2 emissions for each coal mine.
SELECT e.Mine_ID, SUM(e.Amount) FROM Environmental_Impact e INNER JOIN Mining_Operations m ON e.Mine_ID = m.Mine_ID WHERE m.Material = 'Coal' AND e.Pollutant IN ('CO2', 'SO2') GROUP BY e.Mine_ID;
gretelai_synthetic_text_to_sql
CREATE TABLE initiative (initiative_id INT, initative_start_date DATE, initative_end_date DATE, budget FLOAT, region VARCHAR(50)); INSERT INTO initiative (initiative_id, initative_start_date, initative_end_date, budget, region) VALUES (1, '2017-01-01', '2018-12-31', 50000.0, 'R1'), (2, '2019-06-15', '2021-05-30', 75000.0, 'R2');
What is the average budget and number of community development initiatives per region for the last 5 years?
SELECT region, AVG(budget) AS avg_budget, COUNT(*) AS num_initiatives FROM initiative WHERE initative_end_date >= (CURRENT_DATE - INTERVAL '5 years') GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE airport_locations (airport_id INT, airport_name VARCHAR(50), country VARCHAR(50));
How many airports are there in each country in the 'airports' table?
SELECT country, COUNT(*) FROM airport_locations GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE clinics (clinic_id INT, clinic_name TEXT, state TEXT); CREATE TABLE treatments (treatment_id INT, patient_id INT, clinic_id INT, therapy TEXT); CREATE TABLE conditions (condition_id INT, patient_id INT, condition TEXT); INSERT INTO clinics (clinic_id, clinic_name, state) VALUES (1, 'Texas Mental Health Clinic', 'Texas'); INSERT INTO treatments (treatment_id, patient_id, clinic_id, therapy) VALUES (1, 1, 1, 'DBT'); INSERT INTO conditions (condition_id, patient_id, condition) VALUES (1, 1, 'Depression');
List the number of unique mental health conditions treated in Texas clinics using DBT?
SELECT COUNT(DISTINCT conditions.condition) FROM clinics INNER JOIN treatments ON clinics.clinic_id = treatments.clinic_id INNER JOIN conditions ON treatments.patient_id = conditions.patient_id WHERE clinics.state = 'Texas' AND therapy = 'DBT';
gretelai_synthetic_text_to_sql
CREATE TABLE solar_projects (id INT, state VARCHAR(255), name VARCHAR(255), completion_year INT); INSERT INTO solar_projects (id, state, name, completion_year) VALUES (1, 'California', 'Solar Project C', 2020), (2, 'California', 'Solar Project D', 2021);
How many solar projects were completed in California in 2020 and 2021?
SELECT COUNT(*) FROM solar_projects WHERE state = 'California' AND completion_year IN (2020, 2021);
gretelai_synthetic_text_to_sql
CREATE TABLE oil_fields_me (field_name VARCHAR(50), location VARCHAR(50), production_qty INT); INSERT INTO oil_fields_me (field_name, location, production_qty) VALUES ('Burgan', 'Middle East', 1800000), ('Safaniya', 'Middle East', 1500000);
List all oil fields in the Middle East and their production quantities
SELECT field_name, production_qty FROM oil_fields_me WHERE location = 'Middle East';
gretelai_synthetic_text_to_sql
CREATE TABLE inclusive_housing (property_id INT, city VARCHAR(20), units INT); INSERT INTO inclusive_housing (property_id, city, units) VALUES (1, 'Oakland', 20), (2, 'Berkeley', 15), (3, 'Seattle', 10), (4, 'Vancouver', 25);
How many inclusive housing units are in Vancouver?
SELECT SUM(units) FROM inclusive_housing WHERE city = 'Vancouver';
gretelai_synthetic_text_to_sql
CREATE TABLE accommodations_state (id INT, accommodation_date DATE, accommodation_type TEXT, student_state TEXT); INSERT INTO accommodations_state (id, accommodation_date, accommodation_type, student_state) VALUES (1, '2020-01-01', 'Assistive Technology', 'California'), (2, '2020-02-01', 'Note Taker', 'California'), (3, '2020-01-15', 'Extended Testing Time', 'New York'), (4, '2019-12-20', 'Assistive Technology', 'Texas');
What is the total number of disability accommodations provided in each state?
SELECT student_state, COUNT(*) FROM accommodations_state GROUP BY student_state;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists industry (industry_id INT, industry_name TEXT, total_workers INT, female_workers INT); INSERT INTO industry (industry_id, industry_name, total_workers, female_workers) VALUES (1, 'manufacturing', 5000, 2500), (2, 'technology', 7000, 3500), (3, 'healthcare', 6000, 4000), (4, 'finance', 4000, 2000), (5, 'retail', 3000, 2000);
How many female workers are there in the 'manufacturing' industry?
SELECT SUM(female_workers) FROM industry WHERE industry_name = 'manufacturing';
gretelai_synthetic_text_to_sql
CREATE TABLE concerts (id INT, country VARCHAR(255), city VARCHAR(255), artist_name VARCHAR(255), tier VARCHAR(255), price DECIMAL(10,2), num_tickets INT);
Delete all concerts with a price greater than $500.
DELETE FROM concerts WHERE price > 500;
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_energy (id INT, project_name VARCHAR(50), location VARCHAR(50)); INSERT INTO renewable_energy (id, project_name, location) VALUES (1, 'SolarFarm AP', 'Asia Pacific'), (2, 'WindFarm EU', 'Europe'), (3, 'HydroAP', 'Asia Pacific'), (4, 'GeoThermal NA', 'North America');
How many renewable energy projects have been implemented in the Asia Pacific region?
SELECT COUNT(*) FROM renewable_energy WHERE location = 'Asia Pacific';
gretelai_synthetic_text_to_sql
CREATE TABLE startups(id INT, name TEXT, industry TEXT, founder_ethnicity TEXT, funding FLOAT); INSERT INTO startups (id, name, industry, founder_ethnicity, funding) VALUES (1, 'HealthcareNative', 'Healthcare', 'Indigenous', 4000000);
What is the average funding received by startups founded by indigenous people in the healthcare sector?
SELECT AVG(funding) FROM startups WHERE industry = 'Healthcare' AND founder_ethnicity = 'Indigenous';
gretelai_synthetic_text_to_sql
CREATE TABLE courses (course_id INT, course_name VARCHAR(50), creation_date DATE);
Insert a new open pedagogy course, 'Introduction to Open Pedagogy', created on January 1, 2022 into the 'courses' table.
INSERT INTO courses (course_name, creation_date) VALUES ('Introduction to Open Pedagogy', '2022-01-01');
gretelai_synthetic_text_to_sql
CREATE TABLE grad_programs (program_id INT, program_name VARCHAR(50), num_students INT); CREATE TABLE publications (pub_id INT, program_id INT, pub_type VARCHAR(10)); INSERT INTO grad_programs (program_id, program_name, num_students) VALUES (10, 'Computer Science', 50), (20, 'English', 30), (30, 'Mathematics', 40); INSERT INTO publications (pub_id, program_id, pub_type) VALUES (100, 10, 'Journal'), (101, 10, 'Conference'), (102, 20, 'Journal'), (103, 20, 'Book'), (104, 30, 'Journal');
What is the average number of publications per graduate program?
SELECT g.program_name, AVG(p.num_publications) AS avg_publications FROM (SELECT program_id, COUNT(*) AS num_publications FROM publications GROUP BY program_id) p INNER JOIN grad_programs g ON p.program_id = g.program_id GROUP BY g.program_name;
gretelai_synthetic_text_to_sql
CREATE TABLE projects (project_name VARCHAR(50), budget INTEGER, technology_for_social_good BOOLEAN);
What is the minimum budget for any project in 'projects' table related to social good?
SELECT MIN(budget) FROM projects WHERE technology_for_social_good = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (sale_id INT, product_id INT, product_category VARCHAR(255), sales FLOAT, state VARCHAR(255)); INSERT INTO sales (sale_id, product_id, product_category, sales, state) VALUES (1, 1, 'Electronics', 100, 'WA'), (2, 2, 'Clothing', 200, 'NY'), (3, 3, 'Electronics', 150, 'CA');
Calculate the total sales for each product category in each state
SELECT s1.product_category, s1.state, SUM(s1.sales) FROM sales s1 GROUP BY s1.product_category, s1.state;
gretelai_synthetic_text_to_sql
CREATE TABLE mining_production_australia (production_date DATE, production_volume INT, mining_method VARCHAR(255)); INSERT INTO mining_production_australia (production_date, production_volume, mining_method) VALUES ('2021-08-01', 1000, 'Open Pit'), ('2021-08-01', 1200, 'Underground'), ('2021-07-01', 1500, 'Open Pit'), ('2021-07-01', 1800, 'Underground');
What is the maximum production volume per mining method in Australia in the past month?
SELECT mining_method, MAX(production_volume) as max_production_volume FROM mining_production_australia WHERE production_date >= DATEADD(month, -1, CURRENT_DATE) GROUP BY mining_method;
gretelai_synthetic_text_to_sql
CREATE TABLE community_engagement_3 (id INT, region VARCHAR(50), event VARCHAR(100), attendees INT); INSERT INTO community_engagement_3 (id, region, event, attendees) VALUES (1, 'North', 'Art Exhibition', 150), (2, 'South', 'Language Workshop', 75), (3, 'North', 'Music Festival', 120);
Which community engagement events had more than 100 attendees?
SELECT event FROM community_engagement_3 WHERE attendees > 100;
gretelai_synthetic_text_to_sql
CREATE TABLE bike_sharing (trip_id INT, trip_start_station VARCHAR(50), trip_start_time TIMESTAMP, city VARCHAR(50)); INSERT INTO bike_sharing (trip_id, trip_start_station, trip_start_time, city) VALUES (1, 'Waterloo Station', '2022-01-01 09:00:00', 'London'), (2, 'Tower Bridge', '2022-01-01 10:30:00', 'London');
How many bike-sharing trips start at each station in London?
SELECT trip_start_station, COUNT(*) FROM bike_sharing WHERE city = 'London' GROUP BY trip_start_station;
gretelai_synthetic_text_to_sql
CREATE TABLE EducationBudget (Year INT, Budget FLOAT); INSERT INTO EducationBudget VALUES (2018, 12000000), (2019, 13000000), (2020, 14000000), (2021, 15000000);
What is the maximum budget allocated for education in each year?
SELECT Year, MAX(Budget) OVER (PARTITION BY Year) AS MaxBudget FROM EducationBudget;
gretelai_synthetic_text_to_sql
CREATE TABLE initiative (initiative_id INT, name VARCHAR(50), location VARCHAR(50), success_rate FLOAT, launch_date DATE); CREATE TABLE location (location_id INT, name VARCHAR(50), continent_id INT); CREATE TABLE continent (continent_id INT, name VARCHAR(50), description TEXT); INSERT INTO continent (continent_id, name, description) VALUES (3, 'Sub-Saharan Africa', 'The area of the African continent that lies south of the Sahara.'); INSERT INTO location (location_id, name, continent_id) VALUES (3, 'Sub-Saharan Africa', 3);
What is the success rate of community development initiatives in Sub-Saharan Africa?
SELECT AVG(i.success_rate) FROM initiative i JOIN location l ON i.location = l.name WHERE l.continent_id = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE national_parks (name VARCHAR(255), country VARCHAR(64), category VARCHAR(64), visitors INT); INSERT INTO national_parks (name, country, category, visitors) VALUES ('Yosemite', 'USA', 'National Park', 5000), ('Banff', 'Canada', 'National Park', 3000), ('Everglades', 'USA', 'National Park', 4000), ('Jasper', 'Canada', 'National Park', 2500);
What is the total number of tourists visiting national parks in the United States and Canada, grouped by park category?
SELECT category, SUM(visitors) as total_visitors FROM national_parks GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels (id INT, name VARCHAR(255), region VARCHAR(255), cargo_weight FLOAT); INSERT INTO Vessels (id, name, region, cargo_weight) VALUES (1, 'VesselA', 'South Pacific', 5000); INSERT INTO Vessels (id, name, region, cargo_weight) VALUES (2, 'VesselB', 'South Pacific', 7000); CREATE TABLE Cargo (vessel_id INT, cargo_weight FLOAT, cargo_date DATE); INSERT INTO Cargo (vessel_id, cargo_weight, cargo_date) VALUES (1, 3000, '2022-10-01'); INSERT INTO Cargo (vessel_id, cargo_weight, cargo_date) VALUES (2, 4000, '2022-11-01');
What was the maximum cargo weight for vessels in the South Pacific in Q4 of 2022?
SELECT MAX(Cargo.cargo_weight) FROM Vessels INNER JOIN Cargo ON Vessels.id = Cargo.vessel_id WHERE Vessels.region = 'South Pacific' AND QUARTER(Cargo.cargo_date) = 4;
gretelai_synthetic_text_to_sql
CREATE TABLE forests (id INT, name TEXT, co2_sequestration_rate REAL, country TEXT, category TEXT, year INT); INSERT INTO forests (id, name, co2_sequestration_rate, country, category, year) VALUES (1, 'Tijuca Forest', 5.6, 'Brazil', 'protected', 2013), (2, 'Jacarepagua Forest', 7.2, 'Brazil', 'protected', 2015);
What is the average CO2 sequestration rate for protected forests in Brazil over the past decade?
SELECT AVG(co2_sequestration_rate) FROM forests WHERE country = 'Brazil' AND category = 'protected' AND year BETWEEN 2012 AND 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE student_open_pedagogy (student_id INT, grade_level INT, participation_score INT); INSERT INTO student_open_pedagogy (student_id, grade_level, participation_score) VALUES (1, 6, 85), (2, 6, 90), (3, 7, 75), (4, 7, 80), (5, 8, 95);
What is the maximum open pedagogy participation score for students in each grade level that has more than 5 students?
SELECT grade_level, MAX(participation_score) as max_participation_score FROM student_open_pedagogy GROUP BY grade_level HAVING COUNT(student_id) > 5;
gretelai_synthetic_text_to_sql
CREATE TABLE posts (id INT, user_id INT, platform VARCHAR(255), post_date DATE); INSERT INTO posts (id, user_id, platform, post_date) VALUES (1, 1, 'Instagram', '2022-01-01'), (2, 2, 'Twitter', '2022-01-10'), (3, 1, 'Instagram', '2022-02-01'), (4, 3, 'LinkedIn', '2022-03-01'), (5, 1, 'Instagram', '2022-03-01'), (6, 1, 'Instagram', '2022-03-01'); CREATE TABLE users (id INT, country VARCHAR(255)); INSERT INTO users (id, country) VALUES (1, 'Spain'), (2, 'Russia'), (3, 'Indonesia');
What is the maximum number of posts made by a single user on a specific platform in a day?
SELECT platform, user_id, MAX(post_count) FROM (SELECT platform, user_id, COUNT(*) AS post_count FROM posts WHERE platform = 'Instagram' GROUP BY platform, user_id, post_date) AS subquery GROUP BY platform, user_id;
gretelai_synthetic_text_to_sql
CREATE TABLE teams (team_id INT, team_name VARCHAR(255), avg_points DECIMAL(5,2)); INSERT INTO teams (team_id, team_name, avg_points) VALUES (1, 'TeamA', 85.5), (2, 'TeamB', 78.9), (3, 'TeamC', 92.2);
Which teams have the highest average points per game in the last 30 days?
SELECT team_name FROM teams WHERE avg_points = (SELECT MAX(avg_points) FROM teams WHERE avg_points >= (SELECT AVG(avg_points) FROM teams WHERE date >= DATEADD(day, -30, GETDATE())));
gretelai_synthetic_text_to_sql
CREATE TABLE Trees (id INT, species VARCHAR(255), age INT); INSERT INTO Trees (id, species, age) VALUES (1, 'Oak', 50), (2, 'Pine', 30), (3, 'Maple', 40);
What is the total biomass of all the trees in the Trees table, if each tree has a biomass of 0.022 pounds per year per inch of age?
SELECT SUM(age * 0.022) FROM Trees;
gretelai_synthetic_text_to_sql
CREATE TABLE Climate_Data ( id INT PRIMARY KEY, location VARCHAR(50), temperature FLOAT, precipitation FLOAT, date DATE ); INSERT INTO Climate_Data (id, location, temperature, precipitation, date) VALUES (1, 'Longyearbyen', -10.5, 50.0, '2022-01-01'); INSERT INTO Climate_Data (id, location, temperature, precipitation, date) VALUES (2, 'Tromsø', -5.0, 70.0, '2022-01-01'); INSERT INTO Climate_Data (id, location, temperature, precipitation, date) VALUES (3, 'Arctic Circle', -15.0, 30.0, '2022-01-01'); INSERT INTO Climate_Data (id, location, temperature, precipitation, date) VALUES (4, 'Arctic Circle', -12.0, 35.0, '2022-02-01'); INSERT INTO Climate_Data (id, location, temperature, precipitation, date) VALUES (5, 'Arctic Circle', -8.0, 40.0, '2022-03-01');
What are the average annual temperatures for the Arctic region in 2020 and 2021?
SELECT location, AVG(temperature) FROM Climate_Data WHERE location = 'Arctic Circle' AND year(date) IN (2020, 2021) GROUP BY location
gretelai_synthetic_text_to_sql
CREATE TABLE climate_finance (region VARCHAR(50), investment INT, year INT); INSERT INTO climate_finance (region, investment, year) VALUES ('Oceania', 1500000, 2020), ('Europe', 4000000, 2020);
What is the average investment in climate finance for Oceania and Europe in 2020?
SELECT region, AVG(investment) as avg_investment FROM climate_finance WHERE year = 2020 AND region IN ('Oceania', 'Europe') GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE economic_diversification (id INT, project_name VARCHAR(255), company_size INT, completion_date DATE, country VARCHAR(50)); INSERT INTO economic_diversification (id, project_name, company_size, completion_date, country) VALUES (1, 'Renewable Energy Project', 1000, '2017-06-12', 'Mexico'), (2, 'Tourism Development', 550, '2018-11-20', 'Mexico'), (3, 'Manufacturing Plant', 700, '2016-03-15', 'Mexico');
How many economic diversification projects were completed in Mexico by companies with more than 500 employees?
SELECT COUNT(*) FROM economic_diversification WHERE country = 'Mexico' AND company_size > 500 AND completion_date IS NOT NULL
gretelai_synthetic_text_to_sql
CREATE TABLE healthcare_services (id INT, name TEXT, country TEXT, community TEXT, cost FLOAT);
What is the average cost of healthcare services for indigenous people in Canada?
SELECT AVG(cost) FROM healthcare_services WHERE country = 'Canada' AND community = 'indigenous';
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (hotel_id INT, hotel_name TEXT, country TEXT, rating FLOAT, ai_adoption BOOLEAN); INSERT INTO hotels (hotel_id, hotel_name, country, rating, ai_adoption) VALUES (1, 'The Sydney Harbour', 'Australia', 4.7, true), (2, 'The Great Barrier Reef', 'Australia', 4.8, true), (3, 'The Auckland Sky Tower', 'New Zealand', 4.6, false);
What is the maximum rating of hotels in Oceania that have adopted AI technology?
SELECT MAX(rating) FROM hotels WHERE ai_adoption = true AND country = 'Oceania';
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_subscribers (subscriber_id INT, region VARCHAR(50), data_usage INT); INSERT INTO mobile_subscribers (subscriber_id, region, data_usage) VALUES (1, 'Latin America', 4000), (2, 'Europe', 3000);
What is the maximum data usage for mobile subscribers in the Latin America region?
SELECT MAX(data_usage) FROM mobile_subscribers WHERE region = 'Latin America';
gretelai_synthetic_text_to_sql
CREATE TABLE Dispensaries (DispensaryID int, DispensaryName varchar(255), State varchar(255)); INSERT INTO Dispensaries (DispensaryID, DispensaryName, State) VALUES (1, 'Dank Depot', 'California'); INSERT INTO Dispensaries (DispensaryID, DispensaryName, State) VALUES (2, 'Euphoric Enterprises', 'California'); CREATE TABLE Sales (SaleID int, DispensaryID int, SalesAmount decimal(10,2)); INSERT INTO Sales (SaleID, DispensaryID, SalesAmount) VALUES (1, 1, 5000); INSERT INTO Sales (SaleID, DispensaryID, SalesAmount) VALUES (2, 2, 7000);
What are the total sales for each dispensary in the state of California, ordered by sales from highest to lowest?
SELECT Dispensaries.DispensaryName, SUM(Sales.SalesAmount) AS TotalSales FROM Dispensaries INNER JOIN Sales ON Dispensaries.DispensaryID = Sales.DispensaryID WHERE Dispensaries.State = 'California' GROUP BY Dispensaries.DispensaryName ORDER BY TotalSales DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE warehouses (id VARCHAR(5), name VARCHAR(10)); INSERT INTO warehouses (id, name) VALUES ('W01', 'Warehouse One'), ('W02', 'Warehouse Two'), ('W03', 'Warehouse Three'), ('W04', 'Warehouse Four'); CREATE TABLE inventory (item_code VARCHAR(5), warehouse_id VARCHAR(5), quantity INT); INSERT INTO inventory (item_code, warehouse_id, quantity) VALUES ('A101', 'W01', 300), ('A202', 'W02', 200), ('A303', 'W03', 450), ('B404', 'W04', 500), ('B102', 'W02', 600), ('B305', 'W03', 700);
What is the total quantity of items starting with 'B' in warehouse 'W02'?
SELECT SUM(quantity) FROM inventory WHERE item_code LIKE 'B%' AND warehouse_id = 'W02';
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, PlayerName VARCHAR(50), Age INT, Country VARCHAR(50)); INSERT INTO Players (PlayerID, PlayerName, Age, Country) VALUES (1, 'John Doe', 25, 'USA'); INSERT INTO Players (PlayerID, PlayerName, Age, Country) VALUES (2, 'Jane Smith', 30, 'Canada'); INSERT INTO Players (PlayerID, PlayerName, Age, Country) VALUES (3, 'Raj Patel', 24, 'India');
Update the age of all players from India to 27.
UPDATE Players SET Age = 27 WHERE Country = 'India';
gretelai_synthetic_text_to_sql
CREATE TABLE social_good_projects (year INT, projects INT); INSERT INTO social_good_projects (year, projects) VALUES (2020, 100), (2021, 150), (2022, 120);
What is the total number of social good technology projects completed in 2022?
SELECT projects as completed_projects FROM social_good_projects WHERE year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (VolunteerID INT, VolunteerName TEXT, Region TEXT); INSERT INTO Volunteers (VolunteerID, VolunteerName, Region) VALUES (1, 'Alex Brown', 'North'), (2, 'Bella Johnson', 'South'), (3, 'Charlie Davis', 'East'), (4, 'David White', 'West'); CREATE TABLE Donors (DonorID INT, DonorName TEXT, DonationAmount DECIMAL, Region TEXT); INSERT INTO Donors (DonorID, DonorName, DonationAmount, Region) VALUES (1, 'John Doe', 500.00, 'North'), (2, 'Jane Smith', 350.00, 'South'), (3, 'Alice Johnson', 700.00, 'East'), (4, 'John Doe', 200.00, 'North');
What is the number of unique donors and total donation amount by each region?
SELECT Region, COUNT(DISTINCT DonorID) as TotalDonors, SUM(DonationAmount) as TotalDonation FROM Donors GROUP BY Region;
gretelai_synthetic_text_to_sql
CREATE TABLE clinics (id INT, name TEXT, city TEXT, state TEXT, num_doctors INT, last_review_date DATE); INSERT INTO clinics (id, name, city, state, num_doctors, last_review_date) VALUES (1, 'Houston Medical Center', 'Houston', 'TX', 50, '2020-01-10'); INSERT INTO clinics (id, name, city, state, num_doctors, last_review_date) VALUES (2, 'Memorial Hermann Hospital', 'Houston', 'TX', 75, '2020-02-15');
What is the maximum number of doctors in clinics in Houston, TX?
SELECT MAX(num_doctors) FROM clinics WHERE city = 'Houston' AND state = 'TX';
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_rates (id INT, year INT, country VARCHAR(255), material VARCHAR(255), recycling_rate DECIMAL(5,2));
What is the recycling rate of glass by country in 2021?
SELECT country, AVG(recycling_rate) as avg_recycling_rate FROM recycling_rates WHERE year = 2021 AND material = 'glass' GROUP BY country HAVING COUNT(*) > 3;
gretelai_synthetic_text_to_sql
CREATE TABLE BusStations (id INT, borough VARCHAR(255), station_name VARCHAR(255)); CREATE TABLE TrainStations (id INT, district VARCHAR(255), station_name VARCHAR(255)); CREATE TABLE TramStations (id INT, district VARCHAR(255), station_name VARCHAR(255));
Find the number of bus, train and tram stations in each borough or district, and the total number of stations.
SELECT 'Bus' as transportation, borough, COUNT(*) as station_count FROM BusStations GROUP BY borough UNION ALL SELECT 'Train', district, COUNT(*) FROM TrainStations GROUP BY district UNION ALL SELECT 'Tram', district, COUNT(*) FROM TramStations GROUP BY district UNION ALL SELECT 'Total', '', COUNT(*) FROM BusStations UNION ALL SELECT '', '', COUNT(*) FROM TrainStations UNION ALL SELECT '', '', COUNT(*) FROM TramStations;
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_energy_projects (id INT, name VARCHAR(50), province VARCHAR(50), country VARCHAR(50), capacity FLOAT, completion_year INT, project_type VARCHAR(50));
How many renewable energy projects have been completed in the province of Quebec, Canada since 2015, excluding hydroelectric projects?
SELECT COUNT(*) FROM renewable_energy_projects WHERE province = 'Quebec' AND country = 'Canada' AND completion_year >= 2015 AND project_type != 'hydroelectric';
gretelai_synthetic_text_to_sql
CREATE TABLE peacekeeping_ops (id INT, country VARCHAR(50), operation VARCHAR(50), start_date DATE, end_date DATE, initial_mandate_end DATE); INSERT INTO peacekeeping_ops (id, country, operation, start_date, end_date, initial_mandate_end) VALUES (1, 'Bangladesh', 'UNAMID', '2007-07-31', '2021-06-30', '2017-12-31'); INSERT INTO peacekeeping_ops (id, country, operation, start_date, end_date, initial_mandate_end) VALUES (2, 'Ethiopia', 'UNMISS', '2011-07-09', '2023-01-15', '2021-12-31');
What is the total number of peacekeeping operations that have been extended beyond their initial mandate?
SELECT COUNT(*) as extensions FROM peacekeeping_ops WHERE end_date > initial_mandate_end;
gretelai_synthetic_text_to_sql
CREATE TABLE production (id INT, year INT, quarter INT, quantity INT); INSERT INTO production (id, year, quarter, quantity) VALUES (1, 2021, 4, 1200), (2, 2022, 1, 1500), (3, 2022, 2, 1300), (4, 2022, 3, 1400), (5, 2022, 4, 1600);
Show the total quantity of items produced in the last quarter
SELECT SUM(quantity) FROM production WHERE quarter IN (4, 1, 2, 3);
gretelai_synthetic_text_to_sql
CREATE TABLE workshops (workshop_id INT, workshop_name TEXT);CREATE TABLE vehicle_maintenance (maintenance_id INT, workshop_id INT, vehicle_id INT, maintenance_date DATE); INSERT INTO workshops (workshop_id, workshop_name) VALUES (1, 'Workshop A'), (2, 'Workshop B'), (3, 'Workshop C'); INSERT INTO vehicle_maintenance (maintenance_id, workshop_id, vehicle_id, maintenance_date) VALUES (1, 1, 1001, '2022-05-03'), (2, 1, 1002, '2022-05-10'), (3, 2, 2001, '2022-05-05'), (4, 2, 2002, '2022-05-12'), (5, 3, 3001, '2022-05-01'), (6, 3, 3002, '2022-05-15');
What is the number of vehicles serviced in each workshop between May 1 and May 15, 2022?
SELECT w.workshop_name, COUNT(vm.vehicle_id) as vehicles_serviced FROM workshops w JOIN vehicle_maintenance vm ON w.workshop_id = vm.workshop_id WHERE vm.maintenance_date BETWEEN '2022-05-01' AND '2022-05-15' GROUP BY w.workshop_name;
gretelai_synthetic_text_to_sql
CREATE TABLE incidents(id INT, ip VARCHAR(255), incident_count INT, date DATE); INSERT INTO incidents(id, ip, incident_count, date) VALUES (1, '192.168.0.1', 50, '2021-09-01'), (2, '192.168.0.2', 30, '2021-09-01'), (3, '192.168.0.3', 15, '2021-09-01'), (4, '192.168.0.1', 45, '2021-09-02'), (5, '192.168.0.2', 35, '2021-09-02'), (6, '192.168.0.3', 20, '2021-09-02');
How many unique IP addresses are associated with security incidents in the last month?
SELECT COUNT(DISTINCT ip) as unique_ips FROM incidents WHERE date >= DATE_SUB(CURRENT_DATE(), INTERVAL 1 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE network_investments (investment_id INT, region VARCHAR(255), investment_amount DECIMAL(10,2), investment_date DATE); INSERT INTO network_investments (investment_id, region, investment_amount, investment_date) VALUES (1, 'Southeast', 250000.00, '2022-01-01'), (2, 'Northeast', 300000.00, '2022-01-10'), (3, 'Southeast', 150000.00, '2022-02-01');
What is the total network investment in the Southeast region for the current year?
SELECT SUM(investment_amount) FROM network_investments WHERE region = 'Southeast' AND YEAR(investment_date) = YEAR(CURRENT_DATE);
gretelai_synthetic_text_to_sql
CREATE TABLE habitats (id INT, name TEXT, animal_id INT, size_km2 FLOAT); INSERT INTO habitats (id, name, animal_id, size_km2) VALUES (1, 'Habitat1', 1, 50.3), (2, 'Habitat2', 2, 32.1), (3, 'Habitat3', 2, 87.6), (4, 'Habitat4', 3, 22.5), (5, 'Habitat5', 1, 75.8);
What is the average size of protected habitats for each animal species?
SELECT a.species, AVG(h.size_km2) as avg_size FROM animals a JOIN habitats h ON a.id = h.animal_id GROUP BY a.species;
gretelai_synthetic_text_to_sql
CREATE TABLE routes (route_id INT, name VARCHAR(255), start_station_id INT, end_station_id INT);
List all the routes and their corresponding start and end stations.
SELECT route_id, name, start_station_id, end_station_id FROM routes;
gretelai_synthetic_text_to_sql
CREATE TABLE wind_turbines_us (id INT, installed_year INT, production FLOAT); INSERT INTO wind_turbines_us (id, installed_year, production) VALUES (1, 2012, 5.5), (2, 2014, 6.0), (3, 2016, 4.5);
What is the average energy production for wind turbines installed in the US before 2015?
SELECT AVG(production) as avg_production FROM wind_turbines_us WHERE installed_year < 2015;
gretelai_synthetic_text_to_sql
CREATE TABLE military_equipment (equipment_type VARCHAR(255), quantity INT);
What is the total number of military equipment records for each type in the military_equipment table, excluding the 'Aircraft' type?
SELECT equipment_type, SUM(quantity) FROM military_equipment WHERE equipment_type != 'Aircraft' GROUP BY equipment_type;
gretelai_synthetic_text_to_sql
CREATE TABLE DiseaseStats (Year INT, Disease VARCHAR(20), Region VARCHAR(20), Cases INT); INSERT INTO DiseaseStats (Year, Disease, Region, Cases) VALUES (2018, 'Cholera', 'East Africa', 15000); INSERT INTO DiseaseStats (Year, Disease, Region, Cases) VALUES (2020, 'Malaria', 'West Africa', 80000);
What is the total number of Malaria cases in West Africa in 2020?
SELECT SUM(Cases) FROM DiseaseStats WHERE Disease = 'Malaria' AND Region = 'West Africa' AND Year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE cases (case_id INT, city TEXT, alternative_sanctions BOOLEAN); INSERT INTO cases (case_id, city, alternative_sanctions) VALUES (1, 'Chicago', true), (2, 'Chicago', false), (3, 'Chicago', true), (4, 'Chicago', true), (5, 'Chicago', false);
What is the percentage of cases where alternative sanctions were applied in the city of Chicago?
SELECT (COUNT(*) FILTER (WHERE alternative_sanctions = true)) * 100.0 / COUNT(*) AS percentage FROM cases WHERE city = 'Chicago';
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, category VARCHAR(20), is_cruelty_free BOOLEAN, is_vegan BOOLEAN); INSERT INTO products (product_id, category, is_cruelty_free, is_vegan) VALUES (1, 'Skincare', TRUE, TRUE), (2, 'Skincare', TRUE, FALSE), (3, 'Haircare', FALSE, TRUE), (4, 'Haircare', TRUE, FALSE), (5, 'Makeup', TRUE, TRUE);
Show the number of cruelty-free and vegan products in each category.
SELECT category, COUNT(*) as count FROM products WHERE is_cruelty_free = TRUE AND is_vegan = TRUE GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE safety_tests (vehicle_model VARCHAR(10), safety_rating INT, year INT);
What is the difference in safety ratings between the latest and earliest tests for each vehicle model in the 'safety_tests' table?
SELECT vehicle_model, MAX(safety_rating) - MIN(safety_rating) AS safety_rating_diff FROM safety_tests GROUP BY vehicle_model;
gretelai_synthetic_text_to_sql
CREATE TABLE legal_aid_attorneys (attorney_id INT, name VARCHAR(50), age INT, cases_worked_on VARCHAR(50)); INSERT INTO legal_aid_attorneys (attorney_id, name, age, cases_worked_on) VALUES (1, 'John Doe', 35, 'access to justice, criminal justice reform'), (2, 'Jane Smith', 40, 'restorative justice'), (3, 'Mike Johnson', 30, 'criminal justice reform');
List the names and ages of all legal aid attorneys who have worked on cases related to criminal justice reform
SELECT name, age FROM legal_aid_attorneys WHERE cases_worked_on LIKE '%criminal justice reform%';
gretelai_synthetic_text_to_sql
CREATE TABLE arctic_animal_sightings (id INT, date DATE, animal VARCHAR(255)); INSERT INTO arctic_animal_sightings (id, date, animal) VALUES (1, '2021-01-01', 'Polar Bear'), (2, '2021-02-01', 'Walrus'), (3, '2021-03-01', 'Fox');
How many animal sightings were recorded in the 'arctic_animal_sightings' table for each month?
SELECT MONTH(date) AS month, COUNT(*) AS animal_sightings FROM arctic_animal_sightings GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE courses (course_id INT, course_name TEXT, year INT); INSERT INTO courses (course_id, course_name, year) VALUES (1, 'Course X', 2021), (2, 'Course Y', 2021), (3, 'Course Z', 2022); CREATE TABLE enrollments (enrollment_id INT, course_id INT, student_id INT); INSERT INTO enrollments (enrollment_id, course_id, student_id) VALUES (1, 1, 1), (2, 1, 2), (3, 2, 3), (4, 2, 4), (5, 3, 5);
Which lifelong learning courses had the highest enrollment in the past year?
SELECT c.course_name, COUNT(e.student_id) as enrollment_count FROM courses c JOIN enrollments e ON c.course_id = e.course_id WHERE c.year = 2021 GROUP BY c.course_name ORDER BY enrollment_count DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE InsurancePolicies (PolicyNumber INT, PolicyHolderName VARCHAR(50), PolicyType VARCHAR(50), IssueDate DATE); CREATE TABLE Policyholders (PolicyHolderID INT, PolicyHolderName VARCHAR(50), DateOfBirth DATE, Gender VARCHAR(50)); INSERT INTO Policyholders VALUES (1, 'Dan', '1970-01-01', 'Male'), (2, 'Eve', '1985-03-20', 'Female');
Insert records for new policyholders with home insurance.
INSERT INTO InsurancePolicies (PolicyNumber, PolicyHolderName, PolicyType, IssueDate) SELECT PolicyHolderID, PolicyHolderName, 'Home', GETDATE() FROM Policyholders WHERE NOT EXISTS (SELECT 1 FROM InsurancePolicies WHERE PolicyHolderName = Policyholders.PolicyHolderName);
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (hotel_id INT, hotel_name TEXT, type TEXT, daily_rate DECIMAL(5,2), revenue INT); INSERT INTO hotels (hotel_id, hotel_name, type, daily_rate, revenue) VALUES (1, 'Eco Hotel', 'eco', 100.00, 3000), (2, 'Urban Resort', 'standard', 150.00, 5000), (3, 'Beach Retreat', 'eco', 120.00, 4000);
Update the room rates of eco-friendly hotels by 5% for the next month.
UPDATE hotels SET daily_rate = daily_rate * 1.05 WHERE type = 'eco' AND daily_rate * 1.05 BETWEEN DATE_SUB(curdate(), INTERVAL 1 MONTH) AND DATE_ADD(curdate(), INTERVAL 1 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE game_results (game_id INT, home_team VARCHAR(20), away_team VARCHAR(20), home_score INT, away_score INT, city VARCHAR(20), stadium VARCHAR(50));
Find the number of games won by the home_team for each city in the game_results table.
SELECT city, home_team, COUNT(*) as num_wins FROM game_results WHERE home_score > away_score GROUP BY city, home_team;
gretelai_synthetic_text_to_sql
CREATE SCHEMA education;CREATE TABLE professional_development (id INT, role VARCHAR(10), name VARCHAR(50), completed BOOLEAN);INSERT INTO professional_development (id, role, name, completed) VALUES (1, 'student', 'John Doe', FALSE), (2, 'teacher', 'Jane Smith', TRUE);
What is the total number of students and teachers who have ever participated in professional development programs, regardless of completion status, in the education schema?
SELECT COUNT(*) FROM education.professional_development;
gretelai_synthetic_text_to_sql
CREATE TABLE city_budget (city VARCHAR(20), program VARCHAR(20), budget INT); INSERT INTO city_budget (city, program, budget) VALUES ('Denver', 'Homeless Services', 5000000);
What is the total budget allocated for social services in the city of Denver, including all programs, for the fiscal year 2023?
SELECT SUM(budget) FROM city_budget WHERE city = 'Denver' AND program LIKE '%Social Services%' AND fiscal_year = 2023;
gretelai_synthetic_text_to_sql
CREATE TABLE tickets_4 (team TEXT, quantity INTEGER); INSERT INTO tickets_4 (team, quantity) VALUES ('Red Sox', 30000), ('Yankees', 35000), ('Mets', 25000), ('Giants', 22000);
What is the total number of tickets sold for each team?
SELECT team, SUM(quantity) FROM tickets_4 GROUP BY team;
gretelai_synthetic_text_to_sql
CREATE TABLE MiningSites (SiteID INT, SiteName VARCHAR(50), Location VARCHAR(50), EnvironmentalImpactScore INT);
Insert a new record for a mining site located in 'Oregon' with an environmental impact score of 75.
INSERT INTO MiningSites (SiteName, Location, EnvironmentalImpactScore) VALUES ('New Mine', 'Oregon', 75);
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (id INT, region VARCHAR(20), transaction_amount DECIMAL(10, 2)); INSERT INTO transactions (id, region, transaction_amount) VALUES (1, 'Southwest', 120.00), (2, 'Northeast', 75.00), (3, 'Southwest', 150.00);
What is the total number of transactions in the Southwest region with a value greater than $100?
SELECT COUNT(*) FROM transactions WHERE region = 'Southwest' AND transaction_amount > 100;
gretelai_synthetic_text_to_sql