context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE sales (sale_id INT, supplier_id INT, product_id INT, quantity INT, price DECIMAL);
What is the total revenue generated by suppliers with ethical labor practices?
SELECT SUM(quantity * price) FROM sales JOIN suppliers ON sales.supplier_id = suppliers.supplier_id WHERE suppliers.labor_practice = 'Ethical';
gretelai_synthetic_text_to_sql
CREATE TABLE Countries (id INT, name TEXT, region TEXT); INSERT INTO Countries (id, name, region) VALUES (1, 'France', 'Europe'), (2, 'Germany', 'Europe'); CREATE TABLE HeritageSitesEurope (id INT, country_id INT, name TEXT); INSERT INTO HeritageSitesEurope (id, country_id, name) VALUES (1, 1, 'Eiffel Tower'), (2, 1, 'Louvre Museum'), (3, 2, 'Brandenburg Gate'), (4, 2, 'Berlin Wall');
What is the average number of heritage sites per country in Europe?
SELECT AVG(site_count) FROM (SELECT COUNT(HeritageSitesEurope.id) AS site_count FROM HeritageSitesEurope GROUP BY HeritageSitesEurope.country_id) AS SiteCountPerCountry
gretelai_synthetic_text_to_sql
CREATE TABLE recidivism (offender_id INT, release_year INT, parole INT, state VARCHAR(20)); INSERT INTO recidivism (offender_id, release_year, parole, state) VALUES (1, 2018, 1, 'Texas'), (2, 2017, 0, 'Texas');
What is the recidivism rate for offenders released on parole in Texas in 2018?
SELECT (SUM(parole = 1) / COUNT(*)) * 100 AS recidivism_rate FROM recidivism WHERE state = 'Texas' AND release_year = 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE popularity (menu_id INT, popularity INT); INSERT INTO popularity (menu_id, popularity) VALUES (1, 10), (2, 20), (3, 30), (4, 40), (5, 50);
Show menu items with higher prices than the least popular entrée.
SELECT menu_name, price FROM menus WHERE menu_type = 'Entree' AND price > (SELECT MIN(price) FROM menus WHERE menu_type = 'Entree') AND menu_id NOT IN (SELECT menu_id FROM popularity WHERE popularity = (SELECT MIN(popularity) FROM popularity));
gretelai_synthetic_text_to_sql
CREATE TABLE judges (judge_id INT, name VARCHAR(50), court_id INT); INSERT INTO judges (judge_id, name, court_id) VALUES (1, 'John Doe', 1001), (2, 'Jane Smith', 1002), (3, 'Robert Johnson', 1003); CREATE TABLE cases (case_id INT, judge_id INT, court_date DATE); INSERT INTO cases (case_id, judge_id, court_date) VALUES (101, 1, '2021-01-01'), (102, 1, '2021-02-01'), (103, 2, '2021-03-01'), (104, 3, '2021-04-01'), (105, 3, '2021-05-01');
What is the total number of cases heard by each judge, ordered by total cases in descending order?
SELECT judge_id, COUNT(*) as total_cases FROM cases GROUP BY judge_id ORDER BY total_cases DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE visitor_data (id INT, country VARCHAR(255), visit_quarter INT, visit_year INT, visit_type VARCHAR(255)); INSERT INTO visitor_data (id, country, visit_quarter, visit_year, visit_type) VALUES (1, 'Canada', 3, 2021, 'adventure-tourism'), (2, 'Canada', 1, 2022, 'adventure-tourism');
How many tourists visited Canada for adventure tourism in Q3 of 2021 and Q1 of 2022?
SELECT SUM(id) FROM visitor_data WHERE country = 'Canada' AND visit_type = 'adventure-tourism' AND (visit_quarter = 3 AND visit_year = 2021 OR visit_quarter = 1 AND visit_year = 2022);
gretelai_synthetic_text_to_sql
CREATE TABLE PlayerProgress (PlayerID INT, GameName VARCHAR(20), Level INT, Completion BOOLEAN, PlayerContinent VARCHAR(30)); INSERT INTO PlayerProgress (PlayerID, GameName, Level, Completion, PlayerContinent) VALUES (1, 'Quantum Shift', 10, true, 'North America'), (2, 'Quantum Shift', 15, true, 'Europe'), (3, 'Quantum Shift', 5, false, 'North America'), (4, 'Quantum Shift', 20, true, 'South America'), (5, 'Quantum Shift', 7, false, 'Europe'), (6, 'Quantum Shift', 18, true, 'Asia'), (7, 'Quantum Shift', 12, false, 'Asia'), (8, 'Quantum Shift', 14, true, 'Africa');
What is the average level achieved by users in "Quantum Shift" for each continent, excluding the lowest 5 levels?
SELECT PlayerContinent, AVG(Level) AS avg_level FROM (SELECT PlayerContinent, Level FROM PlayerProgress WHERE GameName = 'Quantum Shift' GROUP BY PlayerContinent, Level HAVING COUNT(*) > 4) AS filtered_data GROUP BY PlayerContinent;
gretelai_synthetic_text_to_sql
CREATE TABLE Concerts (id INT, date DATE, revenue FLOAT); CREATE TABLE Streams (song_id INT, date DATE, revenue FLOAT);
What is the total revenue for concerts and streams in Australia, grouped by year and quarter.
SELECT YEAR(date) AS year, QUARTER(date) AS quarter, SUM(Concerts.revenue) + SUM(Streams.revenue) FROM Concerts INNER JOIN Streams ON YEAR(Concerts.date) = YEAR(Streams.date) AND QUARTER(Concerts.date) = QUARTER(Streams.date) WHERE Concerts.country = 'Australia' GROUP BY year, quarter;
gretelai_synthetic_text_to_sql
CREATE TABLE heritage_sites (id INT, country TEXT, site_name TEXT); INSERT INTO heritage_sites (id, country, site_name) VALUES (1, 'Mexico', 'Palace of Fine Arts'), (2, 'Mexico', 'Historic Centre of Mexico City and Xochimilco'), (3, 'Brazil', 'Historic Centre of Salvador de Bahia'), (4, 'Brazil', 'Iguaçu National Park');
How many heritage sites are in Mexico and Brazil?
SELECT country, COUNT(*) FROM heritage_sites GROUP BY country HAVING country IN ('Mexico', 'Brazil');
gretelai_synthetic_text_to_sql
CREATE TABLE dispensaries (id INT, name TEXT, state TEXT); INSERT INTO dispensaries (id, name, state) VALUES (1, 'Dispensary A', 'California'), (2, 'Dispensary B', 'California'); CREATE TABLE licenses (id INT, dispensary_id INT, status TEXT); INSERT INTO licenses (id, dispensary_id, status) VALUES (1, 1, 'active'), (2, 2, 'active'); CREATE TABLE sales (id INT, dispensary_id INT, quantity INT);
Which dispensaries in California have a license but haven't made any sales?
SELECT d.name FROM dispensaries d JOIN licenses l ON d.id = l.dispensary_id LEFT JOIN sales s ON d.id = s.dispensary_id WHERE d.state = 'California' AND s.id IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE GraduateStudents (StudentID int, Name varchar(50), Department varchar(50)); CREATE TABLE Enrollment (StudentID int, Course varchar(50), Semester varchar(50)); INSERT INTO GraduateStudents (StudentID, Name, Department) VALUES (1, 'Alice Johnson', 'Computer Science'); INSERT INTO GraduateStudents (StudentID, Name, Department) VALUES (2, 'Bob Brown', 'Computer Science'); INSERT INTO Enrollment (StudentID, Course, Semester) VALUES (1, 'Database Systems', 'Fall'); INSERT INTO Enrollment (StudentID, Course, Semester) VALUES (1, 'Artificial Intelligence', 'Spring'); INSERT INTO Enrollment (StudentID, Course, Semester) VALUES (2, 'Database Systems', 'Fall'); INSERT INTO Enrollment (StudentID, Course, Semester) VALUES (3, 'Operating Systems', 'Fall');
How many graduate students have not enrolled in any courses in the Spring semester?
SELECT COUNT(*) FROM GraduateStudents WHERE StudentID NOT IN (SELECT StudentID FROM Enrollment WHERE Semester = 'Spring');
gretelai_synthetic_text_to_sql
CREATE TABLE Exhibits (ExhibitID int, Gallery varchar(50), ArtworkID int); CREATE TABLE ExhibitionTitles (ExhibitID int, Title varchar(50)); INSERT INTO Exhibits (ExhibitID, Gallery, ArtworkID) VALUES (1, 'Impressionism', 101), (2, 'Impressionism', 102), (3, 'Surrealism', 201); INSERT INTO ExhibitionTitles (ExhibitID, Title) VALUES (1, 'Impressionist Masterpieces'), (2, 'Post-Impressionism'), (3, 'Surrealist Dreams');
List the exhibition titles and the number of artworks in each exhibit from the galleries 'Impressionism' and 'Surrealism'.
SELECT e.Gallery, et.Title, COUNT(e.ArtworkID) AS ArtworkCount FROM Exhibits e INNER JOIN ExhibitionTitles et ON e.ExhibitID = et.ExhibitID WHERE e.Gallery IN ('Impressionism', 'Surrealism') GROUP BY e.Gallery, et.Title;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_projects (region VARCHAR(255), status VARCHAR(255), type VARCHAR(255));
How many climate mitigation projects were completed in the Asia-Pacific region?
SELECT COUNT(*) FROM climate_projects WHERE region = 'Asia-Pacific' AND type = 'climate mitigation' AND status = 'completed';
gretelai_synthetic_text_to_sql
CREATE TABLE providers (id INT, name TEXT, service TEXT, location TEXT);
Insert records of new providers in Texas offering primary care, mental health, and dental services.
INSERT INTO providers (id, name, service, location) VALUES (1, 'Lone Star Care', 'Primary Care', 'Texas'); INSERT INTO providers (id, name, service, location) VALUES (2, 'Rio Grande Care', 'Mental Health', 'Texas'); INSERT INTO providers (id, name, service, location) VALUES (3, 'Star of Texas Dental', 'Dental', 'Texas')
gretelai_synthetic_text_to_sql
CREATE TABLE vulnerabilities (vulnerability_id INT, vulnerability_severity VARCHAR(255), sector VARCHAR(255), resolution_time INT); INSERT INTO vulnerabilities (vulnerability_id, vulnerability_severity, sector, resolution_time) VALUES (1, 'Critical', 'Financial', 7), (2, 'High', 'Financial', 12), (3, 'Medium', 'Healthcare', 23), (4, 'Low', 'Retail', 34), (5, 'Critical', 'Healthcare', 45), (6, 'High', 'Healthcare', 56), (7, 'Medium', 'Financial', 67);
What is the average time to resolve critical vulnerabilities in the healthcare sector in the last 6 months?
SELECT AVG(resolution_time) as avg_resolution_time FROM vulnerabilities WHERE sector = 'Healthcare' AND vulnerability_severity = 'Critical' AND resolution_time > 0 AND resolution_time IS NOT NULL AND resolution_time < 1000 AND vulnerability_date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE materials (id INT, country VARCHAR(255), type VARCHAR(255), sales FLOAT, profits FLOAT); INSERT INTO materials (id, country, type, sales, profits) VALUES (1, 'UK', 'Organic Cotton', 500, 250), (2, 'Australia', 'Hemp', 600, 360), (3, 'UK', 'Recycled Polyester', 700, 350), (4, 'Australia', 'Organic Cotton', 800, 400);
What is the sales ratio of ethical material types in the UK to those in Australia?
SELECT a.type, a.sales / b.sales as sales_ratio FROM materials a JOIN materials b ON a.type = b.type WHERE a.country = 'UK' AND b.country = 'Australia';
gretelai_synthetic_text_to_sql
CREATE TABLE algorithmic_fairness (table_name VARCHAR(255)); INSERT INTO algorithmic_fairness (table_name) VALUES ('disparate_impact'), ('equal_opportunity'), ('demographic_parity');
Show all tables related to algorithmic fairness.
SELECT table_name FROM algorithmic_fairness
gretelai_synthetic_text_to_sql
CREATE SCHEMA IF NOT EXISTS cybersecurity_strategies; CREATE TABLE IF NOT EXISTS strategy_risk (id INT PRIMARY KEY, name TEXT, category TEXT, risk_rating INT); INSERT INTO strategy_risk (id, name, category, risk_rating) VALUES (1, 'Firewalls', 'Network Security', 2), (2, 'Penetration Testing', 'Vulnerability Management', 5), (3, 'Intrusion Detection Systems', 'Network Security', 3);
List the name and category of cybersecurity strategies with a risk rating above 3.
SELECT name, category FROM cybersecurity_strategies.strategy_risk WHERE risk_rating > 3;
gretelai_synthetic_text_to_sql
CREATE TABLE WasteGenerated (WasteID INT, MineID INT, WasteDate DATE, WasteAmount INT);
What is the average amount of waste generated per month for the silver mines?
SELECT AVG(WasteAmount) FROM WasteGenerated WHERE (SELECT MineType FROM Mines WHERE Mines.MineID = WasteGenerated.MineID) = 'Silver' GROUP BY MONTH(WasteDate), YEAR(WasteDate);
gretelai_synthetic_text_to_sql
CREATE TABLE sustainable_practices (practice_id INT, building_id INT, city VARCHAR(20)); INSERT INTO sustainable_practices (practice_id, building_id, city) VALUES (1, 101, 'New York'), (2, 101, 'New York'), (3, 102, 'Los Angeles'), (5, 103, 'New York');
Which sustainable building practices were implemented in New York?
SELECT DISTINCT city, building_type FROM sustainable_practices SP JOIN (SELECT building_id, 'Solar Panels' as building_type FROM sustainable_practices WHERE practice_id = 1 UNION ALL SELECT building_id, 'Green Roofs' as building_type FROM sustainable_practices WHERE practice_id = 2) AS subquery ON SP.building_id = subquery.building_id WHERE city = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers (id INT PRIMARY KEY, name TEXT, race TEXT, sustainable_practices BOOLEAN); CREATE TABLE products (id INT PRIMARY KEY, name TEXT, supplier_id INT, FOREIGN KEY (supplier_id) REFERENCES suppliers(id));
What are the products made by BIPOC-owned suppliers?
SELECT products.name, suppliers.name AS supplier_name FROM products INNER JOIN suppliers ON products.supplier_id = suppliers.id WHERE suppliers.race = 'BIPOC';
gretelai_synthetic_text_to_sql
CREATE TABLE subscribers (subscriber_id INT, name VARCHAR(50), region VARCHAR(50), subscribed_date DATE); INSERT INTO subscribers VALUES (1, 'John Doe', 'RegionA', '2022-01-01'); INSERT INTO subscribers VALUES (2, 'Jane Smith', 'RegionB', '2022-02-15'); INSERT INTO subscribers VALUES (3, 'Mike Johnson', 'RegionA', '2022-03-05');
How many subscribers are there in each region?
SELECT region, COUNT(*) as num_subscribers FROM subscribers GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (id INT PRIMARY KEY, species_name VARCHAR(255), conservation_status VARCHAR(255)); INSERT INTO marine_species (id, species_name, conservation_status) VALUES (1001, 'Oceanic Whitetip Shark', 'Vulnerable'), (1002, 'Green Sea Turtle', 'Threatened'), (1003, 'Leatherback Sea Turtle', 'Vulnerable'), (1004, 'Hawksbill Sea Turtle', 'Endangered');
List all marine species in the 'marine_species' table, ordered alphabetically
SELECT species_name FROM marine_species ORDER BY species_name ASC;
gretelai_synthetic_text_to_sql
CREATE TABLE ConstructionEmployers (id INT, name TEXT, state TEXT, year INT, numEmployees INT);
Who were the top 3 employers of construction laborers in Texas in 2020?
SELECT name FROM ConstructionEmployers WHERE state = 'Texas' AND year = 2020 ORDER BY numEmployees DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE sharks (name TEXT, region TEXT); INSERT INTO sharks (name, region) VALUES ('Tiger Shark', 'Indian'), ('Great White', 'Atlantic'), ('Hammerhead', 'Pacific');
List all shark species in the Indian Ocean.
SELECT name FROM sharks WHERE region = 'Indian';
gretelai_synthetic_text_to_sql
CREATE TABLE faculty (id INT, name VARCHAR(50), department VARCHAR(50), community VARCHAR(50));
How many faculty members from each department identify as LGBTQ+?
SELECT department, COUNT(*) FROM faculty WHERE community = 'LGBTQ+' GROUP BY department;
gretelai_synthetic_text_to_sql
CREATE TABLE Events (event_id INT, event_location VARCHAR(20), event_type VARCHAR(20), num_attendees INT); INSERT INTO Events (event_id, event_location, event_type, num_attendees) VALUES (1, 'New York', 'Concert', 500), (2, 'Los Angeles', 'Theater', 300), (3, 'Chicago', 'Exhibition', 400), (4, 'San Francisco', 'Theater', 200), (5, 'Seattle', 'Exhibition', 150);
How many 'Exhibitions' and 'Theater' events did not happen in 'New York' or 'Los Angeles'?
SELECT event_type, COUNT(*) FROM Events WHERE event_location NOT IN ('New York', 'Los Angeles') AND event_type IN ('Exhibition', 'Theater') GROUP BY event_type;
gretelai_synthetic_text_to_sql
CREATE TABLE financial_education (individual_id TEXT, financial_education TEXT, wellbeing_score NUMERIC); INSERT INTO financial_education (individual_id, financial_education, wellbeing_score) VALUES ('12345', 'high', 78); INSERT INTO financial_education (individual_id, financial_education, wellbeing_score) VALUES ('67890', 'high', 82);
What is the average financial wellbeing score of individuals in Canada with a financial education level of "high"?
SELECT AVG(wellbeing_score) FROM financial_education WHERE financial_education = 'high' AND country = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE menu_items (menu_item_id INT, name VARCHAR(255), description TEXT, price DECIMAL(5,2), category VARCHAR(255), sustainability_rating INT);
Add Tofu Stir Fry as a new menu item with a price of $12.50 and a sustainability_rating of 4 in the menu_items table
INSERT INTO menu_items (name, price, sustainability_rating) VALUES ('Tofu Stir Fry', 12.50, 4);
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (ArtistID INT, ArtistName VARCHAR(100), Age INT, Genre VARCHAR(50)); INSERT INTO Artists VALUES (1, 'Artist1', 35, 'Rock'); INSERT INTO Artists VALUES (2, 'Artist2', 45, 'Rock'); CREATE TABLE Festivals (FestivalID INT, FestivalName VARCHAR(100), ArtistID INT); INSERT INTO Festivals VALUES (1, 'Festival1', 1); INSERT INTO Festivals VALUES (2, 'Festival2', 2);
Which artists have never performed at music festivals?
SELECT A.ArtistName FROM Artists A LEFT JOIN Festivals F ON A.ArtistID = F.ArtistID WHERE F.ArtistID IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE covid_deaths (id INT, state TEXT, num_deaths INT); INSERT INTO covid_deaths (id, state, num_deaths) VALUES (1, 'California', 50000), (2, 'Texas', 45000), (3, 'Florida', 40000), (4, 'New York', 55000), (5, 'Pennsylvania', 25000), (6, 'Illinois', 20000), (7, 'Ohio', 15000), (8, 'Georgia', 12000), (9, 'Michigan', 18000), (10, 'North Carolina', 10000);
How many people have died from COVID-19 in each state in the United States?
SELECT state, SUM(num_deaths) FROM covid_deaths GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name VARCHAR(255), region VARCHAR(50), sales FLOAT, organic BOOLEAN); INSERT INTO products (product_id, product_name, region, sales, organic) VALUES (1, 'Lipstick A', 'Europe', 5000, true), (2, 'Foundation B', 'Asia', 7000, false), (3, 'Mascara C', 'Europe', 6000, false), (4, 'Eye-shadow D', 'America', 8000, true), (5, 'Blush E', 'Europe', 4000, true);
What is the total sales of organic cosmetic products per region?
SELECT region, SUM(sales) AS total_sales FROM products WHERE organic = true GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, country VARCHAR(255), followers INT); CREATE TABLE posts (id INT, user_id INT, hashtags VARCHAR(255), post_date DATE);
What is the maximum number of followers for users from Canada who have posted about #tech in the last month?
SELECT MAX(users.followers) FROM users INNER JOIN posts ON users.id = posts.user_id WHERE users.country = 'Canada' AND hashtags LIKE '%#tech%' AND post_date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE fifa_world_cup_goals (player_id INT, name VARCHAR(50), country VARCHAR(50), goals INT); INSERT INTO fifa_world_cup_goals (player_id, name, country, goals) VALUES (1, 'Miroslav Klose', 'Germany', 16);
How many FIFA World Cup goals has Miroslav Klose scored?
SELECT goals FROM fifa_world_cup_goals WHERE name = 'Miroslav Klose';
gretelai_synthetic_text_to_sql
CREATE TABLE funding (funding_id INT, org_id INT, amount INT, funding_type VARCHAR(50), region VARCHAR(50)); INSERT INTO funding (funding_id, org_id, amount, funding_type, region) VALUES (1, 1, 100000, 'government', 'Africa'), (2, 1, 200000, 'private', 'Africa'), (3, 2, 150000, 'private', 'Asia'), (4, 3, 50000, 'government', 'Latin America'); CREATE TABLE organizations (org_id INT, name VARCHAR(50), implemented_digital_divide BOOLEAN); INSERT INTO organizations (org_id, name, implemented_digital_divide) VALUES (1, 'Digital Divide Africa Inc.', TRUE), (2, 'Asian Tech Inc.', FALSE), (3, 'Latin America Tech', TRUE), (4, 'Non-profit Tech', FALSE);
What is the total funding received by organizations that have implemented digital divide initiatives and are based in either Africa or Latin America, broken down by the type of funding (government or private)?
SELECT implemented_digital_divide, funding_type, region, SUM(amount) FROM funding INNER JOIN organizations ON funding.org_id = organizations.org_id WHERE implemented_digital_divide = TRUE AND (region = 'Africa' OR region = 'Latin America') GROUP BY implemented_digital_divide, funding_type, region;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, FirstName VARCHAR(50), LastName VARCHAR(50), Department VARCHAR(50), Salary DECIMAL(10,2)); INSERT INTO Employees (EmployeeID, FirstName, LastName, Department, Salary) VALUES (1, 'John', 'Doe', 'Mining', 75000.00); INSERT INTO Employees (EmployeeID, FirstName, LastName, Department, Salary) VALUES (2, 'Jane', 'Doe', 'Environment', 70000.00); INSERT INTO Employees (EmployeeID, FirstName, LastName, Department, Salary) VALUES (3, 'Mike', 'Smith', 'Mining', 80000.00);
What is the average salary for each department, along with the number of employees in that department?
SELECT Department, AVG(Salary) as 'AvgSalary', COUNT(*) as 'EmployeeCount' FROM Employees GROUP BY Department;
gretelai_synthetic_text_to_sql
CREATE TABLE GraduateStudents(StudentID INT, Name VARCHAR(50), Department VARCHAR(50), Gender VARCHAR(10)); INSERT INTO GraduateStudents(StudentID, Name, Department, Gender) VALUES (1, 'Alice Johnson', 'Computer Science', 'Female'), (2, 'Bob Brown', 'Physics', 'Male'), (3, 'Charlie Davis', 'Mathematics', 'Female');
What is the number of female graduate students in each department?
SELECT Department, COUNT(*) FROM GraduateStudents WHERE Gender = 'Female' GROUP BY Department
gretelai_synthetic_text_to_sql
CREATE TABLE defense_diplomacy (id INT, region VARCHAR(50), budget INT);
What is the maximum defense diplomacy event budget for each region in the 'defense_diplomacy' table?
SELECT region, MAX(budget) FROM defense_diplomacy GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE posts (id INT, timestamp TIMESTAMP); INSERT INTO posts (id, timestamp) VALUES (1, '2022-01-01 10:00:00'), (2, '2022-01-02 12:00:00'), (3, '2022-01-03 14:00:00'); CREATE TABLE likes (post_id INT, likes INT); INSERT INTO likes (post_id, likes) VALUES (1, 100), (2, 200), (3, 50);
What is the total number of likes on posts in a given time period?
SELECT SUM(likes) FROM posts JOIN likes ON posts.id = likes.post_id WHERE posts.timestamp BETWEEN '2022-01-01' AND '2022-01-05';
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (Donor_ID int, Name varchar(50), Donation_Amount int, Country varchar(50)); INSERT INTO Donors (Donor_ID, Name, Donation_Amount, Country) VALUES (1, 'John Doe', 7000, 'USA'), (2, 'Jane Smith', 3000, 'Canada'), (3, 'Mike Johnson', 4000, 'USA'), (4, 'Emma Wilson', 8000, 'Canada'), (5, 'Raj Patel', 9000, 'India'), (6, 'Ana Sousa', 10000, 'Brazil');
select max(Donation_Amount) as Highest_Donation from Donors where Country in ('India', 'Brazil')
SELECT MAX(Donation_Amount) AS Highest_Donation FROM Donors WHERE Country IN ('India', 'Brazil');
gretelai_synthetic_text_to_sql
CREATE TABLE mlb_players (player_id INT, name VARCHAR(50), team VARCHAR(50), position VARCHAR(20), home_runs INT); INSERT INTO mlb_players (player_id, name, team, position, home_runs) VALUES (1, 'Barry Bonds', 'San Francisco Giants', 'Left Field', 73);
Who holds the record for most home runs in a single MLB season?
SELECT name FROM mlb_players WHERE home_runs = (SELECT MAX(home_runs) FROM mlb_players);
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (hotel_id INT, name VARCHAR(50), category VARCHAR(20), rating DECIMAL(2,1)); INSERT INTO hotels (hotel_id, name, category, rating) VALUES (1, 'The Urban Chic', 'boutique', 4.5), (2, 'The Artistic Boutique', 'boutique', 4.7), (3, 'The Cozy Inn', 'budget', 4.2), (4, 'The Grand Palace', 'luxury', 4.8), (5, 'The Majestic', 'luxury', 4.6), (6, 'The Beach Resort', 'resort', 4.4);
What is the average rating of hotels in each category?
SELECT category, AVG(rating) FROM hotels GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID int, DonorType varchar(50), Country varchar(50), AmountDonated numeric(18,2), DonationDate date); INSERT INTO Donors (DonorID, DonorType, Country, AmountDonated, DonationDate) VALUES (1, 'Organization', 'China', 12000, '2022-07-01'), (2, 'Individual', 'Japan', 5000, '2022-08-01'), (3, 'Organization', 'India', 15000, '2022-09-01');
What is the average amount donated by organizations in Asia in Q3 2022?
SELECT AVG(AmountDonated) FROM Donors WHERE DonorType = 'Organization' AND Country LIKE 'Asia%' AND QUARTER(DonationDate) = 3 AND YEAR(DonationDate) = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE digital_asset_prices (id INT, digital_asset_id INT, price DECIMAL, price_date DATE); INSERT INTO digital_asset_prices (id, digital_asset_id, price, price_date) VALUES (1, 1, 100, '2022-01-01'), (2, 1, 105, '2022-01-02'), (3, 1, 110, '2022-01-03'), (4, 1, 115, '2022-01-04'), (5, 1, 120, '2022-01-05'), (6, 2, 50, '2022-01-01'), (7, 2, 52, '2022-01-02'), (8, 2, 54, '2022-01-03'), (9, 2, 56, '2022-01-04'), (10, 2, 58, '2022-01-05');
Calculate the moving average of the price of a digital asset with ID 2 over the last 7 days.
SELECT digital_asset_id, AVG(price) OVER (PARTITION BY digital_asset_id ORDER BY price_date ROWS BETWEEN 6 PRECEDING AND CURRENT ROW) as moving_average FROM digital_asset_prices WHERE digital_asset_id = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, brand_id INT, product_name VARCHAR(50), safety_rating INT); INSERT INTO products (product_id, brand_id, product_name, safety_rating) VALUES (1, 1, 'Soap', 5), (2, 1, 'Lotion', 4), (3, 2, 'Shower Gel', 5), (4, 2, 'Body Butter', 5), (5, 3, 'Foundation', 3), (6, 4, 'Lipstick', 4), (7, 4, 'Mascara', 4), (8, 5, 'Eyeshadow', 5); CREATE TABLE brands (brand_id INT, brand_name VARCHAR(50), country VARCHAR(50), cruelty_free BOOLEAN); INSERT INTO brands (brand_id, brand_name, country, cruelty_free) VALUES (1, 'Lush', 'United Kingdom', true), (2, 'The Body Shop', 'United Kingdom', true), (3, 'Bare Minerals', 'United States', true), (4, 'MAC', 'Canada', false), (5, 'Chanel', 'France', false);
What is the average safety rating for cosmetics products from each country?
SELECT b.country, AVG(p.safety_rating) as avg_safety_rating FROM products p JOIN brands b ON p.brand_id = b.brand_id GROUP BY b.country;
gretelai_synthetic_text_to_sql
CREATE TABLE deep_sea_species (name VARCHAR(255), habitat VARCHAR(255), max_depth FLOAT); INSERT INTO deep_sea_species (name, habitat, max_depth) VALUES ('Anglerfish', 'Pacific Ocean', 3000), ('Giant Squid', 'Pacific Ocean', 3300);
List all deep-sea species in the Pacific Ocean and their maximum depths.
SELECT name, max_depth FROM deep_sea_species WHERE habitat = 'Pacific Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE Provinces (Province VARCHAR(50), TBCases INT); INSERT INTO Provinces (Province, TBCases) VALUES ('Ontario', 500), ('Quebec', 700), ('British Columbia', 300), ('Alberta', 400);
How many confirmed cases of tuberculosis are there in each province of Canada?
SELECT Province, TBCases FROM Provinces;
gretelai_synthetic_text_to_sql
CREATE TABLE city_budget (city VARCHAR(255), year INT, department VARCHAR(255), allocated_budget FLOAT); INSERT INTO city_budget (city, year, department, allocated_budget) VALUES ('Oakland', 2022, 'Parks and Recreation', 2500000.00);
What is the total budget allocated to parks and recreation in the city of Oakland for the year 2022?
SELECT SUM(allocated_budget) AS total_budget FROM city_budget WHERE city = 'Oakland' AND year = 2022 AND department = 'Parks and Recreation';
gretelai_synthetic_text_to_sql
CREATE TABLE teacher_trainings (training_id INT, teacher_id INT, training_date DATE, course_completed INT); INSERT INTO teacher_trainings (training_id, teacher_id, training_date, course_completed) VALUES (1, 1, '2022-01-01', 1), (2, 1, '2022-02-01', 2), (3, 2, '2022-01-01', 3), (4, 2, '2022-02-01', 1); CREATE TABLE teachers (teacher_id INT, teacher_name VARCHAR(50), gender VARCHAR(10)); INSERT INTO teachers (teacher_id, teacher_name, gender) VALUES (1, 'Ms. Lopez', 'Female'), (2, 'Mr. Johnson', 'Male');
What is the trend of professional development course completions by teachers over time by gender?
SELECT gender, EXTRACT(MONTH FROM training_date) AS month, SUM(course_completed) FROM teacher_trainings JOIN teachers ON teacher_trainings.teacher_id = teachers.teacher_id GROUP BY gender, month;
gretelai_synthetic_text_to_sql
CREATE TABLE clinical_trials (drug varchar(255), year int, trials int); INSERT INTO clinical_trials (drug, year, trials) VALUES ('DrugA', 2019, 2), ('DrugB', 2019, 3);
How many clinical trials were conducted for each drug in 2019?
SELECT drug, AVG(trials) FROM clinical_trials WHERE year = 2019 GROUP BY drug;
gretelai_synthetic_text_to_sql
CREATE TABLE finance (id INT, union_member BOOLEAN, salary FLOAT); INSERT INTO finance (id, union_member, salary) VALUES (1, FALSE, 90000), (2, TRUE, 100000), (3, FALSE, 95000);
What is the maximum salary of non-union workers in the finance industry?
SELECT MAX(salary) FROM finance WHERE union_member = FALSE;
gretelai_synthetic_text_to_sql
CREATE TABLE media_publications (id INT, media_outlet VARCHAR(255), title VARCHAR(255), published_date DATE, topic VARCHAR(255));
Which media outlets published the most articles about 'climate_change' in the 'media_publications' table?
SELECT media_outlet, COUNT(*) as articles_about_climate_change FROM media_publications WHERE topic = 'climate_change' GROUP BY media_outlet ORDER BY articles_about_climate_change DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Water_Infrastructure (id INT, project_name VARCHAR(50), location VARCHAR(50), cost INT);
What is the total cost of all projects in 'Water_Infrastructure' table?
SELECT SUM(cost) FROM Water_Infrastructure;
gretelai_synthetic_text_to_sql
CREATE TABLE user_video_views (user_id INT, user_name TEXT, country TEXT, watch_time INT, media_literacy_score INT); INSERT INTO user_video_views (user_id, user_name, country, watch_time, media_literacy_score) VALUES (1, 'User 1', 'Brazil', 8, 6); INSERT INTO user_video_views (user_id, user_name, country, watch_time, media_literacy_score) VALUES (2, 'User 2', 'Argentina', 6, 7);
What is the average media literacy score for users in South America who watched more than 5 hours of video content in the last week?
SELECT AVG(media_literacy_score) FROM user_video_views WHERE country = 'South America' AND watch_time > 5 AND watch_time <= 5 + 1 AND watch_time >= 5 - 1;
gretelai_synthetic_text_to_sql
CREATE TABLE HeritageSites (Site VARCHAR(50), YearEstablished INT, PreservationStatus VARCHAR(50)); INSERT INTO HeritageSites (Site, YearEstablished, PreservationStatus) VALUES ('Site1', 1890, 'Preserved'), ('Site2', 1920, 'Under Threat');
What is the preservation status of heritage sites established before 1900 in Europe?
SELECT PreservationStatus FROM HeritageSites WHERE YearEstablished < 1900 AND Region = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE EmployeeSalary (EmployeeID INT, Salary DECIMAL(10,2), JobChanges INT); INSERT INTO EmployeeSalary (EmployeeID, Salary, JobChanges) VALUES (1, 70000.00, 3); INSERT INTO EmployeeSalary (EmployeeID, Salary, JobChanges) VALUES (2, 75000.00, 1);
What is the average salary of employees who have changed jobs more than twice?
SELECT AVG(Salary) FROM EmployeeSalary WHERE JobChanges > 2;
gretelai_synthetic_text_to_sql
CREATE TABLE Neodymium_Production (year INT, country TEXT, price FLOAT); INSERT INTO Neodymium_Production (year, country, price) VALUES (2017, 'Australia', 120); INSERT INTO Neodymium_Production (year, country, price) VALUES (2018, 'Australia', 110); INSERT INTO Neodymium_Production (year, country, price) VALUES (2019, 'Australia', 130); INSERT INTO Neodymium_Production (year, country, price) VALUES (2020, 'Australia', 150); INSERT INTO Neodymium_Production (year, country, price) VALUES (2021, 'Australia', 170);
What is the average market price of Neodymium produced in Australia for the last 5 years?
SELECT AVG(price) FROM Neodymium_Production WHERE country = 'Australia' AND year BETWEEN 2017 AND 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE MenuItems (id INT, restaurant_id INT, name VARCHAR, price DECIMAL); INSERT INTO MenuItems (id, restaurant_id, name, price) VALUES (1, 1, 'Quiche', 12.99); INSERT INTO MenuItems (id, restaurant_id, name, price) VALUES (2, 2, 'Pizza', 14.99); INSERT INTO MenuItems (id, restaurant_id, name, price) VALUES (3, 1, 'Steak', 29.99);
What is the most expensive item on the menu for each restaurant?
SELECT m.name, m.price, r.name FROM MenuItems m JOIN Restaurants r ON m.restaurant_id = r.id WHERE m.price = (SELECT MAX(price) FROM MenuItems WHERE restaurant_id = m.restaurant_id);
gretelai_synthetic_text_to_sql
CREATE TABLE donors (id INT, name VARCHAR(50), last_donation_year INT, email VARCHAR(50));
Update the email of a donor with ID 10 in the "donors" table.
UPDATE donors SET email = 'new_email@example.com' WHERE id = 10;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID int, DonorType varchar(50), Country varchar(50), AmountDonated numeric(18,2), DonationDate date); INSERT INTO Donors (DonorID, DonorType, Country, AmountDonated, DonationDate) VALUES (1, 'Organization', 'Indonesia', 12000, '2022-01-01'), (2, 'Individual', 'Malaysia', 5000, '2022-02-01'), (3, 'Organization', 'Philippines', 15000, '2022-03-01'), (4, 'Individual', 'Thailand', 8000, '2022-04-01');
What is the total donation amount by donors located in Southeast Asia in 2022, broken down by donor type?
SELECT DonorType, SUM(AmountDonated) as TotalDonated FROM Donors WHERE Country LIKE 'Southeast Asia%' AND YEAR(DonationDate) = 2022 GROUP BY DonorType;
gretelai_synthetic_text_to_sql
CREATE TABLE port_visits (id INT, port VARCHAR(50), visit_date DATE); INSERT INTO port_visits (id, port, visit_date) VALUES (1, 'Los Angeles', '2022-04-10'), (2, 'Los Angeles', '2022-04-14');
How many vessels visited port 'Los Angeles' in the last week?
SELECT COUNT(DISTINCT id) FROM port_visits WHERE port = 'Los Angeles' AND visit_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY) AND CURRENT_DATE;
gretelai_synthetic_text_to_sql
CREATE TABLE agricultural_projects (id INT, country VARCHAR(20), project_name VARCHAR(50), project_cost FLOAT); INSERT INTO agricultural_projects (id, country, project_name, project_cost) VALUES (1, 'Philippines', 'Irrigation System Upgrade', 50000.00), (2, 'Indonesia', 'Precision Farming', 75000.00);
What is the total cost of all agricultural innovation projects in the Philippines?
SELECT SUM(project_cost) FROM agricultural_projects WHERE country = 'Philippines';
gretelai_synthetic_text_to_sql
CREATE TABLE industry_4_0 (id INT, factory_id INT, material VARCHAR(50), quantity INT, date DATE); INSERT INTO industry_4_0 (id, factory_id, material, quantity, date) VALUES (1, 1, 'Plastic', 100, '2021-04-01'), (2, 2, 'Glass', 200, '2021-05-01'), (3, 1, 'Metal', 150, '2021-06-01');
Calculate the total quantity of recycled materials used in industry 4.0 processes for each factory in Q2 2021.
SELECT factory_id, SUM(quantity) as total_quantity FROM industry_4_0 WHERE DATE_FORMAT(date, '%Y-%m') BETWEEN '2021-04-01' AND '2021-06-30' GROUP BY factory_id;
gretelai_synthetic_text_to_sql
CREATE TABLE water_usage(customer_type VARCHAR(50), city VARCHAR(50), year INT, day DATE, usage FLOAT); INSERT INTO water_usage(customer_type, city, year, day, usage) VALUES ('Residential', 'New York City', 2020, '2020-07-04', 12345.6), ('Residential', 'New York City', 2020, '2020-07-05', 15000);
What is the maximum daily water usage for residential customers in New York City in 2020?
SELECT day, MAX(usage) FROM water_usage WHERE customer_type = 'Residential' AND city = 'New York City' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE teacher_trainings (teacher_id INT, course_id INT, training_date DATE);
Find the number of professional development courses taken by teachers in the past year from the 'teacher_trainings' table.
SELECT COUNT(*) FROM teacher_trainings WHERE training_date >= DATE(NOW()) - INTERVAL 1 YEAR;
gretelai_synthetic_text_to_sql
CREATE TABLE costs (id INT, product VARCHAR(255), cost FLOAT); INSERT INTO costs (id, product, cost) VALUES (1, 'Chemical A', 200.3), (2, 'Chemical B', 150.9), (3, 'Chemical C', 250.7); CREATE VIEW avg_cost AS SELECT product, AVG(cost) as avg_cost FROM costs GROUP BY product;
What is the average production cost for chemical C?
SELECT avg_cost FROM avg_cost WHERE product = 'Chemical C'
gretelai_synthetic_text_to_sql
CREATE TABLE eco_tourism (country VARCHAR(20), tourists INT, year INT); INSERT INTO eco_tourism (country, tourists, year) VALUES ('Indonesia', 500000, 2022), ('Thailand', 600000, 2022), ('Vietnam', 400000, 2022);
What is the total number of eco-tourists who visited Southeast Asian countries in 2022?
SELECT SUM(tourists) as total_eco_tourists FROM eco_tourism WHERE country IN ('Indonesia', 'Thailand', 'Vietnam') AND year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE countries (country_id INT, country_name VARCHAR(100)); CREATE TABLE medals (medal_id INT, country_id INT, medal_type VARCHAR(10), game_name VARCHAR(100));
What is the total number of medals won by each country in the Commonwealth Games?
SELECT countries.country_name, COUNT(medals.medal_id) as total_medals FROM countries INNER JOIN medals ON countries.country_id = medals.country_id WHERE medals.game_name = 'Commonwealth Games' GROUP BY countries.country_name;
gretelai_synthetic_text_to_sql
CREATE TABLE student_clubs (club_id INT PRIMARY KEY, name VARCHAR(50), description TEXT, advisor VARCHAR(50));
Update the 'description' for a record in the 'student_clubs' table
UPDATE student_clubs SET description = 'A club for students interested in social justice.' WHERE name = 'Social Justice Warriors';
gretelai_synthetic_text_to_sql
CREATE TABLE Forests (id INT PRIMARY KEY, name VARCHAR(255), hectares DECIMAL(5,2), country VARCHAR(255)); INSERT INTO Forests (id, name, hectares, country) VALUES (1, 'Greenwood', 520.00, 'Canada'); CREATE TABLE Co2Emissions (id INT PRIMARY KEY, forest_id INT, year INT, value DECIMAL(5,2), FOREIGN KEY (forest_id) REFERENCES Forests(id)); INSERT INTO Co2Emissions (id, forest_id, year, value) VALUES (1, 1, 2010, 120.50);
What are the total CO2 emissions for each forest?
SELECT Forests.name, SUM(Co2Emissions.value) as total_co2_emissions FROM Forests INNER JOIN Co2Emissions ON Forests.id = Co2Emissions.forest_id GROUP BY Forests.name;
gretelai_synthetic_text_to_sql
CREATE TABLE finance.profit (product_line VARCHAR(50), month INT, year INT, profit DECIMAL(10,2)); INSERT INTO finance.profit (product_line, month, year, profit) VALUES ('Product Line A', 1, 2022, 2000.00), ('Product Line A', 2, 2022, 4000.00), ('Product Line B', 1, 2022, 3000.00), ('Product Line B', 2, 2022, 5000.00);
What is the total profit for each product line in the 'finance' schema?
SELECT product_line, SUM(profit) as total_profit FROM finance.profit GROUP BY product_line;
gretelai_synthetic_text_to_sql
CREATE TABLE conventional_farms (farmer_id INT, farm_name VARCHAR(50), location VARCHAR(50), area_ha FLOAT); INSERT INTO conventional_farms (farmer_id, farm_name, location, area_ha) VALUES (1, 'Farm 2', 'Location 2', 12.3), (2, 'Farm 3', 'Location 3', 18.5), (3, 'Farm 4', 'Location 4', 21.7);
What is the average area (in hectares) of farmland per farmer in the 'conventional_farms' table?
SELECT AVG(area_ha) FROM conventional_farms;
gretelai_synthetic_text_to_sql
CREATE TABLE hospitals (name TEXT, region TEXT, patient_satisfaction_score INT); INSERT INTO hospitals (name, region, patient_satisfaction_score) VALUES ('Hospital A', 'Rural Southeast', 88), ('Hospital B', 'Rural Southeast', 75), ('Hospital C', 'Rural Northeast', 90);
How many hospitals are there in the rural southeast region with a patient satisfaction score greater than 85?
SELECT COUNT(*) FROM hospitals WHERE region = 'Rural Southeast' AND patient_satisfaction_score > 85;
gretelai_synthetic_text_to_sql
CREATE SCHEMA IF NOT EXISTS arctic_db; CREATE TABLE IF NOT EXISTS arctic_researchers (id INT PRIMARY KEY, researcher_name TEXT, expertise TEXT);
Add new researchers to the arctic_researchers table
INSERT INTO arctic_researchers (id, researcher_name, expertise) VALUES (1, 'Alice Johnson', 'climate change'), (2, 'Bob Smith', 'biodiversity');
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, org_id INT, donation DECIMAL(10,2)); CREATE TABLE organizations (id INT, name TEXT, region TEXT); INSERT INTO donations (id, org_id, donation) VALUES (1, 1, 50.00), (2, 1, 75.00), (3, 2, 100.00), (4, 2, 125.00), (5, 3, 25.00), (6, 3, 50.00); INSERT INTO organizations (id, name, region) VALUES (1, 'Habitat for Humanity', 'Southeast'), (2, 'Red Cross', 'Southeast'), (3, 'UNICEF', 'Northeast');
What is the total amount donated to each organization in the Southeast region?
SELECT o.name, SUM(d.donation) AS total_donations FROM donations d JOIN organizations o ON d.org_id = o.id WHERE o.region = 'Southeast' GROUP BY o.name;
gretelai_synthetic_text_to_sql
CREATE TABLE violations (violation_id INT, report_date DATE, region TEXT, description TEXT); INSERT INTO violations (violation_id, report_date, region, description) VALUES (1, '2022-01-15', 'Asia', 'Child labor accusation');
How many ethical labor practice violations were reported in Asia in the last 6 months?
SELECT COUNT(*) FROM violations WHERE report_date >= DATEADD(month, -6, CURRENT_DATE) AND region = 'Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE products (id INT, name VARCHAR(255), category VARCHAR(255), price DECIMAL(10, 2)); INSERT INTO products (id, name, category, price) VALUES (1, 'Nourishing Face Cream', 'Organic', 25.99), (2, 'Revitalizing Serum', 'Natural', 34.99), (3, 'Soothing Eye Cream', 'Organic', 19.99);
What is the name and price of the most expensive product in the 'Natural' category?
SELECT name, price FROM products WHERE category = 'Natural' ORDER BY price DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE communications (id INT, project_id INT, communication_type VARCHAR(50), message TEXT, date DATE); INSERT INTO communications (id, project_id, communication_type, message, date) VALUES (1, 1, 'Press Release', 'Solar Farm Completed', '2022-01-05'), (2, 2, 'Email', 'Meeting Invitation', '2022-04-10'); CREATE TABLE projects (id INT, name VARCHAR(100), location VARCHAR(100)); INSERT INTO projects (id, name, location) VALUES (1, 'Coastal Protection', 'Florida'), (2, 'Wind Farm', 'Texas');
Which communication types have been used in the coastal protection project?
SELECT communication_type FROM communications WHERE project_id = (SELECT id FROM projects WHERE name = 'Coastal Protection');
gretelai_synthetic_text_to_sql
CREATE TABLE Rural_Hotels (hotel_id INT, hotel_name TEXT, rating INT); INSERT INTO Rural_Hotels (hotel_id, hotel_name, rating) VALUES (1, 'Forest Retreat', 5), (2, 'Mountain Escape', 4);
How many 5-star hotels are there in the 'Rural_Hotels' table?
SELECT COUNT(*) FROM Rural_Hotels WHERE rating = 5;
gretelai_synthetic_text_to_sql
CREATE TABLE wildlife_habitat (id INT, name VARCHAR(50), area FLOAT); INSERT INTO wildlife_habitat (id, name, area) VALUES (1, 'Habitat1', 150.3), (2, 'Habitat2', 250.8), (3, 'Habitat3', 175.5);
What is the total area of all wildlife habitats in square kilometers?
SELECT SUM(area) FROM wildlife_habitat;
gretelai_synthetic_text_to_sql
CREATE TABLE users (user_id INT); INSERT INTO users (user_id) VALUES (1), (2); CREATE TABLE posts (post_id INT, user_id INT, likes INT); INSERT INTO posts (post_id, user_id, likes) VALUES (1, 1, 100), (2, 1, 200), (3, 2, 50);
Insert a new post with post_id 3 and 75 likes for user_id 2.
INSERT INTO posts (post_id, user_id, likes) VALUES (3, 2, 75);
gretelai_synthetic_text_to_sql
CREATE TABLE labor_hours (labor_id INT, city VARCHAR(20), year INT, hours_worked INT); INSERT INTO labor_hours (labor_id, city, year, hours_worked) VALUES (1, 'Los Angeles', 2019, 1500000), (2, 'Los Angeles', 2018, 1400000), (3, 'New York', 2019, 1200000), (4, 'Los Angeles', 2020, 1600000);
What is the maximum number of construction labor hours worked in a year in the city of Los Angeles?
SELECT city, MAX(hours_worked) FROM labor_hours GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE project_milestones (project_id INT, milestone VARCHAR(50), due_date DATE);
Create a table named 'project_milestones' with columns 'project_id', 'milestone', 'due_date'
CREATE TABLE project_milestones (project_id INT, milestone VARCHAR(50), due_date DATE);
gretelai_synthetic_text_to_sql
CREATE TABLE Contractors (id INT, name TEXT, permits INT);CREATE VIEW Contractor_Permits AS SELECT contractor_id, COUNT(*) as num_permits FROM Building_Permits GROUP BY contractor_id;
Who are the top 5 contractors by number of permits in Texas?
SELECT name, SUM(num_permits) as total_permits FROM Contractor_Permits JOIN Contractors ON Contractor_Permits.contractor_id = Contractors.id GROUP BY name ORDER BY total_permits DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE BudgetAllocation (department VARCHAR(20), budget INT);
Insert a new record of a new budget allocation for the 'Waste Management' department in the 'BudgetAllocation' table
INSERT INTO BudgetAllocation (department, budget) VALUES ('Waste Management', 600000);
gretelai_synthetic_text_to_sql
CREATE TABLE safety_tests (id INT, test_date DATE); INSERT INTO safety_tests (id, test_date) VALUES (1, '2022-01-15'), (2, '2022-02-12'), (3, '2022-03-17'), (4, '2022-04-05'), (5, '2022-05-03'), (6, '2022-06-10'), (7, '2022-07-01'), (8, '2022-08-14'), (9, '2022-09-28'), (10, '2022-10-06'), (11, '2022-11-19'), (12, '2022-12-25');
Find the total number of safety tests conducted per quarter
SELECT EXTRACT(QUARTER FROM test_date) as quarter, COUNT(*) as tests_per_quarter FROM safety_tests GROUP BY quarter;
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (DonationID INT, DonationAmount INT, DonorID INT, DonationDate DATE); INSERT INTO Donations (DonationID, DonationAmount, DonorID, DonationDate) VALUES (1, 100, 1, '2022-01-01'), (2, 200, 2, '2021-05-15');
What is the average number of donations per donor?
SELECT AVG(DonationCount) FROM (SELECT DonorID, COUNT(DonationID) AS DonationCount FROM Donations GROUP BY DonorID) AS Subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE shipments (id INT, origin_region VARCHAR(255), destination_continent VARCHAR(255), weight FLOAT); INSERT INTO shipments (id, origin_region, destination_continent, weight) VALUES (1, 'Southeast Asia', 'Oceania', 900.0), (2, 'Southeast Asia', 'Oceania', 700.0);
What is the total weight of shipments from Southeast Asia to Oceania?
SELECT SUM(weight) FROM shipments WHERE origin_region = 'Southeast Asia' AND destination_continent = 'Oceania';
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_energy (country TEXT, consumption FLOAT); INSERT INTO renewable_energy (country, consumption) VALUES ('China', 1963.73), ('United States', 815.62), ('Brazil', 556.50), ('Germany', 353.34), ('Spain', 275.60), ('India', 245.65), ('Japan', 206.97), ('France', 202.51), ('Canada', 194.51), ('Italy', 168.65); CREATE TABLE energy_efficiency (country TEXT, score FLOAT); INSERT INTO energy_efficiency (country, score) VALUES ('China', 79.8), ('United States', 116.0), ('Brazil', 81.5), ('Germany', 96.5), ('Spain', 95.2), ('India', 65.5), ('Japan', 80.7), ('France', 93.0), ('Canada', 92.5), ('Italy', 87.4);
What is the energy efficiency score for the top 5 countries in renewable energy consumption?
SELECT e.country, e.score FROM (SELECT country FROM renewable_energy ORDER BY consumption DESC LIMIT 5) AS r JOIN energy_efficiency AS e ON r.country = e.country
gretelai_synthetic_text_to_sql
CREATE TABLE ingredients (product_id INT, ingredient_name VARCHAR(50), organic BOOLEAN); INSERT INTO ingredients VALUES (1, 'Water', false), (1, 'Paraben', false), (2, 'Aloe Vera', true), (2, 'Fragrance', false); CREATE TABLE sourcing (product_id INT, country VARCHAR(20), organic BOOLEAN); INSERT INTO sourcing VALUES (1, 'France', false), (2, 'Germany', true); CREATE TABLE products (product_id INT, product_name VARCHAR(100)); INSERT INTO products VALUES (1, 'Mascara'), (2, 'Lipstick');
What is the percentage of organic ingredients in cosmetics produced in France?
SELECT 100.0 * AVG(sourcing.organic) AS percentage FROM ingredients JOIN sourcing ON ingredients.product_id = sourcing.product_id JOIN products ON ingredients.product_id = products.product_id WHERE country = 'France';
gretelai_synthetic_text_to_sql
CREATE TABLE disability_support_programs (id INT, state VARCHAR(255), program_name VARCHAR(255), description VARCHAR(255));
Insert a new support program for the state of New York called "Empowering Disability Services".
INSERT INTO disability_support_programs (id, state, program_name, description) VALUES (4, 'New York', 'Empowering Disability Services', 'Program to empower individuals with disabilities in New York');
gretelai_synthetic_text_to_sql
CREATE TABLE Projects (project_id INT, contractor_id INT, start_date DATE, end_date DATE);
List all projects with a start date in the year 2022 or later from the "Projects" table.
SELECT * FROM Projects WHERE start_date >= '2022-01-01' OR YEAR(start_date) = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE hotel_revenue (id INT, hotel_id INT, region TEXT, quarter INT, revenue FLOAT);
Which hotel in the 'APAC' region had the highest revenue in Q3 2022?
SELECT hotel_id, MAX(revenue) OVER (PARTITION BY region, quarter) as max_revenue FROM hotel_revenue WHERE region = 'APAC' AND quarter = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE drugs (id INT, name VARCHAR(255), category VARCHAR(255)); CREATE TABLE rd_expenditures (id INT, drug_id INT, year INT, amount DECIMAL(10, 2));
What is the minimum R&D expenditure for a specific drug in a certain year?
SELECT MIN(rd_expenditures.amount) FROM rd_expenditures JOIN drugs ON rd_expenditures.drug_id = drugs.id WHERE drugs.name = 'DrugA' AND rd_expenditures.year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (id INT, name VARCHAR(30)); CREATE TABLE Works (id INT, artist_id INT, title VARCHAR(50)); CREATE TABLE Exhibitions (id INT, work_id INT, gallery_id INT, city VARCHAR(20), guest_rating FLOAT, revenue FLOAT); INSERT INTO Exhibitions (id, work_id, gallery_id, city, guest_rating, revenue) VALUES (1, 1, 1, 'New York', 4.5, 6000), (2, 2, 2, 'New York', 4.2, 7000), (3, 3, 3, 'New York', 4.7, 5000);
Find the total number of exhibitions and average guest rating for each artist's works in New York, and rank them in descending order of total number of exhibitions.
SELECT a.name, COUNT(e.id) as total_exhibitions, AVG(e.guest_rating) as avg_guest_rating, RANK() OVER (PARTITION BY a.name ORDER BY COUNT(e.id) DESC) as rank FROM Artists a JOIN Works w ON a.id = w.artist_id JOIN Exhibitions e ON w.id = e.work_id WHERE e.city = 'New York' GROUP BY a.name, rank ORDER BY total_exhibitions DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (species_id INT, species_name VARCHAR(50), ocean_name VARCHAR(50), sighting_date DATE); INSERT INTO marine_species VALUES (1, 'Clownfish', 'Pacific Ocean', '2022-06-15');
Update the sighting_date for species_id 1 to '2022-06-16'.
UPDATE marine_species SET sighting_date = '2022-06-16' WHERE species_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE sustainable_menu_items (menu_item_id INT, menu_item_name VARCHAR(255), sustainable_ingredient BOOLEAN); CREATE TABLE menu_sales (menu_item_id INT, sale_date DATE, quantity INT); INSERT INTO sustainable_menu_items (menu_item_id, menu_item_name, sustainable_ingredient) VALUES (1, 'Quinoa Salad', true), (2, 'Chicken Sandwich', false), (3, 'Tofu Stir Fry', true); INSERT INTO menu_sales (menu_item_id, sale_date, quantity) VALUES (1, '2021-03-01', 55), (1, '2021-03-02', 60), (2, '2021-03-01', 40), (2, '2021-03-02', 35), (3, '2021-03-01', 50), (3, '2021-03-02', 53);
Which sustainable menu items were sold more than 50 times in the month of March 2021?
SELECT menu_item_name, SUM(quantity) as total_quantity FROM menu_sales JOIN sustainable_menu_items ON menu_sales.menu_item_id = sustainable_menu_items.menu_item_id WHERE sustainable_menu_items.sustainable_ingredient = true GROUP BY menu_item_name HAVING total_quantity > 50;
gretelai_synthetic_text_to_sql
CREATE TABLE artists (id INT, name VARCHAR(255), birth_date DATE, gender VARCHAR(50));
How many visual artists are represented in the database, and what is the distribution by their gender?
SELECT COUNT(*) as total_artists, gender FROM artists GROUP BY gender;
gretelai_synthetic_text_to_sql
CREATE TABLE space_debris (debris_id INT, debris_type VARCHAR(50), mass FLOAT); INSERT INTO space_debris (debris_id, debris_type, mass) VALUES (1, 'Fuel Tanks', 350.0); INSERT INTO space_debris (debris_id, debris_type, mass) VALUES (2, 'Instruments', 75.2); INSERT INTO space_debris (debris_id, debris_type, mass) VALUES (3, 'Payload Adapters', 120.5);
Display the total mass of space debris in kg for each debris type
SELECT debris_type, SUM(mass) as total_mass_kg FROM space_debris GROUP BY debris_type;
gretelai_synthetic_text_to_sql
CREATE TABLE customer (customer_id INT, name VARCHAR(255), sector VARCHAR(255)); INSERT INTO customer (customer_id, name, sector) VALUES (1, 'John Doe', 'financial'), (2, 'Jane Smith', 'technology');
What is the total number of customers in the financial sector?
SELECT COUNT(*) FROM customer WHERE sector = 'financial';
gretelai_synthetic_text_to_sql