context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE neighborhoods (neighborhood_id INT, name VARCHAR(255), median_income FLOAT);
|
Find the top 3 neighborhoods with the highest median income?
|
SELECT neighborhood_id, name, median_income FROM (SELECT neighborhood_id, name, median_income, ROW_NUMBER() OVER (ORDER BY median_income DESC) as rn FROM neighborhoods) t WHERE rn <= 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE louvre_visitors (id INT, name VARCHAR(50), age INT); INSERT INTO louvre_visitors (id, name, age) VALUES (1, 'Alice Johnson', 15), (2, 'Bob Brown', 25), (3, 'Charlie Davis', 12);
|
What is the minimum age of tourists visiting the Louvre Museum?
|
SELECT MIN(age) FROM louvre_visitors;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE menus (menu_id INT, item VARCHAR(255), category VARCHAR(255)); INSERT INTO menus VALUES (1, 'Chicken Wings', 'Appetizers'); INSERT INTO menus VALUES (2, 'Beef Burger', 'Entrees'); INSERT INTO menus VALUES (3, 'Chocolate Cake', 'Desserts'); CREATE TABLE sales (sale_id INT, menu_id INT, quantity INT, region VARCHAR(255));
|
Which menu items are not selling well in a specific region?
|
SELECT m.item, s.quantity FROM menus m LEFT JOIN sales s ON m.menu_id = s.menu_id WHERE s.region = 'North';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE EmployeeTrainings (TrainingID int, EmployeeID int, TrainingRating int, EmployeeDisability varchar(10)); INSERT INTO EmployeeTrainings (TrainingID, EmployeeID, TrainingRating, EmployeeDisability) VALUES (1, 1, 8, 'Yes'), (2, 2, 9, 'No'), (3, 3, 7, 'Yes'), (4, 4, 6, 'No');
|
What is the average training program rating for employees with disabilities?
|
SELECT AVG(TrainingRating) FROM EmployeeTrainings WHERE EmployeeDisability = 'Yes';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE carbon_offsets (id INT, initiative_name VARCHAR(100), co2_offset FLOAT, country VARCHAR(50)); INSERT INTO carbon_offsets (id, initiative_name, co2_offset, country) VALUES (1, 'Green Transport Germany', 78.34, 'Germany'), (2, 'Renewable Energy Germany', 90.56, 'Germany'), (3, 'Energy Efficiency Germany', 85.43, 'Germany');
|
What is the average CO2 offset of carbon offset initiatives in Germany?
|
SELECT AVG(co2_offset) FROM carbon_offsets WHERE country = 'Germany';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Games (GameID INT, GameName VARCHAR(50), ReleaseYear INT, Genre VARCHAR(50), Price DECIMAL(5, 2)); INSERT INTO Games (GameID, GameName, ReleaseYear, Genre, Price) VALUES (1, 'GameA', 2020, 'Action', 60.00), (2, 'GameB', 2019, 'Adventure', 50.00), (3, 'GameC', 2018, 'RPG', 40.00);
|
What is the total revenue for games released in 2018 and 2019, and the number of games released in those years?
|
SELECT ReleaseYear, COUNT(GameID) AS NumberOfGames, SUM(Price) AS TotalRevenue FROM Games WHERE ReleaseYear IN (2018, 2019) GROUP BY ReleaseYear;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE employees (id INT, first_name VARCHAR(50), last_name VARCHAR(50), job_title VARCHAR(50), department VARCHAR(50), age INT, salary DECIMAL(10,2), PRIMARY KEY (id)); INSERT INTO employees (id, first_name, last_name, job_title, department, age, salary) VALUES (1, 'John', 'Doe', 'Engineer', 'Mining', 35, 80000.00), (2, 'Jane', 'Doe', 'Operator', 'Mining', 28, 60000.00), (3, 'Mike', 'Johnson', 'Manager', 'Environment', 45, 90000.00), (4, 'Sara', 'Smith', 'Technician', 'Environment', 30, 75000.00);
|
What is the maximum salary for employees in the 'employees' table, grouped by their department?
|
SELECT department, MAX(salary) FROM employees GROUP BY department;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE georgia_water_usage (id INT, building_type VARCHAR(20), water_consumption FLOAT, day VARCHAR(10)); INSERT INTO georgia_water_usage (id, building_type, water_consumption, day) VALUES (1, 'Public', 30000, 'Monday'), (2, 'Public', 35000, 'Tuesday');
|
What is the maximum daily water consumption for public buildings in Georgia?
|
SELECT MAX(water_consumption) FROM georgia_water_usage WHERE building_type = 'Public';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Astronauts (AstronautID INT, Name VARCHAR(50), Spacewalks INT); INSERT INTO Astronauts (AstronautID, Name, Spacewalks) VALUES (1, 'John Doe', 3), (2, 'Jane Smith', 1), (3, 'Mike Johnson', 0);
|
What are the names of all astronauts who have been on a spacewalk?
|
SELECT Name FROM Astronauts WHERE Spacewalks > 0;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MenuItems(menu_item_id INT, item_name VARCHAR(255), order_count INT, food_cost_percentage DECIMAL(5,2));
|
What is the average food cost percentage for menu items that have been ordered more than 50 times?
|
SELECT AVG(food_cost_percentage) FROM MenuItems WHERE order_count > 50;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sales(id INT, equipment_name VARCHAR(50), sale_date DATE, country VARCHAR(50), government_agency VARCHAR(50), sale_value INT, manufacturer_id INT); CREATE TABLE manufacturer(id INT, name VARCHAR(50)); INSERT INTO sales VALUES (1, 'Helicopter', '2017-01-01', 'India', 'Ministry of Defense', 5000000, 1); INSERT INTO manufacturer VALUES (1, 'Boeing');
|
What is the total value of military equipment sales to the Indian government from 2017 to 2020, grouped by manufacturer?
|
SELECT manufacturer.name, SUM(sales.sale_value) FROM sales INNER JOIN manufacturer ON sales.manufacturer_id = manufacturer.id WHERE sales.country = 'India' AND YEAR(sale_date) BETWEEN 2017 AND 2020 GROUP BY manufacturer.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE products (id INT, product_name TEXT, organic BOOLEAN, consumer_preference FLOAT); INSERT INTO products (id, product_name, organic, consumer_preference) VALUES (1, 'Lotion', true, 4.3), (2, 'Shampoo', false, 4.1), (3, 'Soap', true, 4.6);
|
What is the average consumer preference score for organic products?
|
SELECT AVG(consumer_preference) FROM products WHERE organic = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE feedback (service varchar(20), location varchar(20), date date); INSERT INTO feedback (service, location, date) VALUES ('Education', 'Urban', '2021-01-01'), ('Healthcare', 'Urban', '2021-02-01'), ('Education', 'Rural', '2020-12-01'), ('Healthcare', 'Rural', '2020-11-01');
|
What is the percentage of citizen feedback records received for rural areas compared to urban areas?
|
SELECT 100.0 * SUM(CASE WHEN location = 'Rural' THEN 1 ELSE 0 END) / COUNT(*) FROM feedback;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Athletes (AthleteID INT PRIMARY KEY, Name VARCHAR(100), Sport VARCHAR(50), TeamID INT, LastGameDate DATE); CREATE TABLE Games (GameID INT PRIMARY KEY, HomeTeamID INT, AwayTeamID INT, GameDate DATE, Game VARCHAR(50));
|
Delete the records of athletes who have not played in any games in the last 3 years?
|
DELETE FROM Athletes WHERE Athletes.LastGameDate < (YEAR(CURRENT_DATE) - 3) AND Athletes.AthleteID NOT IN (SELECT Games.HomeTeamID FROM Games) AND Athletes.AthleteID NOT IN (SELECT Games.AwayTeamID FROM Games);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE countries (id INT, name VARCHAR(20)); INSERT INTO countries (id, name) VALUES (1, 'USA'); INSERT INTO countries (id, name) VALUES (2, 'China'); CREATE TABLE gaming_companies (id INT, country_id INT, name VARCHAR(20)); INSERT INTO gaming_companies (id, country_id, name) VALUES (1, 1, 'Blizzard'); INSERT INTO gaming_companies (id, country_id, name) VALUES (2, 2, 'Tencent'); CREATE TABLE esports_tournaments (id INT, country_id INT, name VARCHAR(20)); INSERT INTO esports_tournaments (id, country_id, name) VALUES (1, 1, 'Dreamhack'); INSERT INTO esports_tournaments (id, country_id, name) VALUES (2, 2, 'ESL One');
|
Which esports tournaments were held in the same countries as gaming companies?
|
SELECT esports_tournaments.name FROM esports_tournaments INNER JOIN countries ON esports_tournaments.country_id = countries.id INNER JOIN gaming_companies ON countries.id = gaming_companies.country_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Users (user_id INTEGER, app_used TEXT); INSERT INTO Users (user_id, app_used) VALUES (1, 'App A'), (2, 'App B'), (3, 'App C'), (4, 'App C'), (5, 'App C');
|
How many unique users have interacted with Decentralized Application C?
|
SELECT COUNT(DISTINCT user_id) FROM Users WHERE app_used = 'App C';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE peacekeeping_ops (id INT, country VARCHAR(50), region VARCHAR(50)); INSERT INTO peacekeeping_ops (id, country, region) VALUES (1, 'Nigeria', ''), (2, 'Egypt', 'Africa'), (3, 'Iraq', 'Middle East');
|
Update the "peacekeeping_ops" table, setting the "region" column to 'Africa' for records where the "country" column is 'Nigeria'
|
UPDATE peacekeeping_ops SET region = 'Africa' WHERE country = 'Nigeria';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE digital_assets (asset_id INT, asset_name VARCHAR(50), asset_type VARCHAR(50), total_supply DECIMAL(20,2), circulating_supply DECIMAL(20,2)); CREATE TABLE asset_transactions (transaction_id INT, asset_id INT, sender_address VARCHAR(50), receiver_address VARCHAR(50), amount DECIMAL(10,2), timestamp TIMESTAMP);
|
What are the top 5 digital assets with the highest total transaction volume?
|
SELECT d.asset_name, SUM(a.amount) as total_volume FROM digital_assets d JOIN asset_transactions a ON d.asset_id = a.asset_id GROUP BY d.asset_name ORDER BY total_volume DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE DonorCities (City VARCHAR(50), Population INT); INSERT INTO DonorCities (City, Population) VALUES ('San Francisco', 884363), ('Seattle', 753359), ('Boston', 694543); CREATE TABLE Donations (DonationID INT, City VARCHAR(50), DonationAmount DECIMAL(10,2)); INSERT INTO Donations (DonationID, City, DonationAmount) VALUES (1, 'San Francisco', 500000.00), (2, 'Seattle', 400000.00), (3, 'Boston', 300000.00), (4, 'San Francisco', 600000.00);
|
Delete the record with the highest donation amount for 'San Francisco'.
|
DELETE FROM Donations WHERE DonationID = (SELECT DonationID FROM Donations WHERE City = 'San Francisco' ORDER BY DonationAmount DESC LIMIT 1);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE incidents (id INT, industry VARCHAR(255), incident_rate FLOAT, incident_date DATE, country VARCHAR(255));
|
What is the minimum safety incident rate in the chemical industry in China for the past 3 years?
|
SELECT country, MIN(incident_rate) as min_rate FROM incidents WHERE industry = 'chemical' AND country = 'China' AND incident_date > DATE_SUB(CURDATE(), INTERVAL 3 YEAR) GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Artists (id INT, name TEXT); INSERT INTO Artists (id, name) VALUES (1, 'Frida Kahlo'); CREATE TABLE Artwork (id INT, title TEXT, artist_id INT); INSERT INTO Artwork (id, title, artist_id) VALUES (1, 'The Two Fridas', 1), (2, 'Self-Portrait with Cropped Hair', 1), (3, 'Diego and I', 1); CREATE TABLE Galleries (id INT, title TEXT, artwork_id INT);
|
Insert missing artworks by 'Frida Kahlo' in 'Galleries' table.
|
INSERT INTO Galleries (id, title, artwork_id) SELECT NULL, 'Museum of Modern Art', a.id FROM Artwork a JOIN Artists ar ON a.artist_id = ar.id WHERE ar.name = 'Frida Kahlo' WHERE a.id NOT IN (SELECT artwork_id FROM Galleries);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE DefenseContracts (id INT, contractor VARCHAR(255), country VARCHAR(255), contract_value DECIMAL(10,2)); INSERT INTO DefenseContracts (id, contractor, country, contract_value) VALUES (1, 'Contractor1', 'United States', 10000000.00), (2, 'Contractor2', 'Canada', 20000000.00);
|
What is the total value of defense contracts awarded to companies in the United States?
|
SELECT SUM(contract_value) FROM DefenseContracts WHERE country = 'United States';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE financial_aid (id INT, organization VARCHAR(255), country VARCHAR(255), amount DECIMAL(10, 2)); INSERT INTO financial_aid (id, organization, country, amount) VALUES ('1', 'UNHCR', 'Jordan', '500000'), ('2', 'WFP', 'Jordan', '600000'), ('3', 'UNICEF', 'Jordan', '400000'), ('4', 'Red Cross', 'Turkey', '700000'), ('5', 'Save the Children', 'Turkey', '800000'), ('6', 'World Vision', 'Turkey', '900000');
|
What is the total amount of financial aid provided to refugees in Jordan and Turkey, grouped by organization?
|
SELECT organization, SUM(amount) as total_aid FROM financial_aid WHERE country IN ('Jordan', 'Turkey') GROUP BY organization;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE players (id INT, name VARCHAR(50), age INT, country VARCHAR(50)); INSERT INTO players (id, name, age, country) VALUES (1, 'John Doe', 25, 'USA'), (2, 'Jane Smith', 30, 'Canada'), (3, 'Bob Brown', 35, 'UK'); CREATE TABLE player_games (player_id INT, game_id INT, game_type VARCHAR(50)); INSERT INTO player_games (player_id, game_id, game_type) VALUES (1, 1, 'VR'), (1, 2, 'Non-VR'), (2, 1, 'VR'), (3, 3, 'Non-VR');
|
Show the total number of players and the number of players who have played VR games.
|
SELECT COUNT(*) AS total_players, SUM(CASE WHEN game_type = 'VR' THEN 1 ELSE 0 END) AS vr_players FROM player_games;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE brand_material_ratings (brand VARCHAR(50), material VARCHAR(50), rating INT); INSERT INTO brand_material_ratings (brand, material, rating) VALUES ('Brand A', 'organic cotton', 5), ('Brand A', 'recycled polyester', 4), ('Brand B', 'organic cotton', 5), ('Brand B', 'hemp', 3);
|
Which brands in the ethical fashion database have the highest and lowest average rating for sustainable materials?
|
SELECT brand, AVG(rating) FROM brand_material_ratings GROUP BY brand ORDER BY AVG(rating) DESC LIMIT 1; SELECT brand, AVG(rating) FROM brand_material_ratings GROUP BY brand ORDER BY AVG(rating) LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE wells (well_name TEXT, production_q1 FLOAT, production_q2 FLOAT, production_q3 FLOAT, production_q4 FLOAT); INSERT INTO wells (well_name, production_q1, production_q2, production_q3, production_q4) VALUES ('Well A', 1000, 1200, 1500, 1700), ('Well B', 1100, 1350, 1600, 1850), ('Well C', 1200, 1400, 1700, 2000), ('Well D', 1300, 1500, 1800, 2100);
|
Create a view named 'top_producers' that displays the top 3 wells with the highest production figures for the past 4 quarters
|
CREATE VIEW top_producers AS SELECT well_name, production_q1 + production_q2 + production_q3 + production_q4 as total_production FROM wells ORDER BY total_production DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Workout (WorkoutID INT, MemberID INT, WorkoutType VARCHAR(30), Duration INT); INSERT INTO Workout (WorkoutID, MemberID, WorkoutType, Duration) VALUES (1, 1, 'Running', 60); INSERT INTO Workout (WorkoutID, MemberID, WorkoutType, Duration) VALUES (2, 1, 'Cycling', 90); INSERT INTO Workout (WorkoutID, MemberID, WorkoutType, Duration) VALUES (3, 2, 'Yoga', 45); INSERT INTO Workout (WorkoutID, MemberID, WorkoutType, Duration) VALUES (4, 2, 'Cycling', 75); INSERT INTO Workout (WorkoutID, MemberID, WorkoutType, Duration) VALUES (5, 3, 'Swimming', 120);
|
What is the maximum duration of a single workout?
|
SELECT MAX(Duration) FROM Workout;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE companies (id INT, name TEXT, industry TEXT, founder_region TEXT); INSERT INTO companies (id, name, industry, founder_region) VALUES (1, 'LatAmFood', 'Food', 'LatinAmerica'); INSERT INTO companies (id, name, industry, founder_region) VALUES (2, 'TechFem', 'Technology', 'Europe'); CREATE TABLE funding (company_id INT, amount FLOAT); INSERT INTO funding (company_id, amount) VALUES (1, 750000); INSERT INTO funding (company_id, amount) VALUES (2, 500000);
|
What is the total funding received by startups founded by a person from Latin America?
|
SELECT SUM(funding.amount) FROM companies INNER JOIN funding ON companies.id = funding.company_id WHERE companies.founder_region = 'LatinAmerica';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE LandfillCapacity (landfill VARCHAR(255), region VARCHAR(255), capacity INT, used_capacity INT); INSERT INTO LandfillCapacity (landfill, region, capacity, used_capacity) VALUES ('LandfillA', 'RegionC', 50000, 25000), ('LandfillB', 'RegionC', 60000, 30000), ('LandfillC', 'RegionD', 40000, 15000);
|
What is the capacity of each landfill in RegionC and RegionD and its remaining capacity?
|
SELECT landfill, region, capacity, capacity - used_capacity AS remaining_capacity FROM LandfillCapacity WHERE region IN ('RegionC', 'RegionD');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE teams (team_id INT, team_name VARCHAR(50));CREATE TABLE games (game_id INT, team_id INT, home_team BOOLEAN, price DECIMAL(5,2), attendance INT, year INT);INSERT INTO teams (team_id, team_name) VALUES (1, 'Red Sox'), (2, 'Yankees');INSERT INTO games (game_id, team_id, home_team, price, attendance, year) VALUES (1, 1, 1, 35.50, 30000, 2020), (2, 2, 1, 42.75, 45000, 2020), (3, 1, 0, 28.00, 22000, 2019);
|
How many fans attended games in the 2020 season, considering all teams?
|
SELECT SUM(g.attendance) AS total_attendance FROM games g INNER JOIN teams t ON g.team_id = t.team_id WHERE g.year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE players (player_id INT PRIMARY KEY, first_name VARCHAR(50), last_name VARCHAR(50), sport VARCHAR(50), team VARCHAR(50));
|
Insert a new basketball player named "Jamal Wallace" into the "players" table
|
INSERT INTO players (player_id, first_name, last_name, sport, team) VALUES (4, 'Jamal', 'Wallace', 'Basketball', 'Knicks');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hospital (hospital_id INT, name TEXT, location TEXT, beds INT); CREATE TABLE physician (physician_id INT, name TEXT, specialty TEXT, location TEXT, hospital_id INT);
|
List the name, location, and number of physicians for each hospital in rural areas of Texas.
|
SELECT a.name, a.location, COUNT(b.physician_id) FROM hospital a INNER JOIN physician b ON a.hospital_id = b.hospital_id WHERE a.location LIKE '%rural%' AND a.state = 'Texas' GROUP BY a.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donors (donor_id INT, first_name TEXT, last_name TEXT, donation_amount FLOAT);
|
Insert a new record into the 'donors' table for a donor with the first name 'Alex', last name 'Gomez', and a donation amount of 400.00.
|
INSERT INTO donors (first_name, last_name, donation_amount) VALUES ('Alex', 'Gomez', 400.00);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE players (player_id INT, name VARCHAR(255)); CREATE TABLE player_games (player_id INT, game_id INT, hours_played INT);
|
Show the names of all players who have played more than 50 hours on any game
|
SELECT players.name FROM players JOIN player_games ON players.player_id = player_games.player_id WHERE player_games.hours_played > 50;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE security_incidents (id INT, sector VARCHAR(255), date DATE);
|
How many security incidents were reported in the financial sector in the past year?
|
SELECT COUNT(*) FROM security_incidents WHERE sector = 'financial' AND date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_protected_areas (country VARCHAR(255), name VARCHAR(255), size FLOAT, region VARCHAR(255)); INSERT INTO marine_protected_areas (country, name, size, region) VALUES ('Madagascar', 'Nosy Hara Marine Park', 32.0, 'Africa'), ('South Africa', 'Cape Agulhas National Park', 54.8, 'Africa');
|
How many marine protected areas are there in 'Africa'?
|
SELECT COUNT(*) FROM marine_protected_areas WHERE region = 'Africa';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE city_transport (city VARCHAR(20), transport_type VARCHAR(20), avg_distance FLOAT); INSERT INTO city_transport (city, transport_type, avg_distance) VALUES ('CityA', 'bus', 12.3), ('CityB', 'tram', 14.5), ('CityC', 'subway', 10.7);
|
Which city has the highest average distance traveled in public transportation?
|
SELECT city, AVG(avg_distance) as avg_distance FROM city_transport GROUP BY city ORDER BY avg_distance DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cargo_tracking (cargo_id INT, cargo_name VARCHAR(50), destination VARCHAR(50), eta DATE);
|
Delete cargos with destination 'Antananarivo' from the cargo_tracking table
|
DELETE FROM cargo_tracking WHERE destination = 'Antananarivo';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE conservation_targets(state VARCHAR(20), target_to_conserve INT); INSERT INTO conservation_targets VALUES('California', 1500), ('Texas', 2000);
|
What is the water conservation target for each state?
|
SELECT state, target_to_conserve FROM conservation_targets;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE GreenBuildingsByCountry (Country VARCHAR(50), GreenBuildingCount INT, TotalBuildingCount INT); INSERT INTO GreenBuildingsByCountry (Country, GreenBuildingCount, TotalBuildingCount) VALUES ('USA', 100, 200), ('UK', 50, 100);
|
What is the percentage of green buildings in each country?
|
SELECT Country, (GreenBuildingCount * 100.0 / TotalBuildingCount) AS GreenBuildingPercentage FROM GreenBuildingsByCountry;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vulnerabilities (category VARCHAR(255), severity INT); INSERT INTO vulnerabilities (category, severity) VALUES ('Operating System', 5), ('Operating System', 7), ('Application', 3), ('Database', 9), ('Database', 6);
|
What is the distribution of severity levels for vulnerabilities in the 'Database' category?
|
SELECT severity, COUNT(*) as vulnerability_count FROM vulnerabilities WHERE category = 'Database' GROUP BY severity;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE funds (fund_id INT, sector VARCHAR(255), amount DECIMAL(10, 2), donation_date DATE); INSERT INTO funds (fund_id, sector, amount, donation_date) VALUES (1, 'Education', 5000.00, '2021-01-01');
|
What is the total amount of funds raised by each sector in 'disaster_response' schema?
|
SELECT sector, SUM(amount) as total_funds_raised FROM funds GROUP BY sector;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Spacecraft_Capacities (Spacecraft_ID INT, Spacecraft_Name VARCHAR(100), Max_Capacity INT); INSERT INTO Spacecraft_Capacities (Spacecraft_ID, Spacecraft_Name, Max_Capacity) VALUES (1, 'SpaceX Starship', 100);
|
What is the maximum number of people that the SpaceX Starship can carry?
|
SELECT Max_Capacity FROM Spacecraft_Capacities WHERE Spacecraft_Name = 'SpaceX Starship';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE satellite_info (id INT, name VARCHAR(50), orbit_status VARCHAR(20), last_contact_date DATE); INSERT INTO satellite_info (id, name, orbit_status, last_contact_date) VALUES (1, 'Sat 1', 'Active', '2015-01-01'); INSERT INTO satellite_info (id, name, orbit_status, last_contact_date) VALUES (2, 'Sat 2', 'Active', '2020-01-01');
|
Update the "orbit_status" column with 'Inactive' for satellites in the "satellite_info" table that have been inactive for more than 5 years.
|
UPDATE satellite_info SET orbit_status = 'Inactive' WHERE last_contact_date < DATE_SUB(CURRENT_DATE, INTERVAL 5 YEAR);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE inventory (menu_item VARCHAR(255), quantity INT); INSERT INTO inventory (menu_item, quantity) VALUES ('Burger Buns', 1200); INSERT INTO inventory (menu_item, quantity) VALUES ('Lettuce', 2500);
|
How many units of each menu item are currently in inventory?
|
SELECT menu_item, SUM(quantity) as total_quantity FROM inventory GROUP BY menu_item;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE courses (id INT, name VARCHAR(50), institution_type VARCHAR(50));
|
What is the distribution of AI ethics courses by institution type?
|
SELECT institution_type, COUNT(*) as count FROM courses WHERE name LIKE '%AI ethics%' GROUP BY institution_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE GameDesign (GameID INT, Title VARCHAR(50), TargetGender VARCHAR(10)); INSERT INTO GameDesign (GameID, Title, TargetGender) VALUES (1, 'Stardew Valley', 'Female'), (2, 'Minecraft', 'All'), (3, 'The Sims', 'Female');
|
What is the total number of games designed for male players?
|
SELECT SUM(CASE WHEN TargetGender = 'Male' THEN 1 ELSE 0 END) FROM GameDesign;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ingredients (ingredient_id INT, ingredient_name TEXT, is_cruelty_free BOOLEAN, popularity_score INT); INSERT INTO ingredients (ingredient_id, ingredient_name, is_cruelty_free, popularity_score) VALUES (1, 'Argan Oil', TRUE, 80), (2, 'Shea Butter', TRUE, 90), (3, 'Beeswax', FALSE, 70);
|
What are the most popular cruelty-free cosmetic ingredients in Canada?
|
SELECT ingredient_name, popularity_score FROM ingredients WHERE is_cruelty_free = TRUE AND country = 'Canada' ORDER BY popularity_score DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Events (Title TEXT, Date DATE, Location TEXT, Attendees INT);
|
Insert a new record for an event with title 'Music Festival', date '2023-04-01', location 'City Park', and 500 attendees
|
INSERT INTO Events (Title, Date, Location, Attendees) VALUES ('Music Festival', '2023-04-01', 'City Park', 500);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE factory_workers (id INT, factory VARCHAR(100), location VARCHAR(100), num_workers INT); INSERT INTO factory_workers (id, factory, location, num_workers) VALUES (1, 'US Factory', 'United States', 100), (2, 'Canada Factory', 'Canada', 50), (3, 'Mexico Factory', 'Mexico', 150);
|
What is the total number of workers employed in factories in North America?
|
SELECT SUM(num_workers) FROM factory_workers WHERE location = 'North America';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donations (donor_id INT, reserve VARCHAR(50), amount DECIMAL(10, 2), purpose VARCHAR(50)); INSERT INTO Donations (donor_id, reserve, amount, purpose) VALUES (1, 'AsianReserve', 500.00, 'TigerConservation'), (2, 'AfricanReserve', 300.00, 'LionConservation'), (3, 'AmericasReserve', 200.00, 'JaguarConservation'), (4, 'AmericasReserve', 250.00, 'JaguarConservation'), (5, 'AsianReserve', 700.00, 'TigerConservation');
|
What is the average donation amount for jaguar conservation in the "AmericasReserve"?
|
SELECT AVG(amount) FROM Donations WHERE reserve = 'AmericasReserve' AND purpose = 'JaguarConservation';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ports (id INT, name VARCHAR(50), location VARCHAR(50), un_code VARCHAR(10)); CREATE TABLE vessels (id INT, name VARCHAR(50), type VARCHAR(50), year_built INT, port_id INT); CREATE TABLE cargo (id INT, description VARCHAR(50), weight FLOAT, port_id INT, vessel_id INT); CREATE VIEW top_heavy_cargo AS SELECT c.description, c.weight, p.name AS port_name FROM cargo c JOIN ports p ON c.port_id = p.id WHERE c.weight > 10000;
|
How many ports in Asia have handled cargo with a weight greater than 10,000 tons?
|
SELECT COUNT(*) AS num_of_ports FROM ports p JOIN top_heavy_cargo thc ON p.name = thc.port_name WHERE p.location LIKE 'Asia%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CustomerSizes (id INT, size VARCHAR(255), country VARCHAR(255), percentage DECIMAL(4,2)); INSERT INTO CustomerSizes (id, size, country, percentage) VALUES (1, 'XS', 'UK', 5.00), (2, 'S', 'Canada', 15.00), (3, 'M', 'France', 20.00); CREATE TABLE CustomerInterests (id INT, interest VARCHAR(255), country VARCHAR(255), percentage DECIMAL(4,2)); INSERT INTO CustomerInterests (id, interest, country, percentage) VALUES (1, 'Sustainable Fashion', 'Asia', 30.00), (2, 'Fast Fashion', 'Asia', 50.00), (3, 'Sustainable Fashion', 'Oceania', 40.00);
|
What is the total number of customers who prefer sustainable fashion in Asia and Oceania?
|
SELECT SUM(c.percentage + ci.percentage) FROM CustomerSizes c INNER JOIN CustomerInterests ci ON c.country = ci.country WHERE c.country IN ('Asia', 'Oceania') AND ci.interest = 'Sustainable Fashion';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE investigative_reports (id INT, title VARCHAR(255), author VARCHAR(255), publication_date DATE, word_count INT);
|
What is the distribution of articles by word count in the 'investigative_reports' table?
|
SELECT word_count, COUNT(*) as article_count FROM investigative_reports GROUP BY word_count;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE department (id INT, name VARCHAR(255), manager_id INT, location VARCHAR(255)); INSERT INTO department (id, name, manager_id, location) VALUES (1, 'textiles', 101, 'New York'); INSERT INTO department (id, name, manager_id, location) VALUES (2, 'metallurgy', 102, 'Chicago'); CREATE TABLE employee (id INT, name VARCHAR(255), department_id INT, salary DECIMAL(10,2)); INSERT INTO employee (id, name, department_id, salary) VALUES (1001, 'Alice', 1, 50000.00); INSERT INTO employee (id, name, department_id, salary) VALUES (1002, 'Bob', 1, 55000.00); INSERT INTO employee (id, name, department_id, salary) VALUES (1003, 'Charlie', 2, 60000.00);
|
What is the average salary of workers in the 'textiles' department?
|
SELECT AVG(salary) FROM employee WHERE department_id = (SELECT id FROM department WHERE name = 'textiles');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mining_sites (site_id INT, site_name TEXT, location TEXT); INSERT INTO mining_sites (site_id, site_name, location) VALUES (1, 'Site A', 'Country X'), (2, 'Site B', 'Country Y'); CREATE TABLE extraction_methods (method_id INT, site_id INT, method_name TEXT); INSERT INTO extraction_methods (method_id, site_id, method_name) VALUES (1, 1, 'Underground'), (2, 1, 'Open-pit'), (3, 2, 'Underground'), (4, 2, 'Placer'); CREATE TABLE expenditure (expenditure_id INT, site_id INT, method_id INT, amount FLOAT); INSERT INTO expenditure (expenditure_id, site_id, method_id, amount) VALUES (1, 1, 1, 1000000), (2, 1, 2, 1500000), (3, 2, 3, 2000000), (4, 2, 4, 2500000);
|
What is the total expenditure for each mining site, categorized by extraction method?
|
SELECT mining_sites.site_name, extraction_methods.method_name, SUM(expenditure.amount) AS total_expenditure FROM mining_sites INNER JOIN extraction_methods ON mining_sites.site_id = extraction_methods.site_id INNER JOIN expenditure ON mining_sites.site_id = expenditure.site_id AND extraction_methods.method_id = expenditure.method_id GROUP BY mining_sites.site_name, extraction_methods.method_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE renewable_energy (project_id INT, project_name TEXT, location TEXT); CREATE TABLE carbon_offsets (project_id INT, initiative_name TEXT, location TEXT); INSERT INTO renewable_energy (project_id, project_name, location) VALUES (1, 'Solar Field One', 'Europe'), (2, 'Wind Farm Two', 'North America'); INSERT INTO carbon_offsets (project_id, initiative_name, location) VALUES (1, 'Tropical Forest Protection', 'South America'), (3, 'Ocean Current Capture', 'Europe');
|
Identify renewable energy projects in Europe without any associated carbon offset initiatives.
|
SELECT project_name FROM renewable_energy WHERE project_id NOT IN (SELECT project_id FROM carbon_offsets WHERE renewable_energy.location = carbon_offsets.location);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE smart_contracts (id INT, name VARCHAR(255), creator VARCHAR(255)); INSERT INTO smart_contracts (id, name, creator) VALUES (4, 'Uniswap', 'Vitalik Buterin');
|
Who is the creator of the 'Uniswap' smart contract?
|
SELECT creator FROM smart_contracts WHERE name = 'Uniswap';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Interactive_Installations (id INT, name VARCHAR(255), entry_fee DECIMAL(5,2)); CREATE TABLE Interactions (id INT, visitor_id INT, installation_id INT, price DECIMAL(5,2));
|
Calculate total revenue for all interactive installations
|
SELECT SUM(Interactions.price) FROM Interactions JOIN Interactive_Installations ON Interactions.installation_id = Interactive_Installations.id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE FashionTrends (TrendID INT, TrendName VARCHAR(255), Quarter VARCHAR(255), Revenue DECIMAL(10, 2)); INSERT INTO FashionTrends (TrendID, TrendName, Quarter, Revenue) VALUES (1, 'Trend1', 'Q1', 250000);
|
Find the top 2 fashion trends, by total revenue, for each quarter in the year.
|
SELECT TrendName, Quarter, SUM(Revenue) as TotalRevenue FROM FashionTrends GROUP BY Quarter, TrendName ORDER BY TotalRevenue DESC, Quarter, TrendName LIMIT 2;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE company_employees (id INT, company_name VARCHAR(50), city VARCHAR(50), num_employees INT); CREATE TABLE funding_records (id INT, company_name VARCHAR(50), funding_amount DECIMAL(10, 2));
|
Calculate the total funding received by companies with more than 100 employees, grouped by city
|
SELECT e.city, SUM(r.funding_amount) AS total_funding FROM company_employees e JOIN funding_records r ON e.company_name = r.company_name WHERE e.num_employees > 100 GROUP BY e.city;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE products (product_id INT, product_name VARCHAR(100), sales INT, certification VARCHAR(20)); INSERT INTO products (product_id, product_name, sales, certification) VALUES (1, 'Lipstick A', 5000, 'cruelty-free'), (2, 'Mascara B', 7000, 'not_certified'), (3, 'Foundation C', 8000, 'cruelty-free'); CREATE TABLE countries (country_code CHAR(2), country_name VARCHAR(50)); INSERT INTO countries (country_code, country_name) VALUES ('MX', 'Mexico');
|
What is the total sales volume of cosmetic products that are not certified cruelty-free in the Mexican market?
|
SELECT SUM(products.sales) FROM products JOIN countries ON products.country_code = countries.country_code WHERE products.certification = 'not_certified' AND countries.country_name = 'Mexico';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE lifelong_learning (student_id INT, student_name VARCHAR(50), gender VARCHAR(10), dropped_out BOOLEAN); INSERT INTO lifelong_learning (student_id, student_name, gender, dropped_out) VALUES (1, 'John Doe', 'Male', true), (2, 'Jane Smith', 'Female', true);
|
What is the percentage of students who dropped out of lifelong learning programs by gender?
|
SELECT gender, AVG(CAST(dropped_out AS FLOAT)) * 100 AS percentage FROM lifelong_learning GROUP BY gender;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE JobApplications (ApplicationID INT, Country VARCHAR(20)); INSERT INTO JobApplications (ApplicationID, Country) VALUES (1, 'USA'), (2, 'Canada'), (3, 'USA');
|
What is the total number of job applications from each country?
|
SELECT Country, COUNT(*) FROM JobApplications GROUP BY Country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE graduate_students (student_id INT, name TEXT, gpa DECIMAL(3,2), department TEXT);
|
What is the minimum GPA of graduate students in the Physics department?
|
SELECT MIN(gs.gpa) FROM graduate_students gs WHERE gs.department = 'Physics';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE employees (id INT, name VARCHAR(50), department VARCHAR(50), salary FLOAT); INSERT INTO employees (id, name, department, salary) VALUES (1, 'Juan Garcia', 'research and development', 90000), (2, 'Maria Rodriguez', 'human resources', 75000);
|
What is the maximum salary paid in the 'research and development' department?
|
SELECT MAX(salary) FROM employees WHERE department = 'research and development';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SpaceMissions (Id INT, Astronaut VARCHAR(20), Year INT, Duration INT); INSERT INTO SpaceMissions VALUES (1, 'Astronaut1', 2019, 300), (2, 'Astronaut2', 2019, 250), (3, 'Astronaut3', 2019, 400), (4, 'Astronaut4', 2020, 500), (5, 'Astronaut5', 2020, 200), (6, 'Astronaut1', 2020, 350), (7, 'Astronaut2', 2020, 280), (8, 'Astronaut3', 2021, 450), (9, 'Astronaut4', 2021, 550), (10, 'Astronaut5', 2021, 250);
|
Calculate the average duration of space missions for each astronaut in the past 2 years.
|
SELECT Astronaut, AVG(Duration) as AvgDuration FROM SpaceMissions WHERE Year >= 2019 GROUP BY Astronaut;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE songs (id INT, title VARCHAR(100), release_year INT, genre VARCHAR(50), streams INT); INSERT INTO songs (id, title, release_year, genre, streams) VALUES (1, 'Shape of You', 2017, 'Pop', 2000000000); INSERT INTO songs (id, title, release_year, genre, streams) VALUES (2, 'Sicko Mode', 2018, 'Hip Hop', 1500000000); INSERT INTO songs (id, title, release_year, genre, streams) VALUES (3, 'Black Panther', 2018, 'Soundtrack', 1200000000); CREATE TABLE artists (id INT, name VARCHAR(100), age INT);
|
What is the average number of streams for songs released in 2020, grouped by genre?
|
SELECT genre, AVG(streams) as avg_streams FROM songs WHERE release_year = 2020 GROUP BY genre;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE brands (id INT, name VARCHAR(50)); CREATE TABLE materials_used (id INT, brand_id INT, material VARCHAR(50), quantity INT); INSERT INTO brands (id, name) VALUES (1, 'Brand A'), (2, 'Brand B'); INSERT INTO materials_used (id, brand_id, material, quantity) VALUES (1, 1, 'Organic Cotton', 100), (2, 1, 'Recycled Polyester', 150), (3, 2, 'Organic Cotton', 200);
|
Delete a sustainable material for a brand.
|
DELETE FROM materials_used WHERE id = 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE freight_forwarding (request_id INT, warehouse_id INT, request_date DATE); INSERT INTO freight_forwarding (request_id, warehouse_id, request_date) VALUES (1, 1, '2022-06-01'), (2, 2, '2022-06-15'), (3, 3, '2022-07-01'); CREATE TABLE warehouse_geo (warehouse_id INT, country VARCHAR(20)); INSERT INTO warehouse_geo (warehouse_id, country) VALUES (1, 'USA'), (2, 'Canada'), (3, 'Mexico');
|
Which country has the most freight forwarding requests in the month of June 2022?
|
SELECT country, COUNT(*) AS request_count FROM freight_forwarding JOIN warehouse_geo ON freight_forwarding.warehouse_id = warehouse_geo.warehouse_id WHERE request_date BETWEEN '2022-06-01' AND '2022-06-30' GROUP BY country ORDER BY request_count DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Astronauts (ID INT, Name VARCHAR(255), MedicalRisk INT); CREATE TABLE Missions (ID INT, Destination VARCHAR(255)); INSERT INTO Astronauts (ID, Name, MedicalRisk) VALUES (1, 'Astronaut1', 10), (2, 'Astronaut2', 20), (3, 'Astronaut3', 30); INSERT INTO Missions (ID, Destination) VALUES (1, 'Mars'), (2, 'Moon'), (3, 'Mars');
|
What is the maximum medical risk score of astronauts who have flown missions to Mars?
|
SELECT MAX(MedicalRisk) FROM Astronauts INNER JOIN Missions ON Astronauts.ID = Missions.ID WHERE Destination = 'Mars';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE authors (author_id INT PRIMARY KEY, first_name VARCHAR(50), last_name VARCHAR(50));
|
Update the names of authors with the last name 'Doe' to 'Smith' in the 'authors' table
|
UPDATE authors SET last_name = 'Smith' WHERE last_name = 'Doe';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE open_pedagogy (course_id INT, district VARCHAR(50), course_type VARCHAR(50)); INSERT INTO open_pedagogy (course_id, district, course_type) VALUES (1001, 'Urban School District', 'Traditional'), (1002, 'Rural School District', 'Open'), (1003, 'Urban School District', 'Traditional');
|
What is the count of open pedagogy courses offered in 'Rural School District'?
|
SELECT COUNT(*) FROM open_pedagogy WHERE district = 'Rural School District' AND course_type = 'Open';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donations (DonationID int, Amount decimal(10,2), PaymentMethod varchar(50), DonationDate date); INSERT INTO Donations (DonationID, Amount, PaymentMethod, DonationDate) VALUES (1, 50.00, 'Credit Card', '2021-01-01'); INSERT INTO Donations (DonationID, Amount, PaymentMethod, DonationDate) VALUES (2, 100.00, 'PayPal', '2021-02-01');
|
What are the total donation amounts by payment method for the year 2021?
|
SELECT PaymentMethod, SUM(Amount) as TotalDonationAmount FROM Donations WHERE YEAR(DonationDate) = 2021 GROUP BY PaymentMethod;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE workout_data (member_id INT, workout_type VARCHAR(50), duration INT, workout_date DATE); INSERT INTO workout_data (member_id, workout_type, duration, workout_date) VALUES (1, 'yoga', 60, '2021-01-15'), (2, 'cycling', 90, '2022-03-28'); CREATE TABLE members (member_id INT, join_date DATE); INSERT INTO members (member_id, join_date) VALUES (1, '2021-01-15'), (2, '2022-03-28');
|
What is the average duration of cycling workouts in minutes for members who joined in 2019?
|
SELECT AVG(duration) FROM workout_data JOIN members ON workout_data.member_id = members.member_id WHERE workout_type = 'cycling' AND members.join_date >= '2019-01-01' AND members.join_date < '2020-01-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE recycling_rates (city VARCHAR(255), year INT, material VARCHAR(255), rate FLOAT); INSERT INTO recycling_rates (city, year, material, rate) VALUES ('CityA', 2019, 'Plastic', 0.35), ('CityA', 2019, 'Paper', 0.60), ('CityA', 2019, 'Glass', 0.55), ('CityB', 2019, 'Plastic', 0.40), ('CityB', 2019, 'Paper', 0.50), ('CityB', 2019, 'Glass', 0.45);
|
What are the recycling rates for each material type in 2019?
|
SELECT year, material, AVG(rate) FROM recycling_rates WHERE year = 2019 GROUP BY year, material;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE providers (id INT, name TEXT, location TEXT, country TEXT, departure_date DATE, departure_reason TEXT); INSERT INTO providers (id, name, location, country, departure_date, departure_reason) VALUES (1, 'Provider A', 'Rural India', 'India', '2020-01-01', 'Reason 1'), (2, 'Provider B', 'Rural India', 'India', '2019-12-01', 'Reason 2');
|
Find the number of healthcare providers who have left their positions in rural India and the reasons for their departure.
|
SELECT COUNT(*) AS number_of_providers, departure_reason FROM providers WHERE location LIKE '%rural%' AND country = 'India' GROUP BY departure_reason
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CountrySales (country VARCHAR(255), category VARCHAR(255), revenue FLOAT);
|
Which country has the highest revenue in skincare products?
|
SELECT country, MAX(revenue) FROM CountrySales WHERE category = 'Skincare' GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Time (TimeID INT, SongID INT, Year INT, Revenue INT);
|
What is the total revenue for the Jazz genre in 2020?
|
SELECT SUM(Time.Revenue) as TotalRevenue FROM Time INNER JOIN Song ON Time.SongID = Song.SongID WHERE Song.GenreID = (SELECT GenreID FROM Genre WHERE Name='Jazz') AND Time.Year=2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE diversity_incidents (incident_id INT, site_id INT, incident_date DATE, incident_type TEXT); INSERT INTO diversity_incidents (incident_id, site_id, incident_date, incident_type) VALUES (1, 1, '2020-02-01', 'Gender'), (2, 1, '2020-03-01', 'Race'), (3, 2, '2020-02-01', 'Age'), (4, 2, '2020-03-01', 'Gender'), (5, 3, '2020-02-01', 'Race'), (6, 3, '2020-03-01', 'Gender');
|
Show the total number of workforce diversity incidents by type and mining site for the past year.
|
SELECT mining_sites.site_name, diversity_incidents.incident_type, COUNT(diversity_incidents.incident_id) AS total_incidents FROM mining_sites JOIN diversity_incidents ON mining_sites.site_id = diversity_incidents.site_id WHERE diversity_incidents.incident_date >= (CURRENT_DATE - INTERVAL '1 year') GROUP BY mining_sites.site_name, diversity_incidents.incident_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vehicle_safety_test_results (id INT, vehicle_name VARCHAR(50), safety_rating INT);
|
Add a new electric vehicle 'Tesla Model Y' with safety rating 5 to the 'vehicle_safety_test_results' table
|
INSERT INTO vehicle_safety_test_results (id, vehicle_name, safety_rating) VALUES (100, 'Tesla Model Y', 5);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE genetic_research_data (id INT, sample_id TEXT, gene_sequence TEXT, analysis_result TEXT);
|
List all genetic research data tables in the database.
|
SELECT name FROM sqlite_master WHERE type = 'table' AND name NOT LIKE 'sqlite_%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE orders (order_id INT, dish_id INT); CREATE TABLE dishes (dish_id INT, name VARCHAR(50), type VARCHAR(20)); INSERT INTO orders (order_id, dish_id) VALUES (1, 1), (2, 1), (3, 2), (4, 3), (5, 1), (6, 2), (7, 3), (8, 1), (9, 2), (10, 3); INSERT INTO dishes (dish_id, name, type) VALUES (1, 'Veggie Delight', 'vegan'), (2, 'Tofu Stir Fry', 'vegan'), (3, 'Chickpea Curry', 'vegan');
|
List the top 5 most frequently ordered vegan dishes.
|
SELECT dishes.name, COUNT(orders.order_id) AS order_count FROM dishes JOIN orders ON dishes.dish_id = orders.dish_id WHERE dishes.type = 'vegan' GROUP BY dishes.name ORDER BY order_count DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE VIEW sales_data AS SELECT id, vehicle_type, avg_speed, sales FROM vehicle_sales WHERE sales > 20000;
|
What is the total number of vehicles sold in 'sales_data' view that have a speed between 65 and 80 mph?
|
SELECT SUM(sales) FROM sales_data WHERE avg_speed BETWEEN 65 AND 80;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE baseball_teams (team_id INT, name VARCHAR(50), league VARCHAR(20), city VARCHAR(50)); INSERT INTO baseball_teams (team_id, name, league, city) VALUES (1, 'New York Yankees', 'American League', 'New York'); INSERT INTO baseball_teams (team_id, name, league, city) VALUES (2, 'Boston Red Sox', 'American League', 'Boston');
|
How many teams are there in the baseball_teams table?
|
SELECT COUNT(DISTINCT league) FROM baseball_teams;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE research (name TEXT, budget FLOAT); INSERT INTO research (name, budget) VALUES ('ResearchA', 7000000), ('ResearchB', 6000000), ('ResearchC', 8000000);
|
Which genetic research projects have a budget greater than the average budget?
|
SELECT name FROM research WHERE budget > (SELECT AVG(budget) FROM research);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE projects (id INT, city VARCHAR(20), size INT, sustainable BOOLEAN); INSERT INTO projects (id, city, size, sustainable) VALUES (1, 'Los Angeles', 2500, TRUE), (2, 'Los Angeles', 3000, FALSE), (3, 'Los Angeles', 3500, TRUE);
|
What is the maximum square footage of a sustainable urbanism project in the city of Los Angeles?
|
SELECT MAX(size) FROM projects WHERE city = 'Los Angeles' AND sustainable = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE VEHICLE_MAINTENANCE (maintenance_center TEXT, service_date DATE); INSERT INTO VEHICLE_MAINTENANCE (maintenance_center, service_date) VALUES ('North', '2022-02-01'), ('North', '2022-02-03'), ('South', '2022-02-02'), ('East', '2022-02-04'), ('West', '2022-02-05');
|
How many vehicles were serviced in the last 30 days for each maintenance center?
|
SELECT maintenance_center, COUNT(*) FROM VEHICLE_MAINTENANCE WHERE service_date >= (CURRENT_DATE - INTERVAL '30 days') GROUP BY maintenance_center;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Research_Papers (Paper_ID INT, Title VARCHAR(100), Published_Date DATE); INSERT INTO Research_Papers (Paper_ID, Title, Published_Date) VALUES (1, 'Autonomous Vehicles and City Planning', '2019-06-15'), (2, 'Sensor Fusion in Autonomous Driving Systems', '2020-02-22'), (3, 'Deep Learning Approaches in Autonomous Vehicles', '2018-12-03');
|
What is the number of autonomous driving research papers published in 2020?
|
SELECT COUNT(*) FROM Research_Papers WHERE YEAR(Published_Date) = 2020 AND Title LIKE '%Autonomous Driving%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Programs (ProgramID INT, ProgramName TEXT); INSERT INTO Programs (ProgramID, ProgramName) VALUES (1, 'Education'); INSERT INTO Programs (ProgramID, ProgramName) VALUES (2, 'Health'); CREATE TABLE Supplies (SupplyID INT, SupplyName TEXT, SupplyCost DECIMAL, PurchaseDate DATE); INSERT INTO Supplies (SupplyID, SupplyName, SupplyCost, PurchaseDate) VALUES (1, 'Books', 500.00, '2022-01-15'); INSERT INTO Supplies (SupplyID, SupplyName, SupplyCost, PurchaseDate) VALUES (2, 'Medicine', 800.00, '2022-03-30'); CREATE TABLE ProgramSupplies (ProgramID INT, SupplyID INT); INSERT INTO ProgramSupplies (ProgramID, SupplyID) VALUES (1, 1); INSERT INTO ProgramSupplies (ProgramID, SupplyID) VALUES (1, 2);
|
What is the total amount spent on program supplies for the 'Education' program in Q1 2022?
|
SELECT SUM(Supplies.SupplyCost) FROM Supplies INNER JOIN ProgramSupplies ON Supplies.SupplyID = ProgramSupplies.SupplyID INNER JOIN Programs ON ProgramSupplies.ProgramID = Programs.ProgramID WHERE Programs.ProgramName = 'Education' AND QUARTER(Supplies.PurchaseDate) = 1 AND YEAR(Supplies.PurchaseDate) = 2022;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE landfills (name TEXT, country TEXT, capacity INTEGER); INSERT INTO landfills (name, country, capacity) VALUES ('Landfill A', 'USA', 120000), ('Landfill B', 'USA', 150000), ('Landfill C', 'Australia', 180000);
|
Update the capacity of the landfill with name 'Landfill A' to 130000.
|
UPDATE landfills SET capacity = 130000 WHERE name = 'Landfill A';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE laboratories (name TEXT, state TEXT, tests_performed INTEGER, tests_per_day INTEGER); INSERT INTO laboratories (name, state, tests_performed, tests_per_day) VALUES ('Quest Diagnostics', 'Florida', 15000, 500), ('LabCorp', 'Florida', 12000, 400), ('BioReference Laboratories', 'Florida', 9000, 300);
|
How many laboratories are there in the state of Florida that perform more than 9000 tests per day?
|
SELECT COUNT(*) FROM laboratories WHERE state = 'Florida' AND tests_per_day > 9000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ExhibitionRevenue (exhibition_id INT, country VARCHAR(20), revenue DECIMAL(10, 2)); INSERT INTO ExhibitionRevenue (exhibition_id, country, revenue) VALUES (1, 'Mexico', 5000), (2, 'Mexico', 7000), (3, 'Mexico', 6000), (4, 'Brazil', 12000);
|
Find the exhibition with the highest revenue in Mexico.
|
SELECT exhibition_id, MAX(revenue) FROM ExhibitionRevenue WHERE country = 'Mexico' GROUP BY exhibition_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE safety_incidents (app_id INT, algorithm_id INT, incident_date DATE, incident_description VARCHAR(255)); INSERT INTO safety_incidents (app_id, algorithm_id, incident_date, incident_description) VALUES (1, 1, '2020-02-14', 'Minor issue'), (2, 2, '2020-06-05', 'Major incident'), (3, 3, '2021-03-15', 'Minor issue');
|
Identify the AI safety incidents for each algorithm launched in Europe before 2021.
|
SELECT algorithm_id, COUNT(*) AS incident_count FROM safety_incidents WHERE incident_date < '2021-01-01' AND region = 'Europe' GROUP BY algorithm_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE organization (id INT, name VARCHAR(255)); CREATE TABLE volunteer (id INT, name VARCHAR(255), organization_id INT);
|
List the organizations that have no volunteers.
|
SELECT o.name FROM organization o LEFT JOIN volunteer v ON o.id = v.organization_id WHERE v.id IS NULL;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Vessels (ID INT, Name TEXT, Voyages INT, Cargo_Weight INT, Prefix TEXT, Year INT);CREATE VIEW Arctic_Ocean_Vessels AS SELECT * FROM Vessels WHERE Region = 'Arctic Ocean';
|
What is the total number of voyages and total cargo weight for vessels with 'HMM' prefix in the Arctic Ocean in 2019?
|
SELECT SUM(Voyages), SUM(Cargo_Weight) FROM Arctic_Ocean_Vessels WHERE Prefix = 'HMM' AND Year = 2019;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE language_preservation (initiative_id INT, name VARCHAR(50), location VARCHAR(50), date DATE, budget DECIMAL(10,2));
|
Find the top 3 countries with the most language preservation initiatives.
|
SELECT location, COUNT(*) AS initiative_count FROM language_preservation GROUP BY location ORDER BY initiative_count DESC FETCH FIRST 3 ROWS ONLY;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE energy_storage (country VARCHAR(20), capacity FLOAT); INSERT INTO energy_storage (country, capacity) VALUES ('South Korea', 500.0), ('South Korea', 600.0), ('South Korea', 700.0);
|
What is the maximum energy storage capacity (in MWh) in South Korea?
|
SELECT MAX(capacity) FROM energy_storage WHERE country = 'South Korea';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE water_quality (sample_id INT, location TEXT, sample_date DATE, pH FLOAT, turbidity FLOAT);
|
Insert water quality samples from January 2022
|
INSERT INTO water_quality (sample_id, location, sample_date, pH, turbidity) VALUES (1, 'Stream A', '2022-01-01', 7.2, 30), (2, 'River B', '2022-01-02', 7.5, 20), (3, 'Lake C', '2022-01-03', 6.8, 50);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Movie_Studio (id INT, title VARCHAR(100), studio VARCHAR(50), revenue DECIMAL(10,2)); INSERT INTO Movie_Studio (id, title, studio, revenue) VALUES (1, 'Spirited Away', 'Studio Ghibli', 274767908), (2, 'My Neighbor Totoro', 'Studio Ghibli', 16545734), (3, 'Princess Mononoke', 'Studio Ghibli', 159390479);
|
What is the total revenue for movies produced by Studio Ghibli?
|
SELECT studio, SUM(revenue) FROM Movie_Studio WHERE studio = 'Studio Ghibli';
|
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.