context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE players (id INT, has_vr BOOLEAN); INSERT INTO players (id, has_vr) VALUES (1, TRUE), (2, FALSE), (3, TRUE), (4, FALSE), (5, TRUE);
|
What is the total number of players who have adopted VR technology?
|
SELECT COUNT(*) FROM players WHERE has_vr = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customers (customer_id INT, name VARCHAR(50), data_usage FLOAT, region VARCHAR(50), usage_date DATE); INSERT INTO customers (customer_id, name, data_usage, region, usage_date) VALUES (1, 'John Doe', 45.6, 'North', '2022-01-01'), (2, 'Jane Smith', 30.9, 'South', '2022-02-01'), (3, 'Mike Johnson', 60.7, 'East', '2022-03-01'); CREATE TABLE regions (region_id INT, region_name VARCHAR(50)); INSERT INTO regions (region_id, region_name) VALUES (1, 'North'), (2, 'South'), (3, 'East'), (4, 'West');
|
What is the total data usage, in GB, for each customer in the last 3 months, partitioned by region, and ordered by the most data usage?
|
SELECT customer_id, region, SUM(data_usage) as total_data_usage, DENSE_RANK() OVER (ORDER BY SUM(data_usage) DESC) as data_usage_rank FROM customers c JOIN regions r ON c.region = r.region_name WHERE usage_date >= DATEADD(month, -3, GETDATE()) GROUP BY customer_id, region ORDER BY total_data_usage DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ratings (rating_id INT, menu_id INT, customer_id INT, rating FLOAT, review VARCHAR(255));
|
What is the most popular dish in each category?
|
SELECT menu_id, category, MAX(rating) as max_rating FROM menus JOIN ratings ON menus.menu_id = ratings.menu_id GROUP BY category;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MedicalRecords (id INT, astronaut_id INT, start_date DATE, end_date DATE); INSERT INTO MedicalRecords (id, astronaut_id, start_date, end_date) VALUES (1, 1, '2010-01-01', '2010-01-10'), (2, 2, '2012-05-01', '2012-06-01');
|
What is the maximum duration of astronaut medical records in days?
|
SELECT MAX(DATEDIFF(end_date, start_date)) FROM MedicalRecords;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE terbium_production (year INT, production_volume FLOAT);
|
What is the total production volume of Terbium for 2020 and 2021?
|
SELECT SUM(production_volume) FROM terbium_production WHERE year IN (2020, 2021);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hospitals (id INT, name TEXT, state TEXT, location TEXT, type TEXT, num_beds INT); INSERT INTO hospitals (id, name, state, location, type, num_beds) VALUES (1, 'Hospital A', 'State A', 'Urban', 'Teaching', 200), (2, 'Hospital B', 'State B', 'Rural', 'Community', 150), (3, 'Hospital C', 'State A', 'Urban', 'Specialty', 100); CREATE TABLE clinics (id INT, name TEXT, state TEXT, location TEXT, type TEXT, num_providers INT); INSERT INTO clinics (id, name, state, location, type, num_providers) VALUES (1, 'Clinic X', 'State A', 'Urban', 'Specialty Care', 10), (2, 'Clinic Y', 'State B', 'Rural', 'Urgent Care', 8), (3, 'Clinic Z', 'State A', 'Urban', 'Primary Care', 12);
|
What is the number of hospitals and clinics in each state, ordered by the number of hospitals, descending?
|
SELECT h.state, COUNT(h.id) as num_hospitals, COUNT(c.id) as num_clinics FROM hospitals h FULL OUTER JOIN clinics c ON h.state = c.state GROUP BY h.state ORDER BY num_hospitals DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE infrastructure_projects (id INT, name TEXT, location TEXT); INSERT INTO infrastructure_projects (id, name, location) VALUES (1, 'Brooklyn Bridge', 'USA'); INSERT INTO infrastructure_projects (id, name, location) VALUES (2, 'Chunnel', 'UK'); INSERT INTO infrastructure_projects (id, name, location) VALUES (3, 'Tokyo Tower', 'Japan'); INSERT INTO infrastructure_projects (id, name, location) VALUES (4, 'Sydney Opera House', 'Australia');
|
Delete all projects in Australia
|
DELETE FROM infrastructure_projects WHERE location = 'Australia';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Employees (EmployeeID int, Name varchar(50), Department varchar(50)); CREATE TABLE Training (TrainingID int, EmployeeID int, TrainingName varchar(50), TrainingCost decimal(10,2), TrainingDate date); INSERT INTO Employees (EmployeeID, Name, Department) VALUES (1, 'John Doe', 'Sales'); INSERT INTO Training (TrainingID, EmployeeID, TrainingName, TrainingCost, TrainingDate) VALUES (1, 1, 'Sales Training', 500.00, '2021-01-10'); INSERT INTO Training (TrainingID, EmployeeID, TrainingName, TrainingCost, TrainingDate) VALUES (2, 1, 'Sales Training', 500.00, '2021-04-15');
|
What are the total training costs for the Sales department for each quarter in 2021?
|
SELECT DATE_FORMAT(TrainingDate, '%Y-%m') AS Quarter, Department, SUM(TrainingCost) AS TotalCost FROM Training t JOIN Employees e ON t.EmployeeID = e.EmployeeID WHERE YEAR(TrainingDate) = 2021 AND Department = 'Sales' GROUP BY Quarter;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE PatientDemographics (PatientID INT, Age INT, Gender VARCHAR(10), Condition VARCHAR(50), TreatmentDate DATE, State VARCHAR(20));
|
How many patients with a mental health condition have been treated in each state in the past year?
|
SELECT State, COUNT(*) FROM PatientDemographics WHERE TreatmentDate >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR) GROUP BY State;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE safety_incidents (incident_id INT, industry TEXT, incident_date DATE); INSERT INTO safety_incidents (incident_id, industry, incident_date) VALUES (1, 'transportation', '2021-01-05'), (2, 'transportation', '2021-02-12'), (3, 'retail', '2021-03-20');
|
How many workplace safety incidents have been reported in the 'transportation' industry by month in 2021?
|
SELECT industry, MONTH(incident_date) AS month, COUNT(*) OVER (PARTITION BY industry, MONTH(incident_date)) FROM safety_incidents WHERE industry = 'transportation' AND YEAR(incident_date) = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE agriculture (id INT, gender TEXT, union_member BOOLEAN); INSERT INTO agriculture (id, gender, union_member) VALUES (1, 'Female', TRUE), (2, 'Male', FALSE), (3, 'Female', TRUE), (4, 'Male', TRUE);
|
What is the percentage of female union members in the agriculture sector?
|
SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM agriculture WHERE union_member = TRUE)) FROM agriculture WHERE gender = 'Female';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customers (id INT, name VARCHAR(50), age INT, account_balance DECIMAL(10, 2), assets DECIMAL(10, 2)); INSERT INTO customers (id, name, age, account_balance, assets) VALUES (1, 'Jane Smith', 50, 10000.00, 50000.00); CREATE TABLE categories (id INT, customer_id INT, category VARCHAR(20)); INSERT INTO categories (id, customer_id, category) VALUES (1, 1, 'High Net Worth');
|
What is the total value of assets for all customers in the 'High Net Worth' category?
|
SELECT SUM(assets) FROM customers JOIN categories ON customers.id = categories.customer_id WHERE category = 'High Net Worth';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hotels (id INT, hotel_name VARCHAR(50), country VARCHAR(50), revenue INT);
|
What is the total revenue generated by the hotels table for each country?
|
SELECT country, SUM(revenue) FROM hotels GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE initiatives (id INT, name VARCHAR(255), country VARCHAR(255), type VARCHAR(255)); INSERT INTO initiatives (id, name, country, type) VALUES (1, 'Project A', 'Brazil', 'Social Good'), (2, 'Project B', 'India', 'Social Good'), (3, 'Project C', 'Brazil', 'Social Good'), (4, 'Project D', 'South Africa', 'Social Good'), (5, 'Project E', 'United States', 'Social Good');
|
List the top 3 countries with the highest number of social good technology initiatives.
|
SELECT country, COUNT(*) as initiative_count FROM initiatives WHERE type = 'Social Good' GROUP BY country ORDER BY initiative_count DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ArtConservation (art_category VARCHAR(255), conservation_date DATE, cost DECIMAL(10,2)); INSERT INTO ArtConservation (art_category, conservation_date, cost) VALUES ('Painting', '2022-01-02', 1000.00), ('Sculpture', '2022-01-03', 1500.00), ('Painting', '2022-03-05', 1200.00), ('Sculpture', '2022-02-10', 1800.00);
|
What is the total conservation cost for each art category?
|
SELECT art_category, SUM(cost) as Total_Conservation_Cost FROM ArtConservation GROUP BY art_category;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE journalists (id INT, name VARCHAR(50), age INT, gender VARCHAR(10));
|
What is the average age of all female authors in the "journalists" table?
|
SELECT AVG(age) FROM journalists WHERE gender = 'female';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE fare (fare_id INT, route_id INT, passenger_count INT, fare_amount FLOAT, payment_method VARCHAR(255)); INSERT INTO fare (fare_id, route_id, passenger_count, fare_amount, payment_method) VALUES (3, 5, 3, 32.0, 'Credit Card'); INSERT INTO fare (fare_id, route_id, passenger_count, fare_amount, payment_method) VALUES (4, 6, 1, 15.00, 'Cash');
|
What is the total fare collected and the number of unique passengers for routes with a fare amount greater than $30?
|
SELECT route_id, SUM(fare_amount) as total_fare, COUNT(DISTINCT passenger_count) as unique_passengers FROM fare WHERE fare_amount > 30 GROUP BY route_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE organic_cotton (brand VARCHAR(50), quantity INT, year INT); INSERT INTO organic_cotton (brand, quantity, year) VALUES ('BrandA', 12000, 2021), ('BrandB', 18000, 2021), ('BrandC', 9000, 2021);
|
What is the total quantity of organic cotton used by brands in 2021?
|
SELECT SUM(quantity) FROM organic_cotton WHERE year = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE digital_assets (asset_id VARCHAR(42), asset_type VARCHAR(20), country VARCHAR(2)); INSERT INTO digital_assets (asset_id, asset_type, country) VALUES ('0x1234567890123456789012345678901234567890', 'Security Token', 'CA');
|
Delete records from the "digital_assets" table where "asset_type" is "Security Token" and "country" is "Canada"
|
DELETE FROM digital_assets WHERE asset_type = 'Security Token' AND country = 'CA';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Customer (id INT PRIMARY KEY, name VARCHAR(50), country VARCHAR(50), size VARCHAR(50));
|
Add a new record to the 'Customer' table for 'Alicia' from 'USA' who prefers 'Plus Size'
|
INSERT INTO Customer (id, name, country, size) VALUES (100, 'Alicia', 'USA', 'Plus Size');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE company_founding (company_name VARCHAR(255), founder_gender VARCHAR(10), founder_race VARCHAR(50)); INSERT INTO company_founding (company_name, founder_gender, founder_race) VALUES ('Delta Enterprises', 'Female', 'African American'), ('Echo Startups', 'Male', 'Asian'), ('Foxtrot LLC', 'Female', 'Hispanic'), ('Golf Inc', 'Male', 'Caucasian'); CREATE TABLE company_industry (company_name VARCHAR(255), industry VARCHAR(50)); INSERT INTO company_industry (company_name, industry) VALUES ('Delta Enterprises', 'Technology'), ('Delta Enterprises', 'Retail'), ('Echo Startups', 'Technology'), ('Foxtrot LLC', 'Retail'), ('Foxtrot LLC', 'Technology'), ('Golf Inc', 'Sports'); CREATE TABLE funding (company_name VARCHAR(255), funding_amount INT); INSERT INTO funding (company_name, funding_amount) VALUES ('Delta Enterprises', 600000), ('Delta Enterprises', 400000), ('Echo Startups', 750000), ('Foxtrot LLC', 500000), ('Golf Inc', 800000);
|
Show the total funding amount for companies with female founders in the technology industry
|
SELECT SUM(funding_amount) FROM funding WHERE company_name IN (SELECT company_name FROM company_founding f JOIN company_industry i ON f.company_name = i.company_name WHERE f.founder_gender = 'Female' AND i.industry = 'Technology');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE TransportInfrastructure (id INT, division VARCHAR(20), year INT, completed INT); INSERT INTO TransportInfrastructure (id, division, year, completed) VALUES (1, 'East', 2021, 1), (2, 'West', 2020, 1), (3, 'North', 2021, 1);
|
How many transport infrastructure projects were completed in 2021 for each division?
|
SELECT division, COUNT(*) as num_projects FROM TransportInfrastructure WHERE year = 2021 GROUP BY division;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE states (id INT, name VARCHAR(255)); INSERT INTO states (id, name) VALUES (1, 'Alabama'), (2, 'Alaska'); CREATE TABLE incidents (id INT, state_id INT, incident_date DATE, incident_type VARCHAR(255)); INSERT INTO incidents (id, state_id, incident_date, incident_type) VALUES (1, 1, '2021-08-15', 'Child Labor'), (2, 1, '2021-05-03', 'Unfair Pay');
|
List the top 5 states with the highest number of labor rights violation incidents in the last 12 months.
|
SELECT s.name, COUNT(*) as total_incidents FROM incidents i JOIN states s ON i.state_id = s.id WHERE i.incident_date >= DATE(NOW()) - INTERVAL 12 MONTH GROUP BY s.name ORDER BY total_incidents DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA if not exists biotech;CREATE TABLE if not exists biotech.startups (id INT, name VARCHAR(100), industry_segment VARCHAR(50), funding DECIMAL(10,2));INSERT INTO biotech.startups (id, name, industry_segment, funding) VALUES (1, 'StartupA', 'Pharmaceuticals', 5000000.00), (2, 'StartupB', 'Bioinformatics', 7000000.00), (3, 'StartupC', 'Biosensors', 3000000.00);
|
What is the total funding for biotech startups by industry segment?
|
SELECT industry_segment, SUM(funding) as total_funding FROM biotech.startups GROUP BY industry_segment;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE production (id INT, location VARCHAR(20), volume INT); INSERT INTO production (id, location, volume) VALUES (1, 'Canada', 55000); INSERT INTO production (id, location, volume) VALUES (2, 'Canada', 65000); INSERT INTO production (id, location, volume) VALUES (3, 'Brazil', 45000);
|
What is the total production volume in Canada?
|
SELECT SUM(volume) FROM production WHERE location = 'Canada';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE fare_collection (id INT, vehicle_type VARCHAR(20), fare_date DATE, fare FLOAT); INSERT INTO fare_collection (id, vehicle_type, fare_date, fare) VALUES (1, 'Bus', '2021-01-01', 2.0), (2, 'Tram', '2021-01-03', 2.5), (3, 'Train', '2021-01-05', 3.0), (4, 'Bus', '2021-01-07', 2.2), (5, 'Tram', '2021-01-09', 2.8), (6, 'Train', '2021-01-11', 3.2);
|
What was the median fare for each vehicle type in the first quarter of 2021?
|
SELECT vehicle_type, AVG(fare) as median_fare FROM (SELECT vehicle_type, fare, ROW_NUMBER() OVER (PARTITION BY vehicle_type ORDER BY fare) as rn, COUNT(*) OVER (PARTITION BY vehicle_type) as cnt FROM fare_collection WHERE fare_date BETWEEN '2021-01-01' AND '2021-03-31' GROUP BY vehicle_type, fare) x WHERE rn IN (cnt/2 + 1, cnt/2 + 2) GROUP BY vehicle_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE tours (id INT, type TEXT, country TEXT, guests INT); INSERT INTO tours (id, type, country, guests) VALUES (1, 'Virtual Tour of the Alhambra', 'Spain', 500), (2, 'In-person Tour of the Prado Museum', 'Spain', 300), (3, 'Virtual Tour of the Guggenheim Museum', 'Spain', 400);
|
What is the total number of guests who have taken virtual tours in Spain?
|
SELECT SUM(guests) FROM tours WHERE type = 'Virtual Tour' AND country = 'Spain';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Inventory (WarehouseId INT, Product VARCHAR(50), Quantity INT, Category VARCHAR(50)); INSERT INTO Inventory (WarehouseId, Product, Quantity, Category) VALUES (1, 'Laptop', 100, 'Electronics'); INSERT INTO Inventory (WarehouseId, Product, Quantity, Category) VALUES (1, 'Monitor', 200, 'Electronics'); INSERT INTO Inventory (WarehouseId, Product, Quantity, Category) VALUES (2, 'Keyboard', 300, 'Electronics'); INSERT INTO Inventory (WarehouseId, Product, Quantity, Category) VALUES (2, 'Chair', 50, 'Furniture');
|
What is the average quantity of items in stock per product category?
|
SELECT Category, AVG(Quantity) AS AvgQuantity FROM Inventory GROUP BY Category;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Employees (EmployeeID int, Department varchar(20), Salary numeric(10,2)); INSERT INTO Employees (EmployeeID, Department, Salary) VALUES (1, 'IT', 75000.00), (2, 'Management', 90000.00), (3, 'HR', 60000.00);
|
What is the maximum salary for employees in the management department?
|
SELECT MAX(Salary) FROM Employees WHERE Department = 'Management';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE buildings (building_id INT, city VARCHAR(20), green_rating INT, rent INT); INSERT INTO buildings (building_id, city, green_rating, rent) VALUES (1, 'Berlin', 5, 1500), (2, 'Berlin', 4, 1400), (3, 'Paris', 5, 2000);
|
What is the 2nd highest rent in the greenest buildings in Berlin?
|
SELECT LEAD(rent) OVER (ORDER BY green_rating DESC, rent DESC) as second_highest_rent FROM buildings WHERE city = 'Berlin' AND green_rating = (SELECT MAX(green_rating) FROM buildings WHERE city = 'Berlin');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE users (user_id INT, username VARCHAR(20), region VARCHAR(20));CREATE TABLE transactions (transaction_id INT, user_id INT, amount DECIMAL(10,2), transaction_time TIMESTAMP, region VARCHAR(20));
|
Identify users who made transactions in both the US and Canada?
|
SELECT DISTINCT user_id FROM transactions t1 JOIN transactions t2 ON t1.user_id = t2.user_id WHERE t1.region = 'US' AND t2.region = 'Canada';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE criminal_justice (court_case_id INT, court_type VARCHAR(20), location VARCHAR(20), case_status VARCHAR(20)); INSERT INTO criminal_justice (court_case_id, court_type, location, case_status) VALUES (1, 'Supreme_Court', 'NY', 'Open'), (2, 'District_Court', 'NY', 'Closed'), (3, 'Supreme_Court', 'CA', 'Open'), (4, 'District_Court', 'CA', 'Closed'), (5, 'Supreme_Court', 'TX', 'Open'), (6, 'District_Court', 'TX', 'Closed'), (7, 'Court_of_Appeals', 'IL', 'Open'), (8, 'District_Court', 'IL', 'Closed'), (9, 'Supreme_Court', 'IL', 'Open'), (10, 'District_Court', 'IL', 'Closed');
|
Find the total number of court_cases in the criminal_justice table, grouped by court_type, but exclude the records for 'NY' and 'TX' locations.
|
SELECT court_type, COUNT(*) FROM criminal_justice WHERE location NOT IN ('NY', 'TX') GROUP BY court_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE military_personnel(personnel_id INT, assignment VARCHAR(255), region VARCHAR(255)); INSERT INTO military_personnel(personnel_id, assignment, region) VALUES (1, 'Intelligence', 'Asia-Pacific'), (2, 'Cybersecurity', 'Europe'), (3, 'Logistics', 'North America');
|
How many military personnel are currently assigned to intelligence operations in the Asia-Pacific region?
|
SELECT COUNT(*) FROM military_personnel WHERE assignment = 'Intelligence' AND region = 'Asia-Pacific';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Dispensaries (id INT, name TEXT, state TEXT); INSERT INTO Dispensaries (id, name, state) VALUES (1, 'Dispensary A', 'California'), (2, 'Dispensary B', 'Oregon'), (3, 'Dispensary C', 'Washington'); CREATE TABLE Strains (id INT, strain TEXT, thc_content REAL, dispensary_id INT); INSERT INTO Strains (id, strain, thc_content, dispensary_id) VALUES (1, 'Strain A', 25.5, 1), (2, 'Strain B', 18.3, 2), (3, 'Strain C', 22.7, 3), (4, 'Strain D', 21.5, 1), (5, 'Strain E', 19.3, 2), (6, 'Strain F', 23.7, 3);
|
How many dispensaries are there in each state that sell strains with a THC content greater than 20%?
|
SELECT s.state, COUNT(DISTINCT d.id) AS num_dispensaries FROM Strains s INNER JOIN Dispensaries d ON s.dispensary_id = d.id WHERE s.thc_content > 20 GROUP BY s.state;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Flight_Safety (ID INT, Year INT, Number_Of_Accidents INT); INSERT INTO Flight_Safety (ID, Year, Number_Of_Accidents) VALUES (1, 2015, 10), (2, 2016, 12), (3, 2017, 15), (4, 2018, 18), (5, 2019, 20);
|
What is the total number of flight accidents per year?
|
SELECT Year, SUM(Number_Of_Accidents) FROM Flight_Safety GROUP BY Year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE StateWaterUsage (State VARCHAR(20), Usage FLOAT); INSERT INTO StateWaterUsage (State, Usage) VALUES ('California', 25000), ('Texas', 22000), ('Florida', 20000), ('New York', 18000);
|
Identify the top 3 states with the highest water consumption.
|
SELECT State, Usage FROM (SELECT State, Usage, ROW_NUMBER() OVER (ORDER BY Usage DESC) as rank FROM StateWaterUsage) AS subquery WHERE rank <= 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE policyholders (id INT, dob DATE, risk_score INT); INSERT INTO policyholders (id, dob, risk_score) VALUES (1, '1962-05-01', 45); CREATE TABLE claims (id INT, policyholder_id INT, claim_date DATE); INSERT INTO claims (id, policyholder_id, claim_date) VALUES (1, 1, '2021-11-15');
|
What is the average risk score for policyholders aged 50-60 who have made at least one claim in the last 12 months?
|
SELECT AVG(policyholders.risk_score) FROM policyholders JOIN claims ON policyholders.id = claims.policyholder_id WHERE policyholders.dob BETWEEN '1961-01-01' AND '1972-01-01' AND claims.claim_date BETWEEN '2021-11-01' AND '2022-10-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE arctic_weather (station_id INT, record_date DATE, temperature DECIMAL(5,2));
|
What is the average temperature recorded in the 'arctic_weather' table for the month of January, for all years?
|
SELECT AVG(temperature) FROM arctic_weather WHERE EXTRACT(MONTH FROM record_date) = 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ModelExplainabilityScores (ModelID INT, TeamID INT, ExplainabilityScore INT); CREATE TABLE TeamNames (TeamID INT, TeamName VARCHAR(50));
|
List the top 3 teams with the highest average explainability score for their models.
|
SELECT TeamNames.TeamName, AVG(ModelExplainabilityScores.ExplainabilityScore) AS AverageExplainabilityScore FROM ModelExplainabilityScores INNER JOIN TeamNames ON ModelExplainabilityScores.TeamID = TeamNames.TeamID GROUP BY TeamNames.TeamName ORDER BY AverageExplainabilityScore DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Weather (date DATE, crop VARCHAR(20), temperature FLOAT, humidity FLOAT); CREATE TABLE Region (region VARCHAR(20), crop VARCHAR(20), PRIMARY KEY (region, crop));
|
Find the average temperature and humidity for the month of July for all crops in the 'SouthEast' region.
|
SELECT AVG(temperature), AVG(humidity) FROM Weather JOIN Region ON Weather.crop = Region.crop WHERE Region.region = 'SouthEast' AND EXTRACT(MONTH FROM Weather.date) = 7;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE iot_devices (id INT, field_id VARCHAR(10), device_type VARCHAR(20), added_date TIMESTAMP); INSERT INTO iot_devices (id, field_id, device_type, added_date) VALUES (1, 'Field009', 'humidity_sensor', '2022-03-03 10:00:00'), (2, 'Field009', 'temperature_sensor', '2022-03-01 10:00:00');
|
How many IoT devices were added in 'Field009' in the past week?
|
SELECT COUNT(*) FROM iot_devices WHERE field_id = 'Field009' AND added_date BETWEEN DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 7 DAY) AND CURRENT_TIMESTAMP;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Water_Meters (id INT, customer_id INT, meter_reading FLOAT, read_date DATE); INSERT INTO Water_Meters (id, customer_id, meter_reading, read_date) VALUES (1, 2001, 80, '2021-01-01'), (2, 2002, 90, '2021-01-01'), (3, 2003, 70, '2021-01-01');
|
What is the water usage for customers in 'City E'?
|
SELECT SUM(meter_reading) FROM Water_Meters WHERE customer_id IN (SELECT id FROM Customers WHERE city = 'City E');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE endangered_species (species VARCHAR(50), population INT); INSERT INTO endangered_species (species, population) VALUES ('Tiger', 300), ('Giant Panda', 600), ('Elephant', 400);
|
Update the endangered_species table to add 10 to the population of each animal
|
UPDATE endangered_species SET population = population + 10;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customers (id INT, region VARCHAR(10), mobile_subscription VARCHAR(10), broadband_subscription VARCHAR(10)); INSERT INTO customers (id, region, mobile_subscription, broadband_subscription) VALUES (1, 'suburban', 'yes', 'no'), (2, 'urban', 'yes', 'yes'), (3, 'rural', 'no', 'yes'), (4, 'suburban', 'no', 'no'), (5, 'urban', 'yes', 'no');
|
What is the percentage of customers in the 'suburban' region who only have a mobile subscription?
|
SELECT (COUNT(*) FILTER (WHERE region = 'suburban' AND mobile_subscription = 'yes' AND broadband_subscription = 'no')) * 100.0 / (SELECT COUNT(*) FROM customers WHERE region = 'suburban') FROM customers;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE facial_cream_sales (sale_id INT, product_id INT, sale_quantity INT, is_organic BOOLEAN, sale_date DATE, country VARCHAR(20)); INSERT INTO facial_cream_sales VALUES (1, 30, 4, true, '2021-04-23', 'Canada'); INSERT INTO facial_cream_sales VALUES (2, 31, 2, false, '2021-04-23', 'Canada');
|
What is the percentage of organic facial creams sold in Canada in Q2 2021?
|
SELECT ROUND((SUM(CASE WHEN is_organic = true THEN sale_quantity ELSE 0 END) / SUM(sale_quantity)) * 100, 2) FROM facial_cream_sales WHERE sale_date BETWEEN '2021-04-01' AND '2021-06-30' AND country = 'Canada';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Companies (company_id INT, company_name TEXT, has_circular_economy BOOLEAN, total_revenue DECIMAL(10,2));
|
What is the total revenue of companies that have a circular economy model?
|
SELECT SUM(total_revenue) FROM Companies WHERE has_circular_economy = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE PlayerWins (PlayerID INT, Age INT, EventID INT); INSERT INTO PlayerWins (PlayerID, Age, EventID) VALUES (1, 22, 1); CREATE TABLE EsportsEvents (EventID INT, Game VARCHAR(10)); INSERT INTO EsportsEvents (EventID, Game) VALUES (1, 'CS:GO');
|
What is the minimum age of players who have won in an FPS esports event?
|
SELECT MIN(Age) FROM PlayerWins PW JOIN EsportsEvents EE ON PW.EventID = EE.EventID WHERE EE.Game LIKE '%FPS%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE union_contracts (id INT, worker_id INT, occupation VARCHAR(50), start_date DATE, end_date DATE); INSERT INTO union_contracts (id, worker_id, occupation, start_date, end_date) VALUES (1, 1, 'Engineer', '2022-01-01', '2023-12-31'), (2, 2, 'Engineer', '2021-06-15', '2022-06-14'), (3, 3, 'Clerk', '2022-01-01', '2023-12-31'), (4, 4, 'Clerk', '2021-06-15', '2022-06-14');
|
Update all records with the occupation 'Engineer' to 'Senior Engineer' in the 'union_contracts' table
|
UPDATE union_contracts SET occupation = 'Senior Engineer' WHERE occupation = 'Engineer';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE region (id INT PRIMARY KEY, name VARCHAR(255));CREATE TABLE strategy (id INT PRIMARY KEY, name VARCHAR(255), region_id INT, focus VARCHAR(255)); INSERT INTO region (id, name) VALUES (1, 'North America'); INSERT INTO strategy (id, name, region_id, focus) VALUES (1, 'National Security Strategy', 1, 'Counter-Terrorism');
|
Update the focus of the 'National Security Strategy' for the North American region to 'Cyber Defense'.
|
UPDATE strategy SET focus = 'Cyber Defense' WHERE name = 'National Security Strategy' AND region_id = (SELECT id FROM region WHERE name = 'North America');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE seafood_consumption (id INT, province VARCHAR(255), consumption FLOAT); INSERT INTO seafood_consumption (id, province, consumption) VALUES (1, 'British Columbia', 35.0), (2, 'Ontario', 30.0), (3, 'Quebec', 28.0), (4, 'Nova Scotia', 25.0);
|
Calculate the average seafood consumption per capita in each province in Canada.
|
SELECT province, AVG(consumption) FROM seafood_consumption GROUP BY province;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Virtual_Tour (month TEXT, revenue NUMERIC); INSERT INTO Virtual_Tour (month, revenue) VALUES ('January', 5000), ('February', 7000), ('March', 8000);
|
What is the total revenue generated by virtual tours for each month?
|
SELECT month, SUM(revenue) FROM Virtual_Tour GROUP BY month;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE articles (id INT, title VARCHAR(100), content TEXT, category VARCHAR(50), publication_date DATE); INSERT INTO articles (id, title, content, category, publication_date) VALUES (1, 'Climate Change...', '...', 'environment', '2022-01-01');
|
List all news articles related to 'environment' from the 'articles' table.
|
SELECT * FROM articles WHERE category = 'environment';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Artists (id INT, name VARCHAR(100)); CREATE TABLE Users (id INT, name VARCHAR(100)); CREATE TABLE Streams (id INT, user_id INT, artist_id INT, minutes DECIMAL(10,2));
|
What is the average streaming minutes per user for a given artist?
|
SELECT artist_id, AVG(minutes/COUNT(*)) AS avg_minutes_per_user FROM Streams GROUP BY artist_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE visitors (id INT, name VARCHAR(100), country VARCHAR(50), occupation VARCHAR(50)); INSERT INTO visitors (id, name, country, occupation) VALUES (1, 'Leila Zhang', 'China', 'Artist'), (2, 'Alex Brown', 'Japan', 'Musician');
|
What is the total number of visitors who are artists or musicians from Asia?
|
SELECT SUM(occupation IN ('Artist', 'Musician') AND country LIKE 'Asia%') FROM visitors;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE community_health_workers (worker_id INT, name VARCHAR(50), state VARCHAR(2), completed_training BOOLEAN);
|
What is the percentage of community health workers who have completed cultural competency training in each state?
|
SELECT state, AVG(completed_training::INT) FROM community_health_workers GROUP BY state;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE transactions (address TEXT, tx_date DATE, asset TEXT); INSERT INTO transactions (address, tx_date, asset) VALUES ('0x123', '2021-01-01', 'Securitize'), ('0x123', '2021-01-02', 'Polymath');
|
Show the transaction history for smart contract address 0x123, including the transaction date and the digital asset associated with each transaction.
|
SELECT * FROM transactions WHERE address = '0x123' ORDER BY tx_date;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE users (id INT, last_interaction TIMESTAMP); INSERT INTO users (id, last_interaction) VALUES (1, '2021-01-01 10:00:00'), (2, '2021-06-15 14:30:00'), (3, '2020-12-25 09:15:00');
|
Delete records of users who have not interacted with the system in the past 6 months
|
DELETE FROM users WHERE last_interaction < NOW() - INTERVAL 6 MONTH;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MentalHealthParityComplaints (ComplaintID INT, County VARCHAR(50), ComplaintDate DATE); INSERT INTO MentalHealthParityComplaints (ComplaintID, County, ComplaintDate) VALUES (1, 'Los Angeles', '2020-01-01'), (2, 'Harris', '2019-12-15'), (3, 'New York', '2021-02-03');
|
What is the total number of mental health parity complaints by county in the last 3 years?
|
SELECT County, COUNT(*) OVER (PARTITION BY County) AS TotalComplaints FROM MentalHealthParityComplaints WHERE ComplaintDate >= DATEADD(year, -3, GETDATE());
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE movies (id INT, title VARCHAR(255), rating FLOAT, director VARCHAR(255)); INSERT INTO movies (id, title, rating, director) VALUES (1, 'Movie1', 4.5, 'Director1'), (2, 'Movie2', 3.2, 'Director2'), (3, 'Movie3', 4.7, 'Director2'), (4, 'Movie4', 2.9, 'Director3');
|
What is the average rating of movies directed by 'Director2'?
|
SELECT AVG(rating) FROM movies WHERE director = 'Director2';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Policyholders (PolicyholderID INT, LastClaimDate DATE); INSERT INTO Policyholders VALUES (1, '2020-01-01'); INSERT INTO Policyholders VALUES (2, '2021-05-05'); INSERT INTO Policyholders VALUES (3, '2019-12-31');
|
Delete policyholders and their insurance policies from the database who have not filed a claim in the past 2 years.
|
DELETE FROM Policyholders WHERE LastClaimDate < NOW() - INTERVAL '2 years'; DELETE FROM HomeInsurance WHERE PolicyholderID IN (SELECT PolicyholderID FROM Policyholders WHERE LastClaimDate < NOW() - INTERVAL '2 years'); DELETE FROM AutoInsurance WHERE PolicyholderID IN (SELECT PolicyholderID FROM Policyholders WHERE LastClaimDate < NOW() - INTERVAL '2 years');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Species (id INT PRIMARY KEY, name VARCHAR(50), type VARCHAR(50)); INSERT INTO Species (id, name, type) VALUES (1, 'Tuna', 'Fish'); INSERT INTO Species (id, name, type) VALUES (2, 'Krill', 'Crustacean');
|
Insert new record into the Species table.
|
INSERT INTO Species (id, name, type) VALUES (3, 'Coral', 'Cnidarian');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE WaterUsage (id INT, location TEXT, water_usage INT);
|
What is the total water usage in 'WaterUsage' table for the state of California?
|
SELECT SUM(water_usage) FROM WaterUsage WHERE location = 'California';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Events (id INT, city VARCHAR(20), price DECIMAL(5,2)); INSERT INTO Events (id, city, price) VALUES (1, 'Paris', 20.99), (2, 'London', 15.49), (3, 'Paris', 25.00);
|
What is the average ticket price for events in Paris?
|
SELECT AVG(price) FROM Events WHERE city = 'Paris';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE water_usage(province VARCHAR(20), year INT, consumption INT); INSERT INTO water_usage(province, year, consumption) VALUES ('British Columbia', 2015, 10000), ('British Columbia', 2016, 11000), ('British Columbia', 2017, 12000), ('British Columbia', 2018, 13000), ('British Columbia', 2019, 14000);
|
How much water was consumed in the province of British Columbia in 2018?
|
SELECT consumption FROM water_usage WHERE province = 'British Columbia' AND year = 2018;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE exhibitions (id INT, name VARCHAR(100), type VARCHAR(50), visitors INT); INSERT INTO exhibitions (id, name, type, visitors) VALUES (1, 'Impressionism', 'Art', 2000), (2, 'Classical Music', 'Music', 1200);
|
List all art-related exhibitions with more than 1500 visitors.
|
SELECT name FROM exhibitions WHERE type LIKE '%Art%' AND visitors > 1500;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Crops (id INT PRIMARY KEY, name VARCHAR(50), planting_date DATE, harvest_date DATE, yield INT); INSERT INTO Crops (id, name, planting_date, harvest_date, yield) VALUES (1, 'Corn', '2021-04-15', '2021-08-30', 80); INSERT INTO Crops (id, name, planting_date, harvest_date, yield) VALUES (2, 'Soybeans', '2021-05-01', '2021-10-15', 70);
|
Which crops were planted before June 1, 2021 and harvested after September 1, 2021?
|
SELECT name FROM Crops WHERE planting_date < '2021-06-01' AND harvest_date > '2021-09-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Maintenance_Requests (request_id INT, equipment_type TEXT, province TEXT, request_date DATE); INSERT INTO Maintenance_Requests (request_id, equipment_type, province, request_date) VALUES (1, 'Helicopter', 'Ontario', '2021-01-01'), (2, 'Tank', 'Ontario', '2021-06-01');
|
How many military equipment maintenance requests were submitted in Ontario in 2021?
|
SELECT COUNT(*) FROM Maintenance_Requests WHERE province = 'Ontario' AND YEAR(request_date) = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE waste_generation (id INT, country VARCHAR(50), year INT, total_waste_gen FLOAT);
|
Calculate the total waste generation for the year 2020 from the 'waste_generation' table
|
SELECT SUM(total_waste_gen) FROM waste_generation WHERE year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE TemperatureReadings (Year INT, Temperature DECIMAL(5,2)); INSERT INTO TemperatureReadings (Year, Temperature) VALUES (2021, -14.5), (2021, -13.8), (2021, -16.2), (2022, -12.9), (2022, -15.1), (2022, -13.4);
|
What is the maximum temperature recorded in the Arctic in the past year?
|
SELECT MAX(Temperature) FROM TemperatureReadings WHERE Year = 2022;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donors (id INT, donor_name VARCHAR(50), donation_amount DECIMAL(10,2), donation_date DATE, zip VARCHAR(10)); INSERT INTO Donors (id, donor_name, donation_amount, donation_date, zip) VALUES (1, 'Alex Brown', 200.00, '2021-01-01', '10001');
|
What is the average donation amount per zip code?
|
SELECT zip, AVG(donation_amount) as avg_donation_amount FROM Donors GROUP BY zip;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE waste_generation_metrics ( country VARCHAR(50), year INT, generation_metric INT);
|
Create a table named 'waste_generation_metrics'
|
CREATE TABLE waste_generation_metrics ( country VARCHAR(50), year INT, generation_metric INT);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE regulatory_compliance (compliance_date DATE, subscriber_id INT); INSERT INTO regulatory_compliance (compliance_date, subscriber_id) VALUES ('2022-01-01', 1), ('2022-02-01', 2);
|
What is the total number of subscribers who have been in compliance with regulatory requirements for each quarter?
|
SELECT DATE_FORMAT(compliance_date, '%Y-%q') AS quarter, COUNT(DISTINCT subscriber_id) FROM regulatory_compliance GROUP BY quarter;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MovementSales (Movement VARCHAR(255), ArtWork VARCHAR(255), Year INT, QuantitySold INT); INSERT INTO MovementSales (Movement, ArtWork, Year, QuantitySold) VALUES ('Post-Impressionism', 'Artwork 1', 2022, 2), ('Post-Impressionism', 'Artwork 2', 2022, 3), ('Pop Art', 'Artwork 3', 2022, 1), ('Pop Art', 'Artwork 4', 2022, 4);
|
How many artworks were sold by each art movement in 2022?
|
SELECT Movement, SUM(QuantitySold) as TotalQuantitySold FROM MovementSales WHERE Year = 2022 GROUP BY Movement;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Warehouses (warehouse_id INT, location VARCHAR(50), capacity FLOAT); INSERT INTO Warehouses (warehouse_id, location, capacity) VALUES (1, 'Los Angeles', 12000); INSERT INTO Warehouses (warehouse_id, location, capacity) VALUES (2, 'New York', 8000);
|
List all warehouses with available capacity over 10000 square meters.
|
SELECT * FROM Warehouses WHERE capacity > 10000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donations (DonationID INT, DonorID INT, DonationDate DATE, DonationAmount DECIMAL(10,2), DonationCountry VARCHAR(50)); CREATE TABLE Donors (DonorID INT, DonorName VARCHAR(50), DonationType VARCHAR(50));
|
Who is the largest donor in each country?
|
SELECT d.DonorName, d.DonationCountry, SUM(d.DonationAmount) FROM Donations d JOIN Donors don ON d.DonorID = don.DonorID GROUP BY d.DonorName, d.DonationCountry HAVING SUM(d.DonationAmount) = (SELECT MAX(SUM(DonationAmount)) FROM Donations d2 JOIN Donors don2 ON d2.DonorID = don2.DonorID WHERE d2.DonationCountry = d.DonationCountry) ORDER BY SUM(d.DonationAmount) DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE users_roles_table (user_id INT, role VARCHAR(20)); INSERT INTO users_roles_table (user_id, role) VALUES (1, 'regular_user'), (2, 'influencer'), (3, 'partner'), (4, 'influencer'), (5, 'regular_user');
|
What is the total number of posts made by users with the role "influencer" in the "users_roles_table"?
|
SELECT SUM(post_count) FROM (SELECT COUNT(*) AS post_count FROM users_table JOIN users_roles_table ON users_table.user_id = users_roles_table.user_id WHERE users_roles_table.role = 'influencer' GROUP BY users_table.user_id) AS subquery;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Events (id INT, date DATE, language VARCHAR(50), event_type VARCHAR(50)); INSERT INTO Events (id, date, language, event_type) VALUES (1, '2021-01-01', 'English', 'Theater'), (2, '2021-02-01', 'Spanish', 'Theater'); CREATE TABLE Ratings (id INT, event_id INT, age_group VARCHAR(20), rating DECIMAL(3,2)); INSERT INTO Ratings (id, event_id, age_group, rating) VALUES (1, 1, '18-24', 4.5), (2, 1, '25-34', 4.0), (3, 2, '35-44', 4.7);
|
What is the average rating of theater performances, in the past year, broken down by age group and language?
|
SELECT e.language, r.age_group, AVG(r.rating) AS avg_rating FROM Events e INNER JOIN Ratings r ON e.id = r.event_id WHERE e.date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) AND e.event_type = 'Theater' GROUP BY e.language, r.age_group;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE product_details (product_name TEXT, is_organic_certified BOOLEAN, consumer_rating REAL); INSERT INTO product_details (product_name, is_organic_certified, consumer_rating) VALUES ('Product 1', true, 4.2), ('Product 2', false, 3.5), ('Product 3', true, 4.8), ('Product 4', false, 1.8), ('Product 5', true, 2.5);
|
Display the names and consumer ratings of all cosmetics products that are not certified as organic.
|
SELECT product_name, consumer_rating FROM product_details WHERE is_organic_certified = false;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE dispensaries (dispensary_id INT, name VARCHAR(255), city VARCHAR(255), state VARCHAR(255)); INSERT INTO dispensaries (dispensary_id, name, city, state) VALUES (1, 'Dispensary A', 'Los Angeles', 'CA'), (2, 'Dispensary B', 'San Francisco', 'CA'); CREATE TABLE sales (sale_id INT, dispensary_id INT, product_category VARCHAR(255), amount DECIMAL(10, 2)); INSERT INTO sales (sale_id, dispensary_id, product_category, amount) VALUES (1, 1, 'flower', 120.00), (2, 1, 'edibles', 300.50), (3, 2, 'concentrates', 75.25), (4, 2, 'flower', 150.76);
|
What is the total revenue by product category for dispensaries in Los Angeles?
|
SELECT d.city, p.product_category, SUM(s.amount) FROM dispensaries d INNER JOIN sales s ON d.dispensary_id = s.dispensary_id INNER JOIN (SELECT DISTINCT product_category FROM sales) p ON s.product_category = p.product_category WHERE d.city = 'Los Angeles' GROUP BY d.city, p.product_category;
|
gretelai_synthetic_text_to_sql
|
create table vulnerabilities (id int, sector varchar(255), severity int); insert into vulnerabilities values (1, 'retail', 7); insert into vulnerabilities values (2, 'retail', 5); insert into vulnerabilities values (3, 'healthcare', 8); insert into vulnerabilities values (4, 'financial services', 2); insert into vulnerabilities values (5, 'financial services', 9);
|
What is the minimum severity score of vulnerabilities for each sector that has at least one high-severity vulnerability?
|
SELECT sector, MIN(severity) FROM vulnerabilities WHERE sector IN (SELECT sector FROM vulnerabilities WHERE severity = 9) GROUP BY sector;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE diversity_metrics (id INT, name VARCHAR(50), department VARCHAR(50), metric VARCHAR(50));
|
Delete the record of the employee with ID 4 from the 'Diversity Metrics' table if they are from the 'Human Resources' department.
|
DELETE FROM diversity_metrics WHERE id = 4 AND department = 'Human Resources';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sales (sale_id INT, item_name VARCHAR(50), quantity INT); INSERT INTO sales (sale_id, item_name, quantity) VALUES (1, 'Tomato', 20), (2, 'Chicken Breast', 30), (3, 'Vanilla Ice Cream', 25);
|
What is the total quantity of each item sold?
|
SELECT item_name, SUM(quantity) FROM sales GROUP BY item_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE travel_advisory (location VARCHAR(255), status VARCHAR(255), last_updated DATE);
|
Update the travel_advisory table to set the status to 'Safe' for the record with the location 'Japan'
|
UPDATE travel_advisory SET status = 'Safe' WHERE location = 'Japan';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE states (state_id INT, state_name VARCHAR(255), region VARCHAR(255)); CREATE TABLE community_health_centers (center_id INT, center_name VARCHAR(255), state_id INT, location VARCHAR(255)); INSERT INTO states (state_id, state_name, region) VALUES (1, 'California', 'West'), (2, 'Texas', 'South'), (3, 'New York', 'East'), (4, 'Alaska', 'North'); INSERT INTO community_health_centers (center_id, center_name, state_id, location) VALUES (1, 'Center A', 1, 'Urban'), (2, 'Center B', 2, 'Rural'), (3, 'Center C', 3, 'Urban'), (4, 'Center D', 4, 'Rural');
|
What is the number of community health centers in each state, categorized by urban and rural areas?
|
SELECT s.region, CHC.location, COUNT(CHC.center_id) as center_count FROM community_health_centers CHC JOIN states s ON CHC.state_id = s.state_id GROUP BY s.region, CHC.location;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE nba_games (team VARCHAR(255), won INTEGER, games_played INTEGER);
|
List the teams and the number of games they have lost in the "nba_games" table
|
SELECT team, SUM(games_played - won) as total_losses FROM nba_games GROUP BY team;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Manufacturers (id INT, country VARCHAR(50), co2_emission_rate DECIMAL(5,2)); INSERT INTO Manufacturers (id, country, co2_emission_rate) VALUES (1, 'France', 4.5), (2, 'Germany', 6.0), (3, 'Italy', 3.5), (4, 'France', 7.5), (5, 'Germany', 5.0), (6, 'France', 6.5);
|
Find the average CO2 emissions (in kg) for garment manufacturers in France and Germany, for manufacturers with an emission rate higher than 5 kg per garment.
|
SELECT AVG(m.co2_emission_rate) as avg_emission_rate FROM Manufacturers m WHERE m.country IN ('France', 'Germany') AND m.co2_emission_rate > 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE drug_approval (drug_name TEXT, approval_year INTEGER);
|
What is the total revenue of all drugs approved in 2021?
|
SELECT SUM(revenue) FROM sales s INNER JOIN drug_approval a ON s.drug_name = a.drug_name WHERE a.approval_year = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE investment (id INT, company_id INT, investment_date DATE, investment_amount INT); INSERT INTO investment (id, company_id, investment_date, investment_amount) VALUES (1, 1, '2018-01-01', 500000);
|
List the number of investments in startups founded by Indigenous people in the renewable energy sector since 2017.
|
SELECT COUNT(*) FROM investment INNER JOIN company ON investment.company_id = company.id WHERE company.industry = 'Renewable Energy' AND company.founder_gender = 'Indigenous' AND investment_date >= '2017-01-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE FoundationB (org_id INT, org_name VARCHAR(50), amount INT, grant_date DATE);
|
Which cultural organizations received funding from 'Foundation B' in the past year, and what was the total amount granted?
|
SELECT org_name, SUM(amount) FROM FoundationB WHERE org_id IN (SELECT org_id FROM CulturalOrgs) AND grant_date >= DATEADD(year, -1, GETDATE()) GROUP BY org_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE space_debris (id INT, debris_name VARCHAR(50), mass FLOAT, orbit VARCHAR(50)); INSERT INTO space_debris (id, debris_name, mass, orbit) VALUES (1, 'ENVISAT', 8212, 'LEO'); INSERT INTO space_debris (id, debris_name, mass, orbit) VALUES (2, 'FENYERS 3/4', 1520, 'GEO');
|
What is the total mass of space debris in high Earth orbit?
|
SELECT SUM(mass) FROM space_debris WHERE orbit = 'GEO';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Aircraft_Manufacturing (ID INT, Manufacturer VARCHAR(20), Cost INT); INSERT INTO Aircraft_Manufacturing (ID, Manufacturer, Cost) VALUES (1, 'Boeing', 50000), (2, 'Airbus', 60000), (3, 'Lockheed Martin', 40000);
|
What is the total cost of aircraft manufacturing by manufacturer?
|
SELECT Manufacturer, SUM(Cost) FROM Aircraft_Manufacturing GROUP BY Manufacturer;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hotels (hotel_id INT, hotel_name TEXT, country TEXT, revenue FLOAT); INSERT INTO hotels (hotel_id, hotel_name, country, revenue) VALUES (1, 'Hotel X', 'Egypt', 100000), (2, 'Hotel Y', 'Morocco', 120000), (3, 'Hotel Z', 'South Africa', 150000); CREATE TABLE virtual_tours (tour_id INT, hotel_id INT); INSERT INTO virtual_tours (tour_id, hotel_id) VALUES (1, 1), (2, 3);
|
What is the total revenue for hotels that offer virtual tours in Africa?
|
SELECT SUM(revenue) FROM hotels INNER JOIN virtual_tours ON hotels.hotel_id = virtual_tours.hotel_id WHERE hotels.country IN ('Egypt', 'Morocco', 'South Africa');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE city (id INT PRIMARY KEY, name TEXT, state TEXT); CREATE TABLE project (id INT PRIMARY KEY, name TEXT, status TEXT, city_id INT, FOREIGN KEY (city_id) REFERENCES city(id));
|
What is the average number of open civic tech projects per city?
|
SELECT AVG(open_projects_per_city) FROM (SELECT COUNT(*) as open_projects_per_city FROM project WHERE city_id IN (SELECT id FROM city) AND status = 'Open' GROUP BY city_id) as subquery;
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA open_education; CREATE TABLE open_education.courses (course_id INT, student_id INT); CREATE TABLE open_education.students (student_id INT, name VARCHAR(50)); INSERT INTO open_education.students (student_id, name) VALUES (1, 'John Doe'), (2, 'Jane Smith'); INSERT INTO open_education.courses (course_id, student_id) VALUES (101, 1), (102, 2), (103, 1);
|
Find the number of students who have ever been enrolled in a course from the 'open_education' schema
|
SELECT COUNT(DISTINCT student_id) FROM open_education.courses;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE departments (id INT, name VARCHAR(50)); INSERT INTO departments (id, name) VALUES (1, 'Computer Science'); INSERT INTO departments (id, name) VALUES (2, 'Mathematics'); CREATE TABLE research_grants (id INT, department_id INT, pi_gender VARCHAR(10), year INT, amount INT); INSERT INTO research_grants (id, department_id, pi_gender, year, amount) VALUES (1, 1, 'Male', 2018, 50000); INSERT INTO research_grants (id, department_id, pi_gender, year, amount) VALUES (2, 1, 'Female', 2020, 75000);
|
What is the total amount of research grants awarded to each department in the past 5 years, broken down by pi_gender?
|
SELECT d.name, rg.pi_gender, SUM(rg.amount) FROM research_grants rg JOIN departments d ON rg.department_id = d.id WHERE rg.year BETWEEN 2017 AND 2021 GROUP BY d.name, rg.pi_gender;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE EsportsTeamsBrazil (TeamID INT, TeamName VARCHAR(100), Country VARCHAR(50), HoursSpent DECIMAL(10,2)); INSERT INTO EsportsTeamsBrazil (TeamID, TeamName, Country, HoursSpent) VALUES (1, 'Team Brazil', 'Brazil', 120.00), (2, 'Team Argentina Brazil', 'Brazil', 140.00), (3, 'Team Chile Brazil', 'Brazil', 160.00);
|
What is the average number of hours spent on esports events by teams from Brazil?
|
SELECT AVG(HoursSpent) FROM EsportsTeamsBrazil WHERE Country = 'Brazil';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE community_initiatives (id INT, name VARCHAR(255), completion_date DATE); INSERT INTO community_initiatives (id, name, completion_date) VALUES (1, 'Youth Skills Training', '2021-03-01'), (2, 'Women Empowerment Program', '2020-05-15'), (3, 'Elderly Care Center', '2019-12-20');
|
Which community development initiatives in 'RuralDev' database have been completed in the last two years?
|
SELECT * FROM community_initiatives WHERE completion_date >= DATEADD(year, -2, GETDATE());
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE suppliers (id INT, name TEXT, country TEXT); INSERT INTO suppliers (id, name, country) VALUES (1, 'Green Earth Farms', 'France'), (2, 'La Placita Market', 'Spain'), (3, 'Bella Verde Organics', 'Italy');
|
List all suppliers from France and Spain
|
SELECT name FROM suppliers WHERE country IN ('France', 'Spain');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sales (id INT, product_id INT, country VARCHAR(255), quantity INT);
|
List all countries where a product was sold and its total sales
|
SELECT country, SUM(quantity) as total_sales FROM sales GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE game_stats (game_id INT, player_id INT, rebounds INT);
|
What is the minimum number of rebounds in a game by players from Oceania who have played more than 50 games in a season?
|
SELECT MIN(rebounds) FROM game_stats JOIN players ON game_stats.player_id = players.player_id WHERE players.country = 'Oceania' GROUP BY players.country HAVING games_played > 50;
|
gretelai_synthetic_text_to_sql
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.