context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE co_ownership (id INT, property_price FLOAT, num_owners INT); INSERT INTO co_ownership (id, property_price, num_owners) VALUES (1, 800000, 2), (2, 900000, 3), (3, 700000, 2);
|
What is the total property price for co-owned properties in the co_ownership table?
|
SELECT SUM(property_price) FROM co_ownership WHERE num_owners > 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE employees (employee_name VARCHAR(50), age INT, department_name VARCHAR(50), salary DECIMAL(10,2));
|
List the names and ages of all employees in the employees table who have a higher salary than the average salary in their respective department.
|
SELECT employee_name, age FROM employees WHERE salary > (SELECT AVG(salary) FROM employees WHERE employees.department_name = department_name) GROUP BY department_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cb_agreements (id INT, year INT, num_agreements INT); INSERT INTO cb_agreements (id, year, num_agreements) VALUES (1, 2018, 30), (2, 2019, 40), (3, 2020, 50), (4, 2021, 60);
|
How many collective bargaining agreements were signed in the "union_database" in 2020 and 2021?
|
SELECT SUM(num_agreements) FROM cb_agreements WHERE year IN (2020, 2021);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE state_parks.wildlife_habitat (species VARCHAR(255), score DECIMAL(5,2));
|
Find the difference in the number of trees between the tree species with the highest and lowest wildlife habitat scores in the state_parks schema.
|
SELECT species_high.species AS high_species, species_low.species AS low_species, species_high.score - species_low.score AS difference FROM (SELECT species, MAX(score) AS score FROM state_parks.wildlife_habitat GROUP BY species) AS species_high FULL OUTER JOIN (SELECT species, MIN(score) AS score FROM state_parks.wildlife_habitat GROUP BY species) AS species_low ON species_high.score = species_low.score;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE public_health_policy (id INT, policy_type VARCHAR(20), change_date DATE); INSERT INTO public_health_policy (id, policy_type, change_date) VALUES (1, 'Regulation', '2017-08-01'); INSERT INTO public_health_policy (id, policy_type, change_date) VALUES (2, 'Funding', '2018-12-25'); INSERT INTO public_health_policy (id, policy_type, change_date) VALUES (3, 'Legislation', '2019-04-10');
|
What is the total number of public health policy changes in the last 5 years, categorized by type?
|
SELECT policy_type, COUNT(*) as policy_changes FROM public_health_policy WHERE change_date >= DATEADD(year, -5, GETDATE()) GROUP BY policy_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Spacewalks (id INT, astronaut VARCHAR(255), duration INT); INSERT INTO Spacewalks (id, astronaut, duration) VALUES (1, 'Neil Armstrong', 216); INSERT INTO Spacewalks (id, astronaut, duration) VALUES (2, 'Buzz Aldrin', 151);
|
What is the average time spent on spacewalks by each astronaut?
|
SELECT astronaut, AVG(duration) FROM Spacewalks GROUP BY astronaut;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE southeast_region (region VARCHAR(20), account_type VARCHAR(30), account_balance DECIMAL(10,2)); INSERT INTO southeast_region (region, account_type, account_balance) VALUES ('Southeast', 'Financial Capability', 7000.00), ('Southeast', 'Financial Capability', 8000.00), ('Southeast', 'Financial Literacy', 6000.00);
|
What is the average account balance for financial capability accounts in the Southeast region?
|
SELECT AVG(account_balance) FROM southeast_region WHERE account_type = 'Financial Capability';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Citizen_Feedback (Service VARCHAR(255), Location VARCHAR(255), Satisfaction_Score DECIMAL(3,1)); INSERT INTO Citizen_Feedback (Service, Location, Satisfaction_Score) VALUES ('Healthcare', 'Urban', 8.5), ('Healthcare', 'Urban', 9.0), ('Healthcare', 'Rural', 7.5), ('Education', 'Urban', 8.0), ('Education', 'Rural', 8.0);
|
What is the average citizen satisfaction score for healthcare services in urban areas?
|
SELECT AVG(Satisfaction_Score) FROM Citizen_Feedback WHERE Service = 'Healthcare' AND Location = 'Urban';
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA if not exists biotech; CREATE TABLE if not exists biotech.startups (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), funding FLOAT); INSERT INTO biotech.startups (id, name, location, funding) VALUES (1, 'StartupA', 'USA', 5000000), (2, 'StartupB', 'USA', 7000000), (3, 'StartupC', 'Canada', 3000000);
|
What is the total funding received by biotech startups based in the United States?
|
SELECT SUM(funding) FROM biotech.startups WHERE location = 'USA';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE artifacts (id INT, find_year INT, artifact_type VARCHAR(255), artifact_weight FLOAT);
|
How many total artifacts were found in each year, by artifact type?
|
SELECT artifact_type, find_year, COUNT(*) AS total_artifacts FROM artifacts GROUP BY artifact_type, find_year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ReleasedAnimals (ReleaseID INT, AnimalID INT, ReleaseDate DATE, EducationCenterID INT); INSERT INTO ReleasedAnimals (ReleaseID, AnimalID, ReleaseDate, EducationCenterID) VALUES (3, 3, '2018-01-01', 2); INSERT INTO ReleasedAnimals (ReleaseID, AnimalID, ReleaseDate, EducationCenterID) VALUES (4, 4, '2017-12-31', 2);
|
How many animals have been released in 'Community Education Center B' since 2018?
|
SELECT COUNT(*) FROM ReleasedAnimals WHERE EducationCenterID = 2 AND ReleaseDate >= '2018-01-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE volunteers (id INT, name VARCHAR(100), project_id INT); INSERT INTO volunteers (id, name, project_id) VALUES (1, 'Jane Smith', NULL), (2, 'Pedro Rodriguez', 1), (3, 'John Doe', NULL);
|
List all volunteers who have not been assigned to a project.
|
SELECT name FROM volunteers WHERE project_id IS NULL;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE broadband_subscribers (subscriber_id INT, name VARCHAR(50), plan VARCHAR(50), last_usage DATE, region VARCHAR(50)); INSERT INTO broadband_subscribers (subscriber_id, name, plan, last_usage, region) VALUES (1, 'Bruce Willis', '100 Mbps', '2022-03-15', 'Seattle');
|
Delete records of broadband subscribers in the Seattle region who have not used their service in the last 3 months.
|
DELETE FROM broadband_subscribers WHERE region = 'Seattle' AND last_usage <= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mobile_complaints (id INT, plan_type VARCHAR(10), state VARCHAR(20), complaints INT);
|
Which mobile plans have had more than 10,000 complaints in the state of California?
|
SELECT plan_type, state FROM mobile_complaints WHERE state = 'California' AND complaints > 10000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE HeritageSites (SiteID int, SiteName varchar(50), Country varchar(50)); INSERT INTO HeritageSites (SiteID, SiteName, Country) VALUES (1, 'Giza Pyramids', 'Egypt'), (2, 'African Renaissance Monument', 'Senegal'), (3, 'Taj Mahal', 'India'), (4, 'Angkor Wat', 'Cambodia'), (5, 'Machu Picchu', 'Peru');
|
Which heritage sites are located in South America?
|
SELECT SiteName FROM HeritageSites WHERE Country = 'Peru';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE community_policing (id INT, event_type VARCHAR(20), location VARCHAR(20), event_date DATE); INSERT INTO community_policing (id, event_type, location, event_date) VALUES (1, 'meeting', 'eastside', '2021-07-01');
|
What is the average number of community policing events per week in 'eastside' in the second half of 2021?
|
SELECT AVG(COUNT(*)) FROM community_policing WHERE location = 'eastside' AND event_date BETWEEN '2021-07-01' AND '2021-12-31' GROUP BY (event_date - INTERVAL '7 days')::interval;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE AfricaDevices (id INT, company VARCHAR(255), region VARCHAR(255)); INSERT INTO AfricaDevices (id, company, region) VALUES (1, 'TechAfrica', 'Africa'), (2, 'InnoAfrica', 'Africa');
|
What are the names of the companies that produced devices in the 'Africa' region?
|
SELECT company FROM AfricaDevices WHERE region = 'Africa';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE workplaces (id INT, name TEXT, location TEXT, sector TEXT, total_employees INT, union_members INT, successful_cb BOOLEAN, cb_year INT);
|
What is the percentage of workplaces with successful collective bargaining in the retail sector?
|
SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM workplaces WHERE sector = 'retail')) AS percentage FROM workplaces WHERE sector = 'retail' AND successful_cb = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Employees (EmployeeID INT, Gender VARCHAR(10), Department VARCHAR(20), Salary FLOAT); INSERT INTO Employees (EmployeeID, Gender, Department, Salary) VALUES (1, 'Male', 'IT', 80000), (2, 'Female', 'IT', 85000), (3, 'Male', 'IT', 82000), (4, 'Female', 'IT', 88000), (5, 'Non-binary', 'IT', 83000);
|
What is the maximum salary of employees who work in the IT department?
|
SELECT MAX(Salary) FROM Employees WHERE Department = 'IT';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Menu (id INT, name VARCHAR(255), price DECIMAL(5,2), vegetarian BOOLEAN); INSERT INTO Menu (id, name, price, vegetarian) VALUES (1, 'Chicken Burger', 7.99, FALSE), (2, 'Veggie Wrap', 6.49, TRUE), (3, 'Chicken Caesar Salad', 9.99, FALSE);
|
List all menu items that contain 'salad' in their name from the 'Menu' table.
|
SELECT name FROM Menu WHERE name LIKE '%salad%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE spacecraft_experience (astronaut_id INT, spacecraft TEXT); INSERT INTO spacecraft_experience (astronaut_id, spacecraft) VALUES (1, 'SpaceX Dragon'), (2, 'Soyuz'), (3, 'Space Shuttle'); CREATE TABLE astronauts (id INT, name TEXT, age INT); INSERT INTO astronauts (id, name, age) VALUES (1, 'Maria', 45), (2, 'James', 35), (3, 'Anna', 42); CREATE TABLE space_missions (id INT, astronaut_id INT, spacecraft TEXT); INSERT INTO space_missions (id, astronaut_id, spacecraft) VALUES (1, 1, 'SpaceX Dragon'), (2, 2, 'Soyuz'), (3, 3, 'Space Shuttle');
|
Which spacecraft have been used in space missions by astronauts aged 40 or older?
|
SELECT spacecraft FROM spacecraft_experience se JOIN astronauts a ON se.astronaut_id = a.id WHERE a.age >= 40;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE products (product_id INT, product_name TEXT, is_vegan BOOLEAN, is_cruelty_free BOOLEAN);
|
Add a new vegan and cruelty-free product to the database.
|
INSERT INTO products (product_id, product_name, is_vegan, is_cruelty_free) VALUES (123, 'New Vegan Product', TRUE, TRUE);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE underrepresented_farmer (farmer_id INT, name VARCHAR(50), age INT, ethnicity VARCHAR(50), location VARCHAR(50)); INSERT INTO underrepresented_farmer (farmer_id, name, age, ethnicity, location) VALUES (1, 'Sanaa', 35, 'Latina', 'Rural Area');
|
List all underrepresented farmers and their ages in the 'rural_development' database, sorted by age in descending order.
|
SELECT * FROM underrepresented_farmer ORDER BY age DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE professor_advising (id INT, professor TEXT, num_students INT, year INT); INSERT INTO professor_advising (id, professor, num_students, year) VALUES (15, 'Carl', 0, 2021); INSERT INTO professor_advising (id, professor, num_students, year) VALUES (16, 'Dana', 2, 2020);
|
What are the names and research interests of professors who have not advised any graduate students in the past year?
|
SELECT professor, research_interest FROM professors p LEFT JOIN professor_advising pa ON p.name = pa.professor WHERE pa.num_students IS NULL;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Patent (PatentID int, PatentName varchar(255), FilerName varchar(255), FilingDate date, Country varchar(255)); INSERT INTO Patent (PatentID, PatentName, FilerName, FilingDate, Country) VALUES (1, 'AI-based accessibility tool', 'Jane Doe', '2021-01-01', 'USA'), (2, 'Voice recognition software', 'Alice Smith', '2021-05-15', 'UK'), (3, 'Adaptive learning platform', 'Jane Doe', '2021-12-31', 'USA');
|
How many accessibility-related technology patents were filed by females in the USA and Europe in 2021?
|
SELECT COUNT(*) as NumPatents FROM Patent WHERE YEAR(FilingDate) = 2021 AND (Country = 'USA' OR Country = 'UK') AND FilerName LIKE '%[fF]%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Players (PlayerID INT, Age INT, Gender VARCHAR(10), Country VARCHAR(20), TotalHoursPlayed INT, FavoriteGame VARCHAR(10)); INSERT INTO Players (PlayerID, Age, Gender, Country, TotalHoursPlayed, FavoriteGame) VALUES (1, 25, 'Male', 'Japan', 10, 'VR'); INSERT INTO Players (PlayerID, Age, Gender, Country, TotalHoursPlayed, FavoriteGame) VALUES (2, 30, 'Female', 'Japan', 15, 'VR');
|
What is the total number of hours spent on VR games by players from Japan?
|
SELECT SUM(TotalHoursPlayed) FROM Players WHERE Country = 'Japan' AND FavoriteGame = 'VR';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE farming (id INT, name TEXT, location TEXT, crop TEXT, yield INT); INSERT INTO farming VALUES (1, 'Smith Farm', 'Colorado', 'Corn', 120), (2, 'Brown Farm', 'Nebraska', 'Soybeans', 45), (3, 'Jones Farm', 'Iowa', 'Wheat', 80);
|
What is the difference in yield between the highest and lowest yielding crop for each location?
|
SELECT location, MAX(yield) - MIN(yield) as yield_diff FROM farming GROUP BY location;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE tree_species (name VARCHAR(255), status VARCHAR(255));
|
Identify the number of tree species that have a critically endangered status.
|
SELECT COUNT(*) FROM tree_species WHERE status = 'critically endangered';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE countries (country_id INT, name VARCHAR(50), population INT, gdp FLOAT); INSERT INTO countries (country_id, name, population, gdp) VALUES (1, 'Brazil', 210147125, 1.432); INSERT INTO countries (country_id, name, population, gdp) VALUES (2, 'Indonesia', 273523615, 1.019);
|
What is the average population of countries with a GDP less than 1.5 and more than 30 million visitors in the international_visitors table?
|
SELECT AVG(c.population) FROM countries c INNER JOIN (SELECT country_id, SUM(visitors) as total_visitors FROM international_visitors GROUP BY country_id) iv ON c.country_id = iv.country_id WHERE c.gdp < 1.5 AND total_visitors > 30000000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vulnerability_assessments (id INT, vulnerability VARCHAR(50), severity VARCHAR(10));
|
What is the total number of vulnerabilities found for each severity level in the 'vulnerability_assessments' table?
|
SELECT severity, SUM(1) FROM vulnerability_assessments GROUP BY severity;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE aid_operations (id INT, operation_name VARCHAR(50), start_date DATE, end_date DATE, cost FLOAT); INSERT INTO aid_operations (id, operation_name, start_date, end_date, cost) VALUES (1, 'Operation Provide Comfort', '1991-04-05', '1996-12-31', 100000000); INSERT INTO aid_operations (id, operation_name, start_date, end_date, cost) VALUES (2, 'Operation Lifeline Sudan', '1989-05-20', '2000-03-31', 50000000);
|
What is the total cost of all 'humanitarian_aid' operations before 2000 in the 'aid_operations' table?
|
SELECT SUM(cost) FROM aid_operations WHERE start_date < '2000-01-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE employee (id INT, name TEXT, department TEXT, role TEXT, location TEXT); INSERT INTO employee (id, name, department, role, location) VALUES (1, 'John Doe', 'Mining', 'Operator', 'Colorado, USA'), (2, 'Jane Smith', 'Environment', 'Analyst', 'Colorado, USA');
|
What is the total number of employees in mining operations by country?
|
SELECT SUBSTRING(location, 1, INSTR(location, ',') - 1) as country, COUNT(*) as num_employees FROM employee WHERE department LIKE '%Mining%' GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE production_data (id INT PRIMARY KEY, mine_id INT, year INT, monthly_production INT);CREATE TABLE reclamation_data (id INT PRIMARY KEY, mine_id INT, year INT, reclamation_cost INT);CREATE TABLE mine_employees (id INT PRIMARY KEY, mine_id INT, employee_id INT, employment_start_date DATE, employment_end_date DATE);CREATE TABLE employee_demographics (id INT PRIMARY KEY, employee_id INT, gender VARCHAR(255), ethnicity VARCHAR(255));CREATE VIEW employee_stats AS SELECT mine_id, COUNT(employee_id) as employee_count FROM mine_employees GROUP BY mine_id;CREATE VIEW operation_duration AS SELECT mine_id, COUNT(DISTINCT year) as operation_years FROM production_data GROUP BY mine_id;
|
What is the total reclamation cost and number of employees for mines in the Asia-Pacific region with more than 500 employees?
|
SELECT r.mine_id, SUM(r.reclamation_cost) as total_reclamation_cost, e.employee_count FROM reclamation_data r JOIN employee_stats e ON r.mine_id = e.mine_id WHERE r.mine_id IN (SELECT mine_id FROM employee_stats WHERE employee_count > 500) AND e.mine_id IN (SELECT mine_id FROM employee_stats WHERE employee_count > 500) AND r.mine_id IN (SELECT mine_id FROM operation_duration WHERE operation_years > 5) GROUP BY r.mine_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE crop_yields (id INT, crop VARCHAR(50), yield FLOAT, state VARCHAR(50)); INSERT INTO crop_yields (id, crop, yield, state) VALUES (1, 'Corn', 115, 'IA'), (2, 'Corn', 98, 'IN'), (3, 'Soybeans', 45, 'IL'), (4, 'Wheat', 75, 'KS');
|
Delete records from the 'crop_yields' table where 'crop' is 'Corn' and yield is below 100 bushels per acre.
|
DELETE FROM crop_yields WHERE crop = 'Corn' AND yield < 100;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ProductRecalls (BrandID INT, ProductID INT, RecallDate DATE, Country VARCHAR(50)); CREATE TABLE Brands (BrandID INT, BrandName VARCHAR(50)); INSERT INTO ProductRecalls (BrandID, ProductID, RecallDate, Country) VALUES (3001, 300, '2022-01-01', 'India'), (3002, 301, '2022-02-01', 'India'), (3003, 302, '2022-03-01', 'India'), (3001, 303, '2022-04-01', 'India'), (3004, 304, '2022-05-01', 'India'); INSERT INTO Brands (BrandID, BrandName) VALUES (3001, 'BrandA'), (3002, 'BrandB'), (3003, 'BrandC'), (3004, 'BrandD');
|
What are the top 2 cosmetic brands with the most product recalls in India?
|
SELECT B.BrandName, COUNT(*) AS RecallCount FROM ProductRecalls PR INNER JOIN Brands B ON PR.BrandID = B.BrandID WHERE PR.Country = 'India' GROUP BY B.BrandName ORDER BY RecallCount DESC LIMIT 2;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE WorkplaceSafetyInspections (id INT, location VARCHAR, inspection_date DATE, violations INT);
|
What is the total number of workplace safety inspections in Pennsylvania with more than 5 violations?
|
SELECT COUNT(id) as num_inspections FROM WorkplaceSafetyInspections WHERE location = 'Pennsylvania' AND violations > 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Cities (CityID INT, CityName VARCHAR(50), WasteGeneration FLOAT, Population INT, CircularEconomy BOOLEAN); INSERT INTO Cities VALUES (1, 'CityA', 1200, 800000, FALSE), (2, 'CityB', 1800, 1200000, TRUE), (3, 'CityC', 1500, 1000000, FALSE), (4, 'CityD', 2000, 900000, FALSE);
|
What is the waste generation by city for cities with a population above 750,000 that are not part of a circular economy initiative?
|
SELECT CityName, WasteGeneration FROM Cities WHERE Population > 750000 AND CircularEconomy = FALSE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE manufacturing_processes (id INT, name TEXT, co2_emissions INT); INSERT INTO manufacturing_processes (id, name, co2_emissions) VALUES (1, 'Cutting', 50), (2, 'Sewing', 30), (3, 'Dyeing', 70); CREATE TABLE manufacturers (id INT, name TEXT, country TEXT); INSERT INTO manufacturers (id, name, country) VALUES (1, 'ManufacturerA', 'Germany'), (2, 'ManufacturerB', 'Germany'); CREATE TABLE process_emissions (process_id INT, manufacturer_id INT, emissions INT); INSERT INTO process_emissions (process_id, manufacturer_id, emissions) VALUES (1, 1, 100), (2, 1, 80), (3, 1, 150), (1, 2, 120), (2, 2, 70), (3, 2, 180);
|
What is the total CO2 emissions of each manufacturing process in Germany?
|
SELECT mp.name, SUM(pe.emissions) FROM manufacturing_processes mp JOIN process_emissions pe ON mp.id = pe.process_id JOIN manufacturers m ON pe.manufacturer_id = m.id WHERE m.country = 'Germany' GROUP BY mp.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customers (id INT, name VARCHAR(50), device VARCHAR(20)); CREATE TABLE orders (id INT, customer_id INT, order_value DECIMAL(10,2)); INSERT INTO customers (id, name, device) VALUES (1, 'Customer A', 'mobile'), (2, 'Customer B', 'desktop'), (3, 'Customer C', 'mobile'); INSERT INTO orders (id, customer_id, order_value) VALUES (1, 1, 100.00), (2, 2, 75.20), (3, 1, 50.00);
|
What is the number of unique customers who have made purchases using a mobile device in Canada?
|
SELECT COUNT(DISTINCT customers.id) FROM customers INNER JOIN orders ON customers.id = orders.customer_id WHERE customers.device = 'mobile' AND customers.country = 'Canada';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE volunteers (volunteer_id INT, signup_date DATE); INSERT INTO volunteers (volunteer_id, signup_date) VALUES (1, '2020-01-05'), (2, '2020-02-12'), (3, '2020-03-20'), (4, '2019-12-31');
|
How many volunteers signed up in each month of 2020 from the 'volunteers' table?
|
SELECT DATEPART(YEAR, signup_date) as year, DATEPART(MONTH, signup_date) as month, COUNT(*) as num_volunteers FROM volunteers WHERE YEAR(signup_date) = 2020 GROUP BY DATEPART(YEAR, signup_date), DATEPART(MONTH, signup_date);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Investments (InvestmentID INT, Country VARCHAR(20), Amount INT); INSERT INTO Investments (InvestmentID, Country, Amount) VALUES (1, 'USA', 4000), (2, 'Canada', 3000), (3, 'Mexico', 5000), (4, 'Brazil', 6000), (5, 'USA', 7000), (6, 'Canada', 8000);
|
What is the total investment amount made in each country?
|
SELECT Country, SUM(Amount) as TotalInvestment FROM Investments GROUP BY Country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE State (StateName VARCHAR(50), Country VARCHAR(50), NumberOfPublicLibraries INT, Population INT); INSERT INTO State (StateName, Country, NumberOfPublicLibraries, Population) VALUES ('California', 'United States', 1500, 39500000), ('Texas', 'United States', 500, 29500000), ('New York', 'United States', 1000, 20000000);
|
What is the population rank of the state with the most public libraries in the United States?
|
SELECT ROW_NUMBER() OVER (ORDER BY NumberOfPublicLibraries DESC) AS PopulationRank, StateName FROM State WHERE Country = 'United States';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Employees (EmployeeID INT, FirstName VARCHAR(50), LastName VARCHAR(50), Position VARCHAR(50), Department VARCHAR(50), Salary DECIMAL(10,2)); INSERT INTO Employees (EmployeeID, FirstName, LastName, Position, Department, Salary) VALUES (1, 'John', 'Doe', 'Engineer', 'Aerospace', 75000.00); INSERT INTO Employees (EmployeeID, FirstName, LastName, Position, Department, Salary) VALUES (2, 'Jane', 'Doe', 'Manager', 'Flight Safety', 85000.00);
|
Get the average salary for Engineers in the Aerospace Department
|
SELECT AVG(Salary) FROM Employees WHERE Position = 'Engineer' AND Department = 'Aerospace';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE community_education (id INT PRIMARY KEY, program_name VARCHAR, num_participants INT);
|
How many education programs are in the 'community_education' table?
|
SELECT COUNT(*) FROM community_education;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE technology_accessibility_scores (id INT, country VARCHAR(255), score FLOAT); CREATE VIEW lowest_tech_accessibility AS SELECT country, score FROM technology_accessibility_scores WHERE score = (SELECT MIN(score) FROM technology_accessibility_scores); CREATE VIEW highest_tech_accessibility AS SELECT country, score FROM technology_accessibility_scores WHERE score = (SELECT MAX(score) FROM technology_accessibility_scores);
|
Which countries have the lowest and highest technology accessibility scores in the world?
|
SELECT * FROM lowest_tech_accessibility; SELECT * FROM highest_tech_accessibility;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE brands (brand_name VARCHAR(50), country VARCHAR(50), is_eco_friendly BOOLEAN); INSERT INTO brands (brand_name, country, is_eco_friendly) VALUES ('Brand X', 'US', true), ('Brand Y', 'Canada', false);
|
What is the market share of eco-friendly cosmetics brands in the US?
|
SELECT COUNT(*) * 100.0 / (SELECT COUNT(*) FROM brands WHERE country = 'US') FROM brands WHERE is_eco_friendly = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE public.property_utilities (id serial PRIMARY KEY, property_id integer, utility_type varchar, utility_cost integer, utility_start_date date, utility_end_date date);
|
What is the total cost of all utility services for property 3?
|
SELECT SUM(utility_cost) FROM property_utilities WHERE property_id = 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE co_owners (id INT, name VARCHAR(30), property_id INT); CREATE TABLE properties (id INT, address VARCHAR(50), city VARCHAR(20)); INSERT INTO co_owners (id, name, property_id) VALUES (1, 'Alex', 101), (2, 'Bella', 101), (3, 'Charlie', 102); INSERT INTO properties (id, address, city) VALUES (101, '1234 SE Stark St', 'Vancouver'), (102, '5678 NE 20th Ave', 'Vancouver');
|
List the co-owners and their shared property addresses in Vancouver, BC.
|
SELECT co_owners.name, properties.address FROM co_owners INNER JOIN properties ON co_owners.property_id = properties.id WHERE properties.city = 'Vancouver';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sustainable_sourcing (item_id INT, sourcing_date DATE, sustainability_practice VARCHAR(255));
|
Insert a new record for a sustainable sourcing practice
|
INSERT INTO sustainable_sourcing (item_id, sourcing_date, sustainability_practice) VALUES (456, '2022-05-01', 'Organic Ingredients');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE code_updates (dapp_name VARCHAR(20), industry_sector VARCHAR(10), quarter INT, update_count INT); INSERT INTO code_updates (dapp_name, industry_sector, quarter, update_count) VALUES ('AppA', 'Storage', 1, 500), ('AppB', 'Storage', 2, 750), ('AppC', 'Storage', 3, 1000), ('AppD', 'Storage', 4, 1250), ('AppE', 'Storage', 2, 1500);
|
Identify the decentralized application with the most code updates in the 'Storage' industry sector during Q2 2022.
|
SELECT dapp_name, update_count FROM code_updates WHERE industry_sector = 'Storage' AND quarter = 2 ORDER BY update_count DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE security_incidents (id INT, incident_type TEXT, date_reported DATE, severity TEXT); INSERT INTO security_incidents (id, incident_type, date_reported, severity) VALUES (1, 'Phishing', '2022-01-01', 'High');
|
What is the total number of security incidents for each severity level in Q1 2022?
|
SELECT severity, SUM(CASE WHEN date_reported >= '2022-01-01' AND date_reported < '2022-02-01' THEN 1 ELSE 0 END) as count_january, SUM(CASE WHEN date_reported >= '2022-02-01' AND date_reported < '2022-03-01' THEN 1 ELSE 0 END) as count_february, SUM(CASE WHEN date_reported >= '2022-03-01' AND date_reported < '2022-04-01' THEN 1 ELSE 0 END) as count_march FROM security_incidents WHERE severity IN ('Critical', 'High', 'Medium', 'Low') GROUP BY severity;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE financial_capability_programs (provider VARCHAR(50), program VARCHAR(50), country VARCHAR(50)); INSERT INTO financial_capability_programs (provider, program, country) VALUES ('Bank C', 'Financial Literacy 101', 'USA'), ('Credit Union D', 'Youth Financial Education', 'Canada');
|
List all financial capability programs offered by providers in the US?
|
SELECT DISTINCT provider, program FROM financial_capability_programs WHERE country = 'USA';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donors (donor_id INT, donor_name TEXT, country TEXT, amount DECIMAL(10,2)); INSERT INTO donors (donor_id, donor_name, country, amount) VALUES (1, 'John Doe', 'USA', 100.00); INSERT INTO donors (donor_id, donor_name, country, amount) VALUES (2, 'Jane Smith', 'Canada', 200.00);
|
What is the total amount donated by individuals in the United States?
|
SELECT SUM(amount) FROM donors WHERE country = 'USA';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE fair_labor_practices (practice_id INT, brand_id INT, region TEXT, workers_benefitted INT);
|
Decrease the number of workers benefitting from fair labor practices in 'Africa' by 20% in the 'fair_labor_practices' table.
|
UPDATE fair_labor_practices SET workers_benefitted = workers_benefitted * 0.8 WHERE region = 'Africa';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE public_defenders (defender_id INT, cases_handled INT, year INT);
|
What is the maximum number of cases handled by a public defender in a year?
|
SELECT MAX(cases_handled) FROM public_defenders WHERE year = (SELECT MAX(year) FROM public_defenders);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cultural_sites (site_id INT, country VARCHAR(20), type VARCHAR(20)); INSERT INTO cultural_sites (site_id, country, type) VALUES (1, 'Spain', 'heritage'), (2, 'Portugal', 'heritage'), (3, 'Spain', 'heritage'), (4, 'Spain', 'virtual'), (5, 'Portugal', 'virtual');
|
Identify the number of cultural heritage sites and virtual tours offered in Spain and Portugal, and find the difference between the two numbers.
|
SELECT COUNT(*) FROM cultural_sites WHERE country = 'Spain' AND type = 'heritage' UNION ALL SELECT COUNT(*) FROM cultural_sites WHERE country = 'Portugal' AND type = 'heritage' UNION ALL SELECT COUNT(*) FROM cultural_sites WHERE country = 'Spain' AND type = 'virtual' UNION ALL SELECT COUNT(*) FROM cultural_sites WHERE country = 'Portugal' AND type = 'virtual' EXCEPT (SELECT * FROM (SELECT COUNT(*) FROM cultural_sites WHERE country = 'Spain' AND type = 'heritage' UNION ALL SELECT COUNT(*) FROM cultural_sites WHERE country = 'Portugal' AND type = 'heritage' UNION ALL SELECT COUNT(*) FROM cultural_sites WHERE country = 'Spain' AND type = 'virtual' UNION ALL SELECT COUNT(*) FROM cultural_sites WHERE country = 'Portugal' AND type = 'virtual') AS subquery);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE readers (id INT, name VARCHAR(50), age INT, gender VARCHAR(10), country VARCHAR(50));
|
What is the average age of readers in 'readers' table?
|
SELECT AVG(age) FROM readers;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ports (port_id INT, port_name TEXT, country TEXT); INSERT INTO ports VALUES (1, 'Port A', 'Germany'), (2, 'Port B', 'France'), (3, 'Port C', 'Spain'); CREATE TABLE cargo (cargo_id INT, port_id INT, quantity INT, handling_date DATE); INSERT INTO cargo VALUES (1, 1, 500, '2022-01-01'), (2, 1, 600, '2022-01-02'), (3, 2, 700, '2022-01-01'), (4, 1, 800, '2022-04-03');
|
What is the total number of containers handled at ports in Europe, grouped by the quarter in which they were handled?
|
SELECT COUNT(cargo.quantity) FROM cargo JOIN ports ON cargo.port_id = ports.port_id WHERE ports.country = 'Europe' GROUP BY EXTRACT(QUARTER FROM cargo.handling_date);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Waste (WasteID INT, WasteType VARCHAR(50), Amount INT, Date DATE); INSERT INTO Waste (WasteID, WasteType, Amount, Date) VALUES (1, 'Toxic Chemicals', 120, '2022-01-01'); INSERT INTO Waste (WasteID, WasteType, Amount, Date) VALUES (2, 'Radioactive Waste', 50, '2022-02-01'); INSERT INTO Waste (WasteID, WasteType, Amount, Date) VALUES (3, 'Plastic Waste', 80, '2022-03-01');
|
Delete all records from the Waste table that have a WasteType of 'Radioactive Waste'.
|
DELETE FROM Waste WHERE WasteType = 'Radioactive Waste';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE organizations (org_id INT, org_name VARCHAR(50), org_city_id INT);CREATE TABLE donations (donation_id INT, donor_city_id INT, org_id INT); INSERT INTO organizations (org_id, org_name, org_city_id) VALUES (1, 'Habitat for Humanity', 1), (2, 'Greenpeace', 2), (3, 'American Cancer Society', 3); INSERT INTO donations (donation_id, donor_city_id, org_id) VALUES (1, 1, 1), (2, 2, 2), (3, 3, 3), (4, 1, 2), (5, 2, 3);
|
Which organizations have received donations from donors residing in the same city as the organization's headquarters?
|
SELECT o.org_name, d.donor_city_id FROM organizations o INNER JOIN donations d ON o.org_city_id = d.donor_city_id AND o.org_id = d.org_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Archaeologists (ArchaeologistID INT, Name VARCHAR(50), Age INT); INSERT INTO Archaeologists (ArchaeologistID, Name, Age) VALUES (1, 'Alex Nguyen', 35); CREATE TABLE Excavations (ExcavationID INT, Site VARCHAR(50), ArchaeologistID INT, Budget DECIMAL(10,2)); INSERT INTO Excavations (ExcavationID, Site, ArchaeologistID, Budget) VALUES (1, 'Vietnam Dig', 1, 25000.00); INSERT INTO Excavations (ExcavationID, Site, ArchaeologistID, Budget) VALUES (2, 'Cambodia Exploration', 1, 30000.00);
|
What is the average budget for excavations led by archaeologist 'Alex Nguyen'?
|
SELECT AVG(E.Budget) FROM Archaeologists A INNER JOIN Excavations E ON A.ArchaeologistID = E.ArchaeologistID WHERE A.Name = 'Alex Nguyen';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE veteran_employment (state VARCHAR(255), gender VARCHAR(255), employed_veterans INT, total_veterans INT); INSERT INTO veteran_employment (state, gender, employed_veterans, total_veterans) VALUES ('California', 'Male', 400000, 600000), ('California', 'Female', 100000, 200000), ('Texas', 'Male', 350000, 550000), ('Texas', 'Female', 50000, 150000), ('Florida', 'Male', 300000, 500000), ('Florida', 'Female', 50000, 100000), ('New York', 'Male', 250000, 450000), ('New York', 'Female', 50000, 100000), ('Pennsylvania', 'Male', 200000, 400000), ('Pennsylvania', 'Female', 50000, 100000);
|
What are the veteran employment statistics by state and gender?
|
SELECT state, gender, SUM(employed_veterans) FROM veteran_employment GROUP BY state, gender;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE speakers (id INT PRIMARY KEY, name VARCHAR(255), affiliation VARCHAR(255), country VARCHAR(255)); INSERT INTO speakers (id, name, affiliation, country) VALUES (1, 'Dr. Joy Buolamwini', 'MIT Media Lab', 'USA'); INSERT INTO speakers (id, name, affiliation, country) VALUES (2, 'Prof. Virginia Dignum', 'Umeå University', 'Sweden'); INSERT INTO speakers (id, name, affiliation, country) VALUES (3, 'Dr. Rumman Chowdhury', 'Twitter', 'USA'); CREATE TABLE talks (id INT PRIMARY KEY, title VARCHAR(255), speaker_id INT, conference_id INT, date DATE); INSERT INTO talks (id, title, speaker_id, conference_id, date) VALUES (1, 'Algorithms of Oppression', 1, 6, '2022-10-02'); INSERT INTO talks (id, title, speaker_id, conference_id, date) VALUES (2, 'Ethics for AI in Healthcare', 1, 5, '2022-10-02'); INSERT INTO talks (id, title, speaker_id, conference_id, date) VALUES (3, 'Accountable AI Systems', 2, 4, '2022-09-02'); INSERT INTO talks (id, title, speaker_id, conference_id, date) VALUES (4, 'Responsible AI in Social Media', 3, 6, '2022-11-02'); CREATE TABLE conference_speakers (talk_id INT, speaker_id INT); INSERT INTO conference_speakers (talk_id, speaker_id) VALUES (1, 1); INSERT INTO conference_speakers (talk_id, speaker_id) VALUES (2, 1); INSERT INTO conference_speakers (talk_id, speaker_id) VALUES (3, 2); INSERT INTO conference_speakers (talk_id, speaker_id) VALUES (4, 3);
|
Which speakers have given talks on ethical AI at the AI for Social Good Summit?
|
SELECT speakers.name FROM speakers JOIN conference_speakers ON speakers.id = conference_speakers.speaker_id JOIN talks ON conference_speakers.talk_id = talks.id WHERE talks.title LIKE '%ethical AI%' AND talks.conference_id = 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Concerts (country VARCHAR(50), genre VARCHAR(50), price DECIMAL(5,2)); INSERT INTO Concerts (country, genre, price) VALUES ('UK', 'Pop', 35.99); INSERT INTO Concerts (country, genre, price) VALUES ('UK', 'Pop', 39.49);
|
What is the minimum ticket price for Pop concerts in the UK?
|
SELECT MIN(price) FROM Concerts WHERE country = 'UK' AND genre = 'Pop';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE farm2 (id INT, sensor_id INT, temperature FLOAT); INSERT INTO farm2 (id, sensor_id, temperature) VALUES (1, 101, -2.3), (2, 102, -6.1), (3, 103, 0.5);
|
Find the number of IoT sensors in 'farm2' that recorded a minimum temperature below -5 degrees Celsius.
|
SELECT COUNT(*) FROM farm2 WHERE temperature < -5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE evaluations (evaluation_id INT, evaluation_date DATE, region_id INT);
|
What is the total number of health equity metric evaluations conducted in each region?
|
SELECT region_id, COUNT(*) as evaluation_count FROM evaluations GROUP BY region_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE tours (id INT, name TEXT, country TEXT, rating FLOAT, reviews INT); INSERT INTO tours (id, name, country, rating, reviews) VALUES (1, 'Milford Sound Day Tour', 'New Zealand', 4.6, 120), (2, 'Doubtful Sound Day Tour', 'New Zealand', 4.7, 80), (3, 'Hobbiton Movie Set Tour', 'New Zealand', 4.8, 250);
|
What is the average rating of tours in New Zealand with more than 100 reviews?
|
SELECT AVG(rating) FROM tours WHERE country = 'New Zealand' AND reviews > 100;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE fire_incidents (id INT, incident_time TIMESTAMP, district VARCHAR(20)); INSERT INTO fire_incidents (id, incident_time, district) VALUES (1, '2022-02-01 12:30:00', 'brooklyn'), (2, '2022-02-02 15:10:00', 'bronx'), (3, '2022-02-02 09:45:00', 'brooklyn');
|
What is the maximum number of fire incidents in 'brooklyn' that occurred in a single day?
|
SELECT district, MAX(COUNT(*)) OVER (PARTITION BY district) AS max_incidents_per_day FROM fire_incidents GROUP BY district, DATE_TRUNC('day', incident_time);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE orders (order_id INT, location_id INT, item_id INT, quantity INT, date DATE); CREATE TABLE menu (item_id INT, item_name VARCHAR(50), category VARCHAR(50), cuisine VARCHAR(50), price DECIMAL(5,2));
|
Show me the total revenue for each location in the past month.
|
SELECT o.location_id, SUM(m.price * o.quantity) as total_revenue FROM orders o JOIN menu m ON o.item_id = m.item_id WHERE o.date >= CURDATE() - INTERVAL 1 MONTH GROUP BY o.location_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ota_revenue (country VARCHAR(255), revenue DECIMAL(10, 2));
|
What is the total online travel agency revenue for each country?
|
SELECT country, SUM(revenue) FROM ota_revenue GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE startups(id INT, name VARCHAR(50), sector VARCHAR(50), total_funding FLOAT, founded_date DATE);INSERT INTO startups (id, name, sector, total_funding, founded_date) VALUES (1, 'StartupA', 'Genetics', 20000000, '2018-05-15');INSERT INTO startups (id, name, sector, total_funding, founded_date) VALUES (2, 'StartupB', 'Bioprocess', 15000000, '2019-12-20');
|
List all biotech startups founded in the last 3 years, along with their funding amounts.
|
SELECT name, total_funding FROM startups WHERE founded_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 YEAR);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE products(id INT, name TEXT, launch_year INT, safety_issue TEXT); INSERT INTO products(id, name, launch_year, safety_issue) VALUES (1, 'Cleanser X', 2021, 'microplastic use'), (2, 'Lotion Y', 2020, 'paraben content'), (3, 'Shampoo Z', 2021, 'none'), (4, 'Conditioner W', 2019, 'formaldehyde content');
|
List the safety issues for products launched in 2021.
|
SELECT name, safety_issue FROM products WHERE launch_year = 2021 AND safety_issue IS NOT NULL;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE veteran_hiring_stats (state VARCHAR(2), year INT, total_veterans INT, hired_veterans INT);
|
Create a table for storing veteran hiring statistics
|
INSERT INTO veteran_hiring_stats (state, year, total_veterans, hired_veterans) VALUES ('NY', 2020, 5000, 3500);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE user_content_views (view_id INT, user_id INT, content_id INT, view_date DATE, user_gender VARCHAR(10), watch_time INT); CREATE TABLE content (content_id INT, content_category VARCHAR(20));
|
What is the average watch time per user for each content category, segmented by gender?
|
SELECT content.content_category, user_gender, AVG(watch_time) as avg_watch_time FROM user_content_views JOIN content ON user_content_views.content_id = content.content_id GROUP BY content.content_category, user_gender;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE energy_storage_projects (quarter VARCHAR(6), region VARCHAR(255), num_projects INT); INSERT INTO energy_storage_projects (quarter, region, num_projects) VALUES ('Q3 2022', 'Europe', 20), ('Q3 2022', 'Asia', 18), ('Q4 2022', 'Europe', 22);
|
How many energy storage projects were initiated in Europe in Q3 2022?
|
SELECT num_projects FROM energy_storage_projects WHERE quarter = 'Q3 2022' AND region = 'Europe'
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donations (id SERIAL PRIMARY KEY, donor_name VARCHAR(255), donation_amount INTEGER, donation_date DATE);
|
Create a new table for storing disaster donation records
|
CREATE TABLE donations (id SERIAL PRIMARY KEY, donor_name VARCHAR(255), donation_amount INTEGER, donation_date DATE);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE HealthcareFacilities (Name VARCHAR(255), City VARCHAR(255), Specialized BOOLEAN); INSERT INTO HealthcareFacilities (Name, City, Specialized) VALUES ('Facility A', 'City X', TRUE), ('Facility B', 'City X', FALSE), ('Facility C', 'City Y', TRUE);
|
Delete all healthcare facilities in 'City X' that do not offer mental health services.
|
DELETE FROM HealthcareFacilities WHERE City = 'City X' AND Specialized = FALSE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE aquafarms (id INT, name TEXT, location TEXT); INSERT INTO aquafarms (id, name, location) VALUES (1, 'Farm A', 'Atlantic'), (2, 'Farm B', 'Pacific'); CREATE TABLE oxygen_data (aquafarm_id INT, timestamp TIMESTAMP, oxygen_level FLOAT);
|
What is the average dissolved oxygen level per week for each aquafarm in the Atlantic region?
|
SELECT aquafarm_id, AVG(oxygen_level) AS avg_oxygen_level, EXTRACT(WEEK FROM timestamp) AS week FROM oxygen_data JOIN aquafarms ON oxygen_data.aquafarm_id = aquafarms.id WHERE location LIKE 'Atlantic%' GROUP BY aquafarm_id, week;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE textile_industry (id INT PRIMARY KEY, country VARCHAR(50), workers INT, avg_salary FLOAT); INSERT INTO textile_industry (id, country, workers, avg_salary) VALUES (1, 'China', 3000000, 5000.00), (2, 'India', 2500000, 4000.00), (3, 'United States', 1000000, 6000.00), (4, 'Indonesia', 800000, 3500.00), (5, 'Bangladesh', 600000, 2500.00);
|
How many workers are employed in the textile industry in each country, and what is their average salary?
|
SELECT country, workers, AVG(avg_salary) FROM textile_industry GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Building (building_id INT, region VARCHAR(20), construction_cost DECIMAL(10,2)); INSERT INTO Building (building_id, region, construction_cost) VALUES (1, 'West', 3000000.00), (2, 'Midwest', 2500000.00);
|
What is the maximum construction cost for a building in the West?
|
SELECT MAX(construction_cost) FROM Building WHERE region = 'West';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ProductIngredients (productID INT, ingredient VARCHAR(50), organic BOOLEAN); INSERT INTO ProductIngredients (productID, ingredient, organic) VALUES (1, 'Aloe Vera', true), (2, 'Chamomile', true), (3, 'Retinol', false), (4, 'Hyaluronic Acid', false);
|
Add a new organic ingredient 'Jojoba Oil' to the product with ID 2 in the ProductIngredients table.
|
INSERT INTO ProductIngredients (productID, ingredient, organic) VALUES (2, 'Jojoba Oil', true);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE patients (patient_id INT, age INT, gender VARCHAR(20), condition VARCHAR(50), registration_date DATE); INSERT INTO patients (patient_id, age, gender, condition, registration_date) VALUES (1, 35, 'Female', 'Depression', '2021-05-18'); CREATE TABLE treatments (treatment_id INT, patient_id INT, therapy_type VARCHAR(50), duration INT, treatment_date DATE); INSERT INTO treatments (treatment_id, patient_id, therapy_type, duration, treatment_date) VALUES (1, 1, 'CBT', 12, '2021-08-23');
|
How many patients have been treated with exposure therapy in the past 6 months?
|
SELECT COUNT(DISTINCT patients.patient_id) FROM patients JOIN treatments ON patients.patient_id = treatments.patient_id WHERE treatments.therapy_type = 'Exposure Therapy' AND treatments.treatment_date >= '2021-07-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE savings_accounts (id INT, customer_id INT, account_type VARCHAR(20), balance DECIMAL(10, 2), state VARCHAR(2)); INSERT INTO savings_accounts (id, customer_id, account_type, balance, state) VALUES (1, 101, 'Shariah', 5000, 'California'); CREATE TABLE customers (id INT, first_name VARCHAR(20), last_name VARCHAR(20), city VARCHAR(20)); INSERT INTO customers (id, first_name, last_name, city) VALUES (101, 'Ahmad', 'Ali', 'San Francisco');
|
What is the total balance of Shariah-compliant savings accounts for customers in California, grouped by city?
|
SELECT savings_accounts.state, customers.city, SUM(savings_accounts.balance) FROM savings_accounts INNER JOIN customers ON savings_accounts.customer_id = customers.id WHERE savings_accounts.account_type = 'Shariah' AND savings_accounts.state = 'California' GROUP BY customers.city;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MarineSpecies (SpeciesID INT, SpeciesName VARCHAR(255), Habitat VARCHAR(255), ConservationStatus VARCHAR(255));
|
Delete all records from the 'MarineSpecies' table where the 'SpeciesName' is 'Coral'
|
DELETE FROM MarineSpecies WHERE SpeciesName = 'Coral';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE project (project_id INT, region VARCHAR(20), labor_hours INT); INSERT INTO project VALUES (1, 'Northeast', 500); INSERT INTO project VALUES (2, 'Southwest', 700);
|
Determine the minimum and maximum labor hours per project by region.
|
SELECT region, MIN(labor_hours) as min_labor_hours, MAX(labor_hours) as max_labor_hours FROM project GROUP BY region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Neighborhoods (NeighborhoodID INT, NeighborhoodName VARCHAR(255)); CREATE TABLE Properties (PropertyID INT, NeighborhoodID INT, Size INT, Sustainable BOOLEAN, PropertyPrice INT);
|
What is the total value of sustainable properties in each neighborhood, ordered from highest to lowest?
|
SELECT NeighborhoodName, SUM(CASE WHEN Sustainable = 1 THEN PropertyPrice * Size ELSE 0 END) AS TotalValue FROM Properties JOIN Neighborhoods ON Properties.NeighborhoodID = Neighborhoods.NeighborhoodID GROUP BY NeighborhoodName ORDER BY TotalValue DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sales_data (drug_name TEXT, region TEXT, sales INTEGER);
|
Determine the market share of each sales region for a given drug.
|
SELECT region, SUM(sales) OVER (PARTITION BY region) / SUM(sales) OVER () AS market_share FROM sales_data WHERE drug_name = 'DrugX' GROUP BY 1 ORDER BY 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE PlayerTeam (PlayerID INT, TeamID INT); INSERT INTO PlayerTeam (PlayerID, TeamID) VALUES (101, 1), (102, 1), (103, 2), (104, 3);
|
Which players are part of the 'Apex Predators' team?
|
SELECT PlayerID FROM PlayerTeam WHERE TeamID = 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE conservation_status (id INT, species_name VARCHAR(50), status VARCHAR(20)); INSERT INTO conservation_status (id, species_name, status) VALUES (1, 'Green Sea Turtle', 'Least Concern'), (2, 'Clownfish', 'Least Concern'), (3, 'Bottlenose Dolphin', 'Data Deficient'), (4, 'Blue Whale', 'Critically Endangered');
|
Delete all records with a conservation status of 'Least Concern' from the 'conservation_status' table.
|
DELETE FROM conservation_status WHERE status = 'Least Concern';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Auctions (AuctionID INT, AuctionName TEXT, Year INT, Region TEXT, Revenue DECIMAL(10,2)); INSERT INTO Auctions (AuctionID, AuctionName, Year, Region, Revenue) VALUES (1, 'Christie''s New York', 2017, 'America', 5000000); INSERT INTO Auctions (AuctionID, AuctionName, Year, Region, Revenue) VALUES (2, 'Sotheby''s London', 2018, 'Europe', 6000000);
|
What is the total revenue generated by art auctions in the American region?
|
SELECT Region, SUM(Revenue) as TotalRevenue FROM Auctions WHERE Region = 'America' GROUP BY Region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ArtistSculptures (ArtistID INT, Year INT, TotalSculptures INT); INSERT INTO ArtistSculptures (ArtistID, Year, TotalSculptures) VALUES (1, 2020, 450), (1, 2021, 550), (2, 2020, 220), (2, 2021, 180), (3, 2020, 290), (3, 2021, 310);
|
Identify the artist with the most significant increase in the number of sculptures in their portfolio from 2020 to 2021.
|
SELECT ArtistID, (LAG(TotalSculptures, 1) OVER (PARTITION BY ArtistID ORDER BY Year) - TotalSculptures) AS Increase FROM ArtistSculptures WHERE Year = 2021 ORDER BY Increase DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE retailers (retailer_id INT, retailer_name VARCHAR(255), state VARCHAR(255)); INSERT INTO retailers (retailer_id, retailer_name, state) VALUES (1, 'Eco-Friendly Goods', 'California'); INSERT INTO retailers (retailer_id, retailer_name, state) VALUES (2, 'Green Retailer', 'California'); CREATE TABLE products (product_id INT, product_name VARCHAR(255), price DECIMAL(5,2), organic BOOLEAN); INSERT INTO products (product_id, product_name, price, organic) VALUES (1, 'Bio-Degradable Bags', 9.99, true); INSERT INTO products (product_id, product_name, price, organic) VALUES (2, 'Natural Soap', 5.49, true);
|
What is the average price of organic products sold by retailers located in California?
|
SELECT AVG(price) FROM products JOIN retailers ON retailers.retailer_id = products.retailer_id WHERE organic = true AND state = 'California';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SimulationScores (PlayerID int, PlayerName varchar(50), Game varchar(50), Score int); INSERT INTO SimulationScores (PlayerID, PlayerName, Game, Score) VALUES (1, 'Player1', 'Game4', 1000), (2, 'Player2', 'Game4', 1200), (3, 'Player3', 'Game4', 800), (4, 'Player4', 'Game4', 1400);
|
Delete players with a score below the average score in the 'Simulation' game category.
|
DELETE FROM SimulationScores WHERE Game = 'Game4' AND Score < (SELECT AVG(Score) FROM SimulationScores WHERE Game = 'Game4');
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA if not exists biotech;CREATE TABLE if not exists biotech.investments (id INT, startup_id INT, amount DECIMAL(10,2), investment_year INT); INSERT INTO biotech.investments (id, startup_id, amount, investment_year) VALUES (1, 1, 500000, 2020), (2, 2, 300000, 2019), (3, 1, 750000, 2020);
|
Find the average investment amount in biotech startups for the year 2020.
|
SELECT AVG(amount) FROM biotech.investments WHERE investment_year = 2020 AND startup_id IN (SELECT id FROM biotech.startups);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Workout (WorkoutID INT PRIMARY KEY, MemberID INT, Duration INT, Date DATE); CREATE TABLE Member (MemberID INT PRIMARY KEY, Age INT, Gender VARCHAR(10), MembershipStart DATE);
|
What is the total duration of workouts for members aged 30-40, grouped by gender?
|
SELECT Member.Gender, SUM(Workout.Duration) FROM Workout INNER JOIN Member ON Workout.MemberID = Member.MemberID WHERE Member.Age BETWEEN 30 AND 40 GROUP BY Member.Gender;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hydro_dams (id INT PRIMARY KEY, country VARCHAR(50), name VARCHAR(50), capacity FLOAT); INSERT INTO hydro_dams (id, country, name, capacity) VALUES (1, 'Brazil', 'Hydro Dam A', 300.5), (2, 'Brazil', 'Hydro Dam B', 320.2);
|
What is the average capacity of hydroelectric dams in Brazil?
|
SELECT AVG(capacity) FROM hydro_dams WHERE country = 'Brazil';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE smart_contracts (contract_id INT, contract_name VARCHAR(255), total_transactions INT); CREATE TABLE assets_contracts (asset_id INT, contract_id INT); CREATE TABLE assets (asset_id INT, asset_name VARCHAR(255));
|
List all digital assets with their respective smart contract names and the number of transactions, sorted by the total transaction count in descending order. If there is no associated smart contract, display 'N/A'.
|
SELECT a.asset_name, sc.contract_name, SUM(sc.total_transactions) as total_transactions FROM assets a LEFT JOIN assets_contracts ac ON a.asset_id = ac.asset_id LEFT JOIN smart_contracts sc ON ac.contract_id = sc.contract_id GROUP BY a.asset_id, sc.contract_name ORDER BY total_transactions DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE products (product_id INT, product_name TEXT, is_labor_practices_transparent BOOLEAN, price DECIMAL); INSERT INTO products (product_id, product_name, is_labor_practices_transparent, price) VALUES (1, 'Eco-Friendly Notebook', TRUE, 5.99), (2, 'Sustainable Sneakers', FALSE, 129.99), (3, 'Handmade Jewelry', TRUE, 89.99);
|
What is the maximum price of any product that is transparent about its labor practices?
|
SELECT MAX(price) FROM products WHERE is_labor_practices_transparent = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA IF NOT EXISTS smart_cities; CREATE TABLE IF NOT EXISTS smart_cities.smart_city_projects ( project_id INT NOT NULL, location VARCHAR(255) NOT NULL, project_status VARCHAR(255) NOT NULL, PRIMARY KEY (project_id));
|
Find the total number of smart city projects in the smart_cities schema that have project_status 'completed'.
|
SELECT COUNT(*) FROM smart_cities.smart_city_projects WHERE project_status = 'completed';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE facilities (facility_id INT, conditions_treated INT); INSERT INTO facilities (facility_id, conditions_treated) VALUES (1, 5), (2, 3), (3, 7), (4, 2);
|
What is the maximum number of mental health conditions treated at a single facility?
|
SELECT MAX(conditions_treated) FROM facilities;
|
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.