context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE cargo(cargo_id INT, port_id INT, tonnage INT);INSERT INTO cargo VALUES (1,1,500),(2,1,800),(3,2,300),(4,1,0),(5,2,600);
List the names and total tonnage of all cargoes that share the same destination port as cargo with the ID of 5, including cargoes with no tonnage.
SELECT c.name, COALESCE(SUM(c2.tonnage), 0) as total_tonnage FROM cargo c INNER JOIN cargo c2 ON c.port_id = c2.port_id WHERE c2.cargo_id = 5 GROUP BY c.cargo_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Infrastructure (type TEXT, state TEXT, design_code TEXT); INSERT INTO Infrastructure (type, state, design_code) VALUES ('Bridges', 'California', 'AASHTO LRFD');
List the unique types of infrastructure and their respective standard design codes in 'California'.
SELECT DISTINCT type, design_code FROM Infrastructure WHERE state = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name TEXT, is_safety_certified BOOLEAN, country TEXT); INSERT INTO products (product_id, product_name, is_safety_certified, country) VALUES (1, 'Eyeshadow', true, 'USA'), (2, 'Blush', false, 'USA'), (3, 'Highlighter', true, 'USA');
What percentage of cosmetic products are not safety certified in USA?
SELECT (COUNT(*) - SUM(is_safety_certified)) * 100.0 / COUNT(*) as percentage FROM products WHERE country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE DApp (DAppID INT, DAppName VARCHAR(100), IssuerCompany VARCHAR(100), IssuerLocation VARCHAR(50), Industry VARCHAR(50)); INSERT INTO DApp (DAppID, DAppName, IssuerCompany, IssuerLocation, Industry) VALUES (1, 'DApp1', 'CompanyD', 'Africa', 'Finance'), (2, 'DApp2', 'CompanyE', 'Africa', 'Healthcare'), (3, 'DApp3', 'CompanyF', 'Europe', 'Retail');
How many decentralized applications have been developed by companies in the African continent, and what are their industries?
SELECT IssuerLocation, Industry, COUNT(*) as Total FROM DApp WHERE IssuerLocation = 'Africa' GROUP BY IssuerLocation, Industry;
gretelai_synthetic_text_to_sql
CREATE TABLE clothing_brands (brand_id INT PRIMARY KEY, brand_name VARCHAR(100), sustainability_rating FLOAT); INSERT INTO clothing_brands (brand_id, brand_name, sustainability_rating) VALUES (1, 'EcoFriendlyBrand', 4.2), (2, 'GreenFashion', 4.6), (3, 'SustainableTextiles', 4.5);
How many sustainable clothing brands are available in the database?
SELECT COUNT(DISTINCT brand_name) FROM clothing_brands;
gretelai_synthetic_text_to_sql
CREATE TABLE production (country VARCHAR(255), year INT, amount INT);
Insert a new record of rare earth element production for 'Canada' in 2021 with an amount of 10000.
INSERT INTO production (country, year, amount) VALUES ('Canada', 2021, 10000);
gretelai_synthetic_text_to_sql
CREATE TABLE environmental_impact (spill_date DATE); INSERT INTO environmental_impact (spill_date) VALUES ('2020-03-15'), ('2021-08-09'), ('2020-12-25'), ('2019-06-01');
What is the total number of chemical spills recorded in the environmental_impact table, grouped by the year?
SELECT YEAR(spill_date) AS year, COUNT(*) AS total_spills FROM environmental_impact GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE infrastructure_projects (id INT, name VARCHAR(50), location VARCHAR(50), start_date DATE, end_date DATE, total_cost FLOAT);
What is the total cost of all projects in the 'infrastructure_projects' table, ordered by the project's start date?
SELECT SUM(total_cost) FROM infrastructure_projects ORDER BY start_date;
gretelai_synthetic_text_to_sql
CREATE TABLE socially_responsible_loans_over_time (id INT, loan_date DATE, amount FLOAT); INSERT INTO socially_responsible_loans_over_time (id, loan_date, amount) VALUES (1, '2021-01-01', 350000), (2, '2021-04-01', 400000), (3, '2021-07-01', 450000), (4, '2021-10-01', 200000);
What is the trend of socially responsible loan amounts issued per quarter?
SELECT DATE_FORMAT(loan_date, '%Y-%m') as month, QUARTER(loan_date) as quarter, SUM(amount) as total_amount FROM socially_responsible_loans_over_time GROUP BY quarter ORDER BY quarter;
gretelai_synthetic_text_to_sql
CREATE TABLE EuroBikeSharing (id INT, city VARCHAR(20), stations INT);
How many bike-sharing stations are there in Paris and London?
SELECT city, SUM(stations) FROM EuroBikeSharing WHERE city IN ('Paris', 'London') GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE wearable_tech (user_id INT, heart_rate INT, country VARCHAR(50)); INSERT INTO wearable_tech (user_id, heart_rate, country) VALUES (1, 70, 'Mexico'), (2, 75, 'Canada'), (3, 80, 'Mexico'), (4, 65, 'Mexico'), (5, 72, 'Mexico');
What is the average heart rate of users from Mexico?
SELECT AVG(heart_rate) FROM wearable_tech WHERE country = 'Mexico';
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, age INT, media_literacy_score INT); INSERT INTO users (id, age, media_literacy_score) VALUES (1, 25, 80), (2, 34, 85), (3, 22, 75), (4, 45, 90);
What is the average media literacy score for users aged 25-34 in the United States?
SELECT AVG(media_literacy_score) FROM users WHERE age BETWEEN 25 AND 34 AND country = 'United States';
gretelai_synthetic_text_to_sql
CREATE TABLE Garments (GarmentID INT, GarmentName TEXT, IsSustainable BOOLEAN, AverageRating DECIMAL); INSERT INTO Garments VALUES (1, 'Garment1', TRUE, 4.5), (2, 'Garment2', FALSE, 3.5), (3, 'Garment3', TRUE, 4.0);
What is the average garment rating for sustainable garments compared to non-sustainable garments?
SELECT CASE WHEN IsSustainable = TRUE THEN 'Sustainable' ELSE 'Non-Sustainable' END AS Category, AVG(AverageRating) FROM Garments GROUP BY Category;
gretelai_synthetic_text_to_sql
CREATE TABLE hospitals_region (name VARCHAR(100), region VARCHAR(50));
What is the number of hospitals per region?
SELECT region, COUNT(*) FROM hospitals_region GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE cultural_events (id INT, city VARCHAR(20), price INT); INSERT INTO cultural_events (id, city, price) VALUES (1, 'Berlin', 18), (2, 'Sydney', 25), (3, 'Paris', 30);
What is the average ticket price for cultural events in 'Berlin' and 'Sydney'?
SELECT AVG(price) FROM cultural_events WHERE city IN ('Berlin', 'Sydney');
gretelai_synthetic_text_to_sql
CREATE TABLE fairness_issues (issue_id INT, issue_date DATE, country VARCHAR(255), issue_category VARCHAR(255), region VARCHAR(255)); INSERT INTO fairness_issues (issue_id, issue_date, country, issue_category, region) VALUES (1, '2021-08-01', 'Indonesia', 'Bias', 'Southeast Asia'), (2, '2022-02-01', 'Singapore', 'Explainability', 'Southeast Asia'), (3, '2021-12-31', 'Thailand', 'Transparency', 'Southeast Asia');
Identify the number of algorithmic fairness issues reported in Southeast Asia, grouped by issue category and year.
SELECT EXTRACT(YEAR FROM issue_date) as year, issue_category, COUNT(*) as num_issues FROM fairness_issues WHERE region = 'Southeast Asia' GROUP BY year, issue_category;
gretelai_synthetic_text_to_sql
CREATE TABLE restaurants (restaurant_id INT, name VARCHAR(255)); INSERT INTO restaurants (restaurant_id, name) VALUES (3, 'Burger King'); CREATE TABLE menu_items (menu_item_id INT, name VARCHAR(255), price DECIMAL(5,2), restaurant_id INT); INSERT INTO menu_items (menu_item_id, name, price, restaurant_id) VALUES (5, 'Vegan Burger', 6.99, 3); CREATE TABLE orders (order_id INT, menu_item_id INT, quantity INT, order_date DATE, restaurant_id INT); INSERT INTO orders (order_id, menu_item_id, quantity, order_date, restaurant_id) VALUES (1, 5, 2, '2022-01-01', 3);
What percentage of revenue came from 'Vegan Burger' at 'Burger King'?
SELECT 100.0 * SUM(price * quantity) / (SELECT SUM(price * quantity) FROM orders o JOIN menu_items mi ON o.menu_item_id = mi.menu_item_id WHERE mi.restaurant_id = 3) AS revenue_percentage FROM orders o JOIN menu_items mi ON o.menu_item_id = mi.menu_item_id WHERE mi.name = 'Vegan Burger' AND mi.restaurant_id = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE garment_production (id INT PRIMARY KEY, fabric_type VARCHAR(255), production_country VARCHAR(255), quantity INT, price DECIMAL(5,2)); CREATE VIEW top_garment_producers AS SELECT production_country, SUM(quantity) as total_quantity FROM garment_production GROUP BY production_country ORDER BY total_quantity DESC;
Delete records from garment_production where the quantity is less than 500 for garments produced in Vietnam.
DELETE FROM garment_production WHERE garment_production.quantity < 500 AND garment_production.production_country = 'Vietnam';
gretelai_synthetic_text_to_sql
CREATE TABLE creative_apps (id INT, name VARCHAR(255), type VARCHAR(255)); INSERT INTO creative_apps (id, name, type) VALUES (1, 'Image Generation', 'Computer Vision'), (2, 'Text Summarization', 'Natural Language Processing');
Add a new creative AI application 'Music Generation'
INSERT INTO creative_apps (id, name, type) VALUES (3, 'Music Generation', 'Audio Processing');
gretelai_synthetic_text_to_sql
CREATE TABLE wearable_metrics (id INT, user_id INT, heart_rate INT, steps INT, date DATE);
Delete all records in the 'wearable_metrics' table that have a null value in the 'heart_rate' column
DELETE FROM wearable_metrics WHERE heart_rate IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE textile_waste(brand VARCHAR(50), waste FLOAT); INSERT INTO textile_waste(brand, waste) VALUES('BrandA', 12.5), ('BrandB', 15.8), ('BrandC', 18.3);
What is the average textile waste generation (in metric tons) for each fashion brand?
SELECT brand, AVG(waste) FROM textile_waste GROUP BY brand;
gretelai_synthetic_text_to_sql
CREATE TABLE Events (EventID INT, Category VARCHAR(50), FundingReceived DECIMAL(10,2)); INSERT INTO Events (EventID, Category, FundingReceived) VALUES (1, 'Music', 10000), (2, 'Theater', 15000);
Update the funding for event with EventID 1 to 12000
UPDATE Events SET FundingReceived = 12000 WHERE EventID = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE tech_patents_china (country VARCHAR(255), year INT, num_patents INT); INSERT INTO tech_patents_china (country, year, num_patents) VALUES ('China', 2015, 1000), ('China', 2016, 1200), ('China', 2017, 1400);
What is the maximum number of military technology patents filed by China in a single year?
SELECT MAX(num_patents) FROM tech_patents_china WHERE country = 'China';
gretelai_synthetic_text_to_sql
CREATE TABLE articles (id INT, title VARCHAR(50), author_id INT, publish_date DATE); CREATE TABLE authors (id INT, name VARCHAR(50)); INSERT INTO articles (id, title, author_id, publish_date) VALUES (1, 'Article1', 3, '2022-07-01'), (2, 'Article2', 3, '2022-07-15'), (3, 'Article3', 4, '2022-06-30'); INSERT INTO authors (id, name) VALUES (3, 'Sofia Garcia'), (4, 'Ali Bailey');
What is the total number of articles written by each author, and how many of those articles were written in the month of July 2022?
SELECT a.name, COUNT(*) as total_articles, SUM(CASE WHEN DATE_FORMAT(a.publish_date, '%%Y-%%m') = '2022-07' THEN 1 ELSE 0 END) as articles_in_july FROM articles a JOIN authors au ON a.author_id = au.id GROUP BY a.name
gretelai_synthetic_text_to_sql
CREATE TABLE intelligence_operations (operation_id INT PRIMARY KEY, operation_name VARCHAR(100), operation_type VARCHAR(50), country_targeted VARCHAR(50)); INSERT INTO intelligence_operations (operation_id, operation_name, operation_type, country_targeted) VALUES (1, 'Operation Black Swan', 'Cyberwarfare', 'Russia'), (2, 'Operation Red Sparrow', 'Espionage', 'China');
Update the 'country_targeted' to 'China' for the 'intelligence_operation' with 'operation_id' 2 in the 'intelligence_operations' table
UPDATE intelligence_operations SET country_targeted = 'China' WHERE operation_id = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE PeacekeepingOperationsByCountry (Country VARCHAR(50), Year INT, Operations INT); INSERT INTO PeacekeepingOperationsByCountry (Country, Year, Operations) VALUES ('USA', 2020, 250), ('China', 2020, 200), ('India', 2020, 220), ('USA', 2021, 255), ('China', 2021, 210), ('India', 2021, 230);
What is the change in peacekeeping operation count by country between 2020 and 2021, ranked from highest to lowest?
SELECT Country, (Operations - LAG(Operations, 1, 0) OVER (PARTITION BY Country ORDER BY Year)) * 100.0 / LAG(Operations, 1, 0) OVER (PARTITION BY Country ORDER BY Year) AS OperationsChangePercentage, RANK() OVER (ORDER BY OperationsChangePercentage DESC) AS Rank FROM PeacekeepingOperationsByCountry WHERE Year IN (2020, 2021) GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE Visitors (id INT, city VARCHAR(50), digital_exhibits INT, visit_month INT); INSERT INTO Visitors (id, city, digital_exhibits, visit_month) VALUES (1, 'Melbourne', 4, 1);
Calculate the average number of digital exhibits viewed per month in Melbourne.
SELECT AVG(digital_exhibits/12) FROM (SELECT city, COUNT(DISTINCT visit_month) visitors FROM Visitors WHERE city = 'Melbourne' GROUP BY city);
gretelai_synthetic_text_to_sql
CREATE TABLE restaurants (restaurant_id INT, name VARCHAR(255)); INSERT INTO restaurants (restaurant_id, name) VALUES (6, 'Vegan Delight'); CREATE TABLE menu_items (menu_item_id INT, name VARCHAR(255), price DECIMAL(5,2), restaurant_id INT); INSERT INTO menu_items (menu_item_id, name, price, restaurant_id) VALUES (7, 'Impossible Burger', 10.99, 6); CREATE TABLE orders (order_id INT, menu_item_id INT, quantity INT, order_date DATE, restaurant_id INT); INSERT INTO orders (order_id, menu_item_id, quantity, order_date, restaurant_id) VALUES (5, 7, 3, '2022-01-02', 6);
What was the total revenue for 'Impossible Burger' at 'Vegan Delight'?
SELECT SUM(price * quantity) FROM orders o JOIN menu_items mi ON o.menu_item_id = mi.menu_item_id WHERE mi.name = 'Impossible Burger' AND mi.restaurant_id = 6;
gretelai_synthetic_text_to_sql
CREATE TABLE workers (worker_id INT, name TEXT, industry TEXT); INSERT INTO workers (worker_id, name, industry) VALUES (1, 'James Doe', 'manufacturing'), (2, 'Jane Doe', 'retail'), (3, 'James Smith', 'manufacturing'); CREATE TABLE employment (employment_id INT, worker_id INT, gender TEXT); INSERT INTO employment (employment_id, worker_id, gender) VALUES (1, 1, 'Male'), (2, 2, 'Female'), (3, 3, 'Male');
What is the percentage of male workers in each industry?
SELECT industry, COUNT(*) * 100.0 / SUM(COUNT(*)) OVER () FROM workers JOIN employment ON workers.worker_id = employment.worker_id WHERE gender = 'Male' GROUP BY industry;
gretelai_synthetic_text_to_sql
CREATE TABLE DefenseProjectTimelines (id INT PRIMARY KEY, equipment VARCHAR(50), project_start_date DATE, project_end_date DATE, project_status VARCHAR(50)); INSERT INTO EquipmentSales (id, contractor, equipment, sale_date, sale_amount) VALUES (4, 'Raytheon', 'Patriot', '2019-08-01', 80000000); INSERT INTO EquipmentSales (id, contractor, equipment, sale_date, sale_amount) VALUES (5, 'Northrop Grumman', 'Global Hawk', '2020-10-01', 110000000);
What is the total sales amount for each equipment type in the defense project timelines table?
SELECT DefenseProjectTimelines.equipment, SUM(EquipmentSales.sale_amount) FROM EquipmentSales RIGHT JOIN DefenseProjectTimelines ON EquipmentSales.equipment = DefenseProjectTimelines.equipment GROUP BY DefenseProjectTimelines.equipment;
gretelai_synthetic_text_to_sql
CREATE TABLE meals (id INT, name TEXT, type TEXT, calories INT); INSERT INTO meals (id, name, type, calories) VALUES (1, 'Quinoa Salad', 'vegan', 400), (2, 'Tofu Stir Fry', 'vegan', 600);
What is the average calorie content in vegan meals?
SELECT AVG(calories) FROM meals WHERE type = 'vegan';
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tours (tour_id INT, hotel_id INT, city TEXT, engagement_time INT); INSERT INTO virtual_tours (tour_id, hotel_id, city, engagement_time) VALUES (1, 3, 'New York', 1200), (2, 3, 'New York', 1500), (3, 4, 'Chicago', 1000);
What is the total engagement time for virtual tours in 'New York'?
SELECT SUM(engagement_time) FROM virtual_tours WHERE city = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE employees (id INT PRIMARY KEY, name VARCHAR(50), position VARCHAR(50), department VARCHAR(50), salary DECIMAL(5,2), manager_id INT, FOREIGN KEY (manager_id) REFERENCES employees(id)); CREATE TABLE departments (id INT PRIMARY KEY, name VARCHAR(50), manager_id INT, FOREIGN KEY (manager_id) REFERENCES employees(id));
Who are the managers in the human resources department with the highest salary?
SELECT employees.name AS manager_name, employees.salary AS salary FROM employees INNER JOIN departments ON employees.department = departments.name WHERE departments.name = 'Human Resources' AND employees.position = 'Manager' AND employees.salary = (SELECT MAX(employees.salary) FROM employees WHERE employees.department = departments.name AND employees.position = 'Manager');
gretelai_synthetic_text_to_sql
CREATE TABLE schools (id INT, name TEXT, budget INT, city TEXT); INSERT INTO schools (id, name, budget, city) VALUES (1, 'SchoolA', 700000, 'CityB'), (2, 'SchoolB', 600000, 'CityB'), (3, 'SchoolC', 500000, 'CityB');
Which schools have the lowest overall budget per student in CityB?
SELECT s.name, s.budget/COUNT(ds.student_id) as avg_budget_per_student FROM schools s JOIN district_schools ds ON s.id = ds.school_id WHERE s.city = 'CityB' GROUP BY s.name HAVING avg_budget_per_student = (SELECT MIN(s.budget/COUNT(ds.student_id)) FROM schools s JOIN district_schools ds ON s.id = ds.school_id WHERE s.city = 'CityB' GROUP BY s.name);
gretelai_synthetic_text_to_sql
CREATE TABLE co_ownership (property_id INT, city VARCHAR(20)); CREATE TABLE urbanism (property_id INT, city VARCHAR(20), sustainable BOOLEAN); INSERT INTO co_ownership (property_id, city) VALUES (1, 'New_York_City'); INSERT INTO co_ownership (property_id, city) VALUES (2, 'Los_Angeles'); INSERT INTO urbanism (property_id, city, sustainable) VALUES (1, 'New_York_City', true); INSERT INTO urbanism (property_id, city, sustainable) VALUES (2, 'Los_Angeles', false);
What is the number of properties in New York City with co-ownership and sustainable urbanism features?
SELECT COUNT(*) FROM co_ownership INNER JOIN urbanism ON co_ownership.property_id = urbanism.property_id WHERE co_ownership.city = 'New_York_City' AND urbanism.sustainable = true;
gretelai_synthetic_text_to_sql
CREATE TABLE cases (case_id INT, domain TEXT);
What is the total number of cases in the legal services domain?
SELECT COUNT(DISTINCT cases.case_id) FROM cases WHERE cases.domain = 'legal services';
gretelai_synthetic_text_to_sql
CREATE TABLE satellite_deployment (id INT PRIMARY KEY, name VARCHAR(50), launch_year INT, location VARCHAR(50));
Delete all records from the 'satellite_deployment' table where the location is 'not in space'
DELETE FROM satellite_deployment WHERE location != 'Space';
gretelai_synthetic_text_to_sql
CREATE TABLE exoplanets (id INT, name VARCHAR(255), discovery_method VARCHAR(255), discovery_date DATE, telescope VARCHAR(255));
What is the total number of exoplanets discovered by the Kepler space telescope?
SELECT COUNT(*) FROM exoplanets WHERE telescope = 'Kepler';
gretelai_synthetic_text_to_sql
CREATE TABLE autonomous_vehicles (id INT PRIMARY KEY, make VARCHAR(50), model VARCHAR(50), safety_rating FLOAT); INSERT INTO autonomous_vehicles (id, make, model, safety_rating) VALUES (1, 'Tesla', 'Model X', 9.2), (2, 'Waymo', 'Waymo One', 9.5), (3, 'NVIDIA', 'DRIVE AGX', 9.0), (4, 'Baidu', 'Apollo', 8.8), (5, 'Uber', 'ATG', 8.6);
What's the average safety rating of all autonomous vehicles?
SELECT AVG(safety_rating) FROM autonomous_vehicles;
gretelai_synthetic_text_to_sql
CREATE TABLE IndigenousCommunities (CommunityID int, CommunityName varchar(50), Country varchar(50)); INSERT INTO IndigenousCommunities VALUES (1, 'CommunityA', 'Colombia'), (2, 'CommunityB', 'Brazil'), (3, 'CommunityC', 'Canada'); CREATE TABLE ExtractionData (CommunityID int, ExtractionDate date, Material varchar(10), Quantity int); INSERT INTO ExtractionData VALUES (1, '2022-01-01', 'Silver', 1000), (1, '2022-01-15', 'Silver', 1500), (2, '2022-01-30', 'Silver', 800), (1, '2022-02-05', 'Silver', 1200), (3, '2022-03-01', 'Silver', 1000);
What is the total quantity of silver extracted by indigenous communities in Colombia in 2022?
SELECT ic.CommunityName, SUM(ed.Quantity) as TotalExtraction FROM ExtractionData ed JOIN IndigenousCommunities ic ON ed.CommunityID = ic.CommunityID WHERE ed.ExtractionDate BETWEEN '2022-01-01' AND '2022-12-31' AND ed.Material = 'Silver' AND ic.Country = 'Colombia' GROUP BY ic.CommunityName;
gretelai_synthetic_text_to_sql
CREATE TABLE RideHailing (id INT, company VARCHAR(20), vehicle_type VARCHAR(20), num_drivers INT);
Insert a new ride hailing company with EVs and hybrid vehicles.
INSERT INTO RideHailing (id, company, vehicle_type, num_drivers) VALUES (4, 'Juno', 'EV', 1000), (5, 'Juno', 'Hybrid', 2000);
gretelai_synthetic_text_to_sql
CREATE TABLE ChemicalProducts (ProductID INT, Chemical TEXT, ManufacturerID INT, ProductLaunchDate DATE, EnvironmentalImpactScore DECIMAL(3,2)); INSERT INTO ChemicalProducts (ProductID, Chemical, ManufacturerID, ProductLaunchDate, EnvironmentalImpactScore) VALUES (1, 'Acetone', 1, '2020-01-01', 3.2), (2, 'Ethanol', 1, '2020-04-01', 4.5), (3, 'Methanol', 2, '2019-01-01', 5.0), (4, 'Propanol', 2, '2020-06-01', 4.8), (5, 'Butanol', 3, '2020-02-01', 5.0);
What is the average environmental impact score for chemical products launched in Q1 and Q2 of 2020?
SELECT AVG(CP.EnvironmentalImpactScore) AS AverageScore FROM ChemicalProducts CP WHERE QUARTER(CP.ProductLaunchDate) IN (1, 2) AND YEAR(CP.ProductLaunchDate) = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE production (country VARCHAR(255), element VARCHAR(255), quantity INT, year INT, quarter INT); INSERT INTO production (country, element, quantity, year, quarter) VALUES ('China', 'Dysprosium', 10000, 2018, 1), ('China', 'Dysprosium', 12000, 2018, 2), ('China', 'Dysprosium', 14000, 2018, 3), ('China', 'Dysprosium', 16000, 2018, 4), ('China', 'Dysprosium', 18000, 2019, 1);
What is the running total of Dysprosium production by quarter?
SELECT year, quarter, SUM(quantity) OVER (PARTITION BY element ORDER BY year, quarter) as running_total FROM production WHERE element = 'Dysprosium' ORDER BY year, quarter;
gretelai_synthetic_text_to_sql
CREATE TABLE Cephalopods (Species VARCHAR(255), Ocean VARCHAR(255), Population INT);
Add a new record for the Giant Pacific Octopus in the Pacific Ocean with a population of 1500.
INSERT INTO Cephalopods (Species, Ocean, Population) VALUES ('Giant Pacific Octopus', 'Pacific Ocean', 1500);
gretelai_synthetic_text_to_sql
CREATE TABLE smart_city_devices (id INT, name VARCHAR(255), location VARCHAR(255), installed_date DATE); INSERT INTO smart_city_devices (id, name, location, installed_date) VALUES (1, 'SmartBin1', 'CityE', '2021-03-20'), (2, 'SmartLight1', 'CityF', '2021-07-10'), (3, 'SmartSensor1', 'CityE', '2021-04-05'), (4, 'SmartSensor2', 'CityF', '2020-12-20');
Smart city devices installed before 2021-06-01
SELECT name FROM smart_city_devices WHERE installed_date < '2021-06-01' ORDER BY installed_date DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE agricultural_innovation_projects (id INT, country VARCHAR(20), grant_amount DECIMAL(10, 2)); INSERT INTO agricultural_innovation_projects (id, country, grant_amount) VALUES (1, 'Philippines', 5000.00), (2, 'Indonesia', 7000.00);
What is the average amount of grants given for agricultural innovation projects in the Philippines?
SELECT AVG(grant_amount) FROM agricultural_innovation_projects WHERE country = 'Philippines';
gretelai_synthetic_text_to_sql
CREATE TABLE product_details (product_id INT, launch_date DATE, product_category VARCHAR(50), customer_rating FLOAT); INSERT INTO product_details (product_id, launch_date, product_category, customer_rating) VALUES (1001, '2021-02-15', 'makeup', 4.3), (1002, '2021-06-20', 'skincare', 4.1), (1003, '2021-09-01', 'makeup', 4.6), (1004, '2022-01-10', 'haircare', 3.9);
What is the average customer rating for mineral-based makeup products launched in 2021?
SELECT AVG(customer_rating) FROM product_details WHERE product_category = 'makeup' AND launch_date < '2022-01-01' AND EXTRACT(YEAR FROM launch_date) = 2021 AND product_details.product_category IN (SELECT product_category FROM product_details WHERE product_category = 'makeup' AND is_mineral = true);
gretelai_synthetic_text_to_sql
CREATE TABLE vulnerabilities (id INT, vuln_date DATE, asset_type VARCHAR(50)); INSERT INTO vulnerabilities (id, vuln_date, asset_type) VALUES (1, '2021-12-01', 'network'), (2, '2022-01-05', 'server'), (3, '2022-02-10', 'workstation');
How many vulnerabilities were found in the last quarter for the 'network' asset type?
SELECT COUNT(*) as vulnerability_count FROM vulnerabilities WHERE vuln_date >= DATEADD(quarter, -1, GETDATE()) AND asset_type = 'network';
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (id INT, name TEXT, city TEXT, program TEXT); INSERT INTO volunteers (id, name, city, program) VALUES (1, 'John Doe', 'NYC', 'Green City'); INSERT INTO volunteers (id, name, city, program) VALUES (2, 'Jane Smith', 'LA', 'Green City');
What is the total number of volunteers who have participated in 'Green City' program?
SELECT COUNT(*) FROM volunteers WHERE program = 'Green City';
gretelai_synthetic_text_to_sql
CREATE TABLE RestaurantRevenue(restaurant_id INT, revenue DECIMAL(10,2), revenue_date DATE, restaurant_location VARCHAR(255));
What is the total revenue for the month of April 2022 for restaurants located in California?
SELECT SUM(revenue) FROM RestaurantRevenue WHERE revenue_date BETWEEN '2022-04-01' AND '2022-04-30' AND restaurant_location = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE sales (product_category VARCHAR(255), sales_amount NUMERIC, sale_date DATE); INSERT INTO sales (product_category, sales_amount, sale_date) VALUES ('men_shirts', 500, '2022-01-01'); INSERT INTO sales (product_category, sales_amount, sale_date) VALUES ('women_pants', 800, '2022-01-02'); INSERT INTO sales (product_category, sales_amount, sale_date) VALUES ('children_dresses', 400, '2022-01-03');
Find the top 3 product categories with the highest sales in H1 2022.
SELECT product_category, SUM(sales_amount) FROM sales WHERE sale_date BETWEEN '2022-01-01' AND '2022-06-30' GROUP BY product_category ORDER BY SUM(sales_amount) DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE College_of_Engineering_Grants (department VARCHAR(50), grant_awarded BOOLEAN); INSERT INTO College_of_Engineering_Grants (department, grant_awarded) VALUES ('Mechanical Engineering', true), ('Electrical Engineering', false), ('Civil Engineering', true), ('Computer Science and Engineering', true), ('Chemical Engineering', false), ('Biomedical Engineering', true);
Find the number of research grants awarded to each department in the College of Engineering, ordered from the most to least grants.
SELECT department, SUM(grant_awarded) as total_grants FROM College_of_Engineering_Grants GROUP BY department ORDER BY total_grants DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE seattle_households (id INT, water_consumption FLOAT, household_size INT, year INT); INSERT INTO seattle_households (id, water_consumption, household_size, year) VALUES (1, 12000, 4, 2020); INSERT INTO seattle_households (id, water_consumption, household_size, year) VALUES (2, 15000, 5, 2020);
What is the average water consumption per household in the city of Seattle, WA for the year 2020?
SELECT AVG(water_consumption / household_size) FROM seattle_households WHERE year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers (id INT, name TEXT, product TEXT, is_organic BOOLEAN); INSERT INTO suppliers (id, name, product, is_organic) VALUES (1, 'Green Earth Farms', 'Apples', true), (2, 'Fresh Harvest', 'Bananas', true), (3, 'Sunrise Produce', 'Oranges', false), (4, 'Organic Delights', 'Strawberries', true);
Which are the top 3 suppliers of organic fruits?
SELECT name, product FROM suppliers WHERE is_organic = true ORDER BY product LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE cases (case_id INT, case_number VARCHAR(50), client_name VARCHAR(50), attorney_id INT);
List the names and case numbers of cases in 'cases' table that were assigned to attorney_id 5
SELECT cases.case_number, cases.client_name FROM cases WHERE cases.attorney_id = 5;
gretelai_synthetic_text_to_sql
CREATE TABLE MentalHealthParity (ViolationID INT, State VARCHAR(25), Race VARCHAR(25), ViolationDate DATE); INSERT INTO MentalHealthParity (ViolationID, State, Race, ViolationDate) VALUES (1, 'California', 'Asian', '2021-01-15'); INSERT INTO MentalHealthParity (ViolationID, State, Race, ViolationDate) VALUES (2, 'New York', 'African American', '2021-02-20'); INSERT INTO MentalHealthParity (ViolationID, State, Race, ViolationDate) VALUES (3, 'Texas', 'Caucasian', '2021-03-10'); INSERT INTO MentalHealthParity (ViolationID, State, Race, ViolationDate) VALUES (4, 'Florida', 'Hispanic', '2021-04-01');
What is the total number of mental health parity violations for each race?
SELECT Race, COUNT(*) FROM MentalHealthParity GROUP BY Race;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists bioprocess;CREATE TABLE if not exists bioprocess.jobs (id INT, title VARCHAR(50), country VARCHAR(50)); INSERT INTO bioprocess.jobs (id, title, country) VALUES (1, 'JobA', 'France'), (2, 'JobB', 'Spain'), (3, 'JobC', 'France'), (4, 'JobD', 'USA'), (5, 'JobE', 'Spain');
Determine the number of bioprocess engineering jobs in each country.
SELECT country, COUNT(*) FROM bioprocess.jobs GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE game_sessions (session_id INT, player_id INT, session_start_time TIMESTAMP, session_duration INTERVAL);
Create table 'game_sessions' with columns: session_id, player_id, session_start_time, session_duration
CREATE TABLE game_sessions (session_id INT, player_id INT, session_start_time TIMESTAMP, session_duration INTERVAL);
gretelai_synthetic_text_to_sql
CREATE TABLE Artworks (Artist VARCHAR(50), Artwork VARCHAR(50), Year INT);
Add a new artwork by Claude Monet in 1872
INSERT INTO Artworks (Artist, Artwork, Year) VALUES ('Claude Monet', 'Water Lilies', 1872)
gretelai_synthetic_text_to_sql
CREATE TABLE Dishes (dish_id INT, dish_name VARCHAR(50), ingredients VARCHAR(50)); INSERT INTO Dishes (dish_id, dish_name, ingredients) VALUES (1, 'Spaghetti Bolognese', 'Tomatoes, Ground Beef, Pasta'), (2, 'Chicken Curry', 'Chicken, Coconut Milk, Spices'), (3, 'Sushi Roll', 'Fish, Rice, Seaweed'), (4, 'Beef Stew', 'Beef, Carrots, Potatoes'), (5, 'Meat Lovers Pizza', 'Pepperoni, Sausage, Ham, Cheese');
What are the names of dishes that contain more than one type of meat?
SELECT dish_name FROM Dishes WHERE ingredients LIKE '%Meat%' GROUP BY dish_name HAVING COUNT(DISTINCT REGEXP_SPLIT_TO_TABLE(ingredients, '[, ]+')) > 1;
gretelai_synthetic_text_to_sql
CREATE TABLE incident (incident_id INT, incident_date DATE, incident_type VARCHAR(255));
What is the distribution of security incidents by type (e.g., malware, phishing, etc.) for the last 30 days?
SELECT incident_type, COUNT(*) AS incident_count FROM incident WHERE incident_date >= CURDATE() - INTERVAL 30 DAY GROUP BY incident_type;
gretelai_synthetic_text_to_sql
CREATE TABLE digital_assets (id INT, name VARCHAR(255), company VARCHAR(255), launch_date DATE, developer VARCHAR(255)); INSERT INTO digital_assets (id, name, company, launch_date, developer) VALUES (1, 'Asset 1', 'Company A', '2021-01-01', 'Jamila Nguyen'), (2, 'Asset 2', 'Company B', '2022-02-15', 'Minh Tran');
What is the earliest launch date for digital assets created by developers from historically underrepresented communities in Asia?
SELECT MIN(launch_date) FROM digital_assets WHERE developer IN ('Jamila Nguyen', 'Minh Tran') AND country = 'Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, sector TEXT); INSERT INTO companies (id, sector) VALUES (1, 'technology'), (2, 'finance'), (3, 'technology'), (4, 'healthcare');
What's the number of companies in each sector?
SELECT sector, COUNT(*) FROM companies GROUP BY sector;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species_biomass (species_name VARCHAR(255), region VARCHAR(255), biomass FLOAT, conservation_status VARCHAR(255)); INSERT INTO marine_species_biomass (species_name, region, biomass, conservation_status) VALUES ('Polar Bear', 'Arctic', 500, 'Fully Protected'), ('Narwhal', 'Arctic', 300, 'Partially Protected'), ('Ringed Seal', 'Arctic', 200, 'Fully Protected');
What is the total biomass of all marine species in the Arctic region, grouped by conservation status?"
SELECT conservation_status, SUM(biomass) as total_biomass FROM marine_species_biomass WHERE region = 'Arctic' GROUP BY conservation_status;
gretelai_synthetic_text_to_sql
CREATE TABLE national_security_breaches (id INT, country TEXT, breach_date DATE); INSERT INTO national_security_breaches (id, country, breach_date) VALUES (1, 'USA', '2021-01-01'), (2, 'UK', '2021-02-15'), (3, 'USA', '2021-03-01'), (4, 'Canada', '2021-04-15');
Show the number of national security breaches in the last year, and the number of breaches for each country.
SELECT n.country, COUNT(n.id) as total_breaches FROM national_security_breaches n WHERE n.breach_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY n.country;
gretelai_synthetic_text_to_sql
CREATE TABLE CarbonOffset (id INT, project_name VARCHAR(20), project_type VARCHAR(20), amount INT);
Insert a new record into the "CarbonOffset" table for a new "EnergyEfficiencyProject2" in "Rio de Janeiro" with an amount of 8000
INSERT INTO CarbonOffset (project_name, project_type, amount) VALUES ('EnergyEfficiencyProject2', 'energy_efficiency', 8000);
gretelai_synthetic_text_to_sql
CREATE TABLE schedules (route_id INT, vehicle_id INT, departure_time TIME); INSERT INTO schedules VALUES (1, 1, '06:00:00'), (1, 2, '06:15:00'), (1, 3, '06:30:00'), (2, 4, '07:00:00'), (2, 5, '07:15:00');
What are the earliest and latest departure times for buses in the city center?
SELECT MIN(departure_time) AS earliest, MAX(departure_time) AS latest FROM schedules JOIN routes ON schedules.route_id = routes.route_id WHERE routes.city = 'City Center' AND routes.type = 'Bus';
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (DonationID INT, DonorID INT, DonationDate DATE, DonationAmount DECIMAL(10,2));
List all donors who have made donations in the last 6 months
SELECT DonorID, Donations.FirstName, Donations.LastName FROM Donors JOIN Donations ON Donors.DonorID = Donations.DonorID WHERE DonationDate >= DATE_SUB(CURDATE(), INTERVAL 6 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE ArtCollection (ArtworkID INT, ArtistID INT, ArtistNationality VARCHAR(50)); INSERT INTO ArtCollection (ArtworkID, ArtistID, ArtistNationality) VALUES (1, 1, 'American'), (2, 2, 'Canadian'), (3, 3, 'Australian'), (4, 4, 'Indigenous'), (5, 5, 'African');
How many artworks in the 'ArtCollection' table are associated with Indigenous artists?
SELECT COUNT(*) AS ArtworksByIndigenousArtists FROM ArtCollection WHERE ArtistNationality = 'Indigenous';
gretelai_synthetic_text_to_sql
CREATE TABLE populations (id INT, country_id INT, population INT); CREATE TABLE military_personnel (id INT, country_id INT, military_branch_id INT, number INT);
What is the minimum number of military personnel in each branch for countries with a population of over 100 million?
SELECT m.name as branch, MIN(mp.number) as min_personnel FROM populations p JOIN military_personnel mp ON p.country_id = mp.country_id JOIN military_branch m ON mp.military_branch_id = m.id WHERE p.population > 100000000 GROUP BY mp.military_branch_id;
gretelai_synthetic_text_to_sql
CREATE TABLE heritage_sites (id INT, name TEXT, country TEXT, region TEXT); INSERT INTO heritage_sites (id, name, country, region) VALUES (1, 'Great Zimbabwe', 'Zimbabwe', 'Africa');
What is the total number of heritage sites in Africa?
SELECT COUNT(*) FROM heritage_sites WHERE region = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE GARMENTS (garment_id INT, category VARCHAR(20), production_cost FLOAT); INSERT INTO GARMENTS VALUES (1, 'T-Shirts', 10), (2, 'Pants', 15), (3, 'Jackets', 20), (4, 'Dresses', 25);
Show garment categories with production costs lower than the average production cost for all garment categories.
SELECT category, production_cost FROM GARMENTS WHERE production_cost < (SELECT AVG(production_cost) FROM GARMENTS);
gretelai_synthetic_text_to_sql
CREATE TABLE market_trend_table (rare_earth_element VARCHAR(20), year INT, price FLOAT, demand_volume INT);
Update records in the market_trend_table for 'Gadolinium', setting the 'price' to 34.8 and 'demand_volume' to 1550 for year 2019
UPDATE market_trend_table SET price = 34.8, demand_volume = 1550 WHERE rare_earth_element = 'Gadolinium' AND year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE electric_trains (train_id INT, co2_emission FLOAT, city VARCHAR(50));
What is the average CO2 emission of electric trains in Madrid?
SELECT AVG(co2_emission) FROM electric_trains WHERE city = 'Madrid';
gretelai_synthetic_text_to_sql
CREATE TABLE threat_intelligence(report_date DATE, report_category VARCHAR(20)); INSERT INTO threat_intelligence(report_date, report_category) VALUES ('2021-01-01', 'cyber'), ('2021-01-05', 'terrorism'), ('2021-02-01', 'cyber'), ('2021-03-01', 'foreign_intelligence'), ('2021-03-05', 'foreign_intelligence');
Show the number of days between the earliest and latest threat intelligence reports for each category.
SELECT report_category, MAX(report_date) - MIN(report_date) as days_between FROM threat_intelligence GROUP BY report_category;
gretelai_synthetic_text_to_sql
CREATE TABLE UserData (UserID INT, Country VARCHAR(255)); CREATE TABLE WorkoutData (UserID INT, CaloriesBurned INT, WorkoutDate DATE); INSERT INTO UserData (UserID, Country) VALUES (1, 'India'), (2, 'Australia'), (3, 'India'), (4, 'South Africa'), (5, 'India'); INSERT INTO WorkoutData (UserID, CaloriesBurned, WorkoutDate) VALUES (1, 300, '2022-06-01'), (1, 350, '2022-06-02'), (2, 250, '2022-06-01'), (3, 400, '2022-06-01'), (3, 300, '2022-06-02'), (4, 200, '2022-06-01'), (5, 350, '2022-06-02');
What is the average calories burned for users from India during their workouts in the month of June 2022?
SELECT AVG(CaloriesBurned) FROM WorkoutData INNER JOIN UserData ON WorkoutData.UserID = UserData.UserID WHERE Country = 'India' AND WorkoutDate >= '2022-06-01' AND WorkoutDate <= '2022-06-30';
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, name VARCHAR(50), country VARCHAR(50), meal_calories INT); INSERT INTO users (id, name, country, meal_calories) VALUES (1, 'John Doe', 'Canada', 600), (2, 'Jane Smith', 'Canada', 800);
What is the average calorie intake per meal for Canadian users?
SELECT AVG(meal_calories) FROM users WHERE country = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE geological_survey (id INT, mine_id INT, rock_type VARCHAR(50), FOREIGN KEY (mine_id) REFERENCES mines(id)); INSERT INTO geological_survey (id, mine_id, rock_type) VALUES (5, 9, 'Limestone'); INSERT INTO geological_survey (id, mine_id, rock_type) VALUES (6, 10, 'Sandstone'); CREATE TABLE mines (id INT, name VARCHAR(50), location VARCHAR(50), production_metric FLOAT, PRIMARY KEY(id)); INSERT INTO mines (id, name, location, production_metric) VALUES (9, 'Westfield Mine', 'Utah', 45000); INSERT INTO mines (id, name, location, production_metric) VALUES (10, 'Windy Ridge', 'Utah', 32000);
List the rock types in mines with a production metric between 30000 and 50000, and located in Utah.
SELECT gs.rock_type FROM geological_survey gs JOIN mines m ON gs.mine_id = m.id WHERE m.production_metric BETWEEN 30000 AND 50000 AND m.location = 'Utah';
gretelai_synthetic_text_to_sql
CREATE TABLE teachers (id INT, name VARCHAR(20), last_pd_date DATE); INSERT INTO teachers (id, name, last_pd_date) VALUES (1, 'Ms. Garcia', '2020-01-01'); INSERT INTO teachers (id, name, last_pd_date) VALUES (2, 'Mr. Nguyen', '2021-06-15'); INSERT INTO teachers (id, name, last_pd_date) VALUES (3, 'Mx. Patel', '2019-12-31'); INSERT INTO teachers (id, name, last_pd_date) VALUES (4, 'Mrs. Chen', '2021-03-05');
Show teachers who have not received any professional development in the last 2 years
SELECT name FROM teachers WHERE last_pd_date < DATE_SUB(CURRENT_DATE, INTERVAL 2 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE Programs (id INT, program TEXT, budget DECIMAL(10,2)); INSERT INTO Programs (id, program, budget) VALUES (1, 'Feeding the Hungry', 5000.00), (2, 'Clothing Drive', 3000.00);
What is the total budget for each program?
SELECT program, SUM(budget) FROM Programs GROUP BY program;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, Gender VARCHAR(10), JobTitle VARCHAR(50), Salary INT); INSERT INTO Employees (EmployeeID, Gender, JobTitle, Salary) VALUES (1, 'Male', 'Manager', 70000), (2, 'Female', 'Manager', 65000), (3, 'Male', 'Developer', 60000), (4, 'Female', 'Developer', 62000);
What is the difference in average salary between the top and bottom quartile of employees, by job title?
SELECT JobTitle, AVG(CASE WHEN PERCENT_RANK() OVER (PARTITION BY JobTitle ORDER BY Salary) BETWEEN 0 AND 0.25 THEN Salary ELSE NULL END) - AVG(CASE WHEN PERCENT_RANK() OVER (PARTITION BY JobTitle ORDER BY Salary) BETWEEN 0.75 AND 1 THEN Salary ELSE NULL END) AS Salary_Difference FROM Employees GROUP BY JobTitle;
gretelai_synthetic_text_to_sql
CREATE TABLE ClaimsData (ClaimID INT, Payment DECIMAL(5,2), State VARCHAR(20)); INSERT INTO ClaimsData VALUES (1, 500.00, 'California'), (2, 1500.00, 'Texas'), (3, 800.00, 'California');
Which claims had a payment amount greater than $1000 in Texas?
SELECT ClaimID, Payment FROM ClaimsData WHERE State = 'Texas' AND Payment > 1000;
gretelai_synthetic_text_to_sql
CREATE TABLE legal_aid_cases (id INT, lawyer_name TEXT, lawyer_community TEXT); INSERT INTO legal_aid_cases (id, lawyer_name, lawyer_community) VALUES (1, 'Aisha Williams', 'African American'); INSERT INTO legal_aid_cases (id, lawyer_name, lawyer_community) VALUES (2, 'Pedro Rodriguez', 'Hispanic');
What is the total number of legal aid cases handled by lawyers from historically underrepresented communities?
SELECT COUNT(*) FROM legal_aid_cases WHERE lawyer_community IN ('African American', 'Hispanic', 'Indigenous', 'Asian Pacific Islander');
gretelai_synthetic_text_to_sql
CREATE TABLE sales (sale_id INT, dispensary_id INT, strain VARCHAR(255), quantity INT, price INT);CREATE TABLE dispensaries (dispensary_id INT, name VARCHAR(255), state VARCHAR(255));
What are the top 3 strains with the highest average price in Colorado and Washington?
SELECT strain, AVG(price) as avg_price FROM sales JOIN dispensaries ON sales.dispensary_id = dispensaries.dispensary_id WHERE state IN ('Colorado', 'Washington') GROUP BY strain HAVING COUNT(*) > 5 ORDER BY avg_price DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, donor_id INT, org_id INT, zip_code TEXT, donation_amount DECIMAL(10,2)); INSERT INTO donations (id, donor_id, org_id, zip_code, donation_amount) VALUES (1, 1, 1, '90210', 100.00);
What are the top 3 zip codes with the highest total donation amounts in 'California'?
SELECT zip_code, SUM(donation_amount) AS total_donated FROM donations WHERE zip_code LIKE '90%' GROUP BY zip_code ORDER BY total_donated DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Emissions (chemical VARCHAR(20), emission_rate INT, location VARCHAR(20)); INSERT INTO Emissions (chemical, emission_rate, location) VALUES ('ChemicalD', 150, 'Western'), ('ChemicalE', 170, 'Western');
Which chemical has the highest emission rate in the Western region?
SELECT chemical, emission_rate FROM Emissions WHERE location = 'Western' ORDER BY emission_rate DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT, dispensary_name TEXT, state TEXT, revenue INT, date DATE); INSERT INTO sales (id, dispensary_name, state, revenue, date) VALUES (1, 'Dispensary A', 'California', 2000, '2022-01-01'); INSERT INTO sales (id, dispensary_name, state, revenue, date) VALUES (2, 'Dispensary B', 'Colorado', 3000, '2022-01-02'); INSERT INTO sales (id, dispensary_name, state, revenue, date) VALUES (3, 'Dispensary C', 'Washington', 1500, '2022-01-03'); INSERT INTO sales (id, dispensary_name, state, revenue, date) VALUES (4, 'Dispensary D', 'California', 2500, '2022-01-04'); INSERT INTO sales (id, dispensary_name, state, revenue, date) VALUES (5, 'Dispensary E', 'Colorado', 1000, '2022-01-05'); INSERT INTO sales (id, dispensary_name, state, revenue, date) VALUES (6, 'Dispensary F', 'Washington', 4000, '2022-01-06');
List the top 3 states with the highest total revenue in 2022.
SELECT state, SUM(revenue) AS total_revenue FROM sales WHERE date BETWEEN '2022-01-01' AND '2022-12-31' GROUP BY state ORDER BY total_revenue DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE courses (course_id INT, course_name TEXT, added_date DATE); INSERT INTO courses (course_id, course_name, added_date) VALUES (1, 'Intro to Psychology', '2022-01-05');
Which courses were added in the last month?
SELECT * FROM courses WHERE added_date >= DATEADD(month, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE hospitals (id INT, name VARCHAR(50), location VARCHAR(50), equipment_count INT);
Find the total number of medical equipment items owned by hospitals in Africa.
SELECT SUM(equipment_count) FROM hospitals WHERE location LIKE '%Africa%';
gretelai_synthetic_text_to_sql
CREATE TABLE criminal_justice_reform_programs (id INT, case_number INT, program_type VARCHAR(20));
What is the total number of cases in criminal justice reform programs by program type?
SELECT program_type, COUNT(*) FROM criminal_justice_reform_programs GROUP BY program_type;
gretelai_synthetic_text_to_sql
CREATE TABLE diversity_metrics (metric_id INT, category VARCHAR(20), value FLOAT);
Insert data into diversity metrics table
INSERT INTO diversity_metrics (metric_id, category, value) VALUES (1, 'Female Founders', 0.35), (2, 'Underrepresented Racial Groups', 0.18), (3, 'LGBTQ+ Founders', 0.05);
gretelai_synthetic_text_to_sql
CREATE TABLE ad_revenue (post_id INT, region VARCHAR(20), revenue DECIMAL(10,2), ad_date DATE); INSERT INTO ad_revenue (post_id, region, revenue, ad_date) VALUES (1, 'North America', 100, '2022-01-01'), (2, 'Middle East', 200, '2022-02-01'), (3, 'Middle East', 300, '2022-03-01'), (4, 'Europe', 400, '2022-04-01'), (5, 'Middle East', 500, '2022-05-01');
What is the maximum advertising revenue generated in the "Middle East" region in the last month?
SELECT MAX(revenue) FROM ad_revenue WHERE region = 'Middle East' AND ad_date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (hotel_id INT, name VARCHAR(50), facility VARCHAR(50)); INSERT INTO hotels (hotel_id, name, facility) VALUES (1, 'Hotel X', 'spa,gym'), (2, 'Hotel Y', 'gym'), (3, 'Hotel Z', 'spa');
List the hotels in the hotels table that offer a gym facility but do not offer a spa facility.
SELECT * FROM hotels WHERE facility LIKE '%gym%' AND facility NOT LIKE '%spa%';
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (id INT, species VARCHAR(255), habitat VARCHAR(255), invasive BOOLEAN); INSERT INTO marine_species (id, species, habitat, invasive) VALUES (1, 'Pacific Oyster', 'Baltic Sea', TRUE), (2, 'Green Crab', 'North Sea', FALSE);
List all invasive marine species in the Baltic Sea.
SELECT species FROM marine_species WHERE habitat = 'Baltic Sea' AND invasive = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE green_buildings (project_number INT, project_name VARCHAR(30), start_date DATE, end_date DATE); INSERT INTO green_buildings (project_number, project_name, start_date, end_date) VALUES (1, 'Solar Panel Installation', '2020-01-01', '2020-03-15'); INSERT INTO green_buildings (project_number, project_name, start_date, end_date) VALUES (2, 'Wind Turbine Construction', '2019-06-01', '2020-01-05');
What is the total duration of the longest project in the 'green_buildings' table?
SELECT DATEDIFF(end_date, start_date) FROM green_buildings ORDER BY DATEDIFF(end_date, start_date) DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE sales_country (product_id INT, brand VARCHAR(255), country VARCHAR(255), revenue FLOAT); INSERT INTO sales_country (product_id, brand, country, revenue) VALUES (1, 'Lush', 'UK', 50), (2, 'The Body Shop', 'France', 75), (3, 'Sephora', 'USA', 100);
What is the total revenue for each country's products?
SELECT country, SUM(revenue) as total_revenue FROM sales_country GROUP BY country ORDER BY total_revenue DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Researchers (id INT PRIMARY KEY, name VARCHAR(255), affiliation VARCHAR(255)); INSERT INTO Researchers (id, name, affiliation) VALUES (1, 'Sara Ahmed', 'University of Ottawa'); CREATE TABLE Expeditions (id INT PRIMARY KEY, leader_id INT, start_date DATE); INSERT INTO Expeditions (id, leader_id, start_date) VALUES (1, 1, '2022-03-01');
What is the name of the researcher who leads the expedition starting on 2022-03-01?
SELECT name FROM Researchers INNER JOIN Expeditions ON Researchers.id = Expeditions.leader_id WHERE start_date = '2022-03-01';
gretelai_synthetic_text_to_sql
CREATE TABLE CrimeStats (city VARCHAR(255), year INT, crimeType VARCHAR(255), totalCrimes INT); INSERT INTO CrimeStats (city, year, crimeType, totalCrimes) VALUES ('New York City', 2019, 'Homicide', 300), ('New York City', 2020, 'Homicide', 350);
What is the average number of homicides in New York City per year?
SELECT AVG(totalCrimes) AS avg_homicides FROM CrimeStats WHERE city = 'New York City' AND crimeType = 'Homicide';
gretelai_synthetic_text_to_sql
CREATE TABLE socially_responsible_lending (id INT, year INT, country VARCHAR(255), loans INT);
How many socially responsible loans have been issued in Canada for each year?
SELECT year, SUM(loans) FROM socially_responsible_lending WHERE country = 'Canada' GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_facts (name TEXT, fact TEXT); INSERT INTO ocean_facts (name, fact) VALUES ('Indian Ocean', '3,741 meters deep on average'); CREATE TABLE depths (name TEXT, avg_depth FLOAT); INSERT INTO depths (name, avg_depth) VALUES ('Indian Ocean', 3741);
What is the average depth of the Indian Ocean?
SELECT avg_depth FROM depths WHERE name = 'Indian Ocean';
gretelai_synthetic_text_to_sql