context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE sustainable_buildings (id INT, state VARCHAR(2), cost DECIMAL(5,2)); INSERT INTO sustainable_buildings (id, state, cost) VALUES (1, 'TX', 150.50), (2, 'CA', 200.75), (3, 'TX', 175.20);
What is the average labor cost per square foot for sustainable building projects in Texas?
SELECT AVG(cost) FROM sustainable_buildings WHERE state = 'TX';
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name TEXT, rating FLOAT, manufacturer_country TEXT); INSERT INTO products (product_id, product_name, rating, manufacturer_country) VALUES (1, 'Product A', 4.5, 'USA'), (2, 'Product B', 4.2, 'China'), (3, 'Product C', 4.8, 'USA');
Display the product names and their manufacturers for all products with a rating above 4.0.
SELECT product_name, manufacturer_country FROM products WHERE rating > 4.0;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (species_id INTEGER, species_name TEXT, ocean TEXT); CREATE VIEW marine_species_count AS SELECT ocean, COUNT(*) FROM marine_species GROUP BY ocean;
What is the total number of marine species in each ocean?
SELECT ocean, SUM(species_count) FROM marine_species INNER JOIN marine_species_count ON marine_species.ocean = marine_species_count.ocean GROUP BY ocean;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID int, DonorName varchar(50), DonationAmount decimal(10,2), DonationDate date); INSERT INTO Donors (DonorID, DonorName, DonationAmount, DonationDate) VALUES (1, 'John Doe', 500, '2020-01-01'); INSERT INTO Donors (DonorID, DonorName, DonationAmount, DonationDate) VALUES (2, 'Jane Smith', 300, '2020-05-15');
What is the total amount donated by individual donors from California in the year 2020?
SELECT SUM(DonationAmount) FROM Donors WHERE DonorState = 'California' AND YEAR(DonationDate) = 2020 AND DonationType = 'Individual';
gretelai_synthetic_text_to_sql
CREATE TABLE Field23 (date DATE, soil_moisture FLOAT); INSERT INTO Field23 VALUES ('2020-01-01', 30), ('2020-01-02', 32); CREATE TABLE Field24 (date DATE, soil_moisture FLOAT); INSERT INTO Field24 VALUES ('2020-01-01', 28), ('2020-01-02', 30);
What is the average soil moisture difference between Field23 and Field24 for each week in the year 2020?
SELECT AVG(f23.soil_moisture - f24.soil_moisture) as avg_soil_moisture_difference FROM Field23 f23 INNER JOIN Field24 f24 ON f23.date = f24.date WHERE EXTRACT(YEAR FROM f23.date) = 2020 GROUP BY EXTRACT(WEEK FROM f23.date);
gretelai_synthetic_text_to_sql
CREATE TABLE Visitors (id INT, age INT, gender VARCHAR(255)); CREATE TABLE Interactions (id INT, visitor_id INT, installation_id INT);
Get the top 5 most interactive visitors
SELECT Visitors.id, Visitors.age, Visitors.gender, COUNT(Interactions.id) AS interactions FROM Visitors JOIN Interactions ON Visitors.id = Interactions.visitor_id GROUP BY Visitors.id ORDER BY interactions DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE WaterQuality (Location VARCHAR(50), Region VARCHAR(50), DissolvedOxygen FLOAT); INSERT INTO WaterQuality (Location, Region, DissolvedOxygen) VALUES ('Location1', 'RegionA', 6.5), ('Location2', 'RegionB', 7.0), ('Location3', 'RegionA', 6.8), ('Location4', 'RegionC', 7.2);
What is the maximum dissolved oxygen level recorded for each region in the WaterQuality table?
SELECT Region, MAX(DissolvedOxygen) FROM WaterQuality GROUP BY Region;
gretelai_synthetic_text_to_sql
CREATE TABLE biotech_startups (name TEXT, funding FLOAT, date DATE); INSERT INTO biotech_startups (name, funding, date) VALUES ('StartupA', 3000000, '2022-04-15'); INSERT INTO biotech_startups (name, funding, date) VALUES ('StartupB', 4000000, '2022-06-20');
What was the total funding for biotech startups in Q2 2022?
SELECT SUM(funding) FROM biotech_startups WHERE date BETWEEN '2022-04-01' AND '2022-06-30';
gretelai_synthetic_text_to_sql
CREATE TABLE Vendors (VendorID INT, VendorName TEXT, Country TEXT);CREATE TABLE Products (ProductID INT, ProductName TEXT, Price DECIMAL, EthicalSource BOOLEAN, TransparentProduction BOOLEAN, VendorID INT); INSERT INTO Vendors VALUES (1, 'VendorH', 'Germany'), (2, 'VendorI', 'Germany'), (3, 'VendorJ', 'Germany'); INSERT INTO Products VALUES (1, 'Coffee', 7.5, false, true, 1), (2, 'Tea', 3.5, true, true, 1), (3, 'Chocolate', 2.5, false, true, 1), (4, 'Bread', 1.2, true, false, 2);
List the vendors who have products with transparent production methods but not ethically sourced.
SELECT v.VendorName FROM Vendors v JOIN Products p ON v.VendorID = p.VendorID WHERE p.TransparentProduction = true AND p.EthicalSource = false GROUP BY v.VendorID, v.VendorName;
gretelai_synthetic_text_to_sql
CREATE TABLE patients (id INT, name TEXT, age INT, therapy TEXT, therapy_year INT); INSERT INTO patients (id, name, age, therapy, therapy_year) VALUES (1, 'Alice', 30, 'CBT', 2019), (2, 'Bob', 45, 'DBT', 2021), (3, 'Charlie', 60, 'CBT', 2018), (4, 'David', 50, 'CBT', 2017), (5, 'Eve', 55, 'DBT', 2021);
Update the therapy year to 2023 for patients who received CBT
UPDATE patients SET therapy_year = 2023 WHERE therapy = 'CBT';
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (asset TEXT, tx_date DATE); INSERT INTO transactions (asset, tx_date) VALUES ('Securitize', '2021-01-01'), ('Securitize', '2021-01-02'), ('Polymath', '2021-01-01'), ('Polymath', '2021-01-02'), ('Polymath', '2021-01-03');
List the digital assets that have had the highest number of transactions per day on average.
SELECT asset, AVG(tx_count) FROM (SELECT asset, COUNT(*) AS tx_count FROM transactions GROUP BY asset, tx_date) AS subquery GROUP BY asset ORDER BY AVG(tx_count) DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE defendants (id INT, case_id INT, ethnicity VARCHAR(255)); INSERT INTO defendants (id, case_id, ethnicity) VALUES (1, 1, 'Hispanic'); INSERT INTO defendants (id, case_id, ethnicity) VALUES (2, 2, 'African American');
What is the distribution of case types by defendant's ethnicity, ordered by the number of cases?
SELECT ethnicity, type, COUNT(*) as case_count, ROW_NUMBER() OVER(PARTITION BY ethnicity ORDER BY COUNT(*) DESC) as sequence FROM defendants JOIN courts ON defendants.case_id = courts.id GROUP BY ethnicity, type;
gretelai_synthetic_text_to_sql
CREATE TABLE Berlin_Neighborhoods (Neighborhood_Name TEXT, Affordable BOOLEAN); INSERT INTO Berlin_Neighborhoods (Neighborhood_Name, Affordable) VALUES ('Mitte', false), ('Friedrichshain', true), ('Kreuzberg', true), ('Prenzlauer Berg', false); CREATE TABLE Berlin_Properties (Neighborhood_Name TEXT, Property_Price INTEGER); INSERT INTO Berlin_Properties (Neighborhood_Name, Property_Price) VALUES ('Mitte', 500000), ('Friedrichshain', 400000), ('Kreuzberg', 450000), ('Prenzlauer Berg', 550000);
What is the median property price in affordable neighborhoods in Berlin?
SELECT AVG(Berlin_Properties.Property_Price) FROM Berlin_Properties INNER JOIN Berlin_Neighborhoods ON Berlin_Properties.Neighborhood_Name = Berlin_Neighborhoods.Neighborhood_Name WHERE Berlin_Neighborhoods.Affordable = true;
gretelai_synthetic_text_to_sql
CREATE TABLE bioprocess_data (id INT, sample_id VARCHAR(20), pressure FLOAT); CREATE TABLE genetic_data (id INT, sample_id VARCHAR(20), gene_sequence TEXT); INSERT INTO bioprocess_data (id, sample_id, pressure) VALUES (1, 'GD001', 1.5), (2, 'GD002', 0.8); INSERT INTO genetic_data (id, sample_id, gene_sequence) VALUES (1, 'GD001', 'ATGCGA...');
Delete bioprocess data with pressure below 1 and no genetic data.
DELETE bp FROM bioprocess_data bp LEFT JOIN genetic_data gd ON bp.sample_id = gd.sample_id WHERE bp.pressure < 1 AND gd.sample_id IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE Clients (ClientID INT, Ethnicity VARCHAR(20)); CREATE TABLE Cases (CaseID INT, CaseType VARCHAR(20), BillingAmount INT, ClientID INT); INSERT INTO Clients (ClientID, Ethnicity) VALUES (1, 'Hispanic'), (2, 'African American'), (3, 'Asian'), (4, 'Caucasian'); INSERT INTO Cases (CaseID, CaseType, BillingAmount, ClientID) VALUES (1, 'Civil', 500, 1), (2, 'Criminal', 1000, 2), (3, 'Civil', 750, 3), (4, 'Civil', 800, 4);
What is the total billing amount for cases where the client's ethnicity is 'Hispanic' or 'African American'?
SELECT SUM(BillingAmount) FROM Cases JOIN Clients ON Cases.ClientID = Clients.ClientID WHERE Clients.Ethnicity = 'Hispanic' OR Clients.Ethnicity = 'African American';
gretelai_synthetic_text_to_sql
CREATE TABLE worker_competency (worker_id INT, score INT); INSERT INTO worker_competency (worker_id, score) VALUES (1, 85), (2, 90), (3, 80), (4, 88), (5, 92);
What is the percentage of community health workers with a cultural competency score above 85?
SELECT COUNT(*) FILTER (WHERE score > 85) OVER (PARTITION BY 1) * 100.0 / COUNT(*) OVER (PARTITION BY 1) as percentage_above_85 FROM worker_competency;
gretelai_synthetic_text_to_sql
CREATE TABLE programs (program_id INT, program_name TEXT); CREATE TABLE volunteers (volunteer_id INT, volunteer_name TEXT, program_id INT); CREATE TABLE volunteer_hours (hour_id INT, volunteer_id INT, hours FLOAT); INSERT INTO programs (program_id, program_name) VALUES (1, 'Arts'), (2, 'Sports'), (3, 'Education'); INSERT INTO volunteers (volunteer_id, volunteer_name, program_id) VALUES (1, 'Olivia Jones', 1), (2, 'David Kim', 2), (3, 'Sophia Lee', 3); INSERT INTO volunteer_hours (hour_id, volunteer_id, hours) VALUES (1, 1, 10), (2, 2, 15), (3, 3, 20);
What is the total number of volunteers and total volunteer hours for each program in the 'programs' and 'volunteer_hours' tables?
SELECT p.program_name, COUNT(v.volunteer_id) as num_volunteers, SUM(vh.hours) as total_hours FROM programs p JOIN volunteers v ON p.program_id = v.program_id JOIN volunteer_hours vh ON v.volunteer_id = vh.volunteer_id GROUP BY p.program_name;
gretelai_synthetic_text_to_sql
CREATE TABLE vehicles (vehicle_id INT, wheelchair_accessible BOOLEAN); INSERT INTO vehicles VALUES (1, TRUE); INSERT INTO vehicles VALUES (2, FALSE); INSERT INTO vehicles VALUES (3, TRUE); INSERT INTO vehicles VALUES (4, FALSE); INSERT INTO vehicles VALUES (5, TRUE);
What is the number of wheelchair accessible vehicles in the fleet and the percentage of the fleet they represent?
SELECT COUNT(vehicles.vehicle_id) as total_vehicles, SUM(vehicles.wheelchair_accessible) as wheelchair_accessible_vehicles, (SUM(vehicles.wheelchair_accessible) * 100.0 / COUNT(vehicles.vehicle_id)) as percentage FROM vehicles;
gretelai_synthetic_text_to_sql
CREATE TABLE Customers (CustomerID INT, CustomerName VARCHAR(255)); CREATE TABLE Purchases (PurchaseID INT, CustomerID INT, DispensaryName VARCHAR(255), TotalPaid DECIMAL(10,2)); INSERT INTO Customers (CustomerID, CustomerName) VALUES (1, 'John Doe'), (2, 'Jane Smith'), (3, 'Jim Brown'); INSERT INTO Purchases (PurchaseID, CustomerID, DispensaryName, TotalPaid) VALUES (1, 1, 'Dispensary A', 100.00), (2, 1, 'Dispensary A', 75.00), (3, 2, 'Dispensary A', 150.00), (4, 2, 'Dispensary A', 200.00), (5, 3, 'Dispensary A', 50.00);
Who are the top 5 customers by total purchases in dispensary A?
SELECT CustomerName, SUM(TotalPaid) AS TotalPurchases FROM Customers JOIN Purchases ON Customers.CustomerID = Purchases.CustomerID WHERE DispensaryName = 'Dispensary A' GROUP BY CustomerName ORDER BY TotalPurchases DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE smart_contracts (id INT, name VARCHAR(255)); INSERT INTO smart_contracts (id, name) VALUES (9, 'Polygon'); CREATE TABLE stake_limits (smart_contract_id INT, max_stake_tokens INT); INSERT INTO stake_limits (smart_contract_id, max_stake_tokens) VALUES (9, 500000);
What is the maximum number of tokens that can be staked for the 'Polygon' smart contract?
SELECT max_stake_tokens FROM stake_limits WHERE smart_contract_id = (SELECT id FROM smart_contracts WHERE name = 'Polygon');
gretelai_synthetic_text_to_sql
CREATE TABLE MovieData (id INT, title VARCHAR(100), budget FLOAT, marketing FLOAT);
Which movies have a production budget over 5 times the average marketing cost?
SELECT title FROM MovieData WHERE budget > 5 * (SELECT AVG(marketing) FROM MovieData);
gretelai_synthetic_text_to_sql
CREATE TABLE disease_prevalence (county VARCHAR(50), diagnosis VARCHAR(50), prevalence DECIMAL(5,2)); INSERT INTO disease_prevalence (county, diagnosis, prevalence) VALUES ('Rural County A', 'Heart Disease', 10.00), ('Rural County B', 'Diabetes', 7.50);
Delete records from the "disease_prevalence" table for 'Rural County B' with a 'Diabetes' diagnosis
DELETE FROM disease_prevalence WHERE county = 'Rural County B' AND diagnosis = 'Diabetes';
gretelai_synthetic_text_to_sql
CREATE TABLE departments (department VARCHAR(50), num_students INT); INSERT INTO departments VALUES ('Computer Science', 50), ('Mathematics', 40), ('Physics', 60);
What is the percentage of graduate students in each department who have published in the last three years?
SELECT d.department, COUNT(gs.student_id) * 100.0 / d.num_students AS percentage FROM departments d JOIN graduate_students gs ON d.department = gs.department WHERE gs.publication_year BETWEEN YEAR(CURRENT_DATE) - 3 AND YEAR(CURRENT_DATE) GROUP BY d.department;
gretelai_synthetic_text_to_sql
CREATE TABLE states (id INT, name VARCHAR(20), num_bridges INT, avg_length FLOAT); INSERT INTO states (id, name, num_bridges, avg_length) VALUES (1, 'California', 25000, 20), (2, 'Texas', 50000, 20), (3, 'New York', 30000, 25);
List the number of bridges and the average bridge length for each state, in ascending order by the number of bridges.
SELECT name, num_bridges, avg_length FROM states ORDER BY num_bridges ASC;
gretelai_synthetic_text_to_sql
CREATE TABLE cities (name TEXT, state TEXT, avg_income INTEGER, population INTEGER); INSERT INTO cities (name, state, avg_income, population) VALUES ('City1', 'Washington', 70000, 60000), ('City2', 'Washington', 60000, 70000), ('City3', 'Washington', 80000, 40000), ('City4', 'Washington', 50000, 90000), ('City5', 'Washington', 65000, 80000);
What is the average income and population of cities in Washington with a population greater than 50000?
SELECT AVG(avg_income) as avg_income, AVG(population) as avg_population FROM cities WHERE state = 'Washington' AND population > 50000;
gretelai_synthetic_text_to_sql
CREATE TABLE labor_forces (id INT, name VARCHAR(50), gender VARCHAR(10), occupation VARCHAR(50), salary FLOAT); INSERT INTO labor_forces (id, name, gender, occupation, salary) VALUES (1, 'John Doe', 'Male', 'Engineer', 75000.00), (2, 'Jane Smith', 'Female', 'Engineer', 72000.00), (3, 'Mike Johnson', 'Male', 'Clerk', 35000.00), (4, 'Emily Davis', 'Female', 'Clerk', 34000.00);
Calculate the average salary of male and female workers in the 'labor_forces' table
SELECT CASE WHEN gender = 'Male' THEN 'Male' ELSE 'Female' END AS gender, AVG(salary) AS avg_salary FROM labor_forces GROUP BY gender;
gretelai_synthetic_text_to_sql
CREATE TABLE mining_sites (id INT, site_name TEXT, num_employees INT);
What is the total number of employees at each mining site, and which sites have more than 500 employees?
SELECT s.site_name, SUM(s.num_employees) as total_employees FROM mining_sites s GROUP BY s.site_name HAVING SUM(s.num_employees) > 500;
gretelai_synthetic_text_to_sql
CREATE TABLE irrigation (id INT PRIMARY KEY, farm_id INT, method VARCHAR(255), efficiency FLOAT); INSERT INTO irrigation (id, farm_id, method, efficiency) VALUES (1, 1, 'Drip', 0.9), (2, 2, 'Sprinkler', 0.7);
What are the methods used for irrigation with an efficiency greater than 0.75?
SELECT method FROM irrigation WHERE efficiency > 0.75;
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (VolunteerID INT, Name TEXT, Department TEXT, Region TEXT); INSERT INTO Volunteers (VolunteerID, Name, Department, Region) VALUES (1, 'Alice', 'Education', 'North America'), (2, 'Beto', 'Fundraising', 'South America');
Who are the volunteers from the 'Global South' region?
SELECT Name FROM Volunteers WHERE Region = 'South America';
gretelai_synthetic_text_to_sql
CREATE TABLE shark_biomass (id INT, species TEXT, region TEXT, biomass FLOAT); INSERT INTO shark_biomass (id, species, region, biomass) VALUES (1, 'Great White', 'Eastern Pacific', 500), (2, 'Hammerhead', 'Eastern Pacific', 300), (3, 'Mako', 'Western Pacific', 400);
What is the average biomass of all shark species in the 'Eastern Pacific' region?
SELECT AVG(biomass) FROM shark_biomass WHERE region = 'Eastern Pacific';
gretelai_synthetic_text_to_sql
CREATE TABLE vt_engagement (id INT, quarter TEXT, category TEXT, views INT); INSERT INTO vt_engagement (id, quarter, category, views) VALUES (1, 'Q1 2022', 'attractions', 1000), (2, 'Q2 2022', 'attractions', 1200), (3, 'Q1 2022', 'hotels', 800);
What is the growth rate of virtual tour engagement in the 'attractions' category between Q1 2022 and Q2 2022?
SELECT (Q2_views - Q1_views) * 100.0 / Q1_views as growth_rate FROM (SELECT (SELECT views FROM vt_engagement WHERE quarter = 'Q2 2022' AND category = 'attractions') as Q2_views, (SELECT views FROM vt_engagement WHERE quarter = 'Q1 2022' AND category = 'attractions') as Q1_views) as subquery;
gretelai_synthetic_text_to_sql
CREATE SCHEMA humanitarian_assistance;CREATE TABLE un_assistance (assistance_amount INT, year INT, organization VARCHAR(50));INSERT INTO un_assistance (assistance_amount, year, organization) VALUES (1000000, 2015, 'UN'), (1500000, 2016, 'UN'), (2000000, 2017, 'UN'), (1200000, 2018, 'UN'), (1800000, 2019, 'UN'), (2500000, 2020, 'UN');
What is the maximum amount of humanitarian assistance provided by the UN in a single year?
SELECT MAX(assistance_amount) FROM humanitarian_assistance.un_assistance;
gretelai_synthetic_text_to_sql
CREATE TABLE Vehicles (id INT, make VARCHAR(50), model VARCHAR(50), range FLOAT, type VARCHAR(50)); INSERT INTO Vehicles (id, make, model, range, type) VALUES (1, 'Tesla', 'Model S', 373, 'Electric');
What is the maximum range of electric vehicles available on the market?
SELECT MAX(range) FROM Vehicles WHERE type = 'Electric';
gretelai_synthetic_text_to_sql
CREATE TABLE ExcavationRecords (RecordID INT, SiteID INT, Date DATE); INSERT INTO ExcavationRecords (RecordID, SiteID, Date) VALUES (1, 1, '2005-01-01'), (2, 2, '2009-06-12'), (3, 3, '2011-09-28'), (4, 2, '2010-01-01');
Delete any excavation records from site 2?
DELETE FROM ExcavationRecords WHERE SiteID = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (id INT, name VARCHAR(100), region VARCHAR(50), assets_value FLOAT); INSERT INTO customers (id, name, region, assets_value) VALUES (1, 'Min Joon Kim', 'Asia Pacific', 500000.00);
Update the assets value of all customers from 'Asia Pacific' region by 1.05.
UPDATE customers SET assets_value = assets_value * 1.05 WHERE region = 'Asia Pacific';
gretelai_synthetic_text_to_sql
CREATE TABLE protected_habitats (habitat_id INT, habitat_name VARCHAR(50), species VARCHAR(50), cross_border_collaboration BOOLEAN);
Find all the habitats and the number of animal species in the 'protected_habitats' table that require cross-border collaboration?
SELECT habitat_name, COUNT(DISTINCT species) as num_species FROM protected_habitats WHERE cross_border_collaboration = TRUE GROUP BY habitat_name;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_life_research (id INT, country TEXT, region TEXT);INSERT INTO marine_life_research (id, country, region) VALUES (1, 'India', 'Indian'), (2, 'Indonesia', 'Indian'), (3, 'Australia', 'Pacific');
How many countries are involved in marine life research in the 'Indian' ocean?
SELECT COUNT(DISTINCT country) FROM marine_life_research WHERE region = 'Indian';
gretelai_synthetic_text_to_sql
CREATE TABLE CulturalEvents (id INT, year INT, event_type VARCHAR(20)); INSERT INTO CulturalEvents (id, year, event_type) VALUES (1, 2017, 'Music'), (2, 2018, 'Theater'), (3, 2019, 'Dance'), (4, 2020, 'Exhibition');
What is the total number of events organized by the cultural center in the years 2019 and 2020?
SELECT COUNT(*) FROM CulturalEvents WHERE year IN (2019, 2020);
gretelai_synthetic_text_to_sql
CREATE TABLE IF NOT EXISTS players (id INT, name VARCHAR(50), age INT, team VARCHAR(50), league VARCHAR(50));
What is the average age of football players in the Premier League who participated in the 2022 World Cup?
SELECT AVG(age) FROM players WHERE team IN (SELECT name FROM teams WHERE league = 'Premier League') AND name IN (SELECT team FROM games WHERE tournament = '2022 World Cup');
gretelai_synthetic_text_to_sql
CREATE TABLE Students (StudentID int, Department varchar(50)); INSERT INTO Students (StudentID, Department) VALUES (1, 'Computer Science'); INSERT INTO Students (StudentID, Department) VALUES (2, 'Electrical Engineering'); CREATE TABLE Grants (GrantID int, StudentID int); INSERT INTO Grants (GrantID, StudentID) VALUES (1, 1); INSERT INTO Grants (GrantID, StudentID) VALUES (2, 2);
Show the total number of research grants awarded to graduate students in the 'Computer Science' department.
SELECT COUNT(*) FROM Students INNER JOIN Grants ON Students.StudentID = Grants.StudentID WHERE Students.Department = 'Computer Science';
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tours (tour_id INT, hotel_id INT, country TEXT, user_engagement FLOAT);
List the bottom 2 countries with the lowest virtual tour engagement
SELECT country, SUM(user_engagement) as total_engagement FROM virtual_tours GROUP BY country ORDER BY total_engagement ASC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE union_members (member_id INT, name VARCHAR(50), state VARCHAR(2), membership_status VARCHAR(10)); INSERT INTO union_members (member_id, name, state, membership_status) VALUES (1, 'John Smith', 'IL', 'active'); INSERT INTO union_members (member_id, name, state, membership_status) VALUES (2, 'Jane Doe', 'IL', 'inactive'); INSERT INTO union_members (member_id, name, state, membership_status) VALUES (3, 'Mike Johnson', 'WI', 'active');
Delete records from the "union_members" table where the "state" column is "IL" and the "membership_status" column is "inactive"
DELETE FROM union_members WHERE state = 'IL' AND membership_status = 'inactive';
gretelai_synthetic_text_to_sql
CREATE TABLE sales (sale_id INT, product_id INT, price DECIMAL(5,2)); CREATE TABLE products (product_id INT, product_name VARCHAR(50), category_id INT, manufacturing_date DATE); CREATE TABLE product_categories (category_id INT, category_name VARCHAR(50)); INSERT INTO product_categories (category_id, category_name) VALUES (1, 'Clothing'), (2, 'Footwear');
Insert a new product, 'Organic Cotton Shirt', into the products table with a price of 60.00 in the sales table and a manufacturing_date of '2021-09-01' in the products table. The new product should belong to the 'Clothing' category in the product_categories table.
INSERT INTO products (product_id, product_name, category_id, manufacturing_date) VALUES (4, 'Organic Cotton Shirt', 1, '2021-09-01'); INSERT INTO sales (sale_id, product_id, price) VALUES (4, 4, 60.00);
gretelai_synthetic_text_to_sql
CREATE SCHEMA trans schemas.trans; CREATE TABLE max_daily_bus_fares (bus_number INT, fare FLOAT, fare_date DATE); INSERT INTO max_daily_bus_fares (bus_number, fare, fare_date) VALUES (2101, 15.50, '2021-03-01'), (2101, 16.25, '2021-03-02'), (2101, 14.75, '2021-03-03'), (2101, 17.00, '2021-03-04'), (2101, 18.50, '2021-03-05'), (2102, 19.25, '2021-03-01'), (2102, 20.00, '2021-03-02'), (2102, 22.00, '2021-03-03'), (2102, 21.50, '2021-03-04'), (2102, 23.00, '2021-03-05');
What was the maximum daily fare collection for each bus number in the first week of March 2021?
SELECT bus_number, MAX(fare) OVER (PARTITION BY bus_number) FROM max_daily_bus_fares WHERE fare_date BETWEEN '2021-03-01' AND '2021-03-05';
gretelai_synthetic_text_to_sql
CREATE TABLE Suppliers (SupplierID INT, CompanyName VARCHAR(50), Country VARCHAR(20), Organic BOOLEAN); INSERT INTO Suppliers VALUES (1, 'Supplier1', 'Brazil', true); INSERT INTO Suppliers VALUES (2, 'Supplier2', 'USA', false); CREATE TABLE Restaurants (RestaurantID INT, SupplierID INT); INSERT INTO Restaurants VALUES (1, 1); INSERT INTO Restaurants VALUES (2, 2);
List all suppliers from Brazil who supply organic products to our restaurants.
SELECT Suppliers.CompanyName FROM Suppliers INNER JOIN Restaurants ON Suppliers.SupplierID = Restaurants.SupplierID WHERE Suppliers.Country = 'Brazil' AND Suppliers.Organic = true;
gretelai_synthetic_text_to_sql
CREATE TABLE CERTIFICATION (id INT PRIMARY KEY, name TEXT); INSERT INTO CERTIFICATION (id, name) VALUES (1, 'GOTS'), (2, 'Fair Trade'), (3, 'BlueSign');
Add a new sustainable fabric certification named "OEKO-TEX".
INSERT INTO CERTIFICATION (name) VALUES ('OEKO-TEX');
gretelai_synthetic_text_to_sql
CREATE TABLE donations (donation_id INT, donor_name VARCHAR(50), donation_amount DECIMAL(10,2), donation_date DATE);
What was the total donation amount for the year 2020?
SELECT SUM(donation_amount) FROM donations WHERE YEAR(donation_date) = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE startup (id INT, name TEXT, industry TEXT, founder_gender TEXT, funding_amount INT); INSERT INTO startup (id, name, industry, founder_gender, funding_amount) VALUES (1, 'Mu Inc', 'Tech', 'Female', 5000000); INSERT INTO startup (id, name, industry, founder_gender, funding_amount) VALUES (2, 'Nu Corp', 'Tech', 'Female', 2500000); INSERT INTO startup (id, name, industry, founder_gender, funding_amount) VALUES (3, 'Xi Ltd', 'Healthcare', 'Male', 1000000);
What is the median funding amount for startups in the Tech industry that have a female founder?
SELECT AVG(s.funding_amount) AS median_funding_amount FROM startup s WHERE s.industry = 'Tech' AND s.founder_gender = 'Female' ORDER BY s.funding_amount LIMIT 2 OFFSET 1;
gretelai_synthetic_text_to_sql
CREATE TABLE spacecraft_manufacturing (id INT, manufacturer VARCHAR(20), mass FLOAT);INSERT INTO spacecraft_manufacturing (id, manufacturer, mass) VALUES (1, 'AstroCorp', 12000.0), (2, 'SpaceTech', 15000.0);
What is the total mass of spacecraft manufactured by 'AstroCorp'?
SELECT SUM(mass) FROM spacecraft_manufacturing WHERE manufacturer = 'AstroCorp';
gretelai_synthetic_text_to_sql
CREATE TABLE broadband_speeds (location VARCHAR(20), speed FLOAT); INSERT INTO broadband_speeds (location, speed) VALUES ('Brazil', 200.4); INSERT INTO broadband_speeds (location, speed) VALUES ('Argentina', 250.6);
What is the maximum broadband speed in South America?
SELECT MAX(speed) FROM broadband_speeds WHERE location LIKE 'South%';
gretelai_synthetic_text_to_sql
CREATE TABLE pollution_levels (location TEXT, pollution_level INTEGER); INSERT INTO pollution_levels (location, pollution_level) VALUES ('Gulf of Mexico', 5000), ('Sargasso Sea', 6000), ('Arctic Ocean', 3000), ('Atlantic Ocean', 2000);
What is the pollution_level of the 'Arctic Ocean' in the pollution_levels table?
SELECT pollution_level FROM pollution_levels WHERE location = 'Arctic Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE policy (policy_id INT, policy_type VARCHAR(20), effective_date DATE); INSERT INTO policy VALUES (1, 'Personal Auto', '2018-01-01'); INSERT INTO policy VALUES (2, 'Personal Auto', '2020-01-01');
Show all policy records for policy type 'Personal Auto' as separate columns for policy ID, effective date, and a column for each policy type value
SELECT policy_id, effective_date, MAX(CASE WHEN policy_type = 'Personal Auto' THEN policy_type END) AS Personal_Auto, MAX(CASE WHEN policy_type = 'Commercial Auto' THEN policy_type END) AS Commercial_Auto FROM policy GROUP BY policy_id, effective_date;
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (id INT, department VARCHAR(20), amount FLOAT); INSERT INTO Donations (id, department, amount) VALUES (1, 'Animals', 500.00), (2, 'Education', 300.00);
What is the maximum donation amount in the 'Donations' table?
SELECT MAX(amount) FROM Donations
gretelai_synthetic_text_to_sql
CREATE TABLE fish_farms (id INT, name VARCHAR(255)); INSERT INTO fish_farms (id, name) VALUES (1, 'Farm A'), (2, 'Farm B'), (3, 'Farm C'); CREATE TABLE fish_inventory (id INT, farm_id INT, species_id INT, biomass FLOAT); INSERT INTO fish_inventory (id, farm_id, species_id, biomass) VALUES (1, 1, 1, 1000), (2, 1, 2, 800), (3, 2, 1, 1200), (4, 3, 2, 900);
What is the total biomass of fish in each farm in the past year?
SELECT f.name, SUM(fi.biomass) as total_biomass FROM fish_inventory fi JOIN fish_farms f ON fi.farm_id = f.id WHERE fi.date >= DATEADD(year, -1, GETDATE()) GROUP BY f.name;
gretelai_synthetic_text_to_sql
CREATE TABLE attractions (id INT PRIMARY KEY, name VARCHAR(255), description TEXT, category VARCHAR(255), city VARCHAR(255), country VARCHAR(255));
Delete records in the attractions table where the city is 'Rio de Janeiro'
DELETE FROM attractions WHERE city = 'Rio de Janeiro';
gretelai_synthetic_text_to_sql
CREATE TABLE Factories (id INT, industry VARCHAR(255), name VARCHAR(255), num_accidents INT); INSERT INTO Factories (id, industry, name, num_accidents) VALUES (1, 'Renewable Energy', 'XYZ Renewable Energy', 5), (2, 'Renewable Energy', 'LMN Renewable Energy', 3), (3, 'Automotive', 'ABC Automotive', 2);
What is the number of accidents reported by each factory in the renewable energy industry?
SELECT name, num_accidents FROM Factories WHERE industry = 'Renewable Energy';
gretelai_synthetic_text_to_sql
CREATE TABLE fish_inventory (id INT, farm_location VARCHAR(255), num_fish INT, biomass FLOAT); INSERT INTO fish_inventory (id, farm_location, num_fish, biomass) VALUES (1, 'Location1', 1000, 12000.0), (2, 'Location1', 1200, 15000.0), (3, 'Location2', 800, 9000.0), (4, 'Location2', 700, 7000.0), (5, 'Location3', 1500, 18000.0);
What is the total number of fish in the 'fish_inventory' table, grouped by farm location, having a total biomass above the average for all locations?
SELECT farm_location, COUNT(*) FROM fish_inventory GROUP BY farm_location HAVING AVG(biomass) < (SELECT AVG(biomass) FROM fish_inventory);
gretelai_synthetic_text_to_sql
CREATE TABLE purchases (id INT, player_id INT, purchase_date DATE); INSERT INTO purchases (id, player_id, purchase_date) VALUES (1, 1, '2022-01-01'), (2, 2, '2022-02-01'), (3, 1, '2021-01-01');
Remove all the records from the purchases table?
TRUNCATE purchases;
gretelai_synthetic_text_to_sql
CREATE TABLE schools (school_id INT, school_name VARCHAR(50)); INSERT INTO schools (school_id, school_name) VALUES (1, 'Lincoln High'), (2, 'Washington High'), (3, 'Freedom Middle'); CREATE TABLE students (student_id INT, student_name VARCHAR(50), school_id INT, mental_health_score INT); INSERT INTO students (student_id, student_name, school_id, mental_health_score) VALUES (1, 'John Doe', 1, 75), (2, 'Jane Doe', 1, 80), (3, 'Mike Johnson', 2, 85), (4, 'Sara Connor', 3, 70);
Calculate the average mental health score for students in each school?
SELECT s.school_id, AVG(s.mental_health_score) as avg_mental_health_score FROM students s GROUP BY s.school_id;
gretelai_synthetic_text_to_sql
CREATE TABLE project_costs (project_id INT, project_name VARCHAR(255), cost DECIMAL(10,2), start_date DATE); INSERT INTO project_costs (project_id, project_name, cost, start_date) VALUES (1, 'Sample Project 1', 500000, '2020-01-01'), (2, 'Sample Project 2', 750000, '2019-08-15');
What is the total construction cost for each type of construction project?
SELECT project_type, SUM(cost) as total_cost FROM (SELECT id, name as project_name, cost, 'Residential' as project_type FROM project_costs WHERE name LIKE '%Residential%' UNION ALL SELECT id, name as project_name, cost, 'Commercial' as project_type FROM project_costs WHERE name LIKE '%Commercial%') as subquery GROUP BY project_type;
gretelai_synthetic_text_to_sql
CREATE TABLE Policyholders (PolicyID INT, PolicyholderName TEXT, State TEXT); INSERT INTO Policyholders (PolicyID, PolicyholderName, State) VALUES (1, 'John Smith', 'HI'), (2, 'Jane Doe', 'NY'); CREATE TABLE Claims (ClaimID INT, PolicyID INT, ClaimAmount INT); INSERT INTO Claims (ClaimID, PolicyID, ClaimAmount) VALUES (1, 1, 5000), (2, 1, 3000), (3, 2, 7000);
Find the minimum claim amount for policyholders in 'HI'.
SELECT MIN(Claims.ClaimAmount) FROM Claims INNER JOIN Policyholders ON Claims.PolicyID = Policyholders.PolicyID WHERE Policyholders.State = 'HI';
gretelai_synthetic_text_to_sql
CREATE TABLE donations (donation_id INT, donation_amount DECIMAL(10,2), donation_date DATE); INSERT INTO donations (donation_id, donation_amount, donation_date) VALUES (1, 200, '2020-01-01'), (2, 300, '2020-02-05'), (3, 150, '2020-03-15');
What is the average amount donated per month in 2020?
SELECT AVG(donation_amount) FROM donations WHERE YEAR(donation_date) = 2020 GROUP BY MONTH(donation_date);
gretelai_synthetic_text_to_sql
CREATE TABLE property_taxes (property_id INT, tax_year INT, tax_amount FLOAT);
Delete records in the 'property_taxes' table where the 'tax_year' is earlier than 2010
DELETE FROM property_taxes WHERE tax_year < 2010;
gretelai_synthetic_text_to_sql
CREATE TABLE autoshow (vehicle_type VARCHAR(10), top_speed INT);
What is the average speed of electric vehicles in the 'autoshow' table?
SELECT AVG(top_speed) AS avg_speed FROM autoshow WHERE vehicle_type = 'Electric';
gretelai_synthetic_text_to_sql
CREATE TABLE rural_budget (id INT, year INT, budget INT); INSERT INTO rural_budget (id, year, budget) VALUES (1, 2021, 100000), (2, 2022, 120000);
What is the total budget for healthcare in the "rural_budget" table?
SELECT SUM(budget) FROM rural_budget;
gretelai_synthetic_text_to_sql
CREATE TABLE campaigns (id INT, name TEXT, target_gender TEXT, start_date DATETIME, end_date DATETIME, ad_spend DECIMAL(10,2));
What is the total ad spend for campaigns with a 'gender' target of 'non-binary', for the current quarter?
SELECT SUM(ad_spend) FROM campaigns WHERE target_gender = 'non-binary' AND start_date <= NOW() AND end_date >= DATE_SUB(DATE_FORMAT(NOW(), '%Y-%m-01'), INTERVAL 3 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE if NOT EXISTS animal_population (animal_id INT, animal_name VARCHAR(50), conservation_status VARCHAR(20)); INSERT INTO animal_population (animal_id, animal_name, conservation_status) VALUES (1, 'Giant Panda', 'Vulnerable'); INSERT INTO animal_population (animal_id, animal_name, conservation_status) VALUES (2, 'Tiger', 'Endangered'); INSERT INTO animal_population (animal_id, animal_name, conservation_status) VALUES (3, 'Elephant', 'Vulnerable');
What are the total number of animals in the animal_population table grouped by their conservation status?
SELECT conservation_status, COUNT(*) FROM animal_population GROUP BY conservation_status;
gretelai_synthetic_text_to_sql
CREATE TABLE skincare_sales (id INT, product VARCHAR(50), revenue DECIMAL(10,2), country VARCHAR(50)); INSERT INTO skincare_sales (id, product, revenue, country) VALUES (1, 'Organic Facial Cleanser', 500.00, 'USA');
What is the total revenue for organic skincare products in the USA?
SELECT SUM(revenue) FROM skincare_sales WHERE product LIKE '%Organic%' AND country = 'USA';
gretelai_synthetic_text_to_sql
CREATE SCHEMA wind; CREATE TABLE wind_plants (id INT, location VARCHAR(50), capacity FLOAT, price FLOAT); INSERT INTO wind_plants (id, location, capacity, price) VALUES (1, 'Wind Farm 1', 75.2, 0.10), (2, 'Wind Farm 2', 60.0, 0.12), (3, 'Wind Farm 3', 80.0, 0.11), (4, 'Wind Farm 4', 45.0, 0.13), (5, 'Wind Farm 5', 90.0, 0.10);
What is the minimum price per kWh of electricity from wind energy sources located in the 'wind' schema, for installations with a capacity greater than or equal to 50 MW?
SELECT MIN(price) as min_price FROM wind.wind_plants WHERE capacity >= 50;
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_floor_mapping (station_id INT, trench_name TEXT, mean_depth REAL); INSERT INTO ocean_floor_mapping (station_id, trench_name, mean_depth) VALUES (1, 'Puerto Rico Trench', 8376);
Update the mean depth of the ocean floor in the Puerto Rico Trench to 8605 meters.
UPDATE ocean_floor_mapping SET mean_depth = 8605 WHERE trench_name = 'Puerto Rico Trench';
gretelai_synthetic_text_to_sql
CREATE TABLE vessel (id INT PRIMARY KEY, name VARCHAR(255), type VARCHAR(255), length FLOAT, year_built INT);
Create a table for storing vessel information
CREATE TABLE vessel_new AS SELECT * FROM vessel WHERE 1=2;
gretelai_synthetic_text_to_sql
CREATE TABLE green_influencers(id INT, post_text TEXT, likes INT, date DATE);
What is the average number of likes on posts containing the hashtag #sustainability in the 'green_influencers' table?
SELECT AVG(likes) FROM green_influencers WHERE post_text LIKE '%#sustainability%';
gretelai_synthetic_text_to_sql
CREATE TABLE farmers (id INT, name VARCHAR(50), age INT, organic BOOLEAN); INSERT INTO farmers (id, name, age, organic) VALUES (1, 'James Brown', 45, true); INSERT INTO farmers (id, name, age, organic) VALUES (2, 'Sara Johnson', 50, false); INSERT INTO farmers (id, name, age, organic) VALUES (3, 'Maria Garcia', 55, true);
What is the average age of farmers who grow organic crops?
SELECT AVG(age) as avg_age FROM farmers WHERE organic = true;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name TEXT, is_vegan BOOLEAN, source_country TEXT); CREATE TABLE safety_records (record_id INT, product_id INT, violation_date DATE);
Select vegan products that are sourced from Africa and have a safety violation in the past year.
SELECT products.product_name FROM products INNER JOIN safety_records ON products.product_id = safety_records.product_id WHERE products.is_vegan = TRUE AND products.source_country LIKE 'Africa%' AND safety_records.violation_date >= NOW() - INTERVAL '1 year';
gretelai_synthetic_text_to_sql
CREATE TABLE performance_scores (id INT, region VARCHAR(5), date DATE, score INT); INSERT INTO performance_scores VALUES (1, 'NA', '2021-09-01', 85), (2, 'ASIA', '2021-09-03', 90), (3, 'NA', '2021-09-05', 95);
What is the average warehouse management performance score in 'NA' region?
SELECT AVG(score) FROM performance_scores WHERE region = 'NA';
gretelai_synthetic_text_to_sql
CREATE TABLE training_programs (id INT PRIMARY KEY, program_name VARCHAR(255), location VARCHAR(255), start_date DATE, end_date DATE, capacity INT);
Insert data into 'training_programs' for a training program in New York City
INSERT INTO training_programs (id, program_name, location, start_date, end_date, capacity) VALUES (1, 'SQL Fundamentals', 'New York City', '2023-04-01', '2023-04-05', 50);
gretelai_synthetic_text_to_sql
CREATE TABLE visitors (visitor_id INT PRIMARY KEY, exhibition_id INT, age INT, country VARCHAR(255));
Add new records of visitors and their details
INSERT INTO visitors (visitor_id, exhibition_id, age, country) VALUES (1, 123, 25, 'United States'), (2, 123, 27, 'Canada'), (3, 123, 30, 'Mexico');
gretelai_synthetic_text_to_sql
CREATE TABLE financial_wellbeing_data_2 (customer_id INT, score INT, city VARCHAR(50)); INSERT INTO financial_wellbeing_data_2 (customer_id, score, city) VALUES (1, 70, 'New York'), (2, 80, 'London'), (3, 60, 'Tokyo'), (4, 90, 'Toronto'), (5, 75, 'Sydney'), (6, 65, 'Rio de Janeiro'); CREATE VIEW financial_wellbeing_view_2 AS SELECT city, SUM(score) as total_score FROM financial_wellbeing_data_2 GROUP BY city;
What is the total financial wellbeing score for customers in each city?
SELECT city, total_score FROM financial_wellbeing_view_2;
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tour_data (hotel_id INT, total_views INT, avg_rating FLOAT, total_time_spent INT);
Insert new virtual tour data into the 'virtual_tour_data' table for the hotel with ID 101.
INSERT INTO virtual_tour_data (hotel_id, total_views, avg_rating, total_time_spent) VALUES (101, 150, 4.6, 300);
gretelai_synthetic_text_to_sql
CREATE TABLE manufacturing_processes (process_id INT, name TEXT); CREATE TABLE waste_generation (process_id INT, waste_amount INT, date DATE);
What is the average amount of waste generated per manufacturing process per day in the past month?
SELECT manufacturing_processes.name, AVG(waste_generation.waste_amount/1000.0) FROM manufacturing_processes INNER JOIN waste_generation ON manufacturing_processes.process_id = waste_generation.process_id WHERE waste_generation.date > DATEADD(month, -1, GETDATE()) GROUP BY manufacturing_processes.name;
gretelai_synthetic_text_to_sql
CREATE TABLE events (id INT, name VARCHAR(255), date DATE, category VARCHAR(255), price FLOAT); INSERT INTO events (id, name, date, category, price) VALUES (1, 'Concert', '2022-06-01', 'Music', 50.00), (2, 'Play', '2022-07-01', 'Theater', 30.00), (3, 'Festival', '2022-08-01', 'Music', 75.00);
What is the total revenue for each category of events?
SELECT category, SUM(price) FROM events GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE faculty (id INT, name VARCHAR(50), department VARCHAR(50), position VARCHAR(20)); INSERT INTO faculty (id, name, department, position) VALUES (1, 'Ava Williams', 'Chemistry', 'Assistant Professor'), (2, 'Daniel Lee', 'Biology', 'Associate Professor');
Update the position of a faculty member in the faculty table.
UPDATE faculty SET position = 'Professor' WHERE name = 'Ava Williams';
gretelai_synthetic_text_to_sql
CREATE TABLE supplier_items (id INT, supplier_id INT, item_id INT, price DECIMAL(5,2)); INSERT INTO supplier_items (id, supplier_id, item_id, price) VALUES (1, 1, 1, 50.99), (2, 1, 2, 45.99), (3, 2, 3, 39.99); CREATE TABLE suppliers (id INT, name VARCHAR(50), country VARCHAR(50)); INSERT INTO suppliers (id, name, country) VALUES (1, 'Green Trade', 'India'), (2, 'EcoFriendly Co.', 'China'), (3, 'Sustainable Source', 'Brazil');
Who are the top 3 most expensive suppliers?
SELECT suppliers.name, MAX(supplier_items.price) AS max_price FROM supplier_items INNER JOIN suppliers ON supplier_items.supplier_id = suppliers.id GROUP BY suppliers.id ORDER BY max_price DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE farms (id INT, name TEXT, country TEXT, is_organic BOOLEAN); INSERT INTO farms (id, name, country, is_organic) VALUES (1, 'Blue Sky Farms', 'USA', true), (2, 'Green Valley Farms', 'Canada', false); CREATE TABLE crop_yield (farm_id INT, year INT, yield INT); INSERT INTO crop_yield (farm_id, year, yield) VALUES (1, 2020, 1200), (1, 2021, 1500), (2, 2020, 800), (2, 2021, 900);
What is the total crop yield for organic farms in the US?
SELECT SUM(yield) FROM crop_yield JOIN farms ON crop_yield.farm_id = farms.id WHERE farms.country = 'USA' AND farms.is_organic = true;
gretelai_synthetic_text_to_sql
CREATE TABLE players (id INT, name VARCHAR(50), age INT, preferred_genre VARCHAR(20)); INSERT INTO players (id, name, age, preferred_genre) VALUES (1, 'John Doe', 25, 'VR'); CREATE TABLE games (id INT, title VARCHAR(50), genre VARCHAR(20)); INSERT INTO games (id, title, genre) VALUES (1, 'Space Explorer', 'VR'), (2, 'Retro Racer', 'Classic'); CREATE TABLE gaming.players_games (player_id INT, game_id INT); CREATE VIEW vw_player_games AS SELECT players.id AS player_id, players.preferred_genre FROM players JOIN gaming.players_games ON players.id = gaming.players_games.player_id;
What's the average age of players who prefer VR games in the 'gaming' schema?
SELECT AVG(players.age) FROM players JOIN vw_player_games ON players.id = vw_player_games.player_id WHERE vw_player_games.preferred_genre = 'VR';
gretelai_synthetic_text_to_sql
CREATE TABLE wildlife_habitat(type VARCHAR(255), count INT); INSERT INTO wildlife_habitat(type, count) VALUES ('Forest', 300), ('Wetland', 200), ('Grassland', 150), ('Desert', 50);
What is the total number of wildlife habitats for each type?
SELECT type, SUM(count) FROM wildlife_habitat;
gretelai_synthetic_text_to_sql
CREATE TABLE RecyclingFacilities (country VARCHAR(255), num_facilities INT); INSERT INTO RecyclingFacilities (country, num_facilities) VALUES ('Australia', 521), ('New Zealand', 123);
How many recycling facilities are there in Australia and New Zealand?
SELECT SUM(num_facilities) FROM RecyclingFacilities WHERE country IN ('Australia', 'New Zealand')
gretelai_synthetic_text_to_sql
CREATE TABLE Fares(fare INT, journey_date DATE, mode_of_transport VARCHAR(20)); INSERT INTO Fares(fare, journey_date, mode_of_transport) VALUES (5, '2022-01-01', 'Bus'), (10, '2022-01-01', 'Tram'), (15, '2022-01-01', 'Subway');
What is the total fare collected for journeys starting on '2022-01-01'?
SELECT SUM(fare) FROM Fares WHERE journey_date = '2022-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE threat_intelligence (metric_id INT, agency VARCHAR(255), metric VARCHAR(255));INSERT INTO threat_intelligence (metric_id, agency, metric) VALUES (1, 'NSA', 'Cyber Attacks'), (2, 'CIA', 'Foreign Spy Activity'), (3, 'NSA', 'Insider Threats'), (4, 'FBI', 'Domestic Terrorism');
List the total number of threat intelligence metrics collected by each intelligence agency.
SELECT agency, COUNT(*) as total_metrics FROM threat_intelligence GROUP BY agency;
gretelai_synthetic_text_to_sql
CREATE TABLE intelligence_agency (id INT PRIMARY KEY, name VARCHAR(100), location VARCHAR(100), num_personnel INT); INSERT INTO intelligence_agency (id, name, location, num_personnel) VALUES (1, 'CIA', 'USA', 22000), (2, 'MI6', 'UK', 5000);
What is the total number of intelligence personnel in the 'intelligence_agency' table?
SELECT SUM(num_personnel) FROM intelligence_agency WHERE name = 'CIA';
gretelai_synthetic_text_to_sql
CREATE TABLE wastewater_treatment_plants (plant_id INT PRIMARY KEY, plant_name VARCHAR(100), water_flow_rate FLOAT, country VARCHAR(50));
List the names and water flow rates of all wastewater treatment plants in 'wastewater_treatment_plants' table
SELECT plant_name, water_flow_rate FROM wastewater_treatment_plants;
gretelai_synthetic_text_to_sql
CREATE TABLE incident_response (id INT, incident_date DATE, incident_category VARCHAR(50)); INSERT INTO incident_response (id, incident_date, incident_category) VALUES (1, '2022-02-01', 'Malware'), (2, '2022-03-15', 'Phishing'), (3, '2022-02-20', 'Malware'), (4, '2022-04-01', 'Phishing'), (5, '2022-01-10', 'DDoS');
How many security incidents were resolved in each quarter of the last year in the 'incident_response' table?
SELECT QUARTER(incident_date), COUNT(*) FROM incident_response WHERE incident_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY QUARTER(incident_date);
gretelai_synthetic_text_to_sql
CREATE TABLE Members (MemberID INT, Age INT, Gender VARCHAR(10), HasHeartRateMonitor BOOLEAN); INSERT INTO Members (MemberID, Age, Gender, HasHeartRateMonitor) VALUES (1, 35, 'Male', true), (2, 28, 'Female', false), (3, 42, 'Male', false);
What is the average heart rate for members who do not have a heart rate monitor?
SELECT AVG(HeartRate) FROM (SELECT MemberID, AVG(HeartRate) AS HeartRate FROM MemberWorkouts GROUP BY MemberID) AS Subquery WHERE Subquery.MemberID NOT IN (SELECT MemberID FROM Members WHERE HasHeartRateMonitor = true);
gretelai_synthetic_text_to_sql
CREATE TABLE public_transit (route_id INT, num_passengers INT, route_type VARCHAR(255), route_length FLOAT);
Update the 'num_passengers' column in the 'public_transit' table for the 'route_id' 33 to 40
UPDATE public_transit SET num_passengers = 40 WHERE route_id = 33;
gretelai_synthetic_text_to_sql
CREATE TABLE military_bases (id INT, name TEXT, location TEXT, country TEXT); INSERT INTO military_bases (id, name, location, country) VALUES (1, 'Fort Bragg', 'North Carolina', 'USA'), (2, 'Camp Mirage', 'Dubai', 'Canada');
What is the total number of military bases located in the United States and Canada?
SELECT COUNT(*) FROM military_bases WHERE country IN ('USA', 'Canada');
gretelai_synthetic_text_to_sql
CREATE TABLE threat_intelligence_new (id INT, feed_name VARCHAR(255), risk_score INT, date DATE); INSERT INTO threat_intelligence_new (id, feed_name, risk_score, date) VALUES (1, 'Feed C', 9, '2022-01-01'), (2, 'Feed D', 6, '2022-01-05'), (3, 'Feed C', 10, '2022-01-20');
What is the maximum risk score of any threat intelligence feed in the past week?
SELECT MAX(risk_score) FROM threat_intelligence_new WHERE date >= DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY);
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_energy (id INT, project VARCHAR(255), country VARCHAR(255), technology VARCHAR(255), capacity INT); INSERT INTO renewable_energy (id, project, country, technology, capacity) VALUES (2, 'Wind Farm', 'France', 'Wind', 6000);
What is the average capacity of renewable energy projects in France that use wind power?
SELECT AVG(capacity) as avg_capacity FROM renewable_energy WHERE country = 'France' AND technology = 'Wind';
gretelai_synthetic_text_to_sql
CREATE TABLE ota_sales (ota TEXT, country TEXT, revenue FLOAT); INSERT INTO ota_sales (ota, country, revenue) VALUES ('Expedia', 'China', 1000000), ('Booking.com', 'Japan', 1200000), ('Agoda', 'Thailand', 800000), ('MakeMyTrip', 'India', 1100000);
Which online travel agency (OTA) has the highest revenue in 'Asia'?
SELECT ota FROM ota_sales WHERE country = 'Asia' AND revenue = (SELECT MAX(revenue) FROM ota_sales WHERE country = 'Asia');
gretelai_synthetic_text_to_sql
CREATE TABLE Transport (id INT, vessel VARCHAR(255), source VARCHAR(255), destination VARCHAR(255), quantity INT, time DATETIME); INSERT INTO Transport (id, vessel, source, destination, quantity, time) VALUES (1, 'Asian Tide', 'Shanghai', 'Sydney', 120, '2019-07-14 11:00:00'), (2, 'Ocean Surf', 'Tokyo', 'Melbourne', 150, '2019-10-01 08:00:00');
What is the total quantity of containers transported by each vessel between Asian and Australian ports in Q3 2019?
SELECT vessel, SUM(quantity) FROM Transport T WHERE (source = 'Shanghai' OR source = 'Tokyo') AND (destination = 'Sydney' OR destination = 'Melbourne') AND time BETWEEN '2019-07-01' AND '2019-10-01' GROUP BY vessel;
gretelai_synthetic_text_to_sql
CREATE TABLE drug_approval (drug_name VARCHAR(50), country VARCHAR(50), approval_date DATE); INSERT INTO drug_approval (drug_name, country, approval_date) VALUES ('DrugA', 'USA', '2015-01-01'), ('DrugB', 'Canada', '2016-01-01'), ('DrugC', 'USA', '2017-01-01');
Which therapeutics have been approved in the USA since 2015?
SELECT drug_name FROM drug_approval WHERE country = 'USA' AND approval_date >= '2015-01-01' GROUP BY drug_name;
gretelai_synthetic_text_to_sql