context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE humanitarian_assistance (country VARCHAR(50), region VARCHAR(50), operations INT); INSERT INTO humanitarian_assistance (country, region, operations) VALUES ('Egypt', 'Africa', 20), ('South Africa', 'Africa', 30), ('Nigeria', 'Africa', 25);
What is the average number of humanitarian assistance operations per country in the 'africa' region?
SELECT region, AVG(operations) as avg_operations FROM humanitarian_assistance WHERE region = 'Africa' GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE vessel_visits (id INT, vessel_id INT, port_id INT); INSERT INTO vessel_visits (id, vessel_id, port_id) VALUES (1, 1, 1), (2, 2, 2);
What are the names of vessels that have visited the 'PortA'?
SELECT DISTINCT v.name FROM vessel_visits vv JOIN vessels v ON vv.vessel_id = v.id WHERE vv.port_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE field_temperature (field_id INT, date DATE, temperature FLOAT); INSERT INTO field_temperature (field_id, date, temperature) VALUES (3, '2021-07-01', 25.5), (3, '2021-07-02', 24.3), (3, '2021-07-03', 26.1);
What was the minimum temperature in field 3 over the last week?
SELECT MIN(temperature) FROM field_temperature WHERE field_id = 3 AND date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK);
gretelai_synthetic_text_to_sql
CREATE TABLE circular_economy(city VARCHAR(20), year INT, initiative VARCHAR(50));
Insert a new record of circular economy initiative for the city of Tokyo in 2027.
INSERT INTO circular_economy VALUES('Tokyo', 2027, 'Implementing a city-wide food waste reduction program');
gretelai_synthetic_text_to_sql
CREATE TABLE ai_applications (app_id INT, app_name VARCHAR(255), app_type VARCHAR(255), safety_score DECIMAL(3,2), creativity_score DECIMAL(3,2)); INSERT INTO ai_applications (app_id, app_name, app_type, safety_score, creativity_score) VALUES (1, 'App1', 'Safety', 0.95, 0.75), (2, 'App2', 'Creativity', 0.85, 0.92), (3, 'App3', 'Safety', 0.90, 0.65), (4, 'App4', 'Creativity', 0.75, 0.80);
Show the names and safety scores of AI applications, excluding any applications with a safety score less than 0.8.
SELECT app_name, safety_score FROM ai_applications WHERE safety_score >= 0.8;
gretelai_synthetic_text_to_sql
CREATE TABLE ticket_types (type_id INT, event_id INT, description VARCHAR(50), price DECIMAL(5,2)); INSERT INTO ticket_types VALUES (2, 1, 'Standard', 70);
Decrease the price of standard tickets for a particular event by 5%.
UPDATE ticket_types tt SET tt.price = tt.price * 0.95 WHERE tt.type_id = 2 AND tt.event_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Museums (id INT, museum_name VARCHAR(255), location VARCHAR(255), yearly_visitors INT); INSERT INTO Museums (id, museum_name, location, yearly_visitors) VALUES (1, 'National Museum of China', 'China', 8000000); INSERT INTO Museums (id, museum_name, location, yearly_visitors) VALUES (2, 'Louvre Museum', 'France', 10000000); INSERT INTO Museums (id, museum_name, location, yearly_visitors) VALUES (3, 'British Museum', 'UK', 6200000); INSERT INTO Museums (id, museum_name, location, yearly_visitors) VALUES (4, 'Metropolitan Museum of Art', 'USA', 7000000); INSERT INTO Museums (id, museum_name, location, yearly_visitors) VALUES (5, 'Tokyo National Museum', 'Japan', 4600000);
What are the top 3 most visited art museums in 'Asia'?
SELECT museum_name, SUM(yearly_visitors) as total_visitors FROM Museums WHERE location = 'Asia' GROUP BY museum_name ORDER BY total_visitors DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Movies (id INT, title VARCHAR(255), release_year INT, rating DECIMAL(3,2), director_id INT); INSERT INTO Movies (id, title, release_year, rating, director_id) VALUES (1, 'Movie1', 2016, 7.5, 1), (2, 'Movie2', 2017, 8.2, 2), (3, 'Movie3', 2018, 6.8, 1), (4, 'Movie4', 2019, 9.0, 3), (5, 'Movie5', 2020, 8.5, 2); CREATE TABLE Directors (id INT, name VARCHAR(255)); INSERT INTO Directors (id, name) VALUES (1, 'Director1'), (2, 'Director2'), (3, 'Director3');
Who is the director with the highest average rating for their movies?
SELECT d.name, AVG(m.rating) FROM Directors d JOIN Movies m ON d.id = m.director_id GROUP BY d.id ORDER BY AVG(m.rating) DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE explainable_ai (ai_system TEXT, rating FLOAT); INSERT INTO explainable_ai (ai_system, rating) VALUES ('AI Judge', 0.75), ('AI Translator', 0.90), ('AI Artist', 0.60);
What is the explainability rating for the AI system named 'AI Judge'?
SELECT rating FROM explainable_ai WHERE ai_system = 'AI Judge';
gretelai_synthetic_text_to_sql
CREATE TABLE ExtractionData (ExtractionDataID INT, MineID INT, Date DATE, Mineral TEXT, Quantity INT);
What is the total quantity of each mineral extracted from all mines?
SELECT Mineral, SUM(Quantity) FROM ExtractionData GROUP BY Mineral;
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (DonationID INT, DonationAmount INT, DonorID INT, DonationDate DATE, IsRecurring BOOLEAN); INSERT INTO Donations (DonationID, DonationAmount, DonorID, DonationDate, IsRecurring) VALUES (1, 100, 1, '2022-01-01', true), (2, 200, 2, '2021-05-15', false);
What is the total donation amount from recurring donors in 2021?
SELECT SUM(DonationAmount) FROM Donations WHERE IsRecurring = true AND YEAR(DonationDate) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE Hotels (id INT, name TEXT, location TEXT, capacity INT); INSERT INTO Hotels (id, name, location, capacity) VALUES (1, 'Hotel Rio', 'Rio de Janeiro, Brazil', 800), (2, 'Hotel Sao Paulo', 'Sao Paulo, Brazil', 1000), (3, 'Hotel Amazon', 'Amazonas, Brazil', 1200);
What is the maximum capacity of the largest hotel in Brazil?
SELECT MAX(capacity) FROM Hotels WHERE location LIKE '%Brazil%';
gretelai_synthetic_text_to_sql
CREATE TABLE teams (team_id INT, team_name VARCHAR(50), conference VARCHAR(50)); INSERT INTO teams (team_id, team_name, conference) VALUES (4, 'Lakers', 'Western'), (5, 'Warriors', 'Western'), (6, 'Suns', 'Western'); CREATE TABLE season_ticket_sales (team_id INT, sales INT); INSERT INTO season_ticket_sales (team_id, sales) VALUES (4, 80000), (5, 90000), (6, 70000);
What is the total number of season tickets sold for each team in the Western Conference?
SELECT t.team_name, SUM(sts.sales) as total_sales FROM teams t JOIN season_ticket_sales sts ON t.team_id = sts.team_id WHERE t.conference = 'Western' GROUP BY t.team_name;
gretelai_synthetic_text_to_sql
CREATE TABLE company (name VARCHAR(255), country VARCHAR(100), founder_underrepresented BOOLEAN); INSERT INTO company (name, country, founder_underrepresented) VALUES ('CompanyA', 'USA', FALSE), ('CompanyB', 'Canada', TRUE), ('CompanyC', 'USA', TRUE), ('CompanyD', 'Mexico', FALSE), ('CompanyE', 'Brazil', TRUE), ('CompanyF', 'USA', FALSE); CREATE TABLE funding (company_name VARCHAR(255), amount INT); INSERT INTO funding (company_name, amount) VALUES ('CompanyA', 1000000), ('CompanyB', 2000000), ('CompanyC', 1500000), ('CompanyD', 3000000), ('CompanyE', 500000), ('CompanyF', 800000);
What is the total funding received by startups founded by people from each country?
SELECT country, SUM(funding.amount) as total_funding FROM funding INNER JOIN company ON funding.company_name = company.name GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE water_treatment_plants (state VARCHAR(20), num_plants INTEGER); INSERT INTO water_treatment_plants (state, num_plants) VALUES ('New York', 120), ('New Jersey', 85), ('Pennsylvania', 150);
How many water treatment plants are there in total across the states of New York, New Jersey, and Pennsylvania?
SELECT SUM(num_plants) FROM water_treatment_plants WHERE state IN ('New York', 'New Jersey', 'Pennsylvania');
gretelai_synthetic_text_to_sql
CREATE TABLE space_exploration (id INT, mission_name VARCHAR(255), mission_status VARCHAR(255), agency VARCHAR(255), launch_date DATE);
Delete all records in the space_exploration table where launch_date is after '2030-01-01'
DELETE FROM space_exploration WHERE launch_date > '2030-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE players (player_id INT, name VARCHAR(255), country VARCHAR(255), date_registered DATE); CREATE TABLE player_scores (player_id INT, game_name VARCHAR(255), score INT, date DATE);
Delete records for players who have not played the "RPG Quest" game
DELETE FROM players WHERE player_id NOT IN (SELECT player_id FROM player_scores WHERE game_name = 'RPG Quest');
gretelai_synthetic_text_to_sql
CREATE TABLE daily_lithium_production (id INT, country VARCHAR(255), date DATE, quantity INT); INSERT INTO daily_lithium_production (id, country, date, quantity) VALUES (1, 'Chile', '2022-01-01', 50), (2, 'Chile', '2022-01-02', 60), (3, 'Chile', '2022-01-03', 70), (4, 'Chile', '2022-01-04', 80), (5, 'Chile', '2022-01-05', 90);
What is the average daily production rate of lithium in Chile?
SELECT AVG(quantity) as average_daily_production_rate FROM daily_lithium_production WHERE country = 'Chile';
gretelai_synthetic_text_to_sql
CREATE TABLE Programs (ProgramID INT, ProgramName TEXT, Budget DECIMAL(10,2), Category TEXT); INSERT INTO Programs (ProgramID, ProgramName, Budget, Category) VALUES (1, 'Reading for All', 75000.00, 'Education'); INSERT INTO Programs (ProgramID, ProgramName, Budget, Category) VALUES (2, 'Math and Science', 100000.00, 'Education'); INSERT INTO Programs (ProgramID, ProgramName, Budget, Category) VALUES (3, 'Literacy Program', 50000.00, 'Literacy');
What is the total budget for programs focused on education and literacy?
SELECT SUM(Budget) FROM Programs WHERE Category IN ('Education', 'Literacy');
gretelai_synthetic_text_to_sql
CREATE TABLE Projects (project_id INT, project_name VARCHAR(255), sector VARCHAR(255), region VARCHAR(255), start_date DATE, end_date DATE, budget INT); INSERT INTO Projects (project_id, project_name, sector, region, start_date, end_date, budget) VALUES (2, 'ProjectB', 'Community Development', 'Asia-Pacific', '2022-01-01', '2023-12-31', 75000);
Show the number of active projects and total budget for 'Community Development' sector projects in the 'Asia-Pacific' region as of 2022-01-01.
SELECT COUNT(project_id) AS active_projects, SUM(budget) AS total_budget FROM Projects WHERE sector = 'Community Development' AND region = 'Asia-Pacific' AND end_date >= '2022-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE DysprosiumProduction (id INT PRIMARY KEY, year INT, country VARCHAR(50), production_quantity INT);
What is the average production quantity of Dysprosium in African countries in the last 5 years?
SELECT AVG(production_quantity) FROM DysprosiumProduction WHERE country IN ('Africa') AND year BETWEEN (YEAR(CURRENT_DATE) - 5) AND YEAR(CURRENT_DATE);
gretelai_synthetic_text_to_sql
CREATE TABLE donations (donor_id INT, donation_date DATE, donation_amount FLOAT); INSERT INTO donations (donor_id, donation_date, donation_amount) VALUES (1, '2021-10-05', 500.00), (1, '2021-11-15', 250.00), (2, '2021-12-25', 1000.00), (3, '2021-11-30', 150.00);
What is the maximum donation amount received from a single donor in Q4, and how many times did they donate that quarter?
SELECT MAX(donation_amount) AS max_donation, COUNT(*) AS donation_count FROM donations WHERE QUARTER(donation_date) = 4 GROUP BY donor_id HAVING max_donation = (SELECT MAX(donation_amount) FROM donations WHERE QUARTER(donation_date) = 4);
gretelai_synthetic_text_to_sql
CREATE TABLE visitor_attendance (visitor_id INT, continent VARCHAR(30), event_name VARCHAR(50)); INSERT INTO visitor_attendance (visitor_id, continent, event_name) VALUES (1, 'North America', 'Art Festival'), (2, 'North America', 'Art Exhibition'), (3, 'Europe', 'History Day');
What is the total number of community events attended by visitors from each continent?
SELECT continent, COUNT(*) as num_events FROM visitor_attendance GROUP BY continent;
gretelai_synthetic_text_to_sql
CREATE TABLE customer_size (id INT PRIMARY KEY, size VARCHAR(10), customer_count INT); INSERT INTO customer_size (id, size, customer_count) VALUES (1, 'XS', 500), (2, 'S', 800), (3, 'M', 1200), (4, 'L', 1500);
Show total customers for each size
SELECT size, SUM(customer_count) FROM customer_size GROUP BY size;
gretelai_synthetic_text_to_sql
CREATE TABLE debris (id INT, name VARCHAR(255), mass FLOAT, orbit VARCHAR(255));
What is the average mass of all space debris in orbit around Earth?
SELECT AVG(debris.mass) FROM debris WHERE debris.orbit = 'LEO' OR debris.orbit = 'GEO' OR debris.orbit = 'MEO';
gretelai_synthetic_text_to_sql
CREATE TABLE circular_economy (initiative VARCHAR(50), year INT, waste_generation FLOAT); INSERT INTO circular_economy (initiative, year, waste_generation) VALUES ('Waste to Energy', 2018, 3000), ('Recycling Program', 2018, 4000), ('Composting Program', 2018, 2000);
What is the total waste generation in grams for each circular economy initiative in 2018?
SELECT initiative, SUM(waste_generation) FROM circular_economy WHERE year = 2018 GROUP BY initiative;
gretelai_synthetic_text_to_sql
CREATE TABLE Reintroduction (AnimalID INT, AnimalName VARCHAR(50), Minimum INT, Location VARCHAR(50)); INSERT INTO Reintroduction (AnimalID, AnimalName, Minimum, Location) VALUES (1, 'Lion', 150, 'Africa'); INSERT INTO Reintroduction (AnimalID, AnimalName, Minimum, Location) VALUES (2, 'Elephant', 200, 'Africa');
What is the minimum number of animals that need to be reintroduced in Africa for the 'Lion' species?
SELECT MIN(Minimum) FROM Reintroduction WHERE AnimalName = 'Lion' AND Location = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE traffic_violations (id INT PRIMARY KEY, jurisdiction VARCHAR(255), violation_year INT, violation_count INT); INSERT INTO traffic_violations (id, jurisdiction, violation_year, violation_count) VALUES (1, 'Los Angeles', 2019, 50000), (2, 'San Francisco', 2019, 30000), (3, 'San Diego', 2019, 25000), (4, 'Oakland', 2019, 20000), (5, 'Sacramento', 2019, 15000), (6, 'Santa Ana', 2019, 10000), (7, 'Anaheim', 2019, 8000);
List the top 5 jurisdictions with the highest number of traffic violations in 2019.
SELECT jurisdiction, SUM(violation_count) as total_violations FROM traffic_violations WHERE violation_year = 2019 GROUP BY jurisdiction ORDER BY total_violations DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE researchers (id INT, name TEXT, affiliation TEXT); INSERT INTO researchers (id, name, affiliation) VALUES (1, 'Alice', 'University A'); INSERT INTO researchers (id, name, affiliation) VALUES (2, 'Bob', 'University B'); INSERT INTO researchers (id, name, affiliation) VALUES (3, 'Charlie', 'University C'); CREATE TABLE articles (id INT, title TEXT, year INT, author_id INT); INSERT INTO articles (id, title, year, author_id) VALUES (1, 'Article 1', 2010, 1); INSERT INTO articles (id, title, year, author_id) VALUES (2, 'Article 2', 2011, 1); INSERT INTO articles (id, title, year, author_id) VALUES (3, 'Article 3', 2010, 2); INSERT INTO articles (id, title, year, author_id) VALUES (4, 'Article 4', 2011, 2); INSERT INTO articles (id, title, year, author_id) VALUES (5, 'Article 5', 2010, 3);
What are the names of the top 2 most active researchers in terms of published articles?
SELECT name, RANK() OVER (ORDER BY COUNT(author_id) DESC) as rank FROM articles GROUP BY author_id, name HAVING rank <= 2;
gretelai_synthetic_text_to_sql
CREATE TABLE SA_Energy_Consumption (country VARCHAR(255), year INT, consumption INT); INSERT INTO SA_Energy_Consumption (country, year, consumption) VALUES ('Brazil', 2020, 70), ('Argentina', 2020, 80), ('Colombia', 2020, 75), ('Brazil', 2021, 72), ('Argentina', 2021, 82), ('Colombia', 2021, 78);
Compute the percentage of non-renewable energy consumption in South America, for each country, in the last 3 years.
SELECT country, (SUM(consumption) FILTER (WHERE year BETWEEN 2020 AND 2022) OVER (PARTITION BY country)::DECIMAL / SUM(consumption) OVER (PARTITION BY country)) * 100 AS pct_non_renewable FROM SA_Energy_Consumption;
gretelai_synthetic_text_to_sql
CREATE TABLE crimes (id INT, park VARCHAR(20), reported_crimes INT);
What is the total number of crimes reported in 'Park A' and 'Park B'?
SELECT SUM(reported_crimes) FROM crimes WHERE park IN ('Park A', 'Park B');
gretelai_synthetic_text_to_sql
CREATE TABLE labor_productivity_q3_2023 (site_id INT, productivity FLOAT); INSERT INTO labor_productivity_q3_2023 (site_id, productivity) VALUES (6, 12.5), (7, 15.0), (8, 13.3);
Which mine site had the lowest labor productivity in Q3 2023?
SELECT site_id, productivity FROM labor_productivity_q3_2023 ORDER BY productivity ASC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Community_Development_Peru (id INT, country VARCHAR(50), year INT, cost FLOAT); INSERT INTO Community_Development_Peru (id, country, year, cost) VALUES (1, 'Peru', 2018, 12000.0), (2, 'Peru', 2019, 14000.0), (3, 'Peru', 2020, 16000.0);
What was the average cost of community development initiatives in Peru in 2018?
SELECT AVG(cost) FROM Community_Development_Peru WHERE country = 'Peru' AND year = 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE office (office_id INT, office_name VARCHAR(20)); INSERT INTO office (office_id, office_name) VALUES (1, 'boston'), (2, 'new_york'); CREATE TABLE attorney (attorney_id INT, attorney_name VARCHAR(30), office_id INT, billing_rate DECIMAL(5,2));
List the names and billing rates of all attorneys in the 'new_york' office.
SELECT attorney_name, billing_rate FROM attorney WHERE office_id = (SELECT office_id FROM office WHERE office_name = 'new_york');
gretelai_synthetic_text_to_sql
CREATE TABLE clinical_trials (drug varchar(255), year int, trials int); INSERT INTO clinical_trials (drug, year, trials) VALUES ('CardioMed', 2019, 3), ('CardioMed', 2018, 2);
How many clinical trials were conducted for CardioMed in 2019?
SELECT trials FROM clinical_trials WHERE drug = 'CardioMed' AND year = 2019;
gretelai_synthetic_text_to_sql
CREATE SCHEMA space; USE space; CREATE TABLE country (name VARCHAR(50), population INT); CREATE TABLE meteorite (id INT, name VARCHAR(50), type VARCHAR(50), country VARCHAR(50)); INSERT INTO country (name, population) VALUES ('USA', 330000000), ('Russia', 145000000); INSERT INTO meteorite (id, name, type, country) VALUES (1, 'Dhofar 458', 'Lunar', 'Oman'), (2, 'Dhofar 460', 'Lunar', 'Oman'), (3, 'Dhofar 280', 'Mars', 'Oman'), (4, 'Tamentit', 'Lunar', 'Algeria'), (5, 'Tissint', 'Mars', 'Morocco');
How many lunar and Martian meteorites have been discovered by each country?
SELECT s.country, COUNT(s.id) FROM space.meteorite s JOIN space.country c ON s.country = c.name WHERE s.type IN ('Lunar', 'Mars') GROUP BY s.country;
gretelai_synthetic_text_to_sql
CREATE TABLE market_share (hotel_chain VARCHAR(255), region VARCHAR(255), market_share FLOAT); INSERT INTO market_share (hotel_chain, region, market_share) VALUES ('Hotel Chain A', 'Asia', 0.35), ('Hotel Chain B', 'Asia', 0.42), ('Hotel Chain C', 'Asia', 0.23);
What is the market share of Hotel Chain A in Asia?
SELECT market_share * 100 FROM market_share WHERE hotel_chain = 'Hotel Chain A';
gretelai_synthetic_text_to_sql
CREATE TABLE safety_ratings (chemical_id INT, safety_rating INT);
Create a view 'safety_protocols' that includes 'chemical_id', 'chemical_name', and 'safety_rating' columns from 'chemical_inventory' table and 'safety_ratings' table
CREATE VIEW safety_protocols AS SELECT chemical_inventory.chemical_id, chemical_inventory.chemical_name, safety_ratings.safety_rating FROM chemical_inventory INNER JOIN safety_ratings ON chemical_inventory.chemical_id = safety_ratings.chemical_id;
gretelai_synthetic_text_to_sql
CREATE TABLE schools (id INT PRIMARY KEY, name TEXT, location TEXT);
Insert a new record for a school named 'ABC School' located in 'New York'
INSERT INTO schools (id, name, location) VALUES (1, 'ABC School', 'New York');
gretelai_synthetic_text_to_sql
CREATE TABLE defense_contracts (contract_id INT, contract_value FLOAT, contract_date DATE, contracting_agency VARCHAR(255), region VARCHAR(255));
What is the total contract value awarded to each contracting agency in the Pacific region in 2022?
SELECT contracting_agency, SUM(contract_value) FROM defense_contracts WHERE contract_date BETWEEN '2022-01-01' AND '2022-12-31' AND region = 'Pacific' GROUP BY contracting_agency;
gretelai_synthetic_text_to_sql
CREATE TABLE VRAdoption (Region VARCHAR(20), HeadsetsSold INT); INSERT INTO VRAdoption (Region, HeadsetsSold) VALUES ('Japan', 120000), ('United States', 500000), ('Canada', 80000);
Get the total number of VR headsets sold in Japan and the United States
SELECT SUM(HeadsetsSold) FROM VRAdoption WHERE Region IN ('Japan', 'United States')
gretelai_synthetic_text_to_sql
CREATE TABLE MultiYearBudget2 (Quarter TEXT, Year INTEGER, Service TEXT, Amount INTEGER); INSERT INTO MultiYearBudget2 (Quarter, Year, Service, Amount) VALUES ('Q2 2022', 2022, 'Healthcare', 1400000), ('Q2 2022', 2022, 'Transportation', 1500000);
What is the total budget allocated for healthcare and transportation services in Q2 2022?
SELECT SUM(Amount) FROM MultiYearBudget2 WHERE Quarter = 'Q2 2022' AND Service IN ('Healthcare', 'Transportation');
gretelai_synthetic_text_to_sql
CREATE TABLE employees (id INT, name VARCHAR(50), department VARCHAR(50), salary FLOAT); INSERT INTO employees (id, name, department, salary) VALUES (1, 'John Doe', 'manufacturing', 60000), (2, 'Jane Smith', 'marketing', 70000);
What is the total salary cost for the 'manufacturing' department?
SELECT SUM(salary) FROM employees WHERE department = 'manufacturing';
gretelai_synthetic_text_to_sql
CREATE TABLE chemical_compounds (id INT PRIMARY KEY, name VARCHAR(255), safety_rating INT, manufacturing_location VARCHAR(255));
Update records of chemical compounds with a name 'Styrene', changing safety_rating to 7
UPDATE chemical_compounds SET safety_rating = 7 WHERE name = 'Styrene';
gretelai_synthetic_text_to_sql
CREATE TABLE habitat_preservation (project_id INT, project_name VARCHAR(100), region VARCHAR(50), project_status VARCHAR(20), budget DECIMAL(10, 2), start_date DATE);
Calculate the average budget for completed habitat preservation projects in the last 6 months
SELECT AVG(budget) as avg_budget FROM habitat_preservation WHERE project_status = 'completed' AND start_date >= DATE_SUB(CURDATE(), INTERVAL 6 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE Contracts (ContractID int, ContractValue numeric(18,2), ContractType varchar(50), VendorName varchar(50)); INSERT INTO Contracts (ContractID, ContractValue, ContractType, VendorName) VALUES (1, 1500000.00, 'Services', 'Global Enterprises'), (2, 1200000.00, 'Goods', 'ABC Corp'), (3, 800000.00, 'Services', 'XYZ Inc'), (4, 900000.00, 'Goods', 'Global Enterprises'), (5, 1100000.00, 'Services', 'DEF LLC');
What is the average contract value for each vendor by contract type?
SELECT VendorName, ContractType, AVG(ContractValue) as AvgContractValue FROM Contracts GROUP BY VendorName, ContractType;
gretelai_synthetic_text_to_sql
CREATE TABLE investment_strategies (id INT, name VARCHAR(255)); INSERT INTO investment_strategies (id, name) VALUES (1, 'Value Investing'), (2, 'Growth Investing'), (3, 'Index Investing'); CREATE TABLE investments (id INT, investment_strategy_id INT, value DECIMAL(10, 2)); INSERT INTO investments (id, investment_strategy_id, value) VALUES (1, 1, 25000.00), (2, 1, 18000.00), (3, 2, 32000.00), (4, 2, 22000.00), (5, 3, 45000.00), (6, 3, 35000.00);
What is the total value of investments for each investment strategy?
SELECT investment_strategies.name, SUM(investments.value) FROM investment_strategies INNER JOIN investments ON investment_strategies.id = investments.investment_strategy_id GROUP BY investment_strategies.name;
gretelai_synthetic_text_to_sql
CREATE TABLE Permits (Id INT, ProjectId INT, Type VARCHAR(50), IssueDate DATE, ExpirationDate DATE, State VARCHAR(50)); INSERT INTO Permits (Id, ProjectId, Type, IssueDate, ExpirationDate, State) VALUES (1, 1, 'Building', '2020-01-01', '2020-03-01', 'Texas');
What is the average number of construction permits issued per month in Texas?
SELECT COUNT(*)/COUNT(DISTINCT DATE_FORMAT(IssueDate, '%Y-%m')) AS AvgPermitsPerMonth FROM Permits WHERE State = 'Texas';
gretelai_synthetic_text_to_sql
CREATE TABLE organizations (id INT, name VARCHAR(20), location VARCHAR(10)); INSERT INTO organizations (id, name, location) VALUES (1, 'Legal Aid 1', 'Urban'); INSERT INTO organizations (id, name, location) VALUES (2, 'Legal Aid 2', 'Rural');
How many legal aid organizations exist in urban areas?
SELECT COUNT(*) FROM organizations WHERE location = 'Urban';
gretelai_synthetic_text_to_sql
CREATE TABLE Renewable_Energy (project_id INT, project_name VARCHAR(50), location VARCHAR(50)); INSERT INTO Renewable_Energy (project_id, project_name, location) VALUES (1, 'Wind Farm', 'Mountain'), (2, 'Solar Farm', 'Desert'), (3, 'Geothermal Plant', 'Volcanic Area'), (4, 'Hydroelectric Dam', 'River');
List all projects from the 'Renewable_Energy' table that are located in 'Mountain' or 'Desert' areas.
SELECT project_name FROM Renewable_Energy WHERE location IN ('Mountain', 'Desert');
gretelai_synthetic_text_to_sql
CREATE TABLE RuralInfrastructure (id INT, name VARCHAR(50), location VARCHAR(20), project_type VARCHAR(30), completion_date DATE);
Delete all rural infrastructure projects that were completed before 2020
DELETE FROM RuralInfrastructure WHERE completion_date < '2020-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (volunteer_id INT, volunteer_name TEXT, volunteer_date DATE); INSERT INTO volunteers (volunteer_id, volunteer_name, volunteer_date) VALUES (1, 'Fatima Lopez', '2024-01-15'), (2, 'Hamza Ahmed', '2024-02-20'), (3, 'Jasmine Kim', '2024-03-05');
How many volunteers signed up in each month of 2024?
SELECT DATE_PART('month', volunteer_date) as month, COUNT(volunteer_id) as num_volunteers FROM volunteers WHERE volunteer_date BETWEEN '2024-01-01' AND '2024-12-31' GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE player (player_id INT, name VARCHAR(50), score INT, game_genre VARCHAR(20)); INSERT INTO player (player_id, name, score, game_genre) VALUES (1, 'John Doe', 250, 'Racing'); INSERT INTO player (player_id, name, score, game_genre) VALUES (2, 'Jane Smith', 300, 'RPG'); INSERT INTO player (player_id, name, score, game_genre) VALUES (3, 'Alice Johnson', 400, 'Racing');
What is the name of the player with the highest score in the Racing genre?
SELECT name FROM player WHERE game_genre = 'Racing' AND score = (SELECT MAX(score) FROM player WHERE game_genre = 'Racing');
gretelai_synthetic_text_to_sql
CREATE TABLE pacific_species (species_name VARCHAR(255), species_count INT); INSERT INTO pacific_species (species_name, species_count) VALUES ('Clownfish', 1), ('Jellyfish', 2);
What is the total number of marine species in the Pacific Ocean?
SELECT SUM(species_count) FROM pacific_species;
gretelai_synthetic_text_to_sql
CREATE TABLE preservation_projects (project_id INT, project_name TEXT, country TEXT, start_date DATE);
Create a new table for preservation projects with an ID, name, country, and start date.
INSERT INTO preservation_projects (project_id, project_name, country, start_date) VALUES (1, 'Green Gate Restoration', 'Poland', '2022-05-01'), (2, 'Machu Picchu Conservation', 'Peru', '2022-06-15');
gretelai_synthetic_text_to_sql
CREATE TABLE grants (id INT PRIMARY KEY, organization VARCHAR(255), category VARCHAR(255), amount DECIMAL(10,2), date_awarded DATE);
List all legal technology grants awarded by a specific organization
SELECT * FROM grants WHERE organization = 'Legal Code Foundation';
gretelai_synthetic_text_to_sql
CREATE TABLE states (id INT, name VARCHAR(255)); INSERT INTO states (id, name) VALUES (1, 'California'); CREATE TABLE libraries (id INT, state_id INT, name VARCHAR(255)); INSERT INTO libraries (id, state_id) VALUES (1, 1), (2, 1), (3, 1); CREATE TABLE parks (id INT, state_id INT, name VARCHAR(255)); INSERT INTO parks (id, state_id) VALUES (1, 1), (2, 1), (3, 1); CREATE TABLE counties (id INT, state_id INT, name VARCHAR(255)); INSERT INTO counties (id, state_id, name) VALUES (1, 1, 'Los Angeles County');
What is the total number of libraries and parks in California, and how many of them are located in Los Angeles County?
SELECT COUNT(libraries.id) + COUNT(parks.id) AS total_locations, COUNT(counties.name) AS la_county_locations FROM libraries INNER JOIN states ON libraries.state_id = states.id INNER JOIN parks ON libraries.state_id = parks.state_id INNER JOIN counties ON states.id = counties.state_id WHERE states.name = 'California' AND counties.name = 'Los Angeles County';
gretelai_synthetic_text_to_sql
CREATE TABLE ethical_manufacturing (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), ethical_rating DECIMAL(3, 2)); INSERT INTO ethical_manufacturing (id, name, location, ethical_rating) VALUES (6, 'Fair Trade Fabrics', 'Mumbai, India', 4.8);
Identify ethical manufacturing companies in India
SELECT * FROM ethical_manufacturing WHERE location = 'Mumbai, India';
gretelai_synthetic_text_to_sql
CREATE TABLE Spacecraft (id INT, name VARCHAR(50), manufacturer VARCHAR(50), launch_date DATE); INSERT INTO Spacecraft (id, name, manufacturer, launch_date) VALUES (1, 'Voyager 1', 'NASA', '1977-09-05'), (2, 'Dragon 1', 'SpaceX', '2010-12-08');
What are the names of all spacecraft that were launched by both NASA and SpaceX?
SELECT s.name FROM Spacecraft s WHERE s.manufacturer IN ('NASA', 'SpaceX') GROUP BY s.name HAVING COUNT(DISTINCT s.manufacturer) = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE smart_contracts (id INT, name VARCHAR(20), description VARCHAR(50)); INSERT INTO smart_contracts (id, name, description) VALUES (1, 'SmartContractA', 'Sample Description A'), (2, 'SmartContractB', 'Sample Description B'), (3, 'SmartContractY', 'Sample Description Y');
Update the name of the smart contract with ID 3 to 'SmartContractX'
UPDATE smart_contracts SET name = 'SmartContractX' WHERE id = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE company (id INT, name TEXT, founding_year INT, founder_name TEXT); INSERT INTO company (id, name, founding_year, founder_name) VALUES (1, 'Acme Inc', 2010, 'Alice Zhang'); INSERT INTO company (id, name, founding_year, founder_name) VALUES (2, 'Brick Co', 2012, 'John Smith');
Show the number of startups founded by 'Alice Zhang'
SELECT COUNT(*) FROM company c WHERE c.founder_name = 'Alice Zhang';
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_energy (id INT, project_name VARCHAR(50), location VARCHAR(50), investment FLOAT); INSERT INTO renewable_energy (id, project_name, location, investment) VALUES (1, 'Solar Farm', 'Arizona', 12000000), (2, 'Wind Turbines', 'Texas', 8000000);
Find the average investment in renewable energy projects in the 'renewable_energy' schema located in 'TX'.
SELECT AVG(investment) FROM renewable_energy WHERE location = 'Texas';
gretelai_synthetic_text_to_sql
CREATE TABLE satellite_deployment (country VARCHAR(20), satellites INT); INSERT INTO satellite_deployment (country, satellites) VALUES ('United States', 1500), ('Russia', 1200), ('China', 800);
How many satellites were deployed in each country?
SELECT country, satellites FROM satellite_deployment;
gretelai_synthetic_text_to_sql
CREATE TABLE tourism_stats (id INT, city VARCHAR(20), trip_duration FLOAT); INSERT INTO tourism_stats (id, city, trip_duration) VALUES (1, 'Barcelona', 5.6), (2, 'Barcelona', 4.8), (3, 'Rome', 6.2);
What is the average trip duration for tourists visiting Barcelona?
SELECT AVG(trip_duration) FROM tourism_stats WHERE city = 'Barcelona';
gretelai_synthetic_text_to_sql
CREATE TABLE AircraftModel (ID INT, Name VARCHAR(50), ManufacturerID INT); CREATE TABLE FlightData (ID INT, AircraftModelID INT, Altitude INT);
What is the maximum flight altitude for each aircraft model?
SELECT am.Name, MAX(fd.Altitude) AS MaxAltitude FROM AircraftModel am JOIN FlightData fd ON am.ID = fd.AircraftModelID GROUP BY am.Name;
gretelai_synthetic_text_to_sql
CREATE TABLE games (id INT, team TEXT, season INT, home_or_away TEXT, wins INT, losses INT); INSERT INTO games (id, team, season, home_or_away, wins, losses) VALUES (1, 'Team A', 2021, 'Home', 25, 8); INSERT INTO games (id, team, season, home_or_away, wins, losses) VALUES (2, 'Team B', 2021, 'Away', 18, 14);
How many games were won by the home team in the last season?
SELECT team, SUM(wins) FROM games WHERE home_or_away = 'Home' AND season = 2021 GROUP BY team;
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_projects_3 (project_id INT, name VARCHAR(50), type VARCHAR(50), location VARCHAR(50)); INSERT INTO renewable_projects_3 (project_id, name, type, location) VALUES (1, 'Canada Renewable Project 1', 'Solar', 'Ontario');
Find the number of Renewable Energy projects in Ontario, Canada
SELECT COUNT(*) FROM renewable_projects_3 WHERE location = 'Ontario';
gretelai_synthetic_text_to_sql
CREATE TABLE attorney_performance_metrics (attorney_id INT PRIMARY KEY, win_rate DECIMAL(5,4), cases_handled INT); CREATE TABLE case_assignments (case_id INT, attorney_id INT, PRIMARY KEY (case_id, attorney_id)); CREATE TABLE case_outcomes (case_id INT, outcome TEXT, precedent TEXT);
Display the total number of cases won by each attorney
SELECT attorney_id, SUM(CASE WHEN outcome = 'Won' THEN 1 ELSE 0 END) as cases_won FROM case_assignments JOIN case_outcomes ON case_assignments.case_id = case_outcomes.case_id GROUP BY attorney_id;
gretelai_synthetic_text_to_sql
CREATE TABLE volunteer_hours (volunteer_hours_id INT, hours_volunteered INT, volunteer_date DATE); INSERT INTO volunteer_hours (volunteer_hours_id, hours_volunteered, volunteer_date) VALUES (1, 10, '2021-01-01'), (2, 15, '2021-02-15'), (3, 20, '2021-03-15');
What is the maximum number of hours volunteered in a single day in 2021?
SELECT MAX(hours_volunteered) FROM volunteer_hours WHERE YEAR(volunteer_date) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (DonationID INT PRIMARY KEY, DonorID INT, DonationDate DATE, DonationAmount DECIMAL(10,2)); INSERT INTO Donations (DonationID, DonorID, DonationDate, DonationAmount) VALUES (1, 1, '2020-01-01', 500.00), (2, 2, '2020-01-02', 750.00), (3, 3, '2020-01-03', 1200.00);
What is the total amount donated by small donors (those who have donated less than $1000) in the Donations table?
SELECT SUM(DonationAmount) FROM Donations WHERE DonationAmount < 1000;
gretelai_synthetic_text_to_sql
CREATE TABLE astronauts (astronaut_id INT, name VARCHAR(100), age INT, craft VARCHAR(50)); INSERT INTO astronauts (astronaut_id, name, age, craft) VALUES (1, 'John', 45, 'Dragon'), (2, 'Sarah', 36, 'Starship'), (3, 'Mike', 50, 'Falcon'), (4, 'Jane', 42, 'Apollo'), (5, 'Emma', 34, 'Shuttle'), (6, 'Bruce', 30, 'Shuttle'); CREATE TABLE spacex_crafts (craft VARCHAR(50), manufacturer VARCHAR(50)); INSERT INTO spacex_crafts (craft, manufacturer) VALUES ('Dragon', 'SpaceX'), ('Starship', 'SpaceX'), ('Falcon', 'SpaceX'); CREATE TABLE nasa_crafts (craft VARCHAR(50), manufacturer VARCHAR(50)); INSERT INTO nasa_crafts (craft, manufacturer) VALUES ('Apollo', 'NASA'), ('Shuttle', 'NASA');
What is the minimum age of astronauts who have flown on SpaceX or NASA crafts?
SELECT MIN(age) FROM astronauts WHERE craft IN (SELECT craft FROM spacex_crafts) OR craft IN (SELECT craft FROM nasa_crafts);
gretelai_synthetic_text_to_sql
CREATE TABLE emergency_responses (id INT, region TEXT, incident_type TEXT, response_time INT); INSERT INTO emergency_responses (id, region, incident_type, response_time) VALUES (1, 'Region 1', 'Fire', 8), (2, 'Region 1', 'Fire', 9), (3, 'Region 1', 'Medical', 10), (4, 'Region 1', 'Medical', 12), (5, 'Region 2', 'Fire', 7), (6, 'Region 2', 'Fire', 8), (7, 'Region 2', 'Medical', 9), (8, 'Region 2', 'Medical', 11), (9, 'Region 3', 'Fire', 6), (10, 'Region 3', 'Fire', 7), (11, 'Region 3', 'Medical', 8), (12, 'Region 3', 'Medical', 9);
What is the average response time for emergency incidents in each region, broken down by incident type?
SELECT region, incident_type, AVG(response_time) AS avg_response_time FROM emergency_responses GROUP BY region, incident_type;
gretelai_synthetic_text_to_sql
CREATE TABLE industrial_usage (state VARCHAR(20), usage FLOAT, timestamp TIMESTAMP); INSERT INTO industrial_usage (state, usage, timestamp) VALUES ('California', 12000, '2022-01-01 10:00:00'), ('Texas', 15000, '2022-01-02 10:00:00');
Identify the top five states with the highest water usage in industrial applications in the last quarter.
SELECT state, SUM(usage) AS total_usage FROM industrial_usage WHERE timestamp BETWEEN DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 3 MONTH) AND CURRENT_TIMESTAMP GROUP BY state ORDER BY total_usage DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE PricesByState (state VARCHAR(255), price DECIMAL(10,2), product VARCHAR(255)); INSERT INTO PricesByState (state, price, product) VALUES ('CA', 45, 'Quarter'), ('CO', 40, 'Quarter'), ('OR', 35, 'Quarter'), ('WA', 42, 'Quarter'), ('MI', 38, 'Quarter');
What is the average price of a quarter of an ounce of cannabis in each state, rounded to the nearest dollar?
SELECT state, ROUND(AVG(price)) as average_price FROM PricesByState WHERE product = 'Quarter' GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_finance (id INT, country VARCHAR(50), amount FLOAT, sector VARCHAR(50));
Who are the top 5 countries receiving climate finance for mitigation projects?
SELECT cf.country, SUM(cf.amount) FROM climate_finance cf WHERE cf.sector = 'mitigation' GROUP BY cf.country ORDER BY SUM(cf.amount) DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE whale_sharks (population TEXT, biomass NUMERIC); INSERT INTO whale_sharks (population, biomass) VALUES ('Atlantic Ocean', '18000000'); INSERT INTO whale_sharks (population, biomass) VALUES ('Pacific Ocean', '23000000');
What is the total biomass of all whale shark populations?
SELECT SUM(biomass) FROM whale_sharks;
gretelai_synthetic_text_to_sql
CREATE TABLE Policyholders (PolicyID INT, PolicyholderName TEXT); INSERT INTO Policyholders (PolicyID, PolicyholderName) VALUES (1, 'John Doe'), (2, 'Jane Smith'), (3, 'Bob Johnson'); CREATE TABLE Claims (ClaimID INT, PolicyID INT); INSERT INTO Claims (ClaimID, PolicyID) VALUES (1, 1), (2, 1), (3, 2);
List all policyholders who have not filed any claims, ordered alphabetically by policyholder name.
SELECT Policyholders.PolicyID, Policyholders.PolicyholderName FROM Policyholders LEFT JOIN Claims ON Policyholders.PolicyID = Claims.PolicyID WHERE Claims.ClaimID IS NULL ORDER BY Policyholders.PolicyholderName;
gretelai_synthetic_text_to_sql
CREATE TABLE cases (id INT, region VARCHAR(10), billing_amount INT); INSERT INTO cases (id, region, billing_amount) VALUES (1, 'Eastern', 5000), (2, 'Western', 7000), (3, 'Eastern', 6000), (4, 'Central', 8000), (5, 'Central', 6000), (6, 'Central', 4000);
What is the total billing amount for cases in the 'Central' region, excluding cases with a billing amount less than $7000?
SELECT SUM(billing_amount) FROM cases WHERE region = 'Central' AND billing_amount > 7000;
gretelai_synthetic_text_to_sql
CREATE TABLE farmers (id INT PRIMARY KEY, name VARCHAR(50), age INT, ethnicity VARCHAR(20), region VARCHAR(25), practice VARCHAR(25)); INSERT INTO farmers (id, name, age, ethnicity, region, practice) VALUES (1, 'Jamal Davis', 42, 'African American', 'Southeast', 'Agroecology'); INSERT INTO farmers (id, name, age, ethnicity, region, practice) VALUES (2, 'Aisha Patel', 39, 'Asian', 'Southeast', 'Conventional');
What are the names and ethnicities of farmers in the Southeast who practice agroecology?
SELECT name, ethnicity FROM farmers WHERE practice = 'Agroecology' AND region = 'Southeast';
gretelai_synthetic_text_to_sql
CREATE TABLE humanitarian_assistance (id INT, provider VARCHAR(255), year INT, amount FLOAT); INSERT INTO humanitarian_assistance (id, provider, year, amount) VALUES (1, 'United Nations', 2018, 50000000);
What is the total amount of humanitarian assistance provided by the United Nations in 2018?
SELECT SUM(amount) FROM humanitarian_assistance WHERE provider = 'United Nations' AND year = 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (sale_id INT, country VARCHAR(50), amount DECIMAL(5, 2), sustainable BOOLEAN); INSERT INTO sales (sale_id, country, amount, sustainable) VALUES (1, 'UK', 50.00, TRUE); INSERT INTO sales (sale_id, country, amount, sustainable) VALUES (2, 'France', 75.00, TRUE); INSERT INTO sales (sale_id, country, amount, sustainable) VALUES (3, 'Germany', 100.00, FALSE);
What is the sum of sales for sustainable fashion items in the UK, France, and Germany?
SELECT SUM(amount) FROM sales WHERE country IN ('UK', 'France', 'Germany') AND sustainable = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE VolunteerDonations (VolunteerID INT, DonationAmount DECIMAL(10,2), VolunteerHours INT); INSERT INTO VolunteerDonations (VolunteerID, DonationAmount, VolunteerHours) VALUES (1, 3000.00, 0), (2, 1000.00, 25), (3, 500.00, 15), (4, 2500.00, NULL);
List the names of volunteers who have donated more than $2000 but have not volunteered any hours?
SELECT VolunteerName FROM Volunteers INNER JOIN VolunteerDonations ON Volunteers.VolunteerID = VolunteerDonations.VolunteerID WHERE DonationAmount > 2000 AND VolunteerHours IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE investment (id INT, firm TEXT, startup TEXT); INSERT INTO investment (id, firm, startup) VALUES (1, 'Tiger Global', 'GreenSolutions'), (2, 'Sequoia', 'InnovateIT'), (3, 'Accel', 'DataDriven'), (4, 'Kleiner Perkins', 'EcoTech'), (5, 'Andreessen Horowitz', 'AI4Good'), (6, 'Two Spirit Capital', 'Indigenous Tech');
Display the names of investment firms that have funded at least one startup founded by an individual who identifies as Indigenous.
SELECT DISTINCT firm FROM investment WHERE startup IN (SELECT name FROM startup WHERE founder_identity LIKE '%Indigenous%');
gretelai_synthetic_text_to_sql
CREATE TABLE ArtPieces (ArtPieceID INT, Name TEXT, Artist TEXT, YearAdded INT, YearRemoved INT); INSERT INTO ArtPieces (ArtPieceID, Name, Artist, YearAdded, YearRemoved) VALUES (1, 'Starry Night', 'Vincent van Gogh', 1889, 2020); INSERT INTO ArtPieces (ArtPieceID, Name, Artist, YearAdded, YearRemoved) VALUES (2, 'The Persistence of Memory', 'Salvador Dalí', 1931, 1940); INSERT INTO ArtPieces (ArtPieceID, Name, Artist, YearAdded, YearRemoved) VALUES (3, 'Guernica', 'Pablo Picasso', 1937, 1939); INSERT INTO ArtPieces (ArtPieceID, Name, Artist, YearAdded, YearRemoved) VALUES (4, 'The Starry Night Over the Rhone', 'Françoise Nielly', 1888, 1900); INSERT INTO ArtPieces (ArtPieceID, Name, Artist, YearAdded, YearRemoved) VALUES (5, 'Girl with a Pearl Earring', 'Johannes Vermeer', 1665, 1950);
Which art pieces were removed from the museum collection in the last decade?
SELECT Name FROM ArtPieces WHERE YearRemoved > 2010;
gretelai_synthetic_text_to_sql
CREATE TABLE MilitaryVehicles(id INT PRIMARY KEY, country VARCHAR(50), quantity INT);INSERT INTO MilitaryVehicles(id, country, quantity) VALUES (1, 'Germany', 300), (2, 'Japan', 250);
What is the total number of military vehicles manufactured in Germany and Japan?
SELECT SUM(quantity) FROM MilitaryVehicles WHERE country IN ('Germany', 'Japan');
gretelai_synthetic_text_to_sql
CREATE TABLE NationalSecurity (Id INT PRIMARY KEY, Country VARCHAR(50), Operation VARCHAR(50), Year INT);
Identify national security operations that used military technology in the same year
SELECT NationalSecurity.Country, NationalSecurity.Operation FROM NationalSecurity INNER JOIN MilitaryTechnology ON NationalSecurity.Country = MilitaryTechnology.Country AND NationalSecurity.Year = MilitaryTechnology.Year;
gretelai_synthetic_text_to_sql
ALTER TABLE users ADD COLUMN region VARCHAR(50); UPDATE users SET region = 'United Kingdom' WHERE country = 'United Kingdom'; CREATE VIEW playlists_uk AS SELECT * FROM playlists JOIN users ON playlists.user_id = users.user_id WHERE users.region = 'United Kingdom'; CREATE VIEW playlist_songs_uk AS SELECT songs.* FROM songs JOIN playlists_uk ON playlists_uk.playlist_id = playlist_songs.playlist_id;
Return the song_name and genre of songs that are in playlists created by users from the United Kingdom.
SELECT song_name, genre FROM playlist_songs_uk;
gretelai_synthetic_text_to_sql
CREATE TABLE volunteer_registrations (id INT, registration_date DATE);
How many volunteers joined each month in the last year?
SELECT MONTH(vr.registration_date) as month, YEAR(vr.registration_date) as year, COUNT(*) as num_volunteers FROM volunteer_registrations vr WHERE vr.registration_date >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR) GROUP BY month, year;
gretelai_synthetic_text_to_sql
CREATE TABLE trades (trade_id INT, team VARCHAR(20), portfolio VARCHAR(20), trade_date DATE, ticker VARCHAR(10), quantity INT); INSERT INTO trades (trade_id, team, portfolio, trade_date, ticker, quantity) VALUES (1, 'Investment', 'Tech Growth', '2022-01-05', 'AAPL', 50), (2, 'Investment', 'Tech Growth', '2022-01-10', 'MSFT', 75), (3, 'Investment', 'Value', '2022-01-15', 'JPM', 100), (4, 'Trading', 'Small Cap', '2022-02-20', 'TSLA', 25);
Find the total number of trades executed in the 'Small Cap' portfolio during the last month.
SELECT COUNT(*) FROM trades WHERE portfolio = 'Small Cap' AND trade_date >= DATEADD(month, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE UK_Returns (id INT, return_country VARCHAR(50), return_value FLOAT); INSERT INTO UK_Returns (id, return_country, return_value) VALUES (1, 'United Kingdom', 1500), (2, 'United Kingdom', 1100), (3, 'Ireland', 1300);
What is the maximum value of returns from the United Kingdom?
SELECT MAX(return_value) FROM UK_Returns WHERE return_country = 'United Kingdom';
gretelai_synthetic_text_to_sql
CREATE TABLE patents (id INT, title VARCHAR(50), filed_by VARCHAR(50), filed_date DATE, type VARCHAR(50), industry VARCHAR(50));
Get the number of biotech patents filed by year.
SELECT EXTRACT(YEAR FROM filed_date) AS year, COUNT(*) FROM patents WHERE industry = 'biotech' GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE gaming_facts (player_id INT, country VARCHAR(50), total_spending FLOAT); INSERT INTO gaming_facts (player_id, country, total_spending) VALUES (1, 'USA', 450.25), (2, 'Canada', 520.35), (3, 'Egypt', 600), (4, 'Japan', 375.89), (5, 'Nigeria', 550);
How many players from Africa have spent more than $500 in the 'gaming_facts' table?
SELECT COUNT(*) as african_players_over_500 FROM gaming_facts WHERE country IN ('Egypt', 'Nigeria');
gretelai_synthetic_text_to_sql
CREATE TABLE garment_info (garment_id INT, sustainability_rating DECIMAL(3, 2)); INSERT INTO garment_info (garment_id, sustainability_rating) VALUES (1001, 4.2), (1002, 3.5), (1003, 4.8), (1004, 2.9), (1005, 4.5), (1006, 3.7); CREATE TABLE garment_manufacturing (manufacturing_id INT, garment_id INT, country VARCHAR(255)); INSERT INTO garment_manufacturing (manufacturing_id, garment_id, country) VALUES (1, 1001, 'Nigeria'), (2, 1002, 'Egypt'), (3, 1003, 'UK'), (4, 1004, 'China'), (5, 1005, 'Bangladesh'), (6, 1006, 'Indonesia');
What is the average sustainability rating for garments manufactured in Africa?
SELECT AVG(g.sustainability_rating) AS avg_sustainability_rating FROM garment_info g INNER JOIN garment_manufacturing m ON g.garment_id = m.garment_id WHERE m.country IN ('Nigeria', 'Egypt');
gretelai_synthetic_text_to_sql
CREATE TABLE vessels(id INT, name VARCHAR(100), region VARCHAR(50));CREATE TABLE shipments(id INT, vessel_id INT, cargo_weight FLOAT, ship_date DATE, origin VARCHAR(50), destination VARCHAR(50));
What was the total cargo weight transported by vessels from Brazil to Africa in H1 2020?
SELECT SUM(cargo_weight) FROM shipments WHERE (origin, destination) = ('Brazil', 'Africa') AND ship_date BETWEEN '2020-01-01' AND '2020-06-30';
gretelai_synthetic_text_to_sql
CREATE TABLE brands (brand_id INT, brand_name TEXT, country TEXT); INSERT INTO brands (brand_id, brand_name, country) VALUES (1, 'BrandA', 'USA'), (2, 'BrandB', 'Canada'), (3, 'BrandC', 'USA'); CREATE TABLE material_usage (brand_id INT, material_type TEXT, quantity INT, co2_emissions INT); INSERT INTO material_usage (brand_id, material_type, quantity, co2_emissions) VALUES (1, 'organic_cotton', 1000, 500), (1, 'recycled_polyester', 1500, 2000), (2, 'organic_cotton', 1200, 600), (3, 'recycled_polyester', 1800, 2200);
What is the total quantity of sustainable materials used by each brand, and the corresponding CO2 emissions, for brands that have operations in the US?
SELECT b.brand_name, SUM(mu.quantity) AS total_quantity, SUM(mu.co2_emissions) AS total_co2_emissions FROM brands b JOIN material_usage mu ON b.brand_id = mu.brand_id WHERE b.country = 'USA' GROUP BY b.brand_name;
gretelai_synthetic_text_to_sql
CREATE TABLE HealthCenters (HealthCenterID INT, Name VARCHAR(50), State VARCHAR(20), PatientCount INT); INSERT INTO HealthCenters (HealthCenterID, Name, State, PatientCount) VALUES (1, 'Rural Health Center A', 'New York', 2000); INSERT INTO HealthCenters (HealthCenterID, Name, State, PatientCount) VALUES (2, 'Rural Health Center B', 'New York', 1000);
What is the name of the rural health center with the least number of patients in "New York"?
SELECT Name FROM HealthCenters WHERE State = 'New York' AND PatientCount = (SELECT MIN(PatientCount) FROM HealthCenters WHERE State = 'New York');
gretelai_synthetic_text_to_sql
CREATE TABLE FishingVesselInspections (InspectionID INT, VesselID INT, VesselType VARCHAR(50), InspectionDate DATE, Region VARCHAR(50)); INSERT INTO FishingVesselInspections (InspectionID, VesselID, VesselType, InspectionDate, Region) VALUES (1, 1, 'Fishing Vessel', '2022-03-10', 'Pacific'), (2, 2, 'Fishing Vessel', '2022-02-20', 'Atlantic'), (3, 3, 'Fishing Vessel', '2022-01-05', 'Pacific');
Count the number of fishing vessels that have been inspected in the last month, grouped by region
SELECT Region, COUNT(*) FROM FishingVesselInspections WHERE InspectionDate >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH) GROUP BY Region;
gretelai_synthetic_text_to_sql
CREATE TABLE orders (order_id INT, menu_id INT, quantity INT, category VARCHAR(50));
Find the number of times each menu item has been ordered, grouped by its category.
SELECT category, menu_id, name, SUM(quantity) as total_orders FROM orders o JOIN menu_items m ON o.menu_id = m.menu_id GROUP BY category, menu_id;
gretelai_synthetic_text_to_sql
CREATE TABLE security_incidents (id INT, country VARCHAR(255), incident_type VARCHAR(255), timestamp TIMESTAMP);CREATE VIEW incident_count_by_country AS SELECT country, COUNT(*) as total_incidents FROM security_incidents GROUP BY country;
What is the total number of security incidents per country, ordered by the highest number of incidents?
SELECT country, total_incidents FROM incident_count_by_country ORDER BY total_incidents DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Dispensaries (id INT, name TEXT, state TEXT);CREATE TABLE Sales (id INT, dispensary_id INT, revenue DECIMAL(10,2), sale_date DATE); INSERT INTO Dispensaries (id, name, state) VALUES (1, 'Dispensary A', 'Arizona'); INSERT INTO Sales (id, dispensary_id, revenue, sale_date) VALUES (1, 1, 15000, '2022-06-01');
What is the total revenue for each dispensary in Arizona in the last month?
SELECT d.name, SUM(s.revenue) FROM Dispensaries d JOIN Sales s ON d.id = s.dispensary_id WHERE d.state = 'Arizona' AND s.sale_date BETWEEN DATE_SUB(CURDATE(), INTERVAL 1 MONTH) AND CURDATE() GROUP BY d.name;
gretelai_synthetic_text_to_sql