context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE Programs (ProgramID INT, ProgramName VARCHAR(50), Location VARCHAR(50), Budget DECIMAL(10,2), StartDate DATE, EndDate DATE); INSERT INTO Programs (ProgramID, ProgramName, Location, Budget, StartDate, EndDate) VALUES (5, 'Technology', 'Toronto', 30000.00, '2021-01-01', '2021-12-31'), (6, 'Social Work', 'Mon...
What is the average budget and number of programs for each location?
SELECT Location, AVG(Budget), COUNT(*) FROM Programs GROUP BY Location;
gretelai_synthetic_text_to_sql
CREATE TABLE water_plants (id INT, name VARCHAR(255), lat FLOAT, long FLOAT); INSERT INTO water_plants (id, name, lat, long) VALUES (1, 'Plant C', 37.7749, -122.4194), (2, 'Plant D', 29.7604, -95.3698); CREATE TABLE drought_status (id INT, region VARCHAR(255), status VARCHAR(255)); INSERT INTO drought_status (id, regio...
Which water treatment plants are located in drought-prone areas with a drought status of 'extreme'?
SELECT w.name, ds.status FROM water_plants w JOIN drought_status ds ON ST_DWithin(ST_SetSRID(ST_MakePoint(w.long, w.lat), 4326), ST_SetSRID(ST_MakePoint(ds.long, ds.lat), 4326), 100000) WHERE ds.status = 'extreme';
gretelai_synthetic_text_to_sql
CREATE TABLE students (id INT, name VARCHAR(30), program VARCHAR(30)); INSERT INTO students (id, name, program) VALUES (1, 'John Doe', 'Computer Science'), (2, 'Jane Smith', 'Physics');
List the names and programs of all graduate students
SELECT name, program FROM students;
gretelai_synthetic_text_to_sql
CREATE TABLE public.biosensors ( id SERIAL PRIMARY KEY, name VARCHAR(100), type VARCHAR(50), country VARCHAR(50), funding INTEGER ); CREATE TABLE public.startups ( id SERIAL PRIMARY KEY, name VARCHAR(100), industry VARCHAR(50), funding INTEGER ); CREATE TABLE public.investors ( id SERIAL PRIMARY KEY, name VARCHAR(100),...
What are the biosensors produced by startups that have received funding from government organizations, and are located in India or China?
SELECT biosensors.name FROM public.biosensors JOIN public.startups ON biosensors.name = startups.name JOIN public.investments ON startups.id = investments.startup_id JOIN public.investors ON investments.investor_id = investors.id WHERE (biosensors.country = 'India' OR biosensors.country = 'China') AND investors.type = ...
gretelai_synthetic_text_to_sql
CREATE TABLE space_missions (id INT, mission_name VARCHAR(50), launch_date DATE, country_of_origin VARCHAR(50)); INSERT INTO space_missions (id, mission_name, launch_date, country_of_origin) VALUES (1, 'Artemis I', '2022-08-29', 'USA'); INSERT INTO space_missions (id, mission_name, launch_date, country_of_origin) VALUE...
List all space missions that have involved international collaboration, along with the participating countries.
SELECT mission_name, country_of_origin FROM space_missions WHERE country_of_origin <> 'USA' AND country_of_origin <> (SELECT country_of_origin FROM space_missions WHERE mission_name = 'Artemis I');
gretelai_synthetic_text_to_sql
CREATE TABLE professor_advising (id INT, professor TEXT, num_students INT); INSERT INTO professor_advising (id, professor, num_students) VALUES (1, 'Alice', 5); INSERT INTO professor_advising (id, professor, num_students) VALUES (2, 'Bob', 3);
What are the research interests of professors who have advised the most graduate students in the past year?
SELECT professor, research_interest FROM professors p JOIN professor_advising pa ON p.name = pa.professor ORDER BY num_students DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, name VARCHAR(20), country VARCHAR(20), last_login TIMESTAMP); INSERT INTO users (id, name, country, last_login) VALUES (3, 'Bob', 'UK', '2021-01-04 10:00:00');
How many users from each country are there in the users table?
SELECT country, COUNT(*) as users FROM users GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE cultural_events (id INT, city VARCHAR(50), event VARCHAR(50), month VARCHAR(50), attendance INT); INSERT INTO cultural_events (id, city, event, month, attendance) VALUES (1, 'New York', 'Art Exhibit', 'January', 2500), (2, 'Los Angeles', 'Theater Performance', 'February', 1800), (3, 'Chicago', 'Music Conce...
What is the average attendance for cultural events by month?
SELECT month, AVG(attendance) as avg_attendance FROM cultural_events GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE production (id INT, labor_practices VARCHAR(20)); INSERT INTO production (id, labor_practices) VALUES (1, 'fair labor'), (2, 'fair labor'), (3, 'unfair labor');
How many items are produced using fair labor practices?
SELECT COUNT(*) FROM production WHERE labor_practices = 'fair labor';
gretelai_synthetic_text_to_sql
CREATE TABLE orders(order_id INT, dish VARCHAR(255), category VARCHAR(255), quantity INT); INSERT INTO orders(order_id, dish, category, quantity) VALUES (1, 'Tofu Stir Fry', 'Starter', 3), (2, 'Lentil Soup', 'Starter', 5), (3, 'Chickpea Curry', 'Main', 2), (4, 'Tofu Curry', 'Main', 4), (5, 'Quinoa Salad', 'Side', 6), (...
Show the bottom 2 least frequently ordered dishes in each category.
SELECT category, dish, quantity FROM (SELECT category, dish, quantity, ROW_NUMBER() OVER(PARTITION BY category ORDER BY quantity ASC) as row_num FROM orders) as ranked_orders WHERE row_num <= 2;
gretelai_synthetic_text_to_sql
CREATE TABLE dishes (dish_id INT, dish_name VARCHAR(255), last_sold DATE); CREATE TABLE orders (order_id INT, dish_id INT, quantity INT, order_date DATE); INSERT INTO dishes VALUES (1, 'Pizza Margherita', '2022-04-15'); INSERT INTO dishes VALUES (2, 'Chole Bhature', '2022-04-20'); INSERT INTO orders VALUES (1, 1, 5, '2...
How many times has each dish been ordered, excluding dishes sold more than 60 days ago?
SELECT d.dish_name, SUM(o.quantity) as total_orders FROM dishes d JOIN orders o ON d.dish_id = o.dish_id WHERE last_sold > DATE_SUB(CURRENT_DATE, INTERVAL 60 DAY) GROUP BY d.dish_name;
gretelai_synthetic_text_to_sql
CREATE TABLE algorithmic_fairness (algorithm_id INT, name TEXT, safety_rating FLOAT); INSERT INTO algorithmic_fairness (algorithm_id, name, safety_rating) VALUES (1, 'AlgorithmA', 4.3), (2, 'AlgorithmB', 4.7), (3, 'AlgorithmC', 4.5);
What is the average safety rating of all AI algorithms in the 'algorithmic_fairness' table?
SELECT AVG(safety_rating) FROM algorithmic_fairness;
gretelai_synthetic_text_to_sql
CREATE TABLE production_figures (well_name VARCHAR(255), year INT, monthly_production INT); INSERT INTO production_figures (well_name, year, monthly_production) VALUES ('Well A', 2018, 90000); INSERT INTO production_figures (well_name, year, monthly_production) VALUES ('Well A', 2019, 110000); INSERT INTO production_fi...
What was the production difference between 2019 and 2018 for each well?
SELECT well_name, (SUM(monthly_production) FILTER (WHERE year = 2019) - SUM(monthly_production) FILTER (WHERE year = 2018)) as production_difference FROM production_figures GROUP BY well_name
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels (VesselID INT, VesselName VARCHAR(255)); INSERT INTO Vessels (VesselID, VesselName) VALUES (1, 'VesselA'), (2, 'VesselB'), (3, 'VesselC'); CREATE TABLE Voyages (VoyageID INT, VesselID INT, StartPort VARCHAR(255), EndPort VARCHAR(255), VoyageDuration INT); INSERT INTO Voyages (VoyageID, VesselID, St...
What is the maximum duration of a voyage for vessels that have voyaged to the Port of Singapore?
SELECT MAX(VoyageDuration) FROM Voyages V WHERE V.EndPort = 'Singapore';
gretelai_synthetic_text_to_sql
CREATE TABLE biotech_startups (id INT, name VARCHAR(100), location VARCHAR(100), funding FLOAT); INSERT INTO biotech_startups (id, name, location, funding) VALUES (1, 'Startup A', 'India', 12000000); INSERT INTO biotech_startups (id, name, location, funding) VALUES (2, 'Startup B', 'India', 18000000);
Insert a new record for 'Startup C' with a funding amount of 25000000.
INSERT INTO biotech_startups (name, location, funding) VALUES ('Startup C', 'India', 25000000);
gretelai_synthetic_text_to_sql
CREATE TABLE green_infrastructure_funding (funding_id INT, project_id INT, funding_source VARCHAR(50), amount FLOAT, start_date DATE, end_date DATE);CREATE TABLE renewable_energy_projects (project_id INT, green_building_id INT, energy_source VARCHAR(50), capacity FLOAT, start_date DATE, end_date DATE);CREATE VIEW funde...
Summarize the total funding and number of projects for each energy source and funding source combination, using a SQL query with a window function.
SELECT energy_source, funding_source, total_funding, project_count FROM funding_summary;
gretelai_synthetic_text_to_sql
CREATE TABLE esg_scores_2 (investment_id INT, sector VARCHAR(20), esg_score FLOAT); INSERT INTO esg_scores_2 (investment_id, sector, esg_score) VALUES (1, 'Healthcare', 80.5), (2, 'Education', 87.3), (3, 'Healthcare', 84.2), (4, 'Finance', 82.1);
What is the minimum ESG score for investments in the 'Education' sector?
SELECT MIN(esg_score) FROM esg_scores_2 WHERE sector = 'Education';
gretelai_synthetic_text_to_sql
CREATE TABLE IoT_Sensors (farm_type VARCHAR(20), country VARCHAR(20), num_sensors INTEGER); INSERT INTO IoT_Sensors (farm_type, country, num_sensors) VALUES ('Vineyard', 'Australia', 450), ('Vineyard', 'Australia', 520), ('Orchard', 'Australia', 380), ('Orchard', 'Australia', 410), ('Orchard', 'Australia', 460), ('Vine...
List the number of IoT sensors in vineyards and orchards in Australia.
SELECT farm_type, SUM(num_sensors) FROM IoT_Sensors WHERE country = 'Australia' AND farm_type IN ('Vineyard', 'Orchard') GROUP BY farm_type;
gretelai_synthetic_text_to_sql
CREATE TABLE satellites (name TEXT, country TEXT, weight FLOAT); INSERT INTO satellites (name, country, weight) VALUES ('Hayabusa', 'Japan', 500.0);
What is the total weight of all satellites launched by Japan in the satellites table?
SELECT SUM(weight) FROM satellites WHERE country = 'Japan';
gretelai_synthetic_text_to_sql
CREATE TABLE drilling_data (well_id INT, drilling_date DATE, well_depth INT, country TEXT); INSERT INTO drilling_data (well_id, drilling_date, well_depth, country) VALUES (1, '2015-01-01', 12000, 'Brazil'); INSERT INTO drilling_data (well_id, drilling_date, well_depth, country) VALUES (2, '2016-05-15', 15000, 'Nigeria'...
How many wells were drilled in Nigeria between 2016 and 2018?
SELECT COUNT(*) FROM drilling_data WHERE country = 'Nigeria' AND drilling_date BETWEEN '2016-01-01' AND '2018-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE media_ethics (reader_id INT, preference TEXT, age INT); INSERT INTO media_ethics (reader_id, preference, age) VALUES (1, 'digital', 35), (2, 'print', 42), (3, 'digital', 28);
What is the average age of readers who prefer digital news in 'media_ethics' table?
SELECT AVG(age) FROM media_ethics WHERE preference = 'digital';
gretelai_synthetic_text_to_sql
CREATE TABLE field1 (date DATE, temperature FLOAT); INSERT INTO field1 (date, temperature) VALUES ('2021-06-01', 25.5), ('2021-06-02', 24.3), ('2021-06-03', 26.1);
What is the average temperature in the 'field1' for the month of June?
SELECT AVG(temperature) FROM field1 WHERE EXTRACT(MONTH FROM date) = 6 AND field1.date::text LIKE '2021-06-%';
gretelai_synthetic_text_to_sql
CREATE TABLE coal_mines (id INT, name TEXT, location TEXT, production INT); INSERT INTO coal_mines (id, name, location, production) VALUES (1, 'Coal Mine A', 'Country X', 1200); INSERT INTO coal_mines (id, name, location, production) VALUES (2, 'Coal Mine B', 'Country W', 1500); INSERT INTO coal_mines (id, name, locati...
How many coal mines in the 'coal_mines' table are located in 'Country W' and produce more than 1000 tons of coal?
SELECT COUNT(*) FROM coal_mines WHERE location = 'Country W' AND production > 1000;
gretelai_synthetic_text_to_sql
CREATE TABLE orders(id INT, date DATE, quantity INT); INSERT INTO orders(id, date, quantity) VALUES (1, '2022-01-01', 3), (2, '2022-02-01', 5), (3, '2022-03-01', 4);
What is the moving average of customer orders for the past 3 months?
SELECT date, AVG(quantity) OVER (ORDER BY date ROWS BETWEEN 89 PRECEDING AND CURRENT ROW) as moving_average FROM orders WHERE date >= CURRENT_DATE - INTERVAL '3 months';
gretelai_synthetic_text_to_sql
CREATE TABLE vendors (id INT, name VARCHAR(50), type VARCHAR(50)); INSERT INTO vendors (id, name, type) VALUES (1, 'Sushi Bar', 'Restaurant'), (2, 'Bakery', 'Restaurant'), (3, 'Grocery', 'Market'), (4, 'Organic Farm', 'Farm'), (5, 'Tofu Producer', 'Manufacturer');
Show the number of vendors for each type
SELECT type, COUNT(*) AS vendor_count FROM vendors GROUP BY type;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists bioprocessing;CREATE TABLE if not exists bioprocessing.projects (id INT PRIMARY KEY, name VARCHAR(100), region VARCHAR(100)); INSERT INTO bioprocessing.projects (id, name, region) VALUES (1, 'ProjA', 'Dubai'), (2, 'ProjB', 'Riyadh'), (3, 'ProjC', 'Johannesburg'), (4, 'ProjD', 'Cape Town'), (...
How many bioprocess engineering projects are in the Middle East and Africa?
SELECT COUNT(*) FROM bioprocessing.projects WHERE region = 'Middle East' OR region = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name VARCHAR(100), sales INT, certification VARCHAR(20)); INSERT INTO products (product_id, product_name, sales, certification) VALUES (1, 'Lipstick A', 5000, 'cruelty-free'), (2, 'Mascara B', 7000, 'not_certified'), (3, 'Foundation C', 8000, 'cruelty-free'); CREATE TABLE ...
What is the total sales volume of cosmetic products in the Brazilian market that are not certified cruelty-free and contain 'alcohol' as an ingredient?
SELECT SUM(products.sales) FROM products JOIN ingredients ON products.product_id = ingredients.product_id JOIN countries ON products.country_code = countries.country_code WHERE products.certification != 'cruelty-free' AND ingredients.ingredient_name = 'alcohol' AND countries.country_name = 'Brazil';
gretelai_synthetic_text_to_sql
CREATE TABLE Artifacts (ArtifactID INT, ArtifactName TEXT, Period TEXT, AnalyzedBy TEXT); INSERT INTO Artifacts (ArtifactID, ArtifactName, Period, AnalyzedBy) VALUES (1, 'Pompeii Amphora', 'Roman', 'UK');
List all artifacts from the Roman period, analyzed by researchers from the UK and USA.
SELECT ArtifactName FROM Artifacts WHERE Period = 'Roman' AND AnalyzedBy IN ('UK', 'USA')
gretelai_synthetic_text_to_sql
CREATE TABLE Attorneys (AttorneyID int, Name varchar(50)); INSERT INTO Attorneys VALUES (1, 'John Smith'), (2, 'Jane Doe'); CREATE TABLE Cases (CaseID int, AttorneyID int, Outcome varchar(10)); INSERT INTO Cases VALUES (1, 1, 'Won'), (2, 1, 'Lost'), (3, 2, 'Won'), (4, 2, 'Won');
How many cases were handled by each attorney by case outcome?
SELECT A.Name, C.Outcome, COUNT(C.CaseID) as NumCases FROM Attorneys A JOIN Cases C ON A.AttorneyID = C.AttorneyID GROUP BY A.Name, C.Outcome;
gretelai_synthetic_text_to_sql
CREATE TABLE support_programs (program_name VARCHAR(50), department VARCHAR(50)); INSERT INTO support_programs VALUES ('Counseling', 'Psychology'), ('Group Therapy', 'Social Work'), ('Counseling', 'Psychology'), ('Accessibility Services', 'General');
List the number of support programs offered by each department, excluding any duplicate program names, for the departments of social work and psychology.
SELECT department, COUNT(DISTINCT program_name) FROM support_programs WHERE department IN ('Social Work', 'Psychology') GROUP BY department;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists biotech;CREATE TABLE if not exists biotech.startups (id INT, name VARCHAR(100), country VARCHAR(50), funding DECIMAL(10,2));INSERT INTO biotech.startups (id, name, country, funding) VALUES (1, 'StartupA', 'US', 5000000.00), (2, 'StartupB', 'CA', 7000000.00), (3, 'StartupC', 'MX', 3000000.00)...
What is the average funding received by biotech startups per country?
SELECT country, AVG(funding) as avg_funding FROM biotech.startups GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE production (product_type VARCHAR(255), water_consumption NUMERIC, production_date DATE); INSERT INTO production (product_type, water_consumption, production_date) VALUES ('denim_jeans', 2000, '2022-04-01'); INSERT INTO production (product_type, water_consumption, production_date) VALUES ('cotton_t-shirt', ...
What was the total water consumption for denim production in Q2 2022?
SELECT SUM(water_consumption) FROM production WHERE product_type LIKE 'denim%' AND production_date BETWEEN '2022-04-01' AND '2022-06-30';
gretelai_synthetic_text_to_sql
CREATE TABLE routes (route_name VARCHAR(50), total_fare DECIMAL(10,2)); INSERT INTO routes (route_name, total_fare) VALUES ('Red Line', 1200.00), ('Green Line', 1500.00), ('Blue Line', 1800.00);
What is the total fare collected from passengers on the 'Green Line'?
SELECT SUM(total_fare) FROM routes WHERE route_name = 'Green Line';
gretelai_synthetic_text_to_sql
CREATE TABLE streams (stream_id INT, track_id INT, genre VARCHAR(50), country VARCHAR(50), timestamp TIMESTAMP, revenue FLOAT); INSERT INTO streams (stream_id, track_id, genre, country, timestamp, revenue) VALUES (1, 3001, 'Pop', 'US', '2022-01-01 00:00:00', 0.05), (2, 3002, 'Pop', 'US', '2022-01-02 12:30:00', 0.07);
What is the average revenue per stream for the Pop genre in the US for the past month?
SELECT AVG(revenue) FROM streams WHERE genre = 'Pop' AND country = 'US' AND timestamp >= '2022-02-01' AND timestamp < '2022-03-01';
gretelai_synthetic_text_to_sql
CREATE TABLE tours (id INT, name TEXT, location TEXT, type TEXT, date DATE); INSERT INTO tours (id, name, location, type, date) VALUES (1, 'Virtual Tour 1', 'Mount Fuji', 'Virtual', '2022-01-01'), (2, 'Virtual Tour 2', 'Todaiji Temple', 'Virtual', '2022-01-10');
How many virtual tours have been taken in Japan's cultural heritage sites in the last month?
SELECT COUNT(*) FROM tours WHERE location IN (SELECT name FROM cultural_heritage WHERE country = 'Japan') AND type = 'Virtual' AND date >= DATEADD(day, -30, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE coaches (coach_id INT PRIMARY KEY, coach_name VARCHAR(50), team VARCHAR(30)); INSERT INTO coaches (coach_id, coach_name, team) VALUES (1, 'Nick Nurse', 'Toronto Raptors');
What are the details of the coach for the Toronto Raptors?
SELECT * FROM coaches WHERE team = 'Toronto Raptors';
gretelai_synthetic_text_to_sql
CREATE TABLE social_enterprises_education (id INT, name TEXT, sector TEXT, investment FLOAT); INSERT INTO social_enterprises_education (id, name, sector, investment) VALUES (1, 'Education Equity Foundation', 'Education', 250000.0), (2, 'Literacy Improvement Program', 'Education', 175000.0);
What is the average investment in social enterprises in the Education sector?
SELECT AVG(investment) FROM social_enterprises_education WHERE sector = 'Education';
gretelai_synthetic_text_to_sql
CREATE TABLE PolicyAdvocacy (PolicyAdvocacyID INT, Organization VARCHAR(255), AdvocacyDate DATE, AdvocacyType VARCHAR(255)); INSERT INTO PolicyAdvocacy (PolicyAdvocacyID, Organization, AdvocacyDate, AdvocacyType) VALUES (1, 'National Alliance on Mental Illness', '2020-01-01', 'Lobbying'), (2, 'Autistic Self Advocacy Ne...
What is the policy advocacy history for a specific organization?
SELECT Organization, AdvocacyType, AdvocacyDate FROM PolicyAdvocacy WHERE Organization = 'National Alliance on Mental Illness';
gretelai_synthetic_text_to_sql
CREATE TABLE project_year (id INT, year INT, status TEXT); INSERT INTO project_year (id, year, status) VALUES (1, 2021, 'completed'), (2, 2022, 'in_progress');
How many renewable energy projects have been completed in 2021?
SELECT COUNT(*) FROM project_year WHERE year = 2021 AND status = 'completed';
gretelai_synthetic_text_to_sql
CREATE TABLE users (user_id INT, num_posts INT); INSERT INTO users (user_id, num_posts) VALUES (1, 15), (2, 8), (3, 22), (4, 3);
What is the average number of posts per user in the 'social_media' database, excluding users with less than 10 posts?
SELECT AVG(num_posts) FROM users WHERE num_posts >= 10;
gretelai_synthetic_text_to_sql
CREATE TABLE MilitaryEquipment (EquipmentID INT, EquipmentName VARCHAR(100), QuantitySold INT, CustomerID INT);CREATE TABLE Customers (CustomerID INT, CustomerName VARCHAR(100), Country VARCHAR(50));
List the military equipment that was sold to both the US and Canadian governments.
SELECT EquipmentName FROM MilitaryEquipment ME JOIN Customers C ON ME.CustomerID = C.CustomerID WHERE C.Country IN ('United States', 'Canada') GROUP BY EquipmentName HAVING COUNT(DISTINCT C.Country) = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (hotel_id INT, name TEXT, city TEXT, country TEXT, rating FLOAT, eco_friendly BOOLEAN);
What is the average rating of 'eco-friendly' hotels worldwide?
SELECT AVG(rating) FROM hotels WHERE eco_friendly = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE military_equipment_sales (company VARCHAR(255), region VARCHAR(255), year INT, cost INT); INSERT INTO military_equipment_sales (company, region, year, cost) VALUES ('Lockheed Martin', 'Americas', 2019, 1500000);
What was the minimum cost of military equipment sold by Lockheed Martin to the Americas in 2019?
SELECT MIN(cost) FROM military_equipment_sales WHERE company = 'Lockheed Martin' AND region = 'Americas' AND year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE albums (id INT, title VARCHAR(100), release_date DATE); CREATE TABLE streams (id INT, album_id INT, stream_date DATE, streams INT); CREATE VIEW pop_album_streams AS SELECT album_id FROM streams INNER JOIN albums ON streams.album_id = albums.id WHERE genre = 'Pop'; CREATE VIEW album_daily_streams AS SELECT ...
What is the average number of streams per day for each album in the Pop genre?
SELECT album_id, AVG(daily_streams) as avg_daily_streams FROM album_daily_streams INNER JOIN pop_album_streams ON album_daily_streams.album_id = pop_album_streams.album_id GROUP BY album_id;
gretelai_synthetic_text_to_sql
CREATE TABLE restaurants (restaurant_id INT, name VARCHAR(255)); CREATE TABLE revenues (revenue_id INT, restaurant_id INT, revenue DECIMAL(5,2), date DATE, meal_time VARCHAR(255));
What is the total revenue for Restaurant W's 'Lunch Menu'?
SELECT SUM(revenue) as lunch_revenue FROM revenues WHERE restaurant_id = (SELECT restaurant_id FROM restaurants WHERE name = 'Restaurant W') AND meal_time = 'Lunch';
gretelai_synthetic_text_to_sql
CREATE TABLE HeritageSites (SiteName VARCHAR(255), Country VARCHAR(255), YearAdded INT); INSERT INTO HeritageSites (SiteName, Country, YearAdded) VALUES ('City of Cuzco', 'Peru', 1983), ('Historic Quarter of the City of Colonia del Sacramento', 'Uruguay', 1995), ('Iguazu National Park', 'Argentina', 1984), ('Los Glacia...
What is the name of the heritage site added in 1985, and the name of the one added in 2001, in South America?
SELECT SiteName FROM HeritageSites WHERE Country = 'South America' AND YearAdded IN (1985, 2001);
gretelai_synthetic_text_to_sql
CREATE TABLE Products (id INT, name VARCHAR(50), category VARCHAR(50), price DECIMAL(5,2), cruelty_free BOOLEAN); INSERT INTO Products (id, name, category, price, cruelty_free) VALUES (1, 'Hydrating Cleanser', 'Skin Care', 12.99, true), (2, 'Vitamin C Serum', 'Skin Care', 39.99, false), (3, 'Tinted Moisturizer', 'Makeu...
What is the total price of cruelty-free skin care products?
SELECT SUM(p.price) as total_price FROM Products p WHERE p.category = 'Skin Care' AND p.cruelty_free = true;
gretelai_synthetic_text_to_sql
CREATE TABLE healthcare_providers (provider_id INT, provider_name TEXT, state TEXT);
Insert new records for healthcare providers in Wyoming.
INSERT INTO healthcare_providers (provider_id, provider_name, state) VALUES (101, 'Dr. A. Martinez', 'Wyoming'), (102, 'Dr. L. Nguyen', 'Wyoming'), (103, 'Dr. M. Patel', 'Wyoming');
gretelai_synthetic_text_to_sql
CREATE TABLE forests (id INT, biome VARCHAR(50), area FLOAT, year INT); INSERT INTO forests (id, biome, area, year) VALUES (1, 'deciduous', 6000.0, 2022);
Find the total area of 'deciduous' forests in '2022'.
SELECT SUM(area) FROM forests WHERE biome = 'deciduous' AND year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE Sales (Brand VARCHAR(50), Sales_Date DATE, Revenue DECIMAL(10,2)); INSERT INTO Sales (Brand, Sales_Date, Revenue) VALUES ('BrandA', '2022-01-01', 5000), ('BrandA', '2022-02-01', 6000), ('BrandA', '2022-03-01', 7000), ('BrandB', '2022-01-01', 4000), ('BrandB', '2022-02-01', 5000), ('BrandB', '2022-03-01', 6...
What is the total revenue for each brand in the last quarter?
SELECT Brand, SUM(Revenue) FROM Sales WHERE Sales_Date >= DATEADD(quarter, -1, GETDATE()) GROUP BY Brand;
gretelai_synthetic_text_to_sql
CREATE TABLE DefenseProjectTimelines (id INT PRIMARY KEY, project_name VARCHAR(50), negotiation_start_date DATE, negotiation_end_date DATE, country VARCHAR(50)); INSERT INTO DefenseProjectTimelines (id, project_name, negotiation_start_date, negotiation_end_date, country) VALUES (1, 'S-400 Missile Defense System', '2016...
What is the average duration of defense project negotiations with Russia?
SELECT AVG(DATEDIFF(negotiation_end_date, negotiation_start_date)) FROM DefenseProjectTimelines WHERE country = 'Russia';
gretelai_synthetic_text_to_sql
CREATE TABLE faculty (id INT, name VARCHAR(100), department VARCHAR(50), gender VARCHAR(50), race VARCHAR(50)); INSERT INTO faculty VALUES (1, 'Jane Smith', 'Computer Science', 'Female', 'African American'); CREATE TABLE grants (id INT, faculty_id INT, amount DECIMAL(10,2)); INSERT INTO grants VALUES (1, 1, 50000);
What percentage of research grants are awarded to underrepresented minority faculty members?
SELECT 100.0 * SUM(CASE WHEN faculty.race IN ('African American', 'Hispanic', 'Native American') THEN grants.amount ELSE 0 END) / SUM(grants.amount) AS percentage FROM grants JOIN faculty ON grants.faculty_id = faculty.id;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, DonorName TEXT); CREATE TABLE Donations (DonationID INT, DonorID INT, ProgramID INT); INSERT INTO Donors (DonorID, DonorName) VALUES (1, 'Greenpeace'), (2, 'World Food Program'); INSERT INTO Donations (DonationID, DonorID, ProgramID) VALUES (1, 1, 1), (2, 1, 2), (3, 2, 2), (4, 2, 3); C...
Find donors who have donated to both the Food Security and Climate Change programs?
SELECT DonorID FROM Donations d JOIN Programs p ON d.ProgramID = p.ProgramID WHERE p.ProgramName IN ('Food Security', 'Climate Change') GROUP BY DonorID HAVING COUNT(DISTINCT p.ProgramName) = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE language_preservation (id INT, language VARCHAR(255), region VARCHAR(255), status VARCHAR(255)); INSERT INTO language_preservation (id, language, region, status) VALUES (1, 'Māori', 'Asia-Pacific', 'Vulnerable'), (2, 'Hawaiian', 'Asia-Pacific', 'Definitely endangered');
What is the preservation status of indigenous languages in the 'language_preservation' schema in the Asia-Pacific region?
SELECT language, status FROM language_preservation.language_preservation WHERE region = 'Asia-Pacific';
gretelai_synthetic_text_to_sql
CREATE TABLE startups (id INT, name VARCHAR(50), founder_country VARCHAR(30));
Count the number of startups founded by people from each country
SELECT founder_country, COUNT(*) FROM startups GROUP BY founder_country;
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers (supplier_id INT, supplier_name VARCHAR(255), country VARCHAR(255), sourcing VARCHAR(255)); CREATE TABLE product_suppliers (product_id INT, supplier_id INT, price DECIMAL(5,2));
What is the minimum price of products sourced from 'Local' suppliers in the 'suppliers' table?
SELECT MIN(price) FROM product_suppliers INNER JOIN suppliers ON product_suppliers.supplier_id = suppliers.supplier_id WHERE suppliers.sourcing = 'Local';
gretelai_synthetic_text_to_sql
CREATE TABLE heart_rate (id INT, member_id INT, activity_type VARCHAR(50), heart_rate INT); INSERT INTO heart_rate (id, member_id, activity_type, heart_rate) VALUES (1, 1, 'cardio', 160), (2, 1, 'yoga', 140), (3, 2, 'cardio', 180), (4, 2, 'yoga', 150), (5, 3, 'cardio', 170), (6, 3, 'yoga', 130);
What is the maximum heart rate recorded for each member during 'cardio' workouts?'
SELECT member_id, MAX(heart_rate) AS max_heart_rate FROM heart_rate WHERE activity_type = 'cardio' GROUP BY member_id;
gretelai_synthetic_text_to_sql
CREATE TABLE org_sector_2 (id INT, org VARCHAR(100), sector VARCHAR(50), ESG_score FLOAT); INSERT INTO org_sector_2 (id, org, sector, ESG_score) VALUES (1, 'Walmart', 'Consumer Discretionary', 55.0), (2, 'Target', 'Consumer Discretionary', 57.5), (3, 'Ford', 'Consumer Discretionary', 58.5), (4, 'BASF', 'Industrials', 5...
Identify the number of organizations in each sector that have ESG scores below 60.
SELECT sector, COUNT(*) as num_orgs FROM org_sector_2 WHERE ESG_score < 60 GROUP BY sector;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, name VARCHAR(255)); CREATE TABLE transactions (transaction_id INT, customer_id INT, payment_method VARCHAR(50), transaction_date DATE, amount DECIMAL(10,2));
List all customers who have made transactions exclusively with credit cards in the past month, along with their last transaction date and total transaction count?
SELECT c.customer_id, c.name, MAX(t.transaction_date) as last_transaction_date, COUNT(t.transaction_id) as total_transaction_count FROM customers c INNER JOIN transactions t ON c.customer_id = t.customer_id WHERE t.payment_method = 'credit card' AND t.transaction_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP B...
gretelai_synthetic_text_to_sql
CREATE TABLE mental_health_parity (patient_id INT, race VARCHAR(25), parity_score INT); INSERT INTO mental_health_parity (patient_id, race, parity_score) VALUES (1, 'Hispanic', 80), (2, 'African American', 85), (3, 'Asian', 90), (4, 'Caucasian', 95), (5, 'Native American', 100);
What is the average mental health parity score for patients of different races?
SELECT race, AVG(parity_score) as avg_score FROM mental_health_parity GROUP BY race;
gretelai_synthetic_text_to_sql
CREATE TABLE Companies (id INT, name TEXT, industry TEXT, founders TEXT, diversity TEXT); INSERT INTO Companies (id, name, industry, founders, diversity) VALUES (1, 'ShopEasy', 'Retail', 'Diverse Team', 0.00); INSERT INTO Companies (id, name, industry, founders, diversity) VALUES (2, 'TechBoost', 'Technology', 'Non-Div...
How many companies were founded by people from underrepresented communities in the retail sector?
SELECT COUNT(*) FROM Companies WHERE industry = 'Retail' AND diversity = 'Diverse Team';
gretelai_synthetic_text_to_sql
CREATE TABLE ArtSales (id INT, title VARCHAR(255), type VARCHAR(255), price DECIMAL(10,2), sale_year INT); INSERT INTO ArtSales (id, title, type, price, sale_year) VALUES (1, 'Sculpture1', 'Sculpture', 20000, 1982);
What is the maximum price of sculptures sold between 1980 and 1995?
SELECT MAX(price) FROM ArtSales WHERE type = 'Sculpture' AND sale_year BETWEEN 1980 AND 1995;
gretelai_synthetic_text_to_sql
CREATE TABLE Brands (brand_id INT, brand_name TEXT, country TEXT); CREATE TABLE Items (item_id INT, brand_id INT, is_size_inclusive BOOLEAN); CREATE TABLE Sizes (size_id INT, size_name TEXT);
Find the intersection of size-inclusive items between brands in Canada and the UK.
SELECT i.item_id FROM Items i JOIN Brands b1 ON i.brand_id = b1.brand_id JOIN Brands b2 ON i.brand_id = b2.brand_id WHERE b1.country = 'Canada' AND b2.country = 'UK' AND i.is_size_inclusive = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE Projects (id INT, division VARCHAR(10)); INSERT INTO Projects (id, division) VALUES (1, 'water'), (2, 'transport'), (3, 'energy'); CREATE TABLE TransportProjects (id INT, project_id INT, length DECIMAL(10,2)); INSERT INTO TransportProjects (id, project_id, length) VALUES (1, 2, 500), (2, 2, 550), (3, 3, 60...
What is the total length of bridges in the transport division?
SELECT SUM(t.length) FROM TransportProjects t JOIN Projects p ON t.project_id = p.id WHERE p.division = 'transport';
gretelai_synthetic_text_to_sql
CREATE TABLE Restaurants (RestaurantID int, Name varchar(50), Location varchar(50)); CREATE TABLE Inspections (InspectionID int, RestaurantID int, InspectionDate date, ViolationCount int);
How many food safety inspections were conducted for each restaurant in the state of Florida in the month of June 2021?'
SELECT R.Name, COUNT(I.InspectionID) as InspectionCount FROM Restaurants R JOIN Inspections I ON R.RestaurantID = I.RestaurantID WHERE R.Location LIKE '%Florida%' AND I.InspectionDate >= '2021-06-01' AND I.InspectionDate <= '2021-06-30' GROUP BY R.Name;
gretelai_synthetic_text_to_sql
CREATE TABLE crimes (crime_id INT, crime_type VARCHAR(255), crime_date DATE); INSERT INTO crimes VALUES (1, 'Theft', '2019-01-01'), (2, 'Vandalism', '2019-02-01');
What is the total crime count for each type of crime in 2019?
SELECT crime_type, COUNT(*) as total_crimes FROM crimes WHERE EXTRACT(YEAR FROM crime_date) = 2019 GROUP BY crime_type
gretelai_synthetic_text_to_sql
CREATE TABLE languages (id INT, name VARCHAR(255), region VARCHAR(255), endangered BOOLEAN); INSERT INTO languages (id, name, region, endangered) VALUES (1, 'Mandarin', 'Asia-Pacific', FALSE); INSERT INTO languages (id, name, region, endangered) VALUES (2, 'Maori', 'Asia-Pacific', TRUE);
What is the total number of endangered languages in the Asia-Pacific region?
SELECT COUNT(*) FROM languages WHERE region = 'Asia-Pacific' AND endangered = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, DonorName TEXT); CREATE TABLE Donations (DonationID INT, DonorID INT, DonationDate DATE, DonationAmount DECIMAL(10,2));
What is the average donation amount for each donor, sorted by the average donation amount in descending order?
SELECT D.DonorName, AVG(D.DonationAmount) as AvgDonation FROM Donations D JOIN Donors DON ON D.DonorID = DON.DonorID GROUP BY D.DonorName ORDER BY AvgDonation DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE employees (id INT, name VARCHAR(100), division VARCHAR(50), salary FLOAT); INSERT INTO employees (id, name, division, salary) VALUES (1, 'John Doe', 'manufacturing', 60000.00), (2, 'Jane Smith', 'marketing', 70000.00);
What is the 'salary' of the 'employee' with 'employee_id' 2?
SELECT salary FROM employees WHERE id = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE volunteer_program (id INT, name VARCHAR(50), age INT, location VARCHAR(30)); INSERT INTO volunteer_program (id, name, age, location) VALUES (1, 'John Doe', 25, 'New York'), (2, 'Jane Smith', 32, 'California'), (3, 'Alice Johnson', 22, 'Texas');
What is the maximum age of a volunteer in the 'volunteer_program' table?
SELECT MAX(age) FROM volunteer_program;
gretelai_synthetic_text_to_sql
CREATE TABLE MediterraneanSea (depth_name TEXT, depth FLOAT); INSERT INTO MediterraneanSea (depth_name, depth) VALUES ('Max Depth', 5267.0), ('Average Depth', 1500.0);
What is the maximum depth of the Mediterranean Sea?
SELECT depth FROM MediterraneanSea WHERE depth_name = 'Max Depth';
gretelai_synthetic_text_to_sql
CREATE TABLE state (name VARCHAR(50), renewable_energy_consumption DECIMAL(5,2), country VARCHAR(50)); INSERT INTO state (name, renewable_energy_consumption, country) VALUES ('California', 34.2, 'United States'), ('Texas', 29.5, 'United States'), ('New York', 26.1, 'United States');
Identify the top 3 states with the highest renewable energy consumption in the United States.
SELECT name, renewable_energy_consumption FROM (SELECT name, renewable_energy_consumption, RANK() OVER (ORDER BY renewable_energy_consumption DESC) AS rank FROM state WHERE country = 'United States') AS subquery WHERE rank <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE ai_adoption_history (hotel_id INT, hotel_name VARCHAR(255), adopted_date DATE, ai_adopted INT);
How many hotels in EMEA adopted AI in the last 3 years?
SELECT COUNT(DISTINCT hotel_id) FROM ai_adoption_history WHERE region = 'EMEA' AND adopted_date >= DATEADD(year, -3, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE patient (id INT PRIMARY KEY, name VARCHAR(100), age INT, gender VARCHAR(10), race VARCHAR(50)); INSERT INTO patient (id, name, age, gender, race) VALUES (1, 'John Doe', 45, 'Male', 'Caucasian'); INSERT INTO patient (id, name, age, gender, race) VALUES (2, 'Jane Smith', 34, 'Female', 'African American'); IN...
Show the list of patients who are of Asian or Pacific Islander race and diagnosed with Anxiety.
SELECT p.id, p.name FROM patient p JOIN mental_health_parity mhp ON p.id = mhp.patient_id WHERE p.race IN ('Asian', 'Pacific Islander') AND mhp.diagnosis = 'Anxiety';
gretelai_synthetic_text_to_sql
CREATE TABLE StateCapacity (state CHAR(2), capacity FLOAT);CREATE TABLE PowerPlants (id INT, state CHAR(2), capacity FLOAT, fuel VARCHAR(10));
Identify the top 5 states with the highest renewable energy capacity from the StateCapacity and PowerPlants tables
SELECT s.state, SUM(p.capacity) as total_capacity FROM StateCapacity s INNER JOIN PowerPlants p ON s.state = p.state GROUP BY s.state ORDER BY total_capacity DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE MedicalExaminations (ExaminationID INT, AstronautID INT, ExaminationType VARCHAR(50), ExaminationDate DATE); CREATE TABLE Astronauts (AstronautID INT, Name VARCHAR(50), CountryOfOrigin VARCHAR(50)); INSERT INTO Astronauts (AstronautID, Name, CountryOfOrigin) VALUES (1, 'Rakesh Patel', 'India'); INSERT INTO...
How many medical examinations have been conducted for astronauts from India?
SELECT COUNT(*) FROM MedicalExaminations INNER JOIN Astronauts ON MedicalExaminations.AstronautID = Astronauts.AstronautID WHERE CountryOfOrigin = 'India';
gretelai_synthetic_text_to_sql
CREATE TABLE graduate_programs (id INT, program VARCHAR(255), field VARCHAR(255)); INSERT INTO graduate_programs (id, program, field) VALUES (1, 'Program A', 'medicine'), (2, 'Program B', 'engineering'), (3, 'Program C', 'medicine'); CREATE TABLE published_papers (id INT, program_id INT, title VARCHAR(255), year INT); ...
List the top 3 graduate programs with the most published papers in the field of "medicine" in descending order
SELECT gp.program, COUNT(pp.id) AS paper_count FROM graduate_programs gp INNER JOIN published_papers pp ON gp.id = pp.program_id WHERE gp.field = 'medicine' GROUP BY gp.program ORDER BY paper_count DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists companies (company_id INT, sector VARCHAR(50), esg_score DECIMAL(3,2), quarter INT, year INT); INSERT INTO companies (company_id, sector, esg_score, quarter, year) VALUES (1, 'Healthcare', 8.5, 1, 2021), (2, 'Healthcare', 7.9, 1, 2021), (3, 'Healthcare', 8.8, 1, 2021);
What is the average ESG score for companies in the healthcare sector in Q1 2021?
SELECT AVG(esg_score) FROM companies WHERE sector = 'Healthcare' AND quarter = 1 AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE chemical_production (id INT PRIMARY KEY, chemical_id VARCHAR(10), quantity INT, country VARCHAR(50)); INSERT INTO chemical_production (id, chemical_id, quantity, country) VALUES (1, 'C123', 500, 'Germany'), (2, 'C456', 300, 'Canada'), (3, 'C123', 100, 'Germany');
List all the unique chemical_ids with a production quantity greater than 200 in Germany
SELECT DISTINCT chemical_id FROM chemical_production WHERE quantity > 200 AND country = 'Germany';
gretelai_synthetic_text_to_sql
CREATE TABLE community_districts (cd_number INT, community_name VARCHAR(255)); INSERT INTO community_districts (cd_number, community_name) VALUES (1, 'Chinatown'), (2, 'Lower East Side'), (3, 'East Village'); CREATE TABLE emergency_calls (call_date DATE, cd_number INT, call_count INT);
What was the total number of emergency calls received in each community district in the past week?
SELECT cd.community_name, SUM(ec.call_count) as total_calls FROM community_districts cd JOIN emergency_calls ec ON cd.cd_number = ec.cd_number WHERE ec.call_date >= CURDATE() - INTERVAL 1 WEEK GROUP BY cd.community_name;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name TEXT, is_cruelty_free BOOLEAN, sales INT, country TEXT); INSERT INTO products (product_id, product_name, is_cruelty_free, sales, country) VALUES (1, 'Lipstick', true, 550, 'UK'), (2, 'Foundation', false, 600, 'UK'), (3, 'Mascara', true, 700, 'UK');
Which cruelty-free cosmetic products have the highest sales in the UK?
SELECT product_name, SUM(sales) as total_sales FROM products WHERE is_cruelty_free = true AND country = 'UK' GROUP BY product_name ORDER BY total_sales DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Tickets (ticket_id INT, event_id INT, quantity INT); INSERT INTO Tickets (ticket_id, event_id, quantity) VALUES (1, 3, 200), (2, 4, 150);
How many more tickets were sold for 'Theater Performance' compared to 'Dance Recital'?
SELECT (SELECT quantity FROM Tickets WHERE event_id = 3) - (SELECT quantity FROM Tickets WHERE event_id = 4);
gretelai_synthetic_text_to_sql
CREATE TABLE EcoFriendlyItems (id INT, item VARCHAR(255), country VARCHAR(255), price DECIMAL(5,2)); INSERT INTO EcoFriendlyItems (id, item, country, price) VALUES (1, 'Hemp T-Shirt', 'India', 25.00), (2, 'Recycled Plastic Bag', 'India', 10.00), (3, 'Sustainable Silk Saree', 'India', 75.00);
What is the average price of eco-friendly fashion items in India?
SELECT AVG(price) FROM EcoFriendlyItems WHERE country = 'India';
gretelai_synthetic_text_to_sql
CREATE TABLE users (user_id INT, name VARCHAR(255), region VARCHAR(255), followers INT); INSERT INTO users (user_id, name, region, followers) VALUES (1, 'Jun', 'Asia', 1500);
How many users who live in 'Asia' have a follower count greater than 1000?
SELECT COUNT(*) FROM users WHERE region = 'Asia' AND followers > 1000;
gretelai_synthetic_text_to_sql
CREATE TABLE delivery (route VARCHAR(20), delivery_time INT); INSERT INTO delivery (route, delivery_time) VALUES ('Route1', 30), ('Route2', 40), ('Route3', 50);
What is the minimum delivery time for each route in the delivery database?
SELECT route, MIN(delivery_time) FROM delivery GROUP BY route;
gretelai_synthetic_text_to_sql
CREATE TABLE ArtClasses (ID INT, ClassName VARCHAR(255), ClassType VARCHAR(255), StartDate DATE, EndDate DATE, AgeGroup VARCHAR(255));
What is the total number of art classes and workshops held in the last 2 years, categorized by age group?
SELECT AgeGroup, COUNT(*) as TotalClasses FROM ArtClasses WHERE StartDate >= DATEADD(year, -2, GETDATE()) GROUP BY AgeGroup;
gretelai_synthetic_text_to_sql
CREATE TABLE DispensarySalesData2 (DispensaryName VARCHAR(50), State VARCHAR(20), QuantitySold INT); INSERT INTO DispensarySalesData2 (DispensaryName, State, QuantitySold) VALUES ('Green Earth Dispensary', 'Colorado', 400), ('Buds and Beyond', 'Colorado', 500), ('The Healing Center', 'Colorado', 600), ('Elevated Roots'...
What is the total quantity of cannabis products sold by each dispensary in the state of Colorado?
SELECT DispensaryName, SUM(QuantitySold) FROM DispensarySalesData2 WHERE State = 'Colorado' GROUP BY DispensaryName;
gretelai_synthetic_text_to_sql
CREATE TABLE borough (borough_id INT, name VARCHAR(255)); INSERT INTO borough (borough_id, name) VALUES (1, 'Manhattan'), (2, 'Brooklyn'), (3, 'Queens'), (4, 'Bronx'), (5, 'Staten Island'); CREATE TABLE property (property_id INT, price INT, borough_id INT); INSERT INTO property (property_id, price, borough_id) VALUES (...
What is the maximum and minimum property price in each borough?
SELECT b.name, MAX(p.price) as max_price, MIN(p.price) as min_price FROM property p INNER JOIN borough b ON p.borough_id = b.borough_id GROUP BY b.name;
gretelai_synthetic_text_to_sql
CREATE TABLE Cost (id INT, cost INT, issue_date DATE);
Show total construction cost for each quarter in 2021
SELECT DATE_FORMAT(issue_date, '%Y-%m') AS quarter, SUM(cost) AS total_cost FROM Cost WHERE YEAR(issue_date) = 2021 GROUP BY quarter;
gretelai_synthetic_text_to_sql
CREATE TABLE Job_Training (state_id INT, num_programs INT); INSERT INTO Job_Training (state_id, num_programs) VALUES (1, 15), (2, 20), (3, 12), (4, 18), (5, 10); CREATE TABLE States (id INT, name VARCHAR(50)); INSERT INTO States (id, name) VALUES (1, 'California'), (2, 'Texas'), (3, 'New York'), (4, 'Florida'), (5, 'Il...
What is the total number of job training programs offered in each state?
SELECT S.name, SUM(JT.num_programs) as Total_Programs FROM Job_Training JT JOIN States S ON JT.state_id = S.id GROUP BY S.name;
gretelai_synthetic_text_to_sql
CREATE TABLE Stores (StoreID INT, StoreName VARCHAR(50), City VARCHAR(50), Country VARCHAR(50)); INSERT INTO Stores (StoreID, StoreName, City, Country) VALUES (1, 'Flagship Store', 'New York', 'USA'), (2, 'Downtown Store', 'Los Angeles', 'USA'), (3, 'Harajuku Store', 'Tokyo', 'Japan'); CREATE TABLE Sales (SaleID INT, S...
What is the total quantity of garments sold by each store, sorted by the greatest total quantity?
SELECT StoreID, SUM(QuantitySold) AS TotalQuantitySold FROM Sales GROUP BY StoreID ORDER BY TotalQuantitySold DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE species (id INT, name VARCHAR(255), habitat VARCHAR(255), depth FLOAT); INSERT INTO species (id, name, habitat, depth) VALUES (1, 'Clownfish', 'Coral Reef', 20.0); INSERT INTO species (id, name, habitat, depth) VALUES (2, 'Blue Whale', 'Open Ocean', 2000.0); INSERT INTO species (id, name, habitat, depth) V...
What is the minimum depth a marine species can live at?
SELECT MIN(depth) FROM species;
gretelai_synthetic_text_to_sql
CREATE TABLE high_impact_journals (id INT, journal VARCHAR(50)); INSERT INTO high_impact_journals VALUES (1, 'Nature'); INSERT INTO high_impact_journals VALUES (2, 'Science'); CREATE TABLE faculty_publications (id INT, faculty_id INT, journal_id INT); INSERT INTO faculty_publications VALUES (1, 1, 1); INSERT INTO facul...
What is the total amount of research grants awarded to faculty members who have published in high-impact journals?
SELECT SUM(grants.amount) FROM grants JOIN faculty_publications ON grants.faculty_id = faculty_publications.faculty_id JOIN high_impact_journals ON faculty_publications.journal_id = high_impact_journals.id;
gretelai_synthetic_text_to_sql
CREATE TABLE farmers (id INT PRIMARY KEY, name TEXT, location TEXT, age INT, crop TEXT); INSERT INTO farmers (id, name, location, age, crop) VALUES (1, 'Jane Doe', 'Rural', 45, 'Corn');
Find the average age of farmers by crop type.
SELECT crop, AVG(age) FROM farmers GROUP BY crop;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, account_number INT); CREATE TABLE account_balances (balance_id INT, customer_id INT, balance_date DATE, balance DECIMAL(10,2)); INSERT INTO customers (customer_id, account_number) VALUES (1, 123456), (2, 234567), (3, 345678); INSERT INTO account_balances (balance_id, customer_id...
What is the moving average of a customer's account balance for the past 3 months?
SELECT customer_id, AVG(balance) OVER (PARTITION BY customer_id ORDER BY balance_date ROWS BETWEEN 89 PRECEDING AND CURRENT ROW) AS moving_avg FROM account_balances WHERE customer_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Humanitarian_Assistance (Country VARCHAR(100), Quarter INT, Year INT);
What are the names of countries that received humanitarian assistance in Q1 and Q3 of 2022?
SELECT Country FROM Humanitarian_Assistance WHERE Year = 2022 AND Quarter IN (1, 3) GROUP BY Country HAVING COUNT(DISTINCT Quarter) = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, Region VARCHAR(50)); INSERT INTO Donors (DonorID, Region) VALUES (1, 'Africa'), (2, 'Asia'), (3, 'Europe'), (4, 'South America'), (5, 'North America');
How can we delete donors from a specific region?
DELETE FROM Donors WHERE Region = 'South America';
gretelai_synthetic_text_to_sql
CREATE TABLE Warehouse (id INT, location VARCHAR(255), capacity INT); INSERT INTO Warehouse (id, location, capacity) VALUES (1, 'New York', 500), (2, 'Toronto', 700), (3, 'Montreal', 600); CREATE TABLE Shipment (id INT, warehouse_id INT, delivery_time INT); INSERT INTO Shipment (id, warehouse_id, delivery_time) VALUES ...
Find the number of shipments and total delivery time for each warehouse, ordered by the average delivery time?
SELECT warehouse_id, COUNT(*) as num_shipments, AVG(delivery_time) as avg_delivery_time, RANK() OVER (ORDER BY AVG(delivery_time) DESC) as rank FROM Shipment GROUP BY warehouse_id HAVING rank <= 2;
gretelai_synthetic_text_to_sql
CREATE TABLE VESSEL_TRAVEL (id INT, vessel_name VARCHAR(50), destination VARCHAR(50)); CREATE VIEW mediterranean_sea AS SELECT 'Mediterranean Sea';
Display vessels that have never traveled to the Mediterranean Sea
SELECT vessel_name FROM VESSEL_TRAVEL WHERE vessel_name NOT IN (SELECT vessel_name FROM VESSEL_TRAVEL WHERE destination IN (SELECT * FROM mediterranean_sea)) GROUP BY vessel_name;
gretelai_synthetic_text_to_sql
CREATE TABLE accessible_tech_africa(id INT, initiative VARCHAR(50), country VARCHAR(10)); INSERT INTO accessible_tech_africa VALUES (1, 'Tech for Africa', 'Kenya'); CREATE TABLE accessible_tech_asia(id INT, initiative VARCHAR(50), country VARCHAR(10)); INSERT INTO accessible_tech_asia VALUES (1, 'Tech for India', 'Indi...
List the top 3 countries with the most accessible technology initiatives, by continent.
SELECT country, COUNT(initiative) AS num_initiatives FROM accessible_tech_africa GROUP BY country UNION ALL SELECT country, COUNT(initiative) AS num_initiatives FROM accessible_tech_asia GROUP BY country UNION ALL SELECT country, COUNT(initiative) AS num_initiatives FROM accessible_tech_europe GROUP BY country ORDER BY...
gretelai_synthetic_text_to_sql