context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE restaurants (id INT, dish VARCHAR(255), category VARCHAR(255), calories INT);
|
What is the average calorie count for vegetarian dishes in the restaurants table?
|
SELECT AVG(calories) FROM restaurants WHERE category = 'vegetarian';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE DroughtImpact (Id INT, Location VARCHAR(100), Impact INT, Year INT); INSERT INTO DroughtImpact (Id, Location, Impact, Year) VALUES (1, 'Region1', 3, 2018); INSERT INTO DroughtImpact (Id, Location, Impact, Year) VALUES (2, 'Region1', 5, 2019); INSERT INTO DroughtImpact (Id, Location, Impact, Year) VALUES (3, 'Region2', 2, 2018); INSERT INTO DroughtImpact (Id, Location, Impact, Year) VALUES (4, 'Region2', 4, 2019);
|
Which location had the highest drought impact in 2018?
|
SELECT Location, MAX(Impact) FROM DroughtImpact WHERE Year = 2018 GROUP BY Location;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sales_data (id INT, user_id INT, city VARCHAR(50), amount DECIMAL(10,2)); INSERT INTO sales_data (id, user_id, city, amount) VALUES (1, 1, 'London', 600), (2, 2, 'Paris', 700), (3, 3, 'London', 300), (4, 4, 'Paris', 400);
|
What is the total revenue generated from users in London and Paris, for users who have spent more than $500?
|
SELECT city, SUM(amount) as total_revenue FROM sales_data WHERE city IN ('London', 'Paris') AND amount > 500 GROUP BY city;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Sustainable_Materials (Type VARCHAR(255), Price FLOAT); INSERT INTO Sustainable_Materials (Type, Price) VALUES ('Organic Cotton', 3.5), ('Recycled Polyester', 4.2), ('Hemp', 2.8);
|
Find the top 3 most expensive sustainable material types and their average prices.
|
SELECT Type, AVG(Price) as Average_Price FROM (SELECT Type, Price, ROW_NUMBER() OVER (ORDER BY Price DESC) as Rank FROM Sustainable_Materials) WHERE Rank <= 3 GROUP BY Type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SongStreams (id INT, song VARCHAR(50), country VARCHAR(20), streams INT); INSERT INTO SongStreams (id, song, country, streams) VALUES (1, 'Bohemian Rhapsody', 'USA', 1000000), (2, 'Heat Waves', 'Canada', 800000);
|
How many streams did song 'Heat Waves' by Glass Animals get in Canada?
|
SELECT streams FROM SongStreams WHERE song = 'Heat Waves' AND country = 'Canada';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cities (id INT, name VARCHAR(50)); INSERT INTO cities (id, name) VALUES (1, 'CityA'), (2, 'CityB'); CREATE TABLE projects (id INT, city_id INT, type VARCHAR(50), capacity INT); INSERT INTO projects (id, city_id, type, capacity) VALUES (1, 1, 'Solar', 1000), (2, 2, 'Solar', 2000), (3, 1, 'Wind', 1500);
|
What is the total installed solar capacity for each city?
|
SELECT c.name, SUM(p.capacity) as total_solar_capacity FROM cities c INNER JOIN projects p ON c.id = p.city_id WHERE p.type = 'Solar' GROUP BY c.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cities (id INT, name TEXT, country TEXT); CREATE TABLE recycling_centers (id INT, city_id INT, type TEXT); INSERT INTO cities VALUES (1, 'City A', 'Country A'), (2, 'City B', 'Country A'), (3, 'City C', 'Country B'); INSERT INTO recycling_centers VALUES (1, 1, 'Glass'), (2, 1, 'Paper'), (3, 2, 'Plastic'), (4, 3, 'Glass'), (5, 3, 'Plastic');
|
List the top 5 cities with the highest number of recycling centers.
|
SELECT cities.name, COUNT(recycling_centers.id) AS center_count FROM cities INNER JOIN recycling_centers ON cities.id = recycling_centers.city_id GROUP BY cities.name ORDER BY center_count DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mine (id INT, name TEXT, location TEXT); CREATE TABLE resource_extraction (id INT, mine_id INT, date DATE, quantity INT);
|
What is the total amount of resources extracted from each mine, in the past quarter?
|
SELECT mine.name, SUM(resource_extraction.quantity) as total_quantity FROM mine INNER JOIN resource_extraction ON mine.id = resource_extraction.mine_id WHERE resource_extraction.date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH) AND CURRENT_DATE GROUP BY mine.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mining_sites (site_id INT, site_name VARCHAR(50), state VARCHAR(20));CREATE VIEW environmental_impact AS SELECT site_id, SUM(pollution_level) AS total_impact FROM pollution_data GROUP BY site_id;
|
List all the mining sites located in 'California' with their respective environmental impact scores.
|
SELECT s.site_name, e.total_impact FROM mining_sites s INNER JOIN environmental_impact e ON s.site_id = e.site_id WHERE state = 'California';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE exploitation_attempts (id INT, vulnerability_id INT, attempts INT, success BOOLEAN); INSERT INTO exploitation_attempts (id, vulnerability_id, attempts, success) VALUES (1, 1, 5, true), (2, 1, 3, false), (3, 2, 10, true);
|
What is the maximum number of attempts for unsuccessful exploitation of a specific vulnerability?
|
SELECT MAX(attempts) FROM exploitation_attempts WHERE success = false;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE volunteers (id INT, program_id INT, is_active BOOLEAN);
|
Get the total number of volunteers for each program
|
SELECT p.name, COUNT(v.program_id) as total_volunteers FROM programs p JOIN volunteers v ON p.id = v.program_id GROUP BY p.id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE policy (policy_id INT, underwriter_id INT, issue_date DATE, zip_code INT, risk_score INT); CREATE TABLE claim (claim_id INT, policy_id INT, claim_amount INT);
|
What is the total number of policies and total claim amount for policies issued in the last month, grouped by underwriter?
|
SELECT underwriter_id, COUNT(policy_id) as policy_count, SUM(claim_amount) as total_claim_amount FROM claim JOIN policy ON claim.policy_id = policy.policy_id WHERE policy.issue_date >= DATEADD(MONTH, -1, GETDATE()) GROUP BY underwriter_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE landfill (id INT, name VARCHAR(20), location VARCHAR(20), capacity INT, start_date DATE); INSERT INTO landfill (id, name, location, capacity, start_date) VALUES (1, 'Mumbai Landfill', 'Mumbai', 120000, '2018-01-01');
|
Update the capacity of the landfill in Mumbai to 150000 units and update its start date to 2015-01-01.
|
UPDATE landfill SET capacity = 150000, start_date = '2015-01-01' WHERE name = 'Mumbai Landfill';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE wells (well_id INT, well_name VARCHAR(50), region VARCHAR(50), production_rate FLOAT); INSERT INTO wells (well_id, well_name, region, production_rate) VALUES (16, 'Well P', 'Caspian Sea', 7000), (17, 'Well Q', 'Caspian Sea', 8000), (18, 'Well R', 'Caspian Sea', 9000);
|
What is the maximum production rate of wells in the 'Caspian Sea'?
|
SELECT MAX(production_rate) FROM wells WHERE region = 'Caspian Sea';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE military_tech (id INT, tech_name VARCHAR(255), country VARCHAR(255), tech_date DATE);
|
What are the details of the military technologies that were developed by a specific country, say 'USA', from the 'military_tech' table?
|
SELECT * FROM military_tech WHERE country = 'USA';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE community_health_workers (id INT, name VARCHAR, location VARCHAR, patients_served INT); INSERT INTO community_health_workers (id, name, location, patients_served) VALUES (1, 'John Doe', 'Rural', 50); INSERT INTO community_health_workers (id, name, location, patients_served) VALUES (2, 'Jane Smith', 'Urban', 75);
|
How many community health workers serve patients in rural areas?
|
SELECT location, SUM(patients_served) as total_patients FROM community_health_workers WHERE location = 'Rural' GROUP BY location;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE temperature_readings (location TEXT, temperature FLOAT); INSERT INTO temperature_readings (location, temperature) VALUES ('Arctic Ocean', -2.34), ('North Atlantic', 12.56), ('North Pacific', 15.43);
|
Which ocean has the minimum temperature?
|
SELECT location FROM temperature_readings WHERE temperature = (SELECT MIN(temperature) FROM temperature_readings);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Accommodations (id INT, type VARCHAR(255), cost FLOAT, student VARCHAR(255)); CREATE TABLE Students (id INT, name VARCHAR(255), age INT, disability VARCHAR(255));
|
What is the average cost of accommodations per student for each accommodation type?
|
SELECT type, AVG(cost) FROM Accommodations GROUP BY type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE drug_approval (drug_name VARCHAR(255), country VARCHAR(255), approval_date DATE);
|
What was the approval date of a specific drug in a certain country?
|
SELECT approval_date FROM drug_approval WHERE drug_name = 'DrugB' AND country = 'CountryX';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE countries (country_name VARCHAR(50), continent VARCHAR(50)); INSERT INTO countries VALUES ('France', 'Europe'); INSERT INTO countries VALUES ('Brazil', 'South America'); CREATE TABLE world_heritage_sites (site_name VARCHAR(50), country VARCHAR(50)); INSERT INTO world_heritage_sites VALUES ('Eiffel Tower', 'France'); INSERT INTO world_heritage_sites VALUES ('Iguazu Falls', 'Brazil');
|
What is the average number of UNESCO World Heritage Sites per country in Europe?
|
SELECT C.continent, AVG(CASE WHEN C.continent = 'Europe' THEN COUNT(WHS.country) END) as avg_world_heritage_sites FROM countries C JOIN world_heritage_sites WHS ON C.country_name = WHS.country GROUP BY C.continent;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE swimming (athlete VARCHAR(50), event VARCHAR(50), time TIME);
|
What is the average time taken for each athlete to complete the swimming events, in the swimming table?
|
SELECT athlete, AVG(EXTRACT(EPOCH FROM time)/60) AS avg_time FROM swimming GROUP BY athlete;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE wastewater_facilities ( id INT PRIMARY KEY, name VARCHAR(50), facility_type VARCHAR(50), region VARCHAR(20), capacity_bod INT, operational_status VARCHAR(20) ); INSERT INTO wastewater_facilities (id, name, facility_type, region, capacity_bod, operational_status) VALUES (1, 'Facility A', 'Sewage Treatment Plant', 'Northeast', 500000, 'Operational'), (2, 'Facility B', 'Screening Facility', 'Southeast', 250000, 'Operational'), (3, 'Facility C', 'Sewage Treatment Plant', 'Midwest', 750000, 'Operational');
|
Increase the capacity of the 'Screening Facility' in the 'Southeast' region in the wastewater_facilities table by 50000 BOD
|
UPDATE wastewater_facilities SET capacity_bod = capacity_bod + 50000 WHERE name = 'Facility B' AND region = 'Southeast';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE WasteReduction (reduction_date DATE, waste_reduction INT, biodegradable_materials BOOLEAN);
|
What was the total waste reduction in the USA in Q1 2022 from using biodegradable materials?
|
SELECT SUM(waste_reduction) FROM WasteReduction WHERE reduction_date BETWEEN '2022-01-01' AND '2022-03-31' AND biodegradable_materials = TRUE AND country = 'USA';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE investment (id INT, company_id INT, investor TEXT, year INT, amount FLOAT); INSERT INTO investment (id, company_id, investor, year, amount) VALUES (1, 1, 'Kleiner Perkins', 2022, 12000000.0); CREATE TABLE company (id INT, name TEXT, industry TEXT, founder TEXT, PRIMARY KEY (id)); INSERT INTO company (id, name, industry, founder) VALUES (1, 'HealFast', 'Healthcare', 'Female');
|
How many investments have been made in women-founded startups in the healthcare sector in the last 2 years?
|
SELECT COUNT(*) FROM investment i JOIN company c ON i.company_id = c.id WHERE c.founder = 'Female' AND c.industry = 'Healthcare' AND i.year >= (SELECT YEAR(CURRENT_DATE()) - 2);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ticket_sales (sale_date DATE, team VARCHAR(50), tickets_sold INT); INSERT INTO ticket_sales (sale_date, team, tickets_sold) VALUES ('2022-01-01', 'Team A', 1000), ('2022-01-02', 'Team B', 1200), ('2022-02-01', 'Team A', 1500);
|
Display total ticket sales by month
|
SELECT DATE_FORMAT(sale_date, '%Y-%m') AS month, SUM(tickets_sold) AS total_sales FROM ticket_sales GROUP BY month;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE military_threats (threat_id INT, country VARCHAR(255), level VARCHAR(255), threat_date DATE);
|
List the top 5 military threats in the last month
|
SELECT country, level, threat_date FROM military_threats WHERE threat_date >= DATE(NOW()) - INTERVAL 1 MONTH ORDER BY threat_date DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE events (id INT, title VARCHAR(50), event_type VARCHAR(50), city VARCHAR(50), tickets_sold INT); INSERT INTO events (id, title, event_type, city, tickets_sold) VALUES (1, 'The Nutcracker', 'theater', 'Chicago', 1800); INSERT INTO events (id, title, event_type, city, tickets_sold) VALUES (2, 'Swan Lake', 'dance', 'Chicago', 1400); INSERT INTO events (id, title, event_type, city, tickets_sold) VALUES (3, 'Mozart Requiem', 'music', 'Chicago', 1200);
|
How many tickets were sold for each event type (theater, dance, music) at cultural centers in Chicago?
|
SELECT event_type, SUM(tickets_sold) FROM events WHERE city = 'Chicago' GROUP BY event_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE AssetTransactions (AssetID int, TransactionDate date, Value float); INSERT INTO AssetTransactions (AssetID, TransactionDate, Value) VALUES (1, '2021-01-02', 100.5), (2, '2021-02-15', 250.7), (3, '2021-05-03', 75.3), (1, '2021-12-30', 1500.0);
|
What is the average transaction value per digital asset?
|
SELECT AssetID, AVG(Value) as AvgTransactionValue FROM AssetTransactions GROUP BY AssetID;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE space_exploration (id INT, mission_name VARCHAR(255), mission_status VARCHAR(255), agency VARCHAR(255), launch_date DATE);
|
Show all records in the space_exploration table where the mission_status is 'Active' and agency is 'NASA'
|
SELECT * FROM space_exploration WHERE mission_status = 'Active' AND agency = 'NASA';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE financial_wellbeing_gender (person_id INT, gender VARCHAR(6), score INT); INSERT INTO financial_wellbeing_gender (person_id, gender, score) VALUES (1, 'Male', 7), (2, 'Female', 8), (3, 'Male', 9), (4, 'Female', 6), (5, 'Male', 8);
|
What is the average financial wellbeing score for each gender?
|
SELECT gender, AVG(score) FROM financial_wellbeing_gender GROUP BY gender;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE products (id INT, name TEXT, material TEXT, sustainable BOOLEAN); INSERT INTO products (id, name, material, sustainable) VALUES (1, 'Shirt', 'Organic Cotton', 1), (2, 'Pants', 'Conventional Cotton', 0);
|
How many items are made of materials that are not sustainably sourced?
|
SELECT COUNT(*) FROM products WHERE sustainable = 0;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE innovations (id INT PRIMARY KEY, innovation_name VARCHAR(100), description TEXT, category VARCHAR(50), funding FLOAT);
|
Update the funding for military innovations in the 'innovations' table
|
UPDATE innovations SET funding = 12000000.00 WHERE innovation_name = 'Hypersonic Missile';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE BuildingPermits (PermitID INT, PermitType TEXT, DateIssued DATE, City TEXT);
|
What is the total number of building permits issued in each city, for the past year?
|
SELECT City, Count(PermitID) AS Count FROM BuildingPermits WHERE DateIssued >= DATEADD(year, -1, GETDATE()) GROUP BY City;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Textile_Suppliers (supplier_id INT, supplier_name TEXT, country TEXT, is_sustainable BOOLEAN); CREATE TABLE Brands_Textile_Suppliers (brand_id INT, supplier_id INT); CREATE TABLE Brands (brand_id INT, brand_name TEXT, country TEXT, is_sustainable BOOLEAN);
|
What are the top 5 textile suppliers for sustainable brands in Germany?
|
SELECT s.supplier_name, COUNT(DISTINCT bts.brand_id) as sustainable_brand_count FROM Textile_Suppliers s JOIN Brands_Textile_Suppliers bts ON s.supplier_id = bts.supplier_id JOIN Brands b ON bts.brand_id = b.brand_id WHERE s.is_sustainable = TRUE AND b.country = 'Germany' GROUP BY s.supplier_name ORDER BY sustainable_brand_count DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE users (id INT PRIMARY KEY, name VARCHAR(50), email VARCHAR(50), signup_date DATE, signup_source VARCHAR(20));
|
Delete all users who signed up using a social media account
|
DELETE FROM users WHERE signup_source IN ('facebook', 'twitter', 'google');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SatelliteOrbits (SatelliteID INT, OrbitType VARCHAR(50), OrbitHeight INT); INSERT INTO SatelliteOrbits (SatelliteID, OrbitType, OrbitHeight) VALUES (101, 'LEO', 500), (201, 'MEO', 8000), (301, 'GEO', 36000), (401, 'LEO', 600), (501, 'MEO', 10000);
|
Which satellites are in a specific orbit type, based on the SatelliteOrbits table?
|
SELECT SatelliteID, OrbitType FROM SatelliteOrbits WHERE OrbitType = 'LEO';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ResearchProjects (Id INT, Name TEXT, Location TEXT); INSERT INTO ResearchProjects (Id, Name, Location) VALUES (1, 'Project A', 'Japan'); INSERT INTO ResearchProjects (Id, Name, Location) VALUES (2, 'Project B', 'South Korea');
|
What is the total number of autonomous driving research projects in Japan and South Korea?
|
SELECT COUNT(*) FROM ResearchProjects WHERE Location IN ('Japan', 'South Korea');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE company (id INT, name VARCHAR(255), country VARCHAR(255), num_employees INT, avg_salary DECIMAL(10,2));CREATE VIEW mining_companies AS SELECT * FROM company WHERE industry = 'Mining';
|
What is the average salary of employees in mining companies in the top 3 countries with the highest total salary costs?
|
SELECT AVG(c.avg_salary) as avg_salary FROM company c JOIN (SELECT country, SUM(num_employees * avg_salary) as total_salary_costs FROM mining_companies GROUP BY country ORDER BY total_salary_costs DESC LIMIT 3) mc ON c.country = mc.country WHERE c.industry = 'Mining';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ArtHeritage (id INT, name VARCHAR(50), type VARCHAR(50), year INT, country VARCHAR(50)); INSERT INTO ArtHeritage (id, name, type, year, country) VALUES (1, 'Pottery', 'Art', 2005, 'Mexico'); INSERT INTO ArtHeritage (id, name, type, year, country) VALUES (2, 'Woven Baskets', 'Art', 1950, 'USA');
|
Which art pieces in the 'ArtHeritage' table have been preserved for more than 50 years?
|
SELECT name, type, year, country FROM ArtHeritage WHERE year <= (EXTRACT(YEAR FROM CURRENT_DATE) - 50);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE financial_capability (individual_id TEXT, training_date DATE, country TEXT); INSERT INTO financial_capability (individual_id, training_date, country) VALUES ('11111', '2022-01-01', 'Germany'); INSERT INTO financial_capability (individual_id, training_date, country) VALUES ('22222', '2022-02-01', 'France');
|
What is the number of individuals in Europe who have received financial capability training in the last 12 months?
|
SELECT COUNT(individual_id) FROM financial_capability WHERE training_date >= DATEADD(year, -1, CURRENT_DATE) AND country = 'Europe';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE properties (id INT, city VARCHAR(50), state VARCHAR(2), build_date DATE, co_owners INT); INSERT INTO properties (id, city, state, build_date, co_owners) VALUES (1, 'Austin', 'TX', '2015-01-01', 2), (2, 'Dallas', 'TX', '2005-01-01', 1);
|
Find the number of co-owned properties in Austin, TX that were built after 2010.
|
SELECT COUNT(*) FROM properties WHERE city = 'Austin' AND state = 'TX' AND build_date > '2010-01-01' AND co_owners > 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CustomerSizesUS (CustomerID INT, Country TEXT, AvgSize DECIMAL(5,2)); INSERT INTO CustomerSizesUS (CustomerID, Country, AvgSize) VALUES (1, 'US', 8.5), (2, 'US', 7.5), (3, 'US', 9.5), (4, 'US', 6.5); CREATE TABLE CustomerSizesCA (CustomerID INT, Country TEXT, AvgSize DECIMAL(5,2)); INSERT INTO CustomerSizesCA (CustomerID, Country, AvgSize) VALUES (1, 'Canada', 7.0), (2, 'Canada', 6.0), (3, 'Canada', 8.0), (4, 'Canada', 9.0);
|
What is the difference in average customer size between the US and Canada?
|
SELECT AVG(CSUS.AvgSize) - AVG(CSCA.AvgSize) FROM CustomerSizesUS CSUS, CustomerSizesCA CSCA WHERE CSUS.Country = 'US' AND CSCA.Country = 'Canada';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE if not exists habitat_monitoring (id INT, habitat VARCHAR(255), animal VARCHAR(255), PRIMARY KEY(id, habitat, animal)); INSERT INTO habitat_monitoring (id, habitat, animal) VALUES (1, 'Forest', 'Gorilla'), (2, 'Grassland', 'Lion'), (3, 'Wetlands', 'Crocodile'), (4, 'Forest', 'Elephant'), (5, 'Forest', 'Gorilla');
|
Count of monitored habitats with gorillas
|
SELECT habitat, COUNT(*) FROM habitat_monitoring WHERE animal = 'Gorilla' GROUP BY habitat;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE graduates (id INT, name VARCHAR(50), department VARCHAR(50), gpa DECIMAL(3,2)); INSERT INTO graduates (id, name, department, gpa) VALUES (1, 'James Smith', 'Mathematics', 3.3), (2, 'Emily Johnson', 'Physics', 2.9);
|
Delete graduate student records with GPA below 3.0.
|
DELETE FROM graduates WHERE gpa < 3.0;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE nba_games (game_id INT, home_team_id INT, away_team_id INT); CREATE TABLE nba_game_scores (game_id INT, team_id INT, player_name VARCHAR(255), points INT);
|
Identify the players who scored more than 30 points in a game, for each game in the 'nba_games' table.
|
SELECT game_id, home_team_id AS team_id, player_name, points FROM nba_game_scores WHERE points > 30 UNION ALL SELECT game_id, away_team_id, player_name, points FROM nba_game_scores WHERE points > 30;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE facility_data (facility_id INT, facility_location VARCHAR(255), CO2_emission INT, year INT);
|
What is the CO2 emission of each production facility in the Asia-Pacific region for the year 2021?
|
SELECT facility_location, SUM(CO2_emission) AS total_CO2_emission FROM facility_data WHERE facility_location LIKE 'Asia-Pacific%' AND year = 2021 GROUP BY facility_location;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE DancePrograms (programID INT, communityType VARCHAR(20), fundingAmount DECIMAL(10,2)); INSERT INTO DancePrograms (programID, communityType, fundingAmount) VALUES (1, 'Underrepresented', 25000.00), (2, 'General', 15000.00), (3, 'Underrepresented', 30000.00);
|
What is the total funding received by dance programs targeting underrepresented communities?
|
SELECT SUM(fundingAmount) FROM DancePrograms WHERE communityType = 'Underrepresented';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hotel_revenue (hotel_id INT, country VARCHAR(20), daily_revenue FLOAT); INSERT INTO hotel_revenue (hotel_id, country, daily_revenue) VALUES (1, 'France', 100), (2, 'France', 120), (3, 'Italy', 150), (4, 'Italy', 140); CREATE TABLE museum_visitors (visit_id INT, country VARCHAR(20), daily_visitors INT); INSERT INTO museum_visitors (visit_id, country, daily_visitors) VALUES (1, 'France', 50), (2, 'France', 60), (3, 'Italy', 70), (4, 'Italy', 80);
|
Find the average daily revenue of eco-friendly hotels in France and Italy, and the average daily visitor count to museums in these two countries.
|
SELECT AVG(daily_revenue) FROM hotel_revenue WHERE country = 'France' UNION ALL SELECT AVG(daily_visitors) FROM museum_visitors WHERE country = 'France' UNION ALL SELECT AVG(daily_revenue) FROM hotel_revenue WHERE country = 'Italy' UNION ALL SELECT AVG(daily_visitors) FROM museum_visitors WHERE country = 'Italy';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE city_electric_vehicles (city_name VARCHAR(255), country VARCHAR(255), num_electric_vehicles INT); INSERT INTO city_electric_vehicles (city_name, country, num_electric_vehicles) VALUES ('San Francisco', 'USA', 15000), ('Los Angeles', 'USA', 20000), ('Toronto', 'Canada', 10000), ('Montreal', 'Canada', 8000), ('Mexico City', 'Mexico', 5000);
|
What is the average number of electric vehicles per city in the 'transportation' schema, grouped by country?
|
SELECT country, AVG(num_electric_vehicles) FROM city_electric_vehicles GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE production (id INT, country VARCHAR(255), element VARCHAR(255), quantity INT); INSERT INTO production (id, country, element, quantity) VALUES (1, 'China', 'Terbium', 900), (2, 'China', 'Lanthanum', 8000), (3, 'USA', 'Terbium', 700), (4, 'USA', 'Lanthanum', 5000), (5, 'Australia', 'Terbium', 800), (6, 'Australia', 'Lanthanum', 6000);
|
Identify the countries that have higher production of Terbium than Lanthanum.
|
SELECT country FROM production WHERE element = 'Terbium' AND quantity > (SELECT quantity FROM production WHERE element = 'Lanthanum' AND country = production.country) GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE malware_data (id INT, name VARCHAR(255), region VARCHAR(255), last_seen DATETIME); INSERT INTO malware_data (id, name, region, last_seen) VALUES (1, 'WannaCry', 'Asia-Pacific', '2022-01-01 12:00:00'), (2, 'Emotet', 'North America', '2022-01-02 13:00:00');
|
Which malware has been detected in the 'Asia-Pacific' region in the last week?
|
SELECT name FROM malware_data WHERE region = 'Asia-Pacific' AND last_seen >= DATE_SUB(NOW(), INTERVAL 1 WEEK);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE water_conservation_initiatives (id INT, name VARCHAR(50), description TEXT, start_date DATE, end_date DATE);
|
Insert a new water conservation initiative
|
INSERT INTO water_conservation_initiatives (id, name, description, start_date, end_date) VALUES (1, 'Watering Restrictions', 'Restrictions on watering lawns and gardens', '2023-01-01', '2023-12-31');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hospitals_indonesia (id INT, name TEXT, personnel INT); INSERT INTO hospitals_indonesia (id, name, personnel) VALUES (1, 'Hospital Z', 250);
|
What is the average number of medical personnel per hospital in Indonesia?
|
SELECT AVG(personnel) FROM hospitals_indonesia;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE region (id INT, name VARCHAR(255), rainfall FLOAT, rainfall_timestamp DATETIME); INSERT INTO region (id, name, rainfall, rainfall_timestamp) VALUES (1, 'MX-SON', 15.5, '2022-02-25 14:30:00'), (2, 'MX-SIN', 13.8, '2022-02-27 09:15:00'), (3, 'MX-CHI', 17.9, '2022-03-01 12:00:00');
|
What is the total rainfall in the last week for region 'MX-SON'?
|
SELECT SUM(rainfall) FROM region WHERE name = 'MX-SON' AND rainfall_timestamp >= DATEADD(week, -1, CURRENT_TIMESTAMP);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE timber_production_2 (id INT, name VARCHAR(50), area FLOAT); INSERT INTO timber_production_2 (id, name, area) VALUES (1, 'Timber Inc.', 1000.0), (2, 'WoodCo', 600.0), (3, 'Forest Ltd.', 1200.0);
|
Which timber production sites have an area larger than 800?
|
SELECT name FROM timber_production_2 WHERE area > 800;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE event_attendance_2 (event_name VARCHAR(50), city VARCHAR(50), attendees INT); INSERT INTO event_attendance_2 (event_name, city, attendees) VALUES ('Film Appreciation', 'Seattle', 25);
|
Which 'Film Appreciation' events in Seattle had less than 30 attendees?
|
SELECT event_name, city FROM event_attendance_2 WHERE event_name = 'Film Appreciation' AND city = 'Seattle' AND attendees < 30;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE military_spending (country VARCHAR(50), region VARCHAR(50), spending NUMERIC(10,2)); INSERT INTO military_spending (country, region, spending) VALUES ('USA', 'North America', 7319340000), ('Canada', 'North America', 22597000000), ('Mexico', 'North America', 640000000);
|
What is the average military spending by countries in the North American region?
|
SELECT AVG(spending) FROM military_spending WHERE region = 'North America';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE student_mental_health (student_id INT, mental_health_score INT); INSERT INTO student_mental_health (student_id, mental_health_score) VALUES (1, 80), (2, 85), (3, 70), (4, 82), (5, 78), (6, 75);
|
How many students have a mental health score greater than 80?
|
SELECT COUNT(*) FROM student_mental_health WHERE mental_health_score > 80;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Events (id INT, state VARCHAR(50), date DATE, event_type VARCHAR(50)); INSERT INTO Events (id, state, date, event_type) VALUES (1, 'California', '2021-01-01', 'Comedy'), (2, 'New York', '2021-02-01', 'Comedy'); CREATE TABLE Attendance (id INT, event_id INT, is_new_attendee BOOLEAN, gender VARCHAR(10)); INSERT INTO Attendance (id, event_id, is_new_attendee, gender) VALUES (1, 1, TRUE, 'Female'), (2, 1, TRUE, 'Male'), (3, 2, FALSE, 'Non-binary');
|
How many unique first-time attendees were there at comedy events, in the past six months, for each state and gender?
|
SELECT e.state, a.gender, COUNT(DISTINCT a.id) AS count FROM Events e INNER JOIN Attendance a ON e.id = a.event_id AND a.is_new_attendee = TRUE WHERE e.date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) AND e.event_type = 'Comedy' GROUP BY e.state, a.gender;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE adaptation_measures (region TEXT, year INT, measure TEXT); INSERT INTO adaptation_measures (region, year, measure) VALUES ('Asia', 2015, 'Building sea walls'), ('Asia', 2015, 'Planting mangroves'), ('Asia', 2018, 'Improving irrigation systems'), ('Asia', 2018, 'Constructing early warning systems'), ('South America', 2015, 'Building flood defenses'), ('South America', 2018, 'Implementing afforestation programs'), ('Africa', 2015, 'Constructing dikes'), ('Africa', 2018, 'Promoting climate-smart agriculture');
|
Which adaptation measures were implemented in South America in 2018?
|
SELECT measure FROM adaptation_measures WHERE region = 'South America' AND year = 2018;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE buildings (id INT, name TEXT, state TEXT, co2_emissions FLOAT); INSERT INTO buildings (id, name, state, co2_emissions) VALUES (1, 'Building A', 'Texas', 120.5), (2, 'Building B', 'California', 150.3), (3, 'Building C', 'California', 100.2);
|
Update the CO2 emissions of Building A in Texas to 110.5.
|
UPDATE buildings SET co2_emissions = 110.5 WHERE name = 'Building A' AND state = 'Texas';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE co2_emission (garment_type VARCHAR(20), country VARCHAR(20), year INT, co2_emission FLOAT); INSERT INTO co2_emission (garment_type, country, year, co2_emission) VALUES ('tops', 'Brazil', 2020, 5.5), ('bottoms', 'Brazil', 2020, 6.2), ('dresses', 'Brazil', 2020, 4.8);
|
What was the minimum CO2 emission for any garment production in Brazil in 2020?
|
SELECT MIN(co2_emission) FROM co2_emission WHERE country = 'Brazil' AND year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE social_impact_bonds (bond_id INT, bond_name TEXT, issuer_country TEXT); CREATE TABLE esg_scores (bond_id INT, esg_score INT); INSERT INTO social_impact_bonds (bond_id, bond_name, issuer_country) VALUES (1, 'SIB A', 'USA'), (2, 'SIB B', 'Germany'); INSERT INTO esg_scores (bond_id, esg_score) VALUES (1, 80), (2, 85);
|
List all social impact bonds along with their issuer countries and the corresponding ESG scores.
|
SELECT s.bond_name, s.issuer_country, e.esg_score FROM social_impact_bonds s JOIN esg_scores e ON s.bond_id = e.bond_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ElectricVehicles (id INT, name VARCHAR(50), horsepower INT, release_year INT); INSERT INTO ElectricVehicles (id, name, horsepower, release_year) VALUES (1, 'Tesla Model 3', 258, 2020); INSERT INTO ElectricVehicles (id, name, horsepower, release_year) VALUES (2, 'Nissan Leaf', 147, 2020);
|
What is the average horsepower of electric vehicles released in 2020?
|
SELECT AVG(horsepower) FROM ElectricVehicles WHERE release_year = 2020 AND horsepower IS NOT NULL;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ports (id INT, name VARCHAR(50)); CREATE TABLE cargo_handling (id INT, port_id INT, date DATE, cargo_weight INT); INSERT INTO ports (id, name) VALUES (1, 'PortA'), (2, 'PortB'); INSERT INTO cargo_handling (id, port_id, date, cargo_weight) VALUES (1, 1, '2021-01-01', 5000), (2, 2, '2021-02-01', 6000);
|
List all ports with their corresponding cargo handling records, sorted by the date of cargo handling in descending order.
|
SELECT ports.name, cargo_handling.date, cargo_handling.cargo_weight FROM ports INNER JOIN cargo_handling ON ports.id = cargo_handling.port_id ORDER BY cargo_handling.date DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE PolicyEvents (city VARCHAR(50), event_category VARCHAR(50), participation INT); INSERT INTO PolicyEvents (city, event_category, participation) VALUES ('CityA', 'Workshop', 50), ('CityA', 'Meeting', 30), ('CityB', 'Workshop', 40), ('CityB', 'Conference', 60);
|
What is the total number of policy making events in each city, partitioned by event category?
|
SELECT city, event_category, SUM(participation) AS total_participation FROM PolicyEvents GROUP BY city, event_category;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE chemical_substances (substance_id INT, substance_name VARCHAR(255)); INSERT INTO chemical_substances (substance_id, substance_name) VALUES (1, 'SubstanceA'), (2, 'SubstanceB'), (3, 'SubstanceC'), (4, 'SubstanceA');
|
How many unique chemical substances are there in the chemical_substances table?
|
SELECT COUNT(DISTINCT substance_name) AS unique_substances FROM chemical_substances;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE excavation_sites (site_id INT, site_name VARCHAR(50), country VARCHAR(50)); INSERT INTO excavation_sites (site_id, site_name, country) VALUES (1, 'Site A', 'USA'); CREATE TABLE artifacts (artifact_id INT, site_id INT, excavation_date DATE);
|
What was the earliest excavation date for each site?
|
SELECT e.site_name, MIN(a.excavation_date) as earliest_date FROM excavation_sites e JOIN artifacts a ON e.site_id = a.site_id GROUP BY e.site_id, e.site_name ORDER BY earliest_date ASC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE space_debris (debris_id INT, name VARCHAR(100), origin VARCHAR(100), mass FLOAT, launch_date DATE);
|
What is the total mass of space debris in the space_debris table, in kilograms, for debris with a known origin?
|
SELECT SUM(mass) FROM space_debris WHERE origin IS NOT NULL;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE protected_zone (tree_id INT, species VARCHAR(50), age INT, height INT, location VARCHAR(50));CREATE TABLE unprotected_zone (tree_id INT, species VARCHAR(50), age INT, height INT, location VARCHAR(50));
|
What is the average height of trees in the protected_zone table, and how does it compare to the average height of trees in the unprotected_zone table?
|
SELECT AVG(height) FROM protected_zone;SELECT AVG(height) FROM unprotected_zone;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE drug_approval (drug_name VARCHAR(255), approval_date DATE); INSERT INTO drug_approval (drug_name, approval_date) VALUES ('Drug A', '2018-01-01'), ('Drug B', '2018-06-15'), ('Drug C', '2018-12-25');
|
What was the average drug approval time for drugs approved in 2018?
|
SELECT AVG(DATEDIFF('2018-12-31', approval_date)) FROM drug_approval;
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA municipality; CREATE SCHEMA city; CREATE SCHEMA county; CREATE TABLE municipality.policy_data (id INT, name VARCHAR(255), is_evidence_based BOOLEAN); CREATE TABLE city.policy_data (id INT, name VARCHAR(255), is_evidence_based BOOLEAN); CREATE TABLE county.policy_data (id INT, name VARCHAR(255), is_evidence_based BOOLEAN); INSERT INTO municipality.policy_data (id, name, is_evidence_based) VALUES (1, 'transportation', true), (2, 'housing', false), (3, 'education', true); INSERT INTO city.policy_data (id, name, is_evidence_based) VALUES (1, 'transportation', true), (2, 'housing', false); INSERT INTO county.policy_data (id, name, is_evidence_based) VALUES (1, 'transportation', true), (2, 'health', true);
|
Find the total number of evidence-based policy making data sets in 'municipality', 'city', and 'county' schemas.
|
SELECT COUNT(*) FROM ( (SELECT * FROM municipality.policy_data WHERE is_evidence_based = true) UNION (SELECT * FROM city.policy_data WHERE is_evidence_based = true) UNION (SELECT * FROM county.policy_data WHERE is_evidence_based = true) ) AS combined_policy_data;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_sites (site_id INT, site_name VARCHAR(255), longitude DECIMAL(9,6), latitude DECIMAL(9,6), depth DECIMAL(5,2));
|
Find the average depth of all marine life research sites
|
SELECT AVG(depth) FROM marine_sites;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE eSports_games_3 (id INT, team1 TEXT, team2 TEXT, winner TEXT); INSERT INTO eSports_games_3 (id, team1, team2, winner) VALUES (1, 'Green', 'Blue', 'Green'), (2, 'Yellow', 'Green', 'Yellow'), (3, 'Green', 'Purple', 'Green');
|
What is the percentage of games won by team 'Green' in the eSports tournament?
|
SELECT (COUNT(*) FILTER (WHERE winner = 'Green')) * 100.0 / COUNT(*) FROM eSports_games_3 WHERE team1 = 'Green' OR team2 = 'Green';
|
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), (4, 'onshore', 'Alberta', 900);
|
Find the wells with production rates in the top 10 percentile.
|
SELECT * FROM (SELECT well_id, well_type, location, production_rate, PERCENT_RANK() OVER (ORDER BY production_rate DESC) pr FROM wells) t WHERE pr >= 0.9;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE startup (id INT, industry TEXT, founder_demographics TEXT); INSERT INTO startup (id, industry, founder_demographics) VALUES (1, 'Software', 'Latinx Female'), (2, 'Hardware', 'Asian Male'), (3, 'Healthcare', 'Latinx Non-binary'), (4, 'AI', 'Black Female');
|
List the unique industries for startups founded by Latinx individuals that have received Series A funding or higher.
|
SELECT DISTINCT industry FROM startup WHERE founder_demographics LIKE '%Latinx%' AND industry IN ('Series A', 'Series B', 'Series C', 'Series D', 'Series E');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE assists (assist_id INT, player_id INT, match_id INT, team_id INT, assists INT); INSERT INTO assists (assist_id, player_id, match_id, team_id, assists) VALUES (1, 12, 13, 107, 6);
|
What is the average number of assists per basketball player in the 'assists' table?
|
SELECT AVG(assists) FROM assists;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE invoices (invoice_id INT, invoice_date DATE);
|
Delete all records from the 'invoices' table where invoice_date is older than 6 months
|
DELETE FROM invoices WHERE invoice_date < (CURRENT_DATE - INTERVAL '6 months');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sales (sale_id INT, dish_id INT, sale_price DECIMAL(5,2), country VARCHAR(255)); INSERT INTO sales (sale_id, dish_id, sale_price, country) VALUES (1, 1, 9.99, 'USA'), (2, 3, 7.99, 'Mexico'), (3, 2, 12.99, 'USA'); CREATE TABLE dishes (dish_id INT, dish_name VARCHAR(255), cuisine VARCHAR(255)); INSERT INTO dishes (dish_id, dish_name, cuisine) VALUES (1, 'Quinoa Salad', 'Mediterranean'), (2, 'Chicken Caesar Wrap', 'Mediterranean'), (3, 'Tacos', 'Mexican');
|
Identify dishes that contribute to the least revenue
|
SELECT d.dish_id, d.dish_name, SUM(s.sale_price) as revenue FROM dishes d LEFT JOIN sales s ON d.dish_id = s.dish_id GROUP BY d.dish_id, d.dish_name ORDER BY revenue ASC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE patients (id INT, country VARCHAR(255)); CREATE TABLE treatments (id INT, patient_id INT, treatment_date DATE); CREATE TABLE conditions (id INT, patient_id INT, condition VARCHAR(255)); INSERT INTO patients (id, country) VALUES (1, 'Germany'), (2, 'Germany'), (3, 'Germany'), (4, 'Germany'); INSERT INTO treatments (id, patient_id, treatment_date) VALUES (1, 1, '2020-01-01'), (2, 1, '2020-02-15'), (3, 2, '2020-06-30'), (4, 3, '2020-12-31'); INSERT INTO conditions (id, patient_id, condition) VALUES (1, 1, 'depression'), (2, 1, 'anxiety'), (3, 2, 'anxiety'), (4, 3, 'bipolar');
|
Which mental health conditions were treated most frequently in Germany during 2020?
|
SELECT conditions.condition, COUNT(conditions.condition) AS count FROM conditions JOIN patients ON conditions.patient_id = patients.id JOIN treatments ON patients.id = treatments.patient_id WHERE patients.country = 'Germany' AND treatments.treatment_date >= '2020-01-01' AND treatments.treatment_date < '2021-01-01' GROUP BY conditions.condition ORDER BY count DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sa_models (model_name TEXT, region TEXT, explainability_score INTEGER); INSERT INTO sa_models (model_name, region, explainability_score) VALUES ('Model1', 'South America', 90), ('Model2', 'South America', 80), ('Model3', 'South America', 88);
|
What is the total number of AI models developed in South America with an explainability score above 85?
|
SELECT SUM(incident_count) FROM sa_models WHERE region = 'South America' AND explainability_score > 85;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE rental_cars (id INT, country VARCHAR(255), co2_emission INT); INSERT INTO rental_cars (id, country, co2_emission) VALUES (1, 'USA', 150), (2, 'USA', 180), (3, 'Germany', 120), (4, 'Germany', 130), (5, 'Brazil', 200), (6, 'Brazil', 220), (7, 'India', 100), (8, 'India', 110);
|
What is the average CO2 emission of rental cars in each country, ranked by the highest emission?
|
SELECT country, AVG(co2_emission) AS avg_co2_emission, RANK() OVER (ORDER BY AVG(co2_emission) DESC) AS rank FROM rental_cars GROUP BY country ORDER BY rank;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Training_Programs (Program_Name VARCHAR(50), Trainer VARCHAR(20), Location VARCHAR(20), Start_Date DATE, End_Date DATE); CREATE TABLE Trainers (Trainer_ID INT, Trainer VARCHAR(20), Specialization VARCHAR(20));
|
List all trainers who have conducted diversity and inclusion training in the USA or Canada.
|
SELECT Trainer FROM Training_Programs WHERE Program_Name LIKE '%diversity%' AND (Location = 'USA' OR Location = 'Canada') INTERSECT SELECT Trainer FROM Trainers;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Digital_Interactions (id INT, location VARCHAR(50), quarter INT, year INT, interaction_count INT);
|
Find the total number of digital museum interactions in New York and Chicago in Q2 of 2020.
|
SELECT SUM(interaction_count) FROM Digital_Interactions WHERE location IN ('New York', 'Chicago') AND quarter = 2 AND year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE transactions (transaction_id INT, transaction_type VARCHAR(20), transaction_fee DECIMAL(10,2)); INSERT INTO transactions (transaction_id, transaction_type, transaction_fee) VALUES (1, 'Gold', 50.00), (2, 'Silver', 25.00);
|
What is the total transaction fee for all gold transactions?
|
SELECT SUM(transaction_fee) FROM transactions WHERE transaction_type = 'Gold';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE network_investments (investment_id INT, investment_type VARCHAR(50), investment_date DATE, investment_amount DECIMAL(10,2));
|
Delete all records from the network_investments table where the investment_date is older than 3 years
|
DELETE FROM network_investments WHERE investment_date < (CURRENT_DATE - INTERVAL '3' YEAR);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE EsportsEvents (PlayerID INT, Game VARCHAR(20), Event VARCHAR(20)); INSERT INTO EsportsEvents (PlayerID, Game, Event) VALUES (1, 'Counter-Strike: Global Offensive', 'ESL One Cologne'), (2, 'StarCraft II', 'WCS Global Finals'), (3, 'Fortnite', 'World Cup');
|
Show the total number of esports events for 'Counter-Strike: Global Offensive' and 'StarCraft II'
|
SELECT COUNT(DISTINCT Event) FROM EsportsEvents WHERE Game IN ('Counter-Strike: Global Offensive', 'StarCraft II')
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE RecyclingRates (WasteType VARCHAR(50), Region VARCHAR(50), RecyclingRate DECIMAL(5,2)); INSERT INTO RecyclingRates (WasteType, Region, RecyclingRate) VALUES ('Municipal Solid Waste', 'European Union', 0.35), ('Industrial Waste', 'European Union', 0.70), ('Municipal Solid Waste', 'United States', 0.30), ('Industrial Waste', 'United States', 0.65);
|
Which recycling rates are higher, for municipal solid waste or for industrial waste, in the European Union?
|
SELECT WasteType, RecyclingRate FROM RecyclingRates WHERE Region = 'European Union' AND WasteType IN ('Municipal Solid Waste', 'Industrial Waste') ORDER BY RecyclingRate DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Space_Missions (Mission VARCHAR(50), Duration INT, Launch_Date DATE); INSERT INTO Space_Missions (Mission, Duration, Launch_Date) VALUES ('Mission1', 123, '2021-01-01'), ('Mission2', 456, '2021-02-01'), ('Mission3', 789, '2021-03-01');
|
List space missions with duration more than the average, along with their mission names and launch dates.
|
SELECT Mission, Duration, Launch_Date FROM Space_Missions WHERE Duration > (SELECT AVG(Duration) FROM Space_Missions);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE clients (client_id INT, name TEXT, region TEXT, transaction_amount DECIMAL); INSERT INTO clients (client_id, name, region, transaction_amount) VALUES (1, 'John Doe', 'Asia', 500.00); INSERT INTO clients (client_id, name, region, transaction_amount) VALUES (2, 'Jane Smith', 'Europe', 600.00); INSERT INTO clients (client_id, name, region, transaction_amount) VALUES (3, 'Mike Johnson', 'Asia', 400.00);
|
Increase the transaction amount for the client with the highest transaction by 10%.
|
UPDATE clients SET transaction_amount = transaction_amount * 1.10 WHERE client_id = (SELECT client_id FROM clients WHERE transaction_amount = (SELECT MAX(transaction_amount) FROM clients));
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE malware (type VARCHAR(50), affected_software TEXT); INSERT INTO malware (type, affected_software) VALUES ('Ransomware', 'Windows 7, Windows 10');
|
List the unique malware types and their affected software for the healthcare sector, sorted by malware type.
|
SELECT DISTINCT type, affected_software FROM malware WHERE type IN (SELECT type FROM malware_sectors WHERE sector = 'Healthcare') ORDER BY type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE temperature (temp_id INT, location TEXT, temperature FLOAT); INSERT INTO temperature (temp_id, location, temperature) VALUES (1, 'Atlantic', 20.5), (2, 'Indian', 25.7);
|
What is the average temperature in the Atlantic and Indian oceans?
|
SELECT AVG(temperature) FROM temperature WHERE location IN ('Atlantic', 'Indian')
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE malicious_activity (id INT, type VARCHAR(50), timestamp DATETIME);
|
What are the top 5 most common types of malicious activity in the last week?
|
SELECT type, COUNT(*) as num_occurrences FROM malicious_activity WHERE timestamp > DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK) GROUP BY type ORDER BY num_occurrences DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Expenses (expense_id INT, category VARCHAR(50), amount DECIMAL(10,2)); INSERT INTO Expenses (expense_id, category, amount) VALUES (1, 'Office Supplies', 100.00);
|
Insert a new record into the 'Expenses' table for 'Travel Expenses'
|
INSERT INTO Expenses (expense_id, category, amount) VALUES (2, 'Travel Expenses', 0);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE VeganSkincareSales (sale_id INT, product_name TEXT, is_vegan BOOLEAN, sale_amount FLOAT, sale_date DATE); INSERT INTO VeganSkincareSales (sale_id, product_name, is_vegan, sale_amount, sale_date) VALUES (1, 'Vegan Cleanser', TRUE, 60.00, '2019-12-25'); INSERT INTO VeganSkincareSales (sale_id, product_name, is_vegan, sale_amount, sale_date) VALUES (2, 'Natural Moisturizer', FALSE, 75.00, '2020-01-15');
|
find the number of vegan skincare products that were sold between 2019 and 2020
|
SELECT COUNT(*) FROM VeganSkincareSales WHERE is_vegan = TRUE AND YEAR(sale_date) BETWEEN 2019 AND 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hotel_revenue_data_2 (hotel_id INT, country TEXT, pms_type TEXT, daily_revenue FLOAT); INSERT INTO hotel_revenue_data_2 (hotel_id, country, pms_type, daily_revenue) VALUES (1, 'UAE', 'cloud-based', 5000), (2, 'UAE', 'cloud-based', 6000), (3, 'UAE', 'legacy', 4000), (4, 'Qatar', 'cloud-based', 7000);
|
What is the minimum revenue per day for hotels in the UAE that have adopted cloud-based PMS?
|
SELECT MIN(daily_revenue) FROM hotel_revenue_data_2 WHERE country = 'UAE' AND pms_type = 'cloud-based';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hospital_beds (country VARCHAR(20), beds_per_1000 INT); INSERT INTO hospital_beds (country, beds_per_1000) VALUES ('High-Income', 50); INSERT INTO hospital_beds (country, beds_per_1000) VALUES ('Low-Income', 10);
|
What is the minimum number of hospital beds per 1000 people in low-income countries?
|
SELECT MIN(beds_per_1000) FROM hospital_beds WHERE country = 'Low-Income';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE EmployeeDemographics (EmployeeID int, Gender varchar(10), Department varchar(20)); INSERT INTO EmployeeDemographics (EmployeeID, Gender, Department) VALUES (1, 'Female', 'Engineering'), (2, 'Male', 'IT'), (3, 'Non-binary', 'Engineering'), (4, 'Female', 'Sales'), (5, 'Male', 'Sales'), (6, 'Female', 'Sales');
|
What is the percentage of female, male, and non-binary employees in the Sales department?
|
SELECT Department, ROUND(COUNT(CASE WHEN Gender = 'Female' THEN 1 END) * 100.0 / COUNT(*), 1) AS FemalePercentage, ROUND(COUNT(CASE WHEN Gender = 'Male' THEN 1 END) * 100.0 / COUNT(*), 1) AS MalePercentage, ROUND(COUNT(CASE WHEN Gender = 'Non-binary' THEN 1 END) * 100.0 / COUNT(*), 1) AS NonBinaryPercentage FROM EmployeeDemographics GROUP BY Department;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE containers (container_id INT, container_size INT, ship_id INT); INSERT INTO containers (container_id, container_size, ship_id) VALUES (1, 10, 1), (2, 15, 1), (3, 12, 2); CREATE TABLE ships (ship_id INT, ship_name VARCHAR(100), country VARCHAR(100)); INSERT INTO ships (ship_id, ship_name, country) VALUES (1, 'Asian Ship 1', 'Asia'), (2, 'Asian Ship 2', 'Asia');
|
What is the total number of containers that were transported by cargo ships from Asian countries to the Port of Singapore?
|
SELECT COUNT(*) FROM containers JOIN ships ON containers.ship_id = ships.ship_id WHERE ships.country = 'Asia' AND ports.port_name = 'Port of Singapore';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE network_investments (id INT, country VARCHAR(50), region VARCHAR(20), investment FLOAT); INSERT INTO network_investments (id, country, region, investment) VALUES (1, 'South Africa', 'Africa', 2000000);
|
List all mobile subscribers with their monthly usage and network investment in the 'Africa' region.
|
SELECT mobile_subscribers.name, customer_usage.usage, network_investments.investment FROM mobile_subscribers INNER JOIN customer_usage ON mobile_subscribers.id = customer_usage.subscriber_id INNER JOIN network_investments ON mobile_subscribers.country = network_investments.country WHERE network_investments.region = 'Africa';
|
gretelai_synthetic_text_to_sql
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.