context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE SCHEMA food_justice;CREATE TABLE organic_practices (id INT, practice VARCHAR(50), cost FLOAT);INSERT INTO food_justice.organic_practices (id, practice, cost) VALUES (1, 'Practice A', 150.5), (2, 'Practice B', 200.3), (3, 'Practice C', 250.0);
List all organic farming practices in descending order of their associated costs (in dollars) in the 'food_justice' schema?
SELECT practice, cost FROM food_justice.organic_practices ORDER BY cost DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE SHARIAH_COMPLIANT_LOANS (BANK_NAME VARCHAR(50), LOAN_TYPE VARCHAR(50), AMOUNT NUMBER(12,2)); INSERT INTO SHARIAH_COMPLIANT_LOANS VALUES ('Bank A', 'Shariah-compliant', 120000); INSERT INTO SHARIAH_COMPLIANT_LOANS VALUES ('Bank B', 'Shariah-compliant', 180000); INSERT INTO SHARIAH_COMPLIANT_LOANS VALUES ('B...
What is the total amount of Shariah-compliant loans issued by each bank, ordered by total issued amount?
SELECT BANK_NAME, SUM(AMOUNT) TOTAL_LOANS FROM SHARIAH_COMPLIANT_LOANS WHERE LOAN_TYPE = 'Shariah-compliant' GROUP BY BANK_NAME ORDER BY TOTAL_LOANS DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE autonomous_vehicle (id INT PRIMARY KEY, name VARCHAR(255), make VARCHAR(255), model_year INT, defect_status VARCHAR(255)); INSERT INTO autonomous_vehicle (id, name, make, model_year, defect_status) VALUES (1, 'Wayve Pod', 'Wayve', 2021, 'Yes'), (2, 'Nuro R2', 'Nuro', 2022, 'No'), (3, 'Zoox', 'Amazon', 2021...
Delete records of autonomous vehicles with manufacturing defects.
DELETE FROM autonomous_vehicle WHERE defect_status = 'Yes';
gretelai_synthetic_text_to_sql
CREATE TABLE ArtExhibitions (id INT, event_name VARCHAR(50), attendance INT); CREATE TABLE CulturalFestivals (id INT, event_name VARCHAR(50), attendance INT);
List all events with an attendance of over 500 people from the 'ArtExhibitions' and 'CulturalFestivals' tables.
SELECT event_name FROM ArtExhibitions WHERE attendance > 500 UNION SELECT event_name FROM CulturalFestivals WHERE attendance > 500;
gretelai_synthetic_text_to_sql
CREATE TABLE Cultivators (CultivatorID INT, CultivatorName VARCHAR(255)); CREATE TABLE Compliance (ComplianceID INT, CultivatorID INT, ComplianceMonth DATE); INSERT INTO Cultivators (CultivatorID, CultivatorName) VALUES (1, 'Happy Hemp Farms'); INSERT INTO Cultivators (CultivatorID, CultivatorName) VALUES (2, 'Kushy Ka...
Identify cultivators who have been compliant with regulations in the past year, ordered by the number of compliant months in descending order.
SELECT CultivatorName, COUNT(DISTINCT YEAR(ComplianceMonth) * 100 + MONTH(ComplianceMonth)) AS CompliantMonths FROM Cultivators JOIN Compliance ON Cultivators.CultivatorID = Compliance.CultivatorID WHERE ComplianceMonth >= DATEADD(MONTH, -12, GETDATE()) GROUP BY CultivatorName ORDER BY CompliantMonths DESC;
gretelai_synthetic_text_to_sql
CREATE SCHEMA Government;CREATE TABLE Government.Agency (name VARCHAR(255), budget INT);CREATE TABLE Government.Department (name VARCHAR(255), agency VARCHAR(255), employees INT, budget INT);
What is the average number of employees in each department in the 'Health' agency?
SELECT agency, AVG(employees) FROM Government.Department WHERE agency IN (SELECT name FROM Government.Agency WHERE budget > 3000000) GROUP BY agency;
gretelai_synthetic_text_to_sql
CREATE TABLE bus_stops (stop_id INT, stop_name VARCHAR(255)); CREATE TABLE bus_stop_visits (visit_id INT, stop_id INT, visit_date DATE);
What are the top 5 most frequently used bus stops?
SELECT bs.stop_name, COUNT(bsv.visit_id) as num_visits FROM bus_stops bs INNER JOIN bus_stop_visits bsv ON bs.stop_id = bsv.stop_id GROUP BY bs.stop_name ORDER BY num_visits DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE MarineLife (id INT, name VARCHAR(50), species VARCHAR(50), population INT); INSERT INTO MarineLife (id, name, species, population) VALUES (1, 'Sea Dragon', 1500), (2, 'Blue Whale', 2000), (3, 'Clownfish', 500), (4, 'Giant Pacific Octopus', 3000);
What is the maximum population of any marine species in the 'MarineLife' table, and what is the name of the species?
SELECT species, population FROM MarineLife WHERE population = (SELECT MAX(population) FROM MarineLife);
gretelai_synthetic_text_to_sql
CREATE TABLE supplier_data (supplier_id INT, location_id INT, item_id INT, quantity_sold INT, is_local BOOLEAN); INSERT INTO supplier_data (supplier_id, location_id, item_id, quantity_sold, is_local) VALUES (1, 1, 1, 30, TRUE), (2, 2, 2, 70, FALSE);
What is the total quantity of locally sourced items sold?
SELECT SUM(quantity_sold) FROM supplier_data WHERE is_local = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE space_missions (id INT, name VARCHAR(255), status VARCHAR(255), launch_date DATE);
How many space missions have been cancelled before launch?
SELECT COUNT(*) FROM space_missions WHERE status = 'cancelled';
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', 45);
Delete the record with ID 1 from the prison table.
DELETE FROM prison WHERE id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE digital_assets (asset_id INT, asset_name VARCHAR(50), value DECIMAL(10,2)); INSERT INTO digital_assets (asset_id, asset_name, value) VALUES (1, 'Asset1', 50.5), (2, 'Asset2', 100.2), (3, 'Asset3', 75.0); CREATE TABLE smart_contracts (contract_id INT, asset_id INT, contract_name VARCHAR(50)); INSERT INTO sm...
Find the average value of digital assets with smart contracts having the word 'agreement' in their name?
SELECT AVG(digital_assets.value) FROM digital_assets INNER JOIN smart_contracts ON digital_assets.asset_id = smart_contracts.asset_id WHERE smart_contracts.contract_name LIKE '%agreement%';
gretelai_synthetic_text_to_sql
CREATE TABLE education_programs (id INT, name VARCHAR(50), description TEXT, target_audience VARCHAR(50), duration INT);
Insert a new 'education' record into the 'education_programs' table
INSERT INTO education_programs (id, name, description, target_audience, duration) VALUES (1, 'Wildlife Warriors', 'A program to educate children about wildlife conservation.', 'Children (Ages 8-12)', 12);
gretelai_synthetic_text_to_sql
CREATE TABLE HealthcareExpenditures (ExpenditureID INT, Race VARCHAR(25), Expenditure DECIMAL(10,2)); INSERT INTO HealthcareExpenditures (ExpenditureID, Race, Expenditure) VALUES (1, 'Hispanic', 5000), (2, 'African American', 6000), (3, 'Asian', 7000), (4, 'Caucasian', 8000);
What is the total healthcare expenditure for each racial group?
SELECT Race, SUM(Expenditure) as TotalExpenditure FROM HealthcareExpenditures GROUP BY Race;
gretelai_synthetic_text_to_sql
CREATE TABLE buildings_rural (id INT, building_type VARCHAR(255), area VARCHAR(255), energy_efficiency_score FLOAT); INSERT INTO buildings_rural (id, building_type, area, energy_efficiency_score) VALUES (1, 'Residential', 'Rural', 75.0), (2, 'Commercial', 'Rural', 55.0);
What is the minimum energy efficiency score for commercial buildings in 'Rural' areas?
SELECT MIN(energy_efficiency_score) FROM buildings_rural WHERE building_type = 'Commercial' AND area = 'Rural';
gretelai_synthetic_text_to_sql
CREATE TABLE news_channels (channel_name VARCHAR(50), country VARCHAR(50)); INSERT INTO news_channels (channel_name, country) VALUES ('CNN', 'USA'); INSERT INTO news_channels (channel_name, country) VALUES ('BBC', 'UK');
Which countries have the most news channels in the 'news_channels' table?
SELECT country, COUNT(*) as channel_count FROM news_channels GROUP BY country ORDER BY channel_count DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE ipl_players (player_id INT, player_name VARCHAR(50), country VARCHAR(50), birth_year INT);
Which Indian cricketers in the 'ipl_players' table were born before 1990?
SELECT player_name FROM ipl_players WHERE country = 'India' AND birth_year < 1990;
gretelai_synthetic_text_to_sql
CREATE TABLE circular_supply_chain (product_id INT, source VARCHAR(255), quantity INT);CREATE TABLE ethical_suppliers (supplier_id INT, name VARCHAR(255), country VARCHAR(255), fair_trade BOOLEAN);
What is the total quantity of products in the 'circular_supply_chain' table that are sourced from fair trade suppliers in the 'ethical_suppliers' table?
SELECT SUM(quantity) FROM circular_supply_chain c JOIN ethical_suppliers e ON c.source = e.name WHERE e.fair_trade = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE regulations (id INT, proposal TEXT, comments INT); INSERT INTO regulations (id, proposal, comments) VALUES (1, 'Regulation A', 50); INSERT INTO regulations (id, proposal, comments) VALUES (2, 'Regulation B', 100);
What is the maximum number of public comments received for a proposed regulation?
SELECT MAX(comments) FROM regulations;
gretelai_synthetic_text_to_sql
CREATE TABLE union_membership (id INT, union_name TEXT, state TEXT, gender TEXT); INSERT INTO union_membership (id, union_name, state, gender) VALUES (1, 'Union A', 'California', 'Male'), (2, 'Union B', 'California', 'Female'), (3, 'Union C', 'California', 'Male');
What is the total number of male and female members in unions located in California?
SELECT SUM(gender = 'Male') AS total_male, SUM(gender = 'Female') AS total_female FROM union_membership WHERE state = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE FarmC (species VARCHAR(20), country VARCHAR(20), biomass FLOAT, farming_method VARCHAR(20)); INSERT INTO FarmC (species, country, biomass, farming_method) VALUES ('Salmon', 'Norway', 30000, 'Organic'); INSERT INTO FarmC (species, country, biomass, farming_method) VALUES ('Trout', 'Norway', 15000, 'Conventi...
Find the total biomass of fish farmed in each country using organic methods.
SELECT country, SUM(biomass) FROM FarmC WHERE farming_method = 'Organic' GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE public_transportation_2 (system_id INT, system_name VARCHAR(255), ridership INT, year INT);
Identify public transportation systems that have a decrease in ridership by more than 20% since 2020
SELECT system_name, ridership, year FROM public_transportation_2 WHERE year > 2020 AND ridership < 0.8 * (SELECT ridership FROM public_transportation_2 WHERE system_id = system_id AND year = 2020);
gretelai_synthetic_text_to_sql
CREATE TABLE providers (id INT, name VARCHAR, specialty VARCHAR, location VARCHAR);
Find the number of healthcare providers, by specialty and location.
SELECT p.specialty, p.location, COUNT(p.id) AS num_providers FROM providers p GROUP BY p.specialty, p.location;
gretelai_synthetic_text_to_sql
CREATE TABLE DonorPrograms (DonorID INT, ProgramID INT); INSERT INTO DonorPrograms (DonorID, ProgramID) VALUES (1, 101), (1, 102), (2, 102), (3, 103), (3, 104); CREATE TABLE ProgramCategories (CategoryID INT, Category TEXT); INSERT INTO ProgramCategories (CategoryID, Category) VALUES (1, 'Education'), (2, 'Health'), (3...
Display the number of volunteers who have donated to each program category, and the total donation amount.
SELECT PC.Category, COUNT(DP.DonorID) AS NumVolunteers, SUM(D.Amount) AS TotalDonated FROM DonorPrograms DP INNER JOIN Donations D ON DP.DonorID = D.DonorID INNER JOIN Programs P ON DP.ProgramID = P.ProgramID INNER JOIN ProgramCategories PC ON P.CategoryID = PC.CategoryID GROUP BY PC.Category;
gretelai_synthetic_text_to_sql
CREATE TABLE construction_labor (state VARCHAR(2), year INT, wage DECIMAL(5,2)); INSERT INTO construction_labor VALUES ('NY', 2020, 35.50), ('CA', 2020, 32.65), ('TX', 2020, 28.34);
What are the average construction wages by state for the year 2020?
SELECT state, AVG(wage) FROM construction_labor WHERE year = 2020 GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE initiatives (id INT, name VARCHAR(50), year INT, budget INT); INSERT INTO initiatives (id, name, year, budget) VALUES (1, 'Clean Water', 2020, 120000), (2, 'Green Spaces', 2019, 80000);
Which community development initiatives were completed in 2020 and had a budget over $100,000?
SELECT name FROM initiatives WHERE year = 2020 AND budget > 100000;
gretelai_synthetic_text_to_sql
CREATE TABLE mining_sites (id INT, name VARCHAR(50)); CREATE TABLE equipment_usage (site_id INT, equipment_type VARCHAR(20), usage_count INT); INSERT INTO mining_sites (id, name) VALUES (1, 'Site A'), (2, 'Site B'), (3, 'Site C'), (4, 'Site D'); INSERT INTO equipment_usage (site_id, equipment_type, usage_count) VALUES ...
Find the mining sites that have used a specific type of equipment more than any other site.
SELECT ms.name, eu.equipment_type, eu.usage_count FROM mining_sites ms INNER JOIN equipment_usage eu ON ms.id = eu.site_id WHERE eu.usage_count = (SELECT MAX(usage_count) FROM equipment_usage);
gretelai_synthetic_text_to_sql
CREATE TABLE organizations (id INT, name VARCHAR(255), type VARCHAR(255), country VARCHAR(255), budget DECIMAL(10,2)); INSERT INTO organizations (id, name, type, country, budget) VALUES (1, 'Eco-France', 'NGO', 'France', 2000000.00);
What is the total funding spent by organizations based in France?
SELECT SUM(budget) as total_funding FROM organizations WHERE country = 'France';
gretelai_synthetic_text_to_sql
CREATE TABLE attorneys (attorney_id INT, attorney_name VARCHAR(20), office_id INT); INSERT INTO attorneys (attorney_id, attorney_name, office_id) VALUES (101, 'Smith', 1), (102, 'Johnson', 1), (103, 'Williams', 2); CREATE TABLE cases (case_id INT, client_id INT, attorney_id INT, office_id INT); INSERT INTO cases (case_...
List the number of unique clients represented by each attorney in the 'Chicago' office.
SELECT a.attorney_name, COUNT(DISTINCT c.client_id) FROM attorneys a JOIN cases c ON a.attorney_id = c.attorney_id JOIN offices o ON a.office_id = o.office_id WHERE o.office_name = 'Chicago' GROUP BY a.attorney_name;
gretelai_synthetic_text_to_sql
CREATE TABLE VRHardware (HardwareID INT, HardwareName VARCHAR(50), Manufacturer VARCHAR(20), ReleaseDate DATE, Price NUMERIC(10,2)); INSERT INTO VRHardware (HardwareID, HardwareName, Manufacturer, ReleaseDate, Price) VALUES (1, 'Oculus Rift', 'Oculus', '2016-03-28', 599); INSERT INTO VRHardware (HardwareID, HardwareNam...
What is the distribution of VR hardware products by price range, considering price ranges as: 0-500, 500-1000, and >1000, and their respective counts, ranked by count?
SELECT CASE WHEN Price <= 500 THEN '0-500' WHEN Price <= 1000 THEN '500-1000' ELSE '>1000' END as PriceRange, COUNT(*) as ProductsInRange, ROW_NUMBER() OVER (ORDER BY COUNT(*) DESC) as Rank FROM VRHardware GROUP BY PriceRange;
gretelai_synthetic_text_to_sql
CREATE TABLE seattle_community_policing (id INT, event_name VARCHAR(255), event_date TIMESTAMP, event_category VARCHAR(255));
Insert a new community policing event in the city of Seattle, category 'Youth Outreach' on May 15th, 2023.
INSERT INTO seattle_community_policing (id, event_name, event_date, event_category) VALUES (1, 'Youth Outreach Event', '2023-05-15 10:00:00', 'Youth Outreach');
gretelai_synthetic_text_to_sql
CREATE TABLE production (year INT, element TEXT, volume INT); INSERT INTO production (year, element, volume) VALUES (2021, 'neodymium', 15000), (2022, 'neodymium', 18000), (2021, 'dysprosium', 8000), (2022, 'dysprosium', 10000); CREATE TABLE elements (element TEXT); INSERT INTO elements (element) VALUES ('neodymium'), ...
Which rare earth elements were produced in higher volumes in 2022 compared to 2021?
SELECT e.element, p2.volume - p1.volume AS volume_difference FROM elements e JOIN production p1 ON e.element = p1.element AND p1.year = 2021 JOIN production p2 ON e.element = p2.element AND p2.year = 2022 WHERE p2.volume > p1.volume;
gretelai_synthetic_text_to_sql
CREATE TABLE smart_city_projects (id INT, name VARCHAR(50), location VARCHAR(50), adoption_rate FLOAT);
Find the smart city technology adoption project with the highest adoption rate
SELECT * FROM smart_city_projects WHERE adoption_rate = (SELECT MAX(adoption_rate) FROM smart_city_projects);
gretelai_synthetic_text_to_sql
CREATE TABLE community_health_workers (id INT, name TEXT, zip TEXT, consultations INT); INSERT INTO community_health_workers (id, name, zip, consultations) VALUES (1, 'John Doe', '43001', 25), (2, 'Jane Smith', '44101', 15); CREATE VIEW oh_workers AS SELECT * FROM community_health_workers WHERE zip BETWEEN '43001' AND ...
What is the ZIP code of the community health worker who conducted the least mental health parity consultations in Ohio?
SELECT zip FROM oh_workers WHERE consultations = (SELECT MIN(consultations) FROM oh_workers);
gretelai_synthetic_text_to_sql
CREATE TABLE sales_data (id INT, region TEXT, sales_channel TEXT, vehicle_type TEXT, fuel_type TEXT, year INT, quantity_sold INT); INSERT INTO sales_data (id, region, sales_channel, vehicle_type, fuel_type, year, quantity_sold) VALUES (1, 'Asia-Pacific', 'Online', 'Bus', 'Autonomous', 2022, 150), (2, 'Europe', 'Dealers...
How many autonomous buses were sold in the 'Asia-Pacific' region in the sales_data table for the year 2022?
SELECT region, fuel_type, SUM(quantity_sold) as total_autonomous_buses_sold FROM sales_data WHERE region = 'Asia-Pacific' AND vehicle_type = 'Bus' AND fuel_type = 'Autonomous' AND year = 2022 GROUP BY region, fuel_type;
gretelai_synthetic_text_to_sql
CREATE TABLE songs (id INT, title TEXT, release_date DATE, genre TEXT, artist_id INT, streams INT); INSERT INTO songs (id, title, release_date, genre, artist_id, streams) VALUES (1, 'Song1', '2022-01-01', 'Hip-Hop', 1, 100000); INSERT INTO songs (id, title, release_date, genre, artist_id, streams) VALUES (2, 'Song2', '...
Show the moving average of streams for the last 6 months for each artist.
SELECT artist_id, AVG(streams) OVER (PARTITION BY artist_id ORDER BY release_date ROWS BETWEEN 5 PRECEDING AND CURRENT ROW) AS moving_avg FROM songs WHERE release_date >= DATEADD(MONTH, -6, CURRENT_DATE);
gretelai_synthetic_text_to_sql
CREATE TABLE Patients (PatientID INT, Age INT, Gender VARCHAR(10), Ethnicity VARCHAR(50), ConditionID INT); CREATE TABLE MentalHealthConditions (ConditionID INT, Condition VARCHAR(50));
What is the distribution of patients by ethnicity and mental health condition?
SELECT MentalHealthConditions.Condition, Patients.Ethnicity, COUNT(Patients.PatientID) FROM Patients INNER JOIN MentalHealthConditions ON Patients.ConditionID = MentalHealthConditions.ConditionID GROUP BY MentalHealthConditions.Condition, Patients.Ethnicity;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, customer_name VARCHAR(255)); CREATE TABLE orders (order_id INT, customer_id INT, order_date DATE); INSERT INTO customers (customer_id, customer_name) VALUES (1, 'John Doe'), (2, 'Jane Smith'); INSERT INTO orders (order_id, customer_id, order_date) VALUES (1, 1, '2022-01-01'), (2...
Which customers have not placed an order in the last 6 months?
SELECT c.customer_name FROM customers c LEFT JOIN orders o ON c.customer_id = o.customer_id WHERE o.order_date < DATE_SUB(CURDATE(), INTERVAL 6 MONTH) IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE offenders (id INT, state TEXT, annual_income FLOAT, year INT); INSERT INTO offenders (id, state, annual_income, year) VALUES (1, 'California', 30000, 2021), (2, 'California', 45000, 2021), (3, 'Texas', 25000, 2021), (4, 'California', 60000, 2021);
What is the median income of offenders in the justice system in California in 2021?
SELECT AVG(annual_income) as median_income FROM (SELECT annual_income FROM offenders WHERE state = 'California' AND year = 2021 ORDER BY annual_income LIMIT 2 OFFSET 1) as subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE HealthEquityMetrics (ViolationID INT, ViolationType VARCHAR(255), Region VARCHAR(255), ViolationDate DATE); INSERT INTO HealthEquityMetrics (ViolationID, ViolationType, Region, ViolationDate) VALUES (1, 'Language Access', 'Northeast', '2021-02-14'), (2, 'Racial Disparities', 'Southeast', '2021-05-03'), (3,...
What is the total number of health equity metric violations by type and region?
SELECT ViolationType, Region, COUNT(*) as ViolationCount FROM HealthEquityMetrics GROUP BY ViolationType, Region;
gretelai_synthetic_text_to_sql
CREATE TABLE landfill_capacity (country VARCHAR(255), capacity FLOAT); INSERT INTO landfill_capacity (country, capacity) VALUES ('Japan', 9.2), ('Australia', 13.5); CREATE VIEW avg_landfill_capacity AS SELECT country, capacity/1000000 AS capacity_megatons FROM landfill_capacity;
What is the average landfill capacity in Japan and Australia?
SELECT AVG(capacity_megatons) FROM avg_landfill_capacity WHERE country IN ('Japan', 'Australia');
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID int, FirstName varchar(50), LastName varchar(50), HireDate date); INSERT INTO Employees (EmployeeID, FirstName, LastName, HireDate) VALUES (1, 'John', 'Doe', '2020-01-01'); INSERT INTO Employees (EmployeeID, FirstName, LastName, HireDate) VALUES (2, 'Jane', 'Smith', '2020-04-01');
What is the number of employees hired in each quarter, ordered by hire date?
SELECT DATEPART(quarter, HireDate) as HireQuarter, COUNT(*) as HireCount FROM Employees GROUP BY DATEPART(quarter, HireDate) ORDER BY HireQuarter;
gretelai_synthetic_text_to_sql
CREATE TABLE Artworks (artwork_id INT, name VARCHAR(255), artist_id INT, date_sold DATE, price DECIMAL(10,2), museum_id INT); CREATE TABLE Artists (artist_id INT, name VARCHAR(255), nationality VARCHAR(255), gender VARCHAR(255)); CREATE TABLE Museums (museum_id INT, name VARCHAR(255));
What is the total revenue generated by the Tate from Cubist paintings between 1910 and 1920?
SELECT SUM(Artworks.price) FROM Artworks INNER JOIN Artists ON Artworks.artist_id = Artists.artist_id INNER JOIN Museums ON Artworks.museum_id = Museums.museum_id WHERE Artists.nationality = 'Cubist' AND Museums.name = 'The Tate' AND YEAR(Artworks.date_sold) BETWEEN 1910 AND 1920;
gretelai_synthetic_text_to_sql
CREATE TABLE OrderDetails (order_id INT, product_id INT, delivery_date DATE, packaging_type VARCHAR(255)); CREATE TABLE PackagingInfo (packaging_id INT, packaging_type VARCHAR(255), is_recycled BOOLEAN, avg_delivery_time INT); INSERT INTO PackagingInfo (packaging_id, packaging_type, is_recycled, avg_delivery_time) VALU...
What is the average delivery time for recycled packaging orders?
SELECT AVG(PackagingInfo.avg_delivery_time) FROM PackagingInfo INNER JOIN OrderDetails ON PackagingInfo.packaging_type = OrderDetails.packaging_type WHERE PackagingInfo.is_recycled = true;
gretelai_synthetic_text_to_sql
CREATE TABLE taxi_trips (trip_id INT, start_time TIMESTAMP, end_time TIMESTAMP, trip_distance FLOAT, fare FLOAT, wheelchair_accessible BOOLEAN);
What is the total revenue generated from wheelchair accessible taxi rides in London?
SELECT SUM(fare) FROM taxi_trips WHERE wheelchair_accessible = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE professors (id INT, name VARCHAR(50), department VARCHAR(50), research_interest VARCHAR(50), num_papers INT); INSERT INTO professors (id, name, department, research_interest, num_papers) VALUES (1, 'John Doe', 'Computer Science', 'Machine Learning', 6), (2, 'Jane Smith', 'Computer Science', 'Data Science',...
Delete the records of all professors who have not published any papers.
DELETE FROM professors WHERE num_papers = 0;
gretelai_synthetic_text_to_sql
CREATE TABLE Organizations (OrgID INT, OrgName TEXT, OrgState TEXT, ProjectID INT, ProjectCompletionDate DATE);
List all projects and their completion dates from organizations located in 'CA'?
SELECT p.ProjectID, p.ProjectCompletionDate FROM Projects p INNER JOIN Organizations o ON p.OrgID = o.OrgID WHERE o.OrgState = 'CA';
gretelai_synthetic_text_to_sql
CREATE TABLE niger_delta_platforms (platform_id INT, platform_name VARCHAR(50), location VARCHAR(50), operational_status VARCHAR(15)); INSERT INTO niger_delta_platforms VALUES (1, 'Shell 1', 'Niger Delta', 'Active'); INSERT INTO niger_delta_platforms VALUES (2, 'Chevron 1', 'Niger Delta', 'Active'); CREATE TABLE gas_pr...
What is the minimum natural gas production in the Niger Delta for 2018?
SELECT MIN(production) FROM gas_production WHERE year = 2018 AND location = 'Niger Delta';
gretelai_synthetic_text_to_sql
CREATE TABLE explainable_ai.ai_applications (ai_application_id INT PRIMARY KEY, ai_algorithm_id INT, application_name VARCHAR(255), safety_score FLOAT); INSERT INTO explainable_ai.ai_applications (ai_application_id, ai_algorithm_id, application_name, safety_score) VALUES (1, 1, 'AI-generated art', 0.8), (2, 1, 'AI-gene...
What is the minimum safety score for each AI application in the 'explainable_ai' database?
SELECT a.application_name, MIN(safety_score) as min_safety_score FROM explainable_ai.ai_applications a GROUP BY a.application_name;
gretelai_synthetic_text_to_sql
CREATE TABLE field_sensors (id INT, field_id INT, sensor_id INT);
Find the number of sensors in each field.
SELECT field_id, COUNT(DISTINCT sensor_id) as sensor_count FROM field_sensors GROUP BY field_id;
gretelai_synthetic_text_to_sql
CREATE TABLE GameSales (GameID INT, GameType VARCHAR(10), Revenue INT, SaleDate DATE); INSERT INTO GameSales (GameID, GameType, Revenue, SaleDate) VALUES (1, 'FPS', 1000, '2022-01-01'), (2, 'RPG', 2000, '2022-01-02');
What is the total revenue generated by FPS games in the last quarter?
SELECT SUM(Revenue) FROM GameSales WHERE GameType = 'FPS' AND SaleDate >= DATE_SUB(CURDATE(), INTERVAL 3 MONTH)
gretelai_synthetic_text_to_sql
CREATE TABLE Intelligence_Operations (Operation_Name VARCHAR(255), Country VARCHAR(255), Year INT); INSERT INTO Intelligence_Operations (Operation_Name, Country, Year) VALUES ('Operation Red Sparrow', 'Russia', 2015), ('Operation Nightfall', 'China', 2018), ('Operation Black Swan', 'X', 2020);
Which intelligence operations have been conducted in country 'X'?
SELECT Operation_Name FROM Intelligence_Operations WHERE Country = 'X';
gretelai_synthetic_text_to_sql
CREATE TABLE community_health_workers (id INT PRIMARY KEY, name TEXT, hired_date DATE, language TEXT, cultural_competency_score INT);
How many community health workers have been added to the system in the last month?
SELECT COUNT(*) FROM community_health_workers WHERE hired_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE rural_infrastructure (id INT, country VARCHAR(50), project_type VARCHAR(50), budget INT); INSERT INTO rural_infrastructure (id, country, project_type, budget) VALUES (1, 'Kenya', 'Roads', 5000000), (2, 'Kenya', 'Irrigation', 7000000), (3, 'Tanzania', 'Roads', 6000000), (4, 'Uganda', 'Rural Electrification'...
What is the average budget for rural infrastructure projects in each country?
SELECT country, AVG(budget) as avg_budget FROM rural_infrastructure GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE age_improvement (age INT, improvement_score INT); INSERT INTO age_improvement (age, improvement_score) VALUES (18, 10);
What is the average improvement score of patients by age group?
SELECT age_groups.age_group_name, AVG(age_improvement.improvement_score) FROM age_groups INNER JOIN age_improvement ON age_groups.age BETWEEN age_improvement.age - 5 AND age_improvement.age + 5 GROUP BY age_groups.age_group_name;
gretelai_synthetic_text_to_sql
CREATE TABLE Pharmacies (ID INT, Name VARCHAR(50), City VARCHAR(50)); INSERT INTO Pharmacies (ID, Name, City) VALUES (1, 'CVS', 'New York');
How many pharmacies are there in each city, ordered by the number of pharmacies?
SELECT City, COUNT(*) AS NumPharmacies FROM Pharmacies GROUP BY City ORDER BY NumPharmacies DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE regions (region_id INT, region_name TEXT);CREATE TABLE wildlife_habitat (habitat_id INT, region_id INT); INSERT INTO regions (region_id, region_name) VALUES (1, 'Region A'), (2, 'Region B'), (3, 'Region C'); INSERT INTO wildlife_habitat (habitat_id, region_id) VALUES (1, 1), (2, 1), (3, 2), (4, 3), (5, 3);
How many regions have wildlife habitats?
SELECT region_id, region_name, COUNT(*) FROM regions JOIN wildlife_habitat ON regions.region_id = wildlife_habitat.region_id GROUP BY region_id, region_name HAVING COUNT(*) > 0;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists biosensor; USE biosensor; CREATE TABLE if not exists genes_analyzed (gene_name VARCHAR(255)); INSERT INTO genes_analyzed (gene_name) VALUES ('ABC'), ('DEF'), ('GHI'), ('JKL'), ('MNO'), ('PQR'), ('ABC'), ('STU');
What is the total number of unique genes analyzed in the biosensor project?
SELECT COUNT(DISTINCT gene_name) FROM biosensor.genes_analyzed;
gretelai_synthetic_text_to_sql
CREATE TABLE Workers (EmployeeID INT, Industry VARCHAR(20), UnionMember BOOLEAN, Salary FLOAT); INSERT INTO Workers (EmployeeID, Industry, UnionMember, Salary) VALUES (1, 'Transportation', false, 58000.0), (2, 'Transportation', true, 60000.0), (3, 'Transportation', false, 56000.0);
What is the average salary of workers in the 'Transportation' industry who are not members of a union?
SELECT AVG(Salary) FROM Workers WHERE Industry = 'Transportation' AND UnionMember = false;
gretelai_synthetic_text_to_sql
CREATE TABLE precinct (id INT, name VARCHAR(50)); INSERT INTO precinct (id, name) VALUES (1, 'Central'); CREATE TABLE incident (id INT, precinct_id INT, incident_date DATE);
What is the total number of crime incidents per month in the 'Central' precinct?
SELECT DATEPART(year, incident_date) as year, DATEPART(month, incident_date) as month, COUNT(*) as total_incidents FROM incident WHERE precinct_id = 1 GROUP BY DATEPART(year, incident_date), DATEPART(month, incident_date);
gretelai_synthetic_text_to_sql
CREATE TABLE yearly_timber (year INT, volume_m3 INT); INSERT INTO yearly_timber (year, volume_m3) VALUES (2010, 2000), (2011, 2200), (2012, 2500), (2013, 2700), (2014, 3000);
What is the maximum volume of timber produced in a single year?
SELECT MAX(volume_m3) FROM yearly_timber;
gretelai_synthetic_text_to_sql
CREATE TABLE Farms (id INT, name TEXT, state TEXT); INSERT INTO Farms (id, name, state) VALUES (1, 'Farm A', 'Oregon'), (2, 'Farm B', 'Oregon'); CREATE TABLE Strains (id INT, farm_id INT, name TEXT); INSERT INTO Strains (id, farm_id, name) VALUES (1, 1, 'Strain X'), (2, 1, 'Strain Y'), (3, 2, 'Strain Z');
How many unique strains were grown in Oregon in 2020?
SELECT COUNT(DISTINCT s.name) as unique_strains FROM Strains s INNER JOIN Farms f ON s.farm_id = f.id WHERE f.state = 'Oregon' AND s.date BETWEEN '2020-01-01' AND '2020-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE patients (patient_id INT, age INT, gender TEXT, state TEXT, condition TEXT, medication TEXT); INSERT INTO patients (patient_id, age, gender, state, condition, medication) VALUES (1, 30, 'Female', 'Texas', 'Depression', 'Yes'); INSERT INTO patients (patient_id, age, gender, state, condition, medication) VAL...
How many patients in Texas received medication for depression?
SELECT COUNT(*) FROM patients WHERE state = 'Texas' AND condition = 'Depression' AND medication = 'Yes';
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists aerospace;CREATE TABLE if not exists aerospace.aircraft (id INT, name VARCHAR(255), manufacture_country VARCHAR(255), manufacture_date DATE);
Insert a new aircraft into the database
INSERT INTO aerospace.aircraft (id, name, manufacture_country, manufacture_date) VALUES (3, 'Air3', 'Germany', '2022-02-01');
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name VARCHAR(50), price DECIMAL(5,2), category VARCHAR(50), country_of_manufacture VARCHAR(50)); INSERT INTO products (product_id, product_name, price, category, country_of_manufacture) VALUES (1, 'T-Shirt', 20.99, 'clothing', 'USA'), (2, 'Jeans', 55.99, 'clothing', 'USA')...
What is the maximum price of products in the 'clothing' category that are made in the USA?
SELECT MAX(price) FROM products WHERE category = 'clothing' AND country_of_manufacture = 'USA';
gretelai_synthetic_text_to_sql
player (player_id, name, email, age, gender, country, total_games_played); game (game_id, name, genre, release_year); player_game (player_id, game_id, last_played)
Get players who have never played 'RPG' games
SELECT DISTINCT p.player_id, p.name, p.email, p.age, p.gender, p.country, p.total_games_played FROM player p LEFT JOIN player_game pg ON p.player_id = pg.player_id LEFT JOIN game g ON pg.game_id = g.game_id WHERE g.genre != 'RPG' OR g.game_id IS NULL
gretelai_synthetic_text_to_sql
CREATE TABLE wastewater_treatment_plants_by_region (plant_id INT, daily_consumption FLOAT, consumption_date DATE, plant_location VARCHAR(20)); INSERT INTO wastewater_treatment_plants_by_region (plant_id, daily_consumption, consumption_date, plant_location) VALUES (1, 1000, '2022-03-01', 'Africa'), (2, 1500, '2022-03-02...
What is the minimum water consumption in a single day for all wastewater treatment plants in 'Africa'?
SELECT MIN(daily_consumption) FROM wastewater_treatment_plants_by_region WHERE plant_location = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE certifications(certification_id INT, product_id INT, certification_type VARCHAR(50), certified_date DATE);
What is the distribution of cruelty-free certifications by year for cosmetics products in the makeup category?
SELECT YEAR(certified_date) as certification_year, COUNT(*) as cruelty_free_count FROM certifications JOIN cosmetics_products ON certifications.product_id = cosmetics_products.product_id WHERE certifications.certification_type = 'cruelty-free' AND cosmetics_products.category = 'makeup' GROUP BY certification_year;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_trenches (ocean TEXT, trench TEXT, max_depth INTEGER);INSERT INTO marine_trenches (ocean, trench, max_depth) VALUES ('Pacific', 'Mariana Trench', 10994), ('Indian', 'Java Trench', 7725);
Find the trench with the maximum depth in the Indian Ocean and display the trench name and maximum depth
SELECT trench, max_depth FROM marine_trenches WHERE ocean = 'Indian' AND max_depth = (SELECT MAX(max_depth) FROM marine_trenches WHERE ocean = 'Indian');
gretelai_synthetic_text_to_sql
CREATE TABLE Violations (id INT, employee VARCHAR(255), violation_date DATE); INSERT INTO Violations (id, employee, violation_date) VALUES (1, 'John Doe', '2022-01-15'), (2, 'Jane Smith', '2022-02-20');
List all safety protocol violations by employees in the past 6 months, grouped by month.
SELECT DATE_FORMAT(violation_date, '%Y-%m') as Month, employee, COUNT(*) FROM Violations WHERE violation_date >= DATE_SUB(CURDATE(), INTERVAL 6 MONTH) GROUP BY Month, employee
gretelai_synthetic_text_to_sql
CREATE TABLE GitHub (username TEXT, repos INT, domain TEXT); INSERT INTO GitHub VALUES ('Octocat', 10, 'Explainable AI'), ('AI-Guru', 20, 'Explainable AI');
Who are the top contributors to explainable AI on GitHub?
SELECT username FROM GitHub WHERE domain = 'Explainable AI' ORDER BY repos DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE eos_dapps (dapp_id INT, name VARCHAR(255), token_supply DECIMAL(30, 0)); INSERT INTO eos_dapps (dapp_id, name, token_supply) VALUES (1, 'Dapp1', 100000000), (2, 'Dapp2', 200000000), (3, 'Dapp3', 300000000);
How many decentralized applications are built on the EOS blockchain, and what is their total token supply?
SELECT COUNT(*), SUM(token_supply) FROM eos_dapps;
gretelai_synthetic_text_to_sql
CREATE TABLE cases (case_id INT, resolution_date DATE, city VARCHAR(20)); INSERT INTO cases (case_id, resolution_date, city) VALUES (1, '2021-01-01', 'Los Angeles'); INSERT INTO cases (case_id, resolution_date, city) VALUES (2, '2020-01-01', 'New York');
List all access to justice cases resolved in Los Angeles in 2021.
SELECT case_id FROM cases WHERE resolution_date BETWEEN '2021-01-01' AND '2021-12-31' AND city = 'Los Angeles';
gretelai_synthetic_text_to_sql
CREATE TABLE creative_ai (app_id INT, app_name TEXT, safety_rating REAL); INSERT INTO creative_ai VALUES (1, 'Dalle', 4.3, 'USA'), (2, 'GTP-3', 4.5, 'Canada'), (3, 'Midjourney', 4.7, 'Australia');
Find the difference between the highest and lowest safety ratings in the creative_ai table.
SELECT MAX(safety_rating) - MIN(safety_rating) as safety_rating_diff FROM creative_ai;
gretelai_synthetic_text_to_sql
CREATE TABLE DefenseContracts (Id INT, ContractName VARCHAR(50), Timestamp DATETIME); INSERT INTO DefenseContracts (Id, ContractName, Timestamp) VALUES (1, 'Contract A', '2021-01-01 09:00:00'), (2, 'Contract B', '2021-02-15 12:30:00'), (3, 'Contract C', '2021-12-31 16:45:00');
What is the maximum number of defense contracts signed per month in 2021?
SELECT MAX(MonthlyContractCount) FROM (SELECT COUNT(*) AS MonthlyContractCount, YEAR(Timestamp) AS ContractYear, MONTH(Timestamp) AS ContractMonth FROM DefenseContracts GROUP BY YEAR(Timestamp), MONTH(Timestamp)) AS ContractCounts WHERE ContractYear = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE players (player_id INT, name VARCHAR(50)); INSERT INTO players VALUES (1, 'John'); INSERT INTO players VALUES (2, 'Jane'); CREATE TABLE scores (score_id INT, player_id INT, score INT); INSERT INTO scores VALUES (1, 1, 90); INSERT INTO scores VALUES (2, 1, 95); INSERT INTO scores VALUES (3, 2, 85); INSERT I...
Which players from the 'players' table have the highest average scores in the 'scores' table, and how many high scores did they achieve?
SELECT p.name, AVG(s.score) as avg_score, COUNT(*) as high_scores FROM players p JOIN scores s ON p.player_id = s.player_id WHERE s.score >= (SELECT AVG(score) FROM scores) GROUP BY p.player_id ORDER BY avg_score DESC, high_scores DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE market_trends (year INT, market_trend VARCHAR(255), country VARCHAR(255)); INSERT INTO market_trends (year, market_trend, country) VALUES (2017, 'Increase', 'China'), (2017, 'Decrease', 'USA'), (2018, 'Stable', 'China'), (2018, 'Increase', 'USA'), (2019, 'Decrease', 'China'), (2019, 'Stable', 'USA');
Calculate the average REE market trends for each year since 2017, excluding China.
SELECT AVG(market_trend = 'Increase') AS avg_increase, AVG(market_trend = 'Decrease') AS avg_decrease, AVG(market_trend = 'Stable') AS avg_stable FROM market_trends WHERE year >= 2017 AND country != 'China';
gretelai_synthetic_text_to_sql
CREATE TABLE FireIncidents (id INT, incident_type VARCHAR(20), location VARCHAR(50), date DATE, time TIME, response_time INT); INSERT INTO FireIncidents (id, incident_type, location, date, time, response_time) VALUES (1, 'Building fire', 'City H', '2022-05-05', '08:15:00', 25);
What is the average response time for fire incidents?
SELECT AVG(response_time) FROM FireIncidents WHERE incident_type = 'Building fire';
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (species_id INTEGER, species_name TEXT, avg_population_size FLOAT);
Identify the top 3 marine species with the largest population size.
SELECT species_name, avg_population_size FROM marine_species ORDER BY avg_population_size DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Pallets_2 (id INT, item VARCHAR(50), quantity INT, country VARCHAR(50)); INSERT INTO Pallets_2 (id, item, quantity, country) VALUES (1, 'Baz', 50, 'Italy'), (2, 'Qux', 75, 'Spain');
What is the total number of pallets shipped from Italy to Spain?
SELECT SUM(quantity) FROM Pallets_2 WHERE country = 'Italy' AND EXISTS (SELECT 1 FROM Pallets_2 p2 WHERE p2.country = 'Spain');
gretelai_synthetic_text_to_sql
CREATE TABLE r_and_d_expenditures (drug_name VARCHAR(255), expenditure DECIMAL(10,2), expenditure_date DATE); INSERT INTO r_and_d_expenditures (drug_name, expenditure, expenditure_date) VALUES ('DrugB', 50000, '2019-01-01');
What is the average R&D expenditure for 'DrugB' and 'DrugC' in the first quarter of 2019?
SELECT AVG(expenditure) FROM r_and_d_expenditures WHERE drug_name IN ('DrugB', 'DrugC') AND QUARTER(expenditure_date) = 1 AND YEAR(expenditure_date) = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE regions (id INT PRIMARY KEY, name VARCHAR(255)); INSERT INTO regions (id, name) VALUES (1, 'Europe'); INSERT INTO regions (id, name) VALUES (2, 'North America'); CREATE TABLE population_by_region (region_id INT, species_id INT, population INT); INSERT INTO population_by_region (region_id, species_id, popul...
Delete records where the 'Pine' species population is less than 5,500,000.
DELETE FROM population_by_region WHERE species_id = 2 AND population < 5500000;
gretelai_synthetic_text_to_sql
CREATE TABLE Vendors (vid INT, name TEXT);CREATE TABLE Dishes (did INT, name TEXT, calorie_content INT);CREATE TABLE Ingredients (iid INT, dish_id INT, vendor_id INT);INSERT INTO Vendors VALUES (1, 'VendorA'), (2, 'VendorB'), (3, 'VendorC');INSERT INTO Dishes VALUES (1, 'DishA', 500), (2, 'DishB', 1500), (3, 'DishC', 8...
List all vendors that supply ingredients for dishes with a calorie count above the average.
SELECT DISTINCT Vendors.name FROM Vendors INNER JOIN Ingredients ON Vendors.vid = Ingredients.vendor_id INNER JOIN Dishes ON Ingredients.dish_id = Dishes.did WHERE Dishes.calorie_content > (SELECT AVG(calorie_content) FROM Dishes);
gretelai_synthetic_text_to_sql
CREATE TABLE fish_species (species_id INT, species_name TEXT, country TEXT, survival_rate FLOAT); INSERT INTO fish_species (species_id, species_name, country, survival_rate) VALUES (1, 'Salmon', 'Norway', 0.87), (2, 'Cod', 'Norway', 0.82), (3, 'Tilapia', 'Norway', 0.88);
Count the number of fish species farmed in Norway with a survival rate greater than 85%?
SELECT COUNT(*) FROM fish_species WHERE country = 'Norway' AND survival_rate > 0.85;
gretelai_synthetic_text_to_sql
CREATE TABLE Military_Equipment_Sales (sale_id INT, year INT, country VARCHAR(50), value FLOAT); INSERT INTO Military_Equipment_Sales (sale_id, year, country, value) VALUES (1, 2018, 'Japan', 1200000), (2, 2019, 'Japan', 1500000);
What was the total military equipment sales value to Japan in 2018?
SELECT YEAR(assessment_date), SUM(value) FROM Military_Equipment_Sales WHERE country = 'Japan' AND year = 2018 GROUP BY YEAR(assessment_date);
gretelai_synthetic_text_to_sql
CREATE TABLE Revenue (revenue_id INT, revenue_date DATE, revenue_amount DECIMAL(10,2)); INSERT INTO Revenue (revenue_id, revenue_date, revenue_amount) VALUES (1, '2022-01-01', 1500); INSERT INTO Revenue (revenue_id, revenue_date, revenue_amount) VALUES (2, '2022-01-02', 2000);
List all revenue records for the month of January 2022
SELECT * FROM Revenue WHERE revenue_date BETWEEN '2022-01-01' AND '2022-01-31';
gretelai_synthetic_text_to_sql
CREATE TABLE museums (id INT, name TEXT, type TEXT); INSERT INTO museums (id, name, type) VALUES (1, 'contemporary', 'museum'), (2, 'modernart', 'museum'); CREATE TABLE artworks (id INT, museum_id INT, title TEXT, medium TEXT); INSERT INTO artworks (id, museum_id, title, medium) VALUES (1, 1, 'Untitled', 'Sculpture'), ...
How many sculptures are there in the 'contemporary' museum?
SELECT COUNT(*) FROM artworks WHERE museum_id = 1 AND medium = 'Sculpture';
gretelai_synthetic_text_to_sql
CREATE TABLE product (product_id INT, name VARCHAR(255), price DECIMAL(5,2), material VARCHAR(255)); INSERT INTO product (product_id, name, price, material) VALUES (1, 'Organic Cotton T-Shirt', 20.99, 'organic cotton'), (2, 'Polyester Hoodie', 15.99, 'polyester'), (3, 'Bamboo Socks', 7.99, 'bamboo');
Get the product with the lowest price from each material category.
SELECT product_id, name, price, material FROM (SELECT product_id, name, price, material, NTILE(3) OVER (PARTITION BY material ORDER BY price) AS tier FROM product) AS tiered_products WHERE tier = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE defense_contracts (contract_id INT, contract_name VARCHAR(100), budget INT, region VARCHAR(50));
Show the total budget allocated for defense contracts in each region
SELECT region, SUM(budget) FROM defense_contracts GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE delivery (delivery_id INT, delivery_date DATE, num_items INT, disaster_affected BOOLEAN); INSERT INTO delivery (delivery_id, delivery_date, num_items, disaster_affected) VALUES (1, '2021-01-01', 5, true), (2, '2021-01-02', 10, false), (3, '2021-02-01', 15, true);
How many total items were delivered in disaster-affected areas in the year 2021?
SELECT SUM(num_items) FROM delivery WHERE disaster_affected = true AND delivery_date BETWEEN '2021-01-01' AND '2021-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE MilitaryEquipmentSales (id INT PRIMARY KEY, sale_year INT, equipment_type VARCHAR(50), country VARCHAR(50), sale_value FLOAT); INSERT INTO MilitaryEquipmentSales (id, sale_year, equipment_type, country, sale_value) VALUES (1, 2020, 'Aircraft', 'United States', 12000000), (2, 2021, 'Vehicles', 'United State...
What is the total value of military equipment sales to Taiwan and Mexico combined in 2020 and 2021?
SELECT SUM(sale_value) FROM MilitaryEquipmentSales WHERE (country = 'Taiwan' OR country = 'Mexico') AND sale_year IN (2020, 2021);
gretelai_synthetic_text_to_sql
CREATE TABLE gender (gender_code CHAR(1), gender_name VARCHAR(10)); INSERT INTO gender VALUES ('F', 'Female'), ('M', 'Male'), ('N', 'Non-binary'); CREATE TABLE students (student_id INT, gender_code CHAR(1), mental_health_resource_access DATE); INSERT INTO students VALUES (1, 'F', '2021-09-15'), (2, 'M', '2021-10-01'), ...
What is the distribution of mental health resource access by gender?
SELECT g.gender_name, COUNT(DISTINCT students.student_id) AS student_count FROM gender g JOIN students ON g.gender_code = students.gender_code WHERE students.mental_health_resource_access >= DATEADD(month, -1, GETDATE()) GROUP BY g.gender_name;
gretelai_synthetic_text_to_sql
CREATE TABLE Requests(Quarter INT, Group VARCHAR(20), Requests INT); INSERT INTO Requests VALUES (1, 'Persons with Disabilities', 120), (1, 'Seniors', 150), (2, 'Persons with Disabilities', 130), (2, 'Seniors', 140), (3, 'Persons with Disabilities', 125), (3, 'Seniors', 160), (4, 'Persons with Disabilities', 110), (4, ...
How many public service requests were fulfilled for persons with disabilities in Q1 and Q2 of 2022?
SELECT SUM(Requests) FROM Requests WHERE Quarter IN (1, 2) AND Group = 'Persons with Disabilities';
gretelai_synthetic_text_to_sql
CREATE TABLE trains (route_id INT, time INT, line VARCHAR(10)); CREATE TABLE routes (route_id INT, line VARCHAR(10));
What is the average time taken for each train line in Paris to complete a route?
SELECT r.line, AVG(t.time) FROM trains t JOIN routes r ON t.route_id = r.route_id GROUP BY r.line;
gretelai_synthetic_text_to_sql
CREATE TABLE Population (Country VARCHAR(50), Continent VARCHAR(50), Year INT, PopulationSize INT); INSERT INTO Population (Country, Continent, Year, PopulationSize) VALUES ('Australia', 'Oceania', 2018, 25000000), ('New Zealand', 'Oceania', 2018, 4900000);
What is the population size in Oceania countries in 2018?
SELECT Country, Continent, PopulationSize FROM Population WHERE Continent = 'Oceania' AND Year = 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id TEXT, country TEXT, safety_certified BOOLEAN); INSERT INTO products (product_id, country, safety_certified) VALUES ('XYZ-123', 'France', FALSE), ('ABC-456', 'Germany', TRUE);
Update the safety certifications of products manufactured in France to true.
UPDATE products SET safety_certified = TRUE WHERE country = 'France';
gretelai_synthetic_text_to_sql
CREATE TABLE Revenue (booking_id INT, ota TEXT, city TEXT, booking_type TEXT, revenue FLOAT); INSERT INTO Revenue (booking_id, ota, city, booking_type, revenue) VALUES (1, 'Booking.com', 'Paris', 'non-AI', 100), (2, 'Booking.com', 'Paris', 'AI', 120), (3, 'Booking.com', 'Paris', 'non-AI', 80);
What is the total revenue for 'non-AI' hotel bookings on 'Booking.com' in 'Paris'?
SELECT SUM(revenue) FROM Revenue WHERE ota = 'Booking.com' AND city = 'Paris' AND booking_type = 'non-AI';
gretelai_synthetic_text_to_sql
CREATE TABLE investments (id INT, sector VARCHAR(20), esg_score FLOAT, investment_date DATE); INSERT INTO investments (id, sector, esg_score, investment_date) VALUES (1, 'technology', 78.5, '2021-01-10'); INSERT INTO investments (id, sector, esg_score, investment_date) VALUES (2, 'technology', 82.3, '2021-03-22');
Find the average ESG score for investments in the technology sector in Q1 2021
SELECT AVG(esg_score) FROM investments WHERE sector = 'technology' AND investment_date BETWEEN '2021-01-01' AND '2021-03-31';
gretelai_synthetic_text_to_sql
CREATE TABLE Stations (line VARCHAR(20), station VARCHAR(20), accessibility BOOLEAN); INSERT INTO Stations (line, station, accessibility) VALUES ('Red Line', 'Park Street', true), ('Red Line', 'Downtown Crossing', false);
Delete all records of stations without wheelchair accessibility from the Red Line.
DELETE FROM Stations WHERE line = 'Red Line' AND accessibility = false;
gretelai_synthetic_text_to_sql
CREATE TABLE textile_sourcing (id INT, item_id INT, fabric TEXT, cost DECIMAL);
What is the minimum textile sourcing cost for a specific fabric type?
SELECT MIN(cost) FROM textile_sourcing WHERE fabric = 'silk';
gretelai_synthetic_text_to_sql