context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE Players (PlayerID INT, Age INT, Gender VARCHAR(10), FavoriteGenre VARCHAR(20)); INSERT INTO Players (PlayerID, Age, Gender, FavoriteGenre) VALUES (1, 35, 'Female', 'Adventure'), (2, 28, 'Male', 'Action');
What is the average age of players who play adventure games?
SELECT AVG(Age) as AvgAge FROM Players WHERE FavoriteGenre = 'Adventure';
gretelai_synthetic_text_to_sql
CREATE TABLE accessibility_features (id INT PRIMARY KEY, product_name VARCHAR(50), feature_type VARCHAR(50), status VARCHAR(20), company_location VARCHAR(50)); INSERT INTO accessibility_features (id, product_name, feature_type, status, company_location) VALUES (1, 'TalkAssist', 'Screen Reader', 'Active', 'Brazil');
Insert a new record into the "accessibility_features" table for a new screen reader technology from a Latin American company
INSERT INTO accessibility_features (product_name, feature_type, status, company_location) VALUES ('TalkAssist', 'Screen Reader', 'Active', 'Brazil');
gretelai_synthetic_text_to_sql
CREATE TABLE the_daily (title VARCHAR(255), word_count INT, topic VARCHAR(255));
What is the average word count of articles on 'politics' in 'the_daily'?
SELECT AVG(word_count) AS avg_word_count FROM the_daily WHERE topic = 'politics';
gretelai_synthetic_text_to_sql
CREATE TABLE threat_actors (actor_id INT, actor_name VARCHAR(255), intrusion_attempts INT, last_seen TIMESTAMP); INSERT INTO threat_actors (actor_id, actor_name, intrusion_attempts, last_seen) VALUES (1, 'Actor A', 150, '2022-02-01 12:00:00'), (2, 'Actor B', 120, '2022-02-03 16:30:00'), (3, 'Actor C', 90, '2022-02-05 0...
List the top 3 threat actors with the highest number of intrusion attempts in the last week?
SELECT actor_name, intrusion_attempts FROM (SELECT actor_name, intrusion_attempts, ROW_NUMBER() OVER (ORDER BY intrusion_attempts DESC) as rank FROM threat_actors WHERE last_seen >= DATEADD(week, -1, CURRENT_TIMESTAMP)) subquery WHERE rank <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE patients (patient_id INT, age INT, gender VARCHAR(10), state VARCHAR(20), disease VARCHAR(20)); INSERT INTO patients (patient_id, age, gender, state, disease) VALUES (1, 45, 'Male', 'New York', 'HIV'); INSERT INTO patients (patient_id, age, gender, state, disease) VALUES (2, 34, 'Female', 'California', 'He...
What is the total number of patients who have been diagnosed with HIV and hepatitis C in the state of New York?
SELECT COUNT(*) FROM patients WHERE state = 'New York' AND (disease = 'HIV' OR disease = 'Hepatitis C')
gretelai_synthetic_text_to_sql
CREATE TABLE tram_trips (trip_id INT, start_time TIMESTAMP, end_time TIMESTAMP, trip_distance FLOAT, fare FLOAT, wheelchair_accessible BOOLEAN, tram_line INT);
What is the total fare collected for wheelchair-accessible trams in Berlin, by tram line?
SELECT tram_line, SUM(fare) FROM tram_trips WHERE wheelchair_accessible = TRUE GROUP BY tram_line;
gretelai_synthetic_text_to_sql
CREATE TABLE public_transportation (id INT, type VARCHAR(50), city VARCHAR(50));
Find the top 5 most common types of public transportation in Moscow?
SELECT type, COUNT(*) FROM public_transportation WHERE city = 'Moscow' GROUP BY type ORDER BY COUNT(*) DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE metro_lines (id INT, name TEXT, start_time TIME, end_time TIME); CREATE VIEW earliest_latest_times AS SELECT name, MIN(start_time) as earliest_start, MAX(end_time) as latest_end FROM metro_lines GROUP BY name;
What is the earliest and latest time a metro line in Madrid starts and ends?
SELECT name, earliest_start, latest_end FROM earliest_latest_times WHERE name = 'Madrid Line 1';
gretelai_synthetic_text_to_sql
CREATE TABLE military_sales_trend (id INT, year INT, quarter INT, region VARCHAR(20), equipment_type VARCHAR(30), revenue DECIMAL(10,2));
What is the trend of military equipment sales in the Middle East over the last 3 years?
SELECT year, quarter, AVG(revenue) as avg_revenue FROM military_sales_trend WHERE region = 'Middle East' GROUP BY year, quarter ORDER BY year, quarter;
gretelai_synthetic_text_to_sql
CREATE TABLE donors (id INT, name TEXT, last_donation_date DATE); INSERT INTO donors (id, name, last_donation_date) VALUES (1, 'John Doe', '2020-01-01'), (2, 'Jane Smith', '2021-01-01'), (3, 'Pedro Alvarez', '2018-01-01');
Delete records of donors who have not donated in the last 3 years in Canada.
DELETE FROM donors WHERE last_donation_date < NOW() - INTERVAL 3 YEAR AND country = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels (vessel_id VARCHAR(10), name VARCHAR(20), type VARCHAR(20), max_speed FLOAT); INSERT INTO Vessels (vessel_id, name, type, max_speed) VALUES ('1', 'Vessel A', 'Cargo', 20.5), ('2', 'Vessel B', 'Tanker', 15.2), ('3', 'Vessel C', 'Tanker', 18.1), ('4', 'Vessel D', 'Cargo', 12.6);
What is the max speed of all vessels?
SELECT MAX(max_speed) FROM Vessels;
gretelai_synthetic_text_to_sql
CREATE TABLE menu_items (id INT, name VARCHAR(255), category VARCHAR(255), price DECIMAL(5,2)); INSERT INTO menu_items (id, name, category, price) VALUES (1, 'Burger', 'Main', 8.99), (2, 'Fries', 'Side', 2.99); CREATE TABLE orders (id INT, menu_item_id INT, quantity INT, order_date DATE); INSERT INTO orders (id, menu_i...
Which menu items were sold the least in a specific time period?
SELECT m.id, m.name, m.category, SUM(o.quantity) AS total_quantity FROM menu_items m JOIN orders o ON m.id = o.menu_item_id WHERE o.order_date BETWEEN '2022-01-01' AND '2022-01-31' GROUP BY m.id ORDER BY total_quantity ASC;
gretelai_synthetic_text_to_sql
CREATE TABLE projects (id INT, funder TEXT, total_funding DECIMAL); INSERT INTO projects (id, funder, total_funding) VALUES (1, 'European Union', 20000.00), (2, 'World Bank', 30000.00), (3, 'United Nations', 40000.00);
How many total projects have been funded by the European Union and the World Bank?
SELECT COUNT(*) FROM projects WHERE funder IN ('European Union', 'World Bank');
gretelai_synthetic_text_to_sql
CREATE TABLE journalists (id INT PRIMARY KEY, name VARCHAR(255), department VARCHAR(255), ethnicity VARCHAR(255)); INSERT INTO journalists (id, name, department, ethnicity) VALUES (1, 'Sanaa Ahmed', 'reporting', 'Pakistani'), (2, 'José Rodriguez', 'reporting', 'Mexican'), (3, 'Emma Thompson', 'editing', 'British'), (4,...
List the names and ethnicities of all journalists in the 'reporting' department
SELECT name, ethnicity FROM journalists WHERE department = 'reporting';
gretelai_synthetic_text_to_sql
CREATE TABLE student_records (student_id INT, student_name VARCHAR(255), department VARCHAR(255)); INSERT INTO student_records (student_id, student_name, department) VALUES (1, 'Alice Smith', 'Computer Science'), (2, 'John Doe', 'Electrical Engineering'), (3, 'Bob Johnson', 'Mechanical Engineering');
Delete all records from the student_records table where the student_name is 'John Doe' and the department is 'Electrical Engineering'
DELETE FROM student_records WHERE student_name = 'John Doe' AND department = 'Electrical Engineering';
gretelai_synthetic_text_to_sql
CREATE TABLE blue_whale_population (year INT, population INT); INSERT INTO blue_whale_population (year, population) VALUES (2000, 9000), (2001, 9500), (2002, 10000), (2003, 10500);
What is the average population size of the blue whale for every 2 consecutive years?
SELECT AVG(population) FROM (SELECT population, ROW_NUMBER() OVER (ORDER BY year) / 2 as group_number FROM blue_whale_population) as grouped_populations GROUP BY group_number;
gretelai_synthetic_text_to_sql
CREATE TABLE companies (company_name VARCHAR(20), industry VARCHAR(20), date DATE, revenue INT); INSERT INTO companies VALUES ('CompanyA', 'food', '2022-01-01', 1000), ('CompanyB', 'tech', '2022-01-01', 2000);
What is the total ad revenue for companies in the 'food' industry that have advertised on Facebook and Instagram in the past quarter?
SELECT SUM(c.revenue) as total_revenue FROM companies c WHERE c.industry = 'food' AND (c.date >= DATEADD(quarter, -1, GETDATE()) AND c.platform IN ('Facebook', 'Instagram'));
gretelai_synthetic_text_to_sql
CREATE TABLE vehicle_safety_test_results (id INT PRIMARY KEY, vehicle_type VARCHAR(255), safety_rating DECIMAL(3,2));
Show the 'vehicle_type' and 'safety_rating' from 'vehicle_safety_test_results' table
SELECT vehicle_type, safety_rating FROM vehicle_safety_test_results;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, customer_name VARCHAR(255)); CREATE TABLE orders (order_id INT, customer_id INT, order_date DATE); INSERT INTO customers (customer_id, customer_name) VALUES (1, 'John Doe'), (2, 'Jane Smith'); INSERT INTO orders (order_id, customer_id, order_date) VALUES (1, 1, '2022-01-01'), (2...
Which customers have placed an order on or after January 1, 2022?
SELECT c.customer_name FROM customers c JOIN orders o ON c.customer_id = o.customer_id WHERE o.order_date >= '2022-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE producers (id INT, name VARCHAR(255), location VARCHAR(255), cost DECIMAL(10,2)); INSERT INTO producers (id, name, location, cost) VALUES (1, 'Fabric Inc', 'Italy', 250.00), (2, 'Stitch Time', 'USA', 120.00);
Which factories in Italy have a production cost above 200?
SELECT name, cost FROM producers WHERE location = 'Italy' AND cost > 200;
gretelai_synthetic_text_to_sql
CREATE TABLE MenuItems (MenuItemID int, RestaurantID int, MenuItemName varchar(50), SaleAmount numeric(10, 2), SustainabilityRating int); INSERT INTO MenuItems (MenuItemID, RestaurantID, MenuItemName, SaleAmount, SustainabilityRating) VALUES (1, 1, 'Quinoa Salad', 2000, 5); INSERT INTO MenuItems (MenuItemID, Restaurant...
Identify menu items that need sustainable sourcing improvements, i.e., items with low sales but low sustainability ratings.
SELECT M.MenuItemName, M.SaleAmount, M.SustainabilityRating FROM MenuItems M WHERE M.SaleAmount < (SELECT AVG(SaleAmount) FROM MenuItems) AND M.SustainabilityRating < (SELECT AVG(SustainabilityRating) FROM MenuItems);
gretelai_synthetic_text_to_sql
CREATE TABLE sustainable_practices (practice_id INT, practice_name VARCHAR(50), destination_id INT, PRIMARY KEY (practice_id), FOREIGN KEY (destination_id) REFERENCES destinations(destination_id));CREATE TABLE destinations (destination_id INT, destination_name VARCHAR(50), region_id INT, PRIMARY KEY (destination_id));C...
What are the top 3 countries with the highest number of sustainable tourism practices?
SELECT c.country_name, COUNT(sp.practice_id) as total_sustainable_practices, RANK() OVER (ORDER BY COUNT(sp.practice_id) DESC) as sustainable_rank FROM sustainable_practices sp JOIN destinations d ON sp.destination_id = d.destination_id JOIN countries c ON d.country_id = c.country_id GROUP BY c.country_name ORDER BY su...
gretelai_synthetic_text_to_sql
CREATE TABLE chemicals (id INT, name VARCHAR(255), weight FLOAT, region VARCHAR(255));
What is the average weight of chemicals produced in the Asia Pacific region, grouped by chemical category?
SELECT category, AVG(weight) as avg_weight FROM (SELECT chemicals.name as category, AVG(weight) as weight FROM chemicals WHERE region = 'Asia Pacific' GROUP BY chemicals.name) as subquery GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE ports (id VARCHAR(20), name VARCHAR(20), location VARCHAR(20)); CREATE TABLE incidents (id INT, port_id VARCHAR(20), type VARCHAR(20)); INSERT INTO ports (id, name, location) VALUES ('1', 'PortA', 'USA'), ('2', 'PortB', 'Canada'), ('3', 'PortC', 'Mexico'); INSERT INTO incidents (id, port_id, type) VALUES (...
How many safety incidents were reported for 'PortB'?
SELECT COUNT(*) FROM incidents WHERE port_id = (SELECT id FROM ports WHERE name = 'PortB');
gretelai_synthetic_text_to_sql
CREATE TABLE creative_ai (app_id INT, app_name TEXT, release_year INT, region TEXT, satisfaction_score INT); INSERT INTO creative_ai (app_id, app_name, release_year, region, satisfaction_score) VALUES (1, 'Dreamscope', 2020, 'North America', 85); INSERT INTO creative_ai (app_id, app_name, release_year, region, satisfac...
What is the average satisfaction score for creative AI applications, grouped by region, for applications released in 2020?
SELECT region, AVG(satisfaction_score) FROM creative_ai WHERE release_year = 2020 GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE lobbying_meetings (meeting_id INT, lobbyist_name VARCHAR(255), official_name VARCHAR(255), meeting_date DATE);
What is the total number of lobbying meetings with government officials, grouped by lobbyist, in the 'lobbying_meetings' table?
SELECT lobbyist_name, COUNT(meeting_id) AS total_meetings FROM lobbying_meetings GROUP BY lobbyist_name;
gretelai_synthetic_text_to_sql
CREATE TABLE FranceEnergy (id INT, sequence INT, energy INT); INSERT INTO FranceEnergy (id, sequence, energy) VALUES (1, 1, 50), (2, 2, 55), (3, 3, 60);
What is the maximum energy consumption for the first 2 virtual tours in France?
SELECT MAX(energy) OVER (PARTITION BY sequence ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING) AS max_energy FROM FranceEnergy WHERE sequence <= 2;
gretelai_synthetic_text_to_sql
CREATE TABLE donors (id INT, name TEXT, region TEXT, donation_amount DECIMAL(10,2)); INSERT INTO donors (id, name, region, donation_amount) VALUES (1, 'John Smith', 'Asia-Pacific', 500.00), (2, 'Jane Doe', 'Europe', 1500.00), (3, 'James Lee', 'Asia-Pacific', 2000.00);
How many donors have made donations greater than $1000 in the Europe region?
SELECT COUNT(*) FROM donors WHERE donation_amount > 1000 AND region = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE african_ebikes (city VARCHAR(20), num_ebikes INT); INSERT INTO african_ebikes (city, num_ebikes) VALUES ('Cairo', 120), ('Johannesburg', 100), ('Cape Town', 80), ('Nairobi', 60), ('Lagos', 40);
Get the city with the most shared e-bikes in Africa.
SELECT city, num_ebikes FROM (SELECT city, num_ebikes, RANK() OVER (ORDER BY num_ebikes DESC) rn FROM african_ebikes) tmp WHERE rn = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, DonorName TEXT, DonationAmount DECIMAL(10,2), DonationDate DATE);
What is the total donation amount for the year 2020?
SELECT SUM(DonationAmount) FROM Donors WHERE YEAR(DonationDate) = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE irrigation_system (irrigation_id INT, system_type VARCHAR(20), status VARCHAR(10));
Insert new records into the 'irrigation_system' table with values (1, 'drip', 'active')
INSERT INTO irrigation_system (irrigation_id, system_type, status) VALUES (1, 'drip', 'active');
gretelai_synthetic_text_to_sql
CREATE TABLE community_projects (id INT, project_name VARCHAR(255), location VARCHAR(255), sector VARCHAR(255), cost FLOAT); INSERT INTO community_projects (id, project_name, location, sector, cost) VALUES (1, 'Cultural Center', 'Village A', 'Culture', 18000.00), (2, 'Community Health Center', 'Village B', 'Health', 35...
Calculate the average cost of rural community projects per sector and rank them in ascending order.
SELECT sector, AVG(cost) AS avg_cost, RANK() OVER (ORDER BY AVG(cost)) AS sector_rank FROM community_projects GROUP BY sector ORDER BY avg_cost ASC;
gretelai_synthetic_text_to_sql
CREATE TABLE Wearable (DeviceID INT PRIMARY KEY, MemberID INT, Steps INT, Date DATE); CREATE TABLE Member (MemberID INT PRIMARY KEY, Age INT, Gender VARCHAR(10), MembershipStart DATE);
What is the maximum number of steps taken by members, grouped by age?
SELECT Member.Age, MAX(Wearable.Steps) FROM Wearable INNER JOIN Member ON Wearable.MemberID = Member.MemberID GROUP BY Member.Age;
gretelai_synthetic_text_to_sql
CREATE TABLE astrobiology_experiments (experiment_id INT, name VARCHAR(100), spacecraft VARCHAR(100), launch_date DATE, experiments_conducted INT); CREATE TABLE mission_data (mission_id INT, name VARCHAR(100), organization VARCHAR(100), launch_date DATE, mission_cost FLOAT);
What is the average number of experiments conducted per mission in the astrobiology_experiments and mission_data tables?
SELECT AVG(experiments_conducted/1.0) FROM astrobiology_experiments, mission_data WHERE astrobiology_experiments.launch_date = mission_data.launch_date;
gretelai_synthetic_text_to_sql
CREATE TABLE fares (ticket_type VARCHAR(20), fare DECIMAL(5,2)); INSERT INTO fares (ticket_type, fare) VALUES ('Child', 2.00), ('Adult', 3.00), ('Senior', 2.50);
Update the fare of the 'Senior' ticket type to $2.75 in the 'fares' table
UPDATE fares SET fare = 2.75 WHERE ticket_type = 'Senior';
gretelai_synthetic_text_to_sql
CREATE TABLE iot_devices (id INT, field_id VARCHAR(10), device_type VARCHAR(20), last_updated TIMESTAMP); INSERT INTO iot_devices (id, field_id, device_type, last_updated) VALUES (1, 'Field005', 'humidity_sensor', '2022-02-03 10:00:00'), (2, 'Field005', 'temperature_sensor', '2022-02-01 10:00:00');
How many IoT devices were updated in 'Field005' in the past week?
SELECT COUNT(*) FROM iot_devices WHERE field_id = 'Field005' AND last_updated BETWEEN DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 7 DAY) AND CURRENT_TIMESTAMP;
gretelai_synthetic_text_to_sql
CREATE TABLE art_collection (museum VARCHAR(255), artist VARCHAR(255), art_type VARCHAR(255), year INT, value DECIMAL(10,2)); INSERT INTO art_collection (museum, artist, art_type, year, value) VALUES ('MoMA', 'Andy Warhol', 'Painting', 1962, 200000.00), ('MoMA', 'Jackson Pollock', 'Painting', 1952, 140000.00), ('Tate M...
What is the total value of the art collection of the MoMA?
SELECT SUM(value) FROM art_collection WHERE museum = 'MoMA';
gretelai_synthetic_text_to_sql
CREATE TABLE Platforms (platform_id INT, platform_name VARCHAR(255)); INSERT INTO Platforms (platform_id, platform_name) VALUES (1, 'Spotify'), (2, 'Apple Music'), (3, 'YouTube'); CREATE TABLE Plays (play_id INT, platform_id INT, song_id INT, plays INT); INSERT INTO Plays (play_id, platform_id, song_id, plays) VALUES (...
What is the distribution of plays for songs on each platform?
SELECT p.platform_name, s.song_id, SUM(pl.plays) AS total_plays FROM Platforms p JOIN Plays pl ON p.platform_id = pl.platform_id JOIN Songs s ON pl.song_id = s.song_id GROUP BY p.platform_name, s.song_id;
gretelai_synthetic_text_to_sql
CREATE TABLE farmers (id SERIAL PRIMARY KEY, name TEXT, region TEXT, annual_income INT);
Create a table named "farmers" with columns "id", "name", "region", and "annual_income" where "id" is the primary key
CREATE TABLE farmers (id SERIAL PRIMARY KEY, name TEXT, region TEXT, annual_income INT);
gretelai_synthetic_text_to_sql
CREATE TABLE fans (fan_id INT, fan_name VARCHAR(50), country VARCHAR(50));CREATE TABLE ticket_sales (sale_id INT, fan_id INT, sale_date DATE); INSERT INTO fans (fan_id, fan_name, country) VALUES (1, 'Fan1', 'USA'), (2, 'Fan2', 'Canada'), (3, 'Fan3', 'Mexico'); INSERT INTO ticket_sales (sale_id, fan_id, sale_date) VALUE...
Find the number of fans who purchased tickets from each country in the last 3 months.
SELECT f.country, COUNT(ts.fan_id) as num_fans FROM fans f JOIN ticket_sales ts ON f.fan_id = ts.fan_id WHERE ts.sale_date >= DATEADD(month, -3, GETDATE()) GROUP BY f.country;
gretelai_synthetic_text_to_sql
CREATE TABLE hotel_tech (hotel_id INT, hotel_name TEXT, region TEXT, feature TEXT); INSERT INTO hotel_tech (hotel_id, hotel_name, region, feature) VALUES (1, 'Hotel X', 'APAC', 'Smart Room Controls'), (2, 'Hotel Y', 'APAC', 'Mobile Check-in'), (3, 'Hotel Z', 'APAC', 'AI Housekeeping');
What are the top 3 hotel tech features adopted by hotels in APAC region?
SELECT feature, COUNT(*) as adoption_count FROM hotel_tech WHERE region = 'APAC' GROUP BY feature ORDER BY adoption_count DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE incident_reports (id INT, region VARCHAR(255), date DATE); INSERT INTO incident_reports (id, region, date) VALUES (1, 'APAC', '2022-01-01'), (2, 'AMER', '2022-02-05'), (3, 'APAC', '2022-03-20');
What is the total number of security incidents reported in the APAC region in the last quarter?
SELECT COUNT(*) FROM incident_reports WHERE region = 'APAC' AND date >= DATE_SUB(CURRENT_DATE, INTERVAL 90 DAY);
gretelai_synthetic_text_to_sql
CREATE TABLE News (news_id INT, title VARCHAR(255), publication_date DATE, author VARCHAR(255), underrepresented_author BOOLEAN); INSERT INTO News (news_id, title, publication_date, author, underrepresented_author) VALUES (1, 'News1', '2021-01-01', 'Author1', TRUE), (2, 'News2', '2021-02-10', 'Author2', FALSE), (3, 'Ne...
How many news articles were published per month in 2021 by underrepresented authors?
SELECT MONTH(publication_date), COUNT(*) FROM News WHERE underrepresented_author = TRUE AND YEAR(publication_date) = 2021 GROUP BY MONTH(publication_date);
gretelai_synthetic_text_to_sql
CREATE TABLE region (region_id INT, region_name TEXT, PRIMARY KEY (region_id)); CREATE TABLE timber (timber_id INT, region_id INT, year INT, volume INT, PRIMARY KEY (timber_id), FOREIGN KEY (region_id) REFERENCES region(region_id)); CREATE TABLE wildlife (wildlife_id INT, region_id INT, species_count INT, PRIMARY KEY (...
What is the total volume of timber produced by each region, along with the total number of wildlife species in those regions, grouped by year?
SELECT r.region_name, t.year, SUM(t.volume) AS total_timber_volume, COUNT(DISTINCT w.species_count) AS total_species_count FROM region r INNER JOIN timber t ON r.region_id = t.region_id INNER JOIN wildlife w ON r.region_id = w.region_id GROUP BY r.region_name, t.year ORDER BY t.year;
gretelai_synthetic_text_to_sql
CREATE TABLE EIAs (EIAID INT, MineID INT, Date DATE);
Identify mines with outdated environmental impact assessments (EIAs) that need to be updated.
SELECT Mines.MineName FROM Mines LEFT JOIN EIAs ON Mines.MineID = EIAs.MineID WHERE EIAs.Date < DATEADD(year, -3, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE vegetarian_menu (menu_item VARCHAR(255), price DECIMAL(10, 2), restaurant_name VARCHAR(255)); INSERT INTO vegetarian_menu (menu_item, price, restaurant_name) VALUES ('Falafel', 7.99, 'Middle Eastern Grill'), ('Hummus', 6.99, 'Middle Eastern Grill'), ('Tabbouleh', 8.99, 'Middle Eastern Grill');
What is the average price of vegetarian menu items in 'Middle Eastern Grill'?
SELECT AVG(price) FROM vegetarian_menu WHERE restaurant_name = 'Middle Eastern Grill';
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (id INTEGER, name VARCHAR(255), species VARCHAR(255), location VARCHAR(255));
What is the total number of marine species in the 'Atlantic Ocean'?
SELECT COUNT(*) FROM marine_species WHERE location = 'Atlantic Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE chemicals (id INT, name VARCHAR(255), safety_regulation VARCHAR(255));
Update the 'safety_protocols' table to reflect the latest safety regulations for each chemical.
UPDATE safety_protocols sp SET safety_protocol = (SELECT s.safety_regulation FROM chemicals c JOIN safety s ON c.name = s.name) WHERE sp.chemical_id = c.id;
gretelai_synthetic_text_to_sql
CREATE TABLE Exhibitions (id INT, title VARCHAR(255), genre VARCHAR(255), century VARCHAR(255)); INSERT INTO Exhibitions (id, title, genre, century) VALUES (1, 'Impressionism Exhibition', 'European', '19th Century');
Delete all exhibitions from the '19th Century' in the 'European' genre.
DELETE FROM Exhibitions WHERE genre = 'European' AND century = '19th Century';
gretelai_synthetic_text_to_sql
CREATE TABLE HeritageSites (id INT, name TEXT, region TEXT, annual_visitors INT); INSERT INTO HeritageSites (id, name, region, annual_visitors) VALUES (1, 'Machu Picchu', 'Americas', 120000), (2, 'Eiffel Tower', 'Europe', 7000000), (3, 'Chichen Itza', 'Americas', 1500000);
How many heritage sites in the Americas have more than 100,000 annual visitors?
SELECT COUNT(*) FROM HeritageSites WHERE region = 'Americas' AND annual_visitors > 100000
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists regions (region varchar(255));CREATE TABLE if not exists buses (bus_id serial primary key,route_id int,region varchar(255));CREATE TABLE if not exists fares (fare_id serial primary key,route_id int,price decimal);CREATE TABLE if not exists calendar (calendar_id serial primary key,date date,se...
What was the total revenue for buses in the NY region in January?
SELECT SUM(f.price) FROM buses b JOIN fares f ON b.route_id = f.route_id JOIN calendar c ON f.service_id = c.service_id WHERE b.region = 'NY' AND c.date BETWEEN '2022-01-01' AND '2022-01-31';
gretelai_synthetic_text_to_sql
CREATE TABLE VirtualRealms (PlayerID INT, AchievementsEarned INT, Points INT); INSERT INTO VirtualRealms (PlayerID, AchievementsEarned, Points) VALUES (1, 12, 450), (2, 15, 700), (3, 8, 300), (4, 18, 650), (5, 10, 520);
What is the total number of achievements earned by players in the "VirtualRealms" table, who have earned more than 500 points?
SELECT SUM(AchievementsEarned) FROM VirtualRealms WHERE Points > 500;
gretelai_synthetic_text_to_sql
CREATE TABLE production_sites(id INT, site_name TEXT, location TEXT, safety_score INT); INSERT INTO production_sites (id, site_name, location, safety_score) VALUES (1, 'Site A', 'California, USA', 90), (2, 'Site B', 'California, USA', 85);
What is the average safety score for production sites located in California, USA?
SELECT AVG(safety_score) FROM production_sites WHERE location = 'California, USA';
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists higher_ed;CREATE TABLE if not exists higher_ed.students(id INT, name VARCHAR(255), department VARCHAR(255), enrollment_date DATE);CREATE TABLE if not exists higher_ed.publications(id INT, title VARCHAR(255), author_id INT, publication_date DATE);
How many publications were authored or co-authored by graduate students in the Mathematics department in the last 3 years?
SELECT COUNT(*) FROM higher_ed.publications p JOIN higher_ed.students s ON p.author_id = s.id WHERE s.department = 'Mathematics' AND p.publication_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE Exhibitions (ExhibitionID INT, Title VARCHAR(50), Curator VARCHAR(50), City VARCHAR(50)); INSERT INTO Exhibitions (ExhibitionID, Title, Curator, City) VALUES (1, 'African Art Masters', 'Nana Agyeman', 'Accra'); INSERT INTO Exhibitions (ExhibitionID, Title, Curator, City) VALUES (2, 'Digital Art Africa', 'B...
Who are the curators of exhibitions in Africa?
SELECT Exhibitions.Curator FROM Exhibitions WHERE Exhibitions.City = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE Satellites (manufacturer VARCHAR(255), model VARCHAR(255), delivery_date DATE); INSERT INTO Satellites (manufacturer, model, delivery_date) VALUES ('SpaceTech Inc.', 'Sat1', '2020-01-01'), ('SpaceTech Inc.', 'Sat2', '2020-05-15'), ('SpaceTech Inc.', 'Sat3', '2019-12-20');
What was the average delivery time for satellites manufactured by SpaceTech Inc.?
SELECT AVG(DATEDIFF('2020-05-15', delivery_date)) AS avg_delivery_time FROM Satellites WHERE manufacturer = 'SpaceTech Inc.';
gretelai_synthetic_text_to_sql
CREATE TABLE healthcare_centers (name TEXT, location TEXT, size INT); INSERT INTO healthcare_centers (name, location, size) VALUES ('Center A', 'Rural Alabama', 100), ('Center B', 'Rural Alaska', 200), ('Center C', 'Rural California', 150), ('Center D', 'Rural Florida', 75);
List the top 3 states in the US with the highest number of rural healthcare centers.
SELECT location, COUNT(*) as center_count FROM healthcare_centers WHERE location LIKE 'Rural%' GROUP BY location ORDER BY center_count DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE football_prices (game_date DATE, tickets_sold INT, ticket_price DECIMAL(5,2)); INSERT INTO football_prices (game_date, tickets_sold, ticket_price) VALUES ('2022-01-01', 500, 75.50), ('2022-02-01', 700, 65.00), ('2022-03-01', 600, 80.00), ('2022-04-01', 800, 70.00), ('2022-05-01', 900, 60.00);
What is the average ticket price for football games in the last year, broken down by quarter?
SELECT CASE WHEN game_date >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR) AND game_date < DATE_SUB(CURDATE(), INTERVAL 9 MONTH) THEN 'Q1' WHEN game_date >= DATE_SUB(CURDATE(), INTERVAL 9 MONTH) AND game_date < DATE_SUB(CURDATE(), INTERVAL 6 MONTH) THEN 'Q2' WHEN game_date >= DATE_SUB(CURDATE(), INTERVAL 6 MONTH) AND game_date...
gretelai_synthetic_text_to_sql
CREATE TABLE billing (bill_id INT PRIMARY KEY AUTO_INCREMENT, client_id INT, case_type VARCHAR(50), total_cost DECIMAL(10,2));
Update the 'billing' table to set the 'total_cost' field to '2500' where the client's ID is 345 and the case type is 'divorce'.
UPDATE billing SET total_cost = 2500 WHERE client_id = 345 AND case_type = 'divorce';
gretelai_synthetic_text_to_sql
CREATE TABLE financial_capability (id INT, country VARCHAR(255), score INT);
Find the top 3 countries with the highest financial capability scores.
SELECT country, score FROM (SELECT country, score, ROW_NUMBER() OVER (ORDER BY score DESC) rn FROM financial_capability) t WHERE rn <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE satellites (id INT, name VARCHAR(50), country VARCHAR(50), target VARCHAR(50)); INSERT INTO satellites VALUES (1, 'Mars-1', 'Russia', 'Mars');
Which space agency has launched the most satellites to Mars?
SELECT country, COUNT(*) as count FROM satellites WHERE target = 'Mars' GROUP BY country ORDER BY count DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE historical_contexts (context_id INT, context_age INT, site_id INT); INSERT INTO historical_contexts (context_id, context_age, site_id) VALUES (1, 5000, 1), (2, 3500, 2), (3, 7000, 3), (4, 2000, 4), (5, 4500, 5);
What is the average historical context age for artifacts from the 'Indian Subcontinent' site?
SELECT AVG(context_age) FROM historical_contexts JOIN excavation_sites ON historical_contexts.site_id = excavation_sites.site_id WHERE excavation_sites.site_name = 'Indian Subcontinent';
gretelai_synthetic_text_to_sql
CREATE TABLE aquafarms (id INT, name TEXT); INSERT INTO aquafarms (id, name) VALUES (1, 'Farm A'), (2, 'Farm B'), (3, 'Farm C'), (5, 'Farm E'); CREATE TABLE harvest_data (aquafarm_id INT, species TEXT, harvested_quantity INT, timestamp TIMESTAMP);
What is the total quantity of fish harvested per month for each species at Farm E?
SELECT species, EXTRACT(MONTH FROM timestamp) AS month, SUM(harvested_quantity) AS total_harvested FROM harvest_data JOIN aquafarms ON harvest_data.aquafarm_id = aquafarms.id WHERE aquafarm_id = 5 GROUP BY species, month;
gretelai_synthetic_text_to_sql
CREATE TABLE Programs (ProgramID INT, Name TEXT, Region TEXT, Hours FLOAT); INSERT INTO Programs (ProgramID, Name, Region, Hours) VALUES (1, 'Reading Club', 'Northeast', 25), (2, 'Garden Club', 'Midwest', 30);
What is the average number of volunteer hours per program?
SELECT AVG(Hours) as AvgHoursPerProgram FROM Programs;
gretelai_synthetic_text_to_sql
CREATE TABLE ticket_prices(ticket_id INT, sport VARCHAR(10), price DECIMAL(5,2)); INSERT INTO ticket_prices(ticket_id, sport, price) VALUES (1, 'baseball', 75.00), (2, 'hockey', 50.00), (3, 'baseball', 100.00), (4, 'hockey', 60.00), (5, 'baseball', 155.00), (6, 'hockey', 35.00), (7, 'baseball', 80.00), (8, 'hockey', 70...
Find the average ticket price for each sport, excluding prices above $150.
SELECT sport, AVG(price) AS avg_price FROM ticket_prices WHERE price < 150 GROUP BY sport;
gretelai_synthetic_text_to_sql
CREATE TABLE digital_assets (asset_id INT, asset_name TEXT, total_transactions INT); INSERT INTO digital_assets (asset_id, asset_name, total_transactions) VALUES (1, 'AssetA', 500), (2, 'AssetB', 300), (3, 'AssetC', 700);
What is the total number of transactions for each digital asset in the 'digital_assets' table?
SELECT asset_name, SUM(total_transactions) FROM digital_assets GROUP BY asset_name;
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels (id INT, name VARCHAR(50), type VARCHAR(50), average_speed DECIMAL(5,2)); INSERT INTO Vessels (id, name, type, average_speed) VALUES (1, 'Vessel1', 'OilTanker', 15.5), (2, 'Vessel2', 'BulkCarrier', 12.3); CREATE TABLE Cargo (vessel_id INT, cargo_type VARCHAR(50), transport_date DATE); INSERT INTO C...
What is the average speed of vessels that transported oil in the last quarter?
SELECT AVG(Vessels.average_speed) FROM Vessels INNER JOIN Cargo ON Vessels.id = Cargo.vessel_id WHERE Cargo.cargo_type = 'Oil' AND Cargo.transport_date >= '2022-01-01' AND Cargo.transport_date <= '2022-03-31';
gretelai_synthetic_text_to_sql
CREATE TABLE threat_intelligence (id INT, group_name VARCHAR(255), indicator VARCHAR(255), indicator_type VARCHAR(255)); INSERT INTO threat_intelligence (id, group_name, indicator, indicator_type) VALUES (1, 'APT33', '192.168.0.1', 'IP address'), (2, 'APT33', 'example.com', 'domain name');
How many threat intelligence indicators are associated with the 'APT33' group and are of type 'IP address'?
SELECT COUNT(*) FROM threat_intelligence WHERE group_name = 'APT33' AND indicator_type = 'IP address';
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT PRIMARY KEY, name VARCHAR(255)); CREATE TABLE diversity_metrics (id INT PRIMARY KEY, company_id INT, gender VARCHAR(50), diversity_score DECIMAL(3,2));
Insert diversity metrics for 'RenewableEnergy'
INSERT INTO diversity_metrics (id, company_id, gender, diversity_score) VALUES (8, 106, 'Female', 0.70), (9, 106, 'Male', 0.30);
gretelai_synthetic_text_to_sql
CREATE TABLE art_programs (id INT, state VARCHAR(2), avg_age FLOAT); INSERT INTO art_programs (id, state, avg_age) VALUES (1, 'NY', 35.5), (2, 'CA', 32.7);
What is the average age of attendees who have participated in art programs in New York and California?
SELECT AVG(ap.avg_age) FROM art_programs ap WHERE ap.state IN ('NY', 'CA');
gretelai_synthetic_text_to_sql
CREATE TABLE Renewable_Energy (Source VARCHAR(30), Country VARCHAR(20), Installed_Capacity INT); INSERT INTO Renewable_Energy VALUES ('Wind', 'Canada', 12000), ('Solar', 'Canada', 8000), ('Hydro', 'Canada', 20000), ('Geothermal', 'Canada', 2000), ('Biomass', 'Canada', 3000);
List the top 3 renewable energy sources by installed capacity in descending order in Canada?
SELECT Source, Installed_Capacity FROM (SELECT Source, Installed_Capacity, RANK() OVER (ORDER BY Installed_Capacity DESC) as Rank FROM Renewable_Energy WHERE Country = 'Canada') tmp WHERE Rank <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE ApplicantData (ApplicantID int, JobPosition varchar(20), ApplicantType varchar(10), Department varchar(20)); INSERT INTO ApplicantData (ApplicantID, JobPosition, ApplicantType, Department) VALUES (1, 'Sales Representative', 'Applicant', 'Sales'), (2, 'Sales Representative', 'Interviewed', 'Sales'), (3, 'Sa...
What is the count of total applicants, interviewed applicants, and hired applicants by job position for the Sales department?
SELECT JobPosition, COUNT(CASE WHEN ApplicantType = 'Applicant' THEN 1 END) AS TotalApplicants, COUNT(CASE WHEN ApplicantType = 'Interviewed' THEN 1 END) AS InterviewedApplicants, COUNT(CASE WHEN ApplicantType = 'Hired' THEN 1 END) AS HiredApplicants FROM ApplicantData WHERE Department = 'Sales' GROUP BY JobPosition;
gretelai_synthetic_text_to_sql
CREATE TABLE shipments (id INT PRIMARY KEY, freight_forwarder VARCHAR(50), warehouse VARCHAR(50), status VARCHAR(20), delivery_date DATE);
Update the "freight_forwarder" column for all records in the "shipments" table where the "delivery_date" is older than 60 days
UPDATE shipments SET freight_forwarder = 'Reliable Freight' WHERE delivery_date < NOW() - INTERVAL 60 DAY;
gretelai_synthetic_text_to_sql
CREATE TABLE production (element VARCHAR(10), year INT, month INT, quantity INT); INSERT INTO production (element, year, month, quantity) VALUES ('Neodymium', 2015, 1, 120), ('Neodymium', 2015, 2, 150), ('Dysprosium', 2015, 1, 80), ('Dysprosium', 2015, 2, 90), ('Europium', 2015, 1, 70), ('Europium', 2015, 2, 75), ('Gad...
List the rare earth elements with their maximum monthly production quantity
SELECT element, MAX(quantity) FROM production GROUP BY element;
gretelai_synthetic_text_to_sql
CREATE TABLE public.community_policing (id serial PRIMARY KEY, state varchar(255), score int); INSERT INTO public.community_policing (state, score) VALUES ('Texas', 75), ('Texas', 80), ('Texas', 85);
What is the average community policing score in the state of Texas?
SELECT AVG(score) FROM public.community_policing WHERE state = 'Texas';
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels (vessel_name VARCHAR(255)); INSERT INTO Vessels (vessel_name) VALUES ('VesselE'), ('VesselF'); CREATE TABLE Voyages (vessel_name VARCHAR(255), voyage_date DATE, fuel_consumption INT); INSERT INTO Voyages (vessel_name, voyage_date, fuel_consumption) VALUES ('VesselE', '2021-02-01', 150), ('VesselE',...
What was the average fuel consumption by 'VesselE' during its voyages in February 2021?
SELECT AVG(fuel_consumption) FROM Voyages WHERE vessel_name = 'VesselE' AND voyage_date BETWEEN '2021-02-01' AND '2021-02-28';
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (id INT, name TEXT, join_date DATE);
How many new volunteers joined in each month of 2022?
SELECT DATE_FORMAT(join_date, '%Y-%m') as month, COUNT(DISTINCT name) as new_volunteers FROM volunteers WHERE join_date >= '2022-01-01' GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE Companies (id INT, name VARCHAR(255)); CREATE TABLE DigitalAssets (id INT, company_id INT, value DECIMAL(10, 2), asset_date DATE); INSERT INTO Companies (id, name) VALUES (1, 'CompanyX'), (2, 'CompanyY'), (3, 'CompanyZ'); INSERT INTO DigitalAssets (id, company_id, value, asset_date) VALUES (1, 1, 100, '202...
What is the average value of digital assets owned by the company with the name "CompanyX" in the month of June 2022?
SELECT AVG(value) FROM DigitalAssets JOIN Companies ON DigitalAssets.company_id = Companies.id WHERE Companies.name = 'CompanyX' AND DigitalAssets.asset_date >= '2022-06-01' AND DigitalAssets.asset_date < '2022-07-01';
gretelai_synthetic_text_to_sql
CREATE TABLE regions (region_id INT, region_name VARCHAR(255)); INSERT INTO regions (region_id, region_name) VALUES (1, 'Northeast'), (2, 'Southeast'), (3, 'Northwest'), (4, 'Southwest'); CREATE TABLE community_policing (initiative_id INT, region_id INT, initiative_name VARCHAR(255));
What is the total number of community policing initiatives in each region?
SELECT r.region_name, COUNT(c.initiative_id) FROM regions r INNER JOIN community_policing c ON r.region_id = c.region_id GROUP BY r.region_name;
gretelai_synthetic_text_to_sql
CREATE TABLE farm_biomass (farm_id INT, farm_type VARCHAR(255), biomass INT); INSERT INTO farm_biomass (farm_id, farm_type, biomass) VALUES (1, 'Pond', 6000), (2, 'Cage', 7000), (3, 'Recirculating', 8000), (4, 'Pond', 4000), (5, 'Cage', 5000);
What is the total biomass of fish in all farms, grouped by farm type, where the biomass is greater than 5000 tons?
SELECT farm_type, SUM(biomass) FROM farm_biomass WHERE biomass > 5000 GROUP BY farm_type;
gretelai_synthetic_text_to_sql
CREATE TABLE CreativeAIs (id INT, name VARCHAR(255), country VARCHAR(255), budget DECIMAL(10,2));
Which creative AI applications were developed in Canada and what were their budgets?
SELECT name, budget FROM CreativeAIs WHERE country = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE organic_categories (id INT, category VARCHAR(255), total_value DECIMAL(5,2)); INSERT INTO organic_categories (id, category, total_value) VALUES (1, 'Fruits', 350.50), (2, 'Vegetables', 280.25), (3, 'Grains', 120.00);
What are the top 2 organic categories with the highest inventory value?
SELECT category, total_value FROM organic_categories ORDER BY total_value DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE Athletes (AthleteID INT PRIMARY KEY, Name VARCHAR(100), Sport VARCHAR(50), TeamID INT); CREATE TABLE Awards (AwardID INT PRIMARY KEY, AthleteID INT, Award VARCHAR(50), Year INT);
What are the names of athletes who have won the 'Most Valuable Player' award and their corresponding sports?
SELECT Athletes.Name, Athletes.Sport FROM Athletes INNER JOIN Awards ON Athletes.AthleteID = Awards.AthleteID WHERE Awards.Award = 'Most Valuable Player';
gretelai_synthetic_text_to_sql
CREATE TABLE if NOT EXISTS workers (id INT, industry VARCHAR(20), is_union_member BOOLEAN); INSERT INTO workers (id, industry, is_union_member) VALUES (1, 'healthcare', false), (2, 'healthcare', true), (3, 'retail', false);
How many workers in the 'healthcare' industry are not part of a union?
SELECT COUNT(*) FROM workers WHERE industry = 'healthcare' AND is_union_member = false;
gretelai_synthetic_text_to_sql
CREATE TABLE matches (match_id INT, team1_id INT, team2_id INT, winner INT, score INT); INSERT INTO matches (match_id, team1_id, team2_id, winner, score) VALUES (1, 504, 505, 505, 200);
What is the total number of matches played by cricket team 504?
SELECT COUNT(*) FROM matches WHERE team1_id = 504 OR team2_id = 504;
gretelai_synthetic_text_to_sql
CREATE TABLE storage_facilities (id INT, name TEXT, state TEXT, temperature FLOAT); INSERT INTO storage_facilities (id, name, state, temperature) VALUES (1, 'Facility1', 'Texas', 22.5), (2, 'Facility2', 'Texas', 23.3);
What is the average temperature in the chemical storage facilities in Texas?
SELECT AVG(temperature) FROM storage_facilities WHERE state = 'Texas';
gretelai_synthetic_text_to_sql
CREATE TABLE projects_v3 (project_id INT, project_name VARCHAR(50), budget DECIMAL(10, 2), area VARCHAR(50)); INSERT INTO projects_v3 (project_id, project_name, budget, area) VALUES (10, 'ProjectG', 11000000.00, 'Urban'), (11, 'ProjectH', 13000000.00, 'Urban'), (12, 'ProjectI', 14000000.00, 'Urban');
What is the total number of public transportation projects in the "projects_v3" table for projects with a budget more than $10 million and less than $15 million, ordered by budget in descending order?
SELECT COUNT(*) FROM projects_v3 WHERE budget > 10000000.00 AND budget < 15000000.00 ORDER BY budget DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE country_waste (country VARCHAR(255), year INT, waste_generation INT); INSERT INTO country_waste (country, year, waste_generation) VALUES ('Japan', 2020, 60000000);
What is the total waste generation for the country of Japan in 2020?
SELECT waste_generation FROM country_waste WHERE country='Japan' AND year=2020;
gretelai_synthetic_text_to_sql
CREATE TABLE funding (funding_id INT, company_id INT, amount DECIMAL(10,2)); CREATE TABLE companies (company_id INT, industry VARCHAR(255), founding_year INT); INSERT INTO funding (funding_id, company_id, amount) VALUES (1, 1, 150000.00), (2, 2, 200000.00), (3, 3, 250000.00); INSERT INTO companies (company_id, industry...
What is the average funding amount for companies in the healthcare industry?
SELECT AVG(funding.amount) as avg_funding_healthcare FROM funding JOIN companies ON funding.company_id = companies.company_id WHERE companies.industry = 'Healthcare';
gretelai_synthetic_text_to_sql
CREATE TABLE Restaurants (restaurant_id INT, name TEXT, city TEXT, revenue FLOAT); INSERT INTO Restaurants (restaurant_id, name, city, revenue) VALUES (1, 'Asian Fusion', 'New York', 50000.00), (2, 'Bella Italia', 'Los Angeles', 60000.00), (3, 'Sushi House', 'New York', 70000.00), (4, 'Pizzeria La Rosa', 'Chicago', 800...
Determine the percentage of restaurants in each city that have a revenue higher than the city's average revenue.
SELECT city, 100.0 * COUNT(*) / (SELECT COUNT(*) FROM Restaurants r WHERE city = Restaurants.city) as percentage FROM Restaurants WHERE revenue > (SELECT AVG(revenue) FROM Restaurants WHERE city = Restaurants.city) GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE attorneys (attorney_id INT, attorney_name VARCHAR(30), cases_handled INT); CREATE TABLE billing_info (billing_id INT, attorney_id INT, case_id INT, amount FLOAT); INSERT INTO attorneys (attorney_id, attorney_name, cases_handled) VALUES (1, 'Smith', 20), (2, 'Johnson', 30), (3, 'Williams', 15); INSERT INTO ...
Who are the top 3 attorneys with the highest billing in criminal cases?
SELECT attorney_name, SUM(amount) as total_billing FROM billing_info JOIN attorneys ON billing_info.attorney_id = attorneys.attorney_id WHERE attorneys.cases_handled > 20 GROUP BY attorney_name ORDER BY total_billing DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Menu_Engineering (item VARCHAR(50), sales INT, date DATE);
How many items in the menu have not been sold in the past month?
SELECT COUNT(*) FROM Menu_Engineering WHERE item NOT IN (SELECT item FROM Menu_Engineering WHERE date >= DATEADD(month, -1, GETDATE())) AND sales > 0;
gretelai_synthetic_text_to_sql
CREATE TABLE PublicMeetings (ID INT, Date DATE, Status VARCHAR(255)); INSERT INTO PublicMeetings (ID, Date, Status) VALUES (1, '2022-08-01', 'Scheduled'), (2, '2022-08-15', 'Scheduled'), (3, '2022-09-01', 'Scheduled');
Delete the "PublicMeetings" table
DROP TABLE PublicMeetings;
gretelai_synthetic_text_to_sql
CREATE TABLE ocean (id INT, name VARCHAR(50)); CREATE TABLE level (id INT, value FLOAT, ocean_id INT); INSERT INTO ocean (id, name) VALUES (1, 'Atlantic'), (2, 'Pacific'); INSERT INTO level (id, value, ocean_id) VALUES (1, 7.8, 1), (2, 7.9, 2);
What is the maximum ocean acidification level ('level') recorded in the Atlantic Ocean ('ocean')?
SELECT MAX(level.value) FROM level INNER JOIN ocean ON level.ocean_id = ocean.id WHERE ocean.name = 'Atlantic';
gretelai_synthetic_text_to_sql
CREATE TABLE podcasts (id INT, title TEXT, host_id INT); INSERT INTO podcasts (id, title, host_id) VALUES (1, 'Podcast 1', 1); CREATE TABLE hosts (id INT, name TEXT, community TEXT); INSERT INTO hosts (id, name, community) VALUES (1, 'Host 1', 'Marginalized Community');
List all podcasts hosted by individuals from historically marginalized communities.
SELECT p.title FROM podcasts p INNER JOIN hosts h ON p.host_id = h.id WHERE h.community <> '';
gretelai_synthetic_text_to_sql
CREATE TABLE peacekeeping_operations (operation_id INT, organization VARCHAR(255), operation_name VARCHAR(255), start_date DATE, end_date DATE); INSERT INTO peacekeeping_operations (operation_id, organization, operation_name, start_date, end_date) VALUES (1, 'African Union', 'AMIS', '2004-07-25', '2007-12-31');
Select the total number of peacekeeping operations conducted by the African Union
SELECT COUNT(*) FROM peacekeeping_operations WHERE organization = 'African Union';
gretelai_synthetic_text_to_sql
CREATE TABLE clients (client_id INT, name VARCHAR(100), age INT, country VARCHAR(50)); INSERT INTO clients (client_id, name, age, country) VALUES (6, 'Mei Ling', 38, 'Singapore');
What is the average age of clients in Singapore with a loan amount greater than $20,000?
SELECT AVG(age) FROM clients c WHERE country = 'Singapore' AND (SELECT SUM(loan_amount) FROM loans l WHERE l.client_id = c.client_id) > 20000;
gretelai_synthetic_text_to_sql
CREATE TABLE military_equipment_maintenance (id INT PRIMARY KEY, equipment_name VARCHAR(255), category VARCHAR(50), last_maintenance_date DATE, next_maintenance_date DATE);
List all military equipment maintenance records for the 'ground' category
SELECT * FROM military_equipment_maintenance WHERE category = 'ground';
gretelai_synthetic_text_to_sql
CREATE TABLE deep_sea_exploration (id INT, location VARCHAR(50), depth INT, date DATE);
Update the depth of the record with id 2 in the table "deep_sea_exploration" to 5000
UPDATE deep_sea_exploration SET depth = 5000 WHERE id = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE EthicalAIPractices (Project VARCHAR(50), Description TEXT, StartDate DATE, EndDate DATE);
Insert a record for a new ethical AI project in the EthicalAIPractices table.
INSERT INTO EthicalAIPractices (Project, Description, StartDate, EndDate) VALUES ('AI for Accessibility', 'An AI project focused on improving accessibility for individuals with disabilities.', '2022-10-01', '2023-09-30');
gretelai_synthetic_text_to_sql