context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE vessel_performance (id INT, name TEXT, speed DECIMAL(5,2), arrived_date DATE, country TEXT); INSERT INTO vessel_performance (id, name, speed, arrived_date, country) VALUES (1, 'Vessel G', 26.1, '2022-01-02', 'Spain'), (2, 'Vessel H', 22.8, '2022-01-11', 'Spain'), (3, 'Vessel I', 29.6, '2022-01-19', 'Spain'...
How many vessels arrived in Spain in January 2022 with a speed greater than 25 knots?
SELECT COUNT(*) FROM vessel_performance WHERE arrived_date BETWEEN '2022-01-01' AND '2022-01-31' AND country = 'Spain' AND speed > 25;
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_offset_projects (id INT, project_name VARCHAR(50), country VARCHAR(50), offset_amount INT);
What is the maximum carbon offset achieved by a single project in Australia?
SELECT MAX(offset_amount) FROM carbon_offset_projects WHERE country = 'Australia';
gretelai_synthetic_text_to_sql
CREATE TABLE restaurants (restaurant_id INT, city VARCHAR(255)); CREATE TABLE inspections (inspection_id INT, restaurant_id INT, score INT); INSERT INTO restaurants VALUES (1, 'New York'); INSERT INTO restaurants VALUES (2, 'Los Angeles'); INSERT INTO inspections VALUES (1, 1, 85); INSERT INTO inspections VALUES (2, 1,...
Display the average food safety inspection score for restaurants in each city, along with the number of inspections that were conducted.
SELECT r.city, AVG(i.score) as average_score, COUNT(i.inspection_id) as total_inspections FROM restaurants r INNER JOIN inspections i ON r.restaurant_id = i.restaurant_id GROUP BY r.city;
gretelai_synthetic_text_to_sql
CREATE TABLE buildings (id INT, building_type VARCHAR(255), area VARCHAR(255), energy_efficiency_score FLOAT); INSERT INTO buildings (id, building_type, area, energy_efficiency_score) VALUES (1, 'Residential', 'Urban', 75.0), (2, 'Commercial', 'Urban', 60.0);
What is the average energy efficiency score for residential buildings in 'Urban' areas?
SELECT AVG(energy_efficiency_score) FROM buildings WHERE building_type = 'Residential' AND area = 'Urban';
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, customer_name VARCHAR(50), state VARCHAR(20), account_number INT); INSERT INTO customers (customer_id, customer_name, state, account_number) VALUES (1, 'John Doe', 'GA', 12345), (2, 'Jane Smith', 'NY', 67890), (3, 'Jim Brown', 'GA', 11111), (4, 'Jill White', 'GA', 22222);
How many customers have more than one account in Georgia?
SELECT COUNT(*) FROM (SELECT customer_id FROM customers GROUP BY customer_id HAVING COUNT(*) > 1) AS subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE teacher_pd (teacher_id INT, course_id INT, pd_date DATE); INSERT INTO teacher_pd (teacher_id, course_id, pd_date) VALUES (1, 1, '2020-01-01'), (2, 2, '2020-02-15'), (3, 1, '2020-03-10'), (4, 3, '2020-12-31'), (5, 1, '2021-01-01'), (6, 2, '2021-02-15'), (7, 1, '2021-03-10'), (8, 3, '2021-12-31'); CREATE TAB...
What professional development courses were attended by the most teachers in 2020 and 2021?
SELECT c.course_name, COUNT(pd.teacher_id) AS num_teachers FROM teacher_pd pd JOIN courses c ON pd.course_id = c.course_id WHERE pd.pd_date >= '2020-01-01' AND pd.pd_date <= '2021-12-31' GROUP BY pd.course_id ORDER BY num_teachers DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (id INT, donor_name TEXT, donation_amount DECIMAL(10,2), state TEXT); INSERT INTO Donations (id, donor_name, donation_amount, state) VALUES (1, 'John Doe', 50.00, 'NY'), (2, 'Jane Smith', 100.00, 'CA');
What is the average donation amount per state?
SELECT state, AVG(donation_amount) FROM Donations GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE diversity_quota (id INT PRIMARY KEY, region VARCHAR(50), gender VARCHAR(10), minority VARCHAR(10), target INT);
Create a table named 'diversity_quota' to track diversity hiring goals
CREATE TABLE diversity_quota (id INT PRIMARY KEY, region VARCHAR(50), gender VARCHAR(10), minority VARCHAR(10), target INT);
gretelai_synthetic_text_to_sql
CREATE TABLE ChemicalProduction (ID INT, Chemical VARCHAR(10), Quantity INT, ProductionDate DATE); INSERT INTO ChemicalProduction (ID, Chemical, Quantity, ProductionDate) VALUES (1, 'A', 500, '2021-01-05'), (2, 'A', 700, '2021-02-10'), (3, 'A', 800, '2021-03-20');
What is the total quantity of chemical 'A' produced per month in 2021?
SELECT Chemical, DATE_FORMAT(ProductionDate, '%Y-%m') as Month, SUM(Quantity) as TotalQuantity FROM ChemicalProduction WHERE Chemical = 'A' AND ProductionDate >= '2021-01-01' AND ProductionDate < '2022-01-01' GROUP BY Chemical, Month;
gretelai_synthetic_text_to_sql
UPDATE suppliers SET sustainability_score = 4.5 WHERE supplier_id = 2;
Update the sustainability_score of the supplier with supplier_id 2 to 4.5
UPDATE suppliers SET sustainability_score = 4.5 WHERE supplier_id = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE developers (id INT, name VARCHAR(50), gender VARCHAR(10), salary INT, join_date DATE); INSERT INTO developers (id, name, gender, salary, join_date) VALUES (1, 'John Doe', 'Male', 80000, '2020-01-01'); INSERT INTO developers (id, name, gender, salary, join_date) VALUES (2, 'Jane Smith', 'Female', 85000, '20...
What is the average salary of developers who joined in 2020, partitioned by gender and ordered by salary?
SELECT gender, AVG(salary) OVER (PARTITION BY gender ORDER BY salary) as avg_salary FROM developers WHERE YEAR(join_date) = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE temperature_anomaly (region varchar(255), year int, anomaly decimal(10,2)); INSERT INTO temperature_anomaly (region, year, anomaly) VALUES ('Southern Ocean', 2018, 1.20), ('Southern Ocean', 2019, 1.50), ('Southern Ocean', 2020, 1.70);
What is the average temperature anomaly in the Southern Ocean in 2020?
SELECT AVG(anomaly) FROM temperature_anomaly WHERE region = 'Southern Ocean' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE ny_community_policing (id INT, event_type TEXT, event_date DATE); INSERT INTO ny_community_policing (id, event_type, event_date) VALUES (1, 'Meeting', '2022-01-01'), (2, 'Workshop', '2022-02-01'), (3, 'Patrol', '2022-03-01');
How many community policing events were held in New York?
SELECT COUNT(*) FROM ny_community_policing WHERE event_type = 'Meeting' OR event_type = 'Workshop' OR event_type = 'Patrol';
gretelai_synthetic_text_to_sql
CREATE TABLE rescue_center_animals (animal_id INT, animal_name VARCHAR(50), region VARCHAR(50)); INSERT INTO rescue_center_animals (animal_id, animal_name, region) VALUES (1, 'Tiger', 'Asian Rainforest'); INSERT INTO rescue_center_animals (animal_id, animal_name, region) VALUES (2, 'Elephant', 'Asian Rainforest');
Delete all records of animals from the 'Asian Rainforest' region in the rescue center.
DELETE FROM rescue_center_animals WHERE region = 'Asian Rainforest';
gretelai_synthetic_text_to_sql
CREATE TABLE WeatherData (id INT, Location VARCHAR(255), Temperature INT, Timestamp DATETIME); INSERT INTO WeatherData (id, Location, Temperature, Timestamp) VALUES (1, 'Brazil', 35, '2022-05-15 12:00:00'), (2, 'Brazil', 38, '2022-05-16 12:00:00');
List the top 3 hottest days in Brazil in the last 30 days?
SELECT Location, Temperature, Timestamp FROM (SELECT Location, Temperature, Timestamp, ROW_NUMBER() OVER (PARTITION BY Location ORDER BY Temperature DESC) as rn FROM WeatherData WHERE Timestamp BETWEEN DATEADD(day, -30, GETDATE()) AND GETDATE()) t WHERE rn <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE cuisine(id INT, type VARCHAR(255), sales FLOAT); INSERT INTO cuisine (id, type, sales) VALUES (1, 'Italian', 5000.00), (2, 'Mexican', 3000.00), (3, 'Chinese', 4000.00);
What are the total sales for each cuisine type?
SELECT type, SUM(sales) FROM cuisine GROUP BY type;
gretelai_synthetic_text_to_sql
CREATE TABLE botnet_threats (id INT, threat_type VARCHAR(50), severity_score INT, threat_date DATE);
What is the average severity score of threats related to 'botnet' in the last year?
SELECT AVG(severity_score) as avg_severity FROM botnet_threats WHERE threat_type = 'botnet' AND threat_date >= DATEADD(year, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE smart_contracts (contract_id INT PRIMARY KEY, contract_name TEXT, contract_version TEXT); INSERT INTO smart_contracts (contract_id, contract_name, contract_version) VALUES (5, 'Uniswap', 'v3');
What is the name of the smart contract with contract_id 5?
SELECT contract_name FROM smart_contracts WHERE contract_id = 5;
gretelai_synthetic_text_to_sql
CREATE TABLE Operations.Pollution_Initiatives ( id INT, initiative_name VARCHAR(255), budget INT );
Find the total budget for marine pollution initiatives in the 'Operations' schema's 'Pollution_Initiatives' table
SELECT SUM(budget) FROM Operations.Pollution_Initiatives;
gretelai_synthetic_text_to_sql
CREATE TABLE network_investments (investment_id INT, region VARCHAR(50), investment_amount FLOAT); INSERT INTO network_investments (investment_id, region, investment_amount) VALUES (1, 'Asia-Pacific', 5000000), (2, 'Europe', 3000000);
What is the total network investment in the Asia-Pacific region?
SELECT SUM(investment_amount) FROM network_investments WHERE region = 'Asia-Pacific';
gretelai_synthetic_text_to_sql
CREATE TABLE water_usage (year INT, usage FLOAT); INSERT INTO water_usage (year, usage) VALUES (2018, 1234.56), (2019, 2345.67), (2020, 3456.78), (2021, 4567.89);
Determine the average water usage in cubic meters for each year
SELECT year, AVG(usage) FROM water_usage GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE community_health_workers (id INT, name TEXT, state TEXT); INSERT INTO community_health_workers (id, name, state) VALUES (1, 'Aaliyah Johnson', 'TX'), (2, 'Brian Martinez', 'FL'); CREATE TABLE cultural_competency_training (id INT, worker_id INT, state TEXT); INSERT INTO cultural_competency_training (id, wor...
How many community health workers have completed cultural competency training in Texas or Florida?
SELECT chw.name FROM community_health_workers chw INNER JOIN cultural_competency_training cct ON chw.id = cct.worker_id WHERE chw.state IN ('TX', 'FL');
gretelai_synthetic_text_to_sql
CREATE TABLE mining_sites (id INT, name VARCHAR(50), location VARCHAR(50), num_employees INT); INSERT INTO mining_sites (id, name, location, num_employees) VALUES (1, 'Site Alpha', 'USA', 100), (2, 'Site Bravo', 'Canada', 150);
What are the names of all the mining sites in the 'mining_sites' table?
SELECT name FROM mining_sites;
gretelai_synthetic_text_to_sql
CREATE TABLE Mines (MineID INT, Name TEXT, Location TEXT, TotalWorkers INT, EnvironmentalImpactScore INT); INSERT INTO Mines (MineID, Name, Location, TotalWorkers, EnvironmentalImpactScore) VALUES (1, 'Golden Mine', 'California', 250, 60), (2, 'Silver Ridge', 'Nevada', 300, 70);
What is the average environmental impact score for mines in California?
SELECT AVG(EnvironmentalImpactScore) FROM Mines WHERE Location = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE investments (id INT, investor VARCHAR(255), project_type VARCHAR(255), amount INT, date DATE); INSERT INTO investments (id, investor, project_type, amount, date) VALUES (12, 'GreenCapital', 'water_treatment', 900000, '2022-07-22'); INSERT INTO investments (id, investor, project_type, amount, date) VALUES (...
List all investments made in 'water_treatment' projects by 'GreenCapital'.
SELECT * FROM investments WHERE investor = 'GreenCapital' AND project_type = 'water_treatment';
gretelai_synthetic_text_to_sql
CREATE TABLE transportation_workers (id INT, name TEXT, sector TEXT, salary FLOAT, union_member BOOLEAN);
What is the minimum and maximum salary of workers in the 'transportation' sector, grouped by union membership?
SELECT union_member as union, MIN(salary) as min_salary, MAX(salary) as max_salary FROM transportation_workers WHERE sector = 'transportation' GROUP BY union_member;
gretelai_synthetic_text_to_sql
CREATE TABLE underwater_canyons (name VARCHAR(255), depth FLOAT); INSERT INTO underwater_canyons (name, depth) VALUES ('Monterey Canyon', 3600.0), ('Saguenay Fjord', 280.0), ('Laurentian Channel', 340.0);
What is the maximum depth of all underwater canyons?
SELECT MAX(depth) FROM underwater_canyons;
gretelai_synthetic_text_to_sql
CREATE TABLE precinct (id INT, name VARCHAR(50)); INSERT INTO precinct (id, name) VALUES (1, 'Northside'); CREATE TABLE incident (id INT, precinct_id INT, type VARCHAR(50), timestamp TIMESTAMP, response_time INT);
What is the average response time for fire incidents in the 'Northside' precinct?
SELECT AVG(response_time) as avg_response_time FROM incident WHERE precinct_id = 1 AND type = 'fire';
gretelai_synthetic_text_to_sql
CREATE TABLE continent_infrastructure (id INT, name VARCHAR(50), continent VARCHAR(50), resilience_score FLOAT); INSERT INTO continent_infrastructure VALUES (1, 'Dam', 'Africa', 80), (2, 'Bridge', 'Asia', 70), (3, 'Road', 'South America', 88);
What is the average resilience score for infrastructure in each continent?
SELECT continent, AVG(resilience_score) FROM continent_infrastructure GROUP BY continent;
gretelai_synthetic_text_to_sql
CREATE TABLE restaurant_revenue(restaurant_id INT, cuisine VARCHAR(255), daily_revenue DECIMAL(10,2), region VARCHAR(255), revenue_date DATE);
What is the daily revenue for restaurants serving 'Mediterranean' cuisine in the 'Europe' region for the month of August 2022?
SELECT daily_revenue FROM restaurant_revenue WHERE cuisine = 'Mediterranean' AND region = 'Europe' AND revenue_date BETWEEN '2022-08-01' AND '2022-08-31' GROUP BY revenue_date;
gretelai_synthetic_text_to_sql
CREATE TABLE exhibitions (exhibition_id INT, name VARCHAR(255)); INSERT INTO exhibitions (exhibition_id, name) VALUES (1, 'Art of the Renaissance'); CREATE TABLE visitors (visitor_id INT, exhibition_id INT, age INT); INSERT INTO visitors (visitor_id, exhibition_id, age) VALUES (1, 1, 35), (2, 1, 42), (3, 1, 28);
What was the average age of visitors who attended the Art of the Renaissance exhibition?
SELECT AVG(age) as avg_age FROM visitors WHERE exhibition_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Artworks (Artist VARCHAR(50), Artwork VARCHAR(50), Year INT); INSERT INTO Artworks (Artist, Artwork, Year)
Delete artworks from 2000 in the 'Artworks' table
DELETE FROM Artworks WHERE Year = 2000
gretelai_synthetic_text_to_sql
CREATE TABLE HumanResources (employee_id INT, name VARCHAR(50), department VARCHAR(50), salary FLOAT, gender VARCHAR(10)); INSERT INTO HumanResources (employee_id, name, department, salary, gender) VALUES (1, 'John Doe', 'HumanResources', 60000, 'Male'), (2, 'Jane Smith', 'HumanResources', 65000, 'Female');
What is the average annual salary of employees in the 'HumanResources' department, partitioned by gender?
SELECT department, gender, AVG(salary) AS avg_salary FROM (SELECT employee_id, name, department, salary, gender, ROW_NUMBER() OVER (PARTITION BY department, gender ORDER BY salary) as rn FROM HumanResources) x WHERE rn = 1 GROUP BY department, gender;
gretelai_synthetic_text_to_sql
CREATE TABLE graduate_students (id INT, name VARCHAR(50), department VARCHAR(50)); CREATE TABLE publications (id INT, title VARCHAR(100), author_id INT, department VARCHAR(50));
What is the maximum number of publications for a single graduate student in the Physics department?
SELECT MAX(publications_count) FROM (SELECT graduate_students.id, COUNT(publications.id) AS publications_count FROM graduate_students INNER JOIN publications ON graduate_students.id = publications.author_id WHERE graduate_students.department = 'Physics' GROUP BY graduate_students.id) AS subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE plants (id INT, name TEXT, location TEXT, safety_score INT); INSERT INTO plants (id, name, location, safety_score) VALUES (1, 'ChemCo', 'California', 85), (2, 'EcoChem', 'California', 92), (3, 'GreenChem', 'Nevada', 88);
What is the average safety score for chemical plants located in California, ordered by plant name?
SELECT AVG(safety_score) AS avg_safety_score FROM plants WHERE location = 'California' ORDER BY name;
gretelai_synthetic_text_to_sql
CREATE TABLE hotel_data (hotel_id INT, hotel_name TEXT, rating FLOAT, virtual_tour_engagement FLOAT); INSERT INTO hotel_data (hotel_id, hotel_name, rating, virtual_tour_engagement) VALUES (1, 'Hotel X', 4.5, 0.15), (2, 'Hotel Y', 4.2, 0.20), (3, 'Hotel Z', 3.8, 0.10), (4, 'Hotel W', 4.7, 0.18), (5, 'Hotel V', 4.0, 0.12...
What is the correlation between virtual tour engagement and hotel rating?
SELECT CORR(rating, virtual_tour_engagement) FROM hotel_data;
gretelai_synthetic_text_to_sql
CREATE TABLE delivery_data (delivery_id INT, shipment_id INT, delivery_time INT); INSERT INTO delivery_data (delivery_id, shipment_id, delivery_time) VALUES (1, 1, 10), (2, 2, 15), (3, 3, 12), (4, 4, 18), (5, 5, 20);
What is the average delivery time for packages shipped to Africa?
SELECT AVG(delivery_time) FROM delivery_data JOIN shipment_data ON delivery_data.shipment_id = shipment_data.shipment_id WHERE shipment_data.destination_country = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE cybersecurity_policies (id INT, name VARCHAR(50), description TEXT, date DATE); INSERT INTO cybersecurity_policies (id, name, description, date) VALUES (1, 'Incident response policy', 'Outlines the process for responding to security incidents', '2022-04-15'), (2, 'Access control policy', 'Defines who has a...
Show me the cybersecurity policies that were dropped in the last week.
SELECT * FROM cybersecurity_policies WHERE date >= DATEADD(week, -1, GETDATE()) AND name = 'Password policy';
gretelai_synthetic_text_to_sql
CREATE TABLE wind_energy (year INT, region VARCHAR(20), energy_generated INT);CREATE TABLE solar_energy (year INT, region VARCHAR(20), energy_generated INT);
What is the total energy generated by wind and solar sources in 2021?
SELECT SUM(w.energy_generated) + SUM(s.energy_generated) FROM wind_energy w JOIN solar_energy s ON w.year = s.year WHERE w.year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE athletes (athlete_id INT, name VARCHAR(50), state VARCHAR(2)); INSERT INTO athletes (athlete_id, name, state) VALUES (1, 'Alex', 'CA'), (2, 'Beth', 'NY'), (3, 'Charlie', 'CA'); CREATE TABLE wellbeing_programs (program_id INT, athlete_id INT); INSERT INTO wellbeing_programs (program_id, athlete_id) VALUES (...
List all athletes participating in wellbeing programs in California
SELECT athletes.name FROM athletes INNER JOIN wellbeing_programs ON athletes.athlete_id = wellbeing_programs.athlete_id WHERE athletes.state = 'CA';
gretelai_synthetic_text_to_sql
CREATE TABLE accessible_tech_donations (city VARCHAR(50), year INT, devices INT); INSERT INTO accessible_tech_donations (city, year, devices) VALUES ('San Francisco', 2020, 150), ('New York', 2021, 200), ('Los Angeles', 2019, 120), ('Chicago', 2020, 180), ('Houston', 2021, 220);
Find the number of accessible technology devices donated per city in the last 3 years, ordered by the most donated.
SELECT city, SUM(devices) as total_devices FROM accessible_tech_donations WHERE year >= 2019 GROUP BY city ORDER BY total_devices DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Menu_Item (item_name VARCHAR(255), last_sold TIMESTAMP); INSERT INTO Menu_Item (item_name, last_sold) VALUES ('Burger', '2022-02-20 12:00:00'), ('Fries', '2022-02-25 10:00:00');
Which menu items have not been sold in the last week?
SELECT item_name FROM Menu_Item WHERE last_sold <= DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 1 WEEK);
gretelai_synthetic_text_to_sql
CREATE TABLE patients (id INT, name VARCHAR(50), age INT, gender VARCHAR(10), diagnosis VARCHAR(50), location VARCHAR(50)); INSERT INTO patients (id, name, age, gender, diagnosis, location) VALUES (1, 'Jane Doe', 65, 'Female', 'Hypertension', 'Texas'), (2, 'John Doe', 45, 'Male', 'Hypertension', 'Texas'), (3, 'Jim Brow...
What is the average age of patients with hypertension in rural Texas who are female?
SELECT AVG(age) FROM patients WHERE diagnosis = 'Hypertension' AND gender = 'Female' AND location = 'Texas';
gretelai_synthetic_text_to_sql
CREATE TABLE Labor_Statistics_MA (state VARCHAR(2), year INT, workers_count INT); INSERT INTO Labor_Statistics_MA VALUES ('MA', 2020, 30000);
List all construction labor statistics for Massachusetts in 2020
SELECT * FROM Labor_Statistics_MA WHERE state = 'MA' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE drilling_operations (drill_id INT, well_id INT, start_date DATE, end_date DATE, status VARCHAR(50)); INSERT INTO drilling_operations (drill_id, well_id, start_date, end_date, status) VALUES (1, 1, '2020-01-01', '2020-04-30', 'Completed'), (2, 2, '2020-02-15', '2020-05-25', 'In Progress'), (3, 3, '2019-12-1...
Which wells had drilling operations started in 2019?
SELECT well_id FROM drilling_operations WHERE start_date BETWEEN '2019-01-01' AND '2019-12-31' GROUP BY well_id;
gretelai_synthetic_text_to_sql
CREATE TABLE songs (id INT, title TEXT, length FLOAT, genre TEXT); INSERT INTO songs (id, title, length, genre) VALUES (1, 'Song1', 120.0, 'Rock'), (2, 'Song2', 180.0, 'Pop'), (3, 'Song3', 240.0, 'Jazz'), (4, 'Song4', 90.0, 'Classical'), (5, 'Song5', 150.0, 'Hip-Hop'), (6, 'Song6', 210.0, 'Rock');
How many unique genres are represented in the database?
SELECT COUNT(DISTINCT genre) FROM songs;
gretelai_synthetic_text_to_sql
CREATE TABLE employees (employee_name VARCHAR(50), department_name VARCHAR(50), salary DECIMAL(10,2));
What is the name of the department with the highest average salary in the employees table?
SELECT department_name FROM employees WHERE (SELECT AVG(salary) FROM employees AS e2 WHERE e1.department_name = e2.department_name) = (SELECT MAX(avg_salary) FROM (SELECT department_name, AVG(salary) AS avg_salary FROM employees GROUP BY department_name) AS e3);
gretelai_synthetic_text_to_sql
CREATE TABLE CityEnergyConsumption (city TEXT, energy_consumption FLOAT); INSERT INTO CityEnergyConsumption (city, energy_consumption) VALUES ('City1', 12000), ('City2', 15000), ('City3', 18000);
What is the total energy consumption of buildings for each city in the 'CityEnergyConsumption' table?
SELECT city, SUM(energy_consumption) FROM CityEnergyConsumption GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE public_transportation (id INT, trip_date DATE, trip_type VARCHAR(20), num_trips INT);
Find the number of public transportation trips in 'public_transportation' table that were taken in '2022-01-01' and '2022-12-31' and display the results by trip_type.
SELECT trip_type, COUNT(*) AS num_trips FROM public_transportation WHERE trip_date BETWEEN '2022-01-01' AND '2022-12-31' GROUP BY trip_type;
gretelai_synthetic_text_to_sql
CREATE TABLE vessel_inspections (vessel_name VARCHAR(255), inspection_year INT, inspection_location VARCHAR(255)); INSERT INTO vessel_inspections (vessel_name, inspection_year, inspection_location) VALUES ('MV Nisha', 2020, 'Arctic'), ('MV Ravi', 2019, 'Arctic');
How many vessels were inspected for maritime law compliance in the Arctic in 2019?
SELECT COUNT(*) FROM vessel_inspections WHERE inspection_year = 2019 AND inspection_location = 'Arctic';
gretelai_synthetic_text_to_sql
CREATE TABLE students (student_id INT, name VARCHAR(255), major VARCHAR(255), gpa DECIMAL(3,2)); CREATE TABLE research_grants (grant_id INT, title VARCHAR(255), amount DECIMAL(10,2), department VARCHAR(255)); CREATE VIEW major_grants AS SELECT * FROM research_grants WHERE amount > 40000;
List the titles and amounts of all research grants in the "major_grants" view.
SELECT title, amount FROM major_grants;
gretelai_synthetic_text_to_sql
CREATE TABLE ClassicGame (GameID INT, PlayerID INT, PlayerName VARCHAR(50)); INSERT INTO ClassicGame (GameID, PlayerID, PlayerName) VALUES (2001, 1, 'John'), (2002, 2, 'Sarah'), (2003, 3, 'Mike');
What are the names of players who have played the 'ClassicGame' table?
SELECT PlayerName FROM ClassicGame;
gretelai_synthetic_text_to_sql
CREATE TABLE platforms (platform_id INT, daily_gas_production FLOAT); INSERT INTO platforms (platform_id, daily_gas_production) VALUES (1, 2000000), (2, 3000000), (3, 1000000), (4, 4000000);
Calculate the total daily gas production for each platform
SELECT platform_id, SUM(daily_gas_production) as total_daily_gas_production FROM platforms GROUP BY platform_id;
gretelai_synthetic_text_to_sql
CREATE TABLE food_safety_inspections (restaurant VARCHAR(255), inspection_date DATE, score INT); INSERT INTO food_safety_inspections (restaurant, inspection_date, score) VALUES ('Restaurant A', '2022-01-01', 95), ('Restaurant A', '2022-02-01', 90), ('Restaurant B', '2022-01-01', 85), ('Restaurant B', '2022-02-01', 88);
What was the average food safety score for each restaurant in the last 6 months?
SELECT restaurant, AVG(score) FROM food_safety_inspections WHERE inspection_date >= DATE_SUB(CURDATE(), INTERVAL 6 MONTH) GROUP BY restaurant;
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name TEXT, founded_date DATE, founder_gender TEXT); INSERT INTO companies (id, name, founded_date, founder_gender) VALUES (1, 'Acme Inc', '2010-01-01', 'male'); INSERT INTO companies (id, name, founded_date, founder_gender) VALUES (2, 'Beta Corp', '2015-05-15', 'male');
Update the gender of the founder for a specific company.
UPDATE companies SET founder_gender = 'female' WHERE id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE offenders (offender_id INT, age INT, state VARCHAR(20)); INSERT INTO offenders (offender_id, age, state) VALUES (1, 34, 'California'), (2, 45, 'California'); CREATE TABLE restorative_justice (offender_id INT, program_completion BOOLEAN); INSERT INTO restorative_justice (offender_id, program_completion) VAL...
What is the average age of offenders who completed restorative justice programs in California?
SELECT AVG(offenders.age) FROM offenders INNER JOIN restorative_justice ON offenders.offender_id = restorative_justice.offender_id WHERE restorative_justice.program_completion = TRUE AND offenders.state = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE citizen_feedback_records (state VARCHAR(20), response_time INT); INSERT INTO citizen_feedback_records (state, response_time) VALUES ('Florida', 48); INSERT INTO citizen_feedback_records (state, response_time) VALUES ('Florida', 52); INSERT INTO citizen_feedback_records (state, response_time) VALUES ('Texas...
What is the maximum response time for citizen feedback records in the state of Texas?
SELECT MAX(response_time) FROM citizen_feedback_records WHERE state = 'Texas';
gretelai_synthetic_text_to_sql
CREATE TABLE water_treatment_plants (id INT, name VARCHAR(50), division VARCHAR(50), daily_production_capacity INT, daily_consumption FLOAT); INSERT INTO water_treatment_plants (id, name, division, daily_production_capacity, daily_consumption) VALUES (1, 'Plant A', 'Utilities', 5000, 4500.0), (2, 'Plant B', 'Utilities'...
List the water treatment plants in the utilities division along with their daily water production capacity and the average daily water consumption.
SELECT name, daily_production_capacity, AVG(daily_consumption) FROM water_treatment_plants WHERE division = 'Utilities' GROUP BY name;
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, donor_id INT, amount DECIMAL(10,2), donation_date DATE, ethnicity VARCHAR(50)); INSERT INTO donations (id, donor_id, amount, donation_date, ethnicity) VALUES (1, 101, 500.00, '2021-01-01', 'Asian'), (2, 102, 300.00, '2021-02-15', 'Hispanic'), (3, 101, 600.00, '2022-04-01', 'Asian');
What is the total amount donated by each donor who has made a donation in both the last and current quarters, broken down by their ethnicity?
SELECT donor_id, SUM(amount), ethnicity FROM donations WHERE donation_date BETWEEN DATE_SUB(CURDATE(), INTERVAL 6 MONTH) AND DATE_SUB(CURDATE(), INTERVAL 3 MONTH) GROUP BY donor_id, ethnicity;
gretelai_synthetic_text_to_sql
CREATE TABLE Farmers (FarmerID INT, Name VARCHAR(50), Age INT, Country VARCHAR(50)); INSERT INTO Farmers (FarmerID, Name, Age, Country) VALUES (3, 'Raj Patel', 45, 'India'); INSERT INTO Farmers (FarmerID, Name, Age, Country) VALUES (4, 'Priya Kumar', 30, 'India');
What is the total quantity of fish farmed by farmers from India who are above 40 years old?
SELECT SUM(Quantity) FROM FishStock fs JOIN Farmers f ON fs.FarmerID = f.FarmerID WHERE f.Country = 'India' AND f.Age > 40;
gretelai_synthetic_text_to_sql
CREATE TABLE startups (startup_name VARCHAR(50), funding_amount INT);
Update the 'funding_amount' for 'Startup ABC' in the 'startups' table to '5000000'
UPDATE startups SET funding_amount = 5000000 WHERE startup_name = 'Startup ABC';
gretelai_synthetic_text_to_sql
CREATE TABLE garments (id INT, name VARCHAR(255), category VARCHAR(255), country VARCHAR(255), price DECIMAL(10,2)); INSERT INTO garments (id, name, category, country, price) VALUES (1, 'Tencel Shirt', 'Tops', 'Australia', 60.00);
Calculate the average price of 'Tencel Shirts' sold in Australia.
SELECT AVG(price) FROM orders INNER JOIN garments ON orders.garment_id = garments.id WHERE garments.name = 'Tencel Shirt' AND garments.country = 'Australia';
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name VARCHAR(255), region VARCHAR(50), certified_cruelty_free BOOLEAN); INSERT INTO products (product_id, product_name, region, certified_cruelty_free) VALUES (1, 'Lipstick A', 'Europe', true), (2, 'Foundation B', 'Asia', false), (3, 'Mascara C', 'Europe', true), (4, 'Eye-...
What is the percentage of cosmetic products that are certified cruelty-free in the Asian market?
SELECT 100.0 * SUM(certified_cruelty_free) / COUNT(*) AS percentage_cruelty_free FROM products WHERE region = 'Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE trips (id INT PRIMARY KEY, mode VARCHAR(20), time FLOAT, city VARCHAR(20));
What is the minimum time taken by a multimodal trip in London?
SELECT MIN(time) FROM trips WHERE mode = 'Multimodal' AND city = 'London';
gretelai_synthetic_text_to_sql
CREATE TABLE MentalHealthParity (Id INT, Region VARCHAR(20), ReportDate DATE); INSERT INTO MentalHealthParity (Id, Region, ReportDate) VALUES (1, 'Southwest', '2020-01-01'), (2, 'Northeast', '2019-12-31'), (3, 'Southwest', '2020-06-15'), (4, 'Northeast', '2020-01-10'), (5, 'Southwest', '2020-06-15'), (6, 'Northeast', '...
What is the total number of mental health parity cases reported in the Northeast region in 2019?
SELECT COUNT(*) as CountOfCases FROM MentalHealthParity WHERE Region = 'Northeast' AND YEAR(ReportDate) = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE Countries (id INT, name VARCHAR(50), region VARCHAR(50)); INSERT INTO Countries (id, name, region) VALUES (1, 'Kenya', 'Africa'), (2, 'Nigeria', 'Africa'), (3, 'South Africa', 'Africa'), (4, 'Egypt', 'Africa'), (5, 'Tanzania', 'Africa'); CREATE TABLE ArtsEvents (id INT, country_id INT, name VARCHAR(50)); I...
List the top 3 countries with the most traditional arts events in Africa.
SELECT country, COUNT(*) as events_count FROM ArtsEvents GROUP BY country ORDER BY events_count DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE urban.buildings (certification_level VARCHAR(255), energy_consumption INT); INSERT INTO urban.buildings (certification_level, energy_consumption) VALUES ('Gold', 1200), ('Gold', 1500), ('Silver', 1700), ('Silver', 1300), ('Bronze', 1000), ('Bronze', 1100);
What is the average energy consumption of buildings in the 'urban' schema, grouped by certification level?
SELECT certification_level, AVG(energy_consumption) FROM urban.buildings GROUP BY certification_level;
gretelai_synthetic_text_to_sql
CREATE TABLE ny_sales (revenue DECIMAL(10,2), quarter VARCHAR(10), year INT); INSERT INTO ny_sales (revenue, quarter, year) VALUES (50000, 'Q1', 2022), (60000, 'Q1', 2022), (40000, 'Q1', 2022);
What is the total revenue generated by cannabis sales in New York in Q1 2022?
SELECT SUM(revenue) as total_revenue FROM ny_sales WHERE quarter = 'Q1' AND year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_farms_4 (id INT, name TEXT, country TEXT, biomass FLOAT); INSERT INTO marine_farms_4 (id, name, country, biomass) VALUES (1, 'Farm K', 'Norway', 4500.0), (2, 'Farm L', 'Spain', 5500.0), (3, 'Farm M', 'Japan', 6500.0);
Which are the top 3 countries with the highest total biomass in marine farms?
SELECT country, SUM(biomass) AS total_biomass FROM marine_farms_4 GROUP BY country ORDER BY total_biomass DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE esports_events (event_id INT, country VARCHAR(20), num_teams INT);
How many esports events happened in each country, in descending order of events?
SELECT country, COUNT(*) as num_events FROM esports_events GROUP BY country ORDER BY num_events DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE visitor_statistics (id INT PRIMARY KEY, country VARCHAR(50), year INT, month INT, visitors INT);
Create a view for the international visitor statistics by year and country
CREATE VIEW visitor_statistics_by_year_country AS SELECT country, year, SUM(visitors) AS total_visitors FROM visitor_statistics GROUP BY country, year;
gretelai_synthetic_text_to_sql
CREATE TABLE clients(id INT, name TEXT, neighborhood TEXT, financial_wellbeing_score INT);
What is the average financial wellbeing score for clients in low-income neighborhoods?
SELECT AVG(c.financial_wellbeing_score) FROM clients c WHERE c.neighborhood LIKE '%low-income%';
gretelai_synthetic_text_to_sql
CREATE TABLE solar_projects (id INT, state VARCHAR(20), construction_year INT, installed_capacity FLOAT); INSERT INTO solar_projects (id, state, construction_year, installed_capacity) VALUES (1, 'California', 2016, 50.0), (2, 'California', 2017, 60.5), (3, 'California', 2018, 75.2), (4, 'California', 2019, 80.0);
What is the total installed capacity of solar projects in the state of California that were constructed after 2015?
SELECT SUM(installed_capacity) FROM solar_projects WHERE state = 'California' AND construction_year > 2015;
gretelai_synthetic_text_to_sql
CREATE TABLE players (id INT, name VARCHAR(50), position VARCHAR(20), age INT); INSERT INTO players (id, name, position, age) VALUES (1, 'John Doe', 'Guard', 25), (2, 'Jane Smith', 'Forward', 30); CREATE TABLE nba_teams (id INT, team_name VARCHAR(50), players_id INT); INSERT INTO nba_teams (id, team_name, players_id) V...
What is the average age of basketball players in the NBA by position?
SELECT position, AVG(age) FROM players JOIN nba_teams ON players.id = nba_teams.players_id GROUP BY position;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists biotech; CREATE TABLE if not exists biotech.genetic_patents (id INT, name VARCHAR(50), location VARCHAR(50), filed_date DATE, industry VARCHAR(50)); INSERT INTO biotech.genetic_patents (id, name, location, filed_date, industry) VALUES (1, 'PatentA', 'India', '2021-05-15', 'Genetic Research')...
What is the total number of genetic research patents filed per country, in the past 3 years, with a rank per country?
SELECT location, ROW_NUMBER() OVER (PARTITION BY location ORDER BY total_patents DESC) as country_rank, total_patents FROM (SELECT location, COUNT(*) as total_patents FROM biotech.genetic_patents WHERE industry = 'Genetic Research' AND filed_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 YEAR) GROUP BY location) as genetic_...
gretelai_synthetic_text_to_sql
CREATE TABLE gadolinium_production (id INT, name VARCHAR(255), element VARCHAR(10), country VARCHAR(100), production_date DATE, quantity FLOAT); INSERT INTO gadolinium_production (id, name, element, country, production_date, quantity) VALUES (1, 'GreenTech', 'Gd', 'USA', '2019-01-01', 15.0), (2, 'CleanEarth', 'Gd', 'Ca...
Delete all rows of Gadolinium production for 'SustainableInc' in 2019.
DELETE FROM gadolinium_production WHERE name = 'SustainableInc' AND YEAR(production_date) = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE businesses (id INT, name TEXT, industry TEXT, ownership TEXT, funding FLOAT); INSERT INTO businesses (id, name, industry, ownership, funding) VALUES (1, 'HealthCo', 'Health', 'Majority', 200000.00); INSERT INTO businesses (id, name, industry, ownership, funding) VALUES (2, 'TechCo', 'Technology', 'Minority...
What is the maximum amount of funding allocated to a business in the Finance sector?
SELECT MAX(funding) FROM businesses WHERE industry = 'Finance';
gretelai_synthetic_text_to_sql
CREATE TABLE regulatory_frameworks (country TEXT, asset TEXT, status TEXT); INSERT INTO regulatory_frameworks (country, asset, status) VALUES ('Brazil', 'Stellar', 'Approved');
What is the regulatory status of Stellar in Brazil?
SELECT status FROM regulatory_frameworks WHERE country = 'Brazil' AND asset = 'Stellar';
gretelai_synthetic_text_to_sql
funding(id, startup_id, funding_round, funding_amount, date_announced)
Update the funding amount for startup with id 1 in the 'funding' table
UPDATE funding SET funding_amount = 1000000 WHERE startup_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE data_usage (subscriber_id INT, service VARCHAR(10), start_date DATE, end_date DATE, data_usage INT); INSERT INTO data_usage (subscriber_id, service, start_date, end_date, data_usage) VALUES (1, 'prepaid', '2022-01-01', '2022-01-31', 3000), (2, 'prepaid', '2022-02-01', '2022-02-28', 3500);
What is the average monthly data usage for prepaid mobile subscribers?
SELECT AVG(data_usage) FROM data_usage WHERE service = 'prepaid';
gretelai_synthetic_text_to_sql
CREATE TABLE chemical_batches (batch_id INT, pressure FLOAT, timestamp TIMESTAMP); INSERT INTO chemical_batches (batch_id, pressure, timestamp) VALUES (1, 1200, '2021-01-01 00:00:00'); INSERT INTO chemical_batches (batch_id, pressure, timestamp) VALUES (2, 1100, '2021-01-02 00:00:00');
Identify the chemical batch with the lowest pressure value.
SELECT batch_id, pressure FROM (SELECT batch_id, pressure, ROW_NUMBER() OVER (ORDER BY pressure ASC) as row_num FROM chemical_batches) as subquery WHERE row_num = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE smart_contracts (dapp_name VARCHAR(20), contract_address VARCHAR(40)); INSERT INTO smart_contracts (dapp_name, contract_address) VALUES ('Uniswap', '0x1234567890'), ('Sushiswap', '0x2345678901'), ('Uniswap', '0xabcdefghij');
List all smart contracts associated with the decentralized application 'Uniswap' on a specific date.
SELECT contract_address FROM smart_contracts WHERE dapp_name = 'Uniswap';
gretelai_synthetic_text_to_sql
CREATE TABLE CommunityHealthWorkers (WorkerID INT, Name VARCHAR(50), Specialty VARCHAR(50)); CREATE TABLE Cases (WorkerID INT, CaseID INT, CaseType VARCHAR(20)); INSERT INTO CommunityHealthWorkers (WorkerID, Name, Specialty) VALUES (1, 'John Doe', 'Mental Health'); INSERT INTO CommunityHealthWorkers (WorkerID, Name, Sp...
List the names of community health workers who manage cases of both mental health and physical health.
SELECT DISTINCT c.Name FROM Cases c INNER JOIN CommunityHealthWorkers h ON c.WorkerID = h.WorkerID WHERE h.Specialty IN ('Mental Health', 'Physical Health') GROUP BY c.Name HAVING COUNT(DISTINCT c.CaseType) = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE cultural_competency_trainings (training_id INT, location VARCHAR(50), date DATE);
Insert a new cultural competency training in Chicago, IL on 2022-04-01.
INSERT INTO cultural_competency_trainings (training_id, location, date) VALUES (4, 'Chicago, IL', '2022-04-01');
gretelai_synthetic_text_to_sql
CREATE TABLE stores (store_id INT, store_name VARCHAR(50), country VARCHAR(50)); CREATE TABLE inventory (product_id INT, store_id INT, in_stock INT, ethical_product BOOLEAN); INSERT INTO stores (store_id, store_name, country) VALUES (1, 'Store A', 'USA'), (2, 'Store B', 'Canada'), (3, 'Store C', 'USA'); INSERT INTO inv...
Which stores in the USA have more than 50 units of ethical products in stock?
SELECT s.store_name FROM stores s JOIN inventory i ON s.store_id = i.store_id WHERE i.ethical_product = true AND s.country = 'USA' GROUP BY s.store_name HAVING SUM(i.in_stock) > 50;
gretelai_synthetic_text_to_sql
CREATE TABLE ingredient_transparency (ingredient_id INT PRIMARY KEY, product_id INT, ingredient_name VARCHAR(255), ingredient_safety_rating INT);
Insert data for a new product 'Vegan Lipstick' with ingredient 'Organic Avocado Oil' and safety rating 5 into 'ingredient_transparency' table
INSERT INTO ingredient_transparency (ingredient_id, product_id, ingredient_name, ingredient_safety_rating) VALUES ((SELECT MAX(ingredient_id) FROM ingredient_transparency)+1, (SELECT MAX(product_id) FROM ingredient_transparency)+1, 'Organic Avocado Oil', 5);
gretelai_synthetic_text_to_sql
CREATE TABLE Accommodations (student_id INT, accommodation_type VARCHAR(50), state VARCHAR(50), request_date DATE, visual_impairment BOOLEAN);
List the number of students with visual impairments who received accommodations in each state in 2022.
SELECT state, COUNT(DISTINCT student_id) FROM Accommodations WHERE request_date >= '2022-01-01' AND request_date < '2023-01-01' AND visual_impairment = TRUE GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE union_details (id INT, union_name VARCHAR(255), location VARCHAR(255));INSERT INTO union_details (id, union_name, location) VALUES (1, 'California Nurses Association', 'California'); INSERT INTO union_details (id, union_name, location) VALUES (2, 'United Teachers Los Angeles', 'California');
Find the number of members in unions based in California
SELECT COUNT(*) FROM union_details WHERE location = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE Events (EventID INT, EventName TEXT, Country TEXT, Year INT); CREATE TABLE Volunteers (VolunteerID INT, EventID INT, Name TEXT); INSERT INTO Events (EventID, EventName, Country, Year) VALUES (1, 'Gala', 'USA', 2020), (2, 'Fundraiser', 'UK', 2020); INSERT INTO Volunteers (VolunteerID, EventID, Name) VALUES ...
List all events with more than 50 volunteers from the United States and United Kingdom in 2020, including their event names and total volunteer counts.
SELECT e.EventName, COUNT(v.VolunteerID) AS TotalVolunteers FROM Events e JOIN Volunteers v ON e.EventID = v.EventID WHERE e.Country IN ('USA', 'UK') AND TotalVolunteers > 50 GROUP BY e.EventID;
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_rates (id INT, material VARCHAR(20), city VARCHAR(20), rate DECIMAL(3,2)); INSERT INTO recycling_rates (id, material, city, rate) VALUES (1, 'Electronics', 'Montreal', 0.55), (2, 'Textiles', 'Montreal', 0.40);
Find the recycling rates for 'Electronics' and 'Textiles' materials in 'Montreal'
SELECT material, rate FROM recycling_rates WHERE material IN ('Electronics', 'Textiles') AND city = 'Montreal';
gretelai_synthetic_text_to_sql
CREATE TABLE cargo_handling (transaction_id INT, port VARCHAR(255), date DATE, weight INT); INSERT INTO cargo_handling (transaction_id, port, date, weight) VALUES (1, 'PortA', '2022-01-01', 5000), (2, 'PortB', '2022-01-05', 7000), (3, 'PortA', '2022-01-10', 9000);
What are the top 3 heaviest cargo handling transactions for each port in the cargo_handling table?
SELECT port, transaction_id, weight FROM (SELECT port, transaction_id, weight, ROW_NUMBER() OVER (PARTITION BY port ORDER BY weight DESC) as rn FROM cargo_handling) t WHERE t.rn <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE investments (id INT, company_id INT, investment_date DATE, amount FLOAT); INSERT INTO investments (id, company_id, investment_date, amount) VALUES (1, 6, '2022-01-10', 150000.0), (2, 7, '2022-03-25', 300000.0), (3, 8, '2021-12-30', 550000.0);
How many investments were made in the education sector in Q1 of 2022?
SELECT COUNT(*) FROM investments WHERE investment_date >= '2022-01-01' AND investment_date < '2022-04-01' AND company_id IN (SELECT id FROM companies WHERE sector = 'Education');
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (transaction_id INT, customer_id INT, transaction_amount DECIMAL, transaction_date DATE); INSERT INTO transactions (transaction_id, customer_id, transaction_amount, transaction_date) VALUES (1, 1, 50.00, '2022-01-01'), (2, 2, 1500.00, '2022-02-15'); CREATE TABLE customers (customer_id INT, nam...
What is the total transaction amount for each customer in the past year?
SELECT c.name, SUM(t.transaction_amount) FROM customers c JOIN transactions t ON c.customer_id = t.customer_id WHERE t.transaction_date >= DATEADD(year, -1, GETDATE()) GROUP BY c.name;
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, Age INT, Gender VARCHAR(10), TotalHoursPlayed INT); CREATE TABLE Events (EventID INT, EventName VARCHAR(20), Game VARCHAR(10)); INSERT INTO Players (PlayerID, Age, Gender, TotalHoursPlayed) VALUES (1, 25, 'Female', 100); INSERT INTO Players (PlayerID, Age, Gender, TotalHoursPlayed) V...
What is the total number of hours played by female players in Esports events?
SELECT SUM(TotalHoursPlayed) FROM Players P INNER JOIN Events E ON P.TotalHoursPlayed > 0 AND P.Gender = 'Female' AND E.Game = 'Esports';
gretelai_synthetic_text_to_sql
CREATE TABLE Cultural_Events (event_id INT, event_name VARCHAR(255), country VARCHAR(255)); INSERT INTO Cultural_Events (event_id, event_name, country) VALUES (1, 'Art Exhibit', 'USA'), (2, 'Theater Performance', 'Canada'), (3, 'Music Concert', 'USA'), (4, 'Dance Festival', 'Mexico'), (5, 'Film Festival', 'Canada');
Find the top 2 countries with the highest number of cultural events and the respective number of events.
SELECT country, COUNT(event_id) AS num_events FROM Cultural_Events GROUP BY country ORDER BY num_events DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE crime_stats (id INT, year INT, month INT, type VARCHAR(255), PRIMARY KEY(id));
Delete all records for 'january' month from 'crime_stats' table
DELETE FROM crime_stats WHERE month = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE military_branch (id INT, name VARCHAR(255)); CREATE TABLE peacekeeping_missions (id INT, military_branch_id INT, troops INT, mission_date DATE);
What is the maximum number of troops deployed for peacekeeping missions by each military branch in the last 5 years?
SELECT m.name as branch, MAX(pm.troops) as max_troops_deployed FROM military_branch m JOIN peacekeeping_missions pm ON m.id = pm.military_branch_id AND pm.mission_date >= DATE_SUB(CURRENT_DATE, INTERVAL 5 YEAR) GROUP BY m.id;
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_rates (state VARCHAR(20), year INT, recycling_rate FLOAT); INSERT INTO recycling_rates (state, year, recycling_rate) VALUES ('Texas', 2022, 45.0);
What is the current recycling rate in the state of Texas?
SELECT recycling_rate FROM recycling_rates WHERE state = 'Texas' AND year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE Mining_Operations (id INT, operation_name VARCHAR(50), location VARCHAR(50), cost FLOAT, year INT); INSERT INTO Mining_Operations (id, operation_name, location, cost, year) VALUES (1, 'Operation A', 'USA', 100000.00, 2020), (2, 'Operation B', 'Canada', 120000.00, 2019), (3, 'Operation C', 'Mexico', 90000.0...
What is the total amount spent on mining operations in the year 2020?
SELECT SUM(cost) FROM Mining_Operations WHERE year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE game_design (game_id INT, game_name VARCHAR(50), genre VARCHAR(20), revenue FLOAT, vr_compatible BOOLEAN); INSERT INTO game_design (game_id, game_name, genre, revenue, vr_compatible) VALUES (1, 'Elite Dangerous', 'Space Sim', 50.0, true), (2, 'Witcher 3', 'RPG', 120.0, false), (3, 'Half-Life: Alyx', 'Actio...
List all games that are not designed for VR.
SELECT game_name FROM game_design WHERE vr_compatible = false;
gretelai_synthetic_text_to_sql