context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE fleet_management (id INT PRIMARY KEY, cargo_id INT, status VARCHAR(20), destination VARCHAR(20));
Insert a new record in table fleet_management with cargo_id 105 and status as 'loaded'
INSERT INTO fleet_management (cargo_id, status) VALUES (105, 'loaded');
gretelai_synthetic_text_to_sql
CREATE TABLE patients (id INT, name TEXT, age INT, therapy TEXT); INSERT INTO patients (id, name, age, therapy) VALUES (1, 'Alice', 30, 'CBT'), (2, 'Bob', 45, 'DBT'), (3, 'Charlie', 60, 'CBT'), (4, 'David', 50, 'CBT'), (5, 'Eve', 55, 'DBT');
How many patients have received therapy in total?
SELECT COUNT(*) FROM patients WHERE therapy IS NOT NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE Funding (source TEXT, budget INT); CREATE TABLE Operations (name TEXT, source TEXT); INSERT INTO Funding (source, budget) VALUES ('United Nations', 3000000), ('European Union', 2500000), ('Red Cross', 2000000); INSERT INTO Operations (name, source) VALUES ('Operation Provide Comfort', 'United Nations'), ('Operation Restore Hope', 'European Union'), ('Operation Lifeline', 'Red Cross');
Display the name of the humanitarian assistance operations and their corresponding funding sources from the 'Funding' and 'Operations' tables
SELECT Operations.name, Funding.source FROM Operations INNER JOIN Funding ON Operations.source = Funding.source;
gretelai_synthetic_text_to_sql
CREATE TABLE Warehouse (id INT, location VARCHAR(255), capacity INT); INSERT INTO Warehouse (id, location, capacity) VALUES (1, 'New York', 500), (2, 'Toronto', 700), (3, 'Montreal', 600); CREATE TABLE Shipment (id INT, warehouse_id INT, delivery_time INT); INSERT INTO Shipment (id, warehouse_id, delivery_time) VALUES (1, 1, 5), (2, 2, 3), (3, 3, 4), (4, 1, 6), (5, 2, 7), (6, 3, 8);
Find the number of shipments and total delivery time for each warehouse, partitioned by location?
SELECT warehouse_id, location, COUNT(*) as num_shipments, SUM(delivery_time) as total_delivery_time, RANK() OVER (PARTITION BY location ORDER BY SUM(delivery_time) DESC) as rank FROM Shipment JOIN Warehouse ON Shipment.warehouse_id = Warehouse.id GROUP BY warehouse_id, location;
gretelai_synthetic_text_to_sql
CREATE TABLE wells (well_id INT, well_type VARCHAR(10), location VARCHAR(20), production_rate FLOAT); INSERT INTO wells (well_id, well_type, location, production_rate) VALUES (1, 'offshore', 'Gulf of Mexico', 1000), (2, 'onshore', 'Texas', 800), (3, 'offshore', 'North Sea', 1200);
Find the well with the highest production rate.
SELECT * FROM (SELECT well_id, well_type, location, production_rate, ROW_NUMBER() OVER (ORDER BY production_rate DESC) rn FROM wells) t WHERE rn = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE impact_investments (id INT, investment_id INT, value FLOAT); INSERT INTO impact_investments (id, investment_id, value) VALUES (1, 1001, 12000000), (2, 1002, 10000000), (3, 1003, 15000000), (4, 1004, 8000000), (5, 1005, 11000000);
List the top 5 impact investments in terms of value.
SELECT * FROM impact_investments ORDER BY value DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE restaurants (restaurant_id INT PRIMARY KEY, name VARCHAR(255), rating INT);
Create a view for the top 5 restaurants by rating
CREATE VIEW top_5_restaurants AS SELECT * FROM restaurants WHERE rating > 4 ORDER BY rating DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE tickets (ticket_id INT, game_id INT, region VARCHAR(50), quantity INT); INSERT INTO tickets (ticket_id, game_id, region, quantity) VALUES (1, 1, 'Midwest', 500); INSERT INTO tickets (ticket_id, game_id, region, quantity) VALUES (2, 2, 'Northeast', 700); CREATE TABLE games (game_id INT, sport VARCHAR(50)); INSERT INTO games (game_id, sport) VALUES (1, 'Football'); INSERT INTO games (game_id, sport) VALUES (2, 'Basketball');
What is the maximum number of tickets sold for any individual game?
SELECT MAX(quantity) FROM tickets;
gretelai_synthetic_text_to_sql
CREATE TABLE life_expectancy (state VARCHAR(2), years FLOAT); INSERT INTO life_expectancy (state, years) VALUES ('NY', 80.5), ('NJ', 81.3), ('CA', 80.2), ('FL', 79.6), ('TX', 78.9);
Which states have the lowest and highest life expectancy, and what are their respective values?
SELECT state, MAX(years) as max_years, MIN(years) as min_years FROM life_expectancy GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE Inmates (ID INT, Facility VARCHAR(20), Bail FLOAT); INSERT INTO Inmates (ID, Facility, Bail) VALUES (1, 'Facility1', 5000.0), (2, 'Facility2', 7500.0), (3, 'Facility1', 10000.0);
What is the total bail amount set for inmates in each facility?
SELECT Facility, SUM(Bail) OVER (PARTITION BY Facility) AS TotalBail FROM Inmates;
gretelai_synthetic_text_to_sql
CREATE TABLE menu (menu_id INT, menu_name VARCHAR(50), category VARCHAR(50), ingredient VARCHAR(50), price DECIMAL(5,2), month_sold INT); INSERT INTO menu (menu_id, menu_name, category, ingredient, price, month_sold) VALUES (14, 'Organic Green Smoothie', 'Drinks', 'Organic', 6.99, 1), (15, 'Organic Iced Tea', 'Drinks', 'Organic', 5.49, 1);
What is the maximum price of a menu item in the 'Drinks' category from the 'Organic' ingredient type?
SELECT MAX(price) FROM menu WHERE category = 'Drinks' AND ingredient = 'Organic';
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, DonorName VARCHAR(255)); CREATE TABLE DonationCategories (CategoryID INT, CategoryName VARCHAR(255)); CREATE TABLE Donations (DonationID INT, DonorID INT, CategoryID INT, DonationAmount DECIMAL(10, 2));
What is the percentage of the total donation amount for each donation category, and which category has the highest percentage?
SELECT CategoryName, SUM(DonationAmount) AS TotalDonations, (SUM(DonationAmount) * 100.0 / (SELECT SUM(DonationAmount) FROM Donations)) AS Percentage FROM Donors JOIN Donations ON Donors.DonorID = Donations.DonorID JOIN DonationCategories ON Donations.CategoryID = DonationCategories.CategoryID GROUP BY CategoryName ORDER BY Percentage DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE cotton_farming (country VARCHAR(50), region VARCHAR(50), total_production INT, water_usage INT); INSERT INTO cotton_farming (country, region, total_production, water_usage) VALUES ('Egypt', 'Africa', 12000, 2500), ('Ethiopia', 'Africa', 15000, 3000), ('Tanzania', 'Africa', 10000, 2000);
What is the average water usage in the 'cotton_farming' sector in 'Africa'?
SELECT AVG(water_usage) FROM cotton_farming WHERE region = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE cases (case_id INT, attorney_name TEXT); INSERT INTO cases (case_id, attorney_name) VALUES (1, 'Alice Smith'), (2, 'Bob Johnson'), (3, 'Bob Johnson'), (4, 'Charlie Brown');
What is the total number of cases handled by attorney 'Alice Smith'?
SELECT COUNT(*) FROM cases WHERE attorney_name = 'Alice Smith';
gretelai_synthetic_text_to_sql
CREATE TABLE startups(id INT, name VARCHAR(50), sector VARCHAR(50), total_funding FLOAT);INSERT INTO startups (id, name, sector, total_funding) VALUES (1, 'StartupA', 'Genetics', 20000000);INSERT INTO startups (id, name, sector, total_funding) VALUES (2, 'StartupB', 'Bioprocess', NULL);
Identify the biotech startups that have not yet received any funding.
SELECT name FROM startups WHERE total_funding IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE av_testing (id INT PRIMARY KEY, company VARCHAR(255), model VARCHAR(255), city VARCHAR(255), state VARCHAR(255), country VARCHAR(255), test_miles FLOAT); INSERT INTO av_testing (id, company, model, city, state, country, test_miles) VALUES (1, 'Waymo', 'Waymo One', 'Phoenix', 'Arizona', 'USA', 1000000);
Show all records from the autonomous vehicle testing table
SELECT * FROM av_testing;
gretelai_synthetic_text_to_sql
CREATE TABLE Revenues (revenue_id INT, event_id INT, amount DECIMAL(10,2)); INSERT INTO Revenues (revenue_id, event_id, amount) VALUES (1, 1, 5000.00), (2, 5, 3000.00);
What is the total revenue generated from 'Art Exhibition' and 'Photography Workshop' events?
SELECT SUM(amount) FROM Revenues WHERE event_id IN (1, 5);
gretelai_synthetic_text_to_sql
CREATE TABLE investments (investment_id INT, customer_id INT, region VARCHAR(20), investment_amount DECIMAL(10,2)); INSERT INTO investments (investment_id, customer_id, region, investment_amount) VALUES (1, 3, 'North', 10000.00), (2, 4, 'South', 15000.00);
What is the sum of all socially responsible investments held by customers in the North region?
SELECT SUM(investment_amount) FROM investments WHERE region = 'North' AND product_type = 'Socially Responsible Investment';
gretelai_synthetic_text_to_sql
CREATE TABLE methods (id INT, item_id INT, quantity INT, method VARCHAR(255)); INSERT INTO methods (id, item_id, quantity, method) VALUES (1, 1, 100, 'circular'), (2, 2, 75, 'circular'), (3, 1, 50, 'linear');
Find the average quantity of items produced using circular economy methods
SELECT AVG(quantity) FROM methods WHERE method = 'circular';
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (VolunteerID INT, VolunteerName TEXT, Program TEXT); INSERT INTO Volunteers (VolunteerID, VolunteerName, Program) VALUES (1, 'Alice', 'Education'), (2, 'Bob', 'Health'), (3, 'Charlie', 'Education'); CREATE TABLE VolunteerHours (VolunteerID INT, Hours INT); INSERT INTO VolunteerHours (VolunteerID, Hours) VALUES (1, 120), (1, 130), (2, 80), (3, 110), (3, 120);
What is the total number of volunteer hours for each program?
SELECT Volunteers.Program, SUM(VolunteerHours.Hours) FROM Volunteers JOIN VolunteerHours ON Volunteers.VolunteerID = VolunteerHours.VolunteerID GROUP BY Volunteers.Program;
gretelai_synthetic_text_to_sql
CREATE TABLE wildlife_sanctuaries (id INT, species VARCHAR(50), population INT);
List all the sanctuaries with a population of tigers in 'wildlife_sanctuaries' table
SELECT id, species, population FROM wildlife_sanctuaries WHERE species = 'tiger';
gretelai_synthetic_text_to_sql
CREATE TABLE rural_access (id INT PRIMARY KEY, county_name VARCHAR(100), resource_name VARCHAR(100), accessibility DECIMAL(3,1));
Add a new record for healthcare access in a rural county to the rural_access table
INSERT INTO rural_access (id, county_name, resource_name, accessibility) VALUES (1, 'Rural County 1', 'Clinic', 3.5);
gretelai_synthetic_text_to_sql
CREATE TABLE player_achievements (achievement_id INT, achievement_name VARCHAR(30));
Insert new records into the player_achievements table with the following data: (1, 'Player of the Month'), (2, 'Rookie of the Year'), (3, 'Top Fragger')
INSERT INTO player_achievements (achievement_id, achievement_name) VALUES (1, 'Player of the Month'), (2, 'Rookie of the Year'), (3, 'Top Fragger');
gretelai_synthetic_text_to_sql
CREATE TABLE artists (id INT, name TEXT, genre TEXT); CREATE TABLE albums (id INT, title TEXT, artist_id INT, platform TEXT); CREATE VIEW classical_web_albums AS SELECT a.id, a.title, ar.name FROM albums a JOIN artists ar ON a.artist_id = ar.id WHERE ar.genre = 'classical' AND a.platform = 'web';
List the titles and artists of all classical albums available on the 'web' platform.
SELECT title, name FROM classical_web_albums;
gretelai_synthetic_text_to_sql
CREATE TABLE item_sales(item VARCHAR(20), location VARCHAR(20), quantity INT, sale_date DATE); INSERT INTO item_sales (item, location, quantity, sale_date) VALUES ('T-Shirt', 'New York', 12, '2022-04-01'); INSERT INTO item_sales (item, location, quantity, sale_date) VALUES ('Pant', 'New York', 18, '2022-04-02');
What was the total quantity of 'T-Shirt' items sold in 'New York' in Q2 2022?
SELECT SUM(quantity) FROM item_sales WHERE item = 'T-Shirt' AND location = 'New York' AND sale_date BETWEEN '2022-04-01' AND '2022-06-30';
gretelai_synthetic_text_to_sql
CREATE TABLE farm_details (id INT, farm_id INT, farm_name TEXT, region TEXT, system_type TEXT); INSERT INTO farm_details (id, farm_id, farm_name, region, system_type) VALUES (1, 1, 'FarmX', 'Atlantic', 'Recirculating'), (2, 1, 'FarmX', 'Atlantic', 'Flow-through'), (3, 2, 'FarmY', 'Pacific', 'Recirculating'), (4, 2, 'FarmY', 'Pacific', 'Hybrid'), (5, 3, 'FarmZ', 'Atlantic', 'Flow-through');
Identify the number of farms in the Atlantic region using recirculating aquaculture systems?
SELECT COUNT(DISTINCT farm_id) FROM farm_details WHERE region = 'Atlantic' AND system_type = 'Recirculating';
gretelai_synthetic_text_to_sql
CREATE TABLE industrial_sectors (id INT, sector VARCHAR(255)); INSERT INTO industrial_sectors (id, sector) VALUES (1, 'Manufacturing'), (2, 'Mining'), (3, 'Construction'); CREATE TABLE water_consumption (year INT, sector_id INT, consumption INT); INSERT INTO water_consumption (year, sector_id, consumption) VALUES (2020, 1, 10000), (2020, 2, 15000), (2020, 3, 12000);
What is the total water consumption by each industrial sector in 2020?
SELECT i.sector, SUM(w.consumption) as total_consumption FROM industrial_sectors i JOIN water_consumption w ON i.id = w.sector_id WHERE w.year = 2020 GROUP BY i.sector;
gretelai_synthetic_text_to_sql
CREATE TABLE sustainable_practices (id INT, title VARCHAR(50), description TEXT, date DATE);
Add new record to sustainable_practices table with id 11, title 'Solar Panels Installation', description 'Installation of solar panels on buildings', date '2022-04-10'
INSERT INTO sustainable_practices (id, title, description, date) VALUES (11, 'Solar Panels Installation', 'Installation of solar panels on buildings', '2022-04-10');
gretelai_synthetic_text_to_sql
CREATE TABLE donors (donor_id INT, donor_name TEXT, country TEXT, total_donation_amount FLOAT); INSERT INTO donors (donor_id, donor_name, country, total_donation_amount) VALUES (1, 'John Doe', 'USA', 5000.00), (2, 'Jane Smith', 'Canada', 7000.00);
Update the total donation amount for donor 'John Doe' to $6000.
WITH updated_john_doe AS (UPDATE donors SET total_donation_amount = 6000.00 WHERE donor_name = 'John Doe' AND country = 'USA' RETURNING *) SELECT * FROM updated_john_doe;
gretelai_synthetic_text_to_sql
CREATE TABLE safety_incidents (chemical VARCHAR(20), incident_date DATE); INSERT INTO safety_incidents VALUES ('chemical Y', '2022-06-15'); INSERT INTO safety_incidents VALUES ('chemical Z', '2022-07-01');
Identify safety incidents involving chemical Y in the past year.
SELECT * FROM safety_incidents WHERE chemical = 'chemical Y' AND incident_date BETWEEN DATEADD(year, -1, GETDATE()) AND GETDATE();
gretelai_synthetic_text_to_sql
CREATE TABLE wells (well_id INT, well_name VARCHAR(255), well_type VARCHAR(255), location VARCHAR(255)); INSERT INTO wells VALUES (1, 'Well A', 'Offshore', 'Norwegian Continental Shelf'); INSERT INTO wells VALUES (2, 'Well B', 'Onshore', 'Texas');
What is the average production rate per well for offshore wells in the Norwegian Continental Shelf?
SELECT AVG(production_rate) FROM (SELECT well_id, production_rate FROM well_production WHERE well_type = 'Offshore' AND location = 'Norwegian Continental Shelf' ORDER BY production_rate DESC) WHERE row_number() OVER (ORDER BY production_rate DESC) <= 10;
gretelai_synthetic_text_to_sql
CREATE TABLE GameSales (GameTitle VARCHAR(255), UnitsSold INT, Revenue DECIMAL(10,2)); INSERT INTO GameSales VALUES ('GameA', 100, 1500.00), ('GameB', 50, 750.00), ('GameC', 200, 3000.00);
Find the total revenue for each game title, including those with zero revenue.
SELECT g.GameTitle, COALESCE(SUM(g.Revenue), 0) as TotalRevenue FROM GameSales g GROUP BY g.GameTitle;
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, category VARCHAR(255), amount DECIMAL(10, 2)); INSERT INTO donations (id, category, amount) VALUES (1, 'climate change', 5000), (2, 'poverty reduction', 8000), (3, 'healthcare', 3000), (4, 'climate change', 7000), (5, 'healthcare', 100);
What's the minimum and maximum donation amount per category, showing both values side by side?
SELECT category, MIN(amount) AS min_donation, MAX(amount) AS max_donation FROM donations GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE InfrastructureProjects (id INT, category VARCHAR(20), cost FLOAT); INSERT INTO InfrastructureProjects (id, category, cost) VALUES (1, 'Roads', 500000), (2, 'Bridges', 750000), (3, 'Buildings', 900000), (4, 'Roads', 600000);
What is the minimum cost of a project in the 'Buildings' category?
SELECT MIN(cost) FROM InfrastructureProjects WHERE category = 'Buildings';
gretelai_synthetic_text_to_sql
CREATE TABLE tourism_stats (country VARCHAR(20), year INT, tourists INT); INSERT INTO tourism_stats (country, year, tourists) VALUES ('Japan', 2020, 12000), ('Japan', 2021, 15000), ('France', 2020, 18000), ('France', 2021, 20000), ('Germany', 2020, 10000), ('Germany', 2021, 12000), ('Italy', 2020, 9000), ('Italy', 2021, 11000);
Find the names of all countries that had more tourists visiting in 2021 compared to 2020.
SELECT country FROM tourism_stats WHERE country IN (SELECT country FROM tourism_stats WHERE year = 2021 INTERSECT SELECT country FROM tourism_stats WHERE year = 2020) AND tourists_2021 > tourists_2020;
gretelai_synthetic_text_to_sql
CREATE TABLE policyholders (id INT, name TEXT, city TEXT, state TEXT, claim_amount FLOAT); INSERT INTO policyholders (id, name, city, state, claim_amount) VALUES (1, 'John Doe', 'San Francisco', 'CA', 5000.00); INSERT INTO policyholders (id, name, city, state, claim_amount) VALUES (2, 'Jane Doe', 'Los Angeles', 'CA', 3000.00);
List all cities in 'California' with their average claim amount?
SELECT city, AVG(claim_amount) FROM policyholders WHERE state = 'CA' GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE mines (id INT, name TEXT, location TEXT, depth INT); INSERT INTO mines (id, name, location, depth) VALUES (1, 'Diamond Mine', 'South Africa', 1500); INSERT INTO mines (id, name, location, depth) VALUES (2, 'Gold Mine', 'South Africa', 2000);
Find the minimum and maximum depth of mines in South Africa.
SELECT MIN(depth), MAX(depth) FROM mines WHERE location = 'South Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE AccessibleTech (InitiativeID INT, InitiativeName VARCHAR(50), Sector VARCHAR(50)); INSERT INTO AccessibleTech (InitiativeID, InitiativeName, Sector) VALUES (1, 'Accessible Coding Curriculum', 'Education'); INSERT INTO AccessibleTech (InitiativeID, InitiativeName, Sector) VALUES (2, 'Accessible Tech for Health', 'Healthcare');
Show the number of accessible technology initiatives for each sector.
SELECT Sector, COUNT(*) FROM AccessibleTech GROUP BY Sector;
gretelai_synthetic_text_to_sql
CREATE TABLE farm_biomass_by_year (year INT, biomass INT); INSERT INTO farm_biomass_by_year (year, biomass) VALUES (2020, 6000), (2021, 7000), (2022, 8000), (2020, 4000), (2021, 5000);
What is the total biomass of fish in all farms, grouped by year, where the biomass is greater than 5000 tons?
SELECT year, SUM(biomass) FROM farm_biomass_by_year WHERE biomass > 5000 GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE legal_cases (id INT, value DECIMAL(10,2), case_date DATE, lawyer VARCHAR(50));
What is the total number of legal cases handled by each lawyer, with a value over $50,000, in the past year?
SELECT lawyer, COUNT(*) FROM legal_cases WHERE value > 50000 AND case_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY lawyer HAVING COUNT(*) > 0;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_finance (id INT, provider VARCHAR(100), initiative VARCHAR(100), amount FLOAT, year INT, location VARCHAR(100)); INSERT INTO climate_finance (id, provider, initiative, amount, year, location) VALUES (1, 'Green Climate Fund', 'Climate Adaptation', 25000000, 2020, 'Latin America'), (2, 'World Bank', 'Climate Adaptation', 30000000, 2019, 'Latin America');
What is the maximum funding provided by each climate finance provider for climate adaptation projects in Latin America?
SELECT provider, MAX(amount) FROM climate_finance WHERE initiative = 'Climate Adaptation' AND location = 'Latin America' GROUP BY provider;
gretelai_synthetic_text_to_sql
CREATE TABLE military_sales_nato (id INT, year INT, quarter INT, country VARCHAR(50), equipment_type VARCHAR(30), revenue DECIMAL(10,2));
What is the trend of military equipment sales to NATO countries over the last 5 years?
SELECT year, quarter, AVG(revenue) as avg_revenue FROM military_sales_nato WHERE country IN ('France', 'Germany', 'Italy', 'Spain', 'United Kingdom', 'United States') GROUP BY year, quarter ORDER BY year, quarter;
gretelai_synthetic_text_to_sql
CREATE TABLE patients (id INT, state VARCHAR(255), country VARCHAR(255), improvement VARCHAR(255)); INSERT INTO patients (id, state, country, improvement) VALUES (1, 'California', 'USA', 'Improved'), (2, 'Texas', 'USA', 'Not Improved'), (3, 'Florida', 'USA', 'Improved'); CREATE TABLE therapy (patient_id INT, therapy_type VARCHAR(255)); INSERT INTO therapy (patient_id, therapy_type) VALUES (1, 'Psychotherapy'), (2, 'Psychotherapy'), (3, 'CBT');
How many patients improved after psychotherapy in each state of the USA?
SELECT state, COUNT(CASE WHEN improvement = 'Improved' AND country = 'USA' AND therapy_type = 'Psychotherapy' THEN 1 END) as improved_count FROM patients JOIN therapy ON patients.id = therapy.patient_id GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE schools (name TEXT, budget INTEGER, state TEXT); INSERT INTO schools (name, budget, state) VALUES ('SchoolA', 5000, 'Florida'), ('SchoolB', 6000, 'Florida'), ('SchoolC', 7000, 'Florida'), ('SchoolD', 8000, 'Texas'), ('SchoolE', 9000, 'Texas'), ('SchoolF', 10000, 'Texas');
What is the total number of schools and their average budget in Florida and Texas?
SELECT COUNT(*) as total_schools, AVG(budget) as avg_budget FROM schools WHERE state IN ('Florida', 'Texas');
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (DonationID int, DonationDate date, Amount decimal(10, 2)); INSERT INTO Donations (DonationID, DonationDate, Amount) VALUES (1, '2020-01-01', 500), (2, '2020-02-01', 700), (3, '2020-04-01', 800), (4, '2020-07-01', 900);
What is the difference in total donations between the first and second quarters of 2020?
SELECT SUM(CASE WHEN DATEPART(quarter, DonationDate) = 1 THEN Amount ELSE 0 END) - SUM(CASE WHEN DATEPART(quarter, DonationDate) = 2 THEN Amount ELSE 0 END) as Q1Q2Difference FROM Donations WHERE YEAR(DonationDate) = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT, region VARCHAR(255), year INT, quantity INT); INSERT INTO sales (id, region, year, quantity) VALUES (1, 'Asia-Pacific', 2021, 100), (2, 'Europe', 2022, 75), (3, 'Asia-Pacific', 2021, 150);
How many military vehicles were sold in the Asia-Pacific region in the year 2021?
SELECT SUM(quantity) as total_quantity FROM sales WHERE region = 'Asia-Pacific' AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE aircraft (aircraft_id INT, model VARCHAR(100), manufacturer VARCHAR(100)); CREATE TABLE safety_records (record_id INT, aircraft_id INT, incident_count INT); INSERT INTO aircraft (aircraft_id, model, manufacturer) VALUES (1, 'Aeromodel X1', 'AeroCo'); INSERT INTO aircraft (aircraft_id, model, manufacturer) VALUES (2, 'Aeromodel Y2', 'BrightAero'); INSERT INTO safety_records (record_id, aircraft_id, incident_count) VALUES (1, 1, 3); INSERT INTO safety_records (record_id, aircraft_id, incident_count) VALUES (2, 2, 1);
What are the total number of incidents for each manufacturer?
SELECT manufacturer, SUM(incident_count) FROM aircraft INNER JOIN safety_records ON aircraft.aircraft_id = safety_records.aircraft_id GROUP BY manufacturer;
gretelai_synthetic_text_to_sql
CREATE TABLE WaterConservationInitiatives (InitiativeID INT PRIMARY KEY, Location VARCHAR(255), InitiativeType VARCHAR(255), Cost INT, StartDate DATETIME, EndDate DATETIME); INSERT INTO WaterConservationInitiatives (InitiativeID, Location, InitiativeType, Cost, StartDate, EndDate) VALUES (1, 'New York', 'Water-efficient Appliances', 10000, '2022-01-01', '2022-12-31');
What is the total cost and number of days for water conservation initiatives in New York in the year 2022?
SELECT InitiativeType, SUM(Cost) as TotalCost, COUNT(DATEDIFF(day, StartDate, EndDate) + 1) as TotalDays FROM WaterConservationInitiatives WHERE Location = 'New York' AND YEAR(StartDate) = 2022 GROUP BY InitiativeType;
gretelai_synthetic_text_to_sql
CREATE TABLE products (id INT, name VARCHAR(255), price DECIMAL(10,2), supplier_id INT);
Find the number of products supplied by each supplier that are priced higher than the average product price.
SELECT supplier_id, COUNT(*) FROM products WHERE price > (SELECT AVG(price) FROM products) GROUP BY supplier_id;
gretelai_synthetic_text_to_sql
CREATE TABLE sales_q2_2022 (sale_date DATE, country VARCHAR(50), quantity INT, sales DECIMAL(10,2));
What is the total revenue and quantity of garments sold by country in Q2 2022?
SELECT country, SUM(quantity) AS total_quantity, SUM(sales) AS total_revenue FROM sales_q2_2022 WHERE sale_date >= '2022-04-01' AND sale_date < '2022-07-01' GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE team_performance (id INT, team VARCHAR(255), season INT, score INT); INSERT INTO team_performance (id, team, season, score) VALUES (1, 'NY Knicks', 2022, 95), (2, 'LA Lakers', 2022, 88), (3, 'Boston Celtics', 2022, 92), (4, 'NY Knicks', 2021, 89), (5, 'LA Lakers', 2021, 91), (6, 'Boston Celtics', 2021, 96);
What is the average performance score of each team by season?
SELECT team, season, AVG(score) as avg_score FROM team_performance GROUP BY team, season;
gretelai_synthetic_text_to_sql
CREATE TABLE portfolio_managers (manager_name VARCHAR(20), id INT); CREATE TABLE investments (manager_id INT, sector VARCHAR(20), ESG_rating FLOAT); INSERT INTO portfolio_managers (manager_name, id) VALUES ('Portfolio Manager 1', 1), ('Portfolio Manager 2', 2), ('Portfolio Manager 3', 3); INSERT INTO investments (manager_id, sector, ESG_rating) VALUES (1, 'renewable_energy', 8.1), (1, 'technology', 7.5), (2, 'renewable_energy', 6.5), (2, 'technology', 9.0), (3, 'finance', 6.8), (3, 'renewable_energy', 9.2);
List all unique portfolio managers and their minimum ESG ratings for all their investments?
SELECT portfolio_managers.manager_name, MIN(investments.ESG_rating) FROM portfolio_managers INNER JOIN investments ON portfolio_managers.id = investments.manager_id GROUP BY portfolio_managers.manager_name;
gretelai_synthetic_text_to_sql
CREATE TABLE rainfall (location TEXT, rainfall INTEGER, rainy_day BOOLEAN, timestamp TIMESTAMP);
List the total rainfall for each month in the past year.
SELECT DATEPART(year, timestamp) as year, DATEPART(month, timestamp) as month, SUM(rainfall) as total_rainfall FROM rainfall WHERE timestamp BETWEEN DATEADD(year, -1, CURRENT_TIMESTAMP) AND CURRENT_TIMESTAMP GROUP BY DATEPART(year, timestamp), DATEPART(month, timestamp);
gretelai_synthetic_text_to_sql
CREATE TABLE trip (id INT PRIMARY KEY, start_time TIMESTAMP, end_time TIMESTAMP, route_id INT, vehicle_id INT, FOREIGN KEY (route_id) REFERENCES route(id), FOREIGN KEY (vehicle_id) REFERENCES vehicle(id)); INSERT INTO trip (id, start_time, end_time, route_id, vehicle_id) VALUES (1, '2022-01-01 08:00:00', '2022-01-01 09:00:00', 1, 1);
Delete the trip with route_id 3 and vehicle_id 5.
WITH cte_trip AS (DELETE FROM trip WHERE route_id = 3 AND vehicle_id = 5 RETURNING id, start_time, end_time, route_id, vehicle_id) INSERT INTO trip_history SELECT * FROM cte_trip;
gretelai_synthetic_text_to_sql
CREATE TABLE policy_violations (id INT, department VARCHAR(255), violation_count INT); INSERT INTO policy_violations (id, department, violation_count) VALUES (1, 'HR', 10); INSERT INTO policy_violations (id, department, violation_count) VALUES (2, 'IT', 5); INSERT INTO policy_violations (id, department, violation_count) VALUES (3, 'Finance', 8); INSERT INTO policy_violations (id, department, violation_count) VALUES (4, 'Operations', 12); INSERT INTO policy_violations (id, department, violation_count) VALUES (5, 'Government', 0);
Find the total number of policy violations for each department in the government sector
SELECT department, SUM(violation_count) as total_violations FROM policy_violations WHERE department LIKE '%Government%' GROUP BY department;
gretelai_synthetic_text_to_sql
CREATE TABLE budget_report (program VARCHAR(50), budget DECIMAL(10,2));
Calculate the total budget for the 'health' and 'education' programs from the 'budget_report' table.
SELECT program, SUM(budget) FROM budget_report WHERE program IN ('health', 'education') GROUP BY program;
gretelai_synthetic_text_to_sql
CREATE TABLE research_papers (id INT, publication_year INT, topic VARCHAR(255)); INSERT INTO research_papers (id, publication_year, topic) VALUES (1, 2012, 'AI Safety'), (2, 2013, 'Explainable AI'), (3, 2018, 'Algorithmic Fairness'), (4, 2019, 'Creative AI'), (5, 2020, 'AI Safety'), (6, 2021, 'AI Safety');
Calculate the total number of algorithmic fairness research papers published in even-numbered years
SELECT SUM(CASE WHEN publication_year % 2 = 0 THEN 1 ELSE 0 END) FROM research_papers WHERE topic = 'Algorithmic Fairness';
gretelai_synthetic_text_to_sql
CREATE TABLE Workouts (WorkoutID INT, MemberID INT, Duration INT, MembershipType VARCHAR(20));
Delete records of workouts with a duration more than 90 minutes for all members from the 'Workouts' table
DELETE FROM Workouts WHERE Duration > 90;
gretelai_synthetic_text_to_sql
CREATE TABLE company_founding(id INT PRIMARY KEY, company_name VARCHAR(100), founder_gender VARCHAR(10)); CREATE TABLE investment_rounds(id INT PRIMARY KEY, company_id INT, round_type VARCHAR(50), funding_amount INT); INSERT INTO company_founding VALUES (1, 'Acme Inc', 'Female'); INSERT INTO company_founding VALUES (2, 'Beta Corp', 'Male'); INSERT INTO company_founding VALUES (3, 'Charlie LLC', 'Female'); INSERT INTO investment_rounds VALUES (1, 1, 'Seed', 100000); INSERT INTO investment_rounds VALUES (2, 1, 'Series A', 2000000); INSERT INTO investment_rounds VALUES (3, 3, 'Series B', 5000000);
List all companies that have raised a Series B or later and have a female founder
SELECT cf.company_name FROM company_founding cf INNER JOIN investment_rounds ir ON cf.id = ir.company_id WHERE ir.round_type IN ('Series B', 'Series C', 'Series D', 'Series E') AND cf.founder_gender = 'Female';
gretelai_synthetic_text_to_sql
CREATE TABLE attorneys (attorney_id INT, name VARCHAR(50), gender VARCHAR(10), city VARCHAR(50)); INSERT INTO attorneys (attorney_id, name, gender, city) VALUES (1, 'Jane Smith', 'Female', 'Los Angeles'), (2, 'Robert Johnson', 'Male', 'New York'), (3, 'Maria Rodriguez', 'Female', 'Miami'); CREATE TABLE cases (case_id INT, attorney_id INT); INSERT INTO cases (case_id, attorney_id) VALUES (1, 1), (2, 1), (3, 3);
How many cases were handled by female attorneys in the city of Los Angeles?
SELECT COUNT(*) FROM cases INNER JOIN attorneys ON cases.attorney_id = attorneys.attorney_id WHERE attorneys.gender = 'Female' AND attorneys.city = 'Los Angeles';
gretelai_synthetic_text_to_sql
CREATE TABLE developers (developer_id INT, name VARCHAR(50), country VARCHAR(50)); INSERT INTO developers (developer_id, name, country) VALUES (1, 'Alice', 'USA'), (2, 'Bob', 'China'); CREATE TABLE dapps (dapp_id INT, name VARCHAR(50), developer_id INT, network VARCHAR(50)); INSERT INTO dapps (dapp_id, name, developer_id) VALUES (1, 'DApp1', 1), (2, 'DApp2', 2); CREATE TABLE smart_contracts (contract_id INT, name VARCHAR(50), developer_id INT, network VARCHAR(50)); INSERT INTO smart_contracts (contract_id, name, developer_id) VALUES (1, 'SmartContract1', 1), (2, 'SmartContract2', 2);
Show the number of decentralized applications and smart contracts associated with each developer on the Cardano network.
SELECT developers.name, COUNT(dapps.dapp_id) as dapp_count, COUNT(smart_contracts.contract_id) as contract_count FROM developers LEFT JOIN dapps ON developers.developer_id = dapps.developer_id LEFT JOIN smart_contracts ON developers.developer_id = smart_contracts.developer_id WHERE dapps.network = 'Cardano' AND smart_contracts.network = 'Cardano' GROUP BY developers.name;
gretelai_synthetic_text_to_sql
CREATE TABLE organic_farms (id INT, country VARCHAR(50), region VARCHAR(50), no_farms INT); INSERT INTO organic_farms (id, country, region, no_farms) VALUES (1, 'China', 'Asia', 5000); INSERT INTO organic_farms (id, country, region, no_farms) VALUES (2, 'India', 'Asia', 7000); INSERT INTO organic_farms (id, country, region, no_farms) VALUES (3, 'Indonesia', 'Asia', 3500);
How many farms practice organic farming in 'Asia'?
SELECT SUM(no_farms) FROM organic_farms WHERE region = 'Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE vehicle_servicing (vehicle_id INT, servicing_date DATE);
How many vehicles were serviced in each month of the year in the 'vehicle_servicing' table?
SELECT EXTRACT(MONTH FROM servicing_date) as month, COUNT(*) as num_vehicles FROM vehicle_servicing GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE players (player_id INT, name VARCHAR(50), age INT, position VARCHAR(50), team VARCHAR(50));
What is the average age of players in the players table?
SELECT AVG(age) FROM players;
gretelai_synthetic_text_to_sql
CREATE TABLE IF NOT EXISTS programs (id INT, name VARCHAR(255), type VARCHAR(255), year INT, funding DECIMAL(10,2)); INSERT INTO programs (id, name, type, year, funding) VALUES (1, 'ProgramA', 'Visual Arts', 2021, 25000), (2, 'ProgramB', 'Theater', 2021, 30000), (3, 'ProgramC', 'Music', 2021, 20000);
What is the total funding for visual arts programs in 2021?
SELECT SUM(funding) FROM programs WHERE type = 'Visual Arts' AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE wind_energy (project_id INT, project_name VARCHAR(255), country VARCHAR(255), installed_capacity FLOAT);
What is the total installed capacity of wind energy projects in the USA?
SELECT SUM(installed_capacity) FROM wind_energy WHERE country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE infrastructure (project_id INT, project_name VARCHAR(50), location VARCHAR(50), cost INT); INSERT INTO infrastructure (project_id, project_name, location, cost) VALUES (1, 'Dam Reconstruction', 'City A', 5000000), (2, 'Bridge Construction', 'City B', 3000000), (3, 'Road Widening', 'City C', 2000000);
What is the total cost of all projects in the 'infrastructure' table?
SELECT SUM(cost) FROM infrastructure;
gretelai_synthetic_text_to_sql
CREATE TABLE wimbledon (player VARCHAR(50), opponent VARCHAR(50), won INT, lost INT);
What is the percentage of games won by each tennis player, based on the number of games won and total games played, in the wimbledon table?
SELECT player, (SUM(won) * 100.0 / (SUM(won) + SUM(lost))) AS win_percentage FROM wimbledon GROUP BY player;
gretelai_synthetic_text_to_sql
CREATE TABLE users_table (user_id INT, posts_count INT); INSERT INTO users_table (user_id, posts_count) VALUES (1, 20), (2, 30), (3, 15);
What is the average number of posts per user in the "users_table"?
SELECT AVG(posts_count) FROM users_table;
gretelai_synthetic_text_to_sql
CREATE TABLE model_data (model_id INT, fairness_score DECIMAL(3,2), safety_score DECIMAL(3,2)); INSERT INTO model_data (model_id, fairness_score, safety_score) VALUES (1, 0.85, 0.92), (2, 0.70, 0.88), (3, 0.92, 0.85), (4, 0.68, 0.83);
Find the number of models that have both a fairness score and safety score greater than 0.8.
SELECT COUNT(*) FROM model_data WHERE fairness_score > 0.8 AND safety_score > 0.8;
gretelai_synthetic_text_to_sql
CREATE TABLE products (material VARCHAR(50), category VARCHAR(50)); INSERT INTO products (material, category) VALUES ('organic cotton', 'womens'), ('organic cotton', 'childrens'), ('recycled polyester', 'womens'), ('hemp', 'accessories');
Delete all products made of 'hemp' from the ethical fashion database.
DELETE FROM products WHERE material = 'hemp';
gretelai_synthetic_text_to_sql
CREATE TABLE investments (id INT, type TEXT, location TEXT, investment_date DATE); INSERT INTO investments (id, type, location, investment_date) VALUES (1, 'Socially Responsible', 'Latin America', '2021-02-15'), (2, 'Conventional', 'North America', '2022-05-10'), (3, 'Socially Responsible', 'Latin America', '2020-06-20');
List all socially responsible investments made in Latin America since 2020.
SELECT * FROM investments WHERE type = 'Socially Responsible' AND location = 'Latin America' AND investment_date >= '2020-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE socially_responsible_lending_asia (id INT, country VARCHAR(255), loan_amount DECIMAL(10,2)); INSERT INTO socially_responsible_lending_asia (id, country, loan_amount) VALUES (1, 'China', 3000.00), (2, 'Japan', 4000.00), (3, 'India', 5000.00);
What is the average loan amount for socially responsible lending in Asia?
SELECT AVG(loan_amount) FROM socially_responsible_lending_asia WHERE country IN ('China', 'Japan', 'India');
gretelai_synthetic_text_to_sql
CREATE TABLE clients (id INT, name VARCHAR(50), total_billing_amount DECIMAL(10,2)); INSERT INTO clients (id, name, total_billing_amount) VALUES (1, 'ABC Corp', 50000.00), (2, 'XYZ Inc', 75000.00), (3, 'LMN LLC', 30000.00);
What is the minimum total billing amount for clients?
SELECT MIN(total_billing_amount) FROM clients;
gretelai_synthetic_text_to_sql
CREATE TABLE HospitalVisits (ID INT, PatientName VARCHAR(50), Age INT, VisitDate DATE); INSERT INTO HospitalVisits (ID, PatientName, Age, VisitDate) VALUES (1, 'Tom', 15, '2022-01-01');
What is the total number of hospital visits for children under 18 in the last 6 months?
SELECT COUNT(*) FROM HospitalVisits WHERE Age < 18 AND VisitDate >= DATEADD(month, -6, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, PlayerCountry VARCHAR(10), Levels INT); INSERT INTO Players (PlayerID, PlayerCountry, Levels) VALUES (1, 'USA', 12), (2, 'Canada', 15), (3, 'USA', 8);
What is the minimum number of levels achieved by players from the USA?
SELECT MIN(Levels) FROM Players WHERE PlayerCountry = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE Members (MemberID INT, Age INT, Gender VARCHAR(10), WorkoutType VARCHAR(20)); INSERT INTO Members (MemberID, Age, Gender, WorkoutType) VALUES (1, 35, 'Male', 'Cycling'), (2, 28, 'Female', 'Yoga'), (3, 42, 'Male', 'Weightlifting');
What is the most popular workout type among male members?
SELECT WorkoutType, COUNT(*) AS count FROM Members WHERE Gender = 'Male' GROUP BY WorkoutType ORDER BY count DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Participants (participant_id INT, participant_name VARCHAR(255)); CREATE TABLE Attendance (attendance_id INT, participant_id INT, workshop_id INT, attendance_date DATE); CREATE TABLE Workshops (workshop_id INT, workshop_name VARCHAR(255), program_area VARCHAR(255), start_date DATE, end_date DATE); INSERT INTO Participants (participant_id, participant_name) VALUES (5, 'Jose Garcia'); INSERT INTO Attendance (attendance_id, participant_id, workshop_id) VALUES (5, 5, 6); INSERT INTO Workshops (workshop_id, workshop_name, program_area, start_date, end_date) VALUES (6, 'Climate Change Adaptation', 'Climate Action', '2020-01-01', '2020-12-31');
What is the total number of participants who attended 'Climate Action' workshops in '2020' and '2021'?
SELECT SUM(Attendance.participant_id) FROM Attendance INNER JOIN Workshops ON Attendance.workshop_id = Workshops.workshop_id INNER JOIN Participants ON Attendance.participant_id = Participants.participant_id WHERE Workshops.program_area = 'Climate Action' AND (YEAR(Attendance.attendance_date) = 2020 OR YEAR(Attendance.attendance_date) = 2021);
gretelai_synthetic_text_to_sql
CREATE TABLE playerperformances (player_id INT, game_id INT, match_date DATE, kills INT, deaths INT); INSERT INTO playerperformances (player_id, game_id, match_date, kills, deaths) VALUES (1, 1001, '2022-01-01', 25, 10);
Find players with the most matches played in a specific time range
SELECT player_id, COUNT(*) as num_matches, RANK() OVER (ORDER BY COUNT(*) DESC) as rank FROM playerperformances WHERE match_date BETWEEN '2022-01-01' AND '2022-02-01' GROUP BY player_id
gretelai_synthetic_text_to_sql
CREATE TABLE spain_projects (id INT, project_name VARCHAR(100), region VARCHAR(50), project_location VARCHAR(50), project_type VARCHAR(50)); INSERT INTO spain_projects (id, project_name, region, project_location, project_type) VALUES (1, 'Wind Project A', 'Andalusia', 'Southern Andalusia', 'Wind'), (2, 'Wind Project B', 'Andalusia', 'Northern Andalusia', 'Wind'), (3, 'Solar Project A', 'Andalusia', 'Southern Andalusia', 'Solar');
What is the total number of wind energy projects in the region of Andalusia, Spain, grouped by project location?
SELECT project_location, COUNT(*) FROM spain_projects WHERE region = 'Andalusia' AND project_type = 'Wind' GROUP BY project_location;
gretelai_synthetic_text_to_sql
CREATE TABLE justice_schemas.restorative_sessions (id INT PRIMARY KEY, program_id INT, session_type TEXT, duration_minutes INT); CREATE TABLE justice_schemas.restorative_programs (id INT PRIMARY KEY, name TEXT);
How many restorative justice sessions are there in the justice_schemas.restorative_sessions table for each program in the justice_schemas.restorative_programs table?
SELECT rp.name, COUNT(*) FROM justice_schemas.restorative_sessions rs INNER JOIN justice_schemas.restorative_programs rp ON rs.program_id = rp.id GROUP BY rp.name;
gretelai_synthetic_text_to_sql
CREATE TABLE Inventory (Strain VARCHAR(255), PricePerGram DECIMAL(10,2)); INSERT INTO Inventory (Strain, PricePerGram) VALUES ('Blue Dream', 12.00), ('Sour Diesel', 14.00), ('OG Kush', 15.00);
What is the average price per gram of each strain in the cannabis inventory?
SELECT Strain, AVG(PricePerGram) AS AveragePricePerGram FROM Inventory GROUP BY Strain;
gretelai_synthetic_text_to_sql
CREATE TABLE accounts (account_id INT, customer_name VARCHAR(50), country VARCHAR(50), account_balance DECIMAL(10,2));
Compare the average account balance of customers in the Asia-Pacific region with those in Europe.
SELECT 'Asia-Pacific' as region, AVG(account_balance) as avg_balance FROM accounts WHERE country IN ('Singapore', 'Hong Kong', 'Australia', 'Japan', 'China', 'India') UNION ALL SELECT 'Europe' as region, AVG(account_balance) as avg_balance FROM accounts WHERE country IN ('United Kingdom', 'Germany', 'France', 'Italy', 'Spain');
gretelai_synthetic_text_to_sql
CREATE TABLE Events (event_id INT PRIMARY KEY, event_name TEXT, category TEXT, attendees INT);
Increase the attendance by 10% for events with the 'Family' category.
UPDATE Events SET attendees = attendees * 1.1 WHERE category = 'Family';
gretelai_synthetic_text_to_sql
CREATE TABLE cuisine (cuisine_id INT PRIMARY KEY, cuisine_name VARCHAR(255));CREATE TABLE dishes (dish_id INT PRIMARY KEY, dish_name VARCHAR(255), cuisine_id INT, FOREIGN KEY (cuisine_id) REFERENCES cuisine(cuisine_id));CREATE TABLE allergens (allergen_id INT PRIMARY KEY, dish_id INT, FOREIGN KEY (dish_id) REFERENCES dishes(dish_id));
What are the top 5 most common allergens in dishes from the 'Italian' cuisine?
SELECT a.allergen_id, a.allergen_name FROM allergens a JOIN dishes d ON a.dish_id = d.dish_id JOIN cuisine c ON d.cuisine_id = c.cuisine_id WHERE c.cuisine_name = 'Italian' GROUP BY a.allergen_id ORDER BY COUNT(a.allergen_id) DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE community_development (project_name VARCHAR(50), project_start_date DATE, budget DECIMAL(10,2), community_type VARCHAR(50));
Show the community development initiatives that have been implemented in indigenous communities in Latin America, including the project name, start date, and budget.
SELECT project_name, project_start_date, budget FROM community_development WHERE community_type LIKE '%indigenous%' AND country LIKE 'Lat%';
gretelai_synthetic_text_to_sql
CREATE TABLE spacecrafts (spacecraft_id INT, name VARCHAR(100), launch_date DATE); INSERT INTO spacecrafts (spacecraft_id, name, launch_date) VALUES (1, 'Voyager 1', '1977-09-05'); INSERT INTO spacecrafts (spacecraft_id, name, launch_date) VALUES (2, 'Voyager 2', '1977-08-20'); INSERT INTO spacecrafts (spacecraft_id, name, launch_date) VALUES (3, 'Pioneer 10', '1972-03-03'); INSERT INTO spacecrafts (spacecraft_id, name, launch_date) VALUES (4, 'Pioneer 11', '1973-04-06');
Which satellite was launched right after 'Voyager 1'?
SELECT name FROM (SELECT name, launch_date, LAG(launch_date) OVER (ORDER BY launch_date) as prev_launch_date FROM spacecrafts) sub WHERE prev_launch_date = '1977-09-05';
gretelai_synthetic_text_to_sql
CREATE TABLE Satellite_Deployments (satellite_deployment_id INT, satellite_model VARCHAR(50), region VARCHAR(50), deployment_status VARCHAR(50), deployment_date DATE); INSERT INTO Satellite_Deployments (satellite_deployment_id, satellite_model, region, deployment_status, deployment_date) VALUES (1, 'Sat-A', 'Asia-Pacific', 'Success', '2010-02-15'), (2, 'Sat-B', 'Europe', 'Failure', '2012-08-12'), (3, 'Sat-C', 'Asia-Pacific', 'Success', '2015-01-01'), (4, 'Sat-D', 'North America', 'Success', '2018-07-24'), (5, 'Sat-A', 'Asia-Pacific', 'Success', '2019-12-28');
What are the average number of successful satellite deployments by region?
SELECT region, AVG(CASE WHEN deployment_status = 'Success' THEN 1 ELSE 0 END) as avg_successful_deployments FROM Satellite_Deployments GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE geothermal_plants (name TEXT, country TEXT, capacity FLOAT); INSERT INTO geothermal_plants (name, country, capacity) VALUES ('Muara Laboh', 'Indonesia', 80.0), ('Sinabung', 'Indonesia', 45.0), ('Dieng', 'Indonesia', 66.4);
What are the names and capacities of geothermal plants in Indonesia?
SELECT name, capacity FROM geothermal_plants WHERE country = 'Indonesia';
gretelai_synthetic_text_to_sql
CREATE TABLE grants_faculty_engineering (id INT, department VARCHAR(50), faculty_name VARCHAR(50), gender VARCHAR(50), amount DECIMAL(10,2), grant_date DATE); INSERT INTO grants_faculty_engineering (id, department, faculty_name, gender, amount, grant_date) VALUES (1, 'Engineering', 'Aisha', 'Female', 25000.00, '2019-04-02'), (2, 'Engineering', 'Bao', 'Male', 30000.00, '2020-11-15'), (3, 'Engineering', 'Chen', 'Female', 22000.00, '2021-07-30');
What is the average number of research grants received by female faculty members in the Engineering department over the past 3 years?
SELECT AVG(amount) FROM grants_faculty_engineering WHERE department = 'Engineering' AND gender = 'Female' AND grant_date >= DATE_SUB(CURDATE(), INTERVAL 3 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE excavation_sites(site_id INT, site_name TEXT, country TEXT, num_artifacts INT); INSERT INTO excavation_sites(site_id, site_name, country, num_artifacts) VALUES (1, 'Site A', 'Egypt', 500), (2, 'Site B', 'Italy', 300), (3, 'Site C', 'Egypt', 700), (4, 'Site D', 'Mexico', 600), (5, 'Site E', 'Italy', 400);
What are the top 3 countries with the most excavation sites in our database, and how many sites are there in each?
SELECT country, COUNT(*) as num_sites FROM excavation_sites GROUP BY country ORDER BY num_sites DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE dives (dive_id INT, diver_id INT, location VARCHAR(50), depth FLOAT, duration INT); INSERT INTO dives (dive_id, diver_id, location, depth, duration) VALUES (1, 1001, 'Great Barrier Reef', 35.4, 60);
What is the average depth of dives in the 'dives' table, grouped by diver_id?
SELECT diver_id, AVG(depth) FROM dives GROUP BY diver_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (VolunteerID int, Name varchar(50), TotalDonationAmount numeric); INSERT INTO Volunteers (VolunteerID, Name, TotalDonationAmount) VALUES (1, 'John Doe', 500.00), (2, 'Jane Smith', 750.00);
What is the total donation amount per volunteer?
SELECT Volunteers.Name, SUM(Volunteers.TotalDonationAmount) as 'Total Donation Amount' FROM Volunteers GROUP BY Volunteers.Name;
gretelai_synthetic_text_to_sql
CREATE TABLE healthcare_workers (id INT, name TEXT, age INT, position TEXT, hospital_id INT); CREATE TABLE rural_hospitals (id INT, name TEXT, location TEXT, state TEXT);
Insert a new rural healthcare worker into the "healthcare_workers" table.
INSERT INTO healthcare_workers (id, name, age, position, hospital_id) VALUES (3, 'Maria Garcia', 35, 'Nurse', 3);
gretelai_synthetic_text_to_sql
CREATE TABLE metros (id INT, name TEXT, location TEXT, depth INT, type TEXT, year INT); INSERT INTO metros (id, name, location, depth, type, year) VALUES (1, 'Moscow Metro', 'Russia', 84, 'Subway', 1935); INSERT INTO metros (id, name, location, depth, type, year) VALUES (2, 'Pyongyang Metro', 'North Korea', 110, 'Subway', 1973);
Which are the deepest metro systems and their respective depths, constructed between 1965 and 1995?
SELECT name, depth FROM metros WHERE year > 1965 AND year < 1995 ORDER BY depth DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE WastewaterTreatmentCosts (country VARCHAR(20), cost FLOAT);
What is the minimum amount of water (in liters) required to treat one cubic meter of wastewater in India?
SELECT MIN(cost) FROM WastewaterTreatmentCosts WHERE country = 'India';
gretelai_synthetic_text_to_sql
CREATE TABLE PaperWaste (Country VARCHAR(50), RecyclingRate DECIMAL(5,2)); INSERT INTO PaperWaste (Country, RecyclingRate) VALUES ('Sweden', 0.80), ('United States', 0.60), ('China', 0.40), ('India', 0.20);
Which countries have the highest and lowest recycling rates for paper waste?
SELECT Country, RecyclingRate FROM PaperWaste ORDER BY RecyclingRate DESC, Country ASC LIMIT 1; SELECT Country, RecyclingRate FROM PaperWaste ORDER BY RecyclingRate ASC, Country ASC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers (id INT, name VARCHAR(50), country VARCHAR(50), sustainability_rating INT); INSERT INTO suppliers (id, name, country, sustainability_rating) VALUES (1, 'Acme Foods', 'USA', 80); INSERT INTO suppliers (id, name, country, sustainability_rating) VALUES (2, 'Green Earth', 'Canada', 85);
Which countries have suppliers with a sustainability rating above 80?
SELECT s.country, s.sustainability_rating FROM suppliers s WHERE s.sustainability_rating > 80;
gretelai_synthetic_text_to_sql
CREATE TABLE equipment (id INT PRIMARY KEY, name VARCHAR(100), type VARCHAR(50), acquisition_date DATE, decommission_date DATE, status VARCHAR(50));
Update the status of military equipment that has been decommissioned in the 'equipment' table
UPDATE equipment SET status = 'Decommissioned' WHERE decommission_date IS NOT NULL AND status != 'Decommissioned';
gretelai_synthetic_text_to_sql
CREATE TABLE WaterUsage (UserID INT, City VARCHAR(50), Month INT, Year INT, Usage FLOAT); INSERT INTO WaterUsage (UserID, City, Month, Year, Usage) VALUES (1, 'New York', 1, 2020, 15), (2, 'Los Angeles', 2, 2020, 22);
Calculate the total water usage for each city in 2020
SELECT City, SUM(Usage) AS TotalUsage FROM WaterUsage WHERE Year = 2020 GROUP BY City;
gretelai_synthetic_text_to_sql