context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE vehicles (vehicle_id INT, vehicle_make VARCHAR(20), torque FLOAT); INSERT INTO vehicles (vehicle_id, vehicle_make, torque) VALUES (1, 'Tesla', 443), (2, 'Tesla', 431), (3, 'Rivian', 405), (4, 'Rivian', 418), (5, 'Fisker', 310);
What is the average torque of electric vehicles, partitioned by vehicle make?
SELECT vehicle_make, AVG(torque) avg_torque FROM vehicles WHERE vehicle_make IN ('Tesla', 'Rivian', 'Fisker') GROUP BY vehicle_make;
gretelai_synthetic_text_to_sql
CREATE TABLE Events (event_id INT, event_name VARCHAR(255), team VARCHAR(255), price DECIMAL(5,2)); INSERT INTO Events VALUES (1, 'Game 1', 'NBA', 150.00), (2, 'Game 2', 'NBA', 160.00);
What is the average ticket price for each event hosted by the 'NBA'?
SELECT event_name, AVG(price) FROM Events WHERE team = 'NBA' GROUP BY event_name;
gretelai_synthetic_text_to_sql
CREATE TABLE Endangered_Languages (Language_Name VARCHAR(50), Country VARCHAR(50), Number_Speakers INT); INSERT INTO Endangered_Languages (Language_Name, Country, Number_Speakers) VALUES ('Tigrinya', 'Eritrea', 2000000), ('Amharic', 'Ethiopia', 21000000), ('Zulu', 'South Africa', 12000000);
What are the names and languages of all endangered language programs in Africa, sorted by the number of speakers?
SELECT Language_Name, Country, Number_Speakers FROM Endangered_Languages WHERE Country IN ('Eritrea', 'Ethiopia', 'South Africa') ORDER BY Number_Speakers DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE steps_data (id INT, user_id INT, steps INT, date DATE);
Calculate the average number of steps taken per day for all users in the last week?
SELECT AVG(steps) FROM steps_data WHERE date >= DATE(NOW()) - INTERVAL 1 WEEK GROUP BY date;
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (donor_id INT, artwork_id INT, donation_date DATE); INSERT INTO Donations (donor_id, artwork_id, donation_date) VALUES (1, 101, '2020-01-01'), (2, 105, '2019-12-01'), (1, 201, '2020-02-01'), (3, 303, '2018-05-15');
What is the total number of artworks donated by individual donors, and their respective donation dates, sorted by the earliest donation date?
SELECT donor_id, COUNT(artwork_id) AS total_artworks, MIN(donation_date) AS earliest_donation_date FROM Donations GROUP BY donor_id ORDER BY earliest_donation_date;
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, donor_id INT, amount DECIMAL(10, 2), cause_id INT); INSERT INTO donations (id, donor_id, amount, cause_id) VALUES (1, 1, 500.00, 3), (2, 1, 300.00, 3), (3, 2, 250.00, 4), (4, 2, 400.00, 4), (5, 3, 100.00, 3), (6, 4, 700.00, 4), (7, 5, 1200.00, 3);
What is the average donation amount for each non-social cause category?
SELECT c.type, AVG(d.amount) FROM donations d JOIN causes c ON d.cause_id = c.id GROUP BY c.type HAVING c.type != 'Social';
gretelai_synthetic_text_to_sql
CREATE TABLE rural_infrastructure (project VARCHAR(50), country VARCHAR(50), start_year INT, end_year INT, budget FLOAT); INSERT INTO rural_infrastructure (project, country, start_year, end_year, budget) VALUES ('Rural Electrification', 'Mexico', 2012, 2015, 30000000), ('Rural Water Supply', 'Mexico', 2012, 2015, 40000...
Which rural infrastructure projects were initiated in Mexico's rural areas between 2012 and 2015, and what was their combined budget?
SELECT project, SUM(budget) FROM rural_infrastructure WHERE country = 'Mexico' AND start_year BETWEEN 2012 AND 2015 AND end_year BETWEEN 2012 AND 2015 GROUP BY project;
gretelai_synthetic_text_to_sql
CREATE TABLE agricultural_innovation (id INT, project_name VARCHAR(100), project_location VARCHAR(100), project_type VARCHAR(50), project_status VARCHAR(50), total_cost FLOAT, start_date DATE, end_date DATE);
What was the total cost of agricultural innovation projects in the 'Latin America' region for the year 2019, grouped by project_type?
SELECT project_type, SUM(total_cost) FROM agricultural_innovation WHERE project_location LIKE 'Latin%' AND YEAR(start_date) = 2019 GROUP BY project_type;
gretelai_synthetic_text_to_sql
CREATE TABLE factories (id INT, name VARCHAR(50), country VARCHAR(50), industry4 INT, year INT);
How many factories in the United States have implemented industry 4.0 technologies in the past 5 years?
SELECT COUNT(*) FROM factories WHERE country = 'United States' AND industry4 = 1 AND year BETWEEN 2017 AND 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE billing (attorney_id INT, client_id INT, hours FLOAT, rate FLOAT); INSERT INTO billing (attorney_id, client_id, hours, rate) VALUES (1, 101, 10, 300), (2, 102, 8, 350), (3, 103, 12, 250);
List clients with more than 15 hours of billing in the 'billing' table?
SELECT client_id, SUM(hours) FROM billing GROUP BY client_id HAVING SUM(hours) > 15;
gretelai_synthetic_text_to_sql
CREATE TABLE Products (ProductID INT, ProductName VARCHAR(50), SupplierID INT, Category VARCHAR(50), IsKosher BOOLEAN, Price DECIMAL(5, 2)); INSERT INTO Products (ProductID, ProductName, SupplierID, Category, IsKosher, Price) VALUES (1, 'Kosher Chicken', 1, 'Meat', true, 12.99); CREATE TABLE Orders (OrderID INT, Produc...
What is the total quantity of kosher products sold in New York in the last week?
SELECT SUM(Quantity) FROM Orders JOIN Products ON Orders.ProductID = Products.ProductID WHERE Products.IsKosher = true AND CustomerLocation = 'New York' AND Orders.OrderDate >= DATEADD(WEEK, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE donors (donor_id INT, donation_date DATE, donation_amount DECIMAL(10, 2), country VARCHAR(50)); INSERT INTO donors VALUES (1, '2022-01-01', 50.00, 'USA'), (2, '2022-01-15', 100.00, 'Canada'), (3, '2022-03-05', 200.00, 'Mexico');
How many donors from each country donated in 2022?
SELECT country, COUNT(DISTINCT donor_id) FROM donors WHERE donation_date BETWEEN '2022-01-01' AND '2022-12-31' GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE fairness_scores (score_id INT PRIMARY KEY, model_id INT, score_date DATE, model_type VARCHAR(50), fairness_score FLOAT); INSERT INTO fairness_scores (score_id, model_id, score_date, model_type, fairness_score) VALUES (1, 1, '2021-01-01', 'Deep Learning', 0.75), (2, 2, '2021-02-01', 'Tree Based', 0.87), (3,...
What is the total fairness score for each AI model, grouped by model type?
SELECT model_type, AVG(fairness_score) FROM fairness_scores GROUP BY model_type;
gretelai_synthetic_text_to_sql
CREATE TABLE satellites_by_country (satellite_id INT, country VARCHAR(50), orbit_type VARCHAR(50)); INSERT INTO satellites_by_country (satellite_id, country, orbit_type) VALUES (1, 'USA', 'Geostationary'); INSERT INTO satellites_by_country (satellite_id, country, orbit_type) VALUES (2, 'Russia', 'Low Earth Orbit'); INS...
Show the number of satellites in each type of orbit
SELECT orbit_type, COUNT(*) as num_satellites FROM satellites_by_country GROUP BY orbit_type;
gretelai_synthetic_text_to_sql
CREATE TABLE Shipments (ID INT, Origin VARCHAR(50), Destination VARCHAR(50), DeliveryTime INT); INSERT INTO Shipments (ID, Origin, Destination, DeliveryTime) VALUES (1, 'Frankfurt', 'Chicago', 5), (2, 'London', 'New York', 7), (3, 'Brazil', 'India', 10);
What is the average delivery time for shipments from 'Frankfurt' to 'Chicago'?
SELECT AVG(Shipments.DeliveryTime) FROM Shipments WHERE Shipments.Origin = 'Frankfurt' AND Shipments.Destination = 'Chicago';
gretelai_synthetic_text_to_sql
CREATE TABLE properties (id INT, size FLOAT, city VARCHAR(20)); INSERT INTO properties (id, size, city) VALUES (1, 1500, 'New York'), (2, 2000, 'New York'), (3, 1000, 'New York');
What is the second largest property size in New York?
SELECT size FROM (SELECT size, ROW_NUMBER() OVER (ORDER BY size DESC) as rn FROM properties WHERE city = 'New York') t WHERE rn = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE events (id INT, name TEXT, country TEXT, visitors INT);
Insert a new virtual tourism event in Japan with 20000 visitors.
INSERT INTO events (name, country, visitors) VALUES ('Virtual Tourism Japan', 'Japan', 20000);
gretelai_synthetic_text_to_sql
CREATE TABLE military_equipment (equipment_id INT, equipment_name VARCHAR(255), maintenance_cost FLOAT); INSERT INTO military_equipment (equipment_id, equipment_name, maintenance_cost) VALUES (1, 'Tank A', 45000.00), (2, 'Helicopter B', 62000.00), (3, 'Jet C', 38000.00);
Delete records with a maintenance cost greater than $50,000 in the 'military_equipment' table
DELETE FROM military_equipment WHERE maintenance_cost > 50000;
gretelai_synthetic_text_to_sql
CREATE TABLE neodymium_prices (year INT, country TEXT, price DECIMAL(10, 2)); INSERT INTO neodymium_prices (year, country, price) VALUES (2017, 'Australia', 85.5), (2018, 'Australia', 88.3), (2019, 'Australia', 91.7), (2020, 'Australia', 95.2), (2021, 'Australia', 100.5);
What is the average market price of neodymium produced in Australia over the last 5 years?
SELECT AVG(price) FROM neodymium_prices WHERE country = 'Australia' AND year >= 2017;
gretelai_synthetic_text_to_sql
CREATE TABLE WaterTreatmentPlants (id INT, plant_name VARCHAR(50), region VARCHAR(50), total_capacity INT); INSERT INTO WaterTreatmentPlants (id, plant_name, region, total_capacity) VALUES (1, 'Plant A', 'Coastal', 25000), (2, 'Plant B', 'Inland', 35000), (3, 'Plant C', 'Coastal', 45000), (4, 'Plant D', 'Coastal', 1500...
What is the percentage of water treatment plants in the 'Coastal' region that have a water treatment capacity of less than 30,000 cubic meters?
SELECT (COUNT(*) / (SELECT COUNT(*) FROM WaterTreatmentPlants WHERE region = 'Coastal') * 100) FROM WaterTreatmentPlants WHERE region = 'Coastal' AND total_capacity < 30000;
gretelai_synthetic_text_to_sql
CREATE TABLE financial_institutions (id INT, name VARCHAR(255), type VARCHAR(255), location VARCHAR(255)); INSERT INTO financial_institutions (id, name, type, location) VALUES (1, 'ABC Bank', 'Islamic', 'India'); INSERT INTO financial_institutions (id, name, type, location) VALUES (2, 'Islamic Bank', 'Conventional', 'U...
List all financial institutions that offer both Shariah-compliant and conventional loans.
SELECT name FROM financial_institutions WHERE id IN (SELECT institution_id FROM loans WHERE type = 'Islamic') AND id IN (SELECT institution_id FROM loans WHERE type = 'Conventional');
gretelai_synthetic_text_to_sql
CREATE TABLE LanguagePreservationEvents (id INT, event VARCHAR(255), budget DECIMAL(10, 2), program VARCHAR(255)); INSERT INTO LanguagePreservationEvents (id, event, budget, program) VALUES (1, 'Maori Language Course', 12000, 'New Zealand'), (2, 'Aboriginal Language Workshop', 15000, 'Australia'), (3, 'Pacific Islander...
What is the total budget for each community engagement event at the specified language preservation program?
SELECT event, SUM(budget) as total_budget FROM LanguagePreservationEvents WHERE program = 'New Zealand' GROUP BY event;
gretelai_synthetic_text_to_sql
CREATE VIEW HabitatPreservation AS SELECT habitat_id, animal_id FROM AnimalHabitats; INSERT INTO AnimalHabitats (habitat_id, animal_id) VALUES (1, 1), (1, 2), (2, 3), (3, 4), (3, 5), (4, 6);
What is the maximum number of animals in the "HabitatPreservation" view that share the same habitat?
SELECT MAX(habitat_count) FROM (SELECT habitat_id, COUNT(DISTINCT animal_id) AS habitat_count FROM HabitatPreservation GROUP BY habitat_id) AS subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE defense_spending_branches (branch VARCHAR(50), spending NUMERIC(10,2)); INSERT INTO defense_spending_branches (branch, spending) VALUES ('Army', 2000000000), ('Navy', 3000000000), ('Air Force', 4000000000), ('Marines', 1000000000);
What is the total defense spending for each branch?
SELECT branch, spending FROM defense_spending_branches;
gretelai_synthetic_text_to_sql
CREATE TABLE art_pieces (id INT, artist VARCHAR(30), style VARCHAR(20), year_sold INT, price DECIMAL(10,2)); CREATE VIEW abstract_expressionist_sales AS SELECT style, MAX(price) AS max_price FROM art_pieces GROUP BY style;
What was the maximum price for any Abstract Expressionist pieces sold in any year?
SELECT style, max_price FROM abstract_expressionist_sales WHERE style = 'Abstract Expressionist';
gretelai_synthetic_text_to_sql
CREATE TABLE disaster_preparedness (id INT, equipment_type VARCHAR(255), status VARCHAR(255)); INSERT INTO disaster_preparedness (id, equipment_type, status) VALUES (1, 'Communication Equipment', 'Out_of_Service'), (2, 'Generator', 'Functional'), (3, 'Communication Equipment', 'Functional');
Delete all records from the disaster_preparedness table where the 'equipment_type' column is 'Communication Equipment' and the 'status' column is 'Out_of_Service'?
DELETE FROM disaster_preparedness WHERE equipment_type = 'Communication Equipment' AND status = 'Out_of_Service';
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers (supplier_id INT, supplier_name VARCHAR(100), country VARCHAR(50), sustainability_rating INT); INSERT INTO suppliers (supplier_id, supplier_name, country, sustainability_rating) VALUES (1, 'Supplier A', 'China', 5), (2, 'Supplier B', 'Japan', 3), (3, 'Supplier C', 'India', 4);
How many suppliers from Asia have a sustainability rating greater than 4?
SELECT COUNT(*) FROM suppliers WHERE country LIKE 'Asia%' AND sustainability_rating > 4;
gretelai_synthetic_text_to_sql
CREATE TABLE resident (id INT PRIMARY KEY, name TEXT, age INT, city_id INT, gender TEXT, civic_participation BOOLEAN, FOREIGN KEY (city_id) REFERENCES city(id));
What is the minimum age of residents who have participated in civic engagement activities?
SELECT MIN(age) FROM resident WHERE civic_participation = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE research_projects (id INT, name TEXT, country TEXT, components TEXT); INSERT INTO research_projects (id, name, country, components) VALUES (1, 'GenoMaple', 'Canada', 'Biosensor, Sequencing');
Which genetic research projects in Canada have biosensor technology as a component?
SELECT name FROM research_projects WHERE country = 'Canada' AND components LIKE '%Biosensor%';
gretelai_synthetic_text_to_sql
CREATE TABLE CommunityInitiatives (id INT PRIMARY KEY, name VARCHAR(50), location VARCHAR(50), type VARCHAR(20), start_date DATE, end_date DATE); INSERT INTO CommunityInitiatives (id, name, location, type, start_date, end_date) VALUES (1, 'Local Health Clinic', 'Rural Vietnam', 'Healthcare', '2020-02-01', '2021-12-31')...
What community initiatives related to health were active between January 2020 and December 2021?
SELECT name, location, type FROM CommunityInitiatives WHERE start_date <= '2020-12-31' AND end_date >= '2020-01-01' AND type = 'Healthcare';
gretelai_synthetic_text_to_sql
CREATE TABLE routes (route_id INT, route_name TEXT);CREATE TABLE fares (fare_id INT, route_id INT, fare DECIMAL, fare_date DATE); INSERT INTO routes VALUES (123, 'Route 123'); INSERT INTO routes VALUES (456, 'Route 456'); INSERT INTO fares VALUES (1, 123, 2.5, '2022-01-01'); INSERT INTO fares VALUES (2, 123, 2.5, '2022...
What is the total fare collected on each route, grouped by day of the week?
SELECT routes.route_name, DATE_FORMAT(fares.fare_date, '%W') as day_of_week, SUM(fares.fare) FROM routes INNER JOIN fares ON routes.route_id = fares.route_id GROUP BY routes.route_name, day_of_week;
gretelai_synthetic_text_to_sql
CREATE TABLE CargoTracking (CargoID INT, LoadDate DATE, LoadLocation VARCHAR(50), CargoWeight INT); INSERT INTO CargoTracking (CargoID, LoadDate, LoadLocation, CargoWeight) VALUES (1, '2021-01-01', 'Sao Paulo', 850), (2, '2021-02-15', 'Rio de Janeiro', 900), (3, '2021-12-31', 'Brasilia', 750);
What is the total cargo weight loaded in the Brazilian region?
SELECT SUM(CargoWeight) FROM CargoTracking WHERE LoadLocation LIKE 'Brazil%';
gretelai_synthetic_text_to_sql
CREATE TABLE factories (factory_id INT, sector VARCHAR(255), has_automation BOOLEAN, workforce_diversity_score INT); INSERT INTO factories (factory_id, sector, has_automation, workforce_diversity_score) VALUES (1, 'Industry 4.0', TRUE, 85), (2, 'Industry 4.0', TRUE, 70), (3, 'Industry 4.0', FALSE, 90);
What is the total number of factories in the industry 4.0 sector that have implemented automation technologies and have a workforce diversity score above 80?
SELECT COUNT(*) FROM factories WHERE sector = 'Industry 4.0' AND has_automation = TRUE AND workforce_diversity_score > 80;
gretelai_synthetic_text_to_sql
CREATE SCHEMA socialmedia;CREATE TABLE user_settings (id INT, user_id INT, setting VARCHAR(255), timestamp TIMESTAMP, country VARCHAR(255));INSERT INTO user_settings (id, user_id, setting, timestamp, country) VALUES (1, 1, 'privacy', '2023-04-01 12:00:00', 'Canada'), (2, 2, 'privacy', '2023-05-15 15:00:00', 'Mexico');
How many users in Canada and Mexico had their data privacy settings changed in Q2 2023?
SELECT SUM(CASE WHEN country = 'Canada' THEN 1 ELSE 0 END + CASE WHEN country = 'Mexico' THEN 1 ELSE 0 END) FROM socialmedia.user_settings WHERE setting = 'privacy' AND EXTRACT(YEAR FROM timestamp) = 2023 AND EXTRACT(QUARTER FROM timestamp) = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE vehicle_maintenance (id INT, vehicle_id INT, type TEXT, scheduled_time TIMESTAMP);
Delete vehicle maintenance records for vehicle 103
WITH cte AS (DELETE FROM vehicle_maintenance WHERE vehicle_id = 103 RETURNING id) SELECT * FROM cte;
gretelai_synthetic_text_to_sql
CREATE TABLE esg_factors (id INT, risk_score INT, region VARCHAR(50)); INSERT INTO esg_factors (id, risk_score, region) VALUES (1, 3, 'Latin America'), (2, 5, 'North America'), (3, 4, 'Latin America');
What is the minimum risk score for ESG factors in Latin America?
SELECT MIN(risk_score) FROM esg_factors WHERE region = 'Latin America';
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists VisitorContinents (Continent VARCHAR(50), Country VARCHAR(50), Visitors INT); INSERT INTO VisitorContinents (Continent, Country, Visitors) VALUES ('Africa', 'Egypt', 110000), ('Asia', 'Japan', 220000), ('Europe', 'France', 330000), ('South America', 'Brazil', 130000), ('North America', 'Canad...
What was the total number of visitors from each continent in 2022?
SELECT a.Continent, SUM(a.Visitors) AS TotalVisitors FROM VisitorContinents a WHERE a.Year = 2022 GROUP BY a.Continent;
gretelai_synthetic_text_to_sql
CREATE TABLE VolunteerPrograms (VolunteerID INT, ProgramID INT, Hours INT, VolunteerDate DATE); INSERT INTO VolunteerPrograms VALUES (1, 1, 4, '2021-01-01'), (2, 1, 6, '2021-02-01'), (3, 2, 8, '2021-03-01');
How many volunteers participated in each program in 2021?
SELECT ProgramID, COUNT(DISTINCT VolunteerID) FROM VolunteerPrograms WHERE YEAR(VolunteerDate) = 2021 GROUP BY ProgramID;
gretelai_synthetic_text_to_sql
CREATE TABLE urban_farms (id INT, name VARCHAR(255), size FLOAT, continent VARCHAR(255)); INSERT INTO urban_farms (id, name, size, continent) VALUES (1, 'Farm A', 1.2, 'Africa'), (2, 'Farm B', 2.0, 'Asia'), (3, 'Farm C', 0.5, 'South America');
What is the average size of urban farms in hectares, grouped by continent, and only considering farms with more than 100 farms?
SELECT continent, AVG(size) as avg_size FROM urban_farms GROUP BY continent HAVING COUNT(*) > 100;
gretelai_synthetic_text_to_sql
CREATE TABLE price_ranges (price_range_id INT PRIMARY KEY, price_from DECIMAL(10, 2), price_to DECIMAL(10, 2)); INSERT INTO price_ranges (price_range_id, price_from, price_to) VALUES (1, 0, 200000), (2, 200001, 500000), (3, 500001, 1000000);
Show the number of properties in each price range
SELECT price_ranges.price_range_id, COUNT(properties.property_id) FROM properties JOIN price_ranges ON properties.property_price BETWEEN price_ranges.price_from AND price_ranges.price_to GROUP BY price_ranges.price_range_id;
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 'Fire' incident type and a response_time of 4 minutes
INSERT INTO emergency_response (incident_type, response_time) VALUES ('Fire', 4);
gretelai_synthetic_text_to_sql
CREATE TABLE articles (id INT, title TEXT, publish_date DATE, category TEXT); INSERT INTO articles (id, title, publish_date, category) VALUES ('1', 'Article 1', '2021-01-01', 'investigations'), ('2', 'Article 2', '2022-03-15', 'news'), ('3', 'Article 3', '2020-12-25', 'investigations');
What is the earliest date an article was published in the 'investigations' category?
SELECT MIN(publish_date) FROM articles WHERE category = 'investigations';
gretelai_synthetic_text_to_sql
CREATE TABLE sizes (id INT, size VARCHAR(10)); INSERT INTO sizes (id, size) VALUES (1, 'XS'), (2, 'S'), (3, 'M'), (4, 'L'), (5, 'XL'); CREATE TABLE inventory (id INT, item_name VARCHAR(20), size_id INT, is_sustainable BOOLEAN, quantity INT); INSERT INTO inventory (id, item_name, size_id, is_sustainable, quantity) VALUE...
Determine the number of sustainable items in each size
SELECT sizes.size, is_sustainable, SUM(quantity) FROM sizes JOIN inventory ON inventory.size_id = sizes.id GROUP BY sizes.size, is_sustainable;
gretelai_synthetic_text_to_sql
CREATE SCHEMA labor_unions; CREATE TABLE unions (id INT PRIMARY KEY, name VARCHAR(255)); CREATE TABLE employees (id INT PRIMARY KEY, name VARCHAR(255), union_id INT, salary DECIMAL(10,2), FOREIGN KEY (union_id) REFERENCES unions(id)); INSERT INTO unions (id, name) VALUES (1, 'Union A'), (2, 'Union B'); INSERT INTO empl...
Get the average salary for employees in each union
SELECT u.name, AVG(e.salary) AS avg_salary FROM labor_unions.unions u INNER JOIN labor_unions.employees e ON u.id = e.union_id GROUP BY u.name;
gretelai_synthetic_text_to_sql
CREATE TABLE ethical_fashion_brands (brand_id INT, brand_name VARCHAR(255), score INT); INSERT INTO ethical_fashion_brands (brand_id, brand_name, score) VALUES (1, 'People Tree', 85), (2, 'Tentree', 92), (3, 'Everlane', 88), (4, 'Patagonia', 78);
Rank ethical fashion brands by their total sustainability score in ascending order.
SELECT brand_name, score, RANK() OVER (ORDER BY score ASC) as sustainability_rank FROM ethical_fashion_brands;
gretelai_synthetic_text_to_sql
CREATE TABLE clients (id INT, name VARCHAR(255), country VARCHAR(255)); INSERT INTO clients (id, name, country) VALUES (1, 'John Doe', 'USA'), (2, 'Jane Smith', 'Canada'); CREATE TABLE investments (id INT, client_id INT, fund_type VARCHAR(255), amount DECIMAL(10, 2)); INSERT INTO investments (id, client_id, fund_type, ...
What is the total investment in socially responsible funds by clients from the United States?
SELECT SUM(amount) FROM investments i JOIN clients c ON i.client_id = c.id WHERE c.country = 'USA' AND i.fund_type = 'Socially Responsible';
gretelai_synthetic_text_to_sql
CREATE TABLE climate_data (id INT, month VARCHAR(255), temperature INT);
What is the average temperature (in degrees Celsius) for each month in the climate_data dataset?
SELECT month, AVG(temperature) FROM climate_data GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE ProductionMaterials (material_type VARCHAR(20), quantity INT, production_date DATE);
What is the total quantity of sustainable materials used in production in the last year?
SELECT SUM(quantity) FROM ProductionMaterials WHERE material_type IN ('organic cotton','recycled polyester','sustainable silk') AND production_date BETWEEN DATE_SUB(NOW(), INTERVAL 1 YEAR) AND NOW();
gretelai_synthetic_text_to_sql
CREATE TABLE hotel_revenues (hotel_id INT, name TEXT, country TEXT, annual_revenue INT); INSERT INTO hotel_revenues (hotel_id, name, country, annual_revenue) VALUES (1, 'Ritz Paris', 'France', 6000000);
Which countries have hotels with annual revenues over 5 million?
SELECT DISTINCT country FROM hotel_revenues WHERE annual_revenue > 5000000;
gretelai_synthetic_text_to_sql
CREATE TABLE oil_production(country VARCHAR(255), year INT, production INT);INSERT INTO oil_production(country, year, production) VALUES('Nigeria',2020,1800000),('Angola',2020,1500000),('Algeria',2020,900000),('Libya',2020,700000),('Egypt',2020,600000),('South Sudan',2020,400000),('Republic of the Congo',2020,300000),(...
Identify the top 5 oil producing countries in Africa in 2020.
SELECT country, production FROM oil_production WHERE year = 2020 AND country IN ('Nigeria', 'Angola', 'Algeria', 'Libya', 'Egypt', 'South Sudan', 'Republic of the Congo', 'Gabon', 'Equatorial Guinea', 'Chad') ORDER BY production DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE Online_Interaction (id INT, user_id INT, interaction_date DATE, country VARCHAR(50)); INSERT INTO Online_Interaction (id, user_id, interaction_date, country) VALUES (1, 1, '2022-05-01', 'USA'), (2, 3, '2022-05-15', 'Canada'), (3, 5, '2022-04-20', 'France'), (4, 7, '2022-03-25', 'UK');
Find the percentage of visitors that engaged with online exhibitions from North America and Europe combined.
SELECT (COUNT(DISTINCT CASE WHEN country IN ('USA', 'Canada', 'France', 'UK') THEN Online_Interaction.user_id END) * 100.0 / COUNT(DISTINCT Online_Interaction.user_id)) as percentage FROM Online_Interaction;
gretelai_synthetic_text_to_sql
CREATE TABLE drug_k_rd (quarter INTEGER, year INTEGER, amount INTEGER);
Insert a new record for 'DrugK' with R&D expenditure of $1,200,000 in Q1 2022.
INSERT INTO drug_k_rd (quarter, year, amount) VALUES (1, 2022, 1200000);
gretelai_synthetic_text_to_sql
CREATE TABLE solar_plants (id INT, country VARCHAR(255), name VARCHAR(255), capacity FLOAT); INSERT INTO solar_plants (id, country, name, capacity) VALUES (1, 'Spain', 'Solarplant A', 60.5); INSERT INTO solar_plants (id, country, name, capacity) VALUES (2, 'Spain', 'Solarplant B', 70.2); INSERT INTO solar_plants (id, c...
Find the number of solar power plants in Spain and Italy that have a capacity greater than 50 MW.
SELECT COUNT(*) FROM solar_plants WHERE country IN ('Spain', 'Italy') AND capacity > 50;
gretelai_synthetic_text_to_sql
CREATE TABLE Artworks (artwork_name VARCHAR(255), creation_date DATE, movement VARCHAR(255)); INSERT INTO Artworks (artwork_name, creation_date, movement) VALUES ('The Night Watch', '1642-02-01', 'Baroque'), ('Girl with a Pearl Earring', '1665-06-22', 'Dutch Golden Age'), ('The Persistence of Memory', '1931-08-01', 'Su...
What is the latest creation date in the 'Contemporary' period?
SELECT MAX(creation_date) FROM Artworks WHERE movement = 'Contemporary';
gretelai_synthetic_text_to_sql
CREATE TABLE gym_classes (class_name VARCHAR(255), class_location VARCHAR(255));
List the unique types of group fitness classes offered in LA and NYC
SELECT DISTINCT class_location, class_name FROM gym_classes WHERE class_location IN ('LA', 'NYC');
gretelai_synthetic_text_to_sql
CREATE TABLE tourism_stats (destination VARCHAR(255), year INT, visitors INT); INSERT INTO tourism_stats (destination, year, visitors) VALUES ('Canada', 2017, 20000000), ('Canada', 2018, 22000000), ('Canada', 2019, 23000000), ('Canada', 2020, 18000000);
Find the average number of tourists visiting Canada annually from 2017 to 2020
SELECT AVG(visitors) FROM tourism_stats WHERE destination = 'Canada' AND year BETWEEN 2017 AND 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE excavation_sites (id INT, site_name VARCHAR(255)); CREATE TABLE artifacts (id INT, excavation_site_id INT, artifact_age INT);
What is the oldest artifact found at each excavation site?
SELECT e.site_name, MIN(a.artifact_age) AS oldest_artifact_age FROM artifacts a JOIN excavation_sites e ON a.excavation_site_id = e.id GROUP BY e.site_name;
gretelai_synthetic_text_to_sql
CREATE TABLE port_of_oakland (vessel_name VARCHAR(255), dock_month INT); CREATE TABLE port_of_los_angeles (vessel_name VARCHAR(255), dock_month INT); INSERT INTO port_of_oakland (vessel_name, dock_month) VALUES ('Vessel XX', 6), ('Vessel YY', 6), ('Vessel ZZ', 7); INSERT INTO port_of_los_angeles (vessel_name, dock_mont...
What are the names of the vessels that docked in the Port of Oakland in June 2022 and have also docked in the Port of Los Angeles in July 2022?
SELECT o.vessel_name FROM port_of_oakland o WHERE o.dock_month = 6 INTERSECT SELECT l.vessel_name FROM port_of_los_angeles l WHERE l.dock_month = 7;
gretelai_synthetic_text_to_sql
CREATE TABLE eco_hotels (hotel_id INT, name TEXT, country TEXT, revenue FLOAT); INSERT INTO eco_hotels VALUES (1, 'Eco Hotel Stockholm', 'Sweden', 80000), (2, 'Green Hotel Gothenburg', 'Sweden', 90000);
What is the total revenue generated from eco-friendly hotels in Sweden?
SELECT SUM(revenue) FROM eco_hotels WHERE country = 'Sweden';
gretelai_synthetic_text_to_sql
CREATE TABLE Libraries_Dept (ID INT, Library_Type VARCHAR(255), Budget FLOAT); INSERT INTO Libraries_Dept (ID, Library_Type, Budget) VALUES (1, 'Public', 700000), (2, 'Public', 600000), (3, 'Academic', 800000);
How many public libraries in the Libraries department have a budget over $500,000?
SELECT COUNT(*) FROM Libraries_Dept WHERE Library_Type = 'Public' AND Budget > 500000;
gretelai_synthetic_text_to_sql
CREATE TABLE funding(startup_name VARCHAR(50), country VARCHAR(20), amount DECIMAL(10,2));INSERT INTO funding(startup_name, country, amount) VALUES('Startup1', 'India', 3000000.00), ('Startup2', 'Mexico', 4000000.00), ('Startup3', 'India', 5000000.00);
List the names of biotech startups that received funding in India or Mexico.
SELECT startup_name FROM funding WHERE country IN ('India', 'Mexico');
gretelai_synthetic_text_to_sql
CREATE TABLE reserves (country text, resource text, quantity real); INSERT INTO reserves (country, resource, quantity) VALUES ('Saudi Arabia', 'oil', 266.5), ('Saudi Arabia', 'gas', 7.9), ('Russia', 'oil', 109.2), ('Russia', 'gas', 32.9), ('Iran', 'oil', 155.6), ('Iran', 'gas', 33.1);
What is the total oil and gas reserves for Saudi Arabia?
SELECT SUM(quantity) FROM reserves WHERE country = 'Saudi Arabia';
gretelai_synthetic_text_to_sql
CREATE TABLE warehouses (id INT, location VARCHAR(10), item VARCHAR(10), quantity INT); INSERT INTO warehouses (id, location, item, quantity) VALUES (1, 'NY', 'A101', 200), (2, 'NJ', 'A101', 300), (3, 'CA', 'B203', 150), (4, 'NY', 'C304', 50);
What is the total quantity of items in warehouse 1 and 5?
SELECT SUM(quantity) FROM warehouses WHERE id IN (1, 5);
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels (VesselID INT, VesselName VARCHAR(100), MaxSpeed FLOAT); INSERT INTO Vessels (VesselID, VesselName, MaxSpeed) VALUES (1, 'Ocean Titan', 36.5), (2, 'Sea Giant', 33.3), (3, 'Marine Unicorn', 37.8), (4, 'Sky Wanderer', 35.2), (5, 'River Princess', 29.0), (6, 'Lake Explorer', 39.0);
Find the total number of vessels with a maximum speed greater than 35 knots
SELECT COUNT(*) FROM Vessels WHERE MaxSpeed > 35;
gretelai_synthetic_text_to_sql
CREATE TABLE Exhibitions (id INT, curator VARCHAR(50), title VARCHAR(100), location VARCHAR(100), start_date DATE, end_date DATE); INSERT INTO Exhibitions (id, curator, title, location, start_date, end_date) VALUES (1, 'Theodora J. Roethke', 'Impressionist Visions', 'New York', '2022-05-01', '2022-08-31');
Update the location of 'Impressionist Visions' to 'London'.
UPDATE Exhibitions SET location = 'London' WHERE curator = 'Theodora J. Roethke' AND title = 'Impressionist Visions';
gretelai_synthetic_text_to_sql
CREATE TABLE clinical_trials (country TEXT, year INTEGER, trials INTEGER); INSERT INTO clinical_trials (country, year, trials) VALUES ('United States', 2020, 1200); INSERT INTO clinical_trials (country, year, trials) VALUES ('Germany', 2020, 300);
Which countries have the most clinical trials in 2020?
SELECT country, SUM(trials) FROM clinical_trials WHERE year = 2020 GROUP BY country ORDER BY SUM(trials) DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE rovers (id INT, name VARCHAR(255), country VARCHAR(255), landing_date DATE, launch_date DATE); INSERT INTO rovers (id, name, country, landing_date, launch_date) VALUES (1, 'Spirit', 'USA', '2004-01-04', '2003-06-10'); INSERT INTO rovers (id, name, country, landing_date, launch_date) VALUES (2, 'Curiosity',...
Which rovers were launched by China or Russia?
SELECT name, country FROM rovers WHERE country = 'China' OR country = 'Russia';
gretelai_synthetic_text_to_sql
CREATE TABLE materials (material_id INT, material_name VARCHAR(100), unit_cost DECIMAL(5,2)); INSERT INTO materials VALUES (1, 'Concrete', 120.50), (2, 'Steel', 850.00); CREATE TABLE project_materials (project_id INT, material_id INT, quantity INT); INSERT INTO project_materials VALUES (3, 1, 600), (3, 2, 300);
What is the total quantity of steel and concrete used in Project 3?
SELECT m.material_name, SUM(pm.quantity) FROM project_materials pm JOIN materials m ON pm.material_id = m.material_id WHERE pm.project_id = 3 GROUP BY m.material_name;
gretelai_synthetic_text_to_sql
CREATE TABLE Suppliers (SupplierID int, Name varchar(50), Contact varchar(50), Industry varchar(50)); INSERT INTO Suppliers (SupplierID, Name, Contact, Industry) VALUES (1, 'Green Valley', 'contact@greenvalley.com', 'Organic Fruits'); CREATE TABLE Products (ProductID int, Name varchar(50), SupplierID int, Details varch...
List all suppliers for organic fruits and vegetables, along with their contact information and product details.
SELECT Suppliers.Name, Suppliers.Contact, Products.Name, Products.Details FROM Suppliers INNER JOIN Products ON Suppliers.SupplierID = Products.SupplierID WHERE Suppliers.Industry = 'Organic Fruits' AND Products.Details = 'Organic';
gretelai_synthetic_text_to_sql
CREATE TABLE Consumer_Complaints (ComplaintID INT, ProductID INT, ComplaintDate DATE); INSERT INTO Consumer_Complaints (ComplaintID, ProductID, ComplaintDate) VALUES (1, 101, '2021-01-01'), (2, 102, '2021-02-01'), (3, 101, '2021-03-01'), (4, 103, '2021-04-01'), (5, 102, '2021-05-01'), (6, 101, '2021-06-01');
How many consumer complaints were there for each cosmetic product in 2021?
SELECT ProductID, COUNT(*) as Complaints FROM Consumer_Complaints WHERE EXTRACT(YEAR FROM ComplaintDate) = 2021 GROUP BY ProductID;
gretelai_synthetic_text_to_sql
CREATE TABLE players (id INT, name TEXT, level INT, region TEXT);
Calculate the average level of players for each region
SELECT region, AVG(level) AS avg_level FROM players GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE weather_data (country VARCHAR(20), year INT, avg_temp FLOAT); INSERT INTO weather_data (country, year, avg_temp) VALUES ('India', 2000, 25.6), ('India', 2001, 25.8), ('Australia', 2000, 21.3), ('Australia', 2001, 21.5);
What is the average annual temperature change in India and Australia since 2000, ranked by the greatest change?
SELECT country, AVG(avg_temp) as avg_temp_change, ROW_NUMBER() OVER (ORDER BY AVG(avg_temp) DESC) as rank FROM weather_data WHERE country IN ('India', 'Australia') AND year >= 2000 GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE Accounts (CustomerID INT, AccountType VARCHAR(50), Balance DECIMAL(10,2)); INSERT INTO Accounts (CustomerID, AccountType, Balance) VALUES (1, 'Savings', 10000); INSERT INTO Accounts (CustomerID, AccountType, Balance) VALUES (2, 'Checking', 5000);
What are the total assets of the customers who have a savings account?
SELECT SUM(Balance) FROM Accounts WHERE AccountType = 'Savings'
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (ArtistID INT, Name TEXT); INSERT INTO Artists (ArtistID, Name) VALUES (1, 'Pablo Picasso'), (2, 'Vincent van Gogh'); CREATE TABLE Paintings (PaintingID INT, Title TEXT, ArtistID INT); INSERT INTO Paintings (PaintingID, Title, ArtistID) VALUES (1, 'Guernica', 1), (2, 'The Starry Night', 2); CREATE ...
Show the names and number of artworks for all artists who have created works in both the 'Paintings' and 'Sculptures' tables.
SELECT Artists.Name, COUNT(*) as ArtworkCount FROM Artists INNER JOIN Paintings ON Artists.ArtistID = Paintings.ArtistID INNER JOIN Sculptures ON Artists.ArtistID = Sculptures.ArtistID GROUP BY Artists.Name;
gretelai_synthetic_text_to_sql
CREATE TABLE supply_chain (supply_chain_id INT, industry VARCHAR(255), num_initiatives INT);
List the number of circular supply chain initiatives in the electronics industry.
SELECT COUNT(*) FROM supply_chain WHERE industry = 'Electronics';
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT PRIMARY KEY, transaction_id INT, customer_id INT, sale_date DATE, FOREIGN KEY (transaction_id) REFERENCES transactions(id), FOREIGN KEY (customer_id) REFERENCES customers(id));
What is the total quantity of products sold in the last 30 days, grouped by day?
SELECT DATE(sale_date) AS sale_day, SUM(transactions.quantity) AS total_quantity FROM sales INNER JOIN transactions ON sales.transaction_id = transactions.id WHERE sales.sale_date >= CURDATE() - INTERVAL 30 DAY GROUP BY sale_day;
gretelai_synthetic_text_to_sql
CREATE TABLE employee_history (id INT, hire_date DATE, employee_id INT); INSERT INTO employee_history (id, hire_date, employee_id) VALUES (1, '2021-01-01', 1001), (2, '2021-02-01', 2001), (3, '2020-12-01', 3001);
Find the number of employees who joined in each month of the year
SELECT MONTH(hire_date) as hire_month, COUNT(*) as num_employees FROM employee_history GROUP BY hire_month;
gretelai_synthetic_text_to_sql
CREATE TABLE Exhibitions (id INT, theme VARCHAR(255), year INT); INSERT INTO Exhibitions (id, theme, year) VALUES (1, 'Indigenous Cultures', 2020); CREATE TABLE Visitors (id INT, exhibition_id INT);
What is the total number of visitors who attended exhibitions related to indigenous cultures in 2020?
SELECT COUNT(*) FROM Visitors INNER JOIN Exhibitions ON Visitors.exhibition_id = Exhibitions.id WHERE Exhibitions.theme = 'Indigenous Cultures' AND Exhibitions.year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE sustainable_building_projects (project_id INT, project_name VARCHAR(50), state VARCHAR(50), completion_date DATE, is_sustainable BOOLEAN); INSERT INTO sustainable_building_projects (project_id, project_name, state, completion_date, is_sustainable) VALUES (1, 'Green Building', 'California', '2021-01-01', TR...
What is the total number of sustainable building projects in the state of California that were completed in 2021?
SELECT COUNT(*) FROM sustainable_building_projects WHERE state = 'California' AND completion_date BETWEEN '2021-01-01' AND '2021-12-31' AND is_sustainable = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE Restaurants (id INT, name TEXT, country TEXT); CREATE TABLE Meals (id INT, name TEXT, type TEXT, calories INT, RestaurantId INT, FOREIGN KEY (RestaurantId) REFERENCES Restaurants(id)); INSERT INTO Restaurants (id, name, country) VALUES (1, 'Restaurant A', 'USA'), (2, 'Restaurant B', 'USA'), (3, 'Restaurant...
What is the average calorie intake for organic meals served in restaurants located in the US?
SELECT AVG(Meals.calories) FROM Meals JOIN Restaurants ON Meals.RestaurantId = Restaurants.id WHERE Meals.type = 'Organic' AND Restaurants.country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE districts (district_id INT, district_name TEXT); INSERT INTO districts (district_id, district_name) VALUES (1, 'Downtown'), (2, 'Uptown'), (3, 'Suburbs'); CREATE TABLE teachers (teacher_id INT, teacher_name TEXT, district_id INT); INSERT INTO teachers (teacher_id, teacher_name, district_id) VALUES (1, 'Mrs...
What is the number of professional development programs attended by teachers in each district?
SELECT d.district_name, COUNT(pd.program_id) as num_programs FROM districts d JOIN teachers t ON d.district_id = t.district_id JOIN professional_development pd ON t.teacher_id = pd.teacher_id GROUP BY d.district_name;
gretelai_synthetic_text_to_sql
CREATE TABLE athletes (name VARCHAR(100), sport VARCHAR(50), country VARCHAR(50));
Add a new column 'age' to 'athletes' table
ALTER TABLE athletes ADD COLUMN age INT;
gretelai_synthetic_text_to_sql
CREATE TABLE trip_duration (id INT, country VARCHAR(50), tourist_type VARCHAR(50), trip_duration FLOAT); INSERT INTO trip_duration (id, country, tourist_type, trip_duration) VALUES (1, 'South Africa', 'senior', 10.0), (2, 'Egypt', 'senior', 12.0), (3, 'Morocco', 'senior', 14.0), (4, 'Tunisia', 'senior', 16.0), (5, 'Ken...
What is the average trip duration for senior tourists in Africa?
SELECT AVG(trip_duration) FROM trip_duration WHERE country IN ('South Africa', 'Egypt', 'Morocco', 'Tunisia', 'Kenya') AND tourist_type = 'senior';
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers( supplier_id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), sustainability_score DECIMAL(3,2));
Create a table named 'suppliers'
CREATE TABLE suppliers( supplier_id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), sustainability_score DECIMAL(3,2));
gretelai_synthetic_text_to_sql
CREATE TABLE students (id INT, name VARCHAR(20), course VARCHAR(20), joined_date DATE); INSERT INTO students (id, name, course, joined_date) VALUES (1, 'Alex', 'Math', '2022-01-01'); INSERT INTO students (id, name, course, joined_date) VALUES (2, 'Bella', 'English', '2022-02-01'); INSERT INTO students (id, name, course...
Insert new records for students who joined an open pedagogy course in the last month
INSERT INTO students (id, name, course, joined_date) VALUES (5, 'Eli', 'Open Pedagogy', CURRENT_DATE - INTERVAL 15 DAY), (6, 'Fiona', 'Open Pedagogy', CURRENT_DATE - INTERVAL 25 DAY), (7, 'Gabriel', 'Open Pedagogy', CURRENT_DATE - INTERVAL 5 DAY);
gretelai_synthetic_text_to_sql
CREATE TABLE bookings (id INT, hotel_id INT, date DATE, revenue INT); INSERT INTO bookings (id, hotel_id, date, revenue) VALUES (1, 1, '2021-01-01', 100), (2, 1, '2021-02-01', 200); CREATE TABLE hotels (id INT, city VARCHAR(20), sustainable BOOLEAN); INSERT INTO hotels (id, city, sustainable) VALUES (1, 'Tokyo', true),...
Find the total revenue generated from sustainable tourism in Tokyo in the last 6 months.
SELECT SUM(b.revenue) FROM bookings b JOIN hotels h ON b.hotel_id = h.id WHERE h.city = 'Tokyo' AND b.date BETWEEN DATE_SUB(NOW(), INTERVAL 6 MONTH) AND NOW() AND h.sustainable = true;
gretelai_synthetic_text_to_sql
CREATE TABLE players (player_id INT, name VARCHAR(50), position VARCHAR(50), height FLOAT, weight INT, team_id INT, league VARCHAR(50), saves INT); INSERT INTO players (player_id, name, position, height, weight, team_id, league, saves) VALUES (8, 'Ella', 'Goalkeeper', 1.78, 70, 801, 'Ligue 1', 10);
What is the average number of saves made by goalkeepers in the 'Ligue 1' league?
SELECT AVG(saves) FROM players WHERE position = 'Goalkeeper' AND league = 'Ligue 1';
gretelai_synthetic_text_to_sql
CREATE TABLE Papers (id INT, title VARCHAR(255), year INT, country VARCHAR(255)); INSERT INTO Papers (id, title, year, country) VALUES (1, 'Ethical considerations in AI safety', 2021, 'USA'), (2, 'Safe and fair AI algorithms', 2022, 'Canada'), (3, 'Towards explainable AI systems', 2022, 'Australia'), (4, 'AI creativity...
Which countries have had at least 10 papers published in AI safety in the last 5 years?
SELECT country, COUNT(*) as num_papers FROM Papers JOIN Countries ON Papers.country = Countries.name WHERE year BETWEEN 2017 AND 2022 GROUP BY country HAVING num_papers >= 10;
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT PRIMARY KEY, Name VARCHAR(50), GamingCommunity VARCHAR(50), Country VARCHAR(50)); CREATE TABLE GameSessions (SessionID INT PRIMARY KEY, PlayerID INT, Playtime MINUTE, FOREIGN KEY (PlayerID) REFERENCES Players(PlayerID)); INSERT INTO Players (PlayerID, Name, GamingCommunity, Country) V...
What are the countries with the highest average playtime in the "VirtualRealityGaming"?
SELECT Country, AVG(Playtime) FROM Players JOIN GameSessions ON Players.PlayerID = GameSessions.PlayerID WHERE Players.GamingCommunity = 'VirtualRealityGaming' GROUP BY Country ORDER BY AVG(Playtime) DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, name VARCHAR(255), category VARCHAR(255), rating FLOAT, vegan BOOLEAN);
Insert a new row into the 'products' table for a new eyeshadow palette with the name 'Ethereal', a vegan label, and a rating of 4.5.
INSERT INTO products (name, category, rating, vegan) VALUES ('Ethereal', 'eyeshadow', 4.5, TRUE);
gretelai_synthetic_text_to_sql
CREATE TABLE VirtualTours (location VARCHAR(20), year INT, month INT, duration INT);
What is the average number of virtual tours conducted per month in Tokyo, Japan, for the year 2022, if the total duration of the tour was at least 45 minutes?
SELECT AVG(duration) FROM VirtualTours WHERE location = 'Tokyo' AND year = 2022 AND month BETWEEN 1 AND 12 HAVING AVG(duration) >= 45;
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers(id INT, name TEXT, location TEXT);CREATE TABLE products(id INT, supplier_id INT, product_name TEXT, quantity INT, manufacture_date DATE);INSERT INTO suppliers(id, name, location) VALUES (1, 'Supplier A', 'City A'), (2, 'Supplier B', 'City B'); INSERT INTO products(id, supplier_id, product_name, q...
What is the total quantity of products manufactured by each supplier in the past year?
SELECT supplier_id, SUM(quantity) as total_quantity FROM products WHERE manufacture_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY supplier_id;
gretelai_synthetic_text_to_sql
CREATE TABLE justice_programs (id INT, name VARCHAR(50), type VARCHAR(30), location VARCHAR(30)); INSERT INTO justice_programs (id, name, type, location) VALUES (1, 'Mediation Center', 'Restorative Justice', 'San Francisco'); INSERT INTO justice_programs (id, name, type, location) VALUES (2, 'Victim-Offender Reconcilia...
What is the total number of restorative justice programs in the 'justice_programs' table?
SELECT COUNT(*) FROM justice_programs WHERE type = 'Restorative Justice';
gretelai_synthetic_text_to_sql
CREATE TABLE security_incidents (id INT, incident_date DATE);
What is the average number of security incidents per day in the last week?
SELECT AVG(COUNT(*)) FROM security_incidents WHERE incident_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK) GROUP BY DATE(incident_date);
gretelai_synthetic_text_to_sql
CREATE TABLE sector_consumption (year INT, sector TEXT, consumption FLOAT); INSERT INTO sector_consumption (year, sector, consumption) VALUES (2015, 'residential', 123.5), (2015, 'commercial', 234.6), (2016, 'residential', 130.2), (2016, 'commercial', 240.1), (2019, 'commercial', 270.9), (2019, 'industrial', 385.1), (2...
What is the combined water consumption by commercial and industrial sectors in 2019 and 2020?
SELECT consumption FROM sector_consumption WHERE sector IN ('commercial', 'industrial') AND year IN (2019, 2020)
gretelai_synthetic_text_to_sql
CREATE TABLE concerts (concert_id INT, genre VARCHAR(10), region VARCHAR(10), year INT, revenue INT); INSERT INTO concerts (concert_id, genre, region, year, revenue) VALUES (1, 'Classical', 'Europe', 2018, 50000), (2, 'Jazz', 'US', 2019, 30000), (3, 'Classical', 'Europe', 2018, 60000);
What is the total revenue generated by classical music concerts in Europe in 2018?
SELECT SUM(revenue) FROM concerts WHERE genre = 'Classical' AND region = 'Europe' AND year = 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE VolunteerSkills (volunteer_id INT, skill VARCHAR(255), experience INT);
Create a table named 'VolunteerSkills' with columns 'volunteer_id', 'skill', and 'experience'.
CREATE TABLE VolunteerSkills (volunteer_id INT, skill VARCHAR(255), experience INT);
gretelai_synthetic_text_to_sql
CREATE TABLE restaurants (id INT, name VARCHAR(255), city VARCHAR(255)); INSERT INTO restaurants (id, name, city) VALUES (1, 'Restaurant A', 'City A'), (2, 'Restaurant B', 'City B'), (3, 'Organic Garden', 'City A'); CREATE TABLE dishes (id INT, name VARCHAR(255), type VARCHAR(255), restaurant_id INT); INSERT INTO dishe...
Identify the unique vegetarian dishes served at restaurants located in 'City A'.
SELECT d.name FROM dishes d JOIN restaurants r ON d.restaurant_id = r.id WHERE d.type = 'vegetarian' AND r.city = 'City A' GROUP BY d.name;
gretelai_synthetic_text_to_sql
CREATE TABLE service_requests (id INT, request_type VARCHAR(255), request_date DATE); INSERT INTO service_requests (id, request_type, request_date) VALUES (1, 'Road Repair', '2022-01-01'), (2, 'Waste Collection', '2022-02-01'), (3, 'Street Lighting', '2022-01-15');
List all public service requests related to road repair in the 'service_requests' table.
SELECT * FROM service_requests WHERE request_type = 'Road Repair';
gretelai_synthetic_text_to_sql
CREATE TABLE reporters (id INT, name VARCHAR(50), gender VARCHAR(10), age INT); INSERT INTO reporters (id, name, gender, age) VALUES (1, 'Anna Smith', 'Female', 35), (2, 'John Doe', 'Male', 40);
What is the average age of all female reporters in the "reporters" table?
SELECT AVG(age) FROM reporters WHERE gender = 'Female';
gretelai_synthetic_text_to_sql