context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE carbon_offset_initiatives (id INT, name VARCHAR(255), description TEXT, total_carbon_offset FLOAT, country VARCHAR(50));
|
Get the names and total carbon offset of all carbon offset initiatives located in Canada.
|
SELECT name, total_carbon_offset FROM carbon_offset_initiatives WHERE country = 'Canada';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Sales (sale_id INT, garment_id INT, location_id INT, sale_date DATE);CREATE TABLE Garments (garment_id INT, trend_id INT, fabric_source_id INT, size VARCHAR(50), style VARCHAR(255));CREATE TABLE FabricSources (source_id INT, fabric_type VARCHAR(255), country_of_origin VARCHAR(255), ethical_rating DECIMAL(3,2));CREATE TABLE StoreLocations (location_id INT, city VARCHAR(255), country VARCHAR(255), sales_volume INT);CREATE VIEW SustainableGarments AS SELECT * FROM Garments WHERE fabric_source_id IN (SELECT source_id FROM FabricSources WHERE ethical_rating >= 7.0);CREATE VIEW TorontoSales AS SELECT * FROM Sales WHERE location_id IN (SELECT location_id FROM StoreLocations WHERE city = 'Toronto');CREATE VIEW TorontoSustainableGarments AS SELECT * FROM TorontoSales WHERE garment_id IN (SELECT garment_id FROM SustainableGarments);
|
What is the total sales volume for Sustainable garments in Toronto during 2021?
|
SELECT SUM(sales_volume) FROM TorontoSustainableGarments WHERE sale_date BETWEEN '2021-01-01' AND '2021-12-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Hotels (hotel_id INT, hotel_name VARCHAR(100), category VARCHAR(50)); CREATE TABLE Bookings (booking_id INT, hotel_id INT, booking_date DATE, revenue FLOAT, channel VARCHAR(50)); INSERT INTO Hotels (hotel_id, hotel_name, category) VALUES (1, 'Hotel A', 'Boutique'), (2, 'Hotel B', 'Boutique'), (3, 'Hotel C', 'Economy'), (4, 'Hotel D', 'Economy'), (10, 'Hotel J', 'Economy'); INSERT INTO Bookings (booking_id, hotel_id, booking_date, revenue, channel) VALUES (1, 1, '2022-01-01', 200.0, 'Direct'), (2, 1, '2022-01-03', 150.0, 'OTA'), (3, 2, '2022-01-05', 300.0, 'Direct');
|
How many unique hotels in the 'Economy' category have no bookings?
|
SELECT COUNT(DISTINCT Hotels.hotel_id) FROM Hotels LEFT JOIN Bookings ON Hotels.hotel_id = Bookings.hotel_id WHERE Hotels.category = 'Economy' AND Bookings.hotel_id IS NULL;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donors (DonorID INT, DonorName TEXT, DonorType TEXT, Country TEXT); INSERT INTO Donors (DonorID, DonorName, DonorType, Country) VALUES (1, 'Alice Johnson', 'Individual', 'Canada'), (2, 'Bob Brown', 'Individual', 'Canada'); CREATE TABLE Donations (DonationID INT, DonorID INT, DonationAmount INT); INSERT INTO Donations (DonationID, DonorID, DonationAmount) VALUES (1, 1, 1000), (2, 1, 2000), (3, 2, 500);
|
What is the maximum donation amount made by individual donors from Canada?
|
SELECT MAX(DonationAmount) FROM Donations JOIN Donors ON Donations.DonorID = Donors.DonorID WHERE Donors.Country = 'Canada' AND Donors.DonorType = 'Individual';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE shipments (id INT, origin VARCHAR(255), destination VARCHAR(255), shipped_at TIMESTAMP); INSERT INTO shipments (id, origin, destination, shipped_at) VALUES (1, 'India', 'Australia', '2021-04-02 10:30:00'), (2, 'India', 'Australia', '2021-04-05 15:45:00');
|
What was the total number of shipments from India to Australia in April 2021?
|
SELECT COUNT(*) FROM shipments WHERE origin = 'India' AND destination = 'Australia' AND shipped_at >= '2021-04-01' AND shipped_at < '2021-05-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE contracts (id INT, category VARCHAR(255), value DECIMAL(10,2));INSERT INTO contracts (id, category, value) VALUES (1, 'Aircraft', 5000000.00), (2, 'Missiles', 2000000.00), (3, 'Shipbuilding', 8000000.00), (4, 'Cybersecurity', 3000000.00), (5, 'Aircraft', 6000000.00), (6, 'Shipbuilding', 9000000.00);
|
How many aircraft and shipbuilding contracts are there?
|
SELECT SUM(CASE WHEN category IN ('Aircraft', 'Shipbuilding') THEN 1 ELSE 0 END) as total_contracts FROM contracts;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE articles (article_id INT, title TEXT, topic TEXT, is_opinion BOOLEAN, published_at DATETIME); INSERT INTO articles (article_id, title, topic, is_opinion, published_at) VALUES (1, 'Investigation of Corruption Scandal', 'investigative journalism', FALSE, '2021-06-15 12:00:00'), (2, 'Opinion: Future of Investigative Journalism', 'opinion', TRUE, '2021-07-20 09:30:00');
|
How many investigative journalism articles were published in 2021, excluding opinion pieces?
|
SELECT COUNT(*) FROM articles WHERE topic = 'investigative journalism' AND is_opinion = FALSE AND YEAR(published_at) = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE events (id INT, name VARCHAR(50), category VARCHAR(50), revenue INT);
|
What is the total revenue generated by each cultural event category?
|
SELECT category, SUM(revenue) FROM events GROUP BY category;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE if not exists animal_population (id INT, animal VARCHAR(255), country VARCHAR(255), population INT); INSERT INTO animal_population (id, animal, country, population) VALUES (1, 'Tiger', 'India', 2500), (2, 'Elephant', 'India', 5000), (3, 'Rhinoceros', 'India', 1500), (4, 'Lion', 'Kenya', 3000), (5, 'Giraffe', 'Kenya', 1000), (6, 'Gorilla', 'Indonesia', 750);
|
Average population of all animals in forests
|
SELECT AVG(population) FROM animal_population WHERE country IN ('India', 'Indonesia', 'Kenya') AND habitat = 'Forest';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE defense_diplomacy (id INT, country VARCHAR(255), event_name VARCHAR(255), year INT);
|
Display the names of countries that have participated in defense diplomacy events in the last 5 years
|
SELECT country FROM defense_diplomacy WHERE year BETWEEN (YEAR(CURRENT_DATE) - 5) AND YEAR(CURRENT_DATE) GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE LandfillCapacity (country VARCHAR(255), landfill_capacity_cubic_meters DECIMAL(15,2), region VARCHAR(255)); INSERT INTO LandfillCapacity (country, landfill_capacity_cubic_meters, region) VALUES ('Indonesia', 12000000.0, 'Southeast Asia'), ('Thailand', 9000000.0, 'Southeast Asia'), ('Malaysia', 7000000.0, 'Southeast Asia');
|
What is the average landfill capacity in cubic meters for countries in Southeast Asia?
|
SELECT AVG(landfill_capacity_cubic_meters) FROM LandfillCapacity WHERE region = 'Southeast Asia';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE counties_tx (id INT, name VARCHAR(255), state VARCHAR(255)); INSERT INTO counties_tx (id, name, state) VALUES (1, 'Andrews County', 'Texas'); CREATE TABLE dental_providers_tx (id INT, name VARCHAR(255), county_id INT); INSERT INTO dental_providers_tx (id, name, county_id) VALUES (1, 'Provider X', 1);
|
What is the number of dental providers in each county in Texas?
|
SELECT c.name, COUNT(dp.id) FROM counties_tx c JOIN dental_providers_tx dp ON c.id = dp.county_id WHERE c.state = 'Texas' GROUP BY c.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE creative_ai_development (id INT, app_name VARCHAR(50), country VARCHAR(50)); INSERT INTO creative_ai_development (id, app_name, country) VALUES (1, 'DeepArt', 'Germany'), (2, 'Artbreeder', 'Japan'), (3, 'Dreamscope', 'United States'), (4, 'DeepDream Generator', 'Canada'), (5, 'Runway ML', 'United Kingdom'), (6, 'DeepArt Effects', 'France');
|
What is the total number of creative AI applications developed in each country?
|
SELECT country, COUNT(*) FROM creative_ai_development GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE retailers (retailer_id INT, retailer_name VARCHAR(50)); INSERT INTO retailers (retailer_id, retailer_name) VALUES (1, 'Whole Foods'); INSERT INTO retailers (retailer_id, retailer_name) VALUES (2, 'Trader Joe''s'); CREATE TABLE inventory (product_id INT, product_name VARCHAR(50), retailer_id INT, is_organic BOOLEAN, is_gluten_free BOOLEAN); INSERT INTO inventory (product_id, product_name, retailer_id, is_organic, is_gluten_free) VALUES (1, 'Organic Quinoa', 1, true, false); INSERT INTO inventory (product_id, product_name, retailer_id, is_organic, is_gluten_free) VALUES (2, 'Gluten-Free Pasta', 1, false, true); INSERT INTO inventory (product_id, product_name, retailer_id, is_organic, is_gluten_free) VALUES (3, 'Organic Almond Milk', 2, true, false); INSERT INTO inventory (product_id, product_name, retailer_id, is_organic, is_gluten_free) VALUES (4, 'Gluten-Free Bread', 2, false, true);
|
Show the names of all retailers carrying both "organic" and "gluten-free" products
|
SELECT DISTINCT r.retailer_name FROM retailers r JOIN inventory i ON r.retailer_id = i.retailer_id WHERE i.is_organic = true AND i.is_gluten_free = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE transportation_projects (id INT, project_budget INT, project_status TEXT, country TEXT); INSERT INTO transportation_projects (id, project_budget, project_status, country) VALUES (1, 50000, 'completed', 'Nigeria'), (2, 75000, 'in_progress', 'Kenya'), (3, 30000, 'completed', 'Egypt');
|
What is the average budget of transportation projects in African nations that have been completed?
|
SELECT AVG(project_budget) FROM transportation_projects WHERE project_status = 'completed' AND country IN ('Africa');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Vaccines (VaccineID INT, VaccineType VARCHAR(255), Region VARCHAR(255), Date DATE); INSERT INTO Vaccines (VaccineID, VaccineType, Region, Date) VALUES (1, 'Flu Shot', 'Northeast', '2021-10-01');
|
What is the total number of vaccines administered, broken down by the type of vaccine and the region where it was administered?
|
SELECT VaccineType, Region, COUNT(*) FROM Vaccines GROUP BY VaccineType, Region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE festivals (festival_id INT PRIMARY KEY, festival_name VARCHAR(100), location VARCHAR(100), genre VARCHAR(50), attendance INT); INSERT INTO festivals (festival_id, festival_name, location, genre, attendance) VALUES (1, 'Fyre Festival', 'Great Exuma, Bahamas', 'Pop', 45000); INSERT INTO festivals (festival_id, festival_name, location, genre, attendance) VALUES (2, 'Primavera Sound', 'Barcelona, Spain', 'Indie', 220000); INSERT INTO festivals (festival_id, festival_name, location, genre, attendance) VALUES (3, 'SummerStage', 'New York City, NY', 'Jazz', 60000);
|
List all festivals with a genre specification
|
SELECT festival_name FROM festivals WHERE genre IS NOT NULL;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE inmates (id INT, age INT, gender VARCHAR(10), restorative_program BOOLEAN);
|
What is the average age of inmates who have participated in restorative justice programs, grouped by their gender?
|
SELECT gender, AVG(age) avg_age FROM inmates WHERE restorative_program = TRUE GROUP BY gender;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donations (id INT, state VARCHAR(2), donation_amount DECIMAL(5,2), donation_date DATE); INSERT INTO Donations (id, state, donation_amount, donation_date) VALUES (1, 'NY', 50.00, '2022-01-01'), (2, 'CA', 100.00, '2022-01-15'), (3, 'TX', 75.00, '2022-03-03');
|
What was the average donation amount by state in Q1 2022?
|
SELECT AVG(donation_amount) as avg_donation, state FROM Donations WHERE donation_date BETWEEN '2022-01-01' AND '2022-03-31' GROUP BY state;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Policyholder (PolicyholderID INT, Name TEXT, Birthdate DATE, PolicyType TEXT, PolicyState TEXT); INSERT INTO Policyholder (PolicyholderID, Name, Birthdate, PolicyType, PolicyState) VALUES (1, 'James Smith', '1985-03-14', 'Automotive', 'California'); INSERT INTO Policyholder (PolicyholderID, Name, Birthdate, PolicyType, PolicyState) VALUES (2, 'Ava Jones', '1990-08-08', 'Homeowners', 'Texas');
|
What are the names and birthdates of policyholders who have an automotive policy in California?
|
SELECT Name, Birthdate FROM Policyholder WHERE PolicyType = 'Automotive' AND PolicyState = 'California';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE schools (school_id INT, school_name VARCHAR(255), city VARCHAR(255)); CREATE TABLE student_mental_health (student_id INT, school_id INT, mental_health_score INT); INSERT INTO schools (school_id, school_name, city) VALUES (1, 'School A', 'City X'), (2, 'School B', 'City X'), (3, 'School C', 'City Y'); INSERT INTO student_mental_health (student_id, school_id, mental_health_score) VALUES (1, 1, 70), (2, 1, 80), (3, 2, 60), (4, 2, 75), (5, 3, 90), (6, 3, 85);
|
What is the average mental health score of students per city?
|
SELECT s.city, AVG(smh.mental_health_score) as avg_score FROM student_mental_health smh JOIN schools s ON smh.school_id = s.school_id GROUP BY s.city;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Articles (id INT, author TEXT, gender TEXT, topic TEXT); INSERT INTO Articles (id, author, gender, topic) VALUES (1, 'Author 1', 'Female', 'Topic 1'), (2, 'Author 1', 'Female', 'Topic 2'), (3, 'Author 2', 'Male', 'Topic 1');
|
Top 3 most common topics covered in articles by gender?
|
SELECT gender, topic, COUNT(*) as topic_count FROM Articles GROUP BY gender, topic ORDER BY topic_count DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE DonorDemographics (DonorID INT, Gender VARCHAR(255), Income DECIMAL(10,2), EducationLevel VARCHAR(255));
|
What is the total amount donated by each education level?
|
SELECT EducationLevel, SUM(Amount) as TotalDonated FROM Donations D JOIN DonorDemographics DD ON D.DonorID = DD.DonorID GROUP BY EducationLevel;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Budget (program_id INT, program_name VARCHAR(255), year INT, allocated_budget DECIMAL(10, 2)); INSERT INTO Budget (program_id, program_name, year, allocated_budget) VALUES (1, 'Arts', 2020, 2000.00), (2, 'Education', 2020, 3000.00), (3, 'Environment', 2020, 4000.00), (1, 'Arts', 2019, 1500.00), (2, 'Education', 2019, 2500.00), (3, 'Environment', 2019, 3500.00);
|
What is the total budget allocated for program 'Arts' in 2020?
|
SELECT SUM(allocated_budget) FROM Budget WHERE program_name = 'Arts' AND year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Policyholders (PolicyholderID INT, Premium DECIMAL(10, 2), PolicyholderState VARCHAR(10), CarMake VARCHAR(20)); INSERT INTO Policyholders (PolicyholderID, Premium, PolicyholderState, CarMake) VALUES (1, 2500, 'Texas', 'Toyota'), (2, 1500, 'New York', 'Honda'), (3, 1000, 'California', 'Tesla');
|
What is the maximum policy premium for policyholders living in 'Texas' who have a car make of 'Toyota'?
|
SELECT MAX(Premium) FROM Policyholders WHERE PolicyholderState = 'Texas' AND CarMake = 'Toyota';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE artworks (id INT, artist VARCHAR(100), collection VARCHAR(50), value INT); INSERT INTO artworks (id, artist, collection, value) VALUES (1, 'Fernando', 'South American Collection', 1000), (2, 'Gabriela', 'European Collection', 1500), (3, 'Hugo', 'South American Collection', 1200);
|
Who are the artists from South America with the highest average artwork value?
|
SELECT artist, AVG(value) AS avg_value FROM artworks WHERE collection LIKE '%South%American%' GROUP BY artist ORDER BY avg_value DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE GarmentSales (garment_type VARCHAR(50), quantity INT); INSERT INTO GarmentSales (garment_type, quantity) VALUES ('T-Shirt', 500), ('Jeans', 300), ('Hoodie', 200), ('Jackets', 400);
|
List the top 3 garment types with the highest sales quantity in the 'GarmentSales' table.
|
SELECT garment_type, quantity FROM GarmentSales ORDER BY quantity DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE animals (id INT, species TEXT, population INT); CREATE TABLE habitats (id INT, name TEXT, animal_id INT); INSERT INTO animals (id, species, population) VALUES (1, 'Tiger', 1200), (2, 'Elephant', 1500), (3, 'Rhinoceros', 800); INSERT INTO habitats (id, name, animal_id) VALUES (1, 'Habitat1', 1), (2, 'Habitat2', 2), (3, 'Habitat3', 2), (4, 'Habitat4', 3);
|
Which animal species have a population greater than 1000 in each of their protected habitats?
|
SELECT a.species FROM animals a JOIN habitats h ON a.id = h.animal_id GROUP BY a.species HAVING COUNT(DISTINCT h.name) = SUM(CASE WHEN a.population > 1000 THEN 1 ELSE 0 END);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cases (id INT, resolution_type VARCHAR(20)); INSERT INTO cases (id, resolution_type) VALUES (1, 'Restorative Justice'), (2, 'Prison'), (3, 'Fine');
|
What is the total number of cases in the justice system that were resolved through restorative justice programs?
|
SELECT COUNT(*) FROM cases WHERE resolution_type = 'Restorative Justice';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE menu (item_id INT, item_name TEXT, category TEXT, cost FLOAT); INSERT INTO menu (item_id, item_name, category, cost) VALUES (1, 'Quinoa Salad', 'Vegan', 7.50), (2, 'Tofu Stir Fry', 'Vegan', 8.99), (3, 'Chickpea Curry', 'Vegan', 9.49);
|
What is the total inventory cost for vegan menu items?
|
SELECT SUM(cost) FROM menu WHERE category = 'Vegan';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE union_membership (id INT, union VARCHAR(20), member_count INT); INSERT INTO union_membership (id, union, member_count) VALUES (1, 'construction', 3500), (2, 'education', 8000), (3, 'manufacturing', 5000);
|
What is the maximum number of members in a union?
|
SELECT MAX(member_count) FROM union_membership;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE veteran_employment (veteran_id INT, veteran_state VARCHAR(2), employment_status VARCHAR(255), employment_date DATE);
|
Calculate veteran unemployment rates by state, for the past 6 months
|
SELECT veteran_state, AVG(CASE WHEN employment_status = 'Unemployed' THEN 100 ELSE 0 END) as unemployment_rate FROM veteran_employment WHERE employment_date >= DATEADD(month, -6, CURRENT_DATE) GROUP BY veteran_state;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE climate_finance (year INT, country VARCHAR(50), initiative VARCHAR(50), amount FLOAT); INSERT INTO climate_finance (year, country, initiative, amount) VALUES (2016, 'Small Island Nation 1', 'climate adaptation', 100000);
|
What is the average amount of climate finance provided to small island nations for climate adaptation projects between 2016 and 2020?
|
SELECT AVG(amount) FROM climate_finance WHERE country LIKE '%small island nation%' AND initiative = 'climate adaptation' AND year BETWEEN 2016 AND 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE assets (asset_name VARCHAR(255), developer VARCHAR(255), market_cap FLOAT); INSERT INTO assets (asset_name, developer, market_cap) VALUES ('Ethereum', 'Vitalik Buterin', 450.3); INSERT INTO assets (asset_name, developer, market_cap) VALUES ('Bitcoin Cash', 'Bitcoin Devs', 220.1);
|
What are the top 3 digital assets by market capitalization, excluding those developed by Bitcoin developers?
|
SELECT asset_name, developer, market_cap FROM (SELECT asset_name, developer, market_cap, ROW_NUMBER() OVER (ORDER BY market_cap DESC) as row_num FROM assets WHERE developer NOT IN ('Bitcoin Devs')) tmp WHERE row_num <= 3;
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA IF NOT EXISTS defense_security;CREATE TABLE IF NOT EXISTS defense_security.US_Military_Bases (id INT PRIMARY KEY, base_name VARCHAR(255), location VARCHAR(255), type VARCHAR(255));INSERT INTO defense_security.US_Military_Bases (id, base_name, location, type) VALUES (1, 'Fort Bragg', 'North Carolina', 'Army Base');
|
What is the total number of military bases in the 'US_Military_Bases' table?
|
SELECT COUNT(*) FROM defense_security.US_Military_Bases;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE BudgetCategories (ID INT, Category TEXT, Amount FLOAT); INSERT INTO BudgetCategories (ID, Category, Amount) VALUES (1, 'Disability Accommodations', 75000.00), (2, 'Policy Advocacy', 25000.00), (3, 'Health Care', 125000.00);
|
Find the total budget for 'Disability Accommodations' and 'Policy Advocacy' combined.
|
SELECT SUM(Amount) FROM BudgetCategories WHERE Category IN ('Disability Accommodations', 'Policy Advocacy');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ExcavationDates (SiteID INT, Region VARCHAR(50), ExcavationDate DATE); INSERT INTO ExcavationDates (SiteID, Region, ExcavationDate) VALUES (1, 'africa', '2020-01-01'), (2, 'americas', '2019-01-01');
|
What is the earliest excavation date in the 'africa' region?
|
SELECT MIN(ExcavationDate) AS EarliestExcavationDate FROM ExcavationDates WHERE Region = 'africa';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE departments (id INT, name VARCHAR(20)); CREATE TABLE products (id INT, department INT, name VARCHAR(20), material VARCHAR(20), quantity INT); INSERT INTO departments (id, name) VALUES (1, 'textiles'), (2, 'metallurgy'); INSERT INTO products (id, department, name, material, quantity) VALUES (1, 1, 'beam', 'steel', 100), (2, 1, 'plate', 'steel', 200), (3, 2, 'rod', 'aluminum', 150), (4, 2, 'foil', 'aluminum', 50), (5, 1, 'yarn', 'cotton', 200), (6, 1, 'thread', 'polyester', 300), (7, 2, 'wire', 'copper', 500), (8, 2, 'screw', 'steel', 800), (9, 2, 'nut', 'steel', 1000);
|
Show the top 3 products by quantity for the 'metallurgy' department
|
SELECT name, material, quantity FROM products WHERE department = 2 ORDER BY quantity DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Companies (id INT, name TEXT, industry TEXT, founders TEXT, funding FLOAT, bipoc_founder BOOLEAN); INSERT INTO Companies (id, name, industry, founders, funding, bipoc_founder) VALUES (1, 'GreenTech', 'Green Energy', 'BIPOC Founder', 2000000.00, TRUE); INSERT INTO Companies (id, name, industry, founders, funding, bipoc_founder) VALUES (2, 'BlueInnovations', 'Ocean Technology', 'White Founder', 6000000.00, FALSE);
|
What is the minimum funding amount received by a company founded by a person from the BIPOC community?
|
SELECT MIN(funding) FROM Companies WHERE bipoc_founder = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customers (customer_id INT, customer_name VARCHAR(50), account_number VARCHAR(20), primary_contact VARCHAR(50)); CREATE TABLE transactions (transaction_id INT, customer_id INT, transaction_amount DECIMAL(10,2), transaction_date DATE);
|
List the top 5 customers by total transaction amount for the year 2021, including their names and account numbers?
|
SELECT c.customer_name, c.account_number, SUM(t.transaction_amount) as total_transaction_amount FROM customers c JOIN transactions t ON c.customer_id = t.customer_id WHERE transaction_date BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY c.customer_name, c.account_number ORDER BY total_transaction_amount DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE dance_workshops (workshop_id INT, participant_name VARCHAR(50), email VARCHAR(50)); INSERT INTO dance_workshops (workshop_id, participant_name, email) VALUES (1, 'Lucas', 'lucas@oldmail.com'), (2, 'Nia', 'nia@mail.com'), (3, 'Kevin', 'kevin@mail.com');
|
Update the email address of the participant 'Lucas' in the 'Dance Workshops' table.
|
UPDATE dance_workshops SET email = 'lucas@newmail.com' WHERE participant_name = 'Lucas';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE employee_training (employee_id varchar(10),training_topic varchar(255),training_date date);
|
Insert a new record into the "employee_training" table for employee E003 with the training topic "Environmental Regulations" on February 14, 2022.
|
INSERT INTO employee_training (employee_id,training_topic,training_date) VALUES ('E003','Environmental Regulations','2022-02-14');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Volunteers (VolunteerID int, Name varchar(50), Email varchar(50), Community varchar(50), JoinDate date); INSERT INTO Volunteers (VolunteerID, Name, Email, Community, JoinDate) VALUES (1, 'Jamila', 'jamila@example.com', 'African American', '2022-01-10'), (2, 'Hiroshi', 'hiroshi@example.com', 'Japanese', '2022-02-15'), (3, 'Marie', 'marie@example.com', 'French', '2022-01-28');
|
What is the total number of volunteers from historically underrepresented communities who joined in Q1 2022?
|
SELECT COUNT(*) as TotalVolunteers FROM Volunteers WHERE QUARTER(JoinDate) = 1 AND Community IN ('African American', 'Hispanic', 'Indigenous', 'LGBTQ+', 'People with Disabilities');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE security_incidents (id INT, incident_type VARCHAR(255), region VARCHAR(255), severity VARCHAR(255), date DATE); CREATE VIEW incident_summary AS SELECT incident_type, region, severity, date, COUNT(*) OVER (PARTITION BY region ORDER BY date DESC) as incident_count FROM security_incidents;
|
How many critical security incidents have been reported in each region in the past month?
|
SELECT region, incident_count FROM incident_summary WHERE severity = 'critical' AND date >= DATEADD(month, -1, CURRENT_DATE) GROUP BY region ORDER BY incident_count DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SpaceMissions (astronaut_name VARCHAR(255), astronaut_country VARCHAR(255), mission_name VARCHAR(255)); INSERT INTO SpaceMissions (astronaut_name, astronaut_country, mission_name) VALUES ('Tayang Yuan', 'China', 'Shenzhou 10'), ('Fei Junlong', 'China', 'Shenzhou 6'), ('Nie Haisheng', 'China', 'Shenzhou 12');
|
How many space missions have been recorded for astronauts from China?
|
SELECT COUNT(*) FROM SpaceMissions WHERE astronaut_country = 'China';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vehicles (vehicle_id INT, route_id INT, last_maintenance_date DATE);
|
Create a table named 'vehicles' with columns 'vehicle_id', 'route_id', 'last_maintenance_date'
|
CREATE TABLE vehicles (vehicle_id INT, route_id INT, last_maintenance_date DATE);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE graduates (graduate_id INT, name VARCHAR(100), department VARCHAR(50));CREATE TABLE publications (publication_id INT, graduate_id INT, publish_date DATE);
|
What is the average number of papers published per month by graduate students in the Mathematics department in the past 2 years?
|
SELECT AVG(paper_count) as avg_papers_per_month FROM (SELECT graduate_id, COUNT(*) as paper_count FROM publications p JOIN graduates g ON p.graduate_id = g.graduate_id WHERE g.department = 'Mathematics' AND p.publish_date >= DATEADD(year, -2, GETDATE()) GROUP BY g.graduate_id, EOMONTH(p.publish_date)) as subquery;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE bioprocess_engineering (name VARCHAR(255), year INT, budget FLOAT); INSERT INTO bioprocess_engineering (name, year, budget) VALUES ('ProjectA', 2019, 8000000), ('ProjectB', 2020, 9000000), ('ProjectC', 2019, 10000000);
|
What is the minimum budget for bioprocess engineering projects in 2020?
|
SELECT MIN(budget) FROM bioprocess_engineering WHERE year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE restaurant_revenue (restaurant_id INT, revenue INT); INSERT INTO restaurant_revenue (restaurant_id, revenue) VALUES (1, 1200), (2, 1500), (3, 800), (4, 2000), (5, 1700);
|
Display the top 3 most profitable restaurants by total revenue. Use the restaurant_revenue table.
|
SELECT restaurant_id, SUM(revenue) as total_revenue FROM restaurant_revenue GROUP BY restaurant_id ORDER BY total_revenue DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE OilFields (FieldID INT, FieldName VARCHAR(50), Country VARCHAR(50), Production INT, Reserves INT); INSERT INTO OilFields (FieldID, FieldName, Country, Production, Reserves) VALUES (1, 'Galaxy', 'USA', 20000, 500000); INSERT INTO OilFields (FieldID, FieldName, Country, Production, Reserves) VALUES (2, 'Apollo', 'Canada', 15000, 400000); INSERT INTO OilFields (FieldID, FieldName, Country, Production, Reserves) VALUES (3, 'Northstar', 'North Sea', 25000, 600000);
|
List the total production and reserves for oil fields in the North Sea.
|
SELECT Country, SUM(Production) AS Total_Production, SUM(Reserves) AS Total_Reserves FROM OilFields WHERE Country = 'North Sea' GROUP BY Country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE property (id INT, price INT, area VARCHAR(255), co_ownership BOOLEAN); INSERT INTO property (id, price, area, co_ownership) VALUES (1, 200000, 'urban', true), (2, 300000, 'rural', false);
|
What is the total number of properties in urban areas with co-ownership agreements, and their average price?
|
SELECT SUM(price), AVG(price) FROM property WHERE area = 'urban' AND co_ownership = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Songs (id INT, title VARCHAR(100), release_year INT, genre VARCHAR(50), streams INT);
|
What is the total number of streams for all songs released in 2020?
|
SELECT SUM(streams) FROM Songs WHERE release_year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE AutonomousResearch (project VARCHAR(20), company1 VARCHAR(20), company2 VARCHAR(20)); INSERT INTO AutonomousResearch (project, company1, company2) VALUES ('Tesla Autopilot', 'Tesla', 'N/A'); INSERT INTO AutonomousResearch (project, company1, company2) VALUES ('Baidu Apollo', 'Baidu', 'N/A');
|
Find the autonomous driving research projects that are jointly conducted by companies from the USA and China.
|
SELECT project FROM AutonomousResearch WHERE (company1 = 'Tesla' AND company2 = 'Baidu') OR (company1 = 'Baidu' AND company2 = 'Tesla');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE stadiums (id INT, name VARCHAR(50), sport VARCHAR(20), capacity INT);
|
Identify the soccer stadium with the largest capacity
|
SELECT name FROM stadiums WHERE sport = 'Soccer' ORDER BY capacity DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE building_permits (id INT, permit_number VARCHAR(50), issue_date DATE, county VARCHAR(50));
|
How many building permits were issued in Los Angeles County in the last 6 months?
|
SELECT COUNT(*) FROM building_permits WHERE county = 'Los Angeles County' AND issue_date >= DATE_SUB(CURDATE(), INTERVAL 6 MONTH)
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Diseases (ID INT, Country VARCHAR(50), Continent VARCHAR(50), Disease VARCHAR(50), Count INT); INSERT INTO Diseases (ID, Country, Continent, Disease, Count) VALUES (1, 'Brazil', 'South America', 'Malaria', 200000);
|
What is the most common infectious disease in South America?
|
SELECT Disease, MAX(Count) FROM Diseases WHERE Continent = 'South America';
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA if not exists biotech; USE biotech; CREATE TABLE if not exists startup_funding (id INT PRIMARY KEY, company_name VARCHAR(255), location VARCHAR(255), funding_amount FLOAT); INSERT INTO startup_funding (id, company_name, location, funding_amount) VALUES (1, 'BioVeda', 'India', 2500000.00), (2, 'Genesys', 'India', 3000000.00), (3, 'InnoLife', 'USA', 5000000.00);
|
What is the average funding for biotech startups in India?
|
SELECT AVG(funding_amount) FROM biotech.startup_funding WHERE location = 'India';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE digital_divide_initiatives (initiative_name VARCHAR(100), region VARCHAR(50)); INSERT INTO digital_divide_initiatives (initiative_name, region) VALUES ('DigitalEquality Asia', 'Asia'), ('TechInclusion Africa', 'Africa'), ('AccessibleTech Europe', 'Europe');
|
What is the distribution of digital divide initiatives across global regions?
|
SELECT region, COUNT(initiative_name), 100.0*COUNT(initiative_name)/(SELECT COUNT(*) FROM digital_divide_initiatives) AS percentage FROM digital_divide_initiatives GROUP BY region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE soccer_league (game_id INT, team_name VARCHAR(50), coach_gender VARCHAR(10)); CREATE VIEW soccer_league_won AS SELECT game_id, team_name FROM soccer_league WHERE result = 'win';
|
How many soccer games were won by teams in the soccer_league table that have a female coach?
|
SELECT COUNT(*) FROM soccer_league_won JOIN soccer_league ON soccer_league_won.team_name = soccer_league.team_name WHERE coach_gender = 'female';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE humanitarian_missions (id INT, country VARCHAR, mission_count INT);
|
Which countries have participated in the most humanitarian assistance missions?
|
SELECT country, MAX(mission_count) FROM humanitarian_missions GROUP BY country ORDER BY MAX(mission_count) DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CaseDates (CaseID INT, Date DATE); INSERT INTO CaseDates (CaseID, Date) VALUES (1, '2022-01-01'), (2, '2022-02-01');
|
How many cases were opened in each month of 2022?
|
SELECT DATE_FORMAT(CaseDates.Date, '%Y-%m') AS Month, COUNT(*) AS Cases FROM CaseDates GROUP BY Month;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE players (id INT, name VARCHAR(50), country VARCHAR(50), level INT);
|
Delete 'players' records where the 'country' is 'Brazil'
|
DELETE FROM players WHERE country = 'Brazil';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE production_rates (rate_id INT, manufacturer VARCHAR(20), production_rate INT, measurement_date DATE); INSERT INTO production_rates (rate_id, manufacturer, production_rate, measurement_date) VALUES (1, 'X', 500, '2021-01-01'), (2, 'Y', 700, '2021-01-02'), (3, 'X', 600, '2021-01-01');
|
What is the total quantity of chemicals produced by manufacturer 'X'?
|
SELECT SUM(production_rate) FROM production_rates WHERE manufacturer = 'X';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Immunization_NA (Disease VARCHAR(50), Continent VARCHAR(50), Immunization_Rate FLOAT); INSERT INTO Immunization_NA (Disease, Continent, Immunization_Rate) VALUES ('Measles', 'North America', 92.0);
|
What is the immunization rate for Measles in North America?
|
SELECT Immunization_Rate FROM Immunization_NA WHERE Disease = 'Measles' AND Continent = 'North America';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Streams (StreamID INT, UserID INT, ArtistID INT, Genre VARCHAR(10)); INSERT INTO Streams (StreamID, UserID, ArtistID, Genre) VALUES (1, 101, 1, 'Hip Hop'), (2, 101, 2, 'Hip Hop'), (3, 102, 3, 'Jazz'), (4, 102, 4, 'Pop'), (5, 103, 1, 'Hip Hop'), (6, 103, 3, 'Jazz');
|
Identify the top 3 streaming artists by total number of streams in the 'Hip Hop' genre, excluding artist 'ArtistC'?
|
SELECT ArtistID, SUM(1) AS TotalStreams FROM Streams WHERE Genre = 'Hip Hop' AND ArtistID != 3 GROUP BY ArtistID ORDER BY TotalStreams DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Artifacts (ArtifactID INT, ArtifactType VARCHAR(50), ArtifactWeight FLOAT, Country VARCHAR(50)); INSERT INTO Artifacts (ArtifactID, ArtifactType, ArtifactWeight, Country) VALUES (1, 'Pottery', 2.3, 'USA'), (2, 'Stone Tool', 1.8, 'Mexico'), (3, 'Bone Tool', 3.1, 'USA'), (4, 'Ceramic Figurine', 4.7, 'Canada'), (5, 'Metal Artifact', 5.9, 'Canada');
|
Identify the artifact type with the highest average weight for each country, along with the country and average weight.
|
SELECT Country, ArtifactType, AVG(ArtifactWeight) AS AvgWeight FROM Artifacts GROUP BY Country, ArtifactType HAVING COUNT(*) = (SELECT COUNT(*) FROM Artifacts GROUP BY ArtifactType HAVING COUNT(*) = (SELECT COUNT(*) FROM Artifacts GROUP BY Country, ArtifactType));
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE union_names (union_name TEXT); INSERT INTO union_names (union_name) VALUES ('Union A'), ('Union B'), ('Union C'), ('Union D'); CREATE TABLE membership_stats (union_name TEXT, region TEXT, members INTEGER); INSERT INTO membership_stats (union_name, region, members) VALUES ('Union A', 'north_region', 4000), ('Union B', 'south_region', 2000), ('Union C', 'north_region', 6000), ('Union D', 'north_region', 500);
|
List the union names and their membership statistics that are located in the 'north_region'?
|
SELECT union_names.union_name, membership_stats.members FROM union_names INNER JOIN membership_stats ON union_names.union_name = membership_stats.union_name WHERE membership_stats.region = 'north_region';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE security_incidents (id INT, department VARCHAR(20), cost DECIMAL(10, 2), incident_time TIMESTAMP);
|
What are the total costs of security incidents for each department in the last 6 months, sorted from highest to lowest?
|
SELECT department, SUM(cost) as total_cost FROM security_incidents WHERE incident_time >= NOW() - INTERVAL 6 MONTH GROUP BY department ORDER BY total_cost DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CommunityHealthWorkers (WorkerID INT, Name VARCHAR(50), Specialty VARCHAR(50), MentalHealthParity BOOLEAN); INSERT INTO CommunityHealthWorkers (WorkerID, Name, Specialty, MentalHealthParity) VALUES (1, 'John Doe', 'Mental Health', TRUE); INSERT INTO CommunityHealthWorkers (WorkerID, Name, Specialty, MentalHealthParity) VALUES (2, 'Jane Smith', 'Physical Health', FALSE);
|
Delete the records of community health workers who do not have any mental health parity training.
|
DELETE FROM CommunityHealthWorkers WHERE MentalHealthParity = FALSE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE lifelong_learning (student_id INT, learning_score INT, date DATE); INSERT INTO lifelong_learning (student_id, learning_score, date) VALUES (1, 90, '2022-06-01'), (2, 95, '2022-06-02'), (3, 80, '2022-06-03');
|
What is the maximum lifelong learning score of a student in 'Summer 2022'?
|
SELECT MAX(learning_score) FROM lifelong_learning WHERE date = '2022-06-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Spacecraft (id INT, name VARCHAR(50), manufacturer VARCHAR(50), launch_date DATE); INSERT INTO Spacecraft (id, name, manufacturer, launch_date) VALUES (1, 'Vostok 1', 'Roscosmos', '1961-04-12'), (2, 'Mercury-Redstone 3', 'NASA', '1961-05-05'), (3, 'Sputnik 1', 'Roscosmos', '1957-10-04');
|
What are the names of all spacecraft that were launched after the first manned spaceflight by a non-US agency?
|
SELECT s.name FROM Spacecraft s WHERE s.launch_date > (SELECT launch_date FROM Spacecraft WHERE name = 'Vostok 1');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE military_bases (id INT, name VARCHAR(255), type VARCHAR(255), region VARCHAR(255), personnel INT); INSERT INTO military_bases (id, name, type, region, personnel) VALUES (1, 'Base 1', 'Air Force', 'Middle East', 1000), (2, 'Base 2', 'Navy', 'Middle East', 2000);
|
What is the average number of military personnel per base in the Middle East?
|
SELECT AVG(personnel) FROM military_bases WHERE region = 'Middle East';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Diversity (Company VARCHAR(50), Year INT, DiverseEmployees INT); INSERT INTO Diversity (Company, Year, DiverseEmployees) VALUES ('Acme Inc.', 2018, 50), ('Acme Inc.', 2019, 75), ('Acme Inc.', 2020, 85), ('Beta Corp.', 2018, 30), ('Beta Corp.', 2019, 35), ('Beta Corp.', 2020, 40);
|
Delete diversity metrics for 2020 from the database.
|
DELETE FROM Diversity WHERE Year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE agricultural_projects (id INT, project_type VARCHAR(255), location VARCHAR(255), area_ha FLOAT, year INT); INSERT INTO agricultural_projects (id, project_type, location, area_ha, year) VALUES (1, 'Precision Farming', 'Asia', 500, 2020), (2, 'Organic Farming', 'Asia', 300, 2020), (3, 'Agroforestry', 'Asia', 700, 2020);
|
What is the total area (in hectares) of land used for agricultural innovation projects, categorized by project type, for the year 2020 in the Asia region?
|
SELECT project_type, SUM(area_ha) as total_area_ha FROM agricultural_projects WHERE location = 'Asia' AND year = 2020 GROUP BY project_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE materials (material_id INT, name VARCHAR(255), is_sustainable BOOLEAN); INSERT INTO materials VALUES (1, 'Organic Cotton', true); INSERT INTO materials VALUES (2, 'Recycled Polyester', true); INSERT INTO materials VALUES (3, 'Conventional Cotton', false); CREATE TABLE inventory (inventory_id INT, material_id INT, factory_id INT, quantity INT); INSERT INTO inventory VALUES (1, 1, 1, 2000); INSERT INTO inventory VALUES (2, 2, 2, 3000); INSERT INTO inventory VALUES (3, 3, 1, 1500);
|
List all sustainable material types and their respective total quantities used across all factories.
|
SELECT materials.name, SUM(inventory.quantity) FROM materials JOIN inventory ON materials.material_id = inventory.material_id WHERE materials.is_sustainable = true GROUP BY materials.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE programs (program TEXT, impact_score DECIMAL); INSERT INTO programs (program, impact_score) VALUES ('Program C', 4.2), ('Program D', 3.5);
|
What is the average program impact score for program C?
|
SELECT AVG(impact_score) FROM programs WHERE program = 'Program C';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Animals (name VARCHAR(50), species VARCHAR(50), location VARCHAR(50)); INSERT INTO Animals (name, species, location) VALUES ('Seal 1', 'Seal', 'Arctic Ocean'), ('Seal 2', 'Seal', 'Arctic Ocean'), ('Walrus 1', 'Walrus', 'Arctic Ocean');
|
How many walruses are in the Arctic Ocean?
|
SELECT COUNT(*) FROM Animals WHERE species = 'Walrus' AND location = 'Arctic Ocean';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE movies (id INT, title TEXT, country TEXT, year INT, runtime INT); INSERT INTO movies (id, title, country, year, runtime) VALUES (1, 'MovieA', 'Korea', 2015, 120), (2, 'MovieB', 'Korea', 2016, 105), (3, 'MovieC', 'USA', 2017, 90);
|
What is the average runtime of Korean movies produced between 2015 and 2018?
|
SELECT AVG(runtime) FROM movies WHERE country = 'Korea' AND year BETWEEN 2015 AND 2018;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE treatment_history (patient_id INT, treatment_date DATE, treatment_type VARCHAR(255), facility_id INT, facility_name VARCHAR(255), facility_location VARCHAR(255)); CREATE TABLE treatment_codes (treatment_code INT, treatment_type VARCHAR(255)); CREATE TABLE patients (patient_id INT, first_name VARCHAR(255), last_name VARCHAR(255), age INT, gender VARCHAR(255), address VARCHAR(255), phone_number VARCHAR(255), email VARCHAR(255));
|
List the top 5 mental health conditions by number of patients treated in the treatment_history table.
|
SELECT th.treatment_type, COUNT(DISTINCT th.patient_id) as patient_count FROM treatment_history th JOIN treatment_codes tc ON th.treatment_type = tc.treatment_code GROUP BY th.treatment_type ORDER BY patient_count DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donations (id INT, donor_id INT, donation_amount DECIMAL(10,2), donation_date DATE); CREATE TABLE donors (id INT, is_first_time_donor BOOLEAN, country VARCHAR(50)); INSERT INTO donations (id, donor_id, donation_amount, donation_date) VALUES (1, 1, 100.00, '2019-04-15'); INSERT INTO donors (id, is_first_time_donor, country) VALUES (1, true, 'Australia');
|
What is the total amount donated by first-time donors from Australia in 2019?
|
SELECT SUM(donation_amount) FROM donations JOIN donors ON donations.donor_id = donors.id WHERE donors.country = 'Australia' AND donors.is_first_time_donor = true AND YEAR(donation_date) = 2019;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE City_Exhibitions (id INT, city VARCHAR(20), num_exhibitions INT); INSERT INTO City_Exhibitions (id, city, num_exhibitions) VALUES (1, 'New York', 5), (2, 'Chicago', 3), (3, 'Miami', 4); CREATE TABLE Exhibition_Visitors (id INT, exhibition VARCHAR(20), city VARCHAR(20), num_visitors INT); INSERT INTO Exhibition_Visitors (id, exhibition, city, num_visitors) VALUES (1, 'Art of the 90s', 'New York', 2000), (2, 'Science of Space', 'Chicago', 1500), (3, 'Art of the 90s', 'New York', 2500), (4, 'History of Technology', 'Miami', 1000);
|
What was the average number of visitors per exhibition in each city?
|
SELECT ce.city, AVG(ev.num_visitors) AS avg_visitors_per_exhibition FROM City_Exhibitions ce JOIN Exhibition_Visitors ev ON ce.city = ev.city GROUP BY ce.city;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ocean_depths (ocean TEXT, depth FLOAT); INSERT INTO ocean_depths (ocean, depth) VALUES ('Pacific Ocean', 10994.0);
|
What is the minimum depth in the Pacific Ocean?
|
SELECT MIN(depth) FROM ocean_depths WHERE ocean = 'Pacific Ocean';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE programs (id INT, name VARCHAR, budget DECIMAL); CREATE TABLE volunteers (id INT, name VARCHAR, email VARCHAR, phone VARCHAR); CREATE TABLE volunteer_assignments (id INT, volunteer_id INT, program_id INT, hours DECIMAL);
|
Calculate the number of volunteers and total volunteer hours for each program
|
SELECT programs.name, COUNT(DISTINCT volunteers.id) as num_volunteers, SUM(volunteer_assignments.hours) as total_volunteer_hours FROM programs JOIN volunteer_assignments ON programs.id = volunteer_assignments.program_id JOIN volunteers ON volunteer_assignments.volunteer_id = volunteers.id GROUP BY programs.id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE product_transparency (product_id INT, product_name VARCHAR(50), circular_supply_chain BOOLEAN, recycled_content DECIMAL(4,2), COUNTRY VARCHAR(50));
|
Get the 'product_name' and 'country' for 'product_transparency' records with a circular supply chain.
|
SELECT product_name, country FROM product_transparency WHERE circular_supply_chain = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE packages (id INT, route_id VARCHAR(5), weight DECIMAL(5,2)); INSERT INTO packages (id, route_id, weight) VALUES (100, 'R01', 12.3), (101, 'R02', 15.6), (102, 'R03', 8.8), (103, 'R04', 20.1), (104, 'R04', 18.5), (105, 'R01', 10.0);
|
What is the weight of the lightest package on route 'R01'?
|
SELECT MIN(weight) FROM packages WHERE route_id = 'R01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Institutions (InstitutionID INT, InstitutionName VARCHAR(100), Region VARCHAR(50)); INSERT INTO Institutions (InstitutionID, InstitutionName, Region) VALUES (1, 'XYZ Microfinance', 'North America'), (2, 'CDE Credit Union', 'North America'); CREATE TABLE Loans (LoanID INT, InstitutionID INT, Amount DECIMAL(10,2), Outstanding BOOLEAN); INSERT INTO Loans (LoanID, InstitutionID, Amount, Outstanding) VALUES (1, 1, 5000, TRUE), (2, 2, 0, FALSE);
|
Find the number of socially responsible lending institutions in North America that do not have any outstanding loans.
|
SELECT COUNT(DISTINCT Institutions.InstitutionID) FROM Institutions LEFT JOIN Loans ON Institutions.InstitutionID = Loans.InstitutionID WHERE Loans.LoanID IS NULL AND Institutions.Region = 'North America';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE prison (id INT, name TEXT, security_level TEXT, age INT); INSERT INTO prison (id, name, security_level, age) VALUES (1, 'John Doe', 'low_security', 35); INSERT INTO prison (id, name, security_level, age) VALUES (2, 'Jane Smith', 'medium_security', 55);
|
What is the name, security level, and age of inmates who are 30 or older in the prison table?
|
SELECT name, security_level, age FROM prison WHERE age >= 30;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Restaurants (RestaurantID int, Name varchar(50), Location varchar(50)); CREATE TABLE Menu (MenuID int, ItemName varchar(50), Category varchar(50)); CREATE TABLE MenuSales (MenuID int, RestaurantID int, QuantitySold int, Revenue decimal(5,2), SaleDate date);
|
Delete menu items that were not sold in any restaurant in the state of California during the month of August 2021.
|
DELETE M FROM Menu M LEFT JOIN MenuSales MS ON M.MenuID = MS.MenuID WHERE MS.MenuID IS NULL AND M.Location LIKE '%California%' AND MS.SaleDate >= '2021-08-01' AND MS.SaleDate <= '2021-08-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE socially_responsible_lending_3 (id INT, country VARCHAR(20), loan_amount DECIMAL(10, 2)); INSERT INTO socially_responsible_lending_3 (id, country, loan_amount) VALUES (1, 'France', 600.00), (2, 'Germany', 550.00), (3, 'Italy', 500.00);
|
What is the average loan amount for socially responsible lending in the European Union?
|
SELECT AVG(loan_amount) FROM socially_responsible_lending_3 WHERE country IN ('France', 'Germany', 'Italy');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE defense_projects (project_name VARCHAR(255), start_date DATE, end_date DATE); INSERT INTO defense_projects (project_name, start_date, end_date) VALUES ('Joint Light Tactical Vehicle', '2016-01-01', '2020-12-31'), ('Ground Combat Vehicle', '2015-01-01', '2024-12-31');
|
Which defense projects have experienced delays of over 6 months since their original timeline?
|
SELECT project_name FROM defense_projects WHERE DATEDIFF(end_date, start_date) > 180;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Dams (id INT, state VARCHAR(50)); INSERT INTO Dams (id, state) VALUES (1, 'California'), (2, 'Texas');
|
Show the number of dams in each state
|
SELECT state, COUNT(*) FROM Dams GROUP BY state;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Artworks (ArtworkID INT, Title VARCHAR(50), Gallery VARCHAR(50)); INSERT INTO Artworks (ArtworkID, Title, Gallery) VALUES (1, 'Starry Night', 'ImpressionistGallery'); INSERT INTO Artworks (ArtworkID, Title, Gallery) VALUES (2, 'Sunflowers', 'ImpressionistGallery'); INSERT INTO Artworks (ArtworkID, Title, Gallery) VALUES (3, 'Water Lilies', 'ImpressionistGallery'); INSERT INTO Artworks (ArtworkID, Title, Gallery) VALUES (4, 'Water Lilies', 'ModernArt');
|
Which galleries have 'Water Lilies' on display?
|
SELECT DISTINCT Gallery FROM Artworks WHERE Title = 'Water Lilies';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE canada_energy_efficiency (province VARCHAR(50), building_type VARCHAR(50), energy_efficiency_rating FLOAT); INSERT INTO canada_energy_efficiency (province, building_type, energy_efficiency_rating) VALUES ('Ontario', 'Commercial', 75.5), ('Quebec', 'Commercial', 72.3), ('Alberta', 'Commercial', 78.1);
|
What is the minimum energy efficiency rating for commercial buildings in Canada?
|
SELECT MIN(energy_efficiency_rating) FROM canada_energy_efficiency WHERE building_type = 'Commercial';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE VirtualReality (VRID INT PRIMARY KEY, VRName VARCHAR(50), PlayersUsing INT); INSERT INTO VirtualReality (VRID, VRName, PlayersUsing) VALUES (3, 'PlayStation VR', 80000); INSERT INTO VirtualReality (VRID, VRName, PlayersUsing) VALUES (5, 'Valve Index', 60000);
|
What are the names of the virtual reality devices used by the most players?
|
SELECT VRName, PlayersUsing FROM VirtualReality ORDER BY PlayersUsing DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE recalls (recall_id INT, recall_number INT, recall_date DATE, vehicle_id INT, safety_issue BOOLEAN); CREATE TABLE vehicles (vehicle_id INT, manufacture VARCHAR(20), year_produced INT, vehicle_type VARCHAR(20));
|
List the number of recalls for vehicles produced in the last 5 years with a safety issue.
|
SELECT COUNT(*) FROM recalls r JOIN vehicles v ON r.vehicle_id = v.vehicle_id WHERE safety_issue = TRUE AND v.year_produced >= YEAR(DATEADD(year, -5, GETDATE()));
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE loans (loan_number INT, amount DECIMAL(10, 2), status VARCHAR(10), created_at TIMESTAMP);
|
Delete all records in the loans table where the status is 'declined'
|
DELETE FROM loans WHERE status = 'declined';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE provinces (province VARCHAR(255), water_usage INT); INSERT INTO provinces (province, water_usage) VALUES ('Alberta', 1200), ('British Columbia', 1500), ('Manitoba', 800);
|
What is the total water usage by each province in Canada?
|
SELECT province, SUM(water_usage) FROM provinces GROUP BY province;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CreativeAIs (Id INT, Industry VARCHAR(50), Application VARCHAR(50)); INSERT INTO CreativeAIs (Id, Industry, Application) VALUES (1, 'Healthcare', 'Medical Diagnosis'), (2, 'Education', 'Tutoring System'), (3, 'Finance', 'Fraud Detection');
|
How many creative AI applications have been developed for the healthcare industry?
|
SELECT COUNT(*) FROM CreativeAIs WHERE Industry = 'Healthcare';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sales_data (id INT, drug_name VARCHAR(255), sale_channel VARCHAR(255), sale_amount DECIMAL(10,2), sale_date DATE); INSERT INTO sales_data (id, drug_name, sale_channel, sale_amount, sale_date) VALUES (1, 'DrugA', 'Direct', 10000, '2020-01-01'); INSERT INTO sales_data (id, drug_name, sale_channel, sale_amount, sale_date) VALUES (2, 'DrugA', 'Indirect', 15000, '2020-01-01');
|
What are the total sales figures for a specific drug, including sales from both direct and indirect channels, for the year 2020 in the United States?
|
SELECT SUM(sale_amount) FROM sales_data WHERE drug_name = 'DrugA' AND YEAR(sale_date) = 2020 AND (sale_channel = 'Direct' OR sale_channel = 'Indirect');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE attorneys (attorney_id INT PRIMARY KEY, attorney_name VARCHAR(50), experience INT, area_of_practice VARCHAR(50));
|
Add a new attorney named 'Alex' to the 'attorneys' table
|
INSERT INTO attorneys (attorney_id, attorney_name, experience, area_of_practice) VALUES (4, 'Alex', 7, 'Civil Rights');
|
gretelai_synthetic_text_to_sql
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.