context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE cases (case_id INT, case_type VARCHAR(10), billing_amount DECIMAL(10,2)); INSERT INTO cases (case_id, case_type, billing_amount) VALUES (1, 'Civil', 500.00), (2, 'Criminal', 750.00), (3, 'Civil', 1000.00);
|
Show the average billing amount for cases with a 'Civil' case type.
|
SELECT AVG(billing_amount) FROM cases WHERE case_type = 'Civil';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Farm (id INT, farm_name TEXT, species TEXT, weight FLOAT, age INT); INSERT INTO Farm (id, farm_name, species, weight, age) VALUES (1, 'OceanPacific', 'Tilapia', 500.3, 2), (2, 'SeaBreeze', 'Salmon', 300.1, 1), (3, 'OceanPacific', 'Tilapia', 600.5, 3), (4, 'FarmX', 'Salmon', 700.2, 4), (5, 'SeaBreeze', 'Tilapia', 400, 2);
|
Find the total quantity of fish in the 'SeaBreeze' farm.
|
SELECT SUM(weight) FROM Farm WHERE farm_name = 'SeaBreeze';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE departments (department_id INT, department_name VARCHAR(50)); CREATE TABLE military_innovation (innovation_id INT, innovation_name VARCHAR(50), department_id INT); INSERT INTO departments VALUES (1, 'Research'), (2, 'Development'), (3, 'Procurement'); INSERT INTO military_innovation VALUES (1, 'Stealth Technology', 1), (2, 'Advanced Radar Systems', 1), (3, 'Electric Armored Vehicles', 2), (4, 'Automated Turrets', 2), (5, 'Conventional Rifles', 3), (6, 'Body Armor', 3);
|
What is the total number of military innovation projects for each department in the 'military_innovation' and 'departments' tables?
|
SELECT d.department_name, COUNT(mi.innovation_id) as total_projects FROM departments d JOIN military_innovation mi ON d.department_id = mi.department_id GROUP BY d.department_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE consumers (consumer_id INT, country VARCHAR(50), interest_1 VARCHAR(50), interest_2 VARCHAR(50), interest_3 VARCHAR(50)); INSERT INTO consumers (consumer_id, country, interest_1, interest_2, interest_3) VALUES (1, 'US', 'Circular Economy', 'Sustainability', 'Fair Labor'), (2, 'Canada', 'Sustainability', 'Ethical Fashion', ''), (3, 'Mexico', 'Fair Labor', '', '');
|
How many consumers in the US have shown interest in circular economy practices?
|
SELECT COUNT(*) FROM consumers WHERE country = 'US' AND interest_1 = 'Circular Economy';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE products (product_id INT, product_name VARCHAR(255), category VARCHAR(255), price DECIMAL(10,2), is_organic BOOLEAN); INSERT INTO products (product_id, product_name, category, price, is_organic) VALUES (1, 'Moisturizing Shampoo', 'Haircare', 14.99, true), (2, 'Strengthening Conditioner', 'Haircare', 12.99, false), (3, 'Volumizing Shampoo', 'Haircare', 15.99, true);
|
What is the average price of organic haircare products in Canada?
|
SELECT AVG(price) FROM products WHERE category = 'Haircare' AND is_organic = true AND country = 'Canada';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE recycling_rates (country VARCHAR(50), year INT, recycling_rate FLOAT);
|
Calculate the average recycling rate for 'Asia' in 2021 from the 'recycling_rates' table
|
SELECT AVG(recycling_rate) FROM recycling_rates WHERE year = 2021 AND country = 'Asia';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ServiceUnion (member_id INT, member_name TEXT, years_as_member INT); INSERT INTO ServiceUnion (member_id, member_name, years_as_member) VALUES (1, 'John Doe', 6); INSERT INTO ServiceUnion (member_id, member_name, years_as_member) VALUES (2, 'Jane Smith', 3);
|
What is the total number of members in the 'Service Union' who have been members for more than 5 years?
|
SELECT COUNT(*) FROM ServiceUnion WHERE years_as_member > 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE game_sessions (session_id INT, player_id INT, session_length INT); INSERT INTO game_sessions (session_id, player_id, session_length) VALUES (1, 1, 20), (2, 2, 45), (3, 3, 35);
|
Insert a new record into the "game_sessions" table with session_id 4, player_id 4, and session_length 60
|
INSERT INTO game_sessions (session_id, player_id, session_length) VALUES (4, 4, 60);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE event_years (event_year_id INT, year INT); INSERT INTO event_years VALUES (1, 2020);
|
What is the number of events organized by nonprofits focused on capacity building in the US by year?
|
SELECT e.year, COUNT(*) as num_events FROM nonprofit_events ne JOIN events e ON ne.event_id = e.event_id JOIN nonprofits n ON ne.nonprofit_id = n.nonprofit_id JOIN event_years ey ON e.year = ey.year WHERE n.sector = 'capacity building' GROUP BY e.year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donations (id INT, donor_continent VARCHAR(50), donation_amount DECIMAL(10,2)); INSERT INTO donations (id, donor_continent, donation_amount) VALUES (1, 'Asia', 50.00), (2, 'North America', 100.00);
|
What is the average donation amount by donors from Asia?
|
SELECT AVG(donation_amount) FROM donations WHERE donor_continent = 'Asia';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE indian_community_health_workers (id INT, name VARCHAR(50), age INT, region VARCHAR(50)); INSERT INTO indian_community_health_workers (id, name, age, region) VALUES (1, 'Rajesh Patel', 35, 'North');
|
What is the average age of community health workers by region in India?
|
SELECT region, AVG(age) as avg_age FROM indian_community_health_workers GROUP BY region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SatelliteDeployment(id INT, organization VARCHAR(255), satellite VARCHAR(255), cost FLOAT); INSERT INTO SatelliteDeployment(id, organization, satellite, cost) VALUES (1, 'ISRO', 'Satellite 1', 1200000), (2, 'NASA', 'Satellite 2', 1500000), (3, 'ISRO', 'Satellite 3', 1000000);
|
What is the minimum cost of satellites deployed by ISRO?
|
SELECT MIN(cost) FROM SatelliteDeployment WHERE organization = 'ISRO';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Tracks (track_id INT, track_name VARCHAR(50), genre VARCHAR(20), artist_id INT);
|
Delete all records related to the Hip Hop genre from the MusicArtists, MusicSales, and Tracks tables.
|
DELETE ma, ms, t FROM MusicArtists ma INNER JOIN MusicSales ms ON ma.artist_id = ms.artist_id INNER JOIN Tracks t ON ma.artist_id = t.artist_id WHERE ma.genre = 'Hip Hop';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE investments (id INT, region VARCHAR(255), date DATE, amount FLOAT); INSERT INTO investments (id, region, date, amount) VALUES (1, 'Latin America', '2021-03-15', 25000), (2, 'Europe', '2020-12-21', 30000), (3, 'Latin America', '2021-01-03', 15000);
|
What is the total investment amount made in the Latin America region in the last 6 months?
|
SELECT SUM(amount) FROM investments WHERE region = 'Latin America' AND date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE landfill_capacity (region VARCHAR(255), capacity_cubic_meter INT, date DATE); INSERT INTO landfill_capacity (region, capacity_cubic_meter, date) VALUES ('RegionA', 100000, '2022-01-01'), ('RegionB', 120000, '2022-01-01'), ('RegionC', 150000, '2022-01-01');
|
What is the total landfill capacity in cubic meters for each region as of January 1, 2022?
|
SELECT region, SUM(capacity_cubic_meter) FROM landfill_capacity WHERE date = '2022-01-01' GROUP BY region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE detections (id INT, threat_type VARCHAR(255), region VARCHAR(255), detection_date DATE); INSERT INTO detections (id, threat_type, region, detection_date) VALUES (1, 'Malware', 'APAC', '2022-01-01'), (2, 'Phishing', 'APAC', '2022-01-02'), (3, 'Ransomware', 'APAC', '2022-01-03');
|
Which threat types were most frequently detected in the APAC region in the past week?
|
SELECT threat_type, COUNT(*) AS detection_count FROM detections WHERE region = 'APAC' AND detection_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK) GROUP BY threat_type ORDER BY detection_count DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE event_attendance (event_id INT, attendee_age INT, program_id INT, event_date DATE); INSERT INTO event_attendance (event_id, attendee_age, program_id, event_date) VALUES (1, 34, 101, '2022-05-12'); INSERT INTO event_attendance (event_id, attendee_age, program_id, event_date) VALUES (2, 45, 102, '2022-06-20');
|
What was the average age of attendees for each event in 2022?
|
SELECT event_id, AVG(attendee_age) as avg_age FROM event_attendance WHERE YEAR(event_date) = 2022 GROUP BY event_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE crypto_transactions (transaction_id INT, digital_asset VARCHAR(20), transaction_amount DECIMAL(10,2), transaction_time DATETIME);
|
What is the maximum transaction amount for each digital asset in the 'crypto_transactions' table, ordered by the maximum transaction amount in descending order?
|
SELECT digital_asset, MAX(transaction_amount) as max_transaction_amount FROM crypto_transactions GROUP BY digital_asset ORDER BY max_transaction_amount DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CommunityProjects (ProjectID INT, ProjectName VARCHAR(50), Location VARCHAR(50), StartDate DATE, CompletionDate DATE); INSERT INTO CommunityProjects (ProjectID, ProjectName, Location, StartDate, CompletionDate) VALUES (1, 'Clean Water Project', 'Nigeria', '2016-01-01', '2017-12-31'), (2, 'Renewable Energy Initiative', 'Kenya', '2018-01-01', '2019-12-31');
|
What is the ratio of completed to total projects for community development initiatives in Africa in the last 5 years?
|
SELECT AVG(CASE WHEN StartDate >= DATEADD(YEAR, -5, CURRENT_DATE) THEN 1.0 * COUNT(CASE WHEN CompletionDate IS NOT NULL THEN 1 END) / COUNT(*) ELSE NULL END) FROM CommunityProjects WHERE Location IN ('Nigeria', 'Kenya');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE exhibition_attendees (id INT, event_date DATE, continent VARCHAR(255)); INSERT INTO exhibition_attendees (id, event_date, continent) VALUES (1, '2022-04-15', 'Africa'), (2, '2022-04-20', 'Asia'), (3, '2022-04-25', 'Africa');
|
How many visitors attended the exhibition on African art from each continent in the last month?
|
SELECT continent, COUNT(*) FROM exhibition_attendees WHERE event_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) AND CURRENT_DATE AND exhibition = 'African Art' GROUP BY continent;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE waste_generation (id INT, region VARCHAR(255), year INT, waste_quantity INT); INSERT INTO waste_generation (id, region, year, waste_quantity) VALUES (1, 'Asia', 2020, 5000), (2, 'Asia', 2019, 4500), (3, 'Europe', 2020, 6000);
|
What is the total waste generation in the Asian region for the year 2020?
|
SELECT SUM(waste_quantity) FROM waste_generation WHERE region = 'Asia' AND year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE transactions (transaction_id INT, customer_id INT, transaction_date DATE, transaction_amount DECIMAL(10,2)); INSERT INTO transactions (transaction_id, customer_id, transaction_date, transaction_amount) VALUES (1, 2, '2022-01-05', 350.00), (2, 1, '2022-01-10', 500.00), (3, 3, '2022-02-15', 700.00), (4, 4, '2022-01-15', 600.00), (5, 3, '2022-01-20', 800.00); CREATE TABLE customers (customer_id INT, name VARCHAR(100), region VARCHAR(50)); INSERT INTO customers (customer_id, name, region) VALUES (1, 'John Doe', 'Southeast'), (2, 'Jane Smith', 'Northeast'), (3, 'Alice Johnson', 'Midwest'), (4, 'Bob Brown', 'West');
|
What is the total transaction amount for each customer in the Southeast region in January 2022?
|
SELECT customers.name, SUM(transactions.transaction_amount) FROM transactions INNER JOIN customers ON transactions.customer_id = customers.customer_id WHERE customers.region = 'Southeast' AND transactions.transaction_date BETWEEN '2022-01-01' AND '2022-01-31' GROUP BY customers.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE peacekeeping_operations (id INT PRIMARY KEY, operation_name VARCHAR(100), budget DECIMAL(10, 2), start_date DATE, region VARCHAR(50)); INSERT INTO peacekeeping_operations (id, operation_name, budget, start_date, region) VALUES (1, 'Operation 1', 80000, '2019-01-01', 'Americas'), (2, 'Operation 2', 120000, '2018-05-15', 'Asia-Pacific'), (3, 'Operation 3', 90000, '2020-12-31', 'Americas');
|
What is the total budget for peacekeeping operations in the Americas in 2020?
|
SELECT SUM(budget) FROM peacekeeping_operations WHERE start_date LIKE '2020-%' AND region = 'Americas';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Exhibitions_History (id INT, exhibition_date DATE); INSERT INTO Exhibitions_History (id, exhibition_date) VALUES (1, '2022-02-01'), (2, '2022-03-15'), (3, '2022-04-01'), (4, '2022-05-10'), (5, '2022-06-15');
|
How many exhibitions were held in the museum for the last 6 months?
|
SELECT COUNT(*) FROM Exhibitions_History WHERE exhibition_date >= DATEADD(month, -6, CURRENT_DATE);
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA socialmedia;CREATE TABLE users (id INT, country VARCHAR(255), revenue DECIMAL(10,2));INSERT INTO users (id, country, revenue) VALUES (1, 'Middle East', 100.00), (2, 'Middle East', 150.00);
|
What was the average revenue per user in the Middle East in Q3 2022?
|
SELECT AVG(revenue) FROM socialmedia.users WHERE country = 'Middle East' AND EXTRACT(MONTH FROM timestamp) BETWEEN 7 AND 9;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE FlightSafetyRecords (id INT, incident_date DATE, severity VARCHAR(50), description VARCHAR(255)); INSERT INTO FlightSafetyRecords (id, incident_date, severity, description) VALUES (1, '2021-02-10', 'High', 'Engine failure during takeoff'); INSERT INTO FlightSafetyRecords (id, incident_date, severity, description) VALUES (2, '2022-03-15', 'Medium', 'Landing gear malfunction');
|
Display all flight safety records with a severity level of 'High'.
|
SELECT * FROM FlightSafetyRecords WHERE severity = 'High';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE station (station_id INT, name TEXT, line TEXT);CREATE TABLE trip (trip_id INT, start_station_id INT, end_station_id INT, revenue FLOAT);
|
What is the total revenue for each station in the 'subway' system?
|
SELECT s.name, SUM(t.revenue) FROM station s INNER JOIN trip t ON s.station_id = t.start_station_id GROUP BY s.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE chemical_safety_protocols (protocol_id INT PRIMARY KEY, chemical_name VARCHAR(255), safety_measure TEXT);
|
What are the safety measures for hydrochloric acid?
|
SELECT safety_measure FROM chemical_safety_protocols WHERE chemical_name = 'hydrochloric acid';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE users (user_id INT, age INT, gender VARCHAR(10)); INSERT INTO users (user_id, age, gender) VALUES (1, 35, 'Female'), (2, 25, 'Male'), (3, 45, 'Female'); CREATE TABLE vr_games (game_id INT, game_mode VARCHAR(20)); INSERT INTO vr_games (game_id, game_mode) VALUES (1, 'Adventure'), (2, 'Shooter'), (3, 'Strategy'), (4, 'Puzzle'); CREATE TABLE user_games (user_id INT, game_id INT, playtime INT); INSERT INTO user_games (user_id, game_id, playtime) VALUES (1, 1, 50), (1, 2, 20), (1, 3, 0), (2, 2, 100), (2, 3, 80), (3, 1, 60), (3, 4, 100);
|
What are the top 5 most popular game modes in VR games played by female players over the age of 30?
|
SELECT game_mode, SUM(playtime) AS total_playtime FROM user_games JOIN users ON user_games.user_id = users.user_id JOIN vr_games ON user_games.game_id = vr_games.game_id WHERE users.age > 30 AND users.gender = 'Female' GROUP BY game_mode ORDER BY total_playtime DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE books (id INT, title TEXT, genre TEXT);
|
Identify the unique genres in the books table, excluding the children genre.
|
SELECT DISTINCT genre FROM books WHERE genre != 'children';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE WaterConsumption (ID INT, City VARCHAR(20), Consumption FLOAT, Date DATE); INSERT INTO WaterConsumption (ID, City, Consumption, Date) VALUES (9, 'Miami', 150, '2020-09-01'), (10, 'Miami', 145, '2020-09-02'), (11, 'Miami', 160, '2020-09-03'), (12, 'Miami', 140, '2020-09-04');
|
What is the average daily water consumption in the city of Miami for the month of September 2020?
|
SELECT AVG(Consumption) FROM WaterConsumption WHERE City = 'Miami' AND Date >= '2020-09-01' AND Date <= '2020-09-30' GROUP BY Date
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Stores (StoreID INT, StoreName VARCHAR(50), Country VARCHAR(50)); INSERT INTO Stores VALUES (1, 'StoreA', 'USA'), (2, 'StoreB', 'USA'), (3, 'StoreC', 'Canada'); CREATE TABLE Transactions (TransactionID INT, StoreID INT, Quantity INT); INSERT INTO Transactions VALUES (1, 1, 50), (2, 1, 75), (3, 2, 30), (4, 3, 60);
|
What is the average quantity of garments sold by the top 10 stores, per transaction, for each country?
|
SELECT AVG(Quantity) AS Avg_Quantity, Country FROM (SELECT StoreName, Country, Quantity, ROW_NUMBER() OVER (PARTITION BY Country ORDER BY SUM(Quantity) DESC) AS StoreRank FROM Stores JOIN Transactions ON Stores.StoreID = Transactions.StoreID GROUP BY StoreName, Country) AS Subquery WHERE StoreRank <= 10 GROUP BY Country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE agricultural_innovation (region VARCHAR(50), project_type VARCHAR(50), project_start_date DATE);
|
Compare the number of agricultural innovation projects in Latin America and the Caribbean, showing the project type and the number of projects in each region.
|
SELECT 'Latin America' as region, project_type, COUNT(*) as project_count FROM agricultural_innovation WHERE region = 'Latin America' UNION ALL SELECT 'Caribbean' as region, project_type, COUNT(*) as project_count FROM agricultural_innovation WHERE region = 'Caribbean';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE equipment_maintenance (id INT, equipment_name VARCHAR(50), last_update TIMESTAMP);
|
Delete records in the equipment_maintenance table that have not been updated in the last 6 months
|
DELETE FROM equipment_maintenance WHERE last_update < NOW() - INTERVAL 6 MONTH;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE community_policing (cp_id INT, did INT, meetings_this_year INT); INSERT INTO community_policing (cp_id, did, meetings_this_year) VALUES (1, 1, 5), (2, 2, 3), (3, 3, 7);
|
Update the 'community_policing' table to reflect the current number of community meetings held this year
|
UPDATE community_policing SET meetings_this_year = meetings_this_year + 2 WHERE did = 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE JobApplications (ApplicationID INT, Year INT, Month VARCHAR(10)); INSERT INTO JobApplications (ApplicationID, Year, Month) VALUES (1, 2021, 'January'), (2, 2021, 'February'), (3, 2022, 'January');
|
What is the total number of job applications by month for the last year?
|
SELECT Year, SUM(MonthNum) as TotalApplications FROM (SELECT YEAR(STR_TO_DATE(Month, '%M')) AS Year, MONTH(STR_TO_DATE(Month, '%M')) AS MonthNum FROM JobApplications WHERE STR_TO_DATE(Month, '%M') >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR) GROUP BY Year, MonthNum) AS SubQuery GROUP BY Year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE LegalClinics (ID INT, ClinicID VARCHAR(20), District VARCHAR(20), Hours INT, Year INT); INSERT INTO LegalClinics (ID, ClinicID, District, Hours, Year) VALUES (1, 'LC2017', 'South Peak', 300, 2017), (2, 'LC2018', 'North Valley', 200, 2018), (3, 'LC2019', 'South Peak', 250, 2019);
|
List all the legal clinics in 'South Peak' justice district that have provided more than 250 hours of service in a year.
|
SELECT ClinicID FROM LegalClinics WHERE District = 'South Peak' AND Hours > 250;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE GameLevels (PlayerID INT, PlayerName TEXT, Country TEXT, Game TEXT, Level INT); INSERT INTO GameLevels (PlayerID, PlayerName, Country, Game, Level) VALUES (1, 'John Doe', 'USA', 'Game A', 10), (2, 'Jane Smith', 'Canada', 'Game A', 12), (3, 'Bob Johnson', 'USA', 'Game A', 8), (4, 'Alice Williams', 'Canada', 'Game A', 10), (5, 'Charlie Brown', 'Mexico', 'Game A', 9);
|
How many players have reached level 10 in a given game, broken down by country?
|
SELECT Country, COUNT(*) AS NumPlayers FROM GameLevels WHERE Game = 'Game A' AND Level = 10 GROUP BY Country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ingredient_sourcing (id INT, product_id INT, ingredient_id INT, supplier_id INT, country VARCHAR(50)); INSERT INTO ingredient_sourcing (id, product_id, ingredient_id, supplier_id, country) VALUES (1, 101, 1, 201, 'France'), (2, 101, 2, 202, 'Italy'), (3, 101, 3, 203, 'Spain'), (4, 102, 2, 204, 'Germany'), (5, 103, 1, 201, 'France');
|
Which suppliers are associated with ingredient 2?
|
SELECT DISTINCT supplier_id FROM ingredient_sourcing WHERE ingredient_id = 2;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Players (PlayerID INT, Age INT, Gender VARCHAR(10), Country VARCHAR(20)); INSERT INTO Players VALUES (1, 25, 'Male', 'USA'); INSERT INTO Players VALUES (2, 22, 'Female', 'Canada'); CREATE TABLE EsportsEvents (EventID INT, PlayerID INT, EventName VARCHAR(20), PrizeMoney INT); INSERT INTO EsportsEvents VALUES (1, 1, 'Dreamhack', 10000); CREATE TABLE VRGameSessions (SessionID INT, PlayerID INT, VRGameCount INT); INSERT INTO VRGameSessions VALUES (1, 1, 5);
|
List all players who have not participated in any esports events and the number of VR games they have not played.
|
SELECT Players.*, COALESCE(EsportsEvents.PlayerID, 0) AS EventParticipation, COALESCE(VRGameSessions.PlayerID, 0) AS VRGamePlayed FROM Players LEFT JOIN EsportsEvents ON Players.PlayerID = EsportsEvents.PlayerID LEFT JOIN VRGameSessions ON Players.PlayerID = VRGameSessions.PlayerID WHERE EsportsEvents.PlayerID IS NULL AND VRGameSessions.PlayerID IS NULL;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ObesityData (State VARCHAR(50), AgeGroup VARCHAR(20), Population INT, ObesePopulation INT); INSERT INTO ObesityData (State, AgeGroup, Population, ObesePopulation) VALUES ('California', 'Children', 6000000, 850000), ('Texas', 'Children', 5500000, 1000000);
|
What is the obesity rate among children in each state?
|
SELECT State, (SUM(ObesePopulation) / SUM(Population)) * 100 AS ObesityRate FROM ObesityData WHERE AgeGroup = 'Children' GROUP BY State;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE co2_reduction (state VARCHAR(20), sector VARCHAR(20), co2_reduction FLOAT); INSERT INTO co2_reduction (state, sector, co2_reduction) VALUES ('California', 'Transportation', 34.56), ('Texas', 'Transportation', 29.45), ('New York', 'Transportation', 25.13);
|
List the top 2 CO2 reducing states from the transportation sector?
|
SELECT state, SUM(co2_reduction) as total_reduction FROM co2_reduction WHERE sector = 'Transportation' GROUP BY state ORDER BY total_reduction DESC LIMIT 2;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE military_spending (country VARCHAR(50), region VARCHAR(50), spending NUMERIC(10,2)); INSERT INTO military_spending (country, region, spending) VALUES ('USA', 'North America', 7319340000), ('China', 'Asia', 252000000000), ('Germany', 'Europe', 4960600000), ('France', 'Europe', 4125000000), ('UK', 'Europe', 5043000000);
|
What is the average military spending by countries in the European region?
|
SELECT AVG(spending) FROM military_spending WHERE region = 'Europe';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CommunityEngagementEvents (id INT, location VARCHAR(20), year INT, events INT);
|
How many community engagement events were held in North America in 2021?
|
SELECT SUM(events) FROM CommunityEngagementEvents WHERE location LIKE 'North America%' AND year = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cybersecurity_incidents (region VARCHAR(255), date DATE, incident_id INT); INSERT INTO cybersecurity_incidents (region, date, incident_id) VALUES ('Northeast', '2021-01-01', 123), ('Midwest', '2021-01-02', 234), ('South', '2021-01-03', 345), ('West', '2021-01-04', 456), ('Northeast', '2021-02-01', 567), ('Midwest', '2021-02-02', 678), ('South', '2021-02-03', 789), ('West', '2021-02-04', 890);
|
What is the number of cybersecurity incidents reported by region per month in 2021?
|
SELECT region, DATE_TRUNC('month', date) as month, COUNT(incident_id) as num_incidents FROM cybersecurity_incidents WHERE date BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY region, month;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE patients (patient_id INT, age INT, gender TEXT, treatment TEXT, state TEXT); INSERT INTO patients (patient_id, age, gender, treatment, state) VALUES (1, 35, 'Female', 'CBT', 'New York'); INSERT INTO patients (patient_id, age, gender, treatment, state) VALUES (2, 45, 'Male', 'Medication Management', 'New York'); INSERT INTO patients (patient_id, age, gender, treatment, state) VALUES (3, 28, 'Female', 'CBT', 'New York'); INSERT INTO patients (patient_id, age, gender, treatment, state) VALUES (4, 50, 'Male', 'Medication Management', 'New York'); INSERT INTO patients (patient_id, age, gender, treatment, state) VALUES (5, 42, 'Non-binary', 'CBT', 'New York'); INSERT INTO patients (patient_id, age, gender, treatment, state) VALUES (6, 34, 'Male', 'Medication Management', 'New York');
|
How many patients have received both CBT and medication management in NY?
|
SELECT COUNT(DISTINCT patient_id) FROM patients WHERE state = 'New York' AND treatment IN ('CBT', 'Medication Management') GROUP BY patient_id HAVING COUNT(DISTINCT treatment) = 2;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE carbon_offset_programs (id INT, name TEXT, region TEXT); INSERT INTO carbon_offset_programs (id, name, region) VALUES (1, 'Tree Planting', 'North America'), (2, 'Wind Power', 'Europe'), (3, 'Solar Power', 'Asia');
|
Get carbon offset programs in a specific region
|
SELECT * FROM carbon_offset_programs WHERE region = 'North America';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hotel_sustainability (hotel_id integer, name text, location text, sustainable_practices text); CREATE TABLE tourist_attractions (attraction_id integer, name text, type text, location text, cultural_significance text);
|
Display the total number of hotels and tourist attractions in the "hotel_sustainability" and "tourist_attractions" tables
|
SELECT COUNT(*) FROM hotel_sustainability; SELECT COUNT(*) FROM tourist_attractions;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE budget_2022 (service TEXT, budget INTEGER); INSERT INTO budget_2022 (service, budget) VALUES ('Social Services', 1400000), ('Environment Protection', 1300000); CREATE TABLE budget_2023 (service TEXT, budget INTEGER); INSERT INTO budget_2023 (service, budget) VALUES ('Social Services', 1600000), ('Environment Protection', 1500000);
|
Find the difference in budget allocation between social services and environment protection from 2022 to 2023.
|
SELECT (COALESCE(SUM(budget_2023.budget), 0) - COALESCE(SUM(budget_2022.budget), 0)) FROM budget_2022 FULL OUTER JOIN budget_2023 ON budget_2022.service = budget_2023.service WHERE service IN ('Social Services', 'Environment Protection');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE teacher_professional_development (teacher_id INT, professional_development_score INT);
|
Show all teachers with a professional development score above 90
|
SELECT * FROM teacher_professional_development WHERE professional_development_score > 90;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE athletes (athlete_id INT, game_id INT);
|
List the names of athletes who participated in both football and basketball games.
|
SELECT athlete_id FROM athletes WHERE game_id IN (SELECT game_id FROM games WHERE game_type = 'Football') INTERSECT SELECT athlete_id FROM athletes WHERE game_id IN (SELECT game_id FROM games WHERE game_type = 'Basketball');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Chemical_Waste (chemical_id INT, chemical_name VARCHAR(50), waste_amount DECIMAL(5,2));
|
Find the total waste produced by each chemical in the Chemical_Waste table
|
SELECT chemical_name, SUM(waste_amount) as total_waste FROM Chemical_Waste GROUP BY chemical_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE production (element VARCHAR(10), year INT, month INT, quantity INT); INSERT INTO production (element, year, month, quantity) VALUES ('Europium', 2015, 1, 70), ('Europium', 2015, 2, 75), ('Europium', 2016, 1, 80), ('Europium', 2016, 2, 85), ('Gadolinium', 2015, 1, 90), ('Gadolinium', 2015, 2, 95), ('Gadolinium', 2016, 1, 100), ('Gadolinium', 2016, 2, 105);
|
Identify the total annual production of Europium and Gadolinium, excluding data from 2016
|
SELECT SUM(quantity) FROM production WHERE element IN ('Europium', 'Gadolinium') AND year <> 2016 GROUP BY element;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Attorneys (AttorneyID INT, Name VARCHAR(50)); INSERT INTO Attorneys (AttorneyID, Name) VALUES (1, 'Smith, John'), (2, 'Garcia, Maria'), (3, 'Li, Wei'); CREATE TABLE Cases (CaseID INT, AttorneyID INT, BillingAmount DECIMAL(10, 2)); INSERT INTO Cases (CaseID, AttorneyID, BillingAmount) VALUES (1, 1, 5000.00), (2, 2, 3500.00), (3, 3, 4000.00), (4, 3, 6000.00);
|
What is the total billing amount for cases handled by the attorney with the ID 3?
|
SELECT SUM(BillingAmount) FROM Cases WHERE AttorneyID = 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE DefenseContracts (id INT, company VARCHAR(50), country VARCHAR(50), award_date DATE); INSERT INTO DefenseContracts (id, company, country, award_date) VALUES (1, 'Lockheed Martin', 'USA', '2019-05-15'), (2, 'Raytheon', 'USA', '2020-08-22'), (3, 'Boeing', 'USA', '2021-03-09');
|
How many defense contracts were awarded to companies in the United States in the last 3 years?
|
SELECT COUNT(*) FROM DefenseContracts WHERE country = 'USA' AND award_date >= DATE_SUB(CURDATE(), INTERVAL 3 YEAR);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE properties (id INT, city VARCHAR(20), listing_price FLOAT, co_owned BOOLEAN); INSERT INTO properties (id, city, listing_price, co_owned) VALUES (1, 'Las Vegas', 150000, true), (2, 'Las Vegas', 200000, false), (3, 'Las Vegas', 250000, true);
|
What is the total number of co-owned properties in the city of Las Vegas with a listing price above the average listing price?
|
SELECT COUNT(*) FROM properties WHERE city = 'Las Vegas' AND co_owned = true AND listing_price > (SELECT AVG(listing_price) FROM properties WHERE city = 'Las Vegas');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE security_incidents (id INT, country VARCHAR(20), incident_type VARCHAR(20), timestamp TIMESTAMP); INSERT INTO security_incidents (id, country, incident_type, timestamp) VALUES (1, 'USA', 'Malware', '2022-01-01 10:00:00'), (2, 'Canada', 'Phishing', '2022-01-02 11:00:00');
|
What is the total number of security incidents recorded per country?
|
SELECT country, COUNT(*) as total_incidents FROM security_incidents GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE machinery (id INT PRIMARY KEY, manufacturer VARCHAR(255), model VARCHAR(255), year INT);
|
Delete all records from the 'machinery' table where the 'manufacturer' is 'Heavy Mach'
|
DELETE FROM machinery WHERE manufacturer = 'Heavy Mach';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE GarmentCategories (CategoryID INT, CategoryName VARCHAR(50));CREATE TABLE SustainabilityRatings (GarmentID INT, CategoryID INT, SustainabilityRating INT);
|
What is the average sustainability rating for each garment category?
|
SELECT GC.CategoryName, AVG(SR.SustainabilityRating) AS AverageRating FROM GarmentCategories GC JOIN SustainabilityRatings SR ON GC.CategoryID = SR.CategoryID GROUP BY GC.CategoryName;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE recycling_rates (location VARCHAR(50), material VARCHAR(50), rate DECIMAL(5,2)); INSERT INTO recycling_rates (location, material, rate) VALUES ('Nairobi', 'Plastic', 0.65);
|
What is the average plastic recycling rate by location?
|
SELECT location, AVG(rate) as avg_plastic_recycling_rate FROM recycling_rates WHERE material = 'Plastic' GROUP BY location;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE navy_spending_trend (year INT, spending NUMERIC(10,2)); INSERT INTO navy_spending_trend (year, spending) VALUES (2018, 3000000000), (2019, 3200000000), (2020, 3400000000), (2021, 3600000000), (2022, 3800000000), (2023, 4000000000);
|
What is the defense spending trend for the Navy from 2018 to 2023?
|
SELECT year, spending FROM navy_spending_trend;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE products (product_id INT, category VARCHAR(20), quantity INT); INSERT INTO products (product_id, category, quantity) VALUES (1, 'electronics', 100), (2, 'electronics', 200), (3, 'electronics', 300);
|
List all product_ids and quantities for products in the 'electronics' category
|
SELECT product_id, quantity FROM products WHERE category = 'electronics';
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA AI_Research;CREATE TABLE Safety_Papers (paper_id INT, publication_year INT, citations INT); INSERT INTO AI_Research.Safety_Papers (paper_id, publication_year, citations) VALUES (1, 2016, 20), (2, 2018, 30), (3, 2017, 15);
|
Display the AI safety research papers with the lowest number of citations in the 'AI_Research' schema.
|
SELECT paper_id, citations FROM AI_Research.Safety_Papers ORDER BY citations LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE products (product_id INT, brand_id INT, sustainability_score FLOAT); INSERT INTO products (product_id, brand_id, sustainability_score) VALUES (1, 1, 80), (2, 1, 85), (3, 2, 70), (4, 2, 75); CREATE TABLE brands (brand_id INT, name VARCHAR(255)); INSERT INTO brands (brand_id, name) VALUES (1, 'BrandA'), (2, 'BrandB');
|
What is the average sustainability score for cosmetic products, partitioned by brand and ordered by average score in descending order?
|
SELECT brands.name, AVG(products.sustainability_score) as avg_score FROM products JOIN brands ON products.brand_id = brands.brand_id GROUP BY brands.name ORDER BY avg_score DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Suppliers (sid INT, name TEXT, location TEXT);CREATE TABLE Dishes (did INT, name TEXT, calorie_content INT);CREATE TABLE Ingredients (iid INT, dish_id INT, supplier_id INT);INSERT INTO Suppliers VALUES (1, 'SupplierA', 'West'), (2, 'SupplierB', 'East'), (3, 'SupplierC', 'West');INSERT INTO Dishes VALUES (1, 'DishA', 500), (2, 'DishB', 1500), (3, 'DishC', 800);INSERT INTO Ingredients VALUES (1, 1, 1), (2, 2, 1), (3, 2, 2), (4, 3, 3);
|
What is the total calorie content of dishes that contain ingredients from a supplier in the West?
|
SELECT SUM(Dishes.calorie_content) FROM Dishes INNER JOIN Ingredients ON Dishes.did = Ingredients.dish_id INNER JOIN Suppliers ON Ingredients.supplier_id = Suppliers.sid WHERE Suppliers.location = 'West';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Artists (artist_id INT, artist_name VARCHAR(255)); CREATE TABLE ArtSales (sale_id INT, artist_id INT, sale_price DECIMAL(10,2)); INSERT INTO Artists (artist_id, artist_name) VALUES (1, 'Alice'), (2, 'Bob'), (3, 'Charlie'); INSERT INTO ArtSales (sale_id, artist_id, sale_price) VALUES (1, 1, 5000.00), (2, 2, 7000.00), (3, 1, 6000.00), (4, 3, 8000.00);
|
Who are the top 3 artists by total revenue?
|
SELECT artist_name, SUM(sale_price) as Total_Revenue FROM Artists JOIN ArtSales ON Artists.artist_id = ArtSales.artist_id GROUP BY 1 ORDER BY Total_Revenue DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE movie_sales (id INT, movie_name VARCHAR(50), revenue FLOAT, release_date DATE); CREATE TABLE show_sales (id INT, show_name VARCHAR(50), revenue FLOAT, air_date DATE);
|
Calculate the total revenue for all movies and TV shows released in 2020.
|
SELECT SUM(revenue) FROM movie_sales WHERE YEAR(release_date) = 2020 UNION SELECT SUM(revenue) FROM show_sales WHERE YEAR(air_date) = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Companies (company_id INT, country TEXT); INSERT INTO Companies (company_id, country) VALUES (1, 'USA'), (2, 'China'), (3, 'Bangladesh'), (4, 'Italy'), (5, 'India'); CREATE TABLE SupplyChains (company_id INT, type TEXT); INSERT INTO SupplyChains (company_id, type) VALUES (1, 'circular'), (1, 'linear'), (2, 'linear'), (3, 'circular'), (4, 'circular'), (5, 'linear'); CREATE TABLE Apparel (company_id INT); INSERT INTO Apparel (company_id) VALUES (1), (2), (3), (4), (5);
|
Which countries have the highest percentage of circular supply chains in the apparel industry?
|
SELECT C.country, (COUNT(S.company_id) * 100.0 / (SELECT COUNT(*) FROM Companies C2 JOIN Apparel A2 ON C2.country = A2.country)) AS percentage FROM Companies C JOIN SupplyChains S ON C.company_id = S.company_id JOIN Apparel A ON C.company_id = A.company_id WHERE S.type = 'circular' GROUP BY C.country ORDER BY percentage DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE esg_factors (id INT, investment_id INT, environmental_factor DECIMAL(5,2), social_factor DECIMAL(5,2), governance_factor DECIMAL(5,2)); INSERT INTO esg_factors (id, investment_id, environmental_factor, social_factor, governance_factor) VALUES (1, 1, 0.90, 9.0, 0.95);
|
Find the number of social factors rated 9 or 10 and the corresponding projects in the healthcare sector.
|
SELECT i.project, e.social_factor FROM impact_investments i JOIN esg_factors e ON i.id = e.investment_id WHERE i.primary_sector = 'Healthcare' AND e.social_factor IN (9, 10);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Ingredients (ingredient_id INT, ingredient_name TEXT, dish_id INT, cost FLOAT); INSERT INTO Ingredients (ingredient_id, ingredient_name, dish_id, cost) VALUES (1, 'Sushi Rice', 8, 1.5);
|
What is the total cost of ingredients for the 'Veggie Sushi Roll' for the month of October 2022?
|
SELECT SUM(cost) FROM Ingredients WHERE dish_id IN (SELECT dish_id FROM Dishes WHERE dish_name = 'Veggie Sushi Roll') AND ingredient_name NOT IN ('Seaweed', 'Cucumber', 'Avocado');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mines (id INT, name TEXT, daily_production FLOAT, year INT, primary_key INT);
|
Find the mine that had the lowest daily production of Thulium in 2012.
|
SELECT name FROM mines WHERE element = 'Thulium' AND year = 2012 AND daily_production = (SELECT MIN(daily_production) FROM mines WHERE element = 'Thulium' AND year = 2012);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE movies (id INT, title VARCHAR(100), production_country VARCHAR(50)); INSERT INTO movies (id, title, production_country) VALUES (1, 'MovieA', 'France'); INSERT INTO movies (id, title, production_country) VALUES (2, 'MovieB', 'Germany');
|
How many movies have been produced in each country?
|
SELECT production_country, COUNT(*) FROM movies GROUP BY production_country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE REGIONAL_STORES (store_id INT, region VARCHAR(20), sales FLOAT); INSERT INTO REGIONAL_STORES VALUES (1, 'East', 5000), (2, 'East', 7000), (3, 'East', 8000), (4, 'West', 6000), (5, 'West', 9000), (6, 'West', 4000);
|
Find stores with sales below the overall average for stores in the 'East' and 'West' regions.
|
SELECT store_id FROM REGIONAL_STORES WHERE region IN ('East', 'West') AND sales < (SELECT AVG(sales) FROM REGIONAL_STORES);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE covid_cases (id INT, location TEXT, confirmed INT); INSERT INTO covid_cases (id, location, confirmed) VALUES (1, 'New York City', 500); INSERT INTO covid_cases (id, location, confirmed) VALUES (2, 'Los Angeles', 300);
|
How many cases of COVID-19 have been reported in New York City?
|
SELECT SUM(confirmed) FROM covid_cases WHERE location = 'New York City';
|
gretelai_synthetic_text_to_sql
|
cargo_tracking(tracking_id, voyage_id, cargo_type, cargo_weight)
|
Delete records from the cargo_tracking table where voyage_id = 'V006'
|
DELETE FROM cargo_tracking WHERE voyage_id = 'V006';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE equipment_maintenance (maintenance_id INT, maintenance_date DATE, maintenance_type TEXT, agency_id INT, equipment_model TEXT); INSERT INTO equipment_maintenance (maintenance_id, maintenance_date, maintenance_type, agency_id, equipment_model) VALUES (1, '2022-01-15', 'Preventive maintenance', 101, 'M1 Abrams'); INSERT INTO equipment_maintenance (maintenance_id, maintenance_date, maintenance_type, agency_id, equipment_model) VALUES (2, '2022-01-20', 'Corrective maintenance', 102, 'UH-60 Black Hawk');
|
How many military equipment maintenance requests were submitted by each agency in the last month?
|
SELECT agency_id, COUNT(*) as maintenance_requests FROM equipment_maintenance WHERE maintenance_date >= DATEADD(month, -1, GETDATE()) GROUP BY agency_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE names (id INT, innovation TEXT, community TEXT, adoption_rate FLOAT); INSERT INTO names (id, innovation, community, adoption_rate) VALUES (1, 'SRI', 'Rural Community A', 0.9), (2, 'Hybrid Seeds', 'Rural Community B', 0.7);
|
What are the names and adoption rates of agricultural innovations in rural communities in Bangladesh?
|
SELECT innovation, adoption_rate FROM names WHERE community LIKE 'Rural Community%' AND country = 'Bangladesh';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Southern_Ocean_Vents (vent_name TEXT, location TEXT); INSERT INTO Southern_Ocean_Vents (vent_name, location) VALUES ('E end vent field', 'Southwest Indian Ridge'), ('Lucky Strike', 'Mid-Atlantic Ridge');
|
What are the names and locations of hydrothermal vents in the Southern Ocean?
|
SELECT vent_name, location FROM Southern_Ocean_Vents;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE states (state_name TEXT, num_cities INT);CREATE TABLE charging_stations (station_id INT, station_name TEXT, city_name TEXT, state_name TEXT, num_charging_points INT);
|
Show the number of electric vehicle charging stations in each state in the US.
|
SELECT s.state_name, COUNT(cs.station_id) AS num_charging_stations FROM states s JOIN charging_stations cs ON s.state_name = cs.state_name GROUP BY s.state_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE payments (payment_id INT, payment_date DATE, fine_amount INT); INSERT INTO payments (payment_id, payment_date, fine_amount) VALUES (1, '2020-02-15', 200), (2, '2020-03-10', 500), (3, '2020-04-05', 800), (4, '2020-05-12', 1200);
|
What is the total fine amount collected per month in 2020?
|
SELECT EXTRACT(MONTH FROM payment_date) as month, SUM(fine_amount) as total_fine_amount FROM payments WHERE payment_date BETWEEN '2020-01-01' AND '2020-12-31' GROUP BY month;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE token_circulation (id INT PRIMARY KEY, name VARCHAR(255), circulating_supply BIGINT); INSERT INTO token_circulation (id, name, circulating_supply) VALUES (1, 'TokenC', 50000000), (2, 'TokenD', 25000000);
|
What's the maximum number of tokens in circulation for TokenC?
|
SELECT circulating_supply FROM token_circulation WHERE name = 'TokenC';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MilitaryPersonnel (branch TEXT, num_personnel INTEGER); INSERT INTO MilitaryPersonnel (branch, num_personnel) VALUES ('Army', 500000), ('Navy', 350000), ('AirForce', 300000), ('Marines', 200000);
|
What is the average number of military personnel in the Army and Navy?
|
SELECT AVG(num_personnel) FROM MilitaryPersonnel WHERE branch IN ('Army', 'Navy');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE gym_class_attendance (member_id INT, class_name VARCHAR(255));
|
Which members have attended yoga or pilates classes in LA?
|
SELECT DISTINCT m.member_id FROM member_profiles m INNER JOIN gym_class_attendance gca ON m.member_id = gca.member_id WHERE m.member_city = 'LA' AND gca.class_name IN ('yoga', 'pilates');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Neighborhood_Water_Usage (ID INT, Neighborhood VARCHAR(20), Usage FLOAT);
|
Find the top 5 water consuming neighborhoods in Seattle?
|
SELECT Neighborhood, Usage FROM (SELECT Neighborhood, Usage, ROW_NUMBER() OVER(ORDER BY Usage DESC) as rn FROM Neighborhood_Water_Usage WHERE City = 'Seattle') t WHERE rn <= 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Volunteer (VolunteerID int, VolunteerName varchar(50), Country varchar(50)); CREATE TABLE VolunteerProgram (ProgramID int, VolunteerID int, ProgramDate date);
|
List all volunteers who have participated in programs in the last month?
|
SELECT VolunteerName FROM Volunteer JOIN VolunteerProgram ON Volunteer.VolunteerID = VolunteerProgram.VolunteerID WHERE ProgramDate >= DATEADD(month, -1, GETDATE());
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Fares(fare INT, journey_date DATE, mode_of_transport VARCHAR(20)); INSERT INTO Fares(fare, journey_date, mode_of_transport) VALUES (3, '2022-01-01', 'Tram'), (4, '2022-01-02', 'Tram'), (5, '2022-02-01', 'Tram');
|
What is the maximum fare for 'Tram' mode of transport for journeys on the first day of each month?
|
SELECT MAX(fare) FROM Fares WHERE mode_of_transport = 'Tram' AND EXTRACT(DAY FROM journey_date) = 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE plant_employees (plant_id INT, num_employees INT); INSERT INTO plant_employees (plant_id, num_employees) VALUES (1, 30000), (2, 25000), (3, 15000), (4, 8000), (5, 12000), (6, 5000);
|
Update the aircraft_plants table to include the number of employees at each plant.
|
UPDATE aircraft_plants SET num_employees = (SELECT num_employees FROM plant_employees WHERE aircraft_plants.plant_id = plant_employees.plant_id);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE warehouse (id INT, location VARCHAR(255)); INSERT INTO warehouse (id, location) VALUES (1, 'Chicago'), (2, 'Houston'); CREATE TABLE packages (id INT, warehouse_id INT, weight FLOAT, country VARCHAR(255)); INSERT INTO packages (id, warehouse_id, weight, country) VALUES (1, 1, 50.3, 'Canada'), (2, 1, 30.1, 'Canada'), (3, 2, 70.0, 'Mexico'), (4, 2, 40.0, 'Canada');
|
What is the total weight of packages shipped to Canada, and how many were shipped?
|
SELECT country, SUM(weight) as total_weight, COUNT(*) as num_shipments FROM packages GROUP BY country HAVING country = 'Canada';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE treatments (treatment_id INT, year INT, quarter INT, condition VARCHAR(30)); INSERT INTO treatments (treatment_id, year, quarter, condition) VALUES (1, 2022, 1, 'Anxiety'), (2, 2022, 2, 'Depression'), (3, 2022, 3, 'Anxiety'), (4, 2022, 4, 'PTSD');
|
How many patients have received treatment in each quarter of 2022?
|
SELECT year, quarter, COUNT(*) as count FROM treatments GROUP BY year, quarter;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE otas (ota_id INT, ota_name TEXT, country TEXT); CREATE TABLE virtual_tours (tour_id INT, ota_id INT, views INT); INSERT INTO otas VALUES (1, 'OTA A', 'Japan'); INSERT INTO virtual_tours VALUES (1, 1), (2, 1);
|
What is the market share of OTAs offering virtual tours in the APAC region?
|
SELECT 100.0 * COUNT(DISTINCT otas.ota_id) / (SELECT COUNT(DISTINCT ota_id) FROM otas) AS market_share FROM virtual_tours INNER JOIN otas ON virtual_tours.ota_id = otas.ota_id WHERE otas.country LIKE 'APAC%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE students (id INT, name TEXT, publications INT); INSERT INTO students (id, name, publications) VALUES (1, 'John', 3), (2, 'Jane', 0), (3, 'Doe', 2);
|
Delete the records of students who have not published any articles
|
DELETE FROM students WHERE publications = 0;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE feedback (id INT, service VARCHAR(20), rating INT, comment TEXT); INSERT INTO feedback (id, service, rating, comment) VALUES (1, 'Parks and Recreation', 5, 'Great job!'), (2, 'Parks and Recreation', 3, 'Could improve'), (3, 'Waste Management', 4, 'Good but room for improvement'), (4, 'Libraries', 5, 'Awesome!'), (5, 'Libraries', 4, 'Very helpful'), (6, 'Transportation', 2, 'Needs work');
|
What is the average rating for the 'Transportation' service?
|
SELECT AVG(f.rating) FROM feedback f WHERE f.service = 'Transportation';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE pollution_impacts (species VARCHAR(255), ocean VARCHAR(255), pollution_incident BOOLEAN); INSERT INTO pollution_impacts (species, ocean, pollution_incident) VALUES ('Species3', 'Mediterranean Sea', TRUE);
|
Find species affected by pollution incidents in the Mediterranean Sea.
|
SELECT species FROM pollution_impacts WHERE ocean = 'Mediterranean Sea' AND pollution_incident = TRUE
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE r_and_d_expenditure (expenditure_id INT, drug_name VARCHAR(255), expenditure_date DATE, amount DECIMAL(10,2)); INSERT INTO r_and_d_expenditure (expenditure_id, drug_name, expenditure_date, amount) VALUES (1, 'DrugA', '2019-01-01', 10000), (2, 'DrugB', '2019-01-02', 12000), (3, 'DrugC', '2019-01-03', 15000), (4, 'DrugA', '2019-01-04', 11000), (5, 'DrugB', '2019-01-05', 13000), (6, 'DrugC', '2019-01-06', 16000);
|
Determine the average R&D expenditure per drug, ranked from the highest to the lowest, in the year 2019?
|
SELECT drug_name, AVG(amount) as avg_expenditure FROM r_and_d_expenditure WHERE YEAR(expenditure_date) = 2019 GROUP BY drug_name ORDER BY avg_expenditure DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE climate_mitigation (region VARCHAR(255), funding INT); INSERT INTO climate_mitigation VALUES ('Asia', 5000000);
|
What is the total funding allocated for climate communication initiatives in Asia?
|
SELECT SUM(funding) FROM climate_mitigation WHERE region = 'Asia' AND initiative_type = 'climate communication';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE union_memberships (union_id INT, worker_id INT, union_name VARCHAR(50), join_date DATE); INSERT INTO union_memberships (union_id, worker_id, union_name, join_date) VALUES (1, 1, 'United Steelworkers', '2021-01-10'), (1, 2, 'United Steelworkers', '2022-01-05'), (2, 3, 'Teamsters', '2021-08-10'), (2, 4, 'Teamsters', '2022-02-15'), (3, 5, 'Service Employees International Union', '2021-04-01'), (3, 6, 'Service Employees International Union', '2022-04-12'), (4, 7, 'United Auto Workers', '2021-09-15'), (4, 8, 'United Auto Workers', '2022-09-10'), (1, 9, 'United Steelworkers', '2022-09-20');
|
Display the total number of workers in each union in the 'union_memberships' table, excluding duplicate worker_id's
|
SELECT union_id, COUNT(DISTINCT worker_id) AS total_workers FROM union_memberships GROUP BY union_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Clothing_Items (item_id INT, is_ethically_sourced BOOLEAN, is_organic BOOLEAN, price DECIMAL(5,2)); INSERT INTO Clothing_Items (item_id, is_ethically_sourced, is_organic, price) VALUES (100, true, true, 50.00), (101, false, true, 40.00), (102, true, false, 60.00), (103, false, false, 30.00), (104, true, true, 55.00);
|
Calculate the average price of clothing items that are both ethically sourced and made from organic materials.
|
SELECT AVG(price) as avg_price FROM Clothing_Items WHERE is_ethically_sourced = true AND is_organic = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cultural_sites (site_id INT, city TEXT, virtual_tour BOOLEAN); INSERT INTO cultural_sites (site_id, city, virtual_tour) VALUES (1, 'Athens', true), (2, 'Athens', false);
|
Which cultural heritage sites in Athens have virtual tours available?
|
SELECT name FROM cultural_sites WHERE city = 'Athens' AND virtual_tour = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE research_stations (station_name VARCHAR(50), ocean VARCHAR(20)); INSERT INTO research_stations (station_name, ocean) VALUES ('Indian Ocean Observatory', 'Indian'), ('National Institute of Ocean Technology', 'Indian');
|
How many marine research stations are in the Indian Ocean?
|
SELECT COUNT(*) FROM research_stations WHERE ocean = 'Indian';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Preservation (PreservationID INT, ArtifactID INT, PreservationMethod VARCHAR(255), PreservationDate DATE); INSERT INTO Preservation (PreservationID, ArtifactID, PreservationMethod, PreservationDate) VALUES (1, 2, 'Freezing', '2020-02-01');
|
Calculate the average preservation year for artifacts with more than 2 preservation records.
|
SELECT ArtifactID, AVG(YEAR(PreservationDate)) as AvgPreservationYear FROM Preservation GROUP BY ArtifactID HAVING COUNT(*) > 2;
|
gretelai_synthetic_text_to_sql
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.