context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE Investments (InvestmentID int, InvestorName varchar(50), InvestmentType varchar(50), Sector varchar(50), InvestmentAmount numeric(18,2), InvestmentDate date); INSERT INTO Investments (InvestmentID, InvestorName, InvestmentType, Sector, InvestmentAmount, InvestmentDate) VALUES (1, 'Investor1', 'Impact Investment', 'Technology', 10000, '2020-01-01'), (2, 'Investor2', 'Impact Investment', 'Finance', 15000, '2019-01-01'), (3, 'Investor1', 'Impact Investment', 'Renewable Energy', 12000, '2020-01-01'), (4, 'Investor3', 'Impact Investment', 'Healthcare', 14000, '2020-01-01');
|
Find the number of impact investments made by each investor in 2020.
|
SELECT InvestorName, COUNT(*) FROM Investments WHERE YEAR(InvestmentDate) = 2020 AND InvestmentType = 'Impact Investment' GROUP BY InvestorName;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ExcavationSites (SiteID INT, SiteName VARCHAR(100), ArtifactID INT); INSERT INTO ExcavationSites (SiteID, SiteName, ArtifactID) VALUES (1, 'Site A', 1), (1, 'Site A', 2), (2, 'Site B', 3), (3, 'Site C', NULL), (4, 'Site D', 5), (5, 'Site E', 6); CREATE TABLE Artifacts (ArtifactID INT, Name VARCHAR(100), CreationDate DATETIME) INSERT INTO Artifacts (ArtifactID, Name, CreationDate) VALUES (1, 'Artifact 1', '2022-01-01'), (2, 'Artifact 2', '2022-01-01'), (3, 'Artifact 3', '2022-01-01'), (4, 'Artifact 4', '2022-01-01'), (5, 'Artifact 5', '2022-01-01'), (6, 'Artifact 6', '2022-01-01');
|
How many unique artifacts were found at each excavation site, excluding sites with no artifacts?
|
SELECT SiteName, COUNT(DISTINCT ArtifactID) as UniqueArtifactCount FROM ExcavationSites JOIN Artifacts ON ExcavationSites.ArtifactID = Artifacts.ArtifactID WHERE ExcavationSites.ArtifactID IS NOT NULL GROUP BY SiteName;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE machines (id INT PRIMARY KEY, name VARCHAR(255), type VARCHAR(255), status VARCHAR(255), last_maintenance_date DATE); INSERT INTO machines (id, name, type, status, last_maintenance_date) VALUES (1, 'Machine A', 'CNC', 'Operational', '2021-01-01'), (2, 'Machine B', 'Robotic Arm', 'Under Maintenance', '2022-05-15'), (3, 'Machine C', 'CNC', 'Operational', '2021-10-05'), (4, 'Machine D', 'Robotic Arm', 'Operational', '2022-02-03'), (5, 'Machine E', 'Conveyor Belt', 'Operational', '2021-06-12');
|
Retrieve the maximum and minimum last maintenance dates for all machines
|
SELECT MAX(last_maintenance_date) AS max_date, MIN(last_maintenance_date) AS min_date FROM machines;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Satellite_Launches (country VARCHAR(50), satellite_count INT, successful_missions INT); INSERT INTO Satellite_Launches (country, satellite_count, successful_missions) VALUES ('USA', 100, 90), ('Russia', 80, 75), ('China', 60, 55);
|
Which countries have launched the most satellites and have more than 5 successful space missions?
|
SELECT country FROM Satellite_Launches WHERE satellite_count > 50 AND successful_missions > 5 GROUP BY country ORDER BY satellite_count DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE DiversityInclusion (EmployeeID INT PRIMARY KEY, Gender VARCHAR(10), Ethnicity VARCHAR(20), Disability VARCHAR(10), Veteran VARCHAR(10), HireDate DATE);
|
Create a table for diversity and inclusion metrics
|
CREATE TABLE DiversityInclusion (EmployeeID INT PRIMARY KEY, Gender VARCHAR(10), Ethnicity VARCHAR(20), Disability VARCHAR(10), Veteran VARCHAR(10), HireDate DATE);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Astronauts (AstronautID INT, FirstName VARCHAR(50), LastName VARCHAR(50), Nationality VARCHAR(50), Missions INT); INSERT INTO Astronauts (AstronautID, FirstName, LastName, Nationality, Missions) VALUES (2, 'Rakesh', 'Sharma', 'India', 1);
|
Identify astronauts from India who have participated in more than 1 mission.
|
SELECT AstronautID, FirstName, LastName FROM Astronauts WHERE Nationality = 'India' AND Missions > 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Dispensaries (id INT, name TEXT, location TEXT, sale_price DECIMAL(5,2)); INSERT INTO Dispensaries (id, name, location, sale_price) VALUES (1, 'Cloud Nine', 'Denver', 15.00), (2, 'Euphoria', 'Boulder', 12.50), (3, 'Heavenly Buds', 'Colorado Springs', 14.00); CREATE TABLE Sales (dispensary_id INT, sale_date DATE); INSERT INTO Sales (dispensary_id, sale_date) VALUES (1, '2022-01-01'), (1, '2022-01-02'), (2, '2022-01-01'), (2, '2022-01-02'), (3, '2022-01-01'), (3, '2022-01-02');
|
What is the average sale price for each city?
|
SELECT location, AVG(sale_price) AS avg_sale_price FROM Dispensaries d JOIN Sales s ON d.id = s.dispensary_id GROUP BY location;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE factories_ext_2 (id INT, name VARCHAR(50), country VARCHAR(50), sector VARCHAR(50), is_renewable BOOLEAN); INSERT INTO factories_ext_2 (id, name, country, sector, is_renewable) VALUES (4, 'Hydro Factory', 'Brazil', 'renewable energy', TRUE), (5, 'Nuclear Factory', 'France', 'non-renewable energy', FALSE);
|
What is the total number of factories in the 'renewable energy' sector?
|
SELECT COUNT(*) FROM factories_ext_2 WHERE sector = 'renewable energy' AND is_renewable = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cities (city VARCHAR(255), gender VARCHAR(255), readers INT); INSERT INTO cities VALUES ('CityA', 'Female', 20000), ('CityB', 'Male', 30000);
|
What are the top 5 cities with the most female readership in 'the_news' newspaper?
|
SELECT city, SUM(readers) AS total_readers FROM cities WHERE gender = 'Female' GROUP BY city ORDER BY total_readers DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE renewable_energy (id INT, country VARCHAR(255), source VARCHAR(255), installed_capacity INT); INSERT INTO renewable_energy (id, country, source, installed_capacity) VALUES (1, 'Germany', 'Solar', 500), (2, 'France', 'Wind', 600), (3, 'Spain', 'Hydro', 700), (4, 'Italy', 'Geothermal', 800);
|
What is the minimum installed capacity of renewable energy sources in each country?
|
SELECT country, MIN(installed_capacity) FROM renewable_energy GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE products (product_id INT, is_vegan BOOLEAN, is_cruelty_free BOOLEAN, price DECIMAL(10, 2)); INSERT INTO products (product_id, is_vegan, is_cruelty_free, price) VALUES (1, true, true, 19.99), (2, false, false, 24.99), (3, true, true, 14.99); CREATE TABLE purchases (purchase_id INT, product_id INT, purchase_date DATE, quantity INT); INSERT INTO purchases (purchase_id, product_id, purchase_date, quantity) VALUES (1, 1, '2022-01-01', 2), (2, 2, '2022-01-05', 1), (3, 1, '2022-02-01', 1);
|
What is the total revenue for products that are both cruelty-free and vegan?
|
SELECT SUM(price * quantity) AS total_revenue FROM products INNER JOIN purchases ON products.product_id = purchases.product_id WHERE is_vegan = true AND is_cruelty_free = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Exhibitions (exhibition_id INT, exhibition_name VARCHAR(50), start_date DATE, end_date DATE); INSERT INTO Exhibitions (exhibition_id, exhibition_name, start_date, end_date) VALUES (1, 'Art of the Indigenous', '2023-01-01', '2023-12-31');
|
Update the exhibition 'Art of the Indigenous' to extend its duration until the end of 2024.
|
UPDATE Exhibitions SET end_date = '2024-12-31' WHERE exhibition_name = 'Art of the Indigenous';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE digital_assets_by_country (asset_id INT, country TEXT, asset_count INT); INSERT INTO digital_assets_by_country (asset_id, country, asset_count) VALUES (1, 'US', 100), (2, 'US', 75), (3, 'UK', 50), (4, 'DE', 125), (5, 'FR', 150), (6, 'JP', 75), (7, 'CN', 100);
|
What is the distribution of digital assets by country in the 'digital_assets_by_country' table?
|
SELECT country, SUM(asset_count) FROM digital_assets_by_country GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Species_2 (id INT, name VARCHAR(255), region VARCHAR(255), year INT); INSERT INTO Species_2 (id, name, region, year) VALUES (1, 'Penguin', 'Antarctica', 2020); INSERT INTO Species_2 (id, name, region, year) VALUES (2, 'Shark', 'Africa', 2020); INSERT INTO Species_2 (id, name, region, year) VALUES (3, 'Whale', 'Africa', 2020);
|
Which marine species were found in 'Antarctica' or 'Africa' in 2020?
|
SELECT name FROM Species_2 WHERE region = 'Antarctica' UNION SELECT name FROM Species_2 WHERE region = 'Africa';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Players (PlayerID INT, Age INT, Gender VARCHAR(10), Country VARCHAR(50)); INSERT INTO Players (PlayerID, Age, Gender, Country) VALUES (1, 25, 'Male', 'USA'); INSERT INTO Players (PlayerID, Age, Gender, Country) VALUES (2, 30, 'Female', 'Canada');
|
What is the minimum age of female players?
|
SELECT MIN(Players.Age) FROM Players WHERE Players.Gender = 'Female';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Volunteers (VolunteerID INT, VolunteerName TEXT, ProgramID INT, VolunteerDate DATE); INSERT INTO Volunteers (VolunteerID, VolunteerName, ProgramID, VolunteerDate) VALUES (20, 'Amy Wong', 1, '2022-06-01'), (21, 'Brian Lee', 2, '2022-06-15'), (22, 'Catherine Choi', 3, '2022-07-01'), (23, 'Daniel Kim', 4, '2022-07-15'), (24, 'Emily Chen', 1, '2022-07-01');
|
What is the number of volunteers who have volunteered in each program in the last 3 months?
|
SELECT ProgramID, COUNT(DISTINCT VolunteerID) OVER (PARTITION BY ProgramID ORDER BY VolunteerDate ROWS BETWEEN 3 PRECEDING AND CURRENT ROW) AS VolunteerCountInLast3Months FROM Volunteers;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE engagement (id INT, article_id INT, region VARCHAR(20), views INT, likes INT); INSERT INTO engagement (id, article_id, region, views, likes) VALUES (1, 1, 'Southern', 50, 30), (2, 2, 'Northern', 60, 40), (3, 3, 'Western', 45, 25), (4, 1, 'Southern', 75, 55); CREATE TABLE articles (id INT, title VARCHAR(50), category VARCHAR(20)); INSERT INTO articles (id, title, category) VALUES (1, 'Oil Prices Rising', 'politics'), (2, 'Government Corruption', 'politics'), (3, 'Baseball Game', 'sports');
|
Which news topics received the most engagement in the Southern region?
|
SELECT articles.category, SUM(engagement.views + engagement.likes) AS total_engagement FROM articles INNER JOIN engagement ON articles.id = engagement.article_id WHERE engagement.region = 'Southern' GROUP BY articles.category ORDER BY total_engagement DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE suppliers (id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255), industry VARCHAR(255)); INSERT INTO suppliers (id, name, country, industry) VALUES (3, 'Eco-Threads', 'India', 'Textile'); CREATE TABLE industry_4_0 (id INT PRIMARY KEY, supplier_id INT, automation_level DECIMAL(10,2), ai_integration BOOLEAN); INSERT INTO industry_4_0 (id, supplier_id, automation_level, ai_integration) VALUES (3, 3, 0.88, true);
|
What is the latest AI integration and automation level for suppliers from India in the textile industry?
|
SELECT i.ai_integration, i.automation_level FROM industry_4_0 i INNER JOIN suppliers s ON i.supplier_id = s.id WHERE s.country = 'India' AND s.industry = 'Textile' AND i.id IN (SELECT MAX(id) FROM industry_4_0 GROUP BY supplier_id);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE climate_finance (year INT, region VARCHAR(50), funding_type VARCHAR(50), amount INT);
|
What is the total climate finance provided to Small Island Developing States (SIDS) for climate adaptation projects in 2019?
|
SELECT SUM(amount) FROM climate_finance WHERE year = 2019 AND region = 'Small Island Developing States' AND funding_type = 'climate adaptation';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE weapons (id INT PRIMARY KEY, name VARCHAR(255), origin VARCHAR(255)); INSERT INTO weapons (id, name, origin) VALUES (1, 'AK-47', 'Russia'), (2, 'RPG-7', 'Russia'), (3, 'Mig-29', 'Russia');
|
Delete all records from the 'weapons' table where the 'name' is 'Mig-29'
|
DELETE FROM weapons WHERE name = 'Mig-29';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Players (PlayerID INT, Age INT, Gender VARCHAR(10));CREATE TABLE EsportsEvents (EventID INT, PlayerID INT, EventType VARCHAR(20));
|
List the names and genders of players who have participated in esports events, and the number of events they have participated in, sorted by the number of events in descending order.
|
SELECT Players.Name, Players.Gender, COUNT(EsportsEvents.EventID) FROM Players INNER JOIN EsportsEvents ON Players.PlayerID = EsportsEvents.PlayerID GROUP BY Players.Name, Players.Gender ORDER BY COUNT(EsportsEvents.EventID) DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE energy_efficiency.savings (saving_id int, project varchar(50), savings int); INSERT INTO energy_efficiency.savings (saving_id, project, savings) VALUES (1, 'Project G', 150), (2, 'Project H', 200), (3, 'Project I', 180);
|
What is the total energy efficiency savings for the 'energy_efficiency' schema?
|
SELECT SUM(savings) FROM energy_efficiency.savings;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE seoul_public_transport (transport_id INT, transport_type STRING, passenger_count INT, ride_date DATE);
|
Total number of passengers using public transportation in Seoul per day
|
SELECT ride_date, SUM(passenger_count) AS total_passengers FROM seoul_public_transport GROUP BY ride_date;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sustainable_materials (material_id INT, country VARCHAR(255), cost DECIMAL(10,2)); INSERT INTO sustainable_materials (material_id, country, cost) VALUES (1, 'Nepal', 5.50), (2, 'India', 4.25), (3, 'Bangladesh', 6.00);
|
What is the average sustainable material cost per country?
|
SELECT country, AVG(cost) as avg_cost FROM sustainable_materials GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE military_technology (id INT, country TEXT, technology_type TEXT, quantity INT); INSERT INTO military_technology (id, country, technology_type, quantity) VALUES (1, 'Russia', 'Missiles', 1000), (2, 'India', 'Missiles', 800), (3, 'Russia', 'Drones', 1500), (4, 'India', 'Drones', 1200);
|
List the types of military technology used by Russia and India, and the number of each type.
|
SELECT m.country, m.technology_type, m.quantity FROM military_technology m WHERE m.country IN ('Russia', 'India') GROUP BY m.technology_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE products (id INT, name TEXT, discontinued DATE, sustainable_package BOOLEAN, sustainable_package_date DATE);
|
Identify all products that were sold in a sustainable package before being discontinued.
|
SELECT name FROM products WHERE discontinued IS NOT NULL AND sustainable_package = TRUE AND sustainable_package_date < discontinued;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE virtual_tours (tour_id INT, hotel_id INT, country TEXT, user_count INT); INSERT INTO virtual_tours (tour_id, hotel_id, country, user_count) VALUES (1, 1, 'Japan', 50), (2, 1, 'China', 30), (3, 2, 'USA', 20); INSERT INTO virtual_tours (tour_id, hotel_id, country, user_count) VALUES (4, 3, 'India', 15);
|
What is the number of users who have engaged with virtual tours for hotels in Asia?
|
SELECT SUM(user_count) FROM virtual_tours WHERE country LIKE 'Asia%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE products (id INT, name VARCHAR(255), price DECIMAL(10,2), supplier_id INT);
|
What is the average price of products supplied by each supplier?
|
SELECT supplier_id, AVG(price) FROM products GROUP BY supplier_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Chemicals (ChemicalID INT, ChemicalName TEXT, EnvironmentalImpactScore DECIMAL(5,2)); INSERT INTO Chemicals (ChemicalID, ChemicalName, EnvironmentalImpactScore) VALUES (1, 'Chemical A', 25.3), (2, 'Chemical B', 15.6), (3, 'Chemical C', 35.7), (4, 'Chemical D', 45.8);
|
What is the environmental impact score of each chemical, sorted by the score in ascending order?
|
SELECT ChemicalName, EnvironmentalImpactScore FROM Chemicals ORDER BY EnvironmentalImpactScore ASC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE projects (project_id INT, project_name VARCHAR(50), discipline VARCHAR(20), project_type VARCHAR(20), open_pedagogy BOOLEAN, student_id INT); INSERT INTO projects (project_id, project_name, discipline, project_type, open_pedagogy, student_id) VALUES (1, 'Project X', 'History', 'Group', TRUE, 1001), (2, 'Project Y', 'Science', 'Individual', FALSE, 1002), (3, 'Project Z', 'Math', 'Group', TRUE, 1003);
|
How many students have participated in open pedagogy projects in each discipline?
|
SELECT discipline, COUNT(DISTINCT student_id) FROM projects WHERE open_pedagogy = TRUE GROUP BY discipline;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE biosensor_tech_development (id INT, tech_type TEXT, status TEXT, date_created DATE);
|
What is the status of biosensor technology development records for 'BioSensor-A'?
|
SELECT status FROM biosensor_tech_development WHERE tech_type = 'BioSensor-A';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE teachers (teacher_id INT, department_id INT, name VARCHAR(20), professional_development_course INT); INSERT INTO teachers (teacher_id, department_id, name, professional_development_course) VALUES (1, 1, 'James', 3), (2, 1, 'Emily', 2), (3, 2, 'Michael', 1), (4, 2, 'Olivia', 4); CREATE TABLE departments (department_id INT, name VARCHAR(20)); INSERT INTO departments (department_id, name) VALUES (1, 'English'), (2, 'Math');
|
What is the number of professional development courses completed by teachers in each department?
|
SELECT t.department_id, d.name, COUNT(t.professional_development_course) as courses_completed FROM teachers t JOIN departments d ON t.department_id = d.department_id GROUP BY t.department_id, d.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vessels (id INT, name VARCHAR(255), country VARCHAR(255), capacity INT, year_built INT); INSERT INTO vessels (id, name, country, capacity, year_built) VALUES (1, 'Vessel1', 'China', 10000, 2016), (2, 'Vessel2', 'Japan', 12000, 2018), (3, 'Vessel3', 'South Korea', 8000, 2013);
|
What is the total capacity of vessels in the vessels table that were built after 2015?
|
SELECT SUM(capacity) as total_capacity_after_2015 FROM vessels WHERE year_built > 2015;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE climate_finance (country VARCHAR(50), amount NUMERIC, year INT); INSERT INTO climate_finance (country, amount, year) VALUES ('USA', 10000000, 2020), ('China', 12000000, 2020), ('India', 8000000, 2020);
|
What is the total amount of climate finance committed by each country in 2020?
|
SELECT country, SUM(amount) as total_finance FROM climate_finance WHERE year = 2020 GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Departments (DepartmentID INT, Name TEXT, Budget DECIMAL);
|
What is the total budget for each department in the year 2021?
|
SELECT D.Name as DepartmentName, SUM(D.Budget) as TotalBudget2021 FROM Departments D WHERE YEAR(D.StartDate) = 2021 GROUP BY D.DepartmentID, D.Name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Chemicals (Chemical_ID INT, Chemical_Name TEXT, Safety_Incidents_Past_Year INT); INSERT INTO Chemicals (Chemical_ID, Chemical_Name, Safety_Incidents_Past_Year) VALUES (1, 'Chemical A', 4), (2, 'Chemical B', 7), (3, 'Chemical C', 2);
|
Identify the chemical with the highest safety incident count in the past year.
|
SELECT Chemical_Name, MAX(Safety_Incidents_Past_Year) as Highest_Incident_Count FROM Chemicals;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Spacecrafts (Spacecraft_ID INT, Name VARCHAR(255), Manufacturer VARCHAR(255), Mass FLOAT); INSERT INTO Spacecrafts (Spacecraft_ID, Name, Manufacturer, Mass) VALUES (1, 'Galactic Explorer', 'Galactic Instruments', 4500.2), (2, 'Nebula One', 'AstroTech', 2000.5), (3, 'Stellar Voyager', 'Cosmos Inc', 6000.0);
|
Delete records of spacecraft with a mass greater than 5000 kg from the 'Spacecrafts' table.
|
DELETE FROM Spacecrafts WHERE Mass > 5000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE InvestmentRounds (id INT, founder_id INT, funding_amount INT); INSERT INTO InvestmentRounds VALUES (1, 3, 7000000); CREATE TABLE Founders (id INT, name TEXT, ethnicity TEXT, industry TEXT); INSERT INTO Founders VALUES (3, 'Aaliyah', 'Indigenous', 'Renewable Energy');
|
What is the maximum funding amount received by Indigenous founders in the Renewable Energy sector?
|
SELECT MAX(InvestmentRounds.funding_amount) FROM InvestmentRounds JOIN Founders ON InvestmentRounds.founder_id = Founders.id WHERE Founders.ethnicity = 'Indigenous' AND Founders.industry = 'Renewable Energy';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE animal_relocation (species VARCHAR(50), relocation_reason VARCHAR(50));
|
List all the animals in the 'animal_population' table that were relocated due to habitat loss.
|
SELECT a.species FROM animal_population a JOIN animal_relocation r ON a.species = r.species WHERE r.relocation_reason = 'habitat loss';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE policies (id INT, policyholder_id INT, policy_type TEXT, issue_date DATE, expiry_date DATE); INSERT INTO policies (id, policyholder_id, policy_type, issue_date, expiry_date) VALUES (1, 3, 'Life', '2021-01-01', '2022-01-01'), (2, 4, 'Health', '2021-02-01', '2022-02-01'), (3, 5, 'Auto', '2021-03-01', '2022-03-01'); CREATE TABLE policyholders (id INT, name TEXT, state TEXT, policy_type TEXT); INSERT INTO policyholders (id, name, state, policy_type) VALUES (3, 'Alex Brown', 'Florida', 'Life'), (4, 'Bob Johnson', 'California', 'Health'), (5, 'Claire Williams', 'Texas', 'Auto');
|
Delete all policies that expired before 2021-01-01 for policyholders from Florida.
|
DELETE FROM policies WHERE policies.id IN (SELECT policies.id FROM policies JOIN policyholders ON policies.policyholder_id = policyholders.id WHERE policyholders.state = 'Florida' AND policies.expiry_date < '2021-01-01');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE media_companies (company_id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255), type VARCHAR(255)); CREATE VIEW spanish_companies AS SELECT company_id, name FROM media_companies WHERE country = 'Spain';
|
How many news articles were published by companies based in Spain?
|
SELECT COUNT(*) FROM content WHERE company_id IN (SELECT company_id FROM spanish_companies);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE court_appearances (id INT, case_id INT, appearance_date DATE, court_location VARCHAR(50)); INSERT INTO court_appearances (id, case_id, appearance_date, court_location) VALUES (1, 1001, '2019-01-01', 'Houston'), (2, 1001, '2019-02-01', 'Houston'), (3, 1002, '2019-03-01', 'Dallas');
|
What is the maximum number of court appearances required for a single criminal case in Texas?
|
SELECT MAX(id) FROM court_appearances WHERE case_id = 1001;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE subscribers(id INT, technology VARCHAR(20), type VARCHAR(10)); INSERT INTO subscribers(id, technology, type) VALUES (1, '4G', 'mobile'), (2, '5G', 'mobile'), (3, 'ADSL', 'broadband'), (4, 'FTTH', 'broadband');
|
What is the total number of broadband and mobile subscribers for each technology category?
|
SELECT technology, type, COUNT(*) AS total FROM subscribers GROUP BY technology, type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE farm (id INT, region VARCHAR(20), crop VARCHAR(20), yield INT); INSERT INTO farm (id, region, crop, yield) VALUES (1, 'region2', 'rice', 40), (2, 'region2', 'corn', 60);
|
What is the minimum yield of 'rice' in 'region2'?
|
SELECT MIN(yield) FROM farm WHERE region = 'region2' AND crop = 'rice';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE movie (id INT, title VARCHAR(255), genre VARCHAR(255), country VARCHAR(255)); INSERT INTO movie (id, title, genre, country) VALUES (1, 'Movie1', 'Comedy', 'Spain'), (2, 'Movie2', 'Drama', 'France'), (3, 'Movie3', 'Action', 'Spain');
|
What are the names of the movies and their genres for movies produced in France?
|
SELECT title, genre FROM movie WHERE country = 'France';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE volunteers (volunteer_id INT, volunteer_name TEXT, join_date DATE); INSERT INTO volunteers (volunteer_id, volunteer_name, join_date) VALUES (3, 'Charlie', '2022-04-10'), (4, 'Dana White', '2022-03-15');
|
How many volunteers joined in the last 3 months?
|
SELECT COUNT(volunteer_id) FROM volunteers WHERE join_date BETWEEN (CURRENT_DATE - INTERVAL '3 months') AND CURRENT_DATE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE foi_requests (request_date DATE, request_type VARCHAR(255)); INSERT INTO foi_requests (request_date, request_type) VALUES ('2022-01-01', 'submitted'), ('2022-01-15', 'submitted'), ('2022-02-03', 'submitted');
|
What is the average number of submitted freedom of information requests per month in 'foi_requests' table?
|
SELECT AVG(count) FROM (SELECT EXTRACT(MONTH FROM request_date) AS month, COUNT(*) AS count FROM foi_requests WHERE request_type = 'submitted' GROUP BY EXTRACT(MONTH FROM request_date)) AS subquery;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE doctors (doctor_id INT, name TEXT, age INT); INSERT INTO doctors (doctor_id, name, age) VALUES (1, 'Mohammed', 45), (2, 'Fatima', 50), (3, 'James', 35); CREATE TABLE patients (patient_id INT, doctor_id INT, age INT); INSERT INTO patients (patient_id, doctor_id, age) VALUES (1, 1, 25), (2, 1, 30), (3, 2, 45), (4, 2, 50), (5, 3, 20);
|
What is the average age of patients who received medication from doctors named "Mohammed" or "Fatima"?
|
SELECT AVG(patients.age) FROM patients JOIN doctors ON patients.doctor_id = doctors.doctor_id WHERE doctors.name IN ('Mohammed', 'Fatima');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE waste_generation (waste_type TEXT, amount INTEGER, date DATE); INSERT INTO waste_generation (waste_type, amount, date) VALUES ('plastic', 300, '2021-01-01'), ('paper', 250, '2021-01-01'), ('glass', 150, '2021-01-01');
|
What is the total waste generation in the first half of 2021?
|
SELECT SUM(amount) FROM waste_generation WHERE date >= '2021-01-01' AND date <= '2021-06-30';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE military_contracts (contractor VARCHAR(255), country VARCHAR(255), contract_amount DECIMAL(10, 2), negotiation_date DATE); INSERT INTO military_contracts (contractor, country, contract_amount, negotiation_date) VALUES ('Northrop Grumman', 'Germany', 5000000, '2015-02-14'), ('Northrop Grumman', 'Germany', 7000000, '2017-11-05'), ('Northrop Grumman', 'Germany', 8000000, '2021-04-20');
|
What is the total value of military contracts negotiated by Northrop Grumman with the German government from 2015 to 2021?
|
SELECT SUM(contract_amount) FROM military_contracts WHERE contractor = 'Northrop Grumman' AND country = 'Germany' AND YEAR(negotiation_date) BETWEEN 2015 AND 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE military_innovation (project_year INT, project_status VARCHAR(255));
|
What is the total number of military innovation projects completed in the last 5 years?
|
SELECT SUM(project_status) FROM military_innovation WHERE project_year >= YEAR(CURRENT_DATE) - 5 AND project_status = 'completed';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE departments (id INT, name TEXT); INSERT INTO departments (id, name) VALUES (1, 'Research'), (2, 'Production'), (3, 'Quality'), (4, 'Maintenance'); CREATE TABLE energy_consumption (dept_id INT, consumption_date DATE, energy_used FLOAT); INSERT INTO energy_consumption (dept_id, consumption_date, energy_used) VALUES (1, '2022-01-01', 500.0), (1, '2022-01-02', 510.0), (1, '2022-01-03', 495.0), (2, '2022-01-01', 800.0), (2, '2022-01-02', 805.0), (2, '2022-01-03', 795.0), (3, '2022-01-01', 300.0), (3, '2022-01-02', 310.0), (3, '2022-01-03', 295.0), (4, '2022-01-01', 600.0), (4, '2022-01-02', 610.0), (4, '2022-01-03', 595.0);
|
What is the total energy consumption by each department in the last quarter?
|
SELECT dept_id, SUM(energy_used) as total_energy_consumption FROM energy_consumption WHERE consumption_date BETWEEN DATE_SUB(NOW(), INTERVAL 3 MONTH) AND NOW() GROUP BY dept_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE emergency_calls (id INT, region VARCHAR(20), response_time INT, year INT);
|
What is the average response time for emergency calls in 'Harbor Side' this year?
|
SELECT AVG(response_time) FROM emergency_calls WHERE region = 'Harbor Side' AND year = YEAR(CURRENT_DATE);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE airport_info (airport_id INT, airport_name VARCHAR(50)); CREATE TABLE runway_lengths (airport_id INT, runway_length INT); INSERT INTO airport_info (airport_id, airport_name) VALUES (1, 'JFK Airport'), (2, 'LaGuardia Airport'), (3, 'Newark Airport'); INSERT INTO runway_lengths (airport_id, runway_length) VALUES (1, 14000), (2, 7000), (3, 11000);
|
List all the airports and their respective runway lengths from the 'airport_info' and 'runway_lengths' tables.
|
SELECT airport_info.airport_name, runway_lengths.runway_length FROM airport_info INNER JOIN runway_lengths ON airport_info.airport_id = runway_lengths.airport_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE uranium_mines (id INT, name VARCHAR(50), location VARCHAR(50), size INT, num_employees INT, co2_emissions INT); INSERT INTO uranium_mines VALUES (1, 'Uranium Mine 1', 'Canada', 450, 350, 25000); INSERT INTO uranium_mines VALUES (2, 'Uranium Mine 2', 'USA', 600, 400, 30000); INSERT INTO uranium_mines VALUES (3, 'Uranium Mine 3', 'Kazakhstan', 200, 150, 15000);
|
What is the total CO2 emissions for uranium mines that have more than 200 employees?
|
SELECT SUM(co2_emissions) FROM uranium_mines WHERE num_employees > 200;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Sites (SiteID INT, SiteName TEXT); INSERT INTO Sites (SiteID, SiteName) VALUES (1, 'Site-A'), (2, 'Site-B'), (3, 'Site-C'); CREATE TABLE Artifacts (ArtifactID INT, ArtifactName TEXT, SiteID INT, Age INT); INSERT INTO Artifacts (ArtifactID, ArtifactName, SiteID, Age) VALUES (1, 'Pottery Shard', 1, 1000), (2, 'Bronze Arrowhead', 2, 800), (3, 'Flint Tool', 3, 2000), (4, 'Ancient Coin', 1, 1500), (5, 'Stone Hammer', 2, 3000);
|
What are the earliest artifacts from each excavation site?
|
SELECT Sites.SiteName, MIN(Artifacts.Age) AS EarliestAge FROM Sites INNER JOIN Artifacts ON Sites.SiteID = Artifacts.SiteID GROUP BY Sites.SiteName;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE products (product_id INT, product_name VARCHAR(255), num_ingredients INT); CREATE TABLE ingredients (ingredient_id INT, product_id INT, ingredient_name VARCHAR(255));
|
What is the total number of ingredients in each beauty product?
|
SELECT p.product_name, COUNT(i.ingredient_id) as total_ingredients FROM products p INNER JOIN ingredients i ON p.product_id = i.product_id GROUP BY p.product_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE pharmacies (name TEXT, state TEXT, prescription_volume INTEGER); INSERT INTO pharmacies (name, state, prescription_volume) VALUES ('CVS Pharmacy', 'California', 7000), ('Walgreens', 'California', 6500), ('Rite Aid Pharmacy', 'California', 5500);
|
How many pharmacies are there in the state of California that have a prescription volume greater than 5000?
|
SELECT COUNT(*) FROM pharmacies WHERE state = 'California' AND prescription_volume > 5000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sales (item VARCHAR(20), size VARCHAR(5), customer VARCHAR(20), date DATE); INSERT INTO sales (item, size, customer, date) VALUES ('Dress', '14', 'Customer A', '2022-04-01'), ('Skirt', '14', 'Customer A', '2022-05-15'), ('Top', '14', 'Customer B', '2022-06-30'); CREATE TABLE customers (customer VARCHAR(20), purchase_count INT); INSERT INTO customers (customer, purchase_count) VALUES ('Customer A', 2), ('Customer B', 1);
|
What percentage of size 14 garments were sold to repeat customers in the last quarter?
|
SELECT (COUNT(*) FILTER (WHERE purchases >= 2)) * 100.0 / COUNT(*) FROM (SELECT customer, COUNT(*) AS purchases FROM sales WHERE size = '14' AND date >= '2022-04-01' AND date <= '2022-06-30' GROUP BY customer) AS subquery INNER JOIN customers ON subquery.customer = customers.customer;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Accidents (AccidentID INT, CompanyID INT, AccidentDate DATE); INSERT INTO Accidents (AccidentID, CompanyID, AccidentDate) VALUES (1, 1, '2020-01-01'), (2, 2, '2019-12-15'), (3, 3, '2018-05-23'), (4, 4, '2017-09-04'), (5, 1, '2016-02-10');
|
How many mining accidents were reported in Asia in the last 5 years?
|
SELECT COUNT(*) FROM Accidents WHERE YEAR(AccidentDate) >= YEAR(CURRENT_DATE) - 5 AND Country IN ('China', 'India', 'Indonesia');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE FreshwaterFish (id INT, species VARCHAR(255), weight FLOAT, length FLOAT); INSERT INTO FreshwaterFish (id, species, weight, length) VALUES (1, 'Catfish', 1.2, 0.35); INSERT INTO FreshwaterFish (id, species, weight, length) VALUES (2, 'Bass', 0.7, 0.3); INSERT INTO FreshwaterFish (id, species, weight, length) VALUES (3, 'Trout', 0.5, 0.25);
|
Display the number of fish for each species in the 'FreshwaterFish' table
|
SELECT species, COUNT(*) FROM FreshwaterFish GROUP BY species;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Farming(country VARCHAR(255), year INT, species VARCHAR(255), feed_conversion_ratio FLOAT);
|
Update the feed conversion ratio for all farmed cod in Norway to 1.5 in 2021.
|
UPDATE Farming SET feed_conversion_ratio = 1.5 WHERE country = 'Norway' AND species = 'Cod' AND year = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE imports (import_id INT, import_date DATE, weight INT, country TEXT, product TEXT); INSERT INTO imports (import_id, import_date, weight, country, product) VALUES (1, '2022-01-01', 500, 'Germany', 'Frozen Fish'), (2, '2022-01-05', 600, 'France', 'Frozen Chicken'), (3, '2022-02-10', 700, 'India', 'Fish'), (4, '2022-03-15', 800, 'England', 'Frozen Vegetables');
|
Determine the total weight of all 'Frozen' products imported from 'Europe'
|
SELECT SUM(weight) FROM imports WHERE product LIKE 'Frozen%' AND country IN ('Germany', 'France', 'England');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE feedback (service VARCHAR(255), date DATE); INSERT INTO feedback (service, date) VALUES ('education', '2023-01-01'), ('education', '2023-02-15'), ('healthcare', '2023-03-01'), ('transportation', '2023-04-01'), ('education', '2023-03-20'), ('healthcare', '2023-04-10');
|
How many citizen feedback records were received for each public service in the province of Quebec in the last month?
|
SELECT service, COUNT(*) FROM feedback WHERE date >= DATEADD(month, -1, GETDATE()) GROUP BY service;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE geothermal_power_projects (id INT, name TEXT, country TEXT); INSERT INTO geothermal_power_projects (id, name, country) VALUES (1, 'Sarulla Geothermal Power Plant', 'Indonesia');
|
Find the number of geothermal power projects in Indonesia, Philippines, and Mexico.
|
SELECT COUNT(*) FROM geothermal_power_projects WHERE country IN ('Indonesia', 'Philippines', 'Mexico');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE warehouse (id INT PRIMARY KEY, name VARCHAR(50), city VARCHAR(50));CREATE TABLE carrier (id INT PRIMARY KEY, name VARCHAR(50));CREATE TABLE shipment (id INT PRIMARY KEY, warehouse_id INT, carrier_id INT, pallet_count INT, shipped_date DATE);
|
What is the average number of pallets shipped per day from the 'Berlin' warehouse to 'Germany' via 'Global Shipping' in the last month?
|
SELECT AVG(shipment.pallet_count / 30) FROM shipment WHERE shipment.warehouse_id = (SELECT id FROM warehouse WHERE city = 'Berlin') AND shipment.carrier_id = (SELECT id FROM carrier WHERE name = 'Global Shipping') AND shipment.shipped_date BETWEEN (CURRENT_DATE - INTERVAL '30 days') AND CURRENT_DATE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE healthcare_spending (id INTEGER, state VARCHAR(255), county VARCHAR(255), amount FLOAT);
|
What is the total spending on healthcare per rural capita in New York?
|
SELECT county, AVG(amount) AS avg_spending FROM healthcare_spending WHERE state = 'New York' AND county LIKE '%rural%' GROUP BY county;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Subscribers (subscriber_id INT, service VARCHAR(20), region VARCHAR(20), revenue FLOAT, payment_date DATE); INSERT INTO Subscribers (subscriber_id, service, region, revenue, payment_date) VALUES (1, 'Broadband', 'Metro', 50.00, '2023-07-01'), (2, 'Mobile', 'Urban', 35.00, '2023-07-15'), (3, 'Mobile', 'Rural', 20.00, '2023-07-31'), (4, 'Broadband', 'Metro', 40.00, NULL), (5, 'Broadband', 'Rural', 60.00, '2023-07-20');
|
Delete subscribers who have not made any payments in Q3 of 2023 for the 'Broadband' service.
|
DELETE FROM Subscribers WHERE service = 'Broadband' AND QUARTER(payment_date) = 3 AND YEAR(payment_date) = 2023 AND payment_date IS NULL;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Artworks (id INT, category VARCHAR(20)); INSERT INTO Artworks (id, category) VALUES (1, 'modern'), (2, 'contemporary'), (3, 'classic');
|
What is the total number of artworks in the 'modern' and 'contemporary' categories?
|
SELECT COUNT(*) FROM Artworks WHERE category IN ('modern', 'contemporary');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE patients (id INT, name TEXT, state TEXT);CREATE TABLE treatments (id INT, patient_id INT, therapy TEXT);INSERT INTO patients (id, name, state) VALUES (1, 'James Doe', 'Florida');INSERT INTO treatments (id, patient_id, therapy) VALUES (1, 1, 'Psychodynamic');
|
How many patients have been treated with psychodynamic therapy in Florida?
|
SELECT COUNT(DISTINCT patients.id) FROM patients INNER JOIN treatments ON patients.id = treatments.patient_id WHERE patients.state = 'Florida' AND treatments.therapy = 'Psychodynamic';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE zinc_production (id INT, machine_type VARCHAR(20), zinc_production FLOAT); INSERT INTO zinc_production (id, machine_type, zinc_production) VALUES (5, 'TypeD', 1100.0), (6, 'TypeA', 1400.0), (7, 'TypeB', 1600.0), (8, 'TypeD', 1700.5);
|
What is the total zinc production for each machine type?
|
SELECT machine_type, SUM(zinc_production) as total_production FROM zinc_production GROUP BY machine_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Manufacturers (ManufacturerID INT, ManufacturerName TEXT, Region TEXT); INSERT INTO Manufacturers (ManufacturerID, ManufacturerName, Region) VALUES (1, 'ABC Chemicals', 'Africa'), (2, 'XYZ Chemicals', 'North America'), (3, ' DEF Chemicals', 'Africa'); CREATE TABLE WasteGeneration (WasteGenerationID INT, ManufacturerID INT, Chemical TEXT, Quantity INT, WasteGenerationDate DATE); INSERT INTO WasteGeneration (WasteGenerationID, ManufacturerID, Chemical, Quantity, WasteGenerationDate) VALUES (1, 1, 'Acetone', 500, '2020-01-01'), (2, 1, 'Ethanol', 700, '2020-01-10'), (3, 2, 'Methanol', 800, '2020-02-01'), (4, 3, 'Propanol', 900, '2020-01-01'), (5, 3, 'Butanol', 1000, '2020-02-01');
|
What is the total quantity of chemical waste generated by each manufacturer in the African region in the past year?
|
SELECT M.ManufacturerName, YEAR(WG.WasteGenerationDate) AS WasteGenerationYear, SUM(WG.Quantity) AS TotalWasteQuantity FROM WasteGeneration WG INNER JOIN Manufacturers M ON WG.ManufacturerID = M.ManufacturerID WHERE M.Region = 'Africa' AND YEAR(WG.WasteGenerationDate) = YEAR(CURDATE()) - 1 GROUP BY M.ManufacturerName, WasteGenerationYear;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE GameGenres (GenreID INT, GenreName TEXT, VR BOOLEAN); INSERT INTO GameGenres (GenreID, GenreName, VR) VALUES (1, 'Action', FALSE), (2, 'RPG', FALSE), (3, 'Strategy', FALSE), (4, 'Simulation', TRUE), (5, 'FPS', TRUE), (6, 'Sports', FALSE);
|
List the unique game genres and the number of VR games in each genre.
|
SELECT GenreName, COUNT(*) FROM GameGenres WHERE VR = TRUE GROUP BY GenreName;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE strategies (id INT, sector VARCHAR(20), investment FLOAT); INSERT INTO strategies (id, sector, investment) VALUES (1, 'Education', 50000.0), (2, 'Healthcare', 75000.0), (3, 'Education', 100000.0);
|
What is the sum of investments in the healthcare sector?
|
SELECT SUM(investment) FROM strategies WHERE sector = 'Healthcare';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE shipments (id INT, order_id INT, item_type VARCHAR(50), transportation_mode VARCHAR(50), quantity INT); INSERT INTO shipments (id, order_id, item_type, transportation_mode, quantity) VALUES (1, 1001, 'Item1', 'Air', 50), (2, 1002, 'Item2', 'Road', 80), (3, 1003, 'Item1', 'Rail', 75), (4, 1004, 'Item3', 'Sea', 30);
|
How many items of each type were shipped via each transportation mode?
|
SELECT item_type, transportation_mode, SUM(quantity) as total_quantity FROM shipments GROUP BY item_type, transportation_mode;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE species (id INT, name VARCHAR(255), conservation_status VARCHAR(255)); INSERT INTO species (id, name, conservation_status) VALUES (1, 'Blue Whale', 'Endangered');
|
Find the species and their status
|
SELECT name, CONCAT('Conservation Status: ', conservation_status) AS 'Conservation Status' FROM species;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SiteJ (site_id INT, site_name VARCHAR(20), artifact_type VARCHAR(20), quantity INT); INSERT INTO SiteJ (site_id, site_name, artifact_type, quantity) VALUES (1, 'SiteJ', 'Pottery', 25), (2, 'SiteK', 'Bone Fragments', 18), (3, 'SiteL', 'Pottery', 12), (4, 'SiteM', 'Pottery', 30);
|
List the excavation sites where the total quantity of pottery is more than 20.
|
SELECT site_name FROM SiteJ WHERE artifact_type = 'Pottery' GROUP BY site_name HAVING SUM(quantity) > 20;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donations (donation_id INT, donation_amount DECIMAL(10,2), donor_location VARCHAR(50)); INSERT INTO Donations (donation_id, donation_amount, donor_location) VALUES (1, 10.00, 'Egypt'), (2, 20.00, 'Nigeria'), (3, 30.00, 'South Africa');
|
What is the maximum and minimum donation amount from donors in Africa?
|
SELECT MIN(donation_amount) AS 'Minimum Donation', MAX(donation_amount) AS 'Maximum Donation' FROM Donations WHERE donor_location LIKE 'Africa%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Fabrics (id INT, fabric_type VARCHAR(255), sustainable BOOLEAN); INSERT INTO Fabrics (id, fabric_type, sustainable) VALUES (1, 'Cotton', true), (2, 'Polyester', false), (3, 'Hemp', true), (4, 'Rayon', false), (5, 'Bamboo', true), (6, 'Silk', false);
|
Which fabric type has the most sustainable options?
|
SELECT Fabrics.fabric_type, COUNT(Fabrics.id) AS count FROM Fabrics WHERE Fabrics.sustainable = true GROUP BY Fabrics.fabric_type ORDER BY count DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE purchases (purchase_date DATE, supplier VARCHAR(255), revenue DECIMAL(10,2));
|
What is the total revenue for each supplier, by month?
|
SELECT supplier, DATE_TRUNC('month', purchase_date) AS purchase_month, SUM(revenue) AS total_revenue FROM purchases GROUP BY supplier, purchase_month;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ThreatIntelligence (Id INT, ThreatType VARCHAR(50), Sector VARCHAR(50), Timestamp DATETIME); INSERT INTO ThreatIntelligence (Id, ThreatType, Sector, Timestamp) VALUES (1, 'Cyber', 'Defense', '2022-01-01 10:30:00'), (2, 'Physical', 'Aerospace', '2022-02-01 15:45:00');
|
How many threat intelligence records were added in January 2022 for the defense sector?
|
SELECT COUNT(*) FROM ThreatIntelligence WHERE Sector = 'Defense' AND YEAR(Timestamp) = 2022 AND MONTH(Timestamp) = 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE diagnoses (id INT, patient_id INT, condition VARCHAR(255)); CREATE TABLE patients (id INT, age INT, country VARCHAR(255)); INSERT INTO diagnoses (id, patient_id, condition) VALUES (1, 1, 'Depression'), (2, 2, 'Anxiety'), (3, 3, 'Bipolar'), (4, 4, 'Bipolar'); INSERT INTO patients (id, age, country) VALUES (1, 35, 'United States'), (2, 42, 'Canada'), (3, 28, 'Mexico'), (4, 31, 'United States');
|
What is the average age of patients diagnosed with bipolar disorder in the United States?
|
SELECT AVG(patients.age) FROM patients JOIN diagnoses ON patients.id = diagnoses.patient_id WHERE diagnoses.condition = 'Bipolar' AND patients.country = 'United States';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE faculty (faculty_id INT, name TEXT, department TEXT); INSERT INTO faculty (faculty_id, name, department) VALUES (1, 'John Doe', 'Mathematics'), (2, 'Jane Smith', 'Computer Science'); CREATE TABLE publications (paper_id INT, faculty_id INT, title TEXT); INSERT INTO publications (paper_id, faculty_id, title) VALUES (1, 3, 'Machine Learning Research'), (2, 4, 'Advanced Algebra');
|
What is the name and department of all faculty members who have not published any papers?
|
SELECT faculty.name, faculty.department FROM faculty LEFT JOIN publications ON faculty.faculty_id = publications.faculty_id WHERE publications.faculty_id IS NULL;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE crime_incidents (id INT, city VARCHAR(20), month INT, year INT, incidents INT); INSERT INTO crime_incidents (id, city, month, year, incidents) VALUES (1, 'Miami', 7, 2021, 150); INSERT INTO crime_incidents (id, city, month, year, incidents) VALUES (2, 'Miami', 7, 2021, 140);
|
What is the total number of crime incidents in the city of Miami reported in the month of July 2021?
|
SELECT SUM(incidents) FROM crime_incidents WHERE city = 'Miami' AND month = 7 AND year = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE transactions (asset TEXT, tx_date DATE, tx_count INT); INSERT INTO transactions (asset, tx_date, tx_count) VALUES ('Securitize', '2021-01-01', 100), ('Securitize', '2021-01-02', 110), ('Polymath', '2021-01-01', 120), ('Polymath', '2021-01-02', 125), ('Polymath', '2021-01-03', 130);
|
List the digital assets that have had the largest increase in transaction count from one day to the next.
|
SELECT asset, (LEAD(tx_count) OVER (PARTITION BY asset ORDER BY tx_date) - tx_count) AS tx_count_diff FROM transactions ORDER BY tx_count_diff DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Feeding (Farm_ID INT, Date DATE, Feed_Quantity INT); INSERT INTO Feeding (Farm_ID, Date, Feed_Quantity) VALUES (1, '2022-01-01', 5000), (1, '2022-01-02', 5500), (1, '2022-01-03', 6000), (1, '2022-01-04', 6500), (1, '2022-01-05', 7000);
|
Calculate the moving average of feed quantity for each farm over the last 3 days
|
SELECT Farm_ID, Date, Feed_Quantity, AVG(Feed_Quantity) OVER(PARTITION BY Farm_ID ORDER BY Date ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) AS Moving_Avg FROM Feeding WHERE Farm_ID = 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE oceans (ocean_id INT, name VARCHAR(50)); CREATE TABLE species (species_id INT, name VARCHAR(50), ocean_id INT, max_depth DECIMAL(5,2)); INSERT INTO oceans VALUES (1, 'Atlantic'), (2, 'Pacific'), (3, 'Indian'); INSERT INTO species VALUES (1, 'Clownfish', 2, 10), (2, 'Salmon', 1, 100), (3, 'Clownfish', 3, 15), (4, 'Dolphin', 1, 200), (5, 'Turtle', 3, 30), (6, 'Shark', 2, 250), (7, 'Shark', 1, 300), (8, 'Squid', 3, 40), (9, 'Giant Squid', 2, 1000), (10, 'Anglerfish', 2, 1500), (11, 'Mariana Snailfish', 2, 8178);
|
List the marine species and their maximum depths found in the Mariana Trench.
|
SELECT s.name, s.max_depth FROM species s WHERE s.name = 'Mariana Snailfish';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Students (StudentID INT, FirstName VARCHAR(50), LastName VARCHAR(50), Department VARCHAR(50)); INSERT INTO Students (StudentID, FirstName, LastName, Department) VALUES (1, 'John', 'Doe', 'Computer Science'); INSERT INTO Students (StudentID, FirstName, LastName, Department) VALUES (2, 'Jane', 'Doe', 'Mathematics'); INSERT INTO Students (StudentID, FirstName, LastName, Department) VALUES (3, 'Mohamed', 'Ali', 'Engineering'); INSERT INTO Students (StudentID, FirstName, LastName, Department) VALUES (4, 'Nia', 'Smith', 'Computer Science');
|
What are the names of students who are not in the Computer Science department?
|
SELECT FirstName, LastName FROM Students WHERE Department != 'Computer Science';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Games (GameID INT, GameName VARCHAR(255), Genre VARCHAR(255));CREATE TABLE Players (PlayerID INT, PlayerName VARCHAR(255), GameID INT, Spend DECIMAL(10,2));
|
What are the top 3 countries with the highest average game spend per player in the "VirtualRealityGames" genre?
|
SELECT g.Genre, c.Country, AVG(p.Spend) as AvgSpend FROM Games g JOIN Players p ON g.GameID = p.GameID JOIN (SELECT PlayerID, Country FROM PlayerProfile GROUP BY PlayerID) c ON p.PlayerID = c.PlayerID WHERE g.Genre = 'VirtualRealityGames' GROUP BY g.Genre, c.Country ORDER BY AvgSpend DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE recycling_rates (city TEXT, year INT, recycling_rate DECIMAL(5,4)); INSERT INTO recycling_rates (city, year, recycling_rate) VALUES ('Accra', 2022, 0.25), ('Cape Town', 2022, 0.35), ('Johannesburg', 2022, 0.45);
|
Which city had the lowest recycling rate in 2022?
|
SELECT city, MIN(recycling_rate) FROM recycling_rates WHERE year = 2022 GROUP BY city;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE device_cost_north_america (country VARCHAR(20), device VARCHAR(20), cost FLOAT); INSERT INTO device_cost_north_america (country, device, cost) VALUES ('Canada', 'Screen Reader', 130.00), ('USA', 'Adaptive Keyboard', 90.00), ('Mexico', 'Speech Recognition Software', 110.00);
|
What is the maximum cost of a device for accessibility in North America?
|
SELECT MAX(cost) FROM device_cost_north_america WHERE country = 'North America';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE startups (id INT, name VARCHAR(50), sector VARCHAR(50), funding FLOAT); INSERT INTO startups (id, name, sector, funding) VALUES (1, 'Genetech', 'genetic research', 2000000), (2, 'BioVentures', 'bioprocess engineering', 1500000);
|
Update the funding for 'Genetech' to 2500000.
|
UPDATE startups SET funding = 2500000 WHERE name = 'Genetech';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE materials (id INT PRIMARY KEY, material_name VARCHAR(255), material_type VARCHAR(255)); INSERT INTO materials (id, material_name, material_type) VALUES (1, 'Rebar', 'steel'); INSERT INTO materials (id, material_name, material_type) VALUES (2, 'Concrete Block', 'concrete');
|
Delete all records in the materials table where the material_type is 'concrete'
|
DELETE FROM materials WHERE material_type = 'concrete';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE affordable_housing (property_id INT, building_type VARCHAR(255), PRIMARY KEY (property_id)); INSERT INTO affordable_housing (property_id, building_type) VALUES (1, 'Apartment'), (2, 'Townhouse'), (3, 'Single-family');
|
List the 'property_id' and 'building_type' of buildings in the 'affordable_housing' table.
|
SELECT property_id, building_type FROM affordable_housing;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE fares (id INT, route_id INT, fare FLOAT, distance FLOAT); INSERT INTO fares (id, route_id, fare, distance) VALUES (4001, 204, 5.0, 50.0), (4002, 205, 6.0, 60.0);
|
What is the total fare collected for route 204 and 205?
|
SELECT route_id, SUM(fare) as total_fare FROM fares GROUP BY route_id HAVING route_id IN (204, 205);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Size (id INT PRIMARY KEY, name VARCHAR(50), average_spending DECIMAL(5,2));
|
Delete the 'Teen' size from the 'Size' table
|
DELETE FROM Size WHERE name = 'Teen';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE if not exists shale_gas_production (well_id INT, well_name TEXT, location TEXT, gas_production FLOAT); INSERT INTO shale_gas_production (well_id, well_name, location, gas_production) VALUES (1, 'Well F', 'Marcellus', 12345.67), (2, 'Well G', 'Marcellus', 23456.78), (3, 'Well H', 'Utica', 34567.89);
|
Find the well with the highest gas production in the Marcellus shale
|
SELECT well_name, gas_production FROM shale_gas_production WHERE location = 'Marcellus' ORDER BY gas_production DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE HumanitarianAssistanceByQuarter (Quarter VARCHAR(10), Missions INT); INSERT INTO HumanitarianAssistanceByQuarter (Quarter, Missions) VALUES ('Q1 2019', 10), ('Q2 2019', 12), ('Q3 2019', 15), ('Q4 2019', 18);
|
What is the average number of humanitarian assistance missions conducted per quarter in 2019?
|
SELECT AVG(Missions) FROM HumanitarianAssistanceByQuarter WHERE YEAR(Quarter) = 2019;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE countries (id INT, name VARCHAR(255), unesco_sites INT); INSERT INTO countries (id, name, unesco_sites) VALUES (1, 'Italy', 55), (2, 'China', 54), (3, 'Spain', 49);
|
List the top 2 countries with the highest number of UNESCO World Heritage Sites.
|
SELECT name, RANK() OVER (ORDER BY unesco_sites DESC) as site_rank FROM countries WHERE unesco_sites IS NOT NULL QUALIFY site_rank <= 2;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Programs (ProgramID int, ProgramName varchar(50), FundingSource varchar(50), Attendance int); INSERT INTO Programs VALUES (1, 'Art Education', 'Private Donor', 80), (2, 'Theater Workshop', 'Government Grant', 60), (3, 'Music Camp', 'Local Sponsor', 40);
|
Which programs funded by private donors had over 50% attendance?
|
SELECT ProgramName FROM Programs WHERE FundingSource = 'Private Donor' AND Attendance > (SELECT 0.5 * SUM(Attendance) FROM Programs WHERE FundingSource = 'Private Donor');
|
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.