context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE forest_type_sequestration (id INT, forest_type VARCHAR(255), total_sequestration FLOAT); INSERT INTO forest_type_sequestration (id, forest_type, total_sequestration) VALUES (1, 'Deciduous', 9000.0), (2, 'Coniferous', 11000.0), (3, 'Mixed', 8000.0);
What is the total carbon sequestration potential for each forest type in the 'forest_type_sequestration' table?
SELECT forest_type, SUM(total_sequestration) FROM forest_type_sequestration GROUP BY forest_type;
gretelai_synthetic_text_to_sql
CREATE TABLE CourtCases (Id INT, State VARCHAR(50), CaseNumber INT, Disposition VARCHAR(50), SettlementDate DATE); INSERT INTO CourtCases (Id, State, CaseNumber, Disposition, SettlementDate) VALUES (1, 'California', 12345, 'Settled', '2021-02-15'), (2, 'Texas', 67890, 'Proceeding', '2020-12-21'), (3, 'New York', 23456,...
List the case numbers and defendants' names of all cases that were settled out of court in the past 2 years, for each state.
SELECT State, CaseNumber, DefendantName FROM CourtCases WHERE Disposition = 'Settled' AND SettlementDate >= DATEADD(year, -2, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE production_2020 (production_id INT, quarter INT, oil_production FLOAT); INSERT INTO production_2020 (production_id, quarter, oil_production) VALUES (1, 1, 500.2), (2, 1, 550.4), (3, 2, 600.1), (4, 2, 650.3), (5, 3, 700.5), (6, 3, 750.6), (7, 4, 800.7), (8, 4, 850.8);
What was the total oil production for each quarter in 2020?
SELECT quarter, SUM(oil_production) as total_oil_production FROM production_2020 GROUP BY quarter ORDER BY quarter;
gretelai_synthetic_text_to_sql
CREATE TABLE FishStock (StockID INT, Location VARCHAR(50), Year INT, Species VARCHAR(50), OrganicCarbon FLOAT);
What is the total organic carbon content in each fish species' stock, partitioned by farming location and year?
SELECT Location, Species, Year, SUM(OrganicCarbon) OVER (PARTITION BY Location, Species, Year) AS TotalOrganicCarbon FROM FishStock ORDER BY Location, Species, Year;
gretelai_synthetic_text_to_sql
CREATE TABLE Sprout (customer_id INT, dish_type VARCHAR(15)); INSERT INTO Sprout (customer_id, dish_type) VALUES (7, 'vegetarian'), (8, 'vegan'), (9, 'vegetarian'); CREATE TABLE GreenLeaf (customer_id INT, dish_type VARCHAR(15)); INSERT INTO GreenLeaf (customer_id, dish_type) VALUES (10, 'vegan'), (11, 'vegetarian'), (...
Display the unique customer preferences for 'vegetarian' dishes at 'Sprout' and 'GreenLeaf'.
SELECT customer_id FROM Sprout WHERE dish_type = 'vegetarian' UNION SELECT customer_id FROM GreenLeaf WHERE dish_type = 'vegetarian';
gretelai_synthetic_text_to_sql
CREATE TABLE StateServices (State TEXT, Service TEXT); INSERT INTO StateServices (State, Service) VALUES ('State A', 'Education'), ('State A', 'Healthcare'), ('State B', 'Education'), ('State B', 'Healthcare'), ('State B', 'Transportation'), ('State C', 'Education');
How many public services are available in each state?
SELECT State, COUNT(DISTINCT Service) FROM StateServices GROUP BY State;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, name VARCHAR(50), organic BOOLEAN); INSERT INTO products (product_id, name, organic) VALUES (1, 'Lipstick A', true), (2, 'Lipstick B', false), (3, 'Eyeshadow C', false); CREATE TABLE ingredient_suppliers (ingredient_id INT, supplier_country VARCHAR(50), product_id INT, organic_sou...
Which organic suppliers are used for lipstick products?
SELECT DISTINCT supplier_country FROM ingredient_suppliers WHERE organic_source = true AND ingredient_suppliers.product_id IN (SELECT product_id FROM products WHERE products.name = 'Lipstick A');
gretelai_synthetic_text_to_sql
CREATE TABLE cosmetics (product_name TEXT, cruelty_free BOOLEAN, ingredient_source TEXT); INSERT INTO cosmetics (product_name, cruelty_free, ingredient_source) VALUES ('ProductA', true, 'CountryX'), ('ProductB', false, 'CountryY'), ('ProductC', true, 'CountryZ'), ('ProductD', true, 'CountryZ'), ('ProductE', false, 'Cou...
What are the names of the cosmetic products that are certified cruelty-free and source ingredients from country Z?
SELECT product_name FROM cosmetics WHERE cruelty_free = true AND ingredient_source = 'CountryZ';
gretelai_synthetic_text_to_sql
CREATE TABLE offshore_platforms (id INT, name VARCHAR(50), location VARCHAR(50), installation_year INT); INSERT INTO offshore_platforms VALUES (1, 'Platform A', 'Asia-Pacific', 2010); INSERT INTO offshore_platforms VALUES (2, 'Platform B', 'Asia-Pacific', 2012); INSERT INTO offshore_platforms VALUES (3, 'Platform C', '...
How many offshore platforms have been installed in the Asia-Pacific region in total?
SELECT COUNT(*) FROM offshore_platforms WHERE location = 'Asia-Pacific';
gretelai_synthetic_text_to_sql
CREATE TABLE vulnerabilities (id INT, timestamp TIMESTAMP, category VARCHAR(255), severity VARCHAR(255)); INSERT INTO vulnerabilities (id, timestamp, category, severity) VALUES (1, '2022-01-01 10:00:00', 'Network Devices', 'High');
How many vulnerabilities were found in the 'Network Devices' category in the last quarter?
SELECT category, COUNT(*) as vulnerability_count FROM vulnerabilities WHERE timestamp >= DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 3 MONTH) AND category = 'Network Devices' GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE Sightings (Species VARCHAR(25), Sightings INT); INSERT INTO Sightings (Species, Sightings) VALUES ('Dolphin', 200), ('Turtle', 300), ('Shark', 150), ('Whale', 400), ('Dolphin', 250);
How many sightings of each marine species were recorded?
SELECT Species, COUNT(*) FROM Sightings GROUP BY Species;
gretelai_synthetic_text_to_sql
CREATE TABLE programs (id INT, name VARCHAR(255)); INSERT INTO programs (id, name) VALUES (1, 'Mentoring'), (2, 'After-School Tutoring'), (3, 'Community Garden'); CREATE TABLE volunteer_hours (id INT, program_id INT, volunteer_id INT, hours INT); INSERT INTO volunteer_hours (id, program_id, volunteer_id, hours) VALUES ...
What is the average number of volunteer hours per volunteer for each program in 2021?
SELECT program_id, AVG(hours) as avg_volunteer_hours FROM volunteer_hours GROUP BY program_id;
gretelai_synthetic_text_to_sql
CREATE TABLE players (player_id INT, player_name TEXT); CREATE TABLE games (game_id INT, player_id INT, season TEXT);
How many games did a player play in the last season?
SELECT p.player_name, (SELECT COUNT(*) FROM games g WHERE g.player_id = p.player_id AND g.season = 'last_season') as games_played FROM players p;
gretelai_synthetic_text_to_sql
CREATE TABLE military_equipment (id INT, equipment_type VARCHAR(20), country_of_origin VARCHAR(20)); INSERT INTO military_equipment (id, equipment_type, country_of_origin) VALUES (1, 'Aircraft', 'USA'), (2, 'Ground Vehicle', 'Russia'), (3, 'Naval Vessel', 'China');
Delete all records in the 'military_equipment' table where the 'equipment_type' is 'Aircraft' AND the 'country_of_origin' is 'USA'
DELETE FROM military_equipment WHERE equipment_type = 'Aircraft' AND country_of_origin = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE forest_inventory (id INT, forest_type VARCHAR(255), tree_count INT); INSERT INTO forest_inventory (id, forest_type, tree_count) VALUES (1, 'Temperate', 1000), (2, 'Tropical', 2000), (3, 'Boreal', 1500);
How many trees are present in each forest type in the 'forest_inventory' table?
SELECT forest_type, SUM(tree_count) FROM forest_inventory GROUP BY forest_type;
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (transaction_id INT, account_number INT, amount DECIMAL(10,2), transaction_date DATE); INSERT INTO transactions (transaction_id, account_number, amount, transaction_date) VALUES (1, 999999999, 50.00, '2022-05-01'), (2, 999999999, 50.00, '2022-05-02');
What is the earliest transaction date for account number 999999999?
SELECT MIN(transaction_date) FROM transactions WHERE account_number = 999999999;
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (id INT, name VARCHAR(50), reg_date DATE, location VARCHAR(30)); INSERT INTO volunteers (id, name, reg_date, location) VALUES (1, 'Alex', '2023-02-01', 'urban'), (2, 'Bella', '2023-01-15', 'rural'), (3, 'Charlie', '2023-03-05', 'suburban'), (4, 'Diana', '2022-07-20', 'rural'), (5, 'Eli', '2022-1...
What is the total number of volunteers from rural areas who have volunteered in the last year?
SELECT COUNT(*) FROM volunteers WHERE location = 'rural' AND reg_date >= DATEADD(year, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (id INT, transaction_hash VARCHAR(255), gas_price INT, timestamp TIMESTAMP); INSERT INTO transactions (id, transaction_hash, gas_price, timestamp) VALUES (1, '0x123...', 10, '2022-02-01 00:00:00'), (2, '0x456...', 12, '2022-02-02 12:34:56'), (3, '0x789...', 8, '2022-02-09 14:23:01');
What is the average gas price for transactions in the last 30 days, segmented by day?
SELECT DATE(timestamp) as transaction_date, AVG(gas_price) as avg_gas_price FROM transactions WHERE timestamp >= DATE_SUB(NOW(), INTERVAL 30 DAY) GROUP BY transaction_date;
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (transaction_id INT, account_number INT, amount DECIMAL(10,2), transaction_date DATE); INSERT INTO transactions (transaction_id, account_number, amount, transaction_date) VALUES (1, 123456789, 100.00, '2022-01-05'), (2, 123456789, 200.00, '2022-01-10'), (3, 987654321, 50.00, '2022-02-15');
List all transactions for account number '123456789' in January 2022.
SELECT * FROM transactions WHERE account_number = 123456789 AND transaction_date BETWEEN '2022-01-01' AND '2022-01-31';
gretelai_synthetic_text_to_sql
CREATE TABLE whale_sightings (sighting_date DATE, location VARCHAR(255)); INSERT INTO whale_sightings (sighting_date, location) VALUES ('2021-06-15', 'Atlantic Ocean'), ('2022-03-02', 'Atlantic Ocean');
How many whale sightings were recorded in the Atlantic ocean in the last year?
SELECT COUNT(*) FROM whale_sightings WHERE location = 'Atlantic Ocean' AND sighting_date >= DATEADD(year, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE Terbium_Production (Year INT, Quantity INT); INSERT INTO Terbium_Production (Year, Quantity) VALUES (2016, 700), (2017, 750), (2018, 800), (2019, 850);
List the total production quantity of Terbium for each year it was produced.
SELECT Year, SUM(Quantity) FROM Terbium_Production GROUP BY Year;
gretelai_synthetic_text_to_sql
CREATE TABLE MilitaryEquipmentSales (id INT PRIMARY KEY, year INT, country VARCHAR(50), equipment VARCHAR(50), value FLOAT); INSERT INTO MilitaryEquipmentSales (id, year, country, equipment, value) VALUES (1, 2022, 'Saudi Arabia', 'Missiles', 1000000);
What is the minimum value of military equipment sales in a single transaction to the Middle East?
SELECT MIN(value) FROM MilitaryEquipmentSales WHERE country LIKE 'Middle East%';
gretelai_synthetic_text_to_sql
CREATE TABLE donations (donor_id INT, organization_id INT, amount DECIMAL(10,2), donation_date DATE); INSERT INTO donations (donor_id, organization_id, amount, donation_date) VALUES (1, 101, 500.00, '2022-04-01'), (2, 102, 350.00, '2022-04-15'), (3, 101, 200.00, '2022-04-30'), (1, 101, 50.00, '2022-07-05'), (2, 102, 10...
What is the number of unique donors who made a donation in Q2 2022 and also volunteered in Q3 2022?
SELECT COUNT(DISTINCT donor_id) as unique_donors FROM donations d1 WHERE EXTRACT(QUARTER FROM donation_date) = 2 AND donor_id IN (SELECT donor_id FROM donations d2 WHERE EXTRACT(QUARTER FROM donation_date) = 3);
gretelai_synthetic_text_to_sql
CREATE TABLE customer_size (id INT, name VARCHAR(50), size VARCHAR(20)); INSERT INTO customer_size (id, name, size) VALUES (1, 'David', 'L'); INSERT INTO customer_size (id, name, size) VALUES (2, 'Eva', 'M'); INSERT INTO customer_size (id, name, size) VALUES (3, 'Frank', 'S'); INSERT INTO customer_size (id, name, size)...
Find the least popular size among customers
SELECT size, COUNT(*) FROM customer_size GROUP BY size ORDER BY COUNT(*) ASC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE vehicle_efficiency (vehicle TEXT, rating FLOAT); INSERT INTO vehicle_efficiency (vehicle, rating) VALUES ('Car A', 8.0), ('Bus B', 6.5), ('Truck C', 4.0), ('Motorcycle D', 3.0);
What is the energy efficiency rating of vehicles in South Korea?
SELECT vehicle, rating FROM vehicle_efficiency WHERE vehicle IN ('Car A', 'Bus B', 'Truck C', 'Motorcycle D');
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_rates(location VARCHAR(50), date DATE, recycling_rate DECIMAL(5,2)); INSERT INTO recycling_rates(location, date, recycling_rate) VALUES ('California', '2022-01-01', 0.65), ('California', '2022-01-02', 0.67), ('California', '2022-01-03', 0.68), ('California', '2022-04-01', 0.70), ('California', '2...
What is the average recycling rate for residential areas in California over the last 3 months?
SELECT AVG(recycling_rate) FROM recycling_rates WHERE location = 'California' AND date BETWEEN '2022-01-01' AND '2022-03-31';
gretelai_synthetic_text_to_sql
CREATE TABLE military_sales_3 (id INT, region VARCHAR, year INT, value FLOAT);
Insert new record of military equipment sale to 'South America' in 2021
INSERT INTO military_sales_3 (id, region, year, value) VALUES (1, 'South America', 2021, 500000);
gretelai_synthetic_text_to_sql
CREATE TABLE Artist (ArtistID INT, ArtistName TEXT, Continent TEXT); INSERT INTO Artist (ArtistID, ArtistName, Continent) VALUES (1, 'Vincent Van Gogh', 'Europe');
Which artists have the most artwork entries in the database, grouped by continent?
SELECT Continent, ArtistName, COUNT(*) as ArtworkCount FROM Artist GROUP BY Continent, ArtistName ORDER BY Continent, COUNT(*) DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE education_programs (id INT, program_name VARCHAR(50), location VARCHAR(50), participants INT); INSERT INTO education_programs (id, program_name, location, participants) VALUES (1, 'Wildlife Conservation', 'New York', 100), (2, 'Habitat Restoration', 'Los Angeles', 150), (3, 'Bird Watching', 'Chicago', 75),...
List all the unique locations where 'Habitat Restoration' programs are being conducted from the 'education_programs' table?
SELECT DISTINCT location FROM education_programs WHERE program_name = 'Habitat Restoration'
gretelai_synthetic_text_to_sql
CREATE TABLE public_events (event_id INT, city VARCHAR(20), year INT, month INT, events_held INT); INSERT INTO public_events (event_id, city, year, month, events_held) VALUES (1, 'Los Angeles', 2021, 1, 10);
Determine the number of public events held in the city of Los Angeles in each month of the year 2021
SELECT month, SUM(events_held) FROM public_events WHERE city = 'Los Angeles' AND year = 2021 GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE Budget (year INT, cybersecurity_budget INT, other_budget INT); INSERT INTO Budget (year, cybersecurity_budget, other_budget) VALUES (2018, 5000000, 15000000); INSERT INTO Budget (year, cybersecurity_budget, other_budget) VALUES (2019, 5500000, 16000000);
What is the average budget for cybersecurity operations in the 'Budget' table?
SELECT AVG(cybersecurity_budget) FROM Budget;
gretelai_synthetic_text_to_sql
CREATE TABLE Budget(year INT, department VARCHAR(20), amount INT); INSERT INTO Budget VALUES (2021, 'Healthcare', 7000000), (2021, 'Education', 5000000), (2022, 'Healthcare', 7800000), (2022, 'Education', 5500000);
What was the total budget allocated for the 'Healthcare' department in the year 2021?
SELECT SUM(amount) FROM Budget WHERE department = 'Healthcare' AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (hotel_id INT, name TEXT, city TEXT, virtual_tour BOOLEAN);
What is the number of hotels in 'Rio de Janeiro' with virtual tours?
SELECT city, COUNT(*) as num_hotels FROM hotels WHERE city = 'Rio de Janeiro' AND virtual_tour = TRUE GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE explainability_scores (id INT PRIMARY KEY, algorithm_name VARCHAR(50), explanation_score INT, evaluation_date DATE);
Update records in the 'explainability_scores' table where the 'algorithm_name' is 'DL Algo 2' and the 'explanation_score' is less than 60
UPDATE explainability_scores SET explanation_score = explanation_score + 15 WHERE algorithm_name = 'DL Algo 2' AND explanation_score < 60;
gretelai_synthetic_text_to_sql
CREATE TABLE machinery (machinery_id INT, plant_id INT, machinery_type VARCHAR(50)); INSERT INTO machinery (machinery_id, plant_id, machinery_type) VALUES (1, 1, 'CNC Milling'), (2, 1, 'Lathe'), (3, 2, '3D Printer'), (4, 2, 'Injection Molding'), (5, 3, 'CNC Milling'), (6, 3, 'Lathe');
List all unique machinery types used in the 'Engineering' department across all plants.
SELECT DISTINCT machinery_type FROM machinery WHERE plant_id IN (SELECT plant_id FROM plants WHERE department = 'Engineering');
gretelai_synthetic_text_to_sql
CREATE TABLE smart_city_technology (tech_id INT, tech_name VARCHAR(100), adoption_date DATE); INSERT INTO smart_city_technology (tech_id, tech_name, adoption_date) VALUES (1, 'Smart Grid', '2020-03-15'), (2, 'Smart Lighting', '2019-08-01');
What is the latest smart city technology adoption date in the 'smart_city_technology' table?
SELECT MAX(adoption_date) FROM smart_city_technology;
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (ArtistID INT, Name TEXT);CREATE TABLE Artworks (ArtworkID INT, Title TEXT, Genre TEXT, ArtistID INT); INSERT INTO Artists (ArtistID, Name) VALUES (1, 'Pablo Picasso'); INSERT INTO Artworks (ArtworkID, Title, Genre, ArtistID) VALUES (1, 'Guernica', 'Cubism', 1), (2, 'The Old Guitarist', 'Blue Perio...
Delete all artworks by Pablo Picasso.
DELETE FROM Artworks WHERE ArtistID = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE news_articles (id INT, title VARCHAR(100), publication_date DATE, category VARCHAR(50)); INSERT INTO news_articles (id, title, publication_date, category) VALUES (1, 'Article 1', '2022-01-01', 'Politics'), (2, 'Article 2', '2022-01-02', 'Sports');
What is the distribution of articles by category in 'news_articles' table?
SELECT category, COUNT(*) as num_articles, ROW_NUMBER() OVER (ORDER BY COUNT(*) DESC) as rank FROM news_articles GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE posts (id INT, user_id INT, timestamp DATETIME, content TEXT, hashtags TEXT);
Insert a new post with the content 'Hello world!' and hashtags '#hello' and '#world' into the 'posts' table.
INSERT INTO posts (id, user_id, timestamp, content, hashtags) VALUES (1, 1, NOW(), 'Hello world!', '#hello #world');
gretelai_synthetic_text_to_sql
CREATE TABLE visitor_workshops (visitor_id INT, state VARCHAR(20), workshop_name VARCHAR(50)); INSERT INTO visitor_workshops (visitor_id, state, workshop_name) VALUES (1, 'California', 'Painting'), (2, 'New York', 'Sculpture'), (3, 'Texas', 'Digital Art');
How many visitors from California engaged with the digital museum's online workshops?
SELECT state, COUNT(*) as num_visitors FROM visitor_workshops WHERE state = 'California' GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE clients (id INT, registered_date DATE);CREATE TABLE investments (id INT, client_id INT, investment_date DATE); INSERT INTO clients (id, registered_date) VALUES (1, '2020-01-01'), (2, '2019-01-01'), (3, '2018-01-01'), (4, '2017-01-01'); INSERT INTO investments (id, client_id, investment_date) VALUES (1, 1, ...
What is the maximum number of investments made by a client in a single month?
SELECT client_id, MAX(COUNT(*)) FROM investments GROUP BY client_id, DATE_TRUNC('month', investment_date);
gretelai_synthetic_text_to_sql
CREATE TABLE garment_sales (sales_id INT PRIMARY KEY, garment_id INT, store_id INT, quantity INT, price DECIMAL(5,2), date DATE); CREATE TABLE garments (garment_id INT PRIMARY KEY, garment_name TEXT, garment_category TEXT, sustainability_score INT); INSERT INTO garments (garment_id, garment_name, garment_category, sust...
Which garment has the highest total sales quantity?
SELECT g.garment_name, SUM(gs.quantity) as total_quantity FROM garment_sales gs JOIN garments g ON gs.garment_id = g.garment_id GROUP BY g.garment_name ORDER BY total_quantity DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE AircraftDimensions (Model VARCHAR(50), Wingspan INT, FuselageLength INT); INSERT INTO AircraftDimensions (Model, Wingspan, FuselageLength) VALUES ('Boeing 747', 211, 232), ('Boeing 787 Dreamliner', 197, 186), ('Airbus A320', 118, 124), ('Airbus A380', 262, 245), ('Bombardier CRJ700', 91, 124);
Which aircraft models have a wingspan greater than their fuselage length?
SELECT Model FROM AircraftDimensions WHERE Wingspan > FuselageLength;
gretelai_synthetic_text_to_sql
CREATE TABLE countries (id INT, name VARCHAR(255), continent VARCHAR(255)); INSERT INTO countries (id, name, continent) VALUES (1, 'USA', 'North America'), (2, 'Canada', 'North America'), (3, 'Mexico', 'North America'), (4, 'Brazil', 'South America'), (5, 'Argentina', 'South America');
How many players from each continent play Non-VR games?
SELECT c.continent, COUNT(DISTINCT p.id) as num_players FROM players p JOIN player_games pg ON p.id = pg.player_id JOIN games g ON pg.game_id = g.id JOIN countries c ON p.country = c.name WHERE g.category = 'Non-VR' GROUP BY c.continent;
gretelai_synthetic_text_to_sql
CREATE SCHEMA SouthAmerica; CREATE TABLE MilitarySatellites (id INT, name VARCHAR(255), type VARCHAR(255), in_orbit BOOLEAN); INSERT INTO MilitarySatellites (id, name, type, in_orbit) VALUES (1, 'SGE-SC', 'Earth Observation', true); INSERT INTO MilitarySatellites (id, name, type, in_orbit) VALUES (2, 'GEO-I', 'Communic...
How many military satellites are there in the 'SouthAmerica' schema?
SELECT COUNT(*) FROM SouthAmerica.MilitarySatellites WHERE in_orbit = true;
gretelai_synthetic_text_to_sql
CREATE TABLE rural_hospitals (id INT, state VARCHAR(2), hospital_name VARCHAR(50), num_beds INT); INSERT INTO rural_hospitals (id, state, hospital_name, num_beds) VALUES (1, 'AK', 'Bartlett Regional Hospital', 72); CREATE TABLE states (state_abbr VARCHAR(2), state_name VARCHAR(20)); INSERT INTO states (state_abbr, stat...
What is the total number of rural hospitals in each state, and the average number of hospital beds?
SELECT r.state, COUNT(r.id) AS num_hospitals, AVG(r.num_beds) AS avg_beds FROM rural_hospitals r JOIN states s ON r.state = s.state_abbr GROUP BY r.state;
gretelai_synthetic_text_to_sql
CREATE TABLE workplace_data (workplace_id INT, workplace_name TEXT); CREATE TABLE collective_bargaining (agreement_status TEXT, workplace_id INT);
List all unique workplace names from the 'workplace_data' table that do not have any records in the 'collective_bargaining' table.
SELECT DISTINCT workplace_data.workplace_name FROM workplace_data LEFT JOIN collective_bargaining ON workplace_data.workplace_id = collective_bargaining.workplace_id WHERE collective_bargaining.workplace_id IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE attendee_demographics (attendee_id INT, attendee_name VARCHAR(50), attendee_gender VARCHAR(50)); INSERT INTO attendee_demographics (attendee_id, attendee_name, attendee_gender) VALUES (1, 'Jane Smith', 'Female'), (2, 'Michael Johnson', 'Male'), (3, 'Sophia Rodriguez', 'Female'); CREATE TABLE event_attendan...
How many female attendees were there at the 'Dance Recital'?
SELECT COUNT(*) FROM attendee_demographics ad JOIN event_attendance ea ON ad.attendee_id = ea.attendee_id WHERE attendee_gender = 'Female' AND event_name = 'Dance Recital';
gretelai_synthetic_text_to_sql
CREATE TABLE Patients (PatientID INT, Age INT, TetanusShot DATE, State TEXT); INSERT INTO Patients (PatientID, Age, TetanusShot, State) VALUES (1, 30, '2020-05-01', 'Florida');
What is the minimum age of patients who have had a tetanus shot in the last 10 years in Florida?
SELECT MIN(Age) FROM Patients WHERE TetanusShot >= DATEADD(year, -10, GETDATE()) AND State = 'Florida';
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, donor_name VARCHAR(50), donation_amount DECIMAL(10,2), donation_date DATE, category VARCHAR(50)); INSERT INTO donations (id, donor_name, donation_amount, donation_date, category) VALUES (1, 'John Doe', 100, '2022-01-01', 'Education'), (2, 'Jane Smith', 150, '2022-03-15', 'Health');
What is the total donation amount per category in Q1 2022?
SELECT category, SUM(donation_amount) as total_donation FROM donations WHERE donation_date BETWEEN '2022-01-01' AND '2022-03-31' GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE legaltech_patents (patent_id INT, filing_year INT, company VARCHAR(50)); INSERT INTO legaltech_patents (patent_id, filing_year, company) VALUES (1, 2019, 'TechCorp'), (2, 2020, 'LegalLabs'), (3, 2019, 'JusticeTech'), (4, 2018, 'TechCorp'), (5, 2020, 'JusticeTech');
List the top 5 legaltech patents filed by year, ordered by the number of patents filed
SELECT filing_year, COUNT(*) AS num_patents FROM legaltech_patents GROUP BY filing_year ORDER BY num_patents DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE drugs (id INT, name VARCHAR(255), category VARCHAR(255)); CREATE TABLE rd_expenditures (id INT, drug_id INT, amount DECIMAL(10, 2));
What is the average R&D expenditure for a specific drug category?
SELECT AVG(rd_expenditures.amount) FROM rd_expenditures JOIN drugs ON rd_expenditures.drug_id = drugs.id WHERE drugs.category = 'Pain Relievers';
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, country VARCHAR(255), followers INT); INSERT INTO users (id, country, followers) VALUES (1, 'Brazil', 1000), (2, 'USA', 2000), (3, 'Brazil', 3000), (4, 'USA', 4000);
What is the total number of followers for users in Brazil?
SELECT SUM(followers) FROM users WHERE country = 'Brazil';
gretelai_synthetic_text_to_sql
CREATE TABLE autonomous_buses (bus_id INT, city VARCHAR(20), in_operation BOOLEAN); INSERT INTO autonomous_buses (bus_id, city, in_operation) VALUES (1, 'New York', TRUE), (2, 'New York', FALSE), (3, 'Chicago', TRUE), (4, 'Chicago', TRUE), (5, 'Los Angeles', FALSE), (6, 'Los Angeles', TRUE);
How many autonomous buses are in operation in New York, Chicago, and Los Angeles?
SELECT city, COUNT(*) FROM autonomous_buses WHERE in_operation = TRUE GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE dapps (id INT, name TEXT, category TEXT, launch_date DATE); INSERT INTO dapps (id, name, category, launch_date) VALUES (1, 'AppA', 'DeFi', '2020-01-01'), (2, 'AppB', 'DeFi', '2019-06-15'), (3, 'AppC', 'NFT', '2021-03-20'); CREATE TABLE regulatory_frameworks (id INT, dapp_id INT, name TEXT, implementation_d...
List the regulatory frameworks for each decentralized application in the 'DeFi' category, ordered by the date of implementation.
SELECT d.name, r.name, r.implementation_date FROM dapps d JOIN regulatory_frameworks r ON d.id = r.dapp_id WHERE d.category = 'DeFi' ORDER BY r.implementation_date;
gretelai_synthetic_text_to_sql
CREATE TABLE golf_players (player_id INT, name VARCHAR(50), age INT); INSERT INTO golf_players (player_id, name, age) VALUES (1, 'Tiger Woods', 45); INSERT INTO golf_players (player_id, name, age) VALUES (2, 'Phil Mickelson', 51);
Who is the oldest athlete in the 'golf_players' table?
SELECT name, MAX(age) FROM golf_players;
gretelai_synthetic_text_to_sql
CREATE TABLE investments (region TEXT, year INT, amount FLOAT); INSERT INTO investments (region, year, amount) VALUES ('Asia', 2010, 100000); INSERT INTO investments (region, year, amount) VALUES ('South America', 2010, 50000);
What's the total investment in climate communication in Asia and South America from 2010 to 2020?
SELECT SUM(amount) FROM investments WHERE region IN ('Asia', 'South America') AND year BETWEEN 2010 AND 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE wind_energy (country VARCHAR(20), installed_capacity INT); INSERT INTO wind_energy (country, installed_capacity) VALUES ('Germany', 60000), ('France', 45000);
What is the total installed capacity of wind energy in Germany and France, and which one has a higher capacity?
SELECT w1.country, SUM(w1.installed_capacity) as total_capacity FROM wind_energy w1 WHERE w1.country IN ('Germany', 'France') GROUP BY w1.country;
gretelai_synthetic_text_to_sql
CREATE TABLE sustainable_tourism (tourism_id INT, location VARCHAR(50), economic_impact INT); INSERT INTO sustainable_tourism VALUES (1, 'Maasai Mara', 15000), (2, 'Victoria Falls', 20000), (3, 'Sahara Desert', 10000), (4, 'Serengeti', 25000);
What is the sum of economic impact of sustainable tourism in Africa?
SELECT SUM(economic_impact) FROM sustainable_tourism WHERE location LIKE '%Africa%';
gretelai_synthetic_text_to_sql
CREATE TABLE Exhibitions (id INT, name TEXT, genre TEXT, visitor_count INT);
Find the exhibition with the highest visitor count in the 'Renaissance' genre.
SELECT name, visitor_count FROM (SELECT name, visitor_count, ROW_NUMBER() OVER (PARTITION BY genre ORDER BY visitor_count DESC) as rn FROM Exhibitions WHERE genre = 'Renaissance') t WHERE rn = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE SpaceLaunchs (LaunchID INT, Country VARCHAR(50), SatelliteID INT); INSERT INTO SpaceLaunchs (LaunchID, Country, SatelliteID) VALUES (1, 'USA', 101), (2, 'Russia', 201), (3, 'China', 301), (4, 'India', 401), (5, 'Japan', 501);
What is the total number of satellites launched by country in the SpaceLaunchs table?
SELECT Country, COUNT(SatelliteID) AS TotalSatellites FROM SpaceLaunchs GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE treatments (id INT PRIMARY KEY, patient_id INT, name VARCHAR(255), duration INT); INSERT INTO treatments (id, patient_id, name, duration) VALUES (1, 3, 'Psychotherapy', 20);
What is the treatment duration for the patient with ID 3?
SELECT duration FROM treatments WHERE patient_id = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE wildlife (region VARCHAR(50), species VARCHAR(50), conservation_status VARCHAR(50)); INSERT INTO wildlife (region, species, conservation_status) VALUES ('North America', 'Grizzly Bear', 'Vulnerable'), ('North America', 'Caribou', 'Threatened'), ('South America', 'Jaguar', 'Near Threatened');
How many wildlife species are present in each region and their conservation status?
SELECT region, COUNT(species) as species_count, STRING_AGG(conservation_status, ',') as conservation_status FROM wildlife GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE TrafficViolations (id INT, violation_type VARCHAR(50), location VARCHAR(50), fine DECIMAL(5,2)); INSERT INTO TrafficViolations (id, violation_type, location, fine) VALUES (1, 'Speeding', 'School Zone', 100), (2, 'Illegal Parking', 'Business District', 50), (3, 'Speeding', 'Residential Area', 80), (4, 'Runn...
What is the total number of traffic violations in the "TrafficViolations" table, per type of violation, for violations that occurred in school zones?
SELECT violation_type, COUNT(*) as num_violations FROM TrafficViolations WHERE location LIKE '%School%' GROUP BY violation_type;
gretelai_synthetic_text_to_sql
CREATE TABLE mental_health_facilities (id INT, name VARCHAR, state VARCHAR, cultural_competency_score INT); INSERT INTO mental_health_facilities (id, name, state, cultural_competency_score) VALUES (1, 'Facility One', 'California', 85); INSERT INTO mental_health_facilities (id, name, state, cultural_competency_score) VA...
What is the average cultural competency score for mental health facilities in California?
SELECT state, AVG(cultural_competency_score) as avg_score FROM mental_health_facilities WHERE state = 'California' GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE social_impact_investments (id INT, country VARCHAR(50), transaction_value FLOAT); INSERT INTO social_impact_investments (id, country, transaction_value) VALUES (1, 'United States', 5000.0), (2, 'Canada', 7000.0), (3, 'United Kingdom', 10000.0), (4, 'Germany', 3000.0);
What is the minimum transaction value for social impact investments in Germany?
SELECT MIN(transaction_value) FROM social_impact_investments WHERE country = 'Germany';
gretelai_synthetic_text_to_sql
CREATE TABLE landfill_capacity (id INT, date DATE, capacity INT); INSERT INTO landfill_capacity (id, date, capacity) VALUES (1, '2021-01-01', 10000), (2, '2021-02-01', 9500), (3, '2021-03-01', 9200), (4, '2021-04-01', 8900);
Delete landfill capacity data for January 2021.
DELETE FROM landfill_capacity WHERE date = '2021-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE fan_demographics (age INT, gender VARCHAR(10), location VARCHAR(20));
Insert a new record into the 'fan_demographics' table with age 35, gender 'Female' and location 'California'
INSERT INTO fan_demographics (age, gender, location) VALUES (35, 'Female', 'California');
gretelai_synthetic_text_to_sql
CREATE TABLE Site (SiteID VARCHAR(10), SiteName VARCHAR(20)); INSERT INTO Site (SiteID, SiteName) VALUES ('F', 'Site F'); CREATE TABLE Artifact (ArtifactID VARCHAR(10), SiteID VARCHAR(10), Weight FLOAT); INSERT INTO Artifact (ArtifactID, SiteID, Weight) VALUES ('1', 'F', 12.3), ('2', 'F', 15.6), ('3', 'F', 18.9), ('4',...
What is the maximum weight of artifacts excavated from 'Site F'?
SELECT MAX(Weight) FROM Artifact WHERE SiteID = 'F';
gretelai_synthetic_text_to_sql
CREATE TABLE movies (id INT, title VARCHAR(255), release_year INT, director VARCHAR(255), rating DECIMAL(3,2));
What is the average rating of movies by director?
SELECT director, AVG(rating) as avg_rating FROM movies GROUP BY director;
gretelai_synthetic_text_to_sql
CREATE TABLE countries (id INT, name TEXT, region TEXT); INSERT INTO countries (id, name, region) VALUES (1, 'Country1', 'Africa'), (2, 'Country2', 'Asia'), (3, 'Country3', 'Europe'); CREATE TABLE military_humanitarian_assistance (id INT, country_id INT, year INT); INSERT INTO military_humanitarian_assistance (id, coun...
Which countries received military humanitarian assistance in 2020?
SELECT DISTINCT countries.name FROM countries JOIN military_humanitarian_assistance ON countries.id = military_humanitarian_assistance.country_id WHERE military_humanitarian_assistance.year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE dish_prep_times (id INT, dish_id INT, prep_time INT); CREATE TABLE dishes (id INT, name TEXT, is_vegan BOOLEAN);
What are the average preparation times for vegan dishes compared to non-vegan dishes?
SELECT AVG(prep_time) as avg_prep_time FROM dish_prep_times JOIN dishes ON dish_prep_times.dish_id = dishes.id WHERE dishes.is_vegan = true; SELECT AVG(prep_time) as avg_prep_time FROM dish_prep_times JOIN dishes ON dish_prep_times.dish_id = dishes.id WHERE dishes.is_vegan = false;
gretelai_synthetic_text_to_sql
CREATE TABLE Menu (menu_id INT, menu_name VARCHAR(20)); INSERT INTO Menu (menu_id, menu_name) VALUES (1, 'Vegan'), (2, 'Non-Vegan'); CREATE TABLE Menu_Ingredients (ingredient_id INT, ingredient_cost FLOAT, menu_id INT); INSERT INTO Menu_Ingredients (ingredient_id, ingredient_cost, menu_id) VALUES (1, 5.0, 1), (2, 3.5, ...
What is the total cost of ingredients for the vegan menu?
SELECT SUM(ingredient_cost) FROM Menu_Ingredients WHERE menu_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Subscribers (subscriber_id INT, service VARCHAR(20), region VARCHAR(20), revenue FLOAT, payment_date DATE);
Insert a new subscriber for the 'Mobile' service in the 'Rural' region with a revenue of 25.00 in Q3 of 2022.
INSERT INTO Subscribers (subscriber_id, service, region, revenue, payment_date) VALUES (6, 'Mobile', 'Rural', 25.00, '2022-10-01');
gretelai_synthetic_text_to_sql
CREATE TABLE LandfillCapacity (country VARCHAR(255), landfill_capacity_cubic_meters DECIMAL(15,2), region VARCHAR(255)); INSERT INTO LandfillCapacity (country, landfill_capacity_cubic_meters, region) VALUES ('Japan', 45000000.0, 'Asia'), ('China', 75000000.0, 'Asia'), ('India', 55000000.0, 'Asia');
What is the total landfill capacity in cubic meters for Asia?
SELECT SUM(landfill_capacity_cubic_meters) FROM LandfillCapacity WHERE region = 'Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE water_usage (location VARCHAR(255), usage INT);
Insert new records into the water_usage table
INSERT INTO water_usage (location, usage) VALUES ('City D', 30), ('City E', 40);
gretelai_synthetic_text_to_sql
CREATE TABLE high_data_users (subscriber_id INT, name VARCHAR(50), data_usage_gb FLOAT); INSERT INTO high_data_users (subscriber_id, name, data_usage_gb) VALUES (13, 'Kai Lewis', 12); INSERT INTO high_data_users (subscriber_id, name, data_usage_gb) VALUES (14, 'Lila Clark', 15);
Update mobile subscribers' data plans if they have used more than 10GB of data in the last week.
UPDATE mobile_subscribers M SET data_plan = 'Unlimited' FROM mobile_subscribers M INNER JOIN high_data_users H ON M.subscriber_id = H.subscriber_id WHERE M.data_plan != 'Unlimited' AND H.data_usage_gb > 10;
gretelai_synthetic_text_to_sql
CREATE TABLE biomes (biome_id INT PRIMARY KEY, name VARCHAR(50), area_km2 FLOAT); INSERT INTO biomes (biome_id, name, area_km2) VALUES (1, 'Tropical Rainforest', 15000000.0), (2, 'Temperate Rainforest', 250000.0), (3, 'Boreal Forest', 12000000.0); CREATE TABLE trees (tree_id INT PRIMARY KEY, species VARCHAR(50), biome_...
What is the average DBH for trees in the tropical rainforest that belong to the Dipterocarpaceae family?
SELECT AVG(dbh) FROM trees WHERE trees.family = 'Dipterocarpaceae' AND biomes.name = 'Tropical Rainforest';
gretelai_synthetic_text_to_sql
CREATE TABLE MiningEnvironmentalImpact (year INT, company TEXT, country TEXT, impact_assessment_score INT); INSERT INTO MiningEnvironmentalImpact (year, company, country, impact_assessment_score) VALUES (2020, 'Canada Gold Corp', 'Canada', 80), (2021, 'Canada Gold Corp', 'Canada', 85), (2020, 'Australian Mining Inc', '...
What are the top 3 countries with the highest environmental impact assessments for mining companies, for the last 2 years?
SELECT context.country, SUM(context.impact_assessment_score) as total_impact_score FROM MiningEnvironmentalImpact context WHERE context.year BETWEEN 2020 AND 2021 GROUP BY context.country ORDER BY total_impact_score DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE intelligence_operations (id INT, name VARCHAR(50), location VARCHAR(50), year INT); INSERT INTO intelligence_operations (id, name, location, year) VALUES (1, 'Operation Red Sword', 'Middle East', 2018);
How many intelligence operations were conducted in the Middle East and North Africa between 2015 and 2020?
SELECT COUNT(*) FROM intelligence_operations WHERE location IN ('Middle East', 'North Africa') AND year BETWEEN 2015 AND 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE excavation_sites (site_id INT, site_name VARCHAR(255)); INSERT INTO excavation_sites (site_id, site_name) VALUES (1, 'Peruvian Ruins'), (2, 'Brazilian Dig'), (3, 'Argentine Excavation'); CREATE TABLE artifacts (artifact_id INT, artifact_name VARCHAR(255), site_id INT, artifact_weight FLOAT, artifact_materi...
What is the count of stone artifacts from excavation sites in South America?
SELECT COUNT(*) FROM artifacts JOIN excavation_sites ON artifacts.site_id = excavation_sites.site_id WHERE excavation_sites.site_name LIKE '%South America%' AND artifacts.artifact_material = 'Stone';
gretelai_synthetic_text_to_sql
CREATE TABLE community_policing (policing_type VARCHAR(255), frequency INT, location VARCHAR(255));
Create a view to display the total number of community policing activities by location
CREATE VIEW total_policing_activities AS SELECT location, SUM(frequency) as total_frequency FROM community_policing GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE Exhibitions (ExhibitionID INT, ExhibitionName VARCHAR(100), City VARCHAR(50)); CREATE TABLE Visits (VisitID INT, ExhibitionID INT, VisitorID INT); INSERT INTO Exhibitions (ExhibitionID, ExhibitionName, City) VALUES (1, 'Mona Lisa', 'Paris'), (2, 'Starry Night', 'Amsterdam'), (3, 'Sunflowers', 'Amsterdam'),...
Find the top 3 most visited exhibitions by city and the number of visitors?
SELECT City, ExhibitionName, COUNT(VisitorID) AS NumberOfVisitors FROM Exhibitions A JOIN Visits B ON A.ExhibitionID = B.ExhibitionID GROUP BY City, ExhibitionName ORDER BY City, NumberOfVisitors DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE product (product_id INT, product_name TEXT); CREATE TABLE ingredient (ingredient_id INT, product_id INT, weight FLOAT, country TEXT); INSERT INTO product VALUES (1, 'Lipstick'), (2, 'Moisturizer'); INSERT INTO ingredient VALUES (1, 1, 50.0, 'CA'), (2, 1, 25.0, 'US'), (3, 2, 30.0, 'CA');
What is the total weight of all ingredients for each product?
SELECT p.product_name, SUM(i.weight) FROM product p JOIN ingredient i ON p.product_id = i.product_id GROUP BY p.product_name;
gretelai_synthetic_text_to_sql
CREATE TABLE crops (id INT, crop_name VARCHAR(20), country VARCHAR(20), production INT, year INT); INSERT INTO crops (id, crop_name, country, production, year) VALUES (1, 'wheat', 'USA', 50000, 2020), (2, 'rice', 'China', 60000, 2020);
What is the total production of 'wheat' and 'rice' for each country in 2020, sorted by production amount?
SELECT country, SUM(production) as total_production FROM crops WHERE crop_name IN ('wheat', 'rice') AND year = 2020 GROUP BY country ORDER BY total_production DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE IF NOT EXISTS humanitarian_assistance (id INT PRIMARY KEY, year INT, num_missions INT);
How many humanitarian assistance missions were conducted by year?
SELECT year, SUM(num_missions) FROM humanitarian_assistance GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE investors(id INT, name TEXT, region TEXT, socially_responsible BOOLEAN); CREATE TABLE investments(id INT, investor_id INT, startup_id INT, investment_amount FLOAT); INSERT INTO investors (id, name, region, socially_responsible) VALUES (1, 'Pedro Alvarez', 'Latin America', true); INSERT INTO investors (id, ...
List the total investment made by socially responsible investors from Latin America
SELECT SUM(investment_amount) FROM investments i JOIN investors a ON i.investor_id = a.id WHERE a.region = 'Latin America' AND a.socially_responsible = true;
gretelai_synthetic_text_to_sql
CREATE TABLE deep_sea_expeditions (id INT, name TEXT, organization TEXT, max_depth FLOAT); INSERT INTO deep_sea_expeditions (id, name, organization, max_depth) VALUES (1, 'Expedition 1', 'Ocean Explorers', 8000.0), (2, 'Expedition 2', 'Ocean Researchers', 10000.0), (3, 'Expedition 3', 'Ocean Explorers', 6000.0);
What is the average depth of all deep-sea expeditions led by the 'Ocean Explorers' organization?
SELECT AVG(max_depth) FROM deep_sea_expeditions WHERE organization = 'Ocean Explorers';
gretelai_synthetic_text_to_sql
CREATE TABLE drug_sales (drug_name TEXT, year INTEGER, sales INTEGER, market TEXT); INSERT INTO drug_sales (drug_name, year, sales, market) VALUES ('DrugA', 2018, 3000000, 'US'); INSERT INTO drug_sales (drug_name, year, sales, market) VALUES ('DrugB', 2018, 1500000, 'Canada'); INSERT INTO drug_sales (drug_name, year, s...
What is the earliest approval date for drugs that have a sales figure greater than 2000000 in any market?
SELECT MIN(drug_approval.approval_date) FROM drug_approval JOIN drug_sales ON drug_approval.drug_name = drug_sales.drug_name WHERE drug_sales.sales > 2000000;
gretelai_synthetic_text_to_sql
CREATE TABLE water_usage ( date DATE, usage_category VARCHAR(20), region VARCHAR(20), usage_amount INT ); INSERT INTO water_usage (date, usage_category, region, usage_amount) VALUES ( '2022-07-01', 'Residential', 'Northeast', 15000), ('2022-07-02', 'Industrial', 'Midwest', 200000), ('2022-07-03', 'Agricultural', 'West'...
Find the water usage data with the highest usage amount in the water_usage table
SELECT * FROM water_usage WHERE usage_amount = (SELECT MAX(usage_amount) FROM water_usage);
gretelai_synthetic_text_to_sql
CREATE TABLE sustainable_urbanism (property_id INT, size FLOAT, location VARCHAR(255)); INSERT INTO sustainable_urbanism (property_id, size, location) VALUES (1, 1200, 'Eco City'), (2, 1500, 'Green Valley');
Which properties in the sustainable_urbanism table have a size larger than the average property size?
SELECT * FROM sustainable_urbanism WHERE size > (SELECT AVG(size) FROM sustainable_urbanism);
gretelai_synthetic_text_to_sql
CREATE TABLE Mining_Operation (Operation_ID INT, Mine_Name VARCHAR(50), Location VARCHAR(50), Operation_Type VARCHAR(50), Start_Date DATE, End_Date DATE); CREATE TABLE Environmental_Impact (Impact_ID INT, Operation_ID INT, Date DATE, Carbon_Emissions INT, Water_Usage INT, Waste_Generation INT);
Rank the mining operations with the highest carbon emissions in the past year.
SELECT Operation_ID, Mine_Name, Carbon_Emissions, RANK() OVER (ORDER BY SUM(Carbon_Emissions) DESC) AS Carbon_Emissions_Rank FROM Environmental_Impact JOIN Mining_Operation ON Environmental_Impact.Operation_ID = Mining_Operation.Operation_ID WHERE Date >= DATEADD(year, -1, GETDATE()) GROUP BY Operation_ID, Mine_Name;
gretelai_synthetic_text_to_sql
CREATE TABLE cybersecurity_strategies (id INT PRIMARY KEY, strategy VARCHAR(50), cost INT, sector VARCHAR(50), year INT); INSERT INTO cybersecurity_strategies (id, strategy, cost, sector, year) VALUES (5, 'Encryption', 75000, 'Public', 2019); INSERT INTO cybersecurity_strategies (id, strategy, cost, sector, year) VALUE...
What is the average cost of cybersecurity strategies for each sector in 2019?
SELECT sector, AVG(cost) as avg_cost FROM cybersecurity_strategies WHERE year = 2019 GROUP BY sector;
gretelai_synthetic_text_to_sql
CREATE TABLE FishTank (date DATE, temperature FLOAT); INSERT INTO FishTank (date, temperature) VALUES ('2022-01-01', 20.5), ('2022-01-02', 21.0), ('2022-01-03', 21.5), ('2022-02-14', 20.0);
Update the water temperature for February 14, 2022, to 22.3 degrees in the FishTank table.
UPDATE FishTank SET temperature = 22.3 WHERE date = '2022-02-14';
gretelai_synthetic_text_to_sql
CREATE TABLE public_schools (id INT, name TEXT, location TEXT, num_students INT, avg_teacher_age FLOAT); INSERT INTO public_schools (id, name, location, num_students, avg_teacher_age) VALUES (1, 'School 1', 'NY', 500, 45.3), (2, 'School 2', 'NY', 600, 43.2);
What is the average age of teachers in New York public schools?
SELECT AVG(avg_teacher_age) FROM public_schools WHERE location = 'NY';
gretelai_synthetic_text_to_sql
CREATE TABLE shared_scooters (scooter_id INT, company VARCHAR(255), speed FLOAT, timestamp TIMESTAMP); INSERT INTO shared_scooters (scooter_id, company, speed, timestamp) VALUES (1, 'CompanyA', 15.5, '2022-01-01 10:00:00'), (2, 'CompanyB', 14.3, '2022-01-01 10:00:00');
What is the average speed of shared electric scooters in San Francisco, partitioned by company?
SELECT company, AVG(speed) AS avg_speed FROM (SELECT company, speed, TIMESTAMP_TRUNC(timestamp, HOUR) AS truncated_time, ROW_NUMBER() OVER (PARTITION BY company, TIMESTAMP_TRUNC(timestamp, HOUR) ORDER BY timestamp) rn FROM shared_scooters WHERE city = 'San Francisco') WHERE rn = 1 GROUP BY company;
gretelai_synthetic_text_to_sql
CREATE TABLE shipping_companies (company_id INT, name VARCHAR(255)); INSERT INTO shipping_companies (company_id, name) VALUES (1, 'Pacific Shipping Company'); CREATE TABLE cargo_ships (ship_id INT, company_id INT, capacity INT); INSERT INTO cargo_ships (ship_id, company_id, capacity) VALUES (1, 1, 15000), (2, 1, 18000)...
What is the total capacity of all cargo ships owned by Pacific Shipping Company?
SELECT SUM(capacity) FROM cargo_ships WHERE company_id = (SELECT company_id FROM shipping_companies WHERE name = 'Pacific Shipping Company');
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (ArtistID INT, Name TEXT, Country TEXT);CREATE TABLE Artworks (ArtworkID INT, Title TEXT, ArtistID INT);CREATE TABLE GalleryArtworks (GalleryID INT, ArtworkID INT);CREATE TABLE GalleryLocations (GalleryID INT, Country TEXT);
List all artworks that have been created by artists from Africa and are on display in Europe.
SELECT Artworks.Title FROM Artists INNER JOIN Artworks ON Artworks.ArtistID = Artists.ArtistID INNER JOIN GalleryArtworks ON Artworks.ArtworkID = GalleryArtworks.ArtworkID INNER JOIN GalleryLocations ON GalleryArtworks.GalleryID = GalleryLocations.GalleryID WHERE Artists.Country = 'Africa' AND GalleryLocations.Country ...
gretelai_synthetic_text_to_sql
CREATE TABLE UnionP(member_id INT, job_title VARCHAR(20)); INSERT INTO UnionP(member_id, job_title) VALUES(16001, 'Developer'), (16002, 'Developer'), (16003, 'Designer'), (16004, 'Tester'), (16005, 'Designer');
List all unique job titles in Union 'P' with more than 25 members.
SELECT DISTINCT job_title FROM UnionP GROUP BY job_title HAVING COUNT(*) > 25;
gretelai_synthetic_text_to_sql
CREATE TABLE hospitals (id INT, name VARCHAR(50), location VARCHAR(50)); INSERT INTO hospitals (id, name, location) VALUES (1, 'Hospital A', 'City A'); INSERT INTO hospitals (id, name, location) VALUES (2, 'Hospital B', 'City B'); CREATE TABLE clinics (id INT, name VARCHAR(50), location VARCHAR(50)); INSERT INTO clinic...
What is the total number of hospitals and clinics in the public health database?
SELECT COUNT(*) FROM hospitals UNION SELECT COUNT(*) FROM clinics;
gretelai_synthetic_text_to_sql