context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE strains (type VARCHAR(10), price DECIMAL(5,2), unit VARCHAR(10)); INSERT INTO strains (type, price, unit) VALUES ('indica', 225, 'ounce'), ('indica', 250, 'ounce'), ('hybrid', 180, 'ounce'); CREATE TABLE dispensaries (state VARCHAR(20), sales INT); INSERT INTO dispensaries (state, sales) VALUES ('Oregon', ...
What was the minimum price per ounce of indica strains sold in Oregon dispensaries in Q4 2021?
SELECT MIN(strains.price) FROM strains JOIN dispensaries ON TRUE WHERE strains.type = 'indica' AND strains.unit = 'ounce' AND dispensaries.state = 'Oregon' AND time_periods.quarter = 4;
gretelai_synthetic_text_to_sql
CREATE TABLE projects (project_id INT, district_id INT, budget FLOAT, project_type VARCHAR(50)); INSERT INTO projects (project_id, district_id, budget, project_type) VALUES (1, 10, 400000, 'Road Construction'), (2, 10, 500000, 'Irrigation System'), (3, 11, 350000, 'Electricity'), (4, 12, 200000, 'Water Supply');
What is the total budget for rural infrastructure projects in the Western region?
SELECT SUM(budget) FROM projects WHERE district_id IN (SELECT district_id FROM districts WHERE region = 'Western');
gretelai_synthetic_text_to_sql
CREATE TABLE Videos (video_id INT, title VARCHAR(255), category VARCHAR(50), duration INT); INSERT INTO Videos (video_id, title, category, duration) VALUES (1, 'Video1', 'Education', 60), (2, 'Video2', 'Entertainment', 90), (3, 'Video3', 'Education', 120);
What is the total duration of videos in the 'Education' category?
SELECT SUM(duration) FROM Videos WHERE category = 'Education';
gretelai_synthetic_text_to_sql
CREATE TABLE attorneys (attorney_id INT, name VARCHAR(50)); INSERT INTO attorneys VALUES (1, 'John Smith'); CREATE TABLE cases (case_id INT, attorney_id INT, billing_amount DECIMAL(10,2));
What is the total billing amount for cases handled by attorney 'John Smith'?
SELECT SUM(billing_amount) FROM cases INNER JOIN attorneys ON cases.attorney_id = attorneys.attorney_id WHERE attorneys.name = 'John Smith';
gretelai_synthetic_text_to_sql
CREATE TABLE LandfillSites (LSID INT, Location VARCHAR(50), Capacity FLOAT, OpenDate DATE, CloseDate DATE); INSERT INTO LandfillSites (LSID, Location, Capacity, OpenDate, CloseDate) VALUES (13, 'Beijing', 25000, '2010-01-01', '2027-12-31'); INSERT INTO LandfillSites (LSID, Location, Capacity, OpenDate, CloseDate) VALUE...
What is the remaining capacity of landfill sites in Beijing and Sao Paulo as of the end of 2022?
SELECT LS.Location, (LS.Capacity - SUM(WG.Quantity)) as RemainingCapacity FROM LandfillSites LS RIGHT JOIN WasteGeneration WG ON LS.Location = WG.Location AND WG.CollectionDate BETWEEN LS.OpenDate AND LS.CloseDate WHERE LS.Location IN ('Beijing', 'Sao Paulo') AND YEAR(WG.CollectionDate) = 2022 GROUP BY LS.Location;
gretelai_synthetic_text_to_sql
CREATE TABLE StudentDiversity (ethnicity VARCHAR(50), gender VARCHAR(10), total_students INT);
Create a table named 'StudentDiversity' that stores the number of graduate students by ethnicity and gender.
INSERT INTO StudentDiversity (ethnicity, gender, total_students) VALUES ('Asian', 'Female', 1200), ('Asian', 'Male', 1500), ('Black', 'Female', 800), ('Black', 'Male', 1000), ('Hispanic', 'Female', 900), ('Hispanic', 'Male', 1100), ('White', 'Female', 2000), ('White', 'Male', 2500);
gretelai_synthetic_text_to_sql
CREATE TABLE regulatory_frameworks (framework_id INT, jurisdiction VARCHAR(255), framework_name VARCHAR(255), effective_date DATE); INSERT INTO regulatory_frameworks (framework_id, jurisdiction, framework_name, effective_date) VALUES (1, 'United States', 'Securities Act of 1933', '1933-05-27'), (2, 'European Union', 'M...
Determine the jurisdictions with the most regulatory frameworks in the last 6 months?
SELECT jurisdiction, COUNT(*) OVER (PARTITION BY jurisdiction) AS jurisdiction_framework_count, RANK() OVER (ORDER BY COUNT(*) DESC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS jurisdiction_rank FROM regulatory_frameworks WHERE effective_date >= DATEADD(month, -6, CURRENT_DATE);
gretelai_synthetic_text_to_sql
CREATE TABLE habitat_preservation (habitat_preservation_id INT PRIMARY KEY, location_id INT, preservation_method VARCHAR(50), start_date DATE, end_date DATE, area_preserved INT, status VARCHAR(20));
Update the 'status' column to 'completed' for all records in the 'habitat_preservation' table where the 'end_date' is less than the current date
UPDATE habitat_preservation SET status = 'completed' WHERE end_date < CURDATE();
gretelai_synthetic_text_to_sql
CREATE TABLE SatelliteDeployment(name VARCHAR(20), company VARCHAR(20)); INSERT INTO SatelliteDeployment VALUES('Satellite A', 'NASA'),('Satellite B', 'SpaceX');
Which satellites were deployed by 'SpaceX'?
SELECT name FROM SatelliteDeployment WHERE company='SpaceX';
gretelai_synthetic_text_to_sql
CREATE TABLE cybersecurity_strategy (strategy_id INT PRIMARY KEY, strategy_name VARCHAR(30), strategy_description TEXT);
Delete the 'cybersecurity_strategy' table
DROP TABLE cybersecurity_strategy;
gretelai_synthetic_text_to_sql
CREATE TABLE HiringData (EmployeeID INT, HireDate DATE, JobCategory VARCHAR(20));
How many employees were hired in each month in the last year, broken down by job category?
SELECT DATEPART(MONTH, HireDate) as Month, JobCategory, COUNT(*) as NewHires FROM HiringData WHERE HireDate BETWEEN DATEADD(YEAR, -1, GETDATE()) AND GETDATE() GROUP BY DATEPART(MONTH, HireDate), JobCategory;
gretelai_synthetic_text_to_sql
CREATE TABLE Accommodations (student_id INT, accommodation_type VARCHAR(255)); INSERT INTO Accommodations (student_id, accommodation_type) VALUES (1, 'Extended Time'), (2, 'Quiet Space'), (3, 'Assistive Technology'), (4, 'Sign Language Interpreter');
What is the total number of students who received accommodations for each accommodation type?
SELECT accommodation_type, COUNT(*) as total_students FROM Accommodations GROUP BY accommodation_type;
gretelai_synthetic_text_to_sql
CREATE TABLE mine_stats (mine_name VARCHAR(255), mine_type VARCHAR(255), depth FLOAT); INSERT INTO mine_stats (mine_name, mine_type, depth) VALUES ('Uranium Vale', 'uranium', 3000.9), ('Radium Ridge', 'uranium', 3500.1), ('Nuclear Nexus', 'uranium', 2800.6);
What is the minimum depth of all uranium mines in the 'mine_stats' table?
SELECT MIN(depth) FROM mine_stats WHERE mine_type = 'uranium';
gretelai_synthetic_text_to_sql
CREATE TABLE Participation (participant_id INT, resident_id INT, initiative_id INT); CREATE TABLE CityData (resident_id INT, age INT, gender VARCHAR(10));
Get the count of unique residents in 'Participation' table?
SELECT COUNT(DISTINCT resident_id) FROM Participation;
gretelai_synthetic_text_to_sql
CREATE TABLE player_playtime (player_id INT, region VARCHAR(255), playtime FLOAT); INSERT INTO player_playtime (player_id, region, playtime) VALUES (1, 'North America', 50), (2, 'Europe', 40), (3, 'Asia', 60), (4, 'South America', 70);
What is the minimum playtime for players in each region?
SELECT region, MIN(playtime) as min_playtime FROM player_playtime GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE FishCaught (species VARCHAR(50), region VARCHAR(50), quantity INT); INSERT INTO FishCaught (species, region, quantity) VALUES ('Tuna', 'North Atlantic', 300), ('Salmon', 'North Atlantic', 250), ('Cod', 'North Atlantic', 400);
What is the average quantity of fish caught per species in the North Atlantic region?
SELECT species, AVG(quantity) as avg_quantity FROM FishCaught WHERE region = 'North Atlantic' GROUP BY species;
gretelai_synthetic_text_to_sql
CREATE TABLE defense_contracts (contract_id INT, agency VARCHAR(255), value DECIMAL(10,2));INSERT INTO defense_contracts (contract_id, agency, value) VALUES (1, 'DoD', 1000000.00), (2, 'DoD', 0.00), (3, 'VA', 500000.00);
Find the total count of defense contracts for each contracting agency, excluding contracts with a value of $0.
SELECT agency, COUNT(*) as total_contracts FROM defense_contracts WHERE value > 0 GROUP BY agency;
gretelai_synthetic_text_to_sql
CREATE VIEW Esports_Events (Location, Event_Name) AS SELECT 'Asia' AS Location, 'E-Sports Tournament 1' AS Event_Name UNION ALL SELECT 'Europe' AS Location, 'E-Sports Tournament 2' AS Event_Name;
What is the total number of esports events held in Asia and Europe?
SELECT COUNT(*) FROM Esports_Events WHERE Location IN ('Asia', 'Europe');
gretelai_synthetic_text_to_sql
CREATE TABLE Members (MemberID INT, GymMembership BOOLEAN); INSERT INTO Members (MemberID, GymMembership) VALUES (1, TRUE); INSERT INTO Members (MemberID, GymMembership) VALUES (2, FALSE); CREATE TABLE Workouts (WorkoutID INT, WorkoutDate DATE, WorkoutType VARCHAR(50), MemberID INT); INSERT INTO Workouts (WorkoutID, Wo...
How many members have a gym membership and performed a Pilates workout in the last month?
SELECT COUNT(*) FROM Members INNER JOIN Workouts ON Members.MemberID = Workouts.MemberID WHERE Members.GymMembership = TRUE AND Workouts.WorkoutDate >= '2022-02-01' AND Workouts.WorkoutType = 'Pilates';
gretelai_synthetic_text_to_sql
CREATE TABLE Sales (SaleID INT, ArtistID INT, Sales FLOAT, Genre VARCHAR(10)); INSERT INTO Sales (SaleID, ArtistID, Sales, Genre) VALUES (1, 1, 15000, 'Hip Hop'), (2, 1, 12000, 'Hip Hop'), (3, 2, 20000, 'Pop'), (4, 3, 18000, 'Jazz'), (5, 3, 20000, 'Jazz'), (6, 4, 10000, 'Jazz'), (7, 2, 10000, 'Pop');
What are the total sales for all artists in the 'Jazz' genre, excluding sales from the artist 'ArtistD'?
SELECT SUM(Sales) AS TotalSales FROM Sales WHERE Genre = 'Jazz' AND ArtistID != 4;
gretelai_synthetic_text_to_sql
CREATE TABLE visitors (id INT, age INT, gender TEXT, country TEXT);
Delete records of visitors who are under 18 years old from the visitors table
DELETE FROM visitors WHERE age < 18;
gretelai_synthetic_text_to_sql
CREATE TABLE exhibitions (id INT PRIMARY KEY, name VARCHAR(25), type VARCHAR(15));
Insert a new record into the 'exhibitions' table for a digital exhibition
INSERT INTO exhibitions (id, name, type) VALUES (1, 'Digital Art Experience', 'digital');
gretelai_synthetic_text_to_sql
CREATE TABLE PlayerWins (PlayerID INT, GameID INT, WinID INT); CREATE TABLE PlayerGames (PlayerID INT, GameID INT);
Show the number of wins for each player per game in the 'PlayerWins' and 'PlayerGames' tables
SELECT p.PlayerID, g.GameID, COUNT(pw.WinID) as WinsPerPlayerPerGame FROM PlayerWins pw INNER JOIN PlayerGames pg ON pw.PlayerID = pg.PlayerID AND pw.GameID = pg.GameID INNER JOIN (SELECT GameID, COUNT(*) as TotalGames FROM PlayerGames GROUP BY GameID) g ON pw.GameID = g.GameID GROUP BY p.PlayerID, g.GameID;
gretelai_synthetic_text_to_sql
CREATE TABLE Workers (ID INT, Industry VARCHAR(20), Ethical_Training BOOLEAN); INSERT INTO Workers (ID, Industry, Ethical_Training) VALUES (1, 'Textile', FALSE); INSERT INTO Workers (ID, Industry, Ethical_Training) VALUES (2, 'Textile', TRUE); INSERT INTO Workers (ID, Industry, Ethical_Training) VALUES (3, 'Textile', F...
Delete all records of workers in the 'Textile' industry who have not received ethical manufacturing training.
DELETE FROM Workers WHERE Industry = 'Textile' AND Ethical_Training = FALSE;
gretelai_synthetic_text_to_sql
CREATE TABLE production (country VARCHAR(255), year INT, amount INT); INSERT INTO production (country, year, amount) VALUES ('China', 2019, 120000), ('China', 2020, 140000), ('USA', 2020, 38000), ('Australia', 2020, 20000), ('India', 2020, 5000);
Update the production amount for 'China' in 2019 to 125000.
UPDATE production SET amount = 125000 WHERE country = 'China' AND year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE facility (facility_id INT, facility_name VARCHAR(255)); INSERT INTO facility (facility_id, facility_name) VALUES (1, 'Facility A'), (2, 'Facility B'), (3, 'Facility C'); CREATE TABLE product (product_id INT, product_name VARCHAR(255), facility_id INT, quantity_manufactured INT);
What is the total quantity of chemical products manufactured by each facility, sorted by the highest total quantity?
SELECT facility_id, facility_name, SUM(quantity_manufactured) AS total_quantity FROM product JOIN facility ON product.facility_id = facility.facility_id GROUP BY facility_id, facility_name ORDER BY total_quantity DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_rates (country VARCHAR(50), region VARCHAR(50), recycling_rate FLOAT, year INT); INSERT INTO recycling_rates (country, region, recycling_rate, year) VALUES ('Brazil', 'Latin America and the Caribbean', 0.2, 2021), ('Mexico', 'Latin America and the Caribbean', 0.3, 2021), ('Argentina', 'Latin Amer...
What is the recycling rate for Latin America and the Caribbean in 2021?'
SELECT AVG(recycling_rate) FROM recycling_rates WHERE region = 'Latin America and the Caribbean' AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE restorative_justice_ca (case_id INT, state VARCHAR(20)); INSERT INTO restorative_justice_ca VALUES (1, 'California'), (2, 'California'), (3, 'California'); CREATE TABLE restorative_justice_ny (case_id INT, state VARCHAR(20)); INSERT INTO restorative_justice_ny VALUES (4, 'New York'), (5, 'New York');
What is the total number of cases handled by restorative justice programs in California and New York?
SELECT COUNT(*) FROM restorative_justice_ca UNION ALL SELECT COUNT(*) FROM restorative_justice_ny;
gretelai_synthetic_text_to_sql
CREATE TABLE artists (artist_id INT, artist_genre VARCHAR(50), artist_country VARCHAR(50)); INSERT INTO artists (artist_id, artist_genre, artist_country) VALUES (1, 'Pop', 'United States'), (2, 'Rock', 'Brazil'), (3, 'Reggaeton', 'Mexico'); CREATE TABLE streams (stream_id INT, artist_id INT); INSERT INTO streams (strea...
What is the total number of streams for Pop artists from the United States?
SELECT SUM(s.stream_id) FROM streams s INNER JOIN artists a ON s.artist_id = a.artist_id WHERE a.artist_genre = 'Pop' AND a.artist_country = 'United States';
gretelai_synthetic_text_to_sql
CREATE TABLE Products (product_id INT, product_category VARCHAR(50), fair_trade_product BOOLEAN);
What is the percentage of fair trade products in each product category?
SELECT Products.product_category, AVG(CASE WHEN Products.fair_trade_product = TRUE THEN 100 ELSE 0 END) as fair_trade_percentage FROM Products GROUP BY Products.product_category;
gretelai_synthetic_text_to_sql
CREATE TABLE tour_visitors(tour_id INT, num_visitors INT); INSERT INTO tour_visitors (tour_id, num_visitors) VALUES (1, 2000), (2, 3000); CREATE VIEW virtual_tours_french AS SELECT vt.tour_id, vt.name, vt.country, tv.num_visitors FROM virtual_tours vt INNER JOIN tour_visitors tv ON vt.tour_id = tv.tour_id WHERE vt.coun...
What is the average number of visitors to virtual tours in France?
SELECT AVG(num_visitors) FROM virtual_tours_french;
gretelai_synthetic_text_to_sql
CREATE TABLE Vessel_Cargo (Vessel_ID INT, Cargo_Type VARCHAR(255)); INSERT INTO Vessel_Cargo (Vessel_ID, Cargo_Type) VALUES (1, 'Grain'), (2, 'Containers'), (3, 'Oil'), (4, 'Coal'), (5, 'Coal'), (6, 'Oil');
Find the vessels that have transported both coal and oil.
SELECT Vessel_ID FROM Vessel_Cargo WHERE Cargo_Type = 'Coal' INTERSECT SELECT Vessel_ID FROM Vessel_Cargo WHERE Cargo_Type = 'Oil';
gretelai_synthetic_text_to_sql
CREATE TABLE treatments (treatment_id INT, patient_id INT, healthcare_id INT, date DATE); CREATE TABLE patients (patient_id INT, disease TEXT, age INT, gender TEXT); CREATE TABLE healthcare_facilities (healthcare_id INT, name TEXT, type TEXT, rural BOOLEAN); INSERT INTO treatments (treatment_id, patient_id, healthcare_...
How many patients with respiratory diseases were treated in rural healthcare facilities, broken down by gender and age group?
SELECT CASE WHEN patients.age < 60 THEN 'Under 60' ELSE '60 and Over' END as age_group, patients.gender, COUNT(treatments.treatment_id) as count FROM treatments INNER JOIN patients ON treatments.patient_id = patients.patient_id INNER JOIN healthcare_facilities ON treatments.healthcare_id = healthcare_facilities.healthc...
gretelai_synthetic_text_to_sql
CREATE TABLE Personnel (personnel_id INT, personnel_count INT, year INT, region_id INT); INSERT INTO Personnel (personnel_id, personnel_count, year, region_id) VALUES (1, 1000, 2020, 6), (2, 1200, 2021, 6);
What is the average number of military personnel in the Australian region in 2021?
SELECT AVG(personnel_count) FROM Personnel WHERE year = 2021 AND region_id = (SELECT region_id FROM Regions WHERE region_name = 'Australian');
gretelai_synthetic_text_to_sql
CREATE TABLE sales_eco_north_america (sale_id INT, garment_type VARCHAR(50), sale_date DATE, total_sales DECIMAL(10, 2), region VARCHAR(50), is_eco_friendly BOOLEAN);
What is the average price of each eco-friendly garment type in the North America region in Q4 2022?
SELECT garment_type, AVG(total_sales) FROM sales_eco_north_america WHERE is_eco_friendly = true AND region = 'North America' AND sale_date BETWEEN '2022-10-01' AND '2022-12-31' GROUP BY garment_type;
gretelai_synthetic_text_to_sql
CREATE TABLE Countries (CountryID INT, Country VARCHAR(50)); INSERT INTO Countries (CountryID, Country) VALUES (1, 'USA'), (2, 'Canada'); CREATE TABLE Visits (VisitID INT, VisitorID INT, CountryID INT, InstallationID INT); INSERT INTO Visits (VisitID, VisitorID, CountryID, InstallationID) VALUES (1, 1, 1, 1), (2, 1, 1,...
What is the average number of installations visited per visitor, partitioned by country?
SELECT Country, AVG(InstallationID) OVER (PARTITION BY CountryID) AS AvgInstallationsPerVisitor FROM Visits V JOIN Countries C ON V.CountryID = C.CountryID;
gretelai_synthetic_text_to_sql
CREATE TABLE CompanyInnovations (company_id INT, innovation_date DATE); INSERT INTO CompanyInnovations (company_id, innovation_date) VALUES (1, '2020-01-01'), (1, '2019-01-01'), (2, '2018-01-01');
What is the earliest innovation date for each company?
SELECT company_id, MIN(innovation_date) as earliest_innovation_date FROM CompanyInnovations GROUP BY company_id;
gretelai_synthetic_text_to_sql
CREATE TABLE programs (program_id INT, program_name VARCHAR(50), start_date DATE); INSERT INTO programs (program_id, program_name, start_date) VALUES (1, 'Youth Skills', '2021-01-01'), (2, 'Women Empowerment', '2022-01-01'), (3, 'Clean Water', '2020-01-01');
Which community development programs in the 'programs' table received funding in '2022'?
SELECT program_name FROM programs WHERE YEAR(start_date) = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE fan (id INT, name VARCHAR(50), age INT, gender VARCHAR(10), city VARCHAR(50));
Insert a new record in the fan table with the following data: id=21, name='Mia Zhang', age=32, gender='Female', city='Beijing'.
INSERT INTO fan (id, name, age, gender, city) VALUES (21, 'Mia Zhang', 32, 'Female', 'Beijing');
gretelai_synthetic_text_to_sql
CREATE TABLE teams (team VARCHAR(50)); INSERT INTO teams (team) VALUES ('Team Alpha'), ('Team Bravo'), ('Team Tango'), ('Team Zulu');
Which teams in the 'teams' table have a name that starts with the letter 'T' and ends with the letter 'S'?
SELECT team FROM teams WHERE team LIKE 'T%S';
gretelai_synthetic_text_to_sql
CREATE TABLE menu (menu_id INT, menu_name VARCHAR(255), is_vegan BOOLEAN, cost_ingredients DECIMAL(5,2)); INSERT INTO menu (menu_id, menu_name, is_vegan, cost_ingredients) VALUES (1, 'Vegan Tacos', TRUE, 7.50), (2, 'Chickpea Curry', TRUE, 6.25), (3, 'Beef Burger', FALSE, 8.75), (4, 'Fish and Chips', FALSE, 9.25); CREAT...
Show the number of vegan menu items in the East region.
SELECT COUNT(*) as num_items FROM menu JOIN inventory ON menu.menu_id = inventory.menu_id WHERE is_vegan = TRUE AND region = 'East';
gretelai_synthetic_text_to_sql
CREATE TABLE AseanMilitaryExercises (id INT, exercise VARCHAR(255), country VARCHAR(255), exercise_date DATE);
What is the change in the number of military exercises conducted by the Association of Southeast Asian Nations from 2018 to 2019?
SELECT COUNT(*) - LAG(COUNT(*)) OVER (PARTITION BY country ORDER BY EXTRACT(YEAR FROM exercise_date)) as change FROM AseanMilitaryExercises WHERE country = 'Association of Southeast Asian Nations' AND EXTRACT(YEAR FROM exercise_date) IN (2018, 2019) GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE Garments (garment_id INT, garment_name VARCHAR(50), retail_price DECIMAL(5,2), brand VARCHAR(50)); INSERT INTO Garments (garment_id, garment_name, retail_price, brand) VALUES (1, 'Organic Cotton Blouse', 120.00, 'Eco-Friendly Fashions'), (2, 'Hemp Trousers', 180.00, 'Eco-Friendly Fashions'), (3, 'Bamboo T-...
Delete all garments from brand 'Eco-Friendly Fashions' that have a retail price above $200.
DELETE FROM Garments WHERE brand = 'Eco-Friendly Fashions' AND retail_price > 200;
gretelai_synthetic_text_to_sql
CREATE SCHEMA manufacturing; CREATE TABLE departments (dept_name VARCHAR(50), num_employees INT); INSERT INTO departments (dept_name, num_employees) VALUES ('Engineering', 150), ('Production', 250), ('Quality', 100);
What is the total number of employees per department in the 'manufacturing' schema, ordered by the department name?
SELECT dept_name, SUM(num_employees) OVER (PARTITION BY dept_name) AS total_employees FROM manufacturing.departments ORDER BY dept_name;
gretelai_synthetic_text_to_sql
CREATE TABLE GamePlaytime (GameID INT, GameName VARCHAR(50), Age INT, Playtime INT); INSERT INTO GamePlaytime (GameID, GameName, Age, Playtime) VALUES (1, 'Fortnite', 25, 500), (2, 'Minecraft', 30, 400), (3, 'Call of Duty', 22, 600);
What is the total playtime of players who play each game, grouped by their age?
SELECT Age, GameName, SUM(Playtime) as TotalPlaytime FROM GamePlaytime GROUP BY Age, GameName;
gretelai_synthetic_text_to_sql
CREATE TABLE investment (id INT, company_id INT, investment_round_size REAL, investment_round_date DATE); CREATE TABLE startup (id INT, name TEXT, founding_year INT, founder_race TEXT);
Find companies founded by people of color that have raised more than $10 million in investment
SELECT startup.name FROM startup JOIN investment ON startup.id = investment.company_id WHERE startup.founder_race IS NOT NULL GROUP BY startup.name HAVING SUM(investment.investment_round_size) > 10000000;
gretelai_synthetic_text_to_sql
CREATE TABLE smart_city_projects (id INT, country VARCHAR(20), launch_year INT); INSERT INTO smart_city_projects (id, country, launch_year) VALUES (1, 'Germany', 2015), (2, 'Germany', 2018), (3, 'Germany', 2020), (4, 'Germany', 2019);
How many smart city projects were launched in the country of Germany in the year 2018?
SELECT COUNT(*) FROM smart_city_projects WHERE country = 'Germany' AND launch_year = 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE workforce (id INT, name TEXT, role TEXT, location TEXT); INSERT INTO workforce (id, name, role, location) VALUES (1, 'Alice', 'apprentice', 'USA'), (2, 'Bob', 'engineer', 'USA'), (3, 'Charlie', 'apprentice', 'Canada');
What is the total number of 'apprentices' in 'USA'?
SELECT COUNT(*) FROM workforce WHERE role = 'apprentice' AND location = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE artists (id INT, name TEXT, genre TEXT); CREATE TABLE albums (id INT, title TEXT, artist_id INT, platform TEXT); CREATE TABLE sales (id INT, album_id INT, quantity INT, revenue DECIMAL); CREATE VIEW pop_mobile_albums AS SELECT a.id, a.title, ar.name FROM albums a JOIN artists ar ON a.artist_id = ar.id WHER...
Calculate the average revenue per album for all pop albums available on the 'mobile' platform.
SELECT avg_revenue FROM pop_mobile_sales;
gretelai_synthetic_text_to_sql
CREATE TABLE SpotifyStreaming (stream_id INT PRIMARY KEY, user_id INT, song_id INT, timestamp TIMESTAMP, FOREIGN KEY (user_id) REFERENCES Users(user_id), FOREIGN KEY (song_id) REFERENCES Songs(song_id)); CREATE TABLE Songs (song_id INT PRIMARY KEY, title VARCHAR(255), artist_id INT, genre VARCHAR(100), streams INT); CR...
Create a view to show top 3 most streamed songs on Spotify
CREATE VIEW Top3SpotifySongs AS SELECT song_id, title, artist_id, genre, SUM(streams) AS total_streams FROM (SELECT s.song_id, s.title, s.artist_id, s.genre, COALESCE(ss.streams, 0) AS streams FROM Songs s LEFT JOIN (SELECT song_id, COUNT(*) AS streams FROM SpotifyStreaming GROUP BY song_id) ss ON s.song_id = ss.song_i...
gretelai_synthetic_text_to_sql
CREATE TABLE trips (id INT, country VARCHAR(255), trip_type VARCHAR(255), trip_date DATE); INSERT INTO trips (id, country, trip_type, trip_date) VALUES (1, 'France', 'shared_bicycle', '2022-01-01'), (2, 'Germany', 'human-driven', '2022-01-02');
List the top 2 countries with the most shared bicycle trips, based on the number of trips?
SELECT country, COUNT(*) AS trips FROM trips WHERE trip_type = 'shared_bicycle' GROUP BY country ORDER BY trips DESC FETCH FIRST 2 ROWS ONLY;
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (artist_id INT, artist_name VARCHAR(255)); INSERT INTO Artists (artist_id, artist_name) VALUES (1, 'Artist1'), (2, 'Artist2'), (3, 'Artist3'); CREATE TABLE Genres (genre_id INT, genre_name VARCHAR(255)); INSERT INTO Genres (genre_id, genre_name) VALUES (1, 'Pop'), (2, 'Rock'); CREATE TABLE Sales (s...
What is the average revenue per artist by genre?
SELECT g.genre_name, a.artist_name, AVG(s.revenue) AS avg_revenue FROM Artists a JOIN Sales s ON a.artist_id = s.artist_id JOIN Genres g ON s.genre_id = g.genre_id GROUP BY g.genre_name, a.artist_name;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, DonorName TEXT, Country TEXT); CREATE TABLE Volunteers (VolunteerID INT, VolunteerName TEXT, Country TEXT);
What is the ratio of volunteers to donors in each country?
SELECT Donors.Country, COUNT(Donors.DonorID) / COUNT(Volunteers.VolunteerID) FROM Donors FULL OUTER JOIN Volunteers ON Donors.Country = Volunteers.Country GROUP BY Donors.Country;
gretelai_synthetic_text_to_sql
CREATE TABLE sales(id INT, country VARCHAR(50), equipment_type VARCHAR(30), sale_amount DECIMAL(10,2)); CREATE TABLE risk_assessments(id INT, country VARCHAR(50), risk_level VARCHAR(10));
What is the total number of military equipment sales to countries with high geopolitical risk?
SELECT SUM(sale_amount) FROM sales WHERE country IN (SELECT country FROM risk_assessments WHERE risk_level = 'High');
gretelai_synthetic_text_to_sql
CREATE TABLE machines (location VARCHAR(50), machine_type VARCHAR(50), quantity INT); INSERT INTO machines (location, machine_type, quantity) VALUES ('factory1', 'type1', 20), ('factory2', 'type2', 30), ('factory3', 'type3', 40), ('factory4', 'type4', 50);
What are the 'machine_type' and 'quantity' in 'factory4'?
SELECT machine_type, quantity FROM machines WHERE location = 'factory4';
gretelai_synthetic_text_to_sql
CREATE TABLE recipes (id INT, name TEXT, cuisine TEXT, vegan BOOLEAN, cook_time INT); INSERT INTO recipes (id, name, cuisine, vegan, cook_time) VALUES (1, 'Chana Masala', 'Indian', true, 45), (2, 'Pasta Primavera', 'Italian', false, 30), (3, 'Veggie Fried Rice', 'Chinese', true, 25);
What is the maximum cooking time for vegan dishes?
SELECT MAX(cook_time) FROM recipes WHERE vegan = true;
gretelai_synthetic_text_to_sql
CREATE TABLE artists (artist_id INT PRIMARY KEY, artist_name VARCHAR(100), genre VARCHAR(50), total_streams INT); INSERT INTO artists (artist_id, artist_name, genre, total_streams) VALUES (1, 'Eminem', 'Hip-Hop', 30000000); INSERT INTO artists (artist_id, artist_name, genre, total_streams) VALUES (2, 'Kendrick Lamar', ...
Insert data into 'artists' table for three new hip-hop artists
INSERT INTO artists (artist_id, artist_name, genre, total_streams) VALUES (4, 'Cardi B', 'Hip-Hop', 28000000); INSERT INTO artists (artist_id, artist_name, genre, total_streams) VALUES (5, 'J. Cole', 'Hip-Hop', 22000000); INSERT INTO artists (artist_id, artist_name, genre, total_streams) VALUES (6, 'Big Sean', 'Hip-Hop...
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, name VARCHAR(255)); CREATE TABLE posts (id INT, user_id INT, page_name VARCHAR(255), content TEXT); CREATE TABLE likes (id INT, user_id INT, post_id INT); CREATE TABLE hashtags (id INT, post_id INT, tag VARCHAR(255));
Find posts that are liked by users from the 'movies' page but not interacted with by users from the 'books' page, display the page name.
SELECT DISTINCT posts.page_name FROM posts JOIN likes ON posts.id = likes.post_id JOIN (SELECT user_id FROM users WHERE page_name = 'movies') AS movie_users ON likes.user_id = movie_users.user_id LEFT JOIN (SELECT user_id FROM users WHERE page_name = 'books') AS book_users ON likes.user_id = book_users.user_id WHERE bo...
gretelai_synthetic_text_to_sql
CREATE TABLE Satellites (ID INT, Name VARCHAR(50), LaunchDate DATE, Status VARCHAR(50)); INSERT INTO Satellites (ID, Name, LaunchDate, Status) VALUES (1, 'Sat1', '2018-01-01', 'Active'), (2, 'Sat2', '2020-05-15', 'Active'), (3, 'Sat3', '2019-09-01', 'Inactive'), (4, 'Sat4', '2016-03-01', 'Active'), (5, 'Sat5', '2017-12...
Update satellite status based on time in orbit
UPDATE Satellites SET Status = 'Inactive' WHERE ID IN (SELECT ID FROM (SELECT ID, DATEDIFF(year, LaunchDate, GETDATE()) as YearsInOrbit FROM Satellites) as Satellites WHERE YearsInOrbit > 5);
gretelai_synthetic_text_to_sql
CREATE TABLE projects (id INT, name TEXT, country TEXT); INSERT INTO projects VALUES (1, 'Community Development', 'Colombia'); CREATE TABLE support (id INT, project_id INT, sector TEXT, support_date DATE); INSERT INTO support VALUES (1, 1, 'education', '2020-01-01'); INSERT INTO support VALUES (2, 1, 'infrastructure', ...
List all the projects in Colombia that received support from both 'education' and 'infrastructure' sectors in 2020, along with the number of times they received support.
SELECT projects.name, COUNT(support.id) FROM projects INNER JOIN support ON projects.id = support.project_id WHERE projects.country = 'Colombia' AND support.sector IN ('education', 'infrastructure') AND support.support_date BETWEEN '2020-01-01' AND '2020-12-31' GROUP BY projects.id;
gretelai_synthetic_text_to_sql
CREATE TABLE maritime_laws (law_id INT, law_name VARCHAR(255), region VARCHAR(255), sulfur_limit DECIMAL(5,2), PRIMARY KEY(law_id)); INSERT INTO maritime_laws (law_id, law_name, region, sulfur_limit) VALUES (1, 'Caribbean Sea Emission Law', 'Caribbean Sea', 0.1);
What is the maximum legal limit for sulfur oxide emissions for ships in the Caribbean Sea?
SELECT sulfur_limit FROM maritime_laws WHERE region = 'Caribbean Sea';
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (id INT, name TEXT, type TEXT); INSERT INTO vessels (id, name, type) VALUES (1, 'Cargo Ship 1', 'Cargo'), (2, 'Tanker 1', 'Tanker');
What are the names of the vessels in the 'vessels' table?
SELECT name FROM vessels;
gretelai_synthetic_text_to_sql
CREATE TABLE claims (claim_id INT, policy_id INT, claim_amount DECIMAL(10,2), city VARCHAR(50), policy_type VARCHAR(50)); CREATE TABLE policies (policy_id INT, policy_holder_id INT, policy_type VARCHAR(50), issue_date DATE);
What is the total number of home insurance policies and their corresponding claim amounts for policyholders residing in Miami, Florida?
SELECT p.policy_type, COUNT(c.claim_id), SUM(c.claim_amount) FROM claims c JOIN policies p ON c.policy_id = p.policy_id WHERE city = 'Miami' AND policy_type = 'home' GROUP BY p.policy_type;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (species_id INT, species_name VARCHAR(50), population INT, habitat VARCHAR(50)); INSERT INTO marine_species (species_id, species_name, population, habitat) VALUES (2, 'Sea Turtle', 400000, 'Worldwide Tropical and Temperate Waters');
What are the names of marine species with a population less than 500000?
SELECT species_name FROM marine_species WHERE population < 500000;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, Department VARCHAR(20), Gender VARCHAR(10), Salary FLOAT); INSERT INTO Employees (EmployeeID, Department, Gender, Salary) VALUES (1, 'Marketing', 'Male', 70000), (2, 'Marketing', 'Female', 75000), (3, 'IT', 'Male', 80000), (4, 'IT', 'Female', 85000), (5, 'HR', 'Female', 65000), (...
What is the total salary cost for each department?
SELECT Department, SUM(Salary) FROM Employees GROUP BY Department;
gretelai_synthetic_text_to_sql
CREATE TABLE senegal_sites (id INT, name VARCHAR(50), type VARCHAR(30), events INT); INSERT INTO senegal_sites (id, name, type, events) VALUES (1, 'Goree Island', 'Island', 45), (2, 'Niokolo-Koba National Park', 'Park', 35), (3, 'Djoudj National Bird Sanctuary', 'Sanctuary', 50), (4, 'St. Louis', 'City', 60);
List all heritage sites in Senegal and their respective community engagement event counts in 2020.
SELECT * FROM senegal_sites;
gretelai_synthetic_text_to_sql
CREATE TABLE revenue (item_name TEXT, revenue INTEGER); INSERT INTO revenue (item_name, revenue) VALUES ('Burger', 500), ('Pizza', 700), ('Pasta', 600);
What is the total revenue for 'Pizza' and 'Pasta' items?
SELECT SUM(revenue) FROM revenue WHERE item_name IN ('Pizza', 'Pasta');
gretelai_synthetic_text_to_sql
CREATE TABLE Products (productID INT, productName VARCHAR(50), price DECIMAL(10,2), ethicallySourced BOOLEAN, country VARCHAR(50), productType VARCHAR(50)); CREATE TABLE Sales (saleID INT, productID INT, saleDate DATE);
What is the percentage of ethically sourced accessories sold in Canada in 2022?
SELECT 100.0 * SUM(CASE WHEN P.ethicallySourced = TRUE AND P.country = 'Canada' AND YEAR(S.saleDate) = 2022 THEN P.price ELSE 0 END) / SUM(P.price) AS ethically_sourced_percentage FROM Products P INNER JOIN Sales S ON P.productID = S.productID WHERE P.productType = 'accessories';
gretelai_synthetic_text_to_sql
CREATE TABLE UserInteractions (user_id INT, interaction_date DATE); INSERT INTO UserInteractions (user_id, interaction_date) VALUES (101, '2022-01-15'), (102, '2022-02-03'), (103, '2022-03-10'), (104, '2022-03-20'), (105, NULL);
Find users who have not interacted with the AI system in the past month.
SELECT user_id FROM UserInteractions WHERE interaction_date IS NULL OR interaction_date < DATE_SUB(CURDATE(), INTERVAL 1 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE movies (id INT, title TEXT, actor TEXT, director TEXT); INSERT INTO movies (id, title, actor, director) VALUES (1, 'Movie1', 'Actor1', 'Director1'), (2, 'Movie2', 'Actor2', 'Director2'), (3, 'Movie3', 'Actor1', 'Director1'), (4, 'Movie4', 'Actor3', 'Director3');
Who are the actors that have acted in a movie directed by 'Director1'?
SELECT DISTINCT actor FROM movies WHERE director = 'Director1';
gretelai_synthetic_text_to_sql
CREATE TABLE donors (id INT, name TEXT, country TEXT, amount_donated DECIMAL(10,2)); INSERT INTO donors
What's the average amount donated by donors from the US?
SELECT AVG(amount_donated) FROM donors WHERE country = 'US';
gretelai_synthetic_text_to_sql
CREATE TABLE countries (country_id INT PRIMARY KEY, country_name VARCHAR(255), area VARCHAR(255)); INSERT INTO countries (country_id, country_name, area) VALUES (1, 'United States', 'urban'), (2, 'Canada', 'urban'), (3, 'Mexico', 'rural'); CREATE TABLE life_expectancy (country_id INT, expectancy FLOAT); INSERT INTO lif...
What is the average life expectancy in urban areas?
SELECT c.country_name, le.expectancy FROM countries c JOIN life_expectancy le ON c.country_id = le.country_id WHERE c.area = 'urban';
gretelai_synthetic_text_to_sql
CREATE TABLE circular_economy_workforce (year INT, industry VARCHAR(50), workers NUMERIC); INSERT INTO circular_economy_workforce (year, industry, workers) VALUES (2019, 'Recycling', 10000), (2019, 'Remanufacturing', 8000), (2019, 'Refurbishing', 6000), (2020, 'Recycling', 12000), (2020, 'Remanufacturing', 9000), (2020...
What is the percentage change in the number of workers employed in the circular economy sector, by industry, between 2019 and 2020?
SELECT industry, (SUM(workers)*100.0/ (SELECT SUM(workers) FROM circular_economy_workforce WHERE year = 2019 AND industry = t.industry) - 100.0) as pct_change FROM circular_economy_workforce t WHERE year = 2020 GROUP BY industry;
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (DonationID INT, DonationCategory TEXT, DonationAmount DECIMAL(10,2)); INSERT INTO Donations (DonationID, DonationCategory, DonationAmount) VALUES (1, 'Education', 1000.00), (2, 'Health', 1500.00), (3, 'Environment', 2000.00), (4, 'Education', 500.00), (5, 'Health', 800.00), (6, 'Environment', 12...
List all categories with a total donation amount above the overall average, in alphabetical order.
SELECT DonationCategory, SUM(DonationAmount) AS TotalDonation FROM Donations GROUP BY DonationCategory HAVING SUM(DonationAmount) > (SELECT AVG(DonationAmount) FROM Donations) ORDER BY TotalDonation;
gretelai_synthetic_text_to_sql
CREATE TABLE readers (reader_id INT, last_login DATE); CREATE TABLE article_readers (article_id INT, reader_id INT, read_date DATE); INSERT INTO readers VALUES (1, '2022-01-01'); INSERT INTO article_readers VALUES (1, 1, '2022-01-02');
Get the details of readers who have not read any article in the last month from 'monthlyupdate' database.
SELECT readers.reader_id, readers.last_login FROM readers LEFT JOIN article_readers ON readers.reader_id = article_readers.reader_id WHERE article_readers.read_date IS NULL AND readers.last_login < DATE_SUB(CURDATE(), INTERVAL 1 MONTH)
gretelai_synthetic_text_to_sql
CREATE TABLE Policyholders (PolicyholderID INT, Age INT, Premium DECIMAL(10, 2), CarMake VARCHAR(20)); INSERT INTO Policyholders (PolicyholderID, Age, Premium, CarMake) VALUES (1, 35, 5000, 'Toyota'), (2, 45, 1500, 'Honda'), (3, 50, 3000, 'Tesla');
List all policies for policyholders who have a car make of 'Honda' and are older than 40.
SELECT * FROM Policyholders WHERE Age > 40 AND CarMake = 'Honda';
gretelai_synthetic_text_to_sql
CREATE TABLE City (Id INT PRIMARY KEY, Name VARCHAR(50), Population INT, Country VARCHAR(50)); INSERT INTO City (Id, Name, Population, Country) VALUES (1, 'Moscow', 12000000, 'Russia'); INSERT INTO City (Id, Name, Population, Country) VALUES (2, 'Saint Petersburg', 5000000, 'Russia'); INSERT INTO City (Id, Name, Popula...
How many cities are there in 'Russia', 'Japan', and 'Canada', and what is the total population of these cities?
SELECT Country, COUNT(*) as NumberOfCities, SUM(Population) as TotalPopulation FROM City WHERE Country IN ('Russia', 'Japan', 'Canada') GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE Museums (id INT, city VARCHAR(50), country VARCHAR(50), store_revenue DECIMAL(5,2)); CREATE VIEW Canada_Museums AS SELECT * FROM Museums WHERE country = 'Canada';
What is the total revenue for museum stores in Canada?
SELECT SUM(store_revenue) FROM Canada_Museums;
gretelai_synthetic_text_to_sql
CREATE TABLE organization (org_id INT, org_name TEXT); CREATE TABLE volunteer (vol_id INT, org_id INT, vol_country TEXT); INSERT INTO organization (org_id, org_name) VALUES (1, 'Greenpeace'), (2, 'Oxfam'), (3, 'Save the Children'); INSERT INTO volunteer (vol_id, org_id, vol_country) VALUES (1, 1, 'USA'), (2, 1, 'Canada...
Which organizations have volunteers from both the US and Canada?
SELECT org_name FROM organization WHERE org_id IN (SELECT org_id FROM volunteer WHERE vol_country IN ('USA', 'Canada') GROUP BY org_id HAVING COUNT(DISTINCT vol_country) = 2);
gretelai_synthetic_text_to_sql
CREATE TABLE military_bases (base_name VARCHAR(255), country VARCHAR(255), personnel INT); INSERT INTO military_bases (base_name, country, personnel) VALUES ('Osan Air Base', 'South Korea', 1800), ('Yokota Air Base', 'Japan', 3000), ('Camp Humphreys', 'South Korea', 4000);
How many military bases are there in Asia with less than 2000 personnel?
SELECT COUNT(*) FROM military_bases WHERE country LIKE 'Asia%' AND personnel < 2000;
gretelai_synthetic_text_to_sql
CREATE TABLE athlete_demographics (id INT, name VARCHAR(50), age INT, sport VARCHAR(50));
List all athletes that are part of the soccer team in the athlete_demographics table.
SELECT name FROM athlete_demographics WHERE team = 'soccer';
gretelai_synthetic_text_to_sql
CREATE TABLE Accidents (Id INT, VesselId INT, Year INT); INSERT INTO Accidents (Id, VesselId, Year) VALUES (1, 1, 2021), (2, 1, 2022), (3, 3, 2021), (4, 2, 2020); CREATE TABLE Cargo (Id INT, VesselId INT, Continent VARCHAR(50)); INSERT INTO Cargo (Id, VesselId, Continent) VALUES (1, 1, 'Asia'), (2, 1, 'Asia'), (3, 3, '...
What is the average number of accidents for vessels that have carried cargos from the Asian continent?
SELECT AVG(Accidents_Per_Vessel.Accidents_Count) FROM (SELECT VesselId, COUNT(*) AS Accidents_Count FROM Accidents GROUP BY VesselId) AS Accidents_Per_Vessel INNER JOIN (SELECT VesselId, COUNT(*) AS Cargo_Count FROM Cargo WHERE Continent = 'Asia' GROUP BY VesselId) AS Cargo_Per_Vessel ON Accidents_Per_Vessel.VesselId =...
gretelai_synthetic_text_to_sql
CREATE TABLE movies (movie_id INT, movie_title VARCHAR(100), release_year INT, country VARCHAR(50)); INSERT INTO movies (movie_id, movie_title, release_year, country) VALUES (1, 'Gladiator', 2000, 'USA');
How many movies were produced each year in the US since 2000?
SELECT release_year, COUNT(*) as num_movies FROM movies WHERE country = 'USA' AND release_year >= 2000 GROUP BY release_year;
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (VolunteerID int, VolunteerName varchar(50), Country varchar(50)); INSERT INTO Volunteers (VolunteerID, VolunteerName, Country) VALUES (1, 'Alice', 'USA'), (2, 'Bob', 'Canada'), (3, 'Charlie', 'USA'), (4, 'David', 'Mexico');
How many volunteers are registered in each country in the 'Volunteers' table?
SELECT Country, COUNT(*) as TotalVolunteers FROM Volunteers GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE movies (id INT, title TEXT, release_studio TEXT, release_year INT); INSERT INTO movies (id, title, release_studio, release_year) VALUES (1, 'Movie1', 'Studio1', 2005), (2, 'Movie2', 'Studio2', 2007), (3, 'Movie3', 'Studio1', 2010), (4, 'Movie4', 'Studio3', 2015), (5, 'Movie5', 'Studio1', 2018);
How many movies were released by each studio?
SELECT release_studio, COUNT(*) FROM movies GROUP BY release_studio;
gretelai_synthetic_text_to_sql
CREATE TABLE Reports (Year INT, Count INT); INSERT INTO Reports (Year, Count) VALUES (2021, 1200), (2022, 1500);
What is the total number of threat intelligence reports generated per year?
SELECT Year, SUM(Count) FROM Reports GROUP BY Year;
gretelai_synthetic_text_to_sql
CREATE TABLE articles (id INT, title TEXT, category TEXT); CREATE TABLE users (id INT, age INT, gender TEXT); CREATE TABLE user_likes (user_id INT, article_id INT); INSERT INTO articles (id, title, category) VALUES (1, 'Social Justice 101', 'social_justice'); INSERT INTO users (id, age, gender) VALUES (1, 28, 'f...
What is the average age of users who liked articles about social justice?
SELECT AVG(users.age) FROM users JOIN user_likes ON users.id = user_likes.user_id JOIN articles ON user_likes.article_id = articles.id WHERE articles.category = 'social_justice';
gretelai_synthetic_text_to_sql
CREATE TABLE Players_Games (player_id INT, game_id INT); CREATE TABLE Games (id INT, name VARCHAR(50), designer VARCHAR(50), design_region VARCHAR(20)); INSERT INTO Players_Games (player_id, game_id) VALUES (1, 1), (2, 2), (3, 3); INSERT INTO Games (id, name, designer, design_region) VALUES (1, 'Beat Saber', 'Jan Kozlo...
Get the names of all players who have played a game designed by a designer from 'Europe'
SELECT Players.name FROM Players_Games JOIN Players ON Players_Games.player_id = Players.id JOIN Games ON Players_Games.game_id = Games.id WHERE Games.design_region = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, donor_id INT, sector TEXT, amount INT, donation_date YEAR); INSERT INTO donations VALUES (1, 1, 'healthcare', 5000, 2020); INSERT INTO donations VALUES (2, 2, 'healthcare', 7000, 2020); CREATE TABLE donors (id INT, name TEXT, country TEXT); INSERT INTO donors VALUES (1, 'GlobalGiving', '...
What are the top 3 countries with the highest total donations to 'healthcare' sector in 2020?
SELECT donors.country, SUM(donations.amount) FROM donations INNER JOIN donors ON donations.donor_id = donors.id WHERE donations.sector = 'healthcare' AND donations.donation_date = 2020 GROUP BY donors.country ORDER BY SUM(donations.amount) DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE temperature_data (measurement_id INT, measurement_date DATE, avg_temp FLOAT, location VARCHAR(50));CREATE TABLE species_data (measurement_id INT, measurement_date DATE, observed_species VARCHAR(50), location VARCHAR(50));
What is the correlation between the average temperature and the number of species observed in the Arctic region for each year?
SELECT YEAR(t.measurement_date) AS year, AVG(t.avg_temp) AS avg_temp, COUNT(s.observed_species) AS total_species_observed FROM temperature_data t JOIN species_data s ON t.measurement_date = s.measurement_date WHERE t.location LIKE '%Arctic%' GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE species (id INT, name VARCHAR(255), conservation_status VARCHAR(255), habitat VARCHAR(255)); CREATE TABLE ocean_basin (id INT, name VARCHAR(255), species_count INT);
Count the number of marine species in each ocean basin, excluding species with a conservation status of 'Least Concern'
INSERT INTO ocean_basin (name, species_count) SELECT habitat, COUNT(*) FROM species WHERE conservation_status != 'Least Concern' GROUP BY habitat;
gretelai_synthetic_text_to_sql
CREATE TABLE wells (well_id INT, well_name VARCHAR(50), company VARCHAR(50), production FLOAT); INSERT INTO wells (well_id, well_name, company, production) VALUES (1, 'Well A', 'Shell', 10000), (2, 'Well B', 'Total', 15000), (3, 'Well C', 'Shell', 20000);
Which company has the highest average production per well?
SELECT AVG(production) AS avg_production, wells.company FROM wells GROUP BY wells.company ORDER BY avg_production DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE AutoShows(Id INT, Name VARCHAR(50), Year INT, Country VARCHAR(50), NumberOfExhibitors INT); INSERT INTO AutoShows(Id, Name, Year, Country, NumberOfExhibitors) VALUES (1, 'Geneva Motor Show', 2018, 'Switzerland', 180); INSERT INTO AutoShows(Id, Name, Year, Country, NumberOfExhibitors) VALUES (2, 'Paris Moto...
List all auto shows in Europe and their number of exhibitors since 2018?
SELECT Name, NumberOfExhibitors FROM AutoShows WHERE Year >= 2018 AND Country = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE ports (port_id INT, name VARCHAR(255)); INSERT INTO ports (port_id, name) VALUES (1, 'Atlantic Port'); CREATE TABLE cargo_operations (operation_id INT, port_id INT, cargo_weight INT, operation_date DATE, operation_day VARCHAR(10)); INSERT INTO cargo_operations (operation_id, port_id, cargo_weight, operatio...
What is the average cargo weight handled by Atlantic Port on Fridays?
SELECT AVG(cargo_weight) FROM cargo_operations WHERE port_id = (SELECT port_id FROM ports WHERE name = 'Atlantic Port') AND operation_day = 'Friday';
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (id INT PRIMARY KEY, species_name VARCHAR(255), conservation_status VARCHAR(255)); INSERT INTO marine_species (id, species_name, conservation_status) VALUES (1001, 'Oceanic Whitetip Shark', 'Vulnerable'), (1002, 'Green Sea Turtle', 'Threatened'), (1003, 'Leatherback Sea Turtle', 'Vulnerable'...
List all marine species in the 'marine_species' table, excluding those with a conservation status of 'Endangered'
SELECT species_name FROM marine_species WHERE conservation_status != 'Endangered';
gretelai_synthetic_text_to_sql
CREATE TABLE fan_demographics (fan_id INT, group_name VARCHAR(255), location VARCHAR(255), age INT, ticket_price DECIMAL(5,2));
Which fan demographic group in 'fan_demographics' table has the highest average ticket price?
SELECT group_name, AVG(ticket_price) FROM fan_demographics GROUP BY group_name ORDER BY AVG(ticket_price) DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE foundations (id INT, name TEXT, country TEXT); INSERT INTO foundations (id, name, country) VALUES (1, 'Gates Foundation', 'USA'), (2, 'Open Society Foundations', 'USA'); CREATE TABLE grants (id INT, foundation_id INT, amount INT, year INT); INSERT INTO grants (id, foundation_id, amount, year) VALUES (1, 1,...
What's the total amount of grants given by foundations located in the US, in the year 2020?
SELECT SUM(grants.amount) FROM grants INNER JOIN foundations ON grants.foundation_id = foundations.id WHERE foundations.country = 'USA' AND grants.year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE survivalrates (system VARCHAR(10), survival_rate FLOAT); INSERT INTO survivalrates (system, survival_rate) VALUES ('RAS', 95), ('Traditional', 90);
What is the survival rate of fish in recirculating aquaculture systems (RAS) compared to traditional open systems?
SELECT survival_rate FROM survivalrates WHERE system IN ('RAS', 'Traditional');
gretelai_synthetic_text_to_sql
CREATE TABLE tech_adoption (id INT, hotel_id INT, hotel_name TEXT, score INT); INSERT INTO tech_adoption (id, hotel_id, hotel_name, score) VALUES (1, 1, 'Hotel AD', 90), (2, 2, 'Hotel AE', 85), (3, 3, 'Hotel AF', 80), (4, 4, 'Hotel AG', 88), (5, 5, 'Hotel AH', 92), (6, 6, 'Hotel AI', 95), (7, 7, 'Hotel AJ', 97), (8, 8,...
What are the top 3 hotels in terms of hotel tech adoption metrics in the 'Asia-Pacific' region?
SELECT hotel_id, SUM(score) AS total_score FROM tech_adoption t JOIN hotels h ON t.hotel_id = h.id WHERE h.region = 'Asia-Pacific' GROUP BY hotel_id ORDER BY total_score DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE cosmetic_launches (id INT, product VARCHAR(50), launch_date DATE, cruelty_free BOOLEAN, country VARCHAR(50)); INSERT INTO cosmetic_launches (id, product, launch_date, cruelty_free, country) VALUES (1, 'Cruelty-free Lipstick', '2022-01-15', TRUE, 'Brazil'), (2, 'Non-cruelty-free Moisturizer', '2022-02-10', ...
Display the number of cruelty-free cosmetic product launches in Brazil per month.
SELECT EXTRACT(MONTH FROM launch_date) AS month, COUNT(*) FROM cosmetic_launches WHERE country = 'Brazil' AND cruelty_free = TRUE GROUP BY month;
gretelai_synthetic_text_to_sql